Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add runtime config generation, refactor delegation
This change adds support for generting client runtime configs and dependencies. It required that arbitrary TypeScript files could be written that aren't specific to a shape being generated, so TypeScriptIntegration and CodeWriterDelegator were refactored to support delegating and intercepting the creation of arbitrary files. The idea of a generic CodeWriterDelegator was scrapped in favor of just making a custom flyweight factory style delegator for TypeScript. This simplified how everything works, but it does mean that other language implementations will likely need similar but slightly different abstractions. This can potentially be revisited in the future if needed. TypeScriptIntegration was updated to allow the *creation* of a TypeScriptWriter to be intercepted separate from the *use* of a writer for the purpose of generating a shape. The creation hook can be used to add custom interceptors, license headers, etc. The use hook can be used to modify how a shape is generated, and the callback actually has the context as to which shape is being generated (and it handles de-registering any interceptors of mutations made to the writer once the callback has exited). Because the runtime config needs to know more information about the application protocol like if it's HTTP or not, I added methods that are meant to answer the basic question of if a protocol is HTTP based, MQTT based, etc. There's potential here for describing protocol characteristics in Smithy's core libraries, but that can be revisited later as we roll out more generators. The code for generating the filename of a Symbol we overly complicated for some reason. I simplified it by removing the pointless code and just appending ".ts" to the namespace of a Symbol. The TypeScriptWriter now gracefully handles formatting imports when there are imports explicitly written to the writer in addition to imports that are managed by the writer.
- Loading branch information