@vaadin/hilla-generator-plugin-subtypes 25.3.0-alpha7 → 25.3.0-alpha9
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/ModelFixProcessor.d.ts +1 -1
- package/ModelFixProcessor.js +1 -1
- package/ModelFixProcessor.js.map +1 -1
- package/SubTypesProcessor.d.ts +1 -1
- package/SubTypesProcessor.js +1 -1
- package/SubTypesProcessor.js.map +1 -1
- package/TypeFixProcessor.d.ts +1 -1
- package/TypeFixProcessor.js +1 -1
- package/TypeFixProcessor.js.map +1 -1
- package/package.json +7 -7
- package/utils.d.ts +1 -1
- package/utils.js +1 -1
- package/utils.js.map +1 -1
package/ModelFixProcessor.d.ts
CHANGED
package/ModelFixProcessor.js
CHANGED
package/ModelFixProcessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,
|
|
1
|
+
{"mappings":"AAAA,OAAO,iCAAuD;AAC9D,OAAO,yEAA0E;AACjF,SAAS,wCAAyC;AAElD,OAAO,MAAM,kBAAkB;CAC7B,AAASA;CAET,YAAYC,QAAoB;AAC9B,OAAKD,UAAU;CAChB;CAED,UAAsB;EACpB,MAAM,aAAa,KAAKA,QAAQ,WAAW,IAAI,CAAC,cAAc;AAE5D,OAAI,GAAG,mBAAmB,UAAU,EAAE;IACpC,MAAM,UAAU,UAAU,QAAQ,OAChC,CAAC,aAAa,GAAG,cAAc,OAAO,IAAI,qBAAqB,OAAO,KAAK,KAAK,SACjF;AAED,WAAO,GAAG,QAAQ,uBAChB,UAAU,WACV,UAAU,MACV,UAAU,gBACV,UAAU,iBACV,QACD;GACF;AAED,UAAO;EACR,EAAC;AAEF,SAAO,iBAAiB,YAAY,KAAKA,QAAQ,SAAS;CAC3D;AACF","names":["#source","source: SourceFile"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-plugin-subtypes/src/ModelFixProcessor.ts"],"sourcesContent":["import ts, { type SourceFile } from '@typescript/typescript6';\nimport createSourceFile from '@vaadin/hilla-generator-utils/createSourceFile.js';\nimport { propertyNameToString } from './utils.js';\n\nexport class ModelFixProcessor {\n readonly #source: SourceFile;\n\n constructor(source: SourceFile) {\n this.#source = source;\n }\n\n process(): SourceFile {\n const statements = this.#source.statements.map((statement) => {\n // filter out the @type property from all models\n if (ts.isClassDeclaration(statement)) {\n const members = statement.members.filter(\n (member) => !(ts.isGetAccessor(member) && propertyNameToString(member.name) === '@type'),\n );\n\n return ts.factory.createClassDeclaration(\n statement.modifiers,\n statement.name,\n statement.typeParameters,\n statement.heritageClauses,\n members,\n );\n }\n\n return statement;\n });\n\n return createSourceFile(statements, this.#source.fileName);\n }\n}\n"],"version":3}
|
package/SubTypesProcessor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type SourceFile } from "@typescript/typescript6";
|
|
1
2
|
import { type ReferenceSchema } from "@vaadin/hilla-generator-core/Schema.js";
|
|
2
|
-
import { type SourceFile } from "typescript";
|
|
3
3
|
export declare class SubTypesProcessor {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(typeName: string, source: SourceFile, oneOf: readonly ReferenceSchema[]);
|
package/SubTypesProcessor.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { dirname } from "path/posix";
|
|
2
|
+
import ts from "@typescript/typescript6";
|
|
2
3
|
import { convertReferenceSchemaToPath, convertReferenceSchemaToSpecifier, simplifyFullyQualifiedName } from "@vaadin/hilla-generator-core/Schema.js";
|
|
3
4
|
import createSourceFile from "@vaadin/hilla-generator-utils/createSourceFile.js";
|
|
4
5
|
import DependencyManager from "@vaadin/hilla-generator-utils/dependencies/DependencyManager.js";
|
|
5
6
|
import PathManager from "@vaadin/hilla-generator-utils/dependencies/PathManager.js";
|
|
6
|
-
import ts from "typescript";
|
|
7
7
|
export class SubTypesProcessor {
|
|
8
8
|
#typeName;
|
|
9
9
|
#source;
|
package/SubTypesProcessor.js.map
CHANGED
|
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Q;GAAE,GAAG;GAAY;GAAW,GAAG,QAAQ,QAAQ;EAAC,GAAE,SAAS;CACxG;AACF","names":["#typeName","#source","#oneOf","#dependencies","typeName: string","source: SourceFile","oneOf: readonly ReferenceSchema[]"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-plugin-subtypes/src/SubTypesProcessor.ts"],"sourcesContent":["import { dirname } from 'path/posix';\nimport ts, { type SourceFile } from '@typescript/typescript6';\nimport {\n convertReferenceSchemaToPath,\n convertReferenceSchemaToSpecifier,\n type ReferenceSchema,\n simplifyFullyQualifiedName,\n} from '@vaadin/hilla-generator-core/Schema.js';\nimport createSourceFile from '@vaadin/hilla-generator-utils/createSourceFile.js';\nimport DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';\nimport PathManager from '@vaadin/hilla-generator-utils/dependencies/PathManager.js';\n\nexport class SubTypesProcessor {\n readonly #typeName: string;\n readonly #source: SourceFile;\n readonly #oneOf: readonly ReferenceSchema[];\n readonly #dependencies: DependencyManager;\n\n constructor(typeName: string, source: SourceFile, oneOf: readonly ReferenceSchema[]) {\n this.#typeName = typeName;\n this.#source = source;\n this.#oneOf = oneOf;\n this.#dependencies = new DependencyManager(\n new PathManager({ extension: '.js', relativeTo: dirname(source.fileName) }),\n );\n }\n\n process(): SourceFile {\n const { exports, imports, paths } = this.#dependencies;\n\n // import all subtypes and return them\n const subTypes = this.#oneOf.map((schema) => {\n const path = paths.createRelativePath(convertReferenceSchemaToPath(schema));\n const subType = convertReferenceSchemaToSpecifier(schema);\n return imports.default.add(path, subType, true);\n });\n\n // create a union type from the subtypes\n const union = ts.factory.createUnionTypeNode(\n subTypes.map((subType) => ts.factory.createTypeReferenceNode(subType)),\n );\n\n // create the statement\n const { fileName, statements } = this.#source;\n const unionTypeName = `${simplifyFullyQualifiedName(this.#typeName)}`;\n const unionIdentifier = ts.factory.createIdentifier(unionTypeName);\n const statement = ts.factory.createTypeAliasDeclaration(undefined, unionIdentifier, undefined, union);\n\n exports.default.set(unionTypeName);\n\n return createSourceFile([...imports.toCode(), ...statements, statement, ...exports.toCode()], fileName);\n }\n}\n"],"version":3}
|
package/TypeFixProcessor.d.ts
CHANGED
package/TypeFixProcessor.js
CHANGED
package/TypeFixProcessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,
|
|
1
|
+
{"mappings":"AAAA,OAAO,iCAAuD;AAC9D,OAAO,yEAA0E;AACjF,SAAS,wCAAyC;AAElD,OAAO,MAAM,iBAAiB;CAC5B,AAASA;CACT,AAASC;CAET,YAAYC,QAAuBC,WAAmB;AACpD,OAAKH,UAAU;AACf,OAAKC,aAAa;CACnB;CAED,UAAsB;EACpB,MAAM,aAAa,KAAKD,QAAQ,WAAW,IAAI,CAAC,cAAc;AAE5D,OAAI,GAAG,uBAAuB,UAAU,EAAE;IACxC,MAAM,UAAU,UAAU,QAAQ,IAAI,CAAC,WAAW;AAEhD,SAAI,GAAG,oBAAoB,OAAO,IAAI,qBAAqB,OAAO,KAAK,KAAK,SAAS;AACnF,aAAO,GAAG,QAAQ,wBAChB,WACA,GAAG,QAAQ,oBAAoB,QAAQ,EACvC,WACA,GAAG,QAAQ,sBAAsB,GAAG,QAAQ,oBAAoB,KAAKC,WAAW,CAAC,CAClF;KACF;AAED,YAAO;IACR,EAAC;AAEF,WAAO,GAAG,QAAQ,2BAChB,UAAU,WACV,UAAU,MACV,UAAU,gBACV,UAAU,iBACV,QACD;GACF;AAED,UAAO;EACR,EAAC;AAEF,SAAO,iBAAiB,YAAY,KAAKD,QAAQ,SAAS;CAC3D;AACF","names":["#source","#typeValue","source: ts.SourceFile","typeValue: string"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-plugin-subtypes/src/TypeFixProcessor.ts"],"sourcesContent":["import ts, { type SourceFile } from '@typescript/typescript6';\nimport createSourceFile from '@vaadin/hilla-generator-utils/createSourceFile.js';\nimport { propertyNameToString } from './utils.js';\n\nexport class TypeFixProcessor {\n readonly #source: SourceFile;\n readonly #typeValue: string;\n\n constructor(source: ts.SourceFile, typeValue: string) {\n this.#source = source;\n this.#typeValue = typeValue;\n }\n\n process(): SourceFile {\n const statements = this.#source.statements.map((statement) => {\n // search in the interface definition\n if (ts.isInterfaceDeclaration(statement)) {\n const members = statement.members.map((member) => {\n // search for the @type property and replace it with a quoted string\n if (ts.isPropertySignature(member) && propertyNameToString(member.name) === '@type') {\n return ts.factory.createPropertySignature(\n undefined,\n ts.factory.createStringLiteral('@type'),\n undefined,\n ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(this.#typeValue)),\n );\n }\n\n return member;\n });\n\n return ts.factory.createInterfaceDeclaration(\n statement.modifiers,\n statement.name,\n statement.typeParameters,\n statement.heritageClauses,\n members,\n );\n }\n\n return statement;\n });\n\n return createSourceFile(statements, this.#source.fileName);\n }\n}\n"],"version":3}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-generator-plugin-subtypes",
|
|
3
|
-
"version": "25.3.0-
|
|
3
|
+
"version": "25.3.0-alpha9",
|
|
4
4
|
"description": "A Hilla TypeScript Generator plugin to support JsonSubTypes",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"@vaadin/hilla-generator-
|
|
54
|
-
"@vaadin/hilla-generator-plugin-
|
|
55
|
-
"@vaadin/hilla-generator-
|
|
52
|
+
"@typescript/typescript6": "6.0.2",
|
|
53
|
+
"@vaadin/hilla-generator-core": "25.3.0-alpha9",
|
|
54
|
+
"@vaadin/hilla-generator-plugin-client": "25.3.0-alpha9",
|
|
55
|
+
"@vaadin/hilla-generator-plugin-model": "25.3.0-alpha9",
|
|
56
|
+
"@vaadin/hilla-generator-utils": "25.3.0-alpha9",
|
|
56
57
|
"fast-deep-equal": "^3.1.3",
|
|
57
|
-
"openapi-types": "^12.1.3"
|
|
58
|
-
"typescript": "6.0.3"
|
|
58
|
+
"openapi-types": "^12.1.3"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type PropertyName } from "typescript";
|
|
1
|
+
import { type PropertyName } from "@typescript/typescript6";
|
|
2
2
|
export declare function propertyNameToString(node: PropertyName): string | null;
|
package/utils.js
CHANGED
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,
|
|
1
|
+
{"mappings":"AAAA,OAAO,iCAAyD;AAEhE,OAAO,SAAS,qBAAqBA,MAAmC;AACtE,KAAI,GAAG,aAAa,KAAK,IAAI,GAAG,gBAAgB,KAAK,IAAI,GAAG,iBAAiB,KAAK,EAAE;AAClF,SAAO,KAAK;CACb;AACD,QAAO;AACR","names":["node: PropertyName"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-plugin-subtypes/src/utils.ts"],"sourcesContent":["import ts, { type PropertyName } from '@typescript/typescript6';\n\nexport function propertyNameToString(node: PropertyName): string | null {\n if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node)) {\n return node.text;\n }\n return null;\n}\n"],"version":3}
|