Migrate away from class-transfomer
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, nodejs, typescript
- Ambito
- developer-experience, tooling
Direzione di ricerca
Esamina prima l’issue 68 e l’esempio proposto di handlers.ts, poi analizza l’SDK e il codice generato che, secondo l’issue, richiederebbero modifiche. Traccia l’integrazione attuale di class-transformer e individua i punti di ingresso interessati prima di valutare camelcase-keys, AJV e json-schema-to-typescript. Il lavoro è completato quando il plugin non dipende più da class-transformer, supporta il workflow JavaScript e TypeScript proposto e include le modifiche richieste all’SDK e al codice generato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 46
- Fork
- 18
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws-cloudformation/cloudformation-cli-typescript-plugin
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
aws-cloudformation/cloudformation-cli-typescript-plugin#136 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
aws-cloudformation/cloudformation-cli-typescript-plugin#132 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
aws-cloudformation/cloudformation-cli-typescript-plugin#121 · 9 commenti · 1 reazione ·
-
integration tests are brokenAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
aws-cloudformation/cloudformation-cli-typescript-plugin#115 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
aws-cloudformation/cloudformation-cli-typescript-plugin#113 ·
Tutte le issue di aws-cloudformation/cloudformation-cli-typescript-plugin
Issue simili
-
area/frontend good first issue kind/cooldown
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
voidzero-dev/oxc-angular-compiler#511 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
langchain-ai/deepagentsjs#898 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
anomalyco/models.dev#8509 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug documentation P2 UI/UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno