json2jsii
Advanced tools
Comparing version 0.1.103 to 0.1.104
@@ -5,2 +5,9 @@ # Changelog | ||
### 0.1.104 (2020-11-16) | ||
### Features | ||
* type aliases ([#183](https://github.com/aws/json2jsii/issues/183)) ([d39695d](https://github.com/aws/json2jsii/commit/d39695dcdef3a6cee0723b28d0d85e1868a56200)), closes [awslabs/cdk8s#370](https://github.com/awslabs/cdk8s/issues/370) | ||
### 0.1.103 (2020-11-16) | ||
@@ -7,0 +14,0 @@ |
@@ -37,14 +37,45 @@ import { JSONSchema4 } from 'json-schema'; | ||
/** | ||
* Emit a type based on a JSON schema. | ||
* Adds a JSON schema definition for a type name. This method does not emit the type | ||
* but rather just registers the definition that will get resolved if this type is `$ref`ed. | ||
* | ||
* @param typeName The name of the type. | ||
* @param def The JSON schema definition for this type | ||
*/ | ||
addDefinition(typeName: string, def: JSONSchema4): void; | ||
/** | ||
* Overrides the definition of `fromTypeName` such that any references to it | ||
* will be resolved as `toTypeName`. Bear in mind that the type name specified | ||
* in `to` must either be defined as a definition (`addDefinition()`) _or_ | ||
* emitted as a custom type (`emitCustomType()`). | ||
*/ | ||
addAlias(from: string, to: string): void; | ||
/** | ||
* Emit a type based on a JSON schema. If `def` is not specified, the | ||
* definition of the type will be looked up in the `definitions` provided | ||
* during initialization or via `addDefinition()`. | ||
* | ||
* @param typeName The name of th type | ||
* @param def JSON schema | ||
* @param def JSON schema. If not specified, the schema is looked up from | ||
* `definitions` based on the type name | ||
* @param structFqn FQN for the type (defaults to `typeName`) | ||
* @returns The resolved type (not always the same as `typeName`) | ||
*/ | ||
addType(typeName: string, def: JSONSchema4, structFqn?: string): string; | ||
emitType(typeName: string, def?: JSONSchema4, structFqn?: string): string; | ||
/** | ||
* Emits code once to the output file. | ||
* @param uniqueid A unique identifier for the code snippet (e.g. the name of the type) | ||
* @param codeEmitter A function that will be called to emit the code. | ||
* Registers a custom type and emits it. This will override any existing | ||
* definitions for this type name. | ||
* | ||
* @param typeName The name of the type emitted by this handler. | ||
* @param emitter A function that will be called to emit the code. | ||
*/ | ||
addCode(uniqueid: string, codeEmitter: (code: Code) => void): void; | ||
emitCustomType(typeName: string, emitter: (code: Code) => void): void; | ||
/** | ||
* @deprecated use `emitCustomType()` | ||
*/ | ||
addCode(typeName: string, codeEmitter: (code: Code) => void): void; | ||
/** | ||
* Renders all emitted types to a string. | ||
* | ||
* Use `renderToCode()` in order to render output to an existing `Code` object. | ||
*/ | ||
render(): string; | ||
@@ -56,4 +87,12 @@ /** | ||
*/ | ||
renderToCode(code: Code): void; | ||
/** | ||
* @deprecated use `renderToCode()` | ||
*/ | ||
emitCode(code: Code): void; | ||
/** | ||
* @deprecated use `emitType()` | ||
*/ | ||
addType(typeName: string, def?: JSONSchema4, structFqn?: string): string; | ||
/** | ||
* @returns true if this definition can be represented as a union or false if it cannot | ||
@@ -60,0 +99,0 @@ */ |
@@ -23,3 +23,6 @@ "use strict"; | ||
this.exclude = (_a = options.exclude) !== null && _a !== void 0 ? _a : []; | ||
this.definitions = (_b = options.definitions) !== null && _b !== void 0 ? _b : {}; | ||
this.definitions = {}; | ||
for (const [typeName, def] of Object.entries((_b = options.definitions) !== null && _b !== void 0 ? _b : {})) { | ||
this.addDefinition(typeName, def); | ||
} | ||
} | ||
@@ -49,8 +52,38 @@ /** | ||
/** | ||
* Emit a type based on a JSON schema. | ||
* Adds a JSON schema definition for a type name. This method does not emit the type | ||
* but rather just registers the definition that will get resolved if this type is `$ref`ed. | ||
* | ||
* @param typeName The name of the type. | ||
* @param def The JSON schema definition for this type | ||
*/ | ||
addDefinition(typeName, def) { | ||
this.definitions[typeName] = def; | ||
} | ||
/** | ||
* Overrides the definition of `fromTypeName` such that any references to it | ||
* will be resolved as `toTypeName`. Bear in mind that the type name specified | ||
* in `to` must either be defined as a definition (`addDefinition()`) _or_ | ||
* emitted as a custom type (`emitCustomType()`). | ||
*/ | ||
addAlias(from, to) { | ||
this.addDefinition(from, { $ref: `#/definitions/${to}` }); | ||
} | ||
/** | ||
* Emit a type based on a JSON schema. If `def` is not specified, the | ||
* definition of the type will be looked up in the `definitions` provided | ||
* during initialization or via `addDefinition()`. | ||
* | ||
* @param typeName The name of th type | ||
* @param def JSON schema | ||
* @param def JSON schema. If not specified, the schema is looked up from | ||
* `definitions` based on the type name | ||
* @param structFqn FQN for the type (defaults to `typeName`) | ||
* @returns The resolved type (not always the same as `typeName`) | ||
*/ | ||
addType(typeName, def, structFqn = typeName) { | ||
emitType(typeName, def, structFqn = typeName) { | ||
if (!def) { | ||
def = this.definitions[typeName]; | ||
if (!def) { | ||
throw new Error(`unable to find schema definition for ${typeName}`); | ||
} | ||
} | ||
// callers expect that emit a type named `typeName` so we can't change it here | ||
@@ -110,15 +143,28 @@ // but at least we can verify it's correct. | ||
/** | ||
* Emits code once to the output file. | ||
* @param uniqueid A unique identifier for the code snippet (e.g. the name of the type) | ||
* @param codeEmitter A function that will be called to emit the code. | ||
* Registers a custom type and emits it. This will override any existing | ||
* definitions for this type name. | ||
* | ||
* @param typeName The name of the type emitted by this handler. | ||
* @param emitter A function that will be called to emit the code. | ||
*/ | ||
addCode(uniqueid, codeEmitter) { | ||
if (this.emittedTypes.has(uniqueid)) { | ||
emitCustomType(typeName, emitter) { | ||
if (this.emittedTypes.has(typeName)) { | ||
return; | ||
} | ||
this.typesToEmit[uniqueid] = codeEmitter; | ||
this.typesToEmit[typeName] = emitter; | ||
} | ||
/** | ||
* @deprecated use `emitCustomType()` | ||
*/ | ||
addCode(typeName, codeEmitter) { | ||
return this.emitCustomType(typeName, codeEmitter); | ||
} | ||
/** | ||
* Renders all emitted types to a string. | ||
* | ||
* Use `renderToCode()` in order to render output to an existing `Code` object. | ||
*/ | ||
render() { | ||
const code = new code_1.Code(); | ||
this.emitCode(code); | ||
this.renderToCode(code); | ||
return code.render(); | ||
@@ -131,3 +177,3 @@ } | ||
*/ | ||
emitCode(code) { | ||
renderToCode(code) { | ||
while (Object.keys(this.typesToEmit).length) { | ||
@@ -143,2 +189,14 @@ const name = Object.keys(this.typesToEmit)[0]; | ||
/** | ||
* @deprecated use `renderToCode()` | ||
*/ | ||
emitCode(code) { | ||
return this.renderToCode(code); | ||
} | ||
/** | ||
* @deprecated use `emitType()` | ||
*/ | ||
addType(typeName, def, structFqn = typeName) { | ||
return this.emitType(typeName, def, structFqn); | ||
} | ||
/** | ||
* @returns true if this definition can be represented as a union or false if it cannot | ||
@@ -250,3 +308,3 @@ */ | ||
const subtype = TypeGenerator.normalizeTypeName(propertyFqn.split('.').map(x => pascalCase(x)).join('')); | ||
return this.addType(subtype, def, subtype); | ||
return this.emitType(subtype, def, subtype); | ||
} | ||
@@ -263,4 +321,8 @@ typeForRef(def) { | ||
const typeName = TypeGenerator.normalizeTypeName(comps[comps.length - 1]); | ||
// if we already emitted a type with this type name, just return it | ||
if (this.emittedTypes.has(typeName)) { | ||
return typeName; | ||
} | ||
const schema = this.resolveReference(def); | ||
return this.addType(typeName, schema, def.$ref); | ||
return this.emitType(typeName, schema, def.$ref); | ||
} | ||
@@ -305,2 +367,2 @@ typeForArray(propertyFqn, def) { | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZS1nZW5lcmF0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZS1nZW5lcmF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsdUNBQXVDO0FBRXZDLDJDQUF1QztBQUN2QyxpQ0FBOEI7QUFHOUIsTUFBTSxlQUFlLEdBQUcsQ0FBQyxRQUFRLEVBQUUsUUFBUSxFQUFFLFNBQVMsRUFBRSxTQUFTLENBQUMsQ0FBQztBQUNuRSxNQUFNLGtCQUFrQixHQUFHLGdCQUFnQixDQUFDO0FBZ0I1Qzs7R0FFRztBQUNILE1BQWEsYUFBYTtJQStCeEI7Ozs7T0FJRztJQUNILFlBQVksVUFBZ0MsRUFBRzs7UUFWOUIsZ0JBQVcsR0FBNkM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EgZGVmaW5pdGlvbiBmb3IgdGhlICRyZWYgXCIke2xvb2t1cH1cImApO1xuICAgIH1cblxuICAgIHJldHVybiBmb3VuZDtcbiAgfVxuXG4gIHByaXZhdGUgaXNQcm9wZXJ0eVJlcXVpcmVkKHByb3BlcnR5OiBzdHJpbmcsIHN0cnVjdERlZjogSlNPTlNjaGVtYTQpIHtcbiAgICByZXR1cm4gQXJyYXkuaXNBcnJheShzdHJ1Y3REZWYucmVxdWlyZWQpICYmIHN0cnVjdERlZi5yZXF1aXJlZC5pbmNsdWRlcyhwcm9wZXJ0eSk7XG4gIH1cblxuICBwcml2YXRlIGlzRXhjbHVkZWQoZnFuOiBzdHJpbmcpIHtcbiAgICBmb3IgKGNvbnN0IHBhdHRlcm4gb2YgdGhpcy5leGNsdWRlKSB7XG4gICAgICBjb25zdCByZSA9IG5ldyBSZWdFeHAocGF0dGVybik7XG4gICAgICBpZiAocmUudGVzdChmcW4pKSB7XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiBmYWxzZTtcbiAgfVxufVxuXG5mdW5jdGlvbiBzdXBwb3J0ZWRVbmlvbk9wdGlvblR5cGUodHlwZTogYW55KTogdHlwZSBpcyBzdHJpbmcge1xuICByZXR1cm4gdHlwZSAmJiAodHlwZW9mKHR5cGUpID09PSAnc3RyaW5nJyAmJiBQUklNSVRJVkVfVFlQRVMuaW5jbHVkZXModHlwZSkpO1xufVxuXG5mdW5jdGlvbiBwYXNjYWxDYXNlKHM6IHN0cmluZyk6IHN0cmluZyB7XG4gIHJldHVybiBjYW1lbENhc2UocywgeyBwYXNjYWxDYXNlOiB0cnVlIH0pO1xufSJdfQ== | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZS1nZW5lcmF0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZS1nZW5lcmF0b3IudHMiXSwibmFtZX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ZTtcbiAgICAgIH1cbiAgICB9XG5cbiAgICByZXR1cm4gZmFsc2U7XG4gIH1cbn1cblxuZnVuY3Rpb24gc3VwcG9ydGVkVW5pb25PcHRpb25UeXBlKHR5cGU6IGFueSk6IHR5cGUgaXMgc3RyaW5nIHtcbiAgcmV0dXJuIHR5cGUgJiYgKHR5cGVvZih0eXBlKSA9PT0gJ3N0cmluZycgJiYgUFJJTUlUSVZFX1RZUEVTLmluY2x1ZGVzKHR5cGUpKTtcbn1cblxuZnVuY3Rpb24gcGFzY2FsQ2FzZShzOiBzdHJpbmcpOiBzdHJpbmcge1xuICByZXR1cm4gY2FtZWxDYXNlKHMsIHsgcGFzY2FsQ2FzZTogdHJ1ZSB9KTtcbn0iXX0= |
@@ -124,3 +124,3 @@ { | ||
}, | ||
"version": "0.1.103", | ||
"version": "0.1.104", | ||
"jest": { | ||
@@ -127,0 +127,0 @@ "clearMocks": true, |
@@ -27,3 +27,4 @@ # json2jsii | ||
g.addType('Person', { | ||
// definitions can also be added like this: | ||
g.addDefinition('Person', { | ||
required: [ 'name' ], | ||
@@ -42,2 +43,5 @@ properties: { | ||
// this will emit the specified type & recursively all the referenced types. | ||
g.emitType('Person'); | ||
fs.writeFileSync('gen/ts/person.ts', await g.render()); | ||
@@ -91,2 +95,31 @@ ``` | ||
## Use cases | ||
### Type aliases | ||
It is possible to offer an alias to a type definition using `addAlias(from, | ||
to)`. The type generator will resolve any references to the original type with | ||
the alias: | ||
```ts | ||
const gen = new TypeGenerator(); | ||
gen.addDefinition('TypeA', { type: 'object', properties: { ref: { $ref: '#/definitions/TypeB' } } } ); | ||
gen.addDefinition('TypeC', { type: 'object', properties: { field: { type: 'string' } } }); | ||
gen.addAlias('TypeB', 'TypeC'); | ||
gen.emitType('TypeA'); | ||
``` | ||
This will output: | ||
```ts | ||
interface TypeA { | ||
readonly ref: TypeC; | ||
} | ||
interface TypeC { | ||
readonly field: string; | ||
} | ||
``` | ||
## Language bindings | ||
@@ -93,0 +126,0 @@ |
{ | ||
"version": "0.1.103" | ||
"version": "0.1.104" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79421
530
145