type-crafter 0.6.1 → 0.8.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
@@ -3533,9 +3533,20 @@ function decodeTypes(rawInput) {
3533
3533
  }
3534
3534
  return null;
3535
3535
  }
3536
+ function decodeAdditionalPropertiesKeyType(rawInput) {
3537
+ if (typeof rawInput === 'string') {
3538
+ switch (rawInput) {
3539
+ case 'string':
3540
+ case 'number':
3541
+ return rawInput;
3542
+ }
3543
+ }
3544
+ return null;
3545
+ }
3536
3546
  function decodeTypeInfo(rawInput) {
3537
3547
  if (isJSON(rawInput)) {
3538
3548
  const _type = decodeTypeDataType(rawInput.type);
3549
+ const additionalProperties = decodeAdditionalProperties(rawInput.additionalProperties);
3539
3550
  const result = {
3540
3551
  type: _type,
3541
3552
  required: decodeArray(rawInput.required, decodeString),
@@ -3547,6 +3558,8 @@ function decodeTypeInfo(rawInput) {
3547
3558
  description: decodeString(rawInput.description),
3548
3559
  example: decodeString(rawInput.example) ?? decodeNumber(rawInput.example),
3549
3560
  oneOf: decodeArray(rawInput.oneOf, decodeTypeInfo),
3561
+ allOf: decodeArray(rawInput.allOf, decodeTypeInfo),
3562
+ additionalProperties,
3550
3563
  enum: _type === 'string'
3551
3564
  ? decodeArray(rawInput.enum, decodeString)
3552
3565
  : _type === 'number'
@@ -3557,6 +3570,28 @@ function decodeTypeInfo(rawInput) {
3557
3570
  }
3558
3571
  return null;
3559
3572
  }
3573
+ function decodeAdditionalProperties(rawInput) {
3574
+ return (decodeKeyedAdditionalProperties(rawInput) ?? decodeTypeInfo(rawInput) ?? decodeBoolean(rawInput));
3575
+ }
3576
+ function decodeKeyedAdditionalProperties(rawInput) {
3577
+ if (isJSON(rawInput)) {
3578
+ const keyType = decodeAdditionalPropertiesKeyType(rawInput.keyType);
3579
+ const valueType = decodeTypeInfo(rawInput.valueType);
3580
+ if (keyType !== null && valueType !== null) {
3581
+ return {
3582
+ keyType,
3583
+ valueType
3584
+ };
3585
+ }
3586
+ }
3587
+ return null;
3588
+ }
3589
+ function valueIsKeyedAdditionalProperties(value) {
3590
+ return decodeKeyedAdditionalProperties(value) !== null;
3591
+ }
3592
+ function valueIsTypeInfo(value) {
3593
+ return decodeTypeInfo(value) !== null;
3594
+ }
3560
3595
  function decodeTypeProperties(rawInput) {
3561
3596
  if (isJSON(rawInput)) {
3562
3597
  const result = {};
@@ -11948,6 +11983,7 @@ let exporterModuleSyntaxTemplate = null;
11948
11983
  let typesFileSyntaxTemplate = null;
11949
11984
  let oneOfSyntaxTemplate = null;
11950
11985
  let enumSyntaxTemplate = null;
11986
+ let allOfSyntaxTemplate = null;
11951
11987
  const cachedReferencedTypes = new Map();
11952
11988
  let expectedOutputFiles = null;
11953
11989
  function setConfig(newConfig) {
@@ -11975,6 +12011,7 @@ function compileTemplates() {
11975
12011
  typesFileSyntaxTemplate = Handlebars.compile(config.template.typesFileSyntax);
11976
12012
  enumSyntaxTemplate = Handlebars.compile(config.template.enumSyntax);
11977
12013
  oneOfSyntaxTemplate = Handlebars.compile(config.template.oneOfSyntax);
12014
+ allOfSyntaxTemplate = Handlebars.compile(config.template.allOfSyntax);
11978
12015
  }
11979
12016
  function getObjectTemplate() {
11980
12017
  if (objectSyntaxTemplate === null) {
@@ -12030,6 +12067,12 @@ function getInputFilePath(absolutePath = true) {
12030
12067
  }
12031
12068
  return absolutePath ? resolveFilePath(config$2.input) : config$2.input;
12032
12069
  }
12070
+ function getAllOfTemplate() {
12071
+ if (allOfSyntaxTemplate === null) {
12072
+ throw new RuntimeError('AllOf template not compiled!');
12073
+ }
12074
+ return allOfSyntaxTemplate;
12075
+ }
12033
12076
  var Runtime = {
12034
12077
  getConfig,
12035
12078
  setConfig,
@@ -12046,7 +12089,8 @@ var Runtime = {
12046
12089
  getCachedReferencedTypes,
12047
12090
  getCachedReferenceType,
12048
12091
  cacheReferenceType,
12049
- getInputFilePath
12092
+ getInputFilePath,
12093
+ getAllOfTemplate
12050
12094
  };
12051
12095
 
12052
12096
  const ALIAS = Symbol.for('yaml.alias');
@@ -19647,6 +19691,21 @@ function fillPatterns(input, patterns) {
19647
19691
  return result;
19648
19692
  }
19649
19693
 
19694
+ const placeholderTypeInfo = {
19695
+ required: null,
19696
+ type: null,
19697
+ format: null,
19698
+ items: null,
19699
+ properties: null,
19700
+ $ref: null,
19701
+ oneOf: null,
19702
+ allOf: null,
19703
+ enum: null,
19704
+ additionalProperties: null,
19705
+ summary: null,
19706
+ description: null,
19707
+ example: null
19708
+ };
19650
19709
  /**
19651
19710
  * @description Generates the primitive type for the unit attribute in the spec.
19652
19711
  * @param typeName { string }
@@ -19688,6 +19747,39 @@ function getPrimitiveType(typeName, typeInfo) {
19688
19747
  result.primitives.add(languageDataType);
19689
19748
  return result;
19690
19749
  }
19750
+ async function generateAdditionalPropertiesType(typeName, typeInfo, parentTypes) {
19751
+ let result = null;
19752
+ const stringKeyType = getPrimitiveType(typeName, {
19753
+ ...placeholderTypeInfo,
19754
+ type: 'string'
19755
+ }).templateInput.type;
19756
+ if (typeof typeInfo.additionalProperties === 'boolean') {
19757
+ result = {
19758
+ keyType: stringKeyType,
19759
+ valueType: getPrimitiveType(typeName, {
19760
+ ...placeholderTypeInfo,
19761
+ type: 'unknown'
19762
+ }).templateInput.type
19763
+ };
19764
+ }
19765
+ else if (valueIsKeyedAdditionalProperties(typeInfo.additionalProperties)) {
19766
+ result = {
19767
+ keyType: getPrimitiveType(typeName, {
19768
+ ...placeholderTypeInfo,
19769
+ type: typeInfo.additionalProperties.keyType
19770
+ }).templateInput.type,
19771
+ valueType: (await generateType(typeName + 'ValueType', typeInfo.additionalProperties.valueType, parentTypes)).templateInput.type
19772
+ };
19773
+ }
19774
+ else if (valueIsTypeInfo(typeInfo.additionalProperties)) {
19775
+ const valueType = await generateType(typeName + 'ValueType', typeInfo.additionalProperties, parentTypes);
19776
+ result = {
19777
+ keyType: stringKeyType,
19778
+ valueType: valueType.templateInput.type
19779
+ };
19780
+ }
19781
+ return result;
19782
+ }
19691
19783
  async function generateObjectType(typeName, typeInfo, parentTypes) {
19692
19784
  const templateInput = {
19693
19785
  typeName,
@@ -19708,7 +19800,10 @@ async function generateObjectType(typeName, typeInfo, parentTypes) {
19708
19800
  const reference = propertyDetails.$ref ?? null;
19709
19801
  const enumValues = propertyDetails.enum ?? null;
19710
19802
  // Throwing error in case neither property type nor reference to a different type is present
19711
- if (propertyType === null && reference === null && propertyDetails.oneOf === null) {
19803
+ if (propertyType === null &&
19804
+ reference === null &&
19805
+ propertyDetails.oneOf === null &&
19806
+ propertyDetails.additionalProperties === null) {
19712
19807
  throw new InvalidSpecFileError('Invalid property type for: ' + typeName + '.' + propertyName);
19713
19808
  }
19714
19809
  const primitiveType = propertyType ?? 'object';
@@ -19767,6 +19862,11 @@ async function generateObjectType(typeName, typeInfo, parentTypes) {
19767
19862
  }
19768
19863
  };
19769
19864
  }
19865
+ // Generating additional property types
19866
+ const additionalProperties = await generateAdditionalPropertiesType(typeName + 'AdditionalProperty', typeInfo, parentTypes);
19867
+ if (additionalProperties !== null) {
19868
+ templateInput.additionalProperties = additionalProperties;
19869
+ }
19770
19870
  const result = {
19771
19871
  content: Runtime.getObjectTemplate()(templateInput) +
19772
19872
  (recursiveTypeGenOutput?.content ?? '') +
@@ -19924,6 +20024,58 @@ async function generateOneOfTypes(typeName, typeInfo, parentTypes) {
19924
20024
  result.content = Runtime.getOneOfTemplate()(templateInput);
19925
20025
  return result;
19926
20026
  }
20027
+ async function generateAllOfTypes(typeName, typeInfo, parentTypes) {
20028
+ if (typeInfo.allOf === null || typeInfo.allOf.length === 0) {
20029
+ throw new InvalidSpecFileError('Invalid allOf type for: ' + typeName);
20030
+ }
20031
+ const templateInput = {
20032
+ typeName,
20033
+ type: typeName,
20034
+ compositions: [],
20035
+ description: typeInfo.description,
20036
+ example: typeInfo.example,
20037
+ summary: typeInfo.summary
20038
+ };
20039
+ const result = {
20040
+ content: '',
20041
+ references: new Set(),
20042
+ primitives: new Set(),
20043
+ templateInput
20044
+ };
20045
+ for (let index = 0; index < typeInfo.allOf.length; index++) {
20046
+ const allOfItem = typeInfo.allOf[index];
20047
+ if (allOfItem.$ref !== null) {
20048
+ const referenceData = await resolveTypeReference(allOfItem.$ref);
20049
+ const composition = {
20050
+ source: 'referenced',
20051
+ referencedType: referenceData.name
20052
+ };
20053
+ templateInput.compositions.push(composition);
20054
+ result.references.add(referenceData.name);
20055
+ }
20056
+ else {
20057
+ const generatedType = await generateType(typeName + (index + 1), allOfItem, parentTypes);
20058
+ if (generatedType === null) {
20059
+ throw new InvalidSpecFileError('Invalid allOf type for: ' + typeName);
20060
+ }
20061
+ const composition = {
20062
+ dataType: allOfItem.type,
20063
+ templateInput: generatedType.templateInput,
20064
+ source: 'inline',
20065
+ content: generatedType.content
20066
+ };
20067
+ templateInput.compositions.push(composition);
20068
+ for (const reference of generatedType.references.values()) {
20069
+ result.references.add(reference);
20070
+ }
20071
+ for (const primitive of generatedType.primitives.values()) {
20072
+ result.primitives.add(primitive);
20073
+ }
20074
+ }
20075
+ }
20076
+ result.content = Runtime.getAllOfTemplate()(templateInput);
20077
+ return result;
20078
+ }
19927
20079
  function returnCyclicReference(typeName) {
19928
20080
  const templateInput = {
19929
20081
  typeName,
@@ -19954,6 +20106,9 @@ async function generateType(typeName, typeInfo, parentTypes) {
19954
20106
  if (typeInfo.oneOf !== null) {
19955
20107
  return await generateOneOfTypes(typeName, typeInfo, parentTypes);
19956
20108
  }
20109
+ if (typeInfo.allOf !== null) {
20110
+ return await generateAllOfTypes(typeName, typeInfo, parentTypes);
20111
+ }
19957
20112
  if (typeInfo.type === 'array') {
19958
20113
  return await generateArrayType(typeName, typeInfo, parentTypes);
19959
20114
  }
@@ -20203,6 +20358,7 @@ async function config$1(inputFilePath, outputDirectory, typesWriterMode, grouped
20203
20358
  const typesFileSyntax = await readFile(directoryPrefix + 'templates/typescript/types-file-syntax.hbs', devMode);
20204
20359
  const enumSyntax = await readFile(directoryPrefix + 'templates/typescript/enum-syntax.hbs', devMode);
20205
20360
  const oneOfSyntax = await readFile(directoryPrefix + 'templates/typescript/oneOf-syntax.hbs', devMode);
20361
+ const allOfSyntax = await readFile(directoryPrefix + 'templates/typescript/allOf-syntax.hbs', devMode);
20206
20362
  const config = {
20207
20363
  input: inputFilePath,
20208
20364
  output: {
@@ -20219,7 +20375,8 @@ async function config$1(inputFilePath, outputDirectory, typesWriterMode, grouped
20219
20375
  exporterModuleSyntax,
20220
20376
  typesFileSyntax,
20221
20377
  enumSyntax,
20222
- oneOfSyntax
20378
+ oneOfSyntax,
20379
+ allOfSyntax
20223
20380
  },
20224
20381
  language: {
20225
20382
  exporterModuleName: 'index',
@@ -20245,6 +20402,7 @@ async function config(inputFilePath, outputDirectory, typesWriterMode, groupedTy
20245
20402
  const typesFileSyntax = await readFile(directoryPrefix + 'templates/typescript-with-decoders/types-file-syntax.hbs', devMode);
20246
20403
  const enumSyntax = await readFile(directoryPrefix + 'templates/typescript-with-decoders/enum-syntax.hbs', devMode);
20247
20404
  const oneOfSyntax = await readFile(directoryPrefix + 'templates/typescript-with-decoders/oneOf-syntax.hbs', devMode);
20405
+ const allOfSyntax = await readFile(directoryPrefix + 'templates/typescript-with-decoders/allOf-syntax.hbs', devMode);
20248
20406
  const config = {
20249
20407
  input: inputFilePath,
20250
20408
  output: {
@@ -20261,7 +20419,8 @@ async function config(inputFilePath, outputDirectory, typesWriterMode, groupedTy
20261
20419
  exporterModuleSyntax,
20262
20420
  typesFileSyntax,
20263
20421
  enumSyntax,
20264
- oneOfSyntax
20422
+ oneOfSyntax,
20423
+ allOfSyntax
20265
20424
  },
20266
20425
  language: {
20267
20426
  exporterModuleName: 'index',
@@ -20325,7 +20484,7 @@ async function runner(language, inputFilePath, outputDirectory, _typesWriterMode
20325
20484
  }
20326
20485
  }
20327
20486
  greeting();
20328
- const program = new Command().version('0.6.1');
20487
+ const program = new Command().version('0.8.0');
20329
20488
  program
20330
20489
  .command('generate')
20331
20490
  .description('Generate types for your language from a type spec file')
package/dist/runtime.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Configuration, EnumTemplateInput, ExporterModuleTemplateInput, GeneratedReferencedType, ObjectTemplateInput, OneOfTemplateInput, SpecFileData, TypeFilePath, TypesFileTemplateInput } from '$types';
1
+ import type { AllOfTemplateInput, Configuration, EnumTemplateInput, ExporterModuleTemplateInput, GeneratedReferencedType, ObjectTemplateInput, OneOfTemplateInput, SpecFileData, TypeFilePath, TypesFileTemplateInput } from '$types';
2
2
  declare function setConfig(newConfig: Configuration): void;
3
3
  declare function getConfig(): Configuration;
4
4
  declare function setSpecFileData(newSpecFileData: SpecFileData): void;
@@ -15,6 +15,7 @@ declare function getCachedReferencedTypes(): Map<string, GeneratedReferencedType
15
15
  declare function getCachedReferenceType(referencePath: string): GeneratedReferencedType | null;
16
16
  declare function cacheReferenceType(referencePath: string, generatedData: GeneratedReferencedType): void;
17
17
  declare function getInputFilePath(absolutePath?: boolean): string;
18
+ declare function getAllOfTemplate(): HandlebarsTemplateDelegate<AllOfTemplateInput>;
18
19
  declare const _default: {
19
20
  getConfig: typeof getConfig;
20
21
  setConfig: typeof setConfig;
@@ -32,5 +33,6 @@ declare const _default: {
32
33
  getCachedReferenceType: typeof getCachedReferenceType;
33
34
  cacheReferenceType: typeof cacheReferenceType;
34
35
  getInputFilePath: typeof getInputFilePath;
36
+ getAllOfTemplate: typeof getAllOfTemplate;
35
37
  };
36
38
  export default _default;
@@ -0,0 +1,19 @@
1
+ export type {{typeName}} =
2
+ {{#each compositions}}
3
+ {{#if (eq this.source 'referenced')}}{{referencedType}}
4
+ {{else if (eq this.source 'inline')}}
5
+ {{#if this.templateInput.values}}
6
+ {{this.templateInput.typeName}}
7
+ {{else if (eq this.dataType 'object')}}
8
+ {{this.templateInput.typeName}}
9
+ {{else}}
10
+ {{this.templateInput.type}}
11
+ {{/if}}
12
+ {{/if}} {{#unless @last}} & {{/unless}}
13
+ {{/each}};
14
+
15
+ {{#each compositions}}
16
+ {{#if (eq this.dataType 'object')}}
17
+ {{{this.content}}}
18
+ {{/if}}
19
+ {{/each}}
@@ -21,4 +21,7 @@ export type {{typeName}} = {
21
21
  */
22
22
  {{{jsonKey @key}}}: {{{this.type}}}{{#unless this.required}} | null{{/unless}};
23
23
  {{/each}}
24
+ {{#if additionalProperties}}
25
+ [keys: {{jsonKey additionalProperties.keyType}}]: {{additionalProperties.valueType}};
26
+ {{/if}}
24
27
  };
@@ -4,7 +4,7 @@ export type {{typeName}} =
4
4
  {{else if (eq this.source 'inline')}}
5
5
  {{#if this.templateInput.values}}
6
6
  {{#each this.templateInput.values}}
7
- {{#unless @first}}|{{/unless}} {{#if (eq ../this.templateInput.enumType 'string') }}'{{/if}}{{{this}}}{{#if (eq ../this.templateInput/enumType 'string')}}'{{/if}}
7
+ {{#unless @first}}|{{/unless}} {{#if (eq ../this.templateInput.type 'string') }}'{{/if}}{{{this}}}{{#if (eq ../this.templateInput/type 'string')}}'{{/if}}
8
8
  {{/each}}
9
9
  {{else if (eq this.dataType 'object')}}
10
10
  {
@@ -0,0 +1,42 @@
1
+ export type {{typeName}} =
2
+ {{#each compositions}}
3
+ {{#if (eq this.source 'referenced')}}{{referencedType}}
4
+ {{else if (eq this.source 'inline')}}
5
+ {{#if this.templateInput.values}}
6
+ {{this.templateInput.typeName}}
7
+ {{else if (eq this.dataType 'object')}}
8
+ {{this.templateInput.typeName}}
9
+ {{else}}
10
+ {{this.templateInput.type}}
11
+ {{/if}}
12
+ {{/if}} {{#unless @last}} & {{/unless}}
13
+ {{/each}};
14
+
15
+ {{#each compositions}}
16
+ {{#if (eq this.dataType 'object')}}
17
+ {{{this.content}}}
18
+ {{/if}}
19
+ {{/each}}
20
+
21
+ export function decode{{typeName}}(rawInput: unknown): {{typeName}} | null {
22
+ {{#each compositions}}
23
+ {{#if (eq this.source 'referenced')}}
24
+ const decoded{{referencedType}} = decode{{referencedType}}(rawInput);
25
+ {{else if (eq this.source 'inline')}}
26
+ const decoded{{toPascalCase this.templateInput.typeName}} = decode{{this.templateInput.typeName}}(rawInput);
27
+ {{/if}}
28
+ {{/each}}
29
+
30
+ if (
31
+ {{#each compositions}}decoded{{#if (eq this.source 'referenced')}}{{referencedType}}{{else}}{{toPascalCase this.templateInput.typeName}}{{/if}} !== null {{#unless @last}} && {{/unless}} {{/each}}
32
+ ) {
33
+ return {
34
+ {{#each compositions}}
35
+ {{#if (eq this.source 'referenced')}}...decoded{{referencedType}},
36
+ {{else}}...decoded{{toPascalCase this.templateInput.typeName}},
37
+ {{/if}}
38
+ {{/each}}
39
+ };
40
+ }
41
+ return null;
42
+ }
@@ -21,6 +21,9 @@ export type {{typeName}} = {
21
21
  */
22
22
  {{{jsonKey @key}}}: {{{this.type}}}{{#unless this.required}} | null{{/unless}};
23
23
  {{/each}}
24
+ {{#if additionalProperties}}
25
+ [keys: {{jsonKey additionalProperties.keyType}}]: {{additionalProperties.valueType}};
26
+ {{/if}}
24
27
  };
25
28
 
26
29
  export function decode{{typeName}}(rawInput: unknown): {{typeName}} | null {
@@ -40,6 +43,9 @@ export function decode{{typeName}}(rawInput: unknown): {{typeName}} | null {
40
43
  {{/if}}
41
44
 
42
45
  return {
46
+ {{#if additionalProperties}}
47
+ ...rawInput,
48
+ {{/if}}
43
49
  {{#each properties}}
44
50
  {{{jsonKey @key}}}: decoded{{{variableName @key}}},
45
51
  {{/each}}
@@ -1,9 +1,12 @@
1
- import type { GroupRef, EnumTemplateInput, GroupedTypesWriterMode, ObjectTemplateInputProperties, SpecFileData, TypeInfo, Types, TypesWriterMode, GroupTypesData } from '.';
1
+ import type { GroupRef, EnumTemplateInput, GroupedTypesWriterMode, ObjectTemplateInputProperties, SpecFileData, TypeInfo, Types, TypesWriterMode, GroupTypesData, KeyedAdditionalProperties, AdditionalPropertiesKeyType } from '.';
2
2
  export declare function decodeGroupedTypesWriterMode(rawInput: unknown): GroupedTypesWriterMode | null;
3
3
  export declare function decodeTypesWriterMode(rawInput: unknown): TypesWriterMode | null;
4
4
  export declare function decodeSpecFileData(rawInput: unknown): SpecFileData | null;
5
5
  export declare function valueIsGroupRef(value: GroupTypesData): value is GroupRef;
6
6
  export declare function decodeTypes(rawInput: unknown): Types | null;
7
+ export declare function decodeAdditionalPropertiesKeyType(rawInput: unknown): AdditionalPropertiesKeyType | null;
7
8
  export declare function decodeTypeInfo(rawInput: unknown): TypeInfo | null;
9
+ export declare function valueIsKeyedAdditionalProperties(value: unknown): value is KeyedAdditionalProperties;
10
+ export declare function valueIsTypeInfo(value: unknown): value is TypeInfo;
8
11
  export declare function decodeObjectTemplateInputProperties(rawInput: unknown): ObjectTemplateInputProperties | null;
9
12
  export declare function decodeEnumTemplateInput(rawInput: unknown): EnumTemplateInput | null;
@@ -22,6 +22,7 @@ export type Template = {
22
22
  typesFileSyntax: string;
23
23
  enumSyntax: string;
24
24
  oneOfSyntax: string;
25
+ allOfSyntax: string;
25
26
  };
26
27
  export type LanguageConfig = {
27
28
  exporterModuleName: string;
@@ -78,8 +79,16 @@ export type TypeInfo = TypeDescriptors & {
78
79
  properties: TypeProperties | null;
79
80
  $ref: string | null;
80
81
  oneOf: TypeInfo[] | null;
82
+ allOf: TypeInfo[] | null;
81
83
  enum: string[] | number[] | null;
84
+ additionalProperties: AdditionalProperties | null;
82
85
  };
86
+ export type AdditionalProperties = KeyedAdditionalProperties | TypeInfo | boolean;
87
+ export type KeyedAdditionalProperties = {
88
+ keyType: AdditionalPropertiesKeyType;
89
+ valueType: TypeInfo;
90
+ };
91
+ export type AdditionalPropertiesKeyType = 'string' | 'number';
83
92
  type PropertyName = string;
84
93
  export type TypeProperties = Record<PropertyName, TypeInfo>;
85
94
  export type TypeDataType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'unknown';
@@ -92,6 +101,7 @@ export type ObjectTemplateInput = TypeDescriptors & {
92
101
  typeName: string;
93
102
  type: string;
94
103
  properties: ObjectTemplateInputProperties;
104
+ additionalProperties?: AdditionalPropertiesTemplateInput;
95
105
  };
96
106
  export type ObjectTemplateInputProperties = Record<PropertyName, ObjectTemplateInputProperty>;
97
107
  export type ObjectTemplateInputProperty = TypeDescriptors & {
@@ -101,6 +111,10 @@ export type ObjectTemplateInputProperty = TypeDescriptors & {
101
111
  primitiveType: string;
102
112
  composerType: string | null;
103
113
  };
114
+ export type AdditionalPropertiesTemplateInput = {
115
+ keyType: string;
116
+ valueType: string;
117
+ };
104
118
  export type ExporterModuleTemplateInput = {
105
119
  modules: string[];
106
120
  };
@@ -132,12 +146,24 @@ export type OneOfTemplateInputComposition = {
132
146
  referencedType?: string;
133
147
  content?: string;
134
148
  };
149
+ export type AllOfTemplateInput = TypeDescriptors & {
150
+ typeName: string;
151
+ type: string;
152
+ compositions: AllOfTemplateInputComposition[];
153
+ };
154
+ export type AllOfTemplateInputComposition = {
155
+ dataType?: TypeDataType | null;
156
+ templateInput?: TemplateInput;
157
+ source: 'inline' | 'referenced';
158
+ referencedType?: string;
159
+ content?: string;
160
+ };
135
161
  export type VariableTemplateInput = TypeDescriptors & {
136
162
  typeName: string;
137
163
  type: string;
138
164
  composerType?: string;
139
165
  };
140
- export type TemplateInput = ObjectTemplateInput | EnumTemplateInput | OneOfTemplateInput | VariableTemplateInput;
166
+ export type TemplateInput = ObjectTemplateInput | EnumTemplateInput | OneOfTemplateInput | AllOfTemplateInput | VariableTemplateInput;
141
167
  export type GenerationResult = {
142
168
  groupedTypes: GroupedTypesOutput;
143
169
  types: GeneratedTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-crafter",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "description": "A tool to generate types from a yaml schema for any language",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",