@vaadin/hilla-generator-plugin-model 24.6.5 → 24.7.0-alpha11

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 +1 @@
1
- {"version":3,"file":"EntityModelProcessor.d.ts","sourceRoot":"","sources":["src/EntityModelProcessor.ts"],"names":[],"mappings":"AAEA,OAAO,EAUL,KAAK,MAAM,EACZ,MAAM,wCAAwC,CAAC;AAMhD,OAAO,iBAAiB,MAAM,iEAAiE,CAAC;AAEhG,OAAW,EACT,KAAK,gBAAgB,EAErB,KAAK,UAAU,EACf,KAAK,UAAU,EAEhB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAA0B,KAAK,OAAO,EAAsD,MAAM,YAAY,CAAC;AAEtH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,EAAE,EAAE,UAAU,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH,QAAA,MAAM,aAAa,eAAW,CAAC;AAC/B,QAAA,MAAM,OAAO,eAAW,CAAC;AACzB,QAAA,MAAM,mBAAmB,eAAW,CAAC;AACrC,QAAA,MAAM,MAAM,eAAW,CAAC;AACxB,QAAA,MAAM,mBAAmB,eAAW,CAAC;AAErC,8BAAsB,oBAAoB;;IACxC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU;IAY7E,SAAS,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IACtD,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAC7C,SAAS,CAAC,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACjD,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IAG5C,SAAS,aAAa,IAAI,EAAE,MAAM,EAAE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AC,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IACtD,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAC7C,SAAS,CAAC,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACjD,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IAG5C,SAAS,aAAa,IAAI,EAAE,MAAM,EAAE,wBAAwB,EAAE,OAAO;IAuBrE,OAAO,IAAI,UAAU;IAarB,SAAS,CAAC,QAAQ,CAAC,CAAC,mBAAmB,CAAC,IAAI,gBAAgB,GAAG,SAAS;CACzE;AAED,qBAAa,yBAA0B,SAAQ,oBAAoB;;gBAOrD,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAc7D,SAAS,CAAC,CAAC,mBAAmB,CAAC,IAAI,gBAAgB,GAAG,SAAS;CAyGhE;AAED,qBAAa,wBAAyB,SAAQ,oBAAoB;gBACpD,IAAI,EAAE,MAAM;IAIxB,SAAS,CAAC,CAAC,mBAAmB,CAAC,IAAI,gBAAgB;CA+BpD"}
@@ -1,24 +1,22 @@
1
1
  import { dirname } from "path/posix";
2
2
  import {
3
+ convertFullyQualifiedNameToRelativePath,
3
4
  convertReferenceSchemaToPath,
4
5
  convertReferenceSchemaToSpecifier,
5
6
  decomposeSchema,
6
7
  isComposedSchema,
7
8
  isEnumSchema,
8
9
  isObjectSchema,
9
- isReferenceSchema
10
- } from "@vaadin/hilla-generator-core/Schema.js";
11
- import {
12
- convertFullyQualifiedNameToRelativePath,
10
+ isReferenceSchema,
13
11
  simplifyFullyQualifiedName
14
- } from "@vaadin/hilla-generator-core/utils.js";
12
+ } from "@vaadin/hilla-generator-core/Schema.js";
15
13
  import createSourceFile from "@vaadin/hilla-generator-utils/createSourceFile.js";
16
14
  import DependencyManager from "@vaadin/hilla-generator-utils/dependencies/DependencyManager.js";
17
15
  import PathManager from "@vaadin/hilla-generator-utils/dependencies/PathManager.js";
18
16
  import ts, {
19
17
  } from "typescript";
20
18
  import { ModelSchemaExpressionProcessor, ModelSchemaTypeProcessor } from "./ModelSchemaProcessor.js";
21
- import { importBuiltInFormModel, createModelBuildingCallback, createEmptyValueMaker } from "./utils.js";
19
+ import { createEmptyValueMaker, createModelBuildingCallback, importBuiltInFormModel } from "./utils.js";
22
20
  const $dependencies = Symbol();
23
21
  const $entity = Symbol();
24
22
  const $fullyQualifiedName = Symbol();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/EntityModelProcessor.ts"],
4
- "sourcesContent": ["/* eslint-disable symbol-description */\nimport { dirname } from 'path/posix';\nimport {\n convertReferenceSchemaToPath,\n convertReferenceSchemaToSpecifier,\n decomposeSchema,\n isComposedSchema,\n isEnumSchema,\n isObjectSchema,\n isReferenceSchema,\n type ObjectSchema,\n type ReferenceSchema,\n type Schema,\n} from '@vaadin/hilla-generator-core/Schema.js';\nimport {\n convertFullyQualifiedNameToRelativePath,\n simplifyFullyQualifiedName,\n} from '@vaadin/hilla-generator-core/utils.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, {\n type ClassDeclaration,\n type ClassElement,\n type Identifier,\n type SourceFile,\n type Statement,\n} from 'typescript';\nimport { ModelSchemaExpressionProcessor, ModelSchemaTypeProcessor } from './ModelSchemaProcessor.js';\nimport { importBuiltInFormModel, type Context, createModelBuildingCallback, createEmptyValueMaker } from './utils.js';\n\nexport type DependencyData = Readonly<{\n id: Identifier;\n path: string;\n}>;\n\nconst $dependencies = Symbol();\nconst $entity = Symbol();\nconst $fullyQualifiedName = Symbol();\nconst $model = Symbol();\nconst $processDeclaration = Symbol();\n\nexport abstract class EntityModelProcessor {\n static process(name: string, component: Schema, context: Context): SourceFile {\n context.owner.logger.debug(`Processing model for entity: ${name}`);\n\n const schema = isComposedSchema(component) ? decomposeSchema(component)[0] : component;\n\n return isEnumSchema(schema)\n ? // eslint-disable-next-line @typescript-eslint/no-use-before-define\n new EntityEnumModelProcessor(name).process() // eslint-disable-line no-use-before-define\n : // eslint-disable-next-line @typescript-eslint/no-use-before-define\n new EntityClassModelProcessor(name, component, context).process(); // eslint-disable-line no-use-before-define\n }\n\n protected readonly [$dependencies]: DependencyManager;\n protected readonly [$entity]: DependencyData;\n protected readonly [$fullyQualifiedName]: string;\n protected readonly [$model]: DependencyData;\n readonly #outputPathManager = new PathManager({ extension: 'ts' });\n\n protected constructor(name: string, shouldImportEntityAsType: boolean) {\n this[$fullyQualifiedName] = name;\n\n const entityName = simplifyFullyQualifiedName(name);\n const entityPath = convertFullyQualifiedNameToRelativePath(name);\n\n const modelName = `${entityName}Model`;\n const modelPath = `${entityPath}Model`;\n this[$dependencies] = new DependencyManager(new PathManager({ extension: '.js', relativeTo: dirname(modelPath) }));\n\n const { exports, imports, paths } = this[$dependencies];\n\n this[$model] = {\n id: exports.default.set(modelName),\n path: modelPath,\n };\n\n this[$entity] = {\n id: imports.default.add(paths.createRelativePath(entityPath), entityName, shouldImportEntityAsType),\n path: entityPath,\n };\n }\n\n process(): SourceFile {\n const declaration = this[$processDeclaration]();\n\n const { exports, imports } = this[$dependencies];\n const importStatements = imports.toCode();\n const exportStatement = exports.toCode();\n\n return createSourceFile(\n [...importStatements, declaration, ...exportStatement].filter(Boolean) as readonly Statement[],\n this.#outputPathManager.createRelativePath(this[$model].path),\n );\n }\n\n protected abstract [$processDeclaration](): ClassDeclaration | undefined;\n}\n\nexport class EntityClassModelProcessor extends EntityModelProcessor {\n readonly #component: Schema;\n readonly #context: Context;\n readonly #fullyQualifiedName: string;\n readonly #getPropertyModelSymbol: Identifier;\n readonly #makeObjectEmptyValueCreator: Identifier;\n\n constructor(name: string, component: Schema, context: Context) {\n super(name, true);\n\n this.#component = component;\n this.#context = context;\n this.#fullyQualifiedName = name;\n\n this.#getPropertyModelSymbol = this[$dependencies].imports.named.add('@vaadin/hilla-lit-form', '_getPropertyModel');\n this.#makeObjectEmptyValueCreator = this[$dependencies].imports.named.add(\n '@vaadin/hilla-lit-form',\n 'makeObjectEmptyValueCreator',\n );\n }\n\n protected [$processDeclaration](): ClassDeclaration | undefined {\n const { logger } = this.#context.owner;\n\n let entitySchema = this.#component;\n let parent;\n\n if (isComposedSchema(this.#component)) {\n const decomposed = decomposeSchema(this.#component);\n\n if (decomposed.length > 2) {\n logger.debug(\n this.#component,\n `The schema for a class component ${this.#fullyQualifiedName} has more than two components. This plugin will ignore it.`,\n );\n return undefined;\n }\n\n const [parentSchema, childSchema] = decomposed;\n\n if (!isReferenceSchema(parentSchema)) {\n logger.debug(parentSchema, 'Only reference schema allowed for parent class');\n return undefined;\n }\n\n entitySchema = childSchema;\n parent = this.#processParentClass(parentSchema);\n } else {\n parent = importBuiltInFormModel('ObjectModel', this[$dependencies]);\n }\n\n return this.#processModelClass(entitySchema, this[$entity].id, parent);\n }\n\n #processClassElements({ properties }: ObjectSchema): readonly ClassElement[] {\n if (!properties) {\n return [];\n }\n\n return Object.entries(properties).map(([name, schema]) => {\n const type = new ModelSchemaTypeProcessor(schema, this[$dependencies]).process();\n const args = new ModelSchemaExpressionProcessor(schema, this[$dependencies]).process();\n\n return ts.factory.createGetAccessorDeclaration(\n undefined,\n ts.factory.createIdentifier(name),\n [],\n type,\n ts.factory.createBlock(\n [\n ts.factory.createReturnStatement(\n ts.factory.createCallExpression(\n ts.factory.createElementAccessExpression(ts.factory.createThis(), this.#getPropertyModelSymbol),\n undefined,\n [ts.factory.createStringLiteral(name), createModelBuildingCallback(type.typeName as Identifier, args)],\n ),\n ),\n ],\n true,\n ),\n );\n });\n }\n\n #processModelClass(schema: Schema, entity: Identifier, parent: Identifier): ClassDeclaration | undefined {\n const { logger } = this.#context.owner;\n\n if (!isObjectSchema(schema)) {\n logger.debug(schema, `Component is not an object: ${this.#fullyQualifiedName}`);\n return undefined;\n }\n\n const typeT = ts.factory.createIdentifier('T');\n const modelTypeParameters = ts.factory.createTypeParameterDeclaration(\n undefined,\n typeT,\n ts.factory.createTypeReferenceNode(entity),\n ts.factory.createTypeReferenceNode(entity),\n );\n\n return ts.factory.createClassDeclaration(\n undefined,\n this[$model].id,\n [modelTypeParameters],\n [\n ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [\n ts.factory.createExpressionWithTypeArguments(parent, [ts.factory.createTypeReferenceNode(typeT)]),\n ]),\n ],\n [\n createEmptyValueMaker(this.#makeObjectEmptyValueCreator, this[$model].id),\n ...this.#processClassElements(schema),\n ],\n );\n }\n\n #processParentClass(schema: ReferenceSchema): Identifier {\n const { imports, paths } = this[$dependencies];\n\n const specifier = convertReferenceSchemaToSpecifier(schema);\n const path = convertReferenceSchemaToPath(schema);\n const modelPath = paths.createRelativePath(`${path}Model`);\n const modelSpecifier = `${specifier}Model`;\n\n return imports.default.add(modelPath, modelSpecifier, false);\n }\n}\n\nexport class EntityEnumModelProcessor extends EntityModelProcessor {\n constructor(name: string) {\n super(name, false);\n }\n\n protected [$processDeclaration](): ClassDeclaration {\n const enumModel = importBuiltInFormModel('EnumModel', this[$dependencies]);\n const enumPropertySymbol = this[$dependencies].imports.named.add('@vaadin/hilla-lit-form', '_enum');\n const makeEnumEmptyValueCreator = this[$dependencies].imports.named.add(\n '@vaadin/hilla-lit-form',\n 'makeEnumEmptyValueCreator',\n );\n\n return ts.factory.createClassDeclaration(\n undefined,\n this[$model].id,\n undefined,\n [\n ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [\n ts.factory.createExpressionWithTypeArguments(enumModel, [\n ts.factory.createTypeQueryNode(this[$entity].id, undefined),\n ]),\n ]),\n ],\n [\n createEmptyValueMaker(makeEnumEmptyValueCreator, this[$model].id),\n ts.factory.createPropertyDeclaration(\n [ts.factory.createModifier(ts.SyntaxKind.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EACjE,YAAY,MAAc;AACxB,UAAM,MAAM,KAAK;AAAA,EACnB;AAAA,EAEA,CAAW,mBAAmB,IAAsB;AAClD,UAAM,YAAY,uBAAuB,aAAa,KAAK,aAAa,CAAC;AACzE,UAAM,qBAAqB,KAAK,aAAa,EAAE,QAAQ,MAAM,IAAI,0BAA0B,OAAO;AAClG,UAAM,4BAA4B,KAAK,aAAa,EAAE,QAAQ,MAAM;AAAA,MAClE;AAAA,MACA;AAAA,IACF;AAEA,WAAO,GAAG,QAAQ;AAAA,MAChB;AAAA,MACA,KAAK,MAAM,EAAE;AAAA,MACb;AAAA,MACA;AAAA,QACE,GAAG,QAAQ,qBAAqB,GAAG,WAAW,gBAAgB;AAAA,UAC5D,GAAG,QAAQ,kCAAkC,WAAW;AAAA,YACtD,GAAG,QAAQ,oBAAoB,KAAK,OAAO,EAAE,IAAI,MAAS;AAAA,UAC5D,CAAC;AAAA,QACH,CAAC;AAAA,MACH;AAAA,MACA;AAAA,QACE,sBAAsB,2BAA2B,KAAK,MAAM,EAAE,EAAE;AAAA,QAChE,GAAG,QAAQ;AAAA,UACT,CAAC,GAAG,QAAQ,eAAe,GAAG,WAAW,eAAe,CAAC;AAAA,UACzD,GAAG,QAAQ,2BAA2B,kBAAkB;AAAA,UACxD;AAAA,UACA;AAAA,UACA,KAAK,OAAO,EAAE;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/* eslint-disable symbol-description */\nimport { dirname } from 'path/posix';\nimport {\n convertFullyQualifiedNameToRelativePath,\n convertReferenceSchemaToPath,\n convertReferenceSchemaToSpecifier,\n decomposeSchema,\n isComposedSchema,\n isEnumSchema,\n isObjectSchema,\n isReferenceSchema,\n type ObjectSchema,\n type ReferenceSchema,\n type Schema,\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, {\n type ClassDeclaration,\n type ClassElement,\n type Identifier,\n type SourceFile,\n type Statement,\n} from 'typescript';\nimport { ModelSchemaExpressionProcessor, ModelSchemaTypeProcessor } from './ModelSchemaProcessor.js';\nimport { type Context, createEmptyValueMaker, createModelBuildingCallback, importBuiltInFormModel } from './utils.js';\n\nexport type DependencyData = Readonly<{\n id: Identifier;\n path: string;\n}>;\n\nconst $dependencies = Symbol();\nconst $entity = Symbol();\nconst $fullyQualifiedName = Symbol();\nconst $model = Symbol();\nconst $processDeclaration = Symbol();\n\nexport abstract class EntityModelProcessor {\n static process(name: string, component: Schema, context: Context): SourceFile {\n context.owner.logger.debug(`Processing model for entity: ${name}`);\n\n const schema = isComposedSchema(component) ? decomposeSchema(component)[0] : component;\n\n return isEnumSchema(schema)\n ? // eslint-disable-next-line @typescript-eslint/no-use-before-define\n new EntityEnumModelProcessor(name).process() // eslint-disable-line no-use-before-define\n : // eslint-disable-next-line @typescript-eslint/no-use-before-define\n new EntityClassModelProcessor(name, component, context).process(); // eslint-disable-line no-use-before-define\n }\n\n protected readonly [$dependencies]: DependencyManager;\n protected readonly [$entity]: DependencyData;\n protected readonly [$fullyQualifiedName]: string;\n protected readonly [$model]: DependencyData;\n readonly #outputPathManager = new PathManager({ extension: 'ts' });\n\n protected constructor(name: string, shouldImportEntityAsType: boolean) {\n this[$fullyQualifiedName] = name;\n\n const entityName = simplifyFullyQualifiedName(name);\n const entityPath = convertFullyQualifiedNameToRelativePath(name);\n\n const modelName = `${entityName}Model`;\n const modelPath = `${entityPath}Model`;\n this[$dependencies] = new DependencyManager(new PathManager({ extension: '.js', relativeTo: dirname(modelPath) }));\n\n const { exports, imports, paths } = this[$dependencies];\n\n this[$model] = {\n id: exports.default.set(modelName),\n path: modelPath,\n };\n\n this[$entity] = {\n id: imports.default.add(paths.createRelativePath(entityPath), entityName, shouldImportEntityAsType),\n path: entityPath,\n };\n }\n\n process(): SourceFile {\n const declaration = this[$processDeclaration]();\n\n const { exports, imports } = this[$dependencies];\n const importStatements = imports.toCode();\n const exportStatement = exports.toCode();\n\n return createSourceFile(\n [...importStatements, declaration, ...exportStatement].filter(Boolean) as readonly Statement[],\n this.#outputPathManager.createRelativePath(this[$model].path),\n );\n }\n\n protected abstract [$processDeclaration](): ClassDeclaration | undefined;\n}\n\nexport class EntityClassModelProcessor extends EntityModelProcessor {\n readonly #component: Schema;\n readonly #context: Context;\n readonly #fullyQualifiedName: string;\n readonly #getPropertyModelSymbol: Identifier;\n readonly #makeObjectEmptyValueCreator: Identifier;\n\n constructor(name: string, component: Schema, context: Context) {\n super(name, true);\n\n this.#component = component;\n this.#context = context;\n this.#fullyQualifiedName = name;\n\n this.#getPropertyModelSymbol = this[$dependencies].imports.named.add('@vaadin/hilla-lit-form', '_getPropertyModel');\n this.#makeObjectEmptyValueCreator = this[$dependencies].imports.named.add(\n '@vaadin/hilla-lit-form',\n 'makeObjectEmptyValueCreator',\n );\n }\n\n protected [$processDeclaration](): ClassDeclaration | undefined {\n const { logger } = this.#context.owner;\n\n let entitySchema = this.#component;\n let parent;\n\n if (isComposedSchema(this.#component)) {\n const decomposed = decomposeSchema(this.#component);\n\n if (decomposed.length > 2) {\n logger.debug(\n this.#component,\n `The schema for a class component ${this.#fullyQualifiedName} has more than two components. This plugin will ignore it.`,\n );\n return undefined;\n }\n\n const [parentSchema, childSchema] = decomposed;\n\n if (!isReferenceSchema(parentSchema)) {\n logger.debug(parentSchema, 'Only reference schema allowed for parent class');\n return undefined;\n }\n\n entitySchema = childSchema;\n parent = this.#processParentClass(parentSchema);\n } else {\n parent = importBuiltInFormModel('ObjectModel', this[$dependencies]);\n }\n\n return this.#processModelClass(entitySchema, this[$entity].id, parent);\n }\n\n #processClassElements({ properties }: ObjectSchema): readonly ClassElement[] {\n if (!properties) {\n return [];\n }\n\n return Object.entries(properties).map(([name, schema]) => {\n const type = new ModelSchemaTypeProcessor(schema, this[$dependencies]).process();\n const args = new ModelSchemaExpressionProcessor(schema, this[$dependencies]).process();\n\n return ts.factory.createGetAccessorDeclaration(\n undefined,\n ts.factory.createIdentifier(name),\n [],\n type,\n ts.factory.createBlock(\n [\n ts.factory.createReturnStatement(\n ts.factory.createCallExpression(\n ts.factory.createElementAccessExpression(ts.factory.createThis(), this.#getPropertyModelSymbol),\n undefined,\n [ts.factory.createStringLiteral(name), createModelBuildingCallback(type.typeName as Identifier, args)],\n ),\n ),\n ],\n true,\n ),\n );\n });\n }\n\n #processModelClass(schema: Schema, entity: Identifier, parent: Identifier): ClassDeclaration | undefined {\n const { logger } = this.#context.owner;\n\n if (!isObjectSchema(schema)) {\n logger.debug(schema, `Component is not an object: ${this.#fullyQualifiedName}`);\n return undefined;\n }\n\n const typeT = ts.factory.createIdentifier('T');\n const modelTypeParameters = ts.factory.createTypeParameterDeclaration(\n undefined,\n typeT,\n ts.factory.createTypeReferenceNode(entity),\n ts.factory.createTypeReferenceNode(entity),\n );\n\n return ts.factory.createClassDeclaration(\n undefined,\n this[$model].id,\n [modelTypeParameters],\n [\n ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [\n ts.factory.createExpressionWithTypeArguments(parent, [ts.factory.createTypeReferenceNode(typeT)]),\n ]),\n ],\n [\n createEmptyValueMaker(this.#makeObjectEmptyValueCreator, this[$model].id),\n ...this.#processClassElements(schema),\n ],\n );\n }\n\n #processParentClass(schema: ReferenceSchema): Identifier {\n const { imports, paths } = this[$dependencies];\n\n const specifier = convertReferenceSchemaToSpecifier(schema);\n const path = convertReferenceSchemaToPath(schema);\n const modelPath = paths.createRelativePath(`${path}Model`);\n const modelSpecifier = `${specifier}Model`;\n\n return imports.default.add(modelPath, modelSpecifier, false);\n }\n}\n\nexport class EntityEnumModelProcessor extends EntityModelProcessor {\n constructor(name: string) {\n super(name, false);\n }\n\n protected [$processDeclaration](): ClassDeclaration {\n const enumModel = importBuiltInFormModel('EnumModel', this[$dependencies]);\n const enumPropertySymbol = this[$dependencies].imports.named.add('@vaadin/hilla-lit-form', '_enum');\n const makeEnumEmptyValueCreator = this[$dependencies].imports.named.add(\n '@vaadin/hilla-lit-form',\n 'makeEnumEmptyValueCreator',\n );\n\n return ts.factory.createClassDeclaration(\n undefined,\n this[$model].id,\n undefined,\n [\n ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [\n ts.factory.createExpressionWithTypeArguments(enumModel, [\n ts.factory.createTypeQueryNode(this[$entity].id, undefined),\n ]),\n ]),\n ],\n [\n createEmptyValueMaker(makeEnumEmptyValueCreator, this[$model].id),\n ts.factory.createPropertyDeclaration(\n [ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)],\n ts.factory.createComputedPropertyName(enumPropertySymbol),\n undefined,\n undefined,\n this[$entity].id,\n ),\n ],\n );\n }\n}\n"],
5
+ "mappings": "AACA,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,OACK;AACP,OAAO,sBAAsB;AAC7B,OAAO,uBAAuB;AAC9B,OAAO,iBAAiB;AACxB,OAAO;AAAA,OAMA;AACP,SAAS,gCAAgC,gCAAgC;AACzE,SAAuB,uBAAuB,6BAA6B,8BAA8B;AAOzG,MAAM,gBAAgB,OAAO;AAC7B,MAAM,UAAU,OAAO;AACvB,MAAM,sBAAsB,OAAO;AACnC,MAAM,SAAS,OAAO;AACtB,MAAM,sBAAsB,OAAO;AAE5B,MAAe,qBAAqB;AAAA,EACzC,OAAO,QAAQ,MAAc,WAAmB,SAA8B;AAC5E,YAAQ,MAAM,OAAO,MAAM,gCAAgC,IAAI,EAAE;AAEjE,UAAM,SAAS,iBAAiB,SAAS,IAAI,gBAAgB,SAAS,EAAE,CAAC,IAAI;AAE7E,WAAO,aAAa,MAAM;AAAA;AAAA,MAEtB,IAAI,yBAAyB,IAAI,EAAE,QAAQ;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,KAAK,OAAO,EAAE;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Plugin from '@vaadin/hilla-generator-core/Plugin.js';
2
- import type SharedStorage from '@vaadin/hilla-generator-core/SharedStorage.js';
2
+ import type { SharedStorage } from '@vaadin/hilla-generator-core/SharedStorage.js';
3
3
  export declare enum ModelPluginSourceType {
4
4
  Model = "model"
5
5
  }
package/index.d.ts.map CHANGED
@@ -1 +1 @@
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,qBAAqB;IAC/B,KAAK,UAAU;CAChB;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,MAAM;;IAC7C,MAAM,CAAC,QAAQ,CAAC,sBAAsB,4BAA4B;IAC1D,CAAC,aAAa,CAAC,EAAE,OAAO,WAAW,CAAC;IAG5C,IAAa,IAAI,IAAI,MAAM,CAE1B;IAGc,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wCAAwC,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAMnF,oBAAY,qBAAqB;IAC/B,KAAK,UAAU;CAChB;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,MAAM;;IAC7C,MAAM,CAAC,QAAQ,CAAC,sBAAsB,4BAA4B;IAC1D,CAAC,aAAa,CAAC,EAAE,OAAO,WAAW,CAAC;IAG5C,IAAa,IAAI,IAAI,MAAM,CAE1B;IAGc,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB9D"}
package/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 { EntityModelProcessor } from './EntityModelProcessor.js';\nimport type { Context } from './utils.js';\n\nexport enum ModelPluginSourceType {\n Model = 'model',\n}\n\nexport default class ModelPlugin extends Plugin {\n static readonly MODEL_PLUGIN_FILE_TAGS = 'MODEL_PLUGIN_FILE_TAGS';\n declare ['constructor']: typeof ModelPlugin;\n readonly #tags = new WeakMap<SourceFile, ModelPluginSourceType>();\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 files = this.#processEntities(storage.api.components?.schemas);\n files.forEach((file) => this.#tags.set(file, ModelPluginSourceType.Model));\n storage.sources.push(...files);\n storage.pluginStorage.set(this.constructor.MODEL_PLUGIN_FILE_TAGS, this.#tags);\n }\n\n #processEntities(schemas: ReadonlyDeep<OpenAPIV3.ComponentsObject>['schemas'] | undefined): readonly SourceFile[] {\n this.logger.debug('Processing entities');\n\n if (!schemas) {\n return [];\n }\n\n const ctx: Context = {\n owner: this,\n };\n\n return Object.entries(schemas).map(([name, component]) => EntityModelProcessor.process(name, component, ctx));\n }\n}\n"],
5
- "mappings": "AAAA,OAAO,YAAY;AAKnB,SAAS,4BAA4B;AAG9B,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,WAAQ;AADE,SAAAA;AAAA,GAAA;AAIZ,MAAO,oBAAkC,OAAO;AAAA,EAC9C,OAAgB,yBAAyB;AAAA,EAEhC,QAAQ,oBAAI,QAA2C;AAAA,EAEhE,IAAa,OAAe;AAC1B,WAAO,YAAY;AAAA,EACrB;AAAA;AAAA,EAGA,MAAe,QAAQ,SAAuC;AAC5D,UAAM,QAAQ,KAAK,iBAAiB,QAAQ,IAAI,YAAY,OAAO;AACnE,UAAM,QAAQ,CAAC,SAAS,KAAK,MAAM,IAAI,MAAM,mBAA2B,CAAC;AACzE,YAAQ,QAAQ,KAAK,GAAG,KAAK;AAC7B,YAAQ,cAAc,IAAI,KAAK,YAAY,wBAAwB,KAAK,KAAK;AAAA,EAC/E;AAAA,EAEA,iBAAiB,SAAiG;AAChH,SAAK,OAAO,MAAM,qBAAqB;AAEvC,QAAI,CAAC,SAAS;AACZ,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,MAAe;AAAA,MACnB,OAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,SAAS,MAAM,qBAAqB,QAAQ,MAAM,WAAW,GAAG,CAAC;AAAA,EAC9G;AACF;",
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 { SourceFile } from 'typescript';\nimport { EntityModelProcessor } from './EntityModelProcessor.js';\nimport type { Context } from './utils.js';\n\nexport enum ModelPluginSourceType {\n Model = 'model',\n}\n\nexport default class ModelPlugin extends Plugin {\n static readonly MODEL_PLUGIN_FILE_TAGS = 'MODEL_PLUGIN_FILE_TAGS';\n declare ['constructor']: typeof ModelPlugin;\n readonly #tags = new WeakMap<SourceFile, ModelPluginSourceType>();\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 files = this.#processEntities(storage.api.components?.schemas);\n files.forEach((file) => this.#tags.set(file, ModelPluginSourceType.Model));\n storage.sources.push(...files);\n storage.pluginStorage.set(this.constructor.MODEL_PLUGIN_FILE_TAGS, this.#tags);\n }\n\n #processEntities(schemas: OpenAPIV3.ComponentsObject['schemas'] | undefined): readonly SourceFile[] {\n this.logger.debug('Processing entities');\n\n if (!schemas) {\n return [];\n }\n\n const ctx: Context = {\n owner: this,\n };\n\n return Object.entries(schemas).map(([name, component]) => EntityModelProcessor.process(name, component, ctx));\n }\n}\n"],
5
+ "mappings": "AAAA,OAAO,YAAY;AAInB,SAAS,4BAA4B;AAG9B,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,WAAQ;AADE,SAAAA;AAAA,GAAA;AAIZ,MAAO,oBAAkC,OAAO;AAAA,EAC9C,OAAgB,yBAAyB;AAAA,EAEhC,QAAQ,oBAAI,QAA2C;AAAA,EAEhE,IAAa,OAAe;AAC1B,WAAO,YAAY;AAAA,EACrB;AAAA;AAAA,EAGA,MAAe,QAAQ,SAAuC;AAC5D,UAAM,QAAQ,KAAK,iBAAiB,QAAQ,IAAI,YAAY,OAAO;AACnE,UAAM,QAAQ,CAAC,SAAS,KAAK,MAAM,IAAI,MAAM,mBAA2B,CAAC;AACzE,YAAQ,QAAQ,KAAK,GAAG,KAAK;AAC7B,YAAQ,cAAc,IAAI,KAAK,YAAY,wBAAwB,KAAK,KAAK;AAAA,EAC/E;AAAA,EAEA,iBAAiB,SAAmF;AAClG,SAAK,OAAO,MAAM,qBAAqB;AAEvC,QAAI,CAAC,SAAS;AACZ,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,MAAe;AAAA,MACnB,OAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,SAAS,MAAM,qBAAqB,QAAQ,MAAM,WAAW,GAAG,CAAC;AAAA,EAC9G;AACF;",
6
6
  "names": ["ModelPluginSourceType"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/hilla-generator-plugin-model",
3
- "version": "24.6.5",
3
+ "version": "24.7.0-alpha11",
4
4
  "description": "A Hilla TypeScript Generator plugin to generate form models",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -15,9 +15,10 @@
15
15
  "build:copy": "cd src && copyfiles **/*.d.ts ..",
16
16
  "lint": "eslint src test",
17
17
  "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",
18
+ "test": "vitest --run",
19
+ "test:coverage": "vitest --run --coverage",
20
+ "test:update": "vitest --run --update",
21
+ "test:watch": "vitest",
21
22
  "typecheck": "tsc --noEmit"
22
23
  },
23
24
  "exports": {
@@ -51,31 +52,12 @@
51
52
  "access": "public"
52
53
  },
53
54
  "dependencies": {
54
- "@vaadin/hilla-generator-core": "24.6.5",
55
- "@vaadin/hilla-generator-plugin-backbone": "24.6.5",
56
- "@vaadin/hilla-generator-utils": "24.6.5",
57
- "@vaadin/hilla-lit-form": "24.6.5",
58
- "fast-deep-equal": "^3.1.3",
59
- "openapi-types": "^12.1.3",
60
- "typescript": "5.7.2"
61
- },
62
- "devDependencies": {
63
- "@types/chai": "^4.3.6",
64
- "@types/mocha": "^10.0.2",
65
- "@types/node": "^20.7.1",
66
- "@types/sinon": "^10.0.17",
67
- "@types/sinon-chai": "^3.2.10",
68
- "@vaadin/hilla-generator-core": "24.6.5",
69
- "@vaadin/hilla-generator-plugin-client": "24.6.5",
70
- "c8": "^10.1.2",
71
- "chai": "^4.3.10",
72
- "concurrently": "^8.2.1",
73
- "copyfiles": "^2.4.1",
74
- "mocha": "^10.8.2",
75
- "monocart-coverage-reports": "^2.11.5",
76
- "pino": "^8.21.0",
77
- "sinon": "^16.1.3",
78
- "sinon-chai": "^3.7.0",
79
- "type-fest": "^4.3.2"
55
+ "@vaadin/hilla-generator-core": "24.7.0-alpha11",
56
+ "@vaadin/hilla-generator-plugin-backbone": "24.7.0-alpha11",
57
+ "@vaadin/hilla-generator-utils": "24.7.0-alpha11",
58
+ "@vaadin/hilla-lit-form": "24.7.0-alpha11",
59
+ "fast-deep-equal": "3.1.3",
60
+ "openapi-types": "12.1.3",
61
+ "typescript": "5.7.3"
80
62
  }
81
63
  }