Migrate away from class-transfomer
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- javascript, nodejs, typescript
調査の方向性
まず Issue 68 と提案されている handlers.ts の例を確認し、その後、Issue で変更が必要になるとされている SDK と生成コードを調査します。camelcase-keys、AJV、json-schema-to-typescript を評価する前に、現在の class-transformer 統合を追跡し、影響を受けるエントリーポイントを特定します。完了条件は、plugin が class-transformer に依存しなくなり、提案されている JavaScript および TypeScript のワークフローをサポートし、必要な SDK と生成コードの変更を含むことです。
索引モデルが issue の本文から書いたものです。
説明
This is a rethought version of my previous ticket https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/issues/68
To resummarize the issues with class-transformer:
- The serialization breaks down in the face of unsupported CloudFormation JSON Schema Features, and increases complexity since JSON Schema features must be manually mapped to the Class Transformer equivalent.
- It ties the implementation to TypeScript's decorators which are soon to be completely deprecated and redesigned entirely, and results in a data model that might be foreign to a lot of JavaScript developers today (outside angular and nestjs)
- Because of the above, it prevents JavaScript from working (though I'd personally always encourage TS over JS) (https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/issues/8)
The project isn't also super alive right now: https://github.com/typestack/class-transformer/issues/1272Possibly no longer as valid, it looks like the projects might be getting new maintainers.
The updated proposal proposes swapping class-transformer with three components:
- The package camelcase-keys to handle the CloudFormation-to-JS object key camelcasing.
- The package AJV to handle validating the incoming event properties, provide friendly(er) error messages, as well as automatic type conversion
- The package json-schema-to-typescript to handle consuming the resource definition and outputting type information for a richer experience.
While a very large change, it would uncouple this plugin from TypeScript and an unmaintained library while hopefully simplifying the Dev UX of developing a resource in typescript.
For example, a simple handler like the template default would become (example greatly appreviated):
// handlers.ts
import { Resource, TypeConfiguration } from "./.generated/models";
import { createResource, ProgressEvent, exceptions } from '@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib';
const { entrypoint, testEntrypoint } = createResource<Resource, TypeConfiguration>({
typeName: Resource.TypeName,
schema: Resource.Schema,
// Type information for all the below is automatically infered
async create({ session, properties, request, logger, typeConfiguration }) {
// Example:
try {
const { apiKey } = typeConfiguration;
const response = await fetch(`https://api.someservice.com`, {
method: 'POST',
headers: { 'x-api-key': apiKey },
body: { ...properties },
});
const { id } = await response.json();
properties.id = id;
// else handle error
} catch(err) {
logger.log(err);
// exceptions module lets CloudFormation know the type of failure that occurred
throw new exceptions.InternalFailure(err.message);
// this can also be done by returning a failed progress event
// return ProgressEvent.failed(HandlerErrorCode.InternalFailure, err.message);
}
return properties;
},
/* more handlers.... */
async list({ properties, typeConfiguration }) {
/* ...some list code... */
// Just return a plain array of models, validate via typescript & ajv
return [/* list of plain old javascript models */];
},
});
export { entrypoint, testEntrypoint };
This also externalizes a lot of concerns unnecessary to the user code, infers a lot more of type information automatically, and makes developing resource types much less mentally onerous allowing developers to focus on business logic.
It would require more work with the SDK and generated code however.
- 主要言語
- TypeScript
- スター
- 46
- フォーク
- 18
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aws-cloudformation/cloudformation-cli-typescript-plugin のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
aws-cloudformation/cloudformation-cli-typescript-plugin#136 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
aws-cloudformation/cloudformation-cli-typescript-plugin#132 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
aws-cloudformation/cloudformation-cli-typescript-plugin#121 · コメント 9 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
aws-cloudformation/cloudformation-cli-typescript-plugin#115 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
aws-cloudformation/cloudformation-cli-typescript-plugin#113 ·
aws-cloudformation/cloudformation-cli-typescript-plugin の issue をすべて見る
似ている issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
Crush オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
ElementsProject/cln-application#167 · コメント 1 件 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Quantco/pnpm-licenses#17 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100