@vaadin/hilla-generator-plugin-backbone 24.6.4 → 24.7.0-alpha10
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":"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;
|
|
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;IAE5D,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;IAkB/C,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CACrE"}
|
|
@@ -7,9 +7,10 @@ import EndpointMethodResponseProcessor from "./EndpointMethodResponseProcessor.j
|
|
|
7
7
|
const INIT_TYPE_NAME = "EndpointRequestInit";
|
|
8
8
|
const HILLA_FRONTEND_NAME = "@vaadin/hilla-frontend";
|
|
9
9
|
class EndpointMethodOperationProcessor {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
10
11
|
static createProcessor(httpMethod, endpointName, endpointMethodName, operation, dependencies, owner) {
|
|
11
12
|
switch (httpMethod) {
|
|
12
|
-
case OpenAPIV3.HttpMethods.POST:
|
|
13
|
+
case OpenAPIV3.HttpMethods.POST: {
|
|
13
14
|
return new EndpointMethodOperationPOSTProcessor(
|
|
14
15
|
endpointName,
|
|
15
16
|
endpointMethodName,
|
|
@@ -17,6 +18,7 @@ class EndpointMethodOperationProcessor {
|
|
|
17
18
|
dependencies,
|
|
18
19
|
owner
|
|
19
20
|
);
|
|
21
|
+
}
|
|
20
22
|
default:
|
|
21
23
|
owner.logger.warn(`Processing ${httpMethod.toUpperCase()} currently is not supported`);
|
|
22
24
|
return void 0;
|
|
@@ -29,6 +31,7 @@ class EndpointMethodOperationPOSTProcessor extends EndpointMethodOperationProces
|
|
|
29
31
|
#endpointName;
|
|
30
32
|
#operation;
|
|
31
33
|
#owner;
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
32
35
|
constructor(endpointName, endpointMethodName, operation, dependencies, owner) {
|
|
33
36
|
super();
|
|
34
37
|
this.#owner = owner;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/EndpointMethodOperationProcessor.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-params */\nimport type Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport ClientPlugin from '@vaadin/hilla-generator-plugin-client';\nimport type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';\nimport equal from 'fast-deep-equal';\nimport { OpenAPIV3 } from 'openapi-types';\nimport type { ReadonlyDeep } from 'type-fest';\nimport ts, { type Expression, type Statement, type TypeNode } from 'typescript';\nimport EndpointMethodRequestBodyProcessor from './EndpointMethodRequestBodyProcessor.js';\nimport EndpointMethodResponseProcessor from './EndpointMethodResponseProcessor.js';\n\nexport type EndpointMethodOperation = ReadonlyDeep<OpenAPIV3.OperationObject>;\n\nexport const INIT_TYPE_NAME = 'EndpointRequestInit';\nexport const HILLA_FRONTEND_NAME = '@vaadin/hilla-frontend';\n\nexport default abstract class EndpointMethodOperationProcessor {\n static createProcessor(\n httpMethod: OpenAPIV3.HttpMethods,\n endpointName: string,\n endpointMethodName: string,\n operation: EndpointMethodOperation,\n dependencies: DependencyManager,\n owner: Plugin,\n ): EndpointMethodOperationProcessor | undefined {\n switch (httpMethod) {\n case OpenAPIV3.HttpMethods.POST
|
|
5
|
-
"mappings": "AAEA,OAAO,kBAAkB;AAEzB,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAE1B,OAAO,YAA4D;AACnE,OAAO,wCAAwC;AAC/C,OAAO,qCAAqC;AAIrC,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAEnC,MAAO,iCAAwD;AAAA,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-params */\nimport type Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport ClientPlugin from '@vaadin/hilla-generator-plugin-client';\nimport type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';\nimport equal from 'fast-deep-equal';\nimport { OpenAPIV3 } from 'openapi-types';\nimport type { ReadonlyDeep } from 'type-fest';\nimport ts, { type Expression, type Statement, type TypeNode } from 'typescript';\nimport EndpointMethodRequestBodyProcessor from './EndpointMethodRequestBodyProcessor.js';\nimport EndpointMethodResponseProcessor from './EndpointMethodResponseProcessor.js';\n\nexport type EndpointMethodOperation = ReadonlyDeep<OpenAPIV3.OperationObject>;\n\nexport const INIT_TYPE_NAME = 'EndpointRequestInit';\nexport const HILLA_FRONTEND_NAME = '@vaadin/hilla-frontend';\n\nexport default abstract class EndpointMethodOperationProcessor {\n // eslint-disable-next-line @typescript-eslint/max-params\n static createProcessor(\n httpMethod: OpenAPIV3.HttpMethods,\n endpointName: string,\n endpointMethodName: string,\n operation: EndpointMethodOperation,\n dependencies: DependencyManager,\n owner: Plugin,\n ): EndpointMethodOperationProcessor | undefined {\n switch (httpMethod) {\n case OpenAPIV3.HttpMethods.POST: {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return new EndpointMethodOperationPOSTProcessor(\n endpointName,\n endpointMethodName,\n operation,\n dependencies,\n owner,\n );\n }\n default:\n owner.logger.warn(`Processing ${httpMethod.toUpperCase()} currently is not supported`);\n return undefined;\n }\n }\n\n abstract process(outputDir?: string): Promise<Statement | undefined>;\n}\n\nclass EndpointMethodOperationPOSTProcessor extends EndpointMethodOperationProcessor {\n readonly #dependencies: DependencyManager;\n readonly #endpointMethodName: string;\n readonly #endpointName: string;\n readonly #operation: EndpointMethodOperation;\n readonly #owner: Plugin;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n endpointName: string,\n endpointMethodName: string,\n operation: EndpointMethodOperation,\n dependencies: DependencyManager,\n owner: Plugin,\n ) {\n super();\n this.#owner = owner;\n this.#dependencies = dependencies;\n this.#endpointName = endpointName;\n this.#endpointMethodName = endpointMethodName;\n this.#operation = operation;\n }\n\n async process(outputDir?: string): Promise<Statement | undefined> {\n const { exports, imports, paths } = this.#dependencies;\n this.#owner.logger.debug(`${this.#endpointName}.${this.#endpointMethodName} - processing POST method`);\n const initTypeIdentifier = imports.named.getIdentifier(\n paths.createBareModulePath(HILLA_FRONTEND_NAME),\n INIT_TYPE_NAME,\n )!;\n\n const { initParam, packedParameters, parameters } = new EndpointMethodRequestBodyProcessor(\n this.#operation.requestBody,\n this.#dependencies,\n this.#owner,\n initTypeIdentifier,\n ).process();\n\n const methodIdentifier = exports.named.add(this.#endpointMethodName);\n const clientLibIdentifier = imports.default.getIdentifier(\n paths.createRelativePath(await ClientPlugin.getClientFileName(outputDir)),\n )!;\n\n const callExpression = ts.factory.createCallExpression(\n ts.factory.createPropertyAccessExpression(clientLibIdentifier, ts.factory.createIdentifier('call')),\n undefined,\n [\n ts.factory.createStringLiteral(this.#endpointName),\n ts.factory.createStringLiteral(this.#endpointMethodName),\n packedParameters,\n initParam,\n ].filter(Boolean) as readonly Expression[],\n );\n\n const responseType = this.#prepareResponseType();\n\n return ts.factory.createFunctionDeclaration(\n [ts.factory.createToken(ts.SyntaxKind.AsyncKeyword)],\n undefined,\n methodIdentifier,\n undefined,\n parameters,\n ts.factory.createTypeReferenceNode('Promise', [responseType]),\n ts.factory.createBlock([ts.factory.createReturnStatement(callExpression)]),\n );\n }\n\n #prepareResponseType(): TypeNode {\n this.#owner.logger.debug(`${this.#endpointName}.${this.#endpointMethodName} POST - processing response type`);\n\n const responseTypes = Object.entries(this.#operation.responses)\n .flatMap(([code, response]) =>\n new EndpointMethodResponseProcessor(code, response, this.#dependencies, this.#owner).process(),\n )\n .filter((value, index, arr) => arr.findIndex((v) => equal(v, value)) === index);\n\n if (responseTypes.length === 0) {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword);\n }\n\n return ts.factory.createUnionTypeNode(responseTypes);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEA,OAAO,kBAAkB;AAEzB,OAAO,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package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-generator-plugin-backbone",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.7.0-alpha10",
|
|
4
4
|
"description": "A Hilla TypeScript Generator plugin to generate basic code",
|
|
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": "
|
|
19
|
-
"test:
|
|
20
|
-
"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,30 +52,11 @@
|
|
|
51
52
|
"access": "public"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@vaadin/hilla-generator-core": "24.
|
|
55
|
-
"@vaadin/hilla-generator-plugin-client": "24.
|
|
56
|
-
"@vaadin/hilla-generator-utils": "24.
|
|
57
|
-
"fast-deep-equal": "
|
|
58
|
-
"openapi-types": "
|
|
59
|
-
"typescript": "5.7.
|
|
60
|
-
},
|
|
61
|
-
"devDependencies": {
|
|
62
|
-
"@types/chai": "^4.3.6",
|
|
63
|
-
"@types/mocha": "^10.0.2",
|
|
64
|
-
"@types/node": "^20.7.1",
|
|
65
|
-
"@types/sinon": "^10.0.17",
|
|
66
|
-
"@types/sinon-chai": "^3.2.10",
|
|
67
|
-
"@vaadin/hilla-generator-core": "24.6.4",
|
|
68
|
-
"@vaadin/hilla-generator-plugin-client": "24.6.4",
|
|
69
|
-
"c8": "^10.1.2",
|
|
70
|
-
"chai": "^4.3.10",
|
|
71
|
-
"concurrently": "^8.2.1",
|
|
72
|
-
"copyfiles": "^2.4.1",
|
|
73
|
-
"mocha": "^10.8.2",
|
|
74
|
-
"monocart-coverage-reports": "^2.11.5",
|
|
75
|
-
"pino": "^8.21.0",
|
|
76
|
-
"sinon": "^16.1.3",
|
|
77
|
-
"sinon-chai": "^3.7.0",
|
|
78
|
-
"type-fest": "^4.3.2"
|
|
55
|
+
"@vaadin/hilla-generator-core": "24.7.0-alpha10",
|
|
56
|
+
"@vaadin/hilla-generator-plugin-client": "24.7.0-alpha10",
|
|
57
|
+
"@vaadin/hilla-generator-utils": "24.7.0-alpha10",
|
|
58
|
+
"fast-deep-equal": "3.1.3",
|
|
59
|
+
"openapi-types": "12.1.3",
|
|
60
|
+
"typescript": "5.7.3"
|
|
79
61
|
}
|
|
80
62
|
}
|