@vaadin/hilla-generator-plugin-backbone 24.7.0-alpha9 → 24.7.0-beta2

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.
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["src/TypeSchemaProcessor.ts"],
4
- "sourcesContent": ["import {\n type ArraySchema,\n convertReferenceSchemaToPath,\n convertReferenceSchemaToSpecifier,\n decomposeSchema,\n isArraySchema,\n isBooleanSchema,\n isComposedSchema,\n isIntegerSchema,\n isMapSchema,\n isNullableSchema,\n isNumberSchema,\n isReferenceSchema,\n isStringSchema,\n type MapSchema,\n type NonComposedSchema,\n type ReferenceSchema,\n type Schema,\n} from '@vaadin/hilla-generator-core/Schema.js';\nimport type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';\nimport ts, { type TypeNode } from 'typescript';\nimport { findTypeArguments, findTypeVariable } from './utils.js';\n\nfunction createBoolean(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword);\n}\n\nfunction createNumber(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);\n}\n\nfunction createString(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword);\n}\n\nfunction createUndefined(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword);\n}\n\nfunction createUnknown(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);\n}\n\nfunction unwrapPossiblyNullableSchema(schema: Schema): NonComposedSchema {\n if (isComposedSchema(schema)) {\n const [result] = decomposeSchema(schema);\n\n return result as NonComposedSchema;\n }\n\n return schema as NonComposedSchema;\n}\n\nexport default class TypeSchemaProcessor {\n declare ['constructor']: typeof TypeSchemaProcessor;\n readonly #dependencies: DependencyManager;\n readonly #schema: Schema;\n\n constructor(schema: Schema, dependencies: DependencyManager) {\n this.#schema = schema;\n this.#dependencies = dependencies;\n }\n\n process(): readonly TypeNode[] {\n let node: TypeNode;\n\n const unwrappedSchema = unwrapPossiblyNullableSchema(this.#schema);\n\n const typeVariable = findTypeVariable(this.#schema);\n if (typeVariable) {\n // Type variables are returned directly as they are, no further processing is needed\n return [ts.factory.createTypeReferenceNode(typeVariable)];\n }\n\n if (isReferenceSchema(unwrappedSchema)) {\n const typeArguments = this.#processTypeArguments(this.#schema);\n node = this.#processReference(unwrappedSchema, typeArguments);\n } else if (isArraySchema(unwrappedSchema)) {\n node = this.#processArray(unwrappedSchema);\n } else if (isMapSchema(unwrappedSchema)) {\n node = this.#processMap(unwrappedSchema);\n } else if (isBooleanSchema(unwrappedSchema)) {\n node = createBoolean();\n } else if (isIntegerSchema(unwrappedSchema) || isNumberSchema(unwrappedSchema)) {\n node = createNumber();\n } else if (isStringSchema(unwrappedSchema)) {\n node = createString();\n } else {\n node = createUnknown();\n }\n\n return isNullableSchema(this.#schema) ? [node, createUndefined()] : [node];\n }\n\n #processArray(schema: ArraySchema): TypeNode {\n const nodes = new TypeSchemaProcessor(schema.items, this.#dependencies).process();\n\n return ts.factory.createTypeReferenceNode('Array', [ts.factory.createUnionTypeNode(nodes)]);\n }\n\n #processMap({ additionalProperties: valuesType }: MapSchema): TypeNode {\n let valuesTypeNode: TypeNode;\n\n if (typeof valuesType !== 'boolean') {\n const nodes = new TypeSchemaProcessor(valuesType, this.#dependencies).process();\n valuesTypeNode = ts.factory.createUnionTypeNode(nodes);\n } else {\n valuesTypeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);\n }\n\n return ts.factory.createTypeReferenceNode('Record', [\n ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n valuesTypeNode,\n ]);\n }\n\n #processTypeArguments(schema: Schema): readonly ts.TypeNode[] | undefined {\n // Type arguments are processed recursively\n return findTypeArguments(schema)\n ?.allOf.map((s) => new TypeSchemaProcessor(s, this.#dependencies).process())\n .map((t) => ts.factory.createUnionTypeNode(t));\n }\n\n #processReference(schema: ReferenceSchema, typeArguments: readonly ts.TypeNode[] | undefined): TypeNode {\n const { imports, paths } = this.#dependencies;\n\n const specifier = convertReferenceSchemaToSpecifier(schema);\n const path = paths.createRelativePath(convertReferenceSchemaToPath(schema));\n\n const identifier = imports.default.getIdentifier(path) ?? imports.default.add(path, specifier, true);\n\n return ts.factory.createTypeReferenceNode(identifier, typeArguments);\n }\n}\n"],
5
- "mappings": "AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AAEP,OAAO,YAA2B;AAClC,SAAS,mBAAmB,wBAAwB;AAEpD,SAAS,gBAA0B;AACjC,SAAO,GAAG,QAAQ,sBAAsB,GAAG,WAAW,cAAc;AACtE;AAEA,SAAS,eAAyB;AAChC,SAAO,GAAG,QAAQ,sBAAsB,GAAG,WAAW,aAAa;AACrE;AAEA,SAAS,eAAyB;AAChC,SAAO,GAAG,QAAQ,sBAAsB,GAAG,WAAW,aAAa;AACrE;AAEA,SAAS,kBAA4B;AACnC,SAAO,GAAG,QAAQ,sBAAsB,GAAG,WAAW,gBAAgB;AACxE;AAEA,SAAS,gBAA0B;AACjC,SAAO,GAAG,QAAQ,sBAAsB,GAAG,WAAW,cAAc;AACtE;AAEA,SAAS,6BAA6B,QAAmC;AACvE,MAAI,iBAAiB,MAAM,GAAG;AAC5B,UAAM,CAAC,MAAM,IAAI,gBAAgB,MAAM;AAEvC,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEA,MAAO,oBAAkC;AAAA,EAE9B;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,cAAiC;AAC3D,SAAK,UAAU;AACf,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,UAA+B;AAC7B,QAAI;AAEJ,UAAM,kBAAkB,6BAA6B,KAAK,OAAO;AAE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,EAAY;EACrE,IAAIS;AAEJ,aAAW,eAAe,WAAW;GACnC,MAAM,QAAQ,IAAI,oBAAoB,YAAY,KAAKX,eAAe,KAAKE,gBAAgB,SAAS;AACpG,oBAAiB,GAAG,QAAQ,oBAAoB,MAAM;EACvD,OAAM;AACL,oBAAiB,GAAG,QAAQ,sBAAsB,GAAG,WAAW,eAAe;EAChF;AAED,SAAO,GAAG,QAAQ,wBAAwB,UAAU,CAClD,GAAG,QAAQ,sBAAsB,GAAG,WAAW,cAAc,EAC7D,cACD,EAAC;CACH;CAED,sBAAsBH,QAAiD;AAErE,SAAO,kBAAkB,OAAO,EAC5B,MAAM,IAAI,CAAC,MAAM,IAAI,oBAAoB,GAAG,KAAKC,eAAe,KAAKE,gBAAgB,SAAS,CAAC,CAChG,IAAI,CAAC,MAAM,GAAG,QAAQ,oBAAoB,EAAE,CAAC;CACjD;CAED,kBAAkBU,QAAyBC,eAA0D;EACnG,MAAM,EAAE,SAAS,OAAO,GAAG,KAAKb;EAEhC,MAAM,qBAAqB,2CAA2C,OAAO;AAE7E,MAAI,KAAKE,eAAe,IAAI,mBAAmB,EAAE;AAC/C,UAAO,KAAKA,eAAe,IAAI,mBAAmB,CAAE,cAAc;EACnE;EAED,MAAM,YAAY,kCAAkC,OAAO;EAC3D,MAAM,OAAO,MAAM,mBAAmB,wCAAwC,mBAAmB,CAAC;EAElG,MAAM,aAAa,QAAQ,QAAQ,cAAc,KAAK,IAAI,QAAQ,QAAQ,IAAI,MAAM,WAAW,KAAK;AAEpG,SAAO,GAAG,QAAQ,wBAAwB,YAAY,cAAc;CACrE;AACF","names":["schema: Schema","#dependencies","#schema","#transferTypes","dependencies: DependencyManager","transferTypes: Map<string, TransferTypeMaker>","node: TypeNode","#processTypeArguments","#processReference","#processArray","#processMap","schema: ArraySchema","valuesTypeNode: TypeNode","schema: ReferenceSchema","typeArguments: readonly TypeNode[] | undefined"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-plugin-backbone/src/TypeSchemaProcessor.ts"],"sourcesContent":["import {\n type ArraySchema,\n convertFullyQualifiedNameToRelativePath,\n convertReferenceSchemaToFullyQualifiedName,\n convertReferenceSchemaToSpecifier,\n decomposeSchema,\n isArraySchema,\n isBooleanSchema,\n isComposedSchema,\n isIntegerSchema,\n isMapSchema,\n isNullableSchema,\n isNumberSchema,\n isReferenceSchema,\n isStringSchema,\n type MapSchema,\n type NonComposedSchema,\n type ReferenceSchema,\n type Schema,\n} from '@vaadin/hilla-generator-core/Schema.js';\nimport type { TransferTypeMaker } from '@vaadin/hilla-generator-core/SharedStorage.js';\nimport type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';\nimport ts, { type TypeNode } from 'typescript';\nimport { findTypeArguments, findTypeVariable } from './utils.js';\n\nfunction createBoolean(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword);\n}\n\nfunction createNumber(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);\n}\n\nfunction createString(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword);\n}\n\nfunction createUndefined(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword);\n}\n\nfunction createUnknown(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);\n}\n\nfunction unwrapPossiblyNullableSchema(schema: Schema): NonComposedSchema {\n if (isComposedSchema(schema)) {\n const [result] = decomposeSchema(schema);\n\n return result as NonComposedSchema;\n }\n\n return schema as NonComposedSchema;\n}\n\nexport default class TypeSchemaProcessor {\n declare ['constructor']: typeof TypeSchemaProcessor;\n readonly #dependencies: DependencyManager;\n readonly #schema: Schema;\n readonly #transferTypes: Map<string, TransferTypeMaker>;\n\n constructor(schema: Schema, dependencies: DependencyManager, transferTypes: Map<string, TransferTypeMaker>) {\n this.#schema = schema;\n this.#dependencies = dependencies;\n this.#transferTypes = transferTypes;\n }\n\n process(): readonly TypeNode[] {\n let node: TypeNode;\n\n const unwrappedSchema = unwrapPossiblyNullableSchema(this.#schema);\n\n const typeVariable = findTypeVariable(this.#schema);\n if (typeVariable) {\n // Type variables are returned directly as they are, no further processing is needed\n return [ts.factory.createTypeReferenceNode(typeVariable)];\n }\n\n if (isReferenceSchema(unwrappedSchema)) {\n const typeArguments = this.#processTypeArguments(this.#schema);\n node = this.#processReference(unwrappedSchema, typeArguments);\n } else if (isArraySchema(unwrappedSchema)) {\n node = this.#processArray(unwrappedSchema);\n } else if (isMapSchema(unwrappedSchema)) {\n node = this.#processMap(unwrappedSchema);\n } else if (isBooleanSchema(unwrappedSchema)) {\n node = createBoolean();\n } else if (isIntegerSchema(unwrappedSchema) || isNumberSchema(unwrappedSchema)) {\n node = createNumber();\n } else if (isStringSchema(unwrappedSchema)) {\n node = createString();\n } else {\n node = createUnknown();\n }\n\n return isNullableSchema(this.#schema) ? [node, createUndefined()] : [node];\n }\n\n #processArray(schema: ArraySchema): TypeNode {\n const nodes = new TypeSchemaProcessor(schema.items, this.#dependencies, this.#transferTypes).process();\n\n return ts.factory.createTypeReferenceNode('Array', [ts.factory.createUnionTypeNode(nodes)]);\n }\n\n #processMap({ additionalProperties: valuesType }: MapSchema): TypeNode {\n let valuesTypeNode: TypeNode;\n\n if (typeof valuesType !== 'boolean') {\n const nodes = new TypeSchemaProcessor(valuesType, this.#dependencies, this.#transferTypes).process();\n valuesTypeNode = ts.factory.createUnionTypeNode(nodes);\n } else {\n valuesTypeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);\n }\n\n return ts.factory.createTypeReferenceNode('Record', [\n ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n valuesTypeNode,\n ]);\n }\n\n #processTypeArguments(schema: Schema): readonly TypeNode[] | undefined {\n // Type arguments are processed recursively\n return findTypeArguments(schema)\n ?.allOf.map((s) => new TypeSchemaProcessor(s, this.#dependencies, this.#transferTypes).process())\n .map((t) => ts.factory.createUnionTypeNode(t));\n }\n\n #processReference(schema: ReferenceSchema, typeArguments: readonly TypeNode[] | undefined): TypeNode {\n const { imports, paths } = this.#dependencies;\n\n const fullyQualifiedName = convertReferenceSchemaToFullyQualifiedName(schema);\n\n if (this.#transferTypes.has(fullyQualifiedName)) {\n return this.#transferTypes.get(fullyQualifiedName)!(typeArguments);\n }\n\n const specifier = convertReferenceSchemaToSpecifier(schema);\n const path = paths.createRelativePath(convertFullyQualifiedNameToRelativePath(fullyQualifiedName));\n\n const identifier = imports.default.getIdentifier(path) ?? imports.default.add(path, specifier, true);\n\n return ts.factory.createTypeReferenceNode(identifier, typeArguments);\n }\n}\n"],"version":3}
package/index.d.ts CHANGED
@@ -1,14 +1,13 @@
1
- import Plugin from '@vaadin/hilla-generator-core/Plugin.js';
2
- import type SharedStorage from '@vaadin/hilla-generator-core/SharedStorage.js';
1
+ import Plugin from "@vaadin/hilla-generator-core/Plugin.js";
2
+ import type { SharedStorage } from "@vaadin/hilla-generator-core/SharedStorage.js";
3
3
  export declare enum BackbonePluginSourceType {
4
- Endpoint = "endpoint",
5
- Entity = "entity"
4
+ Endpoint = "endpoint",
5
+ Entity = "entity",
6
6
  }
7
7
  export default class BackbonePlugin extends Plugin {
8
- #private;
9
- static readonly BACKBONE_PLUGIN_FILE_TAGS = "BACKBONE_PLUGIN_FILE_TAGS";
10
- ['constructor']: typeof BackbonePlugin;
11
- get path(): string;
12
- execute(storage: SharedStorage): Promise<void>;
8
+ #private;
9
+ static readonly BACKBONE_PLUGIN_FILE_TAGS = "BACKBONE_PLUGIN_FILE_TAGS";
10
+ ["constructor"]: typeof BackbonePlugin;
11
+ get path(): string;
12
+ execute(storage: SharedStorage): Promise<void>;
13
13
  }
14
- //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,55 +1,45 @@
1
1
  import Plugin from "@vaadin/hilla-generator-core/Plugin.js";
2
2
  import EndpointProcessor from "./EndpointProcessor.js";
3
3
  import { EntityProcessor } from "./EntityProcessor.js";
4
- var BackbonePluginSourceType = /* @__PURE__ */ ((BackbonePluginSourceType2) => {
5
- BackbonePluginSourceType2["Endpoint"] = "endpoint";
6
- BackbonePluginSourceType2["Entity"] = "entity";
7
- return BackbonePluginSourceType2;
8
- })(BackbonePluginSourceType || {});
9
- class BackbonePlugin extends Plugin {
10
- static BACKBONE_PLUGIN_FILE_TAGS = "BACKBONE_PLUGIN_FILE_TAGS";
11
- #tags = /* @__PURE__ */ new WeakMap();
12
- get path() {
13
- return import.meta.url;
14
- }
15
- async execute(storage) {
16
- const endpointSourceFiles = await this.#processEndpoints(storage);
17
- const entitySourceFiles = this.#processEntities(storage);
18
- endpointSourceFiles.forEach((file) => this.#tags.set(file, "endpoint" /* Endpoint */));
19
- entitySourceFiles.forEach((file) => this.#tags.set(file, "entity" /* Entity */));
20
- storage.sources.push(...endpointSourceFiles, ...entitySourceFiles);
21
- storage.pluginStorage.set(this.constructor.BACKBONE_PLUGIN_FILE_TAGS, this.#tags);
22
- }
23
- async #processEndpoints(storage) {
24
- this.logger.debug("Processing endpoints");
25
- const endpoints = /* @__PURE__ */ new Map();
26
- Object.entries(storage.api.paths).filter(([, pathItem]) => !!pathItem).forEach(([path, pathItem]) => {
27
- const [, endpointName, endpointMethodName] = path.split("/");
28
- let methods;
29
- if (endpoints.has(endpointName)) {
30
- methods = endpoints.get(endpointName);
31
- } else {
32
- methods = /* @__PURE__ */ new Map();
33
- endpoints.set(endpointName, methods);
34
- }
35
- methods.set(endpointMethodName, pathItem);
36
- });
37
- const processors = await Promise.all(
38
- [...endpoints.entries()].map(
39
- async ([endpointName, methods]) => EndpointProcessor.create(endpointName, this, methods, storage.outputDir)
40
- )
41
- );
42
- return Promise.all(processors.map(async (processor) => processor.process()));
43
- }
44
- #processEntities(storage) {
45
- this.logger.debug("Processing entities");
46
- return storage.api.components?.schemas ? Object.entries(storage.api.components.schemas).map(
47
- ([name, component]) => new EntityProcessor(name, component, this).process()
48
- ) : [];
49
- }
4
+ export let BackbonePluginSourceType = function(BackbonePluginSourceType) {
5
+ BackbonePluginSourceType["Endpoint"] = "endpoint";
6
+ BackbonePluginSourceType["Entity"] = "entity";
7
+ return BackbonePluginSourceType;
8
+ }({});
9
+ export default class BackbonePlugin extends Plugin {
10
+ static BACKBONE_PLUGIN_FILE_TAGS = "BACKBONE_PLUGIN_FILE_TAGS";
11
+ #tags = new WeakMap();
12
+ get path() {
13
+ return import.meta.url;
14
+ }
15
+ async execute(storage) {
16
+ const endpointSourceFiles = await this.#processEndpoints(storage);
17
+ const entitySourceFiles = this.#processEntities(storage);
18
+ endpointSourceFiles.forEach((file) => this.#tags.set(file, BackbonePluginSourceType.Endpoint));
19
+ entitySourceFiles.forEach((file) => this.#tags.set(file, BackbonePluginSourceType.Entity));
20
+ storage.sources.push(...endpointSourceFiles, ...entitySourceFiles);
21
+ storage.pluginStorage.set(this.constructor.BACKBONE_PLUGIN_FILE_TAGS, this.#tags);
22
+ }
23
+ async #processEndpoints(storage) {
24
+ this.logger.debug("Processing endpoints");
25
+ const endpoints = new Map();
26
+ Object.entries(storage.api.paths).filter(([, pathItem]) => !!pathItem).forEach(([path, pathItem]) => {
27
+ const [, endpointName, endpointMethodName] = path.split("/");
28
+ let methods;
29
+ if (endpoints.has(endpointName)) {
30
+ methods = endpoints.get(endpointName);
31
+ } else {
32
+ methods = new Map();
33
+ endpoints.set(endpointName, methods);
34
+ }
35
+ methods.set(endpointMethodName, pathItem);
36
+ });
37
+ const processors = await Promise.all(Array.from(endpoints.entries(), async ([endpointName, methods]) => EndpointProcessor.create(endpointName, methods, storage, this)));
38
+ return Promise.all(processors.map(async (processor) => processor.process()));
39
+ }
40
+ #processEntities(storage) {
41
+ this.logger.debug("Processing entities");
42
+ return storage.api.components?.schemas ? Object.entries(storage.api.components.schemas).map(([name, component]) => new EntityProcessor(name, component, storage, this).process()) : [];
43
+ }
50
44
  }
51
- export {
52
- BackbonePluginSourceType,
53
- BackbonePlugin as default
54
- };
55
- //# sourceMappingURL=index.js.map
45
+ //# sourceMappingURL=./index.js.map
package/index.js.map CHANGED
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["src/index.ts"],
4
- "sourcesContent": ["import Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport type SharedStorage from '@vaadin/hilla-generator-core/SharedStorage.js';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { ReadonlyDeep } from 'type-fest';\nimport type { SourceFile } from 'typescript';\nimport EndpointProcessor from './EndpointProcessor.js';\nimport { EntityProcessor } from './EntityProcessor.js';\n\nexport enum BackbonePluginSourceType {\n Endpoint = 'endpoint',\n Entity = 'entity',\n}\n\nexport default class BackbonePlugin extends Plugin {\n static readonly BACKBONE_PLUGIN_FILE_TAGS = 'BACKBONE_PLUGIN_FILE_TAGS';\n declare ['constructor']: typeof BackbonePlugin;\n readonly #tags = new WeakMap<SourceFile, BackbonePluginSourceType>();\n\n override get path(): string {\n return import.meta.url;\n }\n\n override async execute(storage: SharedStorage): Promise<void> {\n const endpointSourceFiles = await this.#processEndpoints(storage);\n const entitySourceFiles = this.#processEntities(storage);\n\n endpointSourceFiles.forEach((file) => this.#tags.set(file, BackbonePluginSourceType.Endpoint));\n entitySourceFiles.forEach((file) => this.#tags.set(file, BackbonePluginSourceType.Entity));\n\n storage.sources.push(...endpointSourceFiles, ...entitySourceFiles);\n storage.pluginStorage.set(this.constructor.BACKBONE_PLUGIN_FILE_TAGS, this.#tags);\n }\n\n async #processEndpoints(storage: SharedStorage): Promise<readonly SourceFile[]> {\n this.logger.debug('Processing endpoints');\n const endpoints = new Map<string, Map<string, ReadonlyDeep<OpenAPIV3.PathItemObject>>>();\n\n Object.entries(storage.api.paths)\n .filter(([, pathItem]) => !!pathItem)\n .forEach(([path, pathItem]) => {\n const [, endpointName, endpointMethodName] = path.split('/');\n\n let methods: Map<string, ReadonlyDeep<OpenAPIV3.PathItemObject>>;\n\n if (endpoints.has(endpointName)) {\n methods = endpoints.get(endpointName)!;\n } else {\n methods = new Map();\n endpoints.set(endpointName, methods);\n }\n\n methods.set(endpointMethodName, pathItem!);\n });\n\n const processors = await Promise.all(\n [...endpoints.entries()].map(async ([endpointName, methods]) =>\n EndpointProcessor.create(endpointName, this, methods, storage.outputDir),\n ),\n );\n\n return Promise.all(processors.map(async (processor) => processor.process()));\n }\n\n #processEntities(storage: SharedStorage): readonly SourceFile[] {\n this.logger.debug('Processing entities');\n\n return storage.api.components?.schemas\n ? Object.entries(storage.api.components.schemas).map(([name, component]) =>\n new EntityProcessor(name, component, this).process(),\n )\n : [];\n }\n}\n"],
5
- "mappings": "AAAA,OAAO,YAAY;AAKnB,OAAO,uBAAuB;AAC9B,SAAS,uBAAuB;AAEzB,IAAK,2BAAL,kBAAKA,8BAAL;AACL,EAAAA,0BAAA,cAAW;AACX,EAAAA,0BAAA,YAAS;AAFC,SAAAA;AAAA,GAAA;AAKZ,MAAO,uBAAqC,OAAO;AAAA,EACjD,OAAgB,4BAA4B;AAAA,EAEnC,QAAQ,oBAAI,QAA8C;AAAA,EAEnE,IAAa,OAAe;AAC1B,WAAO,YAAY;AAAA,EACrB;AAAA,EAEA,MAAe,QAAQ,SAAuC;AAC5D,UAAM,sBAAsB,MAAM,KAAK,kBAAkB,OAAO;AAChE,UAAM,oBAAoB,KAAK,iBAAiB,OAAO;AAEvD,wBAAoB,QAAQ,CAAC,SAAS,KAAK,MAAM,IAAI,MAAM,yBAAiC,CAAC;AAC7F,sBAAkB,QAAQ,CAAC,SAAS,KAAK,MAAM,IAAI,MAAM,qBAA+B,CAAC;AAEzF,YAAQ,QAAQ,KAAK,GAAG,qBAAqB,GAAG,iBAAiB;AACjE,YAAQ,cAAc,IAAI,KAAK,YAAY,2BAA2B,KAAK,KAAK;AAAA,EAClF;AAAA,EAEA,MAAM,kBAAkB,SAAwD;AAC9E,SAAK,OAAO,MAAM,sBAAsB;AACxC,UAAM,YAAY,oBAAI,IAAiE;AAEvF,WAAO,QAAQ,QAAQ,IAAI,KAAK,EAC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I,CAAC,CAAC,MAAM,UAAU,KACnE,IAAI,gBAAgB,MAAM,WAAW,SAAS,MAAM,SAAS,CAC9D,GACD,CAAE;CACP;AACF","names":["#tags","storage: SharedStorage","#processEndpoints","#processEntities","methods: Map<string, OpenAPIV3.PathItemObject>"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-plugin-backbone/src/index.ts"],"sourcesContent":["import Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport type { SharedStorage } from '@vaadin/hilla-generator-core/SharedStorage.js';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { SourceFile } from 'typescript';\nimport EndpointProcessor from './EndpointProcessor.js';\nimport { EntityProcessor } from './EntityProcessor.js';\n\nexport enum BackbonePluginSourceType {\n Endpoint = 'endpoint',\n Entity = 'entity',\n}\n\nexport default class BackbonePlugin extends Plugin {\n static readonly BACKBONE_PLUGIN_FILE_TAGS = 'BACKBONE_PLUGIN_FILE_TAGS';\n declare ['constructor']: typeof BackbonePlugin;\n readonly #tags = new WeakMap<SourceFile, BackbonePluginSourceType>();\n\n override get path(): string {\n return import.meta.url;\n }\n\n override async execute(storage: SharedStorage): Promise<void> {\n const endpointSourceFiles = await this.#processEndpoints(storage);\n const entitySourceFiles = this.#processEntities(storage);\n\n endpointSourceFiles.forEach((file) => this.#tags.set(file, BackbonePluginSourceType.Endpoint));\n entitySourceFiles.forEach((file) => this.#tags.set(file, BackbonePluginSourceType.Entity));\n\n storage.sources.push(...endpointSourceFiles, ...entitySourceFiles);\n storage.pluginStorage.set(this.constructor.BACKBONE_PLUGIN_FILE_TAGS, this.#tags);\n }\n\n async #processEndpoints(storage: SharedStorage): Promise<readonly SourceFile[]> {\n this.logger.debug('Processing endpoints');\n const endpoints = new Map<string, Map<string, OpenAPIV3.PathItemObject>>();\n\n Object.entries(storage.api.paths)\n .filter(([, pathItem]) => !!pathItem)\n .forEach(([path, pathItem]) => {\n const [, endpointName, endpointMethodName] = path.split('/');\n\n let methods: Map<string, OpenAPIV3.PathItemObject>;\n\n if (endpoints.has(endpointName)) {\n methods = endpoints.get(endpointName)!;\n } else {\n methods = new Map();\n endpoints.set(endpointName, methods);\n }\n\n methods.set(endpointMethodName, pathItem!);\n });\n\n const processors = await Promise.all(\n Array.from(endpoints.entries(), async ([endpointName, methods]) =>\n EndpointProcessor.create(endpointName, methods, storage, this),\n ),\n );\n\n return Promise.all(processors.map(async (processor) => processor.process()));\n }\n\n #processEntities(storage: SharedStorage): readonly SourceFile[] {\n this.logger.debug('Processing entities');\n\n return storage.api.components?.schemas\n ? Object.entries(storage.api.components.schemas).map(([name, component]) =>\n new EntityProcessor(name, component, storage, this).process(),\n )\n : [];\n }\n}\n"],"version":3}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/hilla-generator-plugin-backbone",
3
- "version": "24.7.0-alpha9",
3
+ "version": "24.7.0-beta2",
4
4
  "description": "A Hilla TypeScript Generator plugin to generate basic code",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -9,15 +9,13 @@
9
9
  },
10
10
  "scripts": {
11
11
  "clean:build": "git clean -fx . -e .vite -e node_modules",
12
- "build": "concurrently npm:build:*",
13
- "build:esbuild": "tsx ../../../scripts/build.ts",
14
- "build:dts": "tsc --isolatedModules -p tsconfig.build.json",
15
- "build:copy": "cd src && copyfiles **/*.d.ts ..",
12
+ "build": "tsx ../../../scripts/fast-build.ts",
16
13
  "lint": "eslint src test",
17
14
  "lint:fix": "eslint src test --fix",
18
- "test": "mocha test/**/*.spec.ts --config ../../../.mocharc.cjs",
19
- "test:update": "npm run test -- --update",
20
- "test:coverage": "c8 --experimental-monocart -c ../../../.c8rc.json npm test",
15
+ "test": "vitest --run",
16
+ "test:coverage": "vitest --run --coverage",
17
+ "test:update": "vitest --run --update",
18
+ "test:watch": "vitest",
21
19
  "typecheck": "tsc --noEmit"
22
20
  },
23
21
  "exports": {
@@ -51,30 +49,11 @@
51
49
  "access": "public"
52
50
  },
53
51
  "dependencies": {
54
- "@vaadin/hilla-generator-core": "24.7.0-alpha9",
55
- "@vaadin/hilla-generator-plugin-client": "24.7.0-alpha9",
56
- "@vaadin/hilla-generator-utils": "24.7.0-alpha9",
57
- "fast-deep-equal": "^3.1.3",
58
- "openapi-types": "^12.1.3",
52
+ "@vaadin/hilla-generator-core": "24.7.0-beta2",
53
+ "@vaadin/hilla-generator-plugin-client": "24.7.0-beta2",
54
+ "@vaadin/hilla-generator-utils": "24.7.0-beta2",
55
+ "fast-deep-equal": "3.1.3",
56
+ "openapi-types": "12.1.3",
59
57
  "typescript": "5.7.3"
60
- },
61
- "devDependencies": {
62
- "@types/chai": "^4.3.20",
63
- "@types/mocha": "^10.0.10",
64
- "@types/node": "^20.17.12",
65
- "@types/sinon": "^10.0.20",
66
- "@types/sinon-chai": "^3.2.12",
67
- "@vaadin/hilla-generator-core": "24.7.0-alpha9",
68
- "@vaadin/hilla-generator-plugin-client": "24.7.0-alpha9",
69
- "c8": "^10.1.3",
70
- "chai": "^4.5.0",
71
- "concurrently": "^9.1.2",
72
- "copyfiles": "^2.4.1",
73
- "mocha": "^11.1.0",
74
- "monocart-coverage-reports": "^2.11.5",
75
- "pino": "^9.6.0",
76
- "sinon": "^16.1.3",
77
- "sinon-chai": "^3.7.0",
78
- "type-fest": "^4.32.0"
79
58
  }
80
59
  }
package/utils.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { type AllOfRuleComposedSchema, type Schema } from '@vaadin/hilla-generator-core/Schema.js';
1
+ import { type AllOfRuleComposedSchema, type Schema } from "@vaadin/hilla-generator-core/Schema.js";
2
2
  export declare const defaultMediaType = "application/json";
3
3
  export type SchemaWithTypeArguments = Readonly<{
4
- 'x-type-arguments': AllOfRuleComposedSchema;
4
+ "x-type-arguments": AllOfRuleComposedSchema
5
5
  }> & Schema;
6
6
  export type SchemaWithTypeParameters = Readonly<{
7
- 'x-type-parameters': Schema[];
7
+ "x-type-parameters": Schema[]
8
8
  }> & Schema;
9
9
  export type SchemaWithTypeVariable = Readonly<{
10
- 'x-type-variable': string;
10
+ "x-type-variable": string
11
11
  }> & Schema;
12
12
  export declare function isSchemaWithTypeArguments(schema: Schema): schema is SchemaWithTypeArguments;
13
13
  export declare function isSchemaWithTypeParameters(schema: Schema): schema is SchemaWithTypeParameters;
@@ -15,4 +15,3 @@ export declare function isSchemaWithTypeVariable(schema: Schema): schema is Sche
15
15
  export declare function findTypeArguments(schema: Schema): AllOfRuleComposedSchema | undefined;
16
16
  export declare function findTypeParameters(schema: Schema): readonly Schema[] | undefined;
17
17
  export declare function findTypeVariable(schema: Schema): string | undefined;
18
- //# sourceMappingURL=utils.d.ts.map
package/utils.js CHANGED
@@ -1,44 +1,33 @@
1
- import {
2
- isAnyOfRuleComposedSchema
3
- } from "@vaadin/hilla-generator-core/Schema.js";
4
- const defaultMediaType = "application/json";
5
- function isSchemaWithTypeArguments(schema) {
6
- return "x-type-arguments" in schema;
1
+ import { isAnyOfRuleComposedSchema } from "@vaadin/hilla-generator-core/Schema.js";
2
+ export const defaultMediaType = "application/json";
3
+ export function isSchemaWithTypeArguments(schema) {
4
+ return "x-type-arguments" in schema;
7
5
  }
8
- function isSchemaWithTypeParameters(schema) {
9
- return "x-type-parameters" in schema;
6
+ export function isSchemaWithTypeParameters(schema) {
7
+ return "x-type-parameters" in schema;
10
8
  }
11
- function isSchemaWithTypeVariable(schema) {
12
- return "x-type-variable" in schema;
9
+ export function isSchemaWithTypeVariable(schema) {
10
+ return "x-type-variable" in schema;
13
11
  }
14
- function findTypeArguments(schema) {
15
- if (isSchemaWithTypeArguments(schema)) {
16
- return schema["x-type-arguments"];
17
- }
18
- if (isAnyOfRuleComposedSchema(schema)) {
19
- return schema.anyOf.find(isSchemaWithTypeArguments)?.["x-type-arguments"];
20
- }
21
- return void 0;
12
+ export function findTypeArguments(schema) {
13
+ if (isSchemaWithTypeArguments(schema)) {
14
+ return schema["x-type-arguments"];
15
+ }
16
+ if (isAnyOfRuleComposedSchema(schema)) {
17
+ return schema.anyOf.find(isSchemaWithTypeArguments)?.["x-type-arguments"];
18
+ }
19
+ return undefined;
22
20
  }
23
- function findTypeParameters(schema) {
24
- if (isSchemaWithTypeParameters(schema)) {
25
- return schema["x-type-parameters"];
26
- }
27
- return void 0;
21
+ export function findTypeParameters(schema) {
22
+ if (isSchemaWithTypeParameters(schema)) {
23
+ return schema["x-type-parameters"];
24
+ }
25
+ return undefined;
28
26
  }
29
- function findTypeVariable(schema) {
30
- if (isSchemaWithTypeVariable(schema)) {
31
- return schema["x-type-variable"];
32
- }
33
- return void 0;
27
+ export function findTypeVariable(schema) {
28
+ if (isSchemaWithTypeVariable(schema)) {
29
+ return schema["x-type-variable"];
30
+ }
31
+ return undefined;
34
32
  }
35
- export {
36
- defaultMediaType,
37
- findTypeArguments,
38
- findTypeParameters,
39
- findTypeVariable,
40
- isSchemaWithTypeArguments,
41
- isSchemaWithTypeParameters,
42
- isSchemaWithTypeVariable
43
- };
44
- //# sourceMappingURL=utils.js.map
33
+ //# sourceMappingURL=./utils.js.map
package/utils.js.map CHANGED
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["src/utils.ts"],
4
- "sourcesContent": ["import {\n isAnyOfRuleComposedSchema,\n type AllOfRuleComposedSchema,\n type Schema,\n} from '@vaadin/hilla-generator-core/Schema.js';\n\nexport const defaultMediaType = 'application/json';\n\nexport type SchemaWithTypeArguments = Readonly<{ 'x-type-arguments': AllOfRuleComposedSchema }> & Schema;\nexport type SchemaWithTypeParameters = Readonly<{ 'x-type-parameters': Schema[] }> & Schema;\nexport type SchemaWithTypeVariable = Readonly<{ 'x-type-variable': string }> & Schema;\n\nexport function isSchemaWithTypeArguments(schema: Schema): schema is SchemaWithTypeArguments {\n return 'x-type-arguments' in schema;\n}\n\nexport function isSchemaWithTypeParameters(schema: Schema): schema is SchemaWithTypeParameters {\n return 'x-type-parameters' in schema;\n}\n\nexport function isSchemaWithTypeVariable(schema: Schema): schema is SchemaWithTypeVariable {\n return 'x-type-variable' in schema;\n}\n\nexport function findTypeArguments(schema: Schema): AllOfRuleComposedSchema | undefined {\n if (isSchemaWithTypeArguments(schema)) {\n return schema['x-type-arguments'];\n }\n\n // Type arguments are defined as part of anyOf schemas\n if (isAnyOfRuleComposedSchema(schema)) {\n return schema.anyOf.find(isSchemaWithTypeArguments)?.['x-type-arguments'];\n }\n\n return undefined;\n}\n\nexport function findTypeParameters(schema: Schema): readonly Schema[] | undefined {\n if (isSchemaWithTypeParameters(schema)) {\n return schema['x-type-parameters'];\n }\n\n return undefined;\n}\n\nexport function findTypeVariable(schema: Schema): string | undefined {\n if (isSchemaWithTypeVariable(schema)) {\n return schema['x-type-variable'];\n }\n\n return undefined;\n}\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,OAGK;AAEA,MAAM,mBAAmB;AAMzB,SAAS,0BAA0B,QAAmD;AAC3F,SAAO,sBAAsB;AAC/B;AAEO,SAAS,2BAA2B,QAAoD;AAC7F,SAAO,uBAAuB;AAChC;AAEO,SAAS,yBAAyB,QAAkD;AACzF,SAAO,qBAAqB;AAC9B;AAEO,SAAS,kBAAkB,QAAqD;AACrF,MAAI,0BAA0B,MAAM,GAAG;AACrC,WAAO,OAAO,kBAAkB;AAAA,EAClC;AAGA,MAAI,0BAA0B,MAAM,GAAG;AACrC,WAAO,OAAO,MAAM,KAAK,yBAAyB,IAAI,kBAAkB;AAAA,EAC1E;AAEA,SAAO;AACT;AAEO,SAAS,mBAAmB,QAA+C;AAChF,MAAI,2BAA2B,MAAM,GAAG;AACtC,WAAO,OAAO,mBAAmB;AAAA,EACnC;AAEA,SAAO;AACT;AAEO,SAAS,iBAAiB,QAAoC;AACnE,MAAI,yBAAyB,MAAM,GAAG;AACpC,WAAO,OAAO,iBAAiB;AAAA,EACjC;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
1
+ {"mappings":"AAAA,SACE,yEAG8C;AAEhD,OAAO,MAAM,mBAAmB;AAMhC,OAAO,SAAS,0BAA0BA,QAAmD;AAC3F,QAAO,sBAAsB;AAC9B;AAED,OAAO,SAAS,2BAA2BA,QAAoD;AAC7F,QAAO,uBAAuB;AAC/B;AAED,OAAO,SAAS,yBAAyBA,QAAkD;AACzF,QAAO,qBAAqB;AAC7B;AAED,OAAO,SAAS,kBAAkBA,QAAqD;AACrF,KAAI,0BAA0B,OAAO,EAAE;AACrC,SAAO,OAAO;CACf;AAGD,KAAI,0BAA0B,OAAO,EAAE;AACrC,SAAO,OAAO,MAAM,KAAK,0BAA0B,GAAG;CACvD;AAED,QAAO;AACR;AAED,OAAO,SAAS,mBAAmBA,QAA+C;AAChF,KAAI,2BAA2B,OAAO,EAAE;AACtC,SAAO,OAAO;CACf;AAED,QAAO;AACR;AAED,OAAO,SAAS,iBAAiBA,QAAoC;AACnE,KAAI,yBAAyB,OAAO,EAAE;AACpC,SAAO,OAAO;CACf;AAED,QAAO;AACR","names":["schema: Schema"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-plugin-backbone/src/utils.ts"],"sourcesContent":["import {\n isAnyOfRuleComposedSchema,\n type AllOfRuleComposedSchema,\n type Schema,\n} from '@vaadin/hilla-generator-core/Schema.js';\n\nexport const defaultMediaType = 'application/json';\n\nexport type SchemaWithTypeArguments = Readonly<{ 'x-type-arguments': AllOfRuleComposedSchema }> & Schema;\nexport type SchemaWithTypeParameters = Readonly<{ 'x-type-parameters': Schema[] }> & Schema;\nexport type SchemaWithTypeVariable = Readonly<{ 'x-type-variable': string }> & Schema;\n\nexport function isSchemaWithTypeArguments(schema: Schema): schema is SchemaWithTypeArguments {\n return 'x-type-arguments' in schema;\n}\n\nexport function isSchemaWithTypeParameters(schema: Schema): schema is SchemaWithTypeParameters {\n return 'x-type-parameters' in schema;\n}\n\nexport function isSchemaWithTypeVariable(schema: Schema): schema is SchemaWithTypeVariable {\n return 'x-type-variable' in schema;\n}\n\nexport function findTypeArguments(schema: Schema): AllOfRuleComposedSchema | undefined {\n if (isSchemaWithTypeArguments(schema)) {\n return schema['x-type-arguments'];\n }\n\n // Type arguments are defined as part of anyOf schemas\n if (isAnyOfRuleComposedSchema(schema)) {\n return schema.anyOf.find(isSchemaWithTypeArguments)?.['x-type-arguments'];\n }\n\n return undefined;\n}\n\nexport function findTypeParameters(schema: Schema): readonly Schema[] | undefined {\n if (isSchemaWithTypeParameters(schema)) {\n return schema['x-type-parameters'];\n }\n\n return undefined;\n}\n\nexport function findTypeVariable(schema: Schema): string | undefined {\n if (isSchemaWithTypeVariable(schema)) {\n return schema['x-type-variable'];\n }\n\n return undefined;\n}\n"],"version":3}
@@ -1 +0,0 @@
1
- {"version":3,"file":"EndpointMethodOperationProcessor.d.ts","sourceRoot":"","sources":["src/EndpointMethodOperationProcessor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AAEjE,OAAO,KAAK,iBAAiB,MAAM,iEAAiE,CAAC;AAErG,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAW,EAAmB,KAAK,SAAS,EAAiB,MAAM,YAAY,CAAC;AAIhF,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AAE9E,eAAO,MAAM,cAAc,wBAAwB,CAAC;AACpD,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,gCAAgC;IAC5D,MAAM,CAAC,eAAe,CACpB,UAAU,EAAE,SAAS,CAAC,WAAW,EACjC,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,uBAAuB,EAClC,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,MAAM,GACZ,gCAAgC,GAAG,SAAS;IAiB/C,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CACrE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"EndpointMethodRequestBodyProcessor.d.ts","sourceRoot":"","sources":["src/EndpointMethodRequestBodyProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AAOjE,OAAO,KAAK,iBAAiB,MAAM,iEAAiE,CAAC;AACrG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,KAAK,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIzF,MAAM,MAAM,yBAAyB,GAAG,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAElF,MAAM,MAAM,yCAAyC,GAAG,QAAQ,CAAC;IAC/D,UAAU,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC5C,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;IAC3C,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC;CAC1B,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,OAAO,kCAAkC;;gBASnD,WAAW,EAAE,YAAY,CAAC,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,iBAAiB,CAAC,GAAG,SAAS,EAC9F,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,MAAM,EACb,kBAAkB,EAAE,EAAE,CAAC,UAAU;IAQnC,OAAO,IAAI,yCAAyC;CAuErD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"EndpointMethodResponseProcessor.d.ts","sourceRoot":"","sources":["src/EndpointMethodResponseProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AACjE,OAAO,KAAK,iBAAiB,MAAM,iEAAiE,CAAC;AACrG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AAC9E,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAE5E,MAAM,CAAC,OAAO,OAAO,+BAA+B;;gBAOhD,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,uBAAuB,CAAC,MAAM,CAAC,EACzC,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM;IAQf,OAAO,IAAI,SAAS,QAAQ,EAAE;CAe/B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"EndpointProcessor.d.ts","sourceRoot":"","sources":["src/EndpointProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AAKjE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,YAAY,CAAC;AAMxD,MAAM,CAAC,OAAO,OAAO,iBAAiB;;WACvB,MAAM,CACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,EAC5D,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC;IAoB7B,OAAO;IAYD,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;CAsCrC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"EntityProcessor.d.ts","sourceRoot":"","sources":["src/EntityProcessor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAGL,KAAK,MAAM,EAWZ,MAAM,wCAAwC,CAAC;AAQhD,OAAW,EAGT,KAAK,UAAU,EAGhB,MAAM,YAAY,CAAC;AAIpB,qBAAa,eAAe;;gBASd,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAiB1D,OAAO,IAAI,UAAU;CA4HtB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TypeSchemaProcessor.d.ts","sourceRoot":"","sources":["src/TypeSchemaProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAiBL,KAAK,MAAM,EACZ,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,iBAAiB,MAAM,iEAAiE,CAAC;AACrG,OAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAiC/C,MAAM,CAAC,OAAO,OAAO,mBAAmB;;IAC9B,CAAC,aAAa,CAAC,EAAE,OAAO,mBAAmB,CAAC;gBAIxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB;IAK3D,OAAO,IAAI,SAAS,QAAQ,EAAE;CAsE/B"}
package/index.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wCAAwC,CAAC;AAC5D,OAAO,KAAK,aAAa,MAAM,+CAA+C,CAAC;AAO/E,oBAAY,wBAAwB;IAClC,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAED,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,MAAM;;IAChD,MAAM,CAAC,QAAQ,CAAC,yBAAyB,+BAA+B;IAChE,CAAC,aAAa,CAAC,EAAE,OAAO,cAAc,CAAC;IAG/C,IAAa,IAAI,IAAI,MAAM,CAE1B;IAEc,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAkD9D"}
package/utils.d.ts.map DELETED
@@ -1 +0,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