type-crafter 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -22207,6 +22207,7 @@ async function writeExporterModules(files, folder) {
|
|
|
22207
22207
|
const exporterModuleContent = Runtime.getExporterModuleTemplate()({
|
|
22208
22208
|
modules: [...files]
|
|
22209
22209
|
.map((file) => file.replace(Runtime.getConfig().output.fileExtension, ''))
|
|
22210
|
+
.filter((name) => name !== Runtime.getConfig().language.exporterModuleName)
|
|
22210
22211
|
.sort()
|
|
22211
22212
|
});
|
|
22212
22213
|
const config = Runtime.getConfig();
|
|
@@ -22581,7 +22582,7 @@ async function runner(language, inputFilePath, outputDirectory, _typesWriterMode
|
|
|
22581
22582
|
}
|
|
22582
22583
|
}
|
|
22583
22584
|
greeting();
|
|
22584
|
-
const program = new Command().version('0.
|
|
22585
|
+
const program = new Command().version('0.19.0');
|
|
22585
22586
|
program
|
|
22586
22587
|
.command('generate')
|
|
22587
22588
|
.description('Generate types for your language from a type spec file')
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
decode{{{toPascalCase composerType}}}
|
|
6
6
|
{{~/if~}}
|
|
7
7
|
{{/inline}}
|
|
8
|
+
{{#*inline "composerClassName"}}C{{#if (eq prefix false)}}{{else if (eq prefix "")}}{{else if prefix}}{{prefix}}{{else}}{{typeName}}{{/if}}{{member}}{{/inline}}
|
|
8
9
|
export type {{typeName}} =
|
|
9
10
|
{{#each compositions}}
|
|
10
|
-
| {{#if (eq this.source 'referenced')}}
|
|
11
|
+
| {{#if (eq this.source 'referenced')}}{{> composerClassName typeName=../typeName member=this.referencedType prefix=../customAttributes.[x-class-name-prefix]}}
|
|
11
12
|
{{else if (eq this.source 'inline')}}
|
|
12
13
|
{{#if this.templateInput.values}}
|
|
13
14
|
{{this.templateInput.typeName}}
|
|
14
|
-
{{else if (eq this.dataType 'object')}}
|
|
15
|
-
C{{typeName}}{{this.templateInput.typeName}}
|
|
15
|
+
{{else if (eq this.dataType 'object')}}{{> composerClassName typeName=../typeName member=this.templateInput.typeName prefix=../customAttributes.[x-class-name-prefix]}}
|
|
16
16
|
{{else}}
|
|
17
17
|
{{this.templateInput.type}}
|
|
18
18
|
{{/if}}
|
|
@@ -24,7 +24,7 @@ export function decode{{typeName}}(rawInput: unknown): {{typeName}} | null {
|
|
|
24
24
|
const result: {{typeName}} | null =
|
|
25
25
|
{{#each compositions}}
|
|
26
26
|
{{#if (eq this.source 'referenced')}}
|
|
27
|
-
|
|
27
|
+
decode{{> composerClassName typeName=../typeName member=this.referencedType prefix=../customAttributes.[x-class-name-prefix]}}(rawInput)
|
|
28
28
|
{{else if (eq this.dataType 'object')}}
|
|
29
29
|
decodeC{{this.templateInput.typeName}}(rawInput)
|
|
30
30
|
{{else if (eq this.dataType 'array')}}
|
|
@@ -45,7 +45,7 @@ export function decode{{typeName}}(rawInput: unknown): {{typeName}} | null {
|
|
|
45
45
|
{{#if this.templateInput.values}}
|
|
46
46
|
{{{this.content}}}
|
|
47
47
|
{{else if (eq this.source 'referenced')}}
|
|
48
|
-
export class
|
|
48
|
+
export class {{> composerClassName typeName=../typeName member=this.referencedType prefix=../customAttributes.[x-class-name-prefix]}} {
|
|
49
49
|
data: {{referencedType}};
|
|
50
50
|
constructor(data: {{referencedType}}) {
|
|
51
51
|
this.data = data;
|
|
@@ -53,12 +53,12 @@ export class C{{../typeName}}{{referencedType}} {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
{{#unless ../customAttributes.skipDecoderGeneration}}
|
|
56
|
-
export function
|
|
56
|
+
export function decode{{> composerClassName typeName=../typeName member=this.referencedType prefix=../customAttributes.[x-class-name-prefix]}}(rawInput: unknown): {{> composerClassName typeName=../typeName member=this.referencedType prefix=../customAttributes.[x-class-name-prefix]}} | null {
|
|
57
57
|
const result = decode{{referencedType}}(rawInput);
|
|
58
58
|
if (result === null) {
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
|
-
return new
|
|
61
|
+
return new {{> composerClassName typeName=../typeName member=this.referencedType prefix=../customAttributes.[x-class-name-prefix]}}(result);
|
|
62
62
|
}
|
|
63
63
|
{{/unless}}
|
|
64
64
|
|
|
@@ -66,7 +66,7 @@ export function decodeC{{../typeName}}{{referencedType}}(rawInput: unknown): C{{
|
|
|
66
66
|
|
|
67
67
|
{{{this.content}}}
|
|
68
68
|
|
|
69
|
-
export class
|
|
69
|
+
export class {{> composerClassName typeName=../typeName member=this.templateInput.typeName prefix=../customAttributes.[x-class-name-prefix]}} {
|
|
70
70
|
data: {{this.templateInput.typeName}};
|
|
71
71
|
constructor(data: {{this.templateInput.typeName}}) {
|
|
72
72
|
this.data = data;
|
|
@@ -79,7 +79,7 @@ export function decodeC{{this.templateInput.typeName}}(rawInput: unknown) {
|
|
|
79
79
|
if (result === null) {
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
|
-
return new
|
|
82
|
+
return new {{> composerClassName typeName=../typeName member=this.templateInput.typeName prefix=../customAttributes.[x-class-name-prefix]}}(result);
|
|
83
83
|
}
|
|
84
84
|
{{/unless}}
|
|
85
85
|
|