@vaadin/hilla-generator-plugin-subtypes 25.0.0-alpha9 → 25.0.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.
- package/ModelFixProcessor.js.map +1 -1
- package/SubTypesProcessor.js.map +1 -1
- package/TypeFixProcessor.js.map +1 -1
- package/index.js.map +1 -1
- package/package.json +6 -6
- package/utils.js.map +1 -1
package/ModelFixProcessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,yEAA0E;AACjF,OAAO,oBAA0C;AACjD,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/
|
|
1
|
+
{"mappings":"AAAA,OAAO,yEAA0E;AACjF,OAAO,oBAA0C;AACjD,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 createSourceFile from '@vaadin/hilla-generator-utils/createSourceFile.js';\nimport ts, { type SourceFile } from 'typescript';\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.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,SAAS,2BAA4B;AACrC,SACE,8BACA,mCAEA,0EAC8C;AAChD,OAAO,yEAA0E;AACjF,OAAO,wFAAyF;AAChG,OAAO,4EAA6E;AACpF,OAAO,oBAA0C;AAEjD,OAAO,MAAM,kBAAkB;CAC7B,AAASA;CACT,AAASC;CACT,AAASC;CACT,AAASC;CAET,YAAYC,UAAkBC,QAAoBC,OAAmC;AACnF,OAAKN,YAAY;AACjB,OAAKC,UAAU;AACf,OAAKC,SAAS;AACd,OAAKC,gBAAgB,IAAI,kBACvB,IAAI,YAAY;GAAE,WAAW;GAAO,YAAY,QAAQ,OAAO,SAAS;EAAE;CAE7E;CAED,UAAsB;EACpB,MAAM,EAAE,SAAS,SAAS,OAAO,GAAG,KAAKA;EAGzC,MAAM,WAAW,KAAKD,OAAO,IAAI,CAAC,WAAW;GAC3C,MAAM,OAAO,MAAM,mBAAmB,6BAA6B,OAAO,CAAC;GAC3E,MAAM,UAAU,kCAAkC,OAAO;AACzD,UAAO,QAAQ,QAAQ,IAAI,MAAM,SAAS,KAAK;EAChD,EAAC;EAGF,MAAM,QAAQ,GAAG,QAAQ,oBACvB,SAAS,IAAI,CAAC,YAAY,GAAG,QAAQ,wBAAwB,QAAQ,CAAC,CACvE;EAGD,MAAM,EAAE,UAAU,YAAY,GAAG,KAAKD;EACtC,MAAM,iBAAiB,EAAE,2BAA2B,KAAKD,UAAU,CAAC;EACpE,MAAM,kBAAkB,GAAG,QAAQ,iBAAiB,cAAc;EAClE,MAAM,YAAY,GAAG,QAAQ,2BAA2B,WAAW,iBAAiB,WAAW,MAAM;AAErG,UAAQ,QAAQ,IAAI,cAAc;AAElC,SAAO,iBAAiB;GAAC,GAAG,QAAQ,QAAQ;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/
|
|
1
|
+
{"mappings":"AAAA,SAAS,2BAA4B;AACrC,SACE,8BACA,mCAEA,0EAC8C;AAChD,OAAO,yEAA0E;AACjF,OAAO,wFAAyF;AAChG,OAAO,4EAA6E;AACpF,OAAO,oBAA0C;AAEjD,OAAO,MAAM,kBAAkB;CAC7B,AAASA;CACT,AAASC;CACT,AAASC;CACT,AAASC;CAET,YAAYC,UAAkBC,QAAoBC,OAAmC;AACnF,OAAKN,YAAY;AACjB,OAAKC,UAAU;AACf,OAAKC,SAAS;AACd,OAAKC,gBAAgB,IAAI,kBACvB,IAAI,YAAY;GAAE,WAAW;GAAO,YAAY,QAAQ,OAAO,SAAS;EAAE;CAE7E;CAED,UAAsB;EACpB,MAAM,EAAE,SAAS,SAAS,OAAO,GAAG,KAAKA;EAGzC,MAAM,WAAW,KAAKD,OAAO,IAAI,CAAC,WAAW;GAC3C,MAAM,OAAO,MAAM,mBAAmB,6BAA6B,OAAO,CAAC;GAC3E,MAAM,UAAU,kCAAkC,OAAO;AACzD,UAAO,QAAQ,QAAQ,IAAI,MAAM,SAAS,KAAK;EAChD,EAAC;EAGF,MAAM,QAAQ,GAAG,QAAQ,oBACvB,SAAS,IAAI,CAAC,YAAY,GAAG,QAAQ,wBAAwB,QAAQ,CAAC,CACvE;EAGD,MAAM,EAAE,UAAU,YAAY,GAAG,KAAKD;EACtC,MAAM,iBAAiB,EAAE,2BAA2B,KAAKD,UAAU,CAAC;EACpE,MAAM,kBAAkB,GAAG,QAAQ,iBAAiB,cAAc;EAClE,MAAM,YAAY,GAAG,QAAQ,2BAA2B,WAAW,iBAAiB,WAAW,MAAM;AAErG,UAAQ,QAAQ,IAAI,cAAc;AAElC,SAAO,iBAAiB;GAAC,GAAG,QAAQ,QAAQ;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 {\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';\nimport ts, { type SourceFile } from 'typescript';\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.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,yEAA0E;AACjF,OAAO,oBAA0C;AACjD,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/
|
|
1
|
+
{"mappings":"AAAA,OAAO,yEAA0E;AACjF,OAAO,oBAA0C;AACjD,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 createSourceFile from '@vaadin/hilla-generator-utils/createSourceFile.js';\nimport ts, { type SourceFile } from 'typescript';\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/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,oDAAqD;AAC5D,SAAS,mBAAmB,uFAAwF;AAEpH,SAAS,iDAAkD;AAC3D,SAAS,iDAAkD;AAC3D,SAAS,+CAAgD;AAEzD,eAAe,MAAM,uBAAuB,OAAO;CAGjD,IAAa,OAAe;AAC1B,SAAO,OAAO,KAAK;CACpB;CAGD,MAAe,QAAQA,SAAuC;EAC5D,MAAM,EAAE,KAAK,SAAS,GAAG;EAEzB,MAAM,aAAa,IAAI,YAAY;AAEnC,OAAK,YAAY;AACf;EACD;AAED,SAAO,QAAQ,WAAW,CAAC,QAAQ,CAAC,CAAC,SAAS,cAAc,KAAK;AAE/D,OACE,WAAW,iBACX,MAAM,QAAQ,cAAc,MAAM,IAClC,cAAc,MAAM,MA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MAAM,YAAY,EAAE,WAAW,SAAS;UACxC,MAAM,SAAS,EAAE,wCAAwC,OAAO,CAAC;UACjE,MAAM,YAAY,QAAQ,KAAK,CAAC,EAAE,UAAU,KAAK,aAAa,MAAM;UAEpE,MAAM,cAAc,IAAI,iBAAiB,WAAW,WAAW,SAAS;AACxE,kBAAQ,OAAO,QAAQ,QAAQ,UAAU,EAAE,GAAG,YAAY;UAG1D,MAAM,WAAW,EAAE,wCAAwC,OAAO,CAAC;UACnE,MAAM,cAAc,QAAQ,KAAK,CAAC,EAAE,UAAU,KAAK,aAAa,QAAQ;UACxE,MAAM,mBAAmB,IAAI,kBAAkB,aAAa,SAAS;AACrE,kBAAQ,OAAO,QAAQ,QAAQ,YAAY,EAAE,GAAG,iBAAiB;SAClE;QACF,EAAC;OACH;MACF,EAAC;KACH;IACF,EAAC;IAGF,MAAM,WAAW,EAAE,wCAAwC,QAAQ,CAAC;IACpE,MAAM,cAAc,QAAQ,KAAK,CAAC,EAAE,UAAU,KAAK,aAAa,QAAQ;AACxE,YAAQ,OAAO,QAAQ,QAAQ,YAAY,EAAE,EAAE;GAChD;EACF,EAAC;CACH;AACF","names":["storage: SharedStorage"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-plugin-subtypes/src/index.ts"],"sourcesContent":["import Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport { isReferenceSchema, convertFullyQualifiedNameToRelativePath } from '@vaadin/hilla-generator-core/Schema.js';\nimport type { SharedStorage } from '@vaadin/hilla-generator-core/SharedStorage.js';\nimport { ModelFixProcessor } from './ModelFixProcessor.js';\nimport { SubTypesProcessor } from './SubTypesProcessor.js';\nimport { TypeFixProcessor } from './TypeFixProcessor.js';\n\nexport default class SubTypesPlugin extends Plugin {\n declare ['constructor']: typeof SubTypesPlugin;\n\n override get path(): string {\n return import.meta.url;\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n override async execute(storage: SharedStorage): Promise<void> {\n const { api, sources } = storage;\n\n const components = api.components?.schemas;\n\n if (!components) {\n return;\n }\n\n Object.entries(components).forEach(([baseKey, baseComponent]) => {\n // search for components with oneOf: those are union types\n if (\n 'oneOf' in baseComponent &&\n Array.isArray(baseComponent.oneOf) &&\n baseComponent.oneOf.every((schema) => isReferenceSchema(schema))\n ) {\n const fn = `${convertFullyQualifiedNameToRelativePath(baseKey)}.ts`;\n const source = sources.find(({ fileName }) => fileName === fn)!;\n // replace the (empty) source with a newly-generated one\n const newSource = new SubTypesProcessor(baseKey, source, baseComponent.oneOf).process();\n sources.splice(sources.indexOf(source), 1, newSource);\n\n // mentioned types in the oneOf need to be fixed as well\n baseComponent.oneOf.forEach((schema) => {\n if ('$ref' in schema) {\n const path = schema.$ref;\n Object.entries(components).forEach(([subKey, subComponent]) => {\n if ('anyOf' in subComponent && subKey === path.substring('#/components/schemas/'.length)) {\n subComponent.anyOf?.forEach((s) => {\n if ('properties' in s && '@type' in s.properties! && 'example' in s.properties['@type']) {\n const typeValue = s.properties['@type'].example as string;\n const subFn = `${convertFullyQualifiedNameToRelativePath(subKey)}.ts`;\n const subSource = sources.find(({ fileName }) => fileName === subFn)!;\n // fix the source to replace the @type property name with a quoted string\n const fixedSource = new TypeFixProcessor(subSource, typeValue).process();\n sources.splice(sources.indexOf(subSource), 1, fixedSource);\n\n // fix the model to remove the @type property\n const modelFn = `${convertFullyQualifiedNameToRelativePath(subKey)}Model.ts`;\n const modelSource = sources.find(({ fileName }) => fileName === modelFn)!;\n const fixedModelSource = new ModelFixProcessor(modelSource).process();\n sources.splice(sources.indexOf(modelSource), 1, fixedModelSource);\n }\n });\n }\n });\n }\n });\n\n // remove the union type model file\n const unionFn = `${convertFullyQualifiedNameToRelativePath(baseKey)}Model.ts`;\n const unionSource = sources.find(({ fileName }) => fileName === unionFn)!;\n sources.splice(sources.indexOf(unionSource), 1);\n }\n });\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.0.0-
|
|
3
|
+
"version": "25.0.0-beta2",
|
|
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
|
-
"@vaadin/hilla-generator-core": "25.0.0-
|
|
53
|
-
"@vaadin/hilla-generator-plugin-client": "25.0.0-
|
|
54
|
-
"@vaadin/hilla-generator-plugin-model": "25.0.0-
|
|
55
|
-
"@vaadin/hilla-generator-utils": "25.0.0-
|
|
52
|
+
"@vaadin/hilla-generator-core": "25.0.0-beta2",
|
|
53
|
+
"@vaadin/hilla-generator-plugin-client": "25.0.0-beta2",
|
|
54
|
+
"@vaadin/hilla-generator-plugin-model": "25.0.0-beta2",
|
|
55
|
+
"@vaadin/hilla-generator-utils": "25.0.0-beta2",
|
|
56
56
|
"fast-deep-equal": "^3.1.3",
|
|
57
57
|
"openapi-types": "^12.1.3",
|
|
58
|
-
"typescript": "5.9.
|
|
58
|
+
"typescript": "5.9.3"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,oBAA4C;AAEnD,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/
|
|
1
|
+
{"mappings":"AAAA,OAAO,oBAA4C;AAEnD,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';\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}
|