@vaadin/hilla-generator-plugin-model 24.4.0-alpha2 → 24.4.0-alpha4

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,4 +1,4 @@
1
- import { type NonComposedRegularSchema, type Schema } from '@vaadin/hilla-generator-core/Schema.js';
1
+ import type { NonComposedRegularSchema, Schema } from '@vaadin/hilla-generator-core/Schema.js';
2
2
  import { type Identifier, type NewExpression } from 'typescript';
3
3
  export type ValidationConstrainedSchema = NonComposedRegularSchema & Readonly<{
4
4
  'x-validation-constraints': readonly ValidationConstraint[];
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationConstraintProcessor.d.ts","sourceRoot":"","sources":["src/ValidationConstraintProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,MAAM,EACZ,MAAM,wCAAwC,CAAC;AAEhD,OAAW,EAET,KAAK,UAAU,EACf,KAAK,aAAa,EAGnB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,GAChE,QAAQ,CAAC;IAAE,0BAA0B,EAAE,SAAS,oBAAoB,EAAE,CAAA;CAAE,CAAC,CAAC;AAE5E,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,2BAA2B,CAM9F;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,MAAM,4BAA4B,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,CAAC;AAQxE,qBAAa,6BAA6B;;gBAG5B,QAAQ,EAAE,4BAA4B;IAIlD,OAAO,CAAC,UAAU,EAAE,oBAAoB,GAAG,aAAa;CAoBzD"}
1
+ {"version":3,"file":"ValidationConstraintProcessor.d.ts","sourceRoot":"","sources":["src/ValidationConstraintProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAE/F,OAAW,EAET,KAAK,UAAU,EACf,KAAK,aAAa,EAGnB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,GAChE,QAAQ,CAAC;IAAE,0BAA0B,EAAE,SAAS,oBAAoB,EAAE,CAAA;CAAE,CAAC,CAAC;AAE5E,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,2BAA2B,CAK9F;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,MAAM,4BAA4B,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,CAAC;AAQxE,qBAAa,6BAA6B;;gBAG5B,QAAQ,EAAE,4BAA4B;IAIlD,OAAO,CAAC,UAAU,EAAE,oBAAoB,GAAG,aAAa;CAoBzD"}
@@ -1,11 +1,8 @@
1
- import {
2
- isNonComposedRegularSchema
3
- } from "@vaadin/hilla-generator-core/Schema.js";
4
1
  import { template, transform } from "@vaadin/hilla-generator-utils/ast.js";
5
2
  import ts, {
6
3
  } from "typescript";
7
4
  function hasValidationConstraints(schema) {
8
- return isNonComposedRegularSchema(schema) && "x-validation-constraints" in schema && schema["x-validation-constraints"].length > 0;
5
+ return "x-validation-constraints" in schema && schema["x-validation-constraints"].length > 0;
9
6
  }
10
7
  function selector([statement]) {
11
8
  return statement.declarationList.declarations[0].initializer;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/ValidationConstraintProcessor.ts"],
4
- "sourcesContent": ["import {\n isNonComposedRegularSchema,\n type NonComposedRegularSchema,\n type Schema,\n} from '@vaadin/hilla-generator-core/Schema.js';\nimport { template, transform } from '@vaadin/hilla-generator-utils/ast.js';\nimport ts, {\n type Expression,\n type Identifier,\n type NewExpression,\n type Statement,\n type VariableStatement,\n} from 'typescript';\n\nexport type ValidationConstrainedSchema = NonComposedRegularSchema &\n Readonly<{ 'x-validation-constraints': readonly ValidationConstraint[] }>;\n\nexport function hasValidationConstraints(schema: Schema): schema is ValidationConstrainedSchema {\n return (\n isNonComposedRegularSchema(schema) &&\n 'x-validation-constraints' in schema &&\n (schema as ValidationConstrainedSchema)['x-validation-constraints'].length > 0\n );\n}\n\nexport interface ValidationConstraint {\n simpleName: string;\n attributes?: Record<string, unknown>;\n}\n\nexport type ValidationConstraintImporter = (name: string) => Identifier;\n\nfunction selector<T extends Expression>([statement]: readonly Statement[]): T {\n return (statement as VariableStatement).declarationList.declarations[0].initializer as T;\n}\n\nconst variableStatementVar = 'const a';\n\nexport class ValidationConstraintProcessor {\n readonly #importer: ValidationConstraintImporter;\n\n constructor(importer: ValidationConstraintImporter) {\n this.#importer = importer;\n }\n\n process(constraint: ValidationConstraint): NewExpression {\n return ts.factory.createNewExpression(\n this.#importer(constraint.simpleName),\n undefined,\n constraint.attributes ? [ValidationConstraintProcessor.#processAttributes(constraint.attributes)] : [],\n );\n }\n\n static #processAttributes(attributes: Record<string, unknown>): Expression {\n const names = Object.keys(attributes);\n const tpl = JSON.stringify(names.includes('value') && names.length === 1 ? attributes.value : attributes);\n\n return template(`${variableStatementVar}=${tpl}`, selector, [\n transform((node) =>\n ts.isPropertyAssignment(node) && ts.isStringLiteral(node.name)\n ? ts.factory.createPropertyAssignment(node.name.text, node.initializer)\n : node,\n ),\n ]);\n }\n}\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,UAAU,iBAAiB;AACpC,OAAO;AAAA,OAMA;AAKA,SAAS,yBAAyB,QAAuD;AAC9F,SACE,2BAA2B,MAAM,KACjC,8BAA8B,UAC7B,OAAuC,0BAA0B,EAAE,SAAS;AAEjF;AASA,SAAS,SAA+B,CAAC,SAAS,GAA4B;AAC5E,SAAQ,UAAgC,gBAAgB,aAAa,CAAC,EAAE;AAC1E;AAEA,MAAM,uBAAuB;AAEtB,MAAM,8BAA8B;AAAA,EAChC;AAAA,EAET,YAAY,UAAwC;AAClD,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,QAAQ,YAAiD;AACvD,WAAO,GAAG,QAAQ;AAAA,MAChB,KAAK,UAAU,WAAW,UAAU;AAAA,MACpC;AAAA,MACA,WAAW,aAAa,CAAC,8BAA8B,mBAAmB,WAAW,UAAU,CAAC,IAAI,CAAC;AAAA,IACvG;AAAA,EACF;AAAA,EAEA,OAAO,mBAAmB,YAAiD;AACzE,UAAM,QAAQ,OAAO,KAAK,UAAU;AACpC,UAAM,MAAM,KAAK,UAAU,MAAM,SAAS,OAAO,KAAK,MAAM,WAAW,IAAI,WAAW,QAAQ,UAAU;AAExG,WAAO,SAAS,GAAG,oBAAoB,IAAI,GAAG,IAAI,UAAU;AAAA,MAC1D;AAAA,QAAU,CAAC,SACT,GAAG,qBAAqB,IAAI,KAAK,GAAG,gBAAgB,KAAK,IAAI,IACzD,GAAG,QAAQ,yBAAyB,KAAK,KAAK,MAAM,KAAK,WAAW,IACpE;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import type { NonComposedRegularSchema, Schema } from '@vaadin/hilla-generator-core/Schema.js';\nimport { template, transform } from '@vaadin/hilla-generator-utils/ast.js';\nimport ts, {\n type Expression,\n type Identifier,\n type NewExpression,\n type Statement,\n type VariableStatement,\n} from 'typescript';\n\nexport type ValidationConstrainedSchema = NonComposedRegularSchema &\n Readonly<{ 'x-validation-constraints': readonly ValidationConstraint[] }>;\n\nexport function hasValidationConstraints(schema: Schema): schema is ValidationConstrainedSchema {\n return (\n 'x-validation-constraints' in schema &&\n (schema as ValidationConstrainedSchema)['x-validation-constraints'].length > 0\n );\n}\n\nexport interface ValidationConstraint {\n simpleName: string;\n attributes?: Record<string, unknown>;\n}\n\nexport type ValidationConstraintImporter = (name: string) => Identifier;\n\nfunction selector<T extends Expression>([statement]: readonly Statement[]): T {\n return (statement as VariableStatement).declarationList.declarations[0].initializer as T;\n}\n\nconst variableStatementVar = 'const a';\n\nexport class ValidationConstraintProcessor {\n readonly #importer: ValidationConstraintImporter;\n\n constructor(importer: ValidationConstraintImporter) {\n this.#importer = importer;\n }\n\n process(constraint: ValidationConstraint): NewExpression {\n return ts.factory.createNewExpression(\n this.#importer(constraint.simpleName),\n undefined,\n constraint.attributes ? [ValidationConstraintProcessor.#processAttributes(constraint.attributes)] : [],\n );\n }\n\n static #processAttributes(attributes: Record<string, unknown>): Expression {\n const names = Object.keys(attributes);\n const tpl = JSON.stringify(names.includes('value') && names.length === 1 ? attributes.value : attributes);\n\n return template(`${variableStatementVar}=${tpl}`, selector, [\n transform((node) =>\n ts.isPropertyAssignment(node) && ts.isStringLiteral(node.name)\n ? ts.factory.createPropertyAssignment(node.name.text, node.initializer)\n : node,\n ),\n ]);\n }\n}\n"],
5
+ "mappings": "AACA,SAAS,UAAU,iBAAiB;AACpC,OAAO;AAAA,OAMA;AAKA,SAAS,yBAAyB,QAAuD;AAC9F,SACE,8BAA8B,UAC7B,OAAuC,0BAA0B,EAAE,SAAS;AAEjF;AASA,SAAS,SAA+B,CAAC,SAAS,GAA4B;AAC5E,SAAQ,UAAgC,gBAAgB,aAAa,CAAC,EAAE;AAC1E;AAEA,MAAM,uBAAuB;AAEtB,MAAM,8BAA8B;AAAA,EAChC;AAAA,EAET,YAAY,UAAwC;AAClD,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,QAAQ,YAAiD;AACvD,WAAO,GAAG,QAAQ;AAAA,MAChB,KAAK,UAAU,WAAW,UAAU;AAAA,MACpC;AAAA,MACA,WAAW,aAAa,CAAC,8BAA8B,mBAAmB,WAAW,UAAU,CAAC,IAAI,CAAC;AAAA,IACvG;AAAA,EACF;AAAA,EAEA,OAAO,mBAAmB,YAAiD;AACzE,UAAM,QAAQ,OAAO,KAAK,UAAU;AACpC,UAAM,MAAM,KAAK,UAAU,MAAM,SAAS,OAAO,KAAK,MAAM,WAAW,IAAI,WAAW,QAAQ,UAAU;AAExG,WAAO,SAAS,GAAG,oBAAoB,IAAI,GAAG,IAAI,UAAU;AAAA,MAC1D;AAAA,QAAU,CAAC,SACT,GAAG,qBAAqB,IAAI,KAAK,GAAG,gBAAgB,KAAK,IAAI,IACzD,GAAG,QAAQ,yBAAyB,KAAK,KAAK,MAAM,KAAK,WAAW,IACpE;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/hilla-generator-plugin-model",
3
- "version": "24.4.0-alpha2",
3
+ "version": "24.4.0-alpha4",
4
4
  "description": "A Hilla TypeScript Generator plugin to generate form models",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -51,19 +51,19 @@
51
51
  "access": "public"
52
52
  },
53
53
  "peerDependencies": {
54
- "@vaadin/hilla-lit-form": "24.4.0-alpha2",
55
- "@vaadin/hilla-generator-core": "24.4.0-alpha2",
56
- "@vaadin/hilla-generator-plugin-backbone": "24.4.0-alpha2"
54
+ "@vaadin/hilla-lit-form": "24.4.0-alpha4",
55
+ "@vaadin/hilla-generator-core": "24.4.0-alpha4",
56
+ "@vaadin/hilla-generator-plugin-backbone": "24.4.0-alpha4"
57
57
  },
58
58
  "dependencies": {
59
- "@vaadin/hilla-generator-utils": "24.4.0-alpha2",
59
+ "@vaadin/hilla-generator-utils": "24.4.0-alpha4",
60
60
  "fast-deep-equal": "^3.1.3",
61
61
  "openapi-types": "^12.1.3",
62
62
  "typescript": "5.3.2"
63
63
  },
64
64
  "devDependencies": {
65
- "@vaadin/hilla-generator-core": "24.4.0-alpha2",
66
- "@vaadin/hilla-generator-plugin-client": "24.4.0-alpha2",
65
+ "@vaadin/hilla-generator-core": "24.4.0-alpha4",
66
+ "@vaadin/hilla-generator-plugin-client": "24.4.0-alpha4",
67
67
  "@types/chai": "^4.3.6",
68
68
  "@types/mocha": "^10.0.2",
69
69
  "@types/node": "^20.7.1",