type-crafter 0.17.0 → 0.18.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
|
@@ -21560,7 +21560,8 @@ async function generateAdditionalPropertiesType(typeName, typeInfo, parentTypes)
|
|
|
21560
21560
|
valuePrimitiveType: 'unknown',
|
|
21561
21561
|
valueComposerType: null
|
|
21562
21562
|
},
|
|
21563
|
-
primitives: unknownType.primitives
|
|
21563
|
+
primitives: unknownType.primitives,
|
|
21564
|
+
references: new Set()
|
|
21564
21565
|
};
|
|
21565
21566
|
}
|
|
21566
21567
|
else if (valueIsKeyedAdditionalProperties(typeInfo.additionalProperties)) {
|
|
@@ -21584,7 +21585,10 @@ async function generateAdditionalPropertiesType(typeName, typeInfo, parentTypes)
|
|
|
21584
21585
|
? (generatedValueType.templateInput.arrayNestingDepth ?? 0)
|
|
21585
21586
|
: 0
|
|
21586
21587
|
},
|
|
21587
|
-
primitives: generatedValueType.primitives
|
|
21588
|
+
primitives: generatedValueType.primitives,
|
|
21589
|
+
references: isReferenced
|
|
21590
|
+
? new Set([generatedValueType.templateInput.typeName])
|
|
21591
|
+
: generatedValueType.references
|
|
21588
21592
|
};
|
|
21589
21593
|
}
|
|
21590
21594
|
else if (valueIsTypeInfo(typeInfo.additionalProperties)) {
|
|
@@ -21605,7 +21609,10 @@ async function generateAdditionalPropertiesType(typeName, typeInfo, parentTypes)
|
|
|
21605
21609
|
? (generatedValueType.templateInput.arrayNestingDepth ?? 0)
|
|
21606
21610
|
: 0
|
|
21607
21611
|
},
|
|
21608
|
-
primitives: generatedValueType.primitives
|
|
21612
|
+
primitives: generatedValueType.primitives,
|
|
21613
|
+
references: isReferenced
|
|
21614
|
+
? new Set([generatedValueType.templateInput.typeName])
|
|
21615
|
+
: generatedValueType.references
|
|
21609
21616
|
};
|
|
21610
21617
|
}
|
|
21611
21618
|
return null;
|
|
@@ -21704,6 +21711,7 @@ async function generateObjectType(typeName, typeInfo, parentTypes) {
|
|
|
21704
21711
|
if (additionalPropertiesResult !== null) {
|
|
21705
21712
|
templateInput.additionalProperties = additionalPropertiesResult.templateInput;
|
|
21706
21713
|
primitives.push(...additionalPropertiesResult.primitives);
|
|
21714
|
+
references.push(...additionalPropertiesResult.references);
|
|
21707
21715
|
}
|
|
21708
21716
|
const result = {
|
|
21709
21717
|
content: Runtime.getObjectTemplate()(templateInput) +
|
|
@@ -22573,7 +22581,7 @@ async function runner(language, inputFilePath, outputDirectory, _typesWriterMode
|
|
|
22573
22581
|
}
|
|
22574
22582
|
}
|
|
22575
22583
|
greeting();
|
|
22576
|
-
const program = new Command().version('0.
|
|
22584
|
+
const program = new Command().version('0.18.0');
|
|
22577
22585
|
program
|
|
22578
22586
|
.command('generate')
|
|
22579
22587
|
.description('Generate types for your language from a type spec file')
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
/// {{{description}}}
|
|
3
3
|
{{/if}}
|
|
4
4
|
#[derive({{{appendUnique "Debug, Clone, Serialize, Deserialize" customAttributes.[x-derive]}}})]
|
|
5
|
+
{{#each customAttributes.[x-attributes]}}
|
|
6
|
+
#[{{{this}}}]
|
|
7
|
+
{{/each}}
|
|
5
8
|
pub struct {{typeName}} {
|
|
6
9
|
{{#each compositions}}
|
|
7
10
|
{{#if (eq this.source 'referenced')}}
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
/// Example: {{{example}}}
|
|
6
6
|
{{/if}}
|
|
7
7
|
#[derive({{{appendUnique "Debug, Clone, Serialize, Deserialize" customAttributes.[x-derive]}}})]
|
|
8
|
+
{{#each customAttributes.[x-attributes]}}
|
|
9
|
+
#[{{{this}}}]
|
|
10
|
+
{{/each}}
|
|
8
11
|
pub enum {{typeName}} {
|
|
9
12
|
{{#each values}}
|
|
10
13
|
{{#if (eq ../type 'string')}}
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
/// Example: {{{example}}}
|
|
6
6
|
{{/if}}
|
|
7
7
|
#[derive({{{appendUnique "Debug, Clone, Serialize, Deserialize" customAttributes.[x-derive]}}})]
|
|
8
|
+
{{#each customAttributes.[x-attributes]}}
|
|
9
|
+
#[{{{this}}}]
|
|
10
|
+
{{/each}}
|
|
8
11
|
{{#if customAttributes.renameAll}}
|
|
9
12
|
#[serde(rename_all = "{{{customAttributes.renameAll}}}")]
|
|
10
13
|
{{/if}}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
/// {{{description}}}
|
|
3
3
|
{{/if}}
|
|
4
4
|
#[derive({{{appendUnique "Debug, Clone, Serialize, Deserialize" customAttributes.[x-derive]}}})]
|
|
5
|
+
{{#each customAttributes.[x-attributes]}}
|
|
6
|
+
#[{{{this}}}]
|
|
7
|
+
{{/each}}
|
|
5
8
|
#[serde(untagged)]
|
|
6
9
|
pub enum {{typeName}} {
|
|
7
10
|
{{#each compositions}}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -144,6 +144,7 @@ export type AdditionalPropertiesTemplateInput = {
|
|
|
144
144
|
export type AdditionalPropertiesGenerationResult = {
|
|
145
145
|
templateInput: AdditionalPropertiesTemplateInput;
|
|
146
146
|
primitives: Set<string>;
|
|
147
|
+
references: Set<string>;
|
|
147
148
|
};
|
|
148
149
|
export type ExporterModuleTemplateInput = {
|
|
149
150
|
modules: string[];
|