@vaadin/hilla-generator-plugin-backbone 24.4.0-alpha1
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/.lintstagedrc.js +6 -0
- package/EndpointMethodOperationProcessor.d.ts +13 -0
- package/EndpointMethodOperationProcessor.d.ts.map +1 -0
- package/EndpointMethodOperationProcessor.js +94 -0
- package/EndpointMethodOperationProcessor.js.map +7 -0
- package/EndpointMethodRequestBodyProcessor.d.ts +17 -0
- package/EndpointMethodRequestBodyProcessor.d.ts.map +1 -0
- package/EndpointMethodRequestBodyProcessor.js +84 -0
- package/EndpointMethodRequestBodyProcessor.js.map +7 -0
- package/EndpointMethodResponseProcessor.d.ts +13 -0
- package/EndpointMethodResponseProcessor.d.ts.map +1 -0
- package/EndpointMethodResponseProcessor.js +31 -0
- package/EndpointMethodResponseProcessor.js.map +7 -0
- package/EndpointProcessor.d.ts +11 -0
- package/EndpointProcessor.d.ts.map +1 -0
- package/EndpointProcessor.js +63 -0
- package/EndpointProcessor.js.map +7 -0
- package/EntityProcessor.d.ts +9 -0
- package/EntityProcessor.d.ts.map +1 -0
- package/EntityProcessor.js +132 -0
- package/EntityProcessor.js.map +7 -0
- package/LICENSE +201 -0
- package/README.md +1 -0
- package/TypeSchemaProcessor.d.ts +10 -0
- package/TypeSchemaProcessor.d.ts.map +1 -0
- package/TypeSchemaProcessor.js +93 -0
- package/TypeSchemaProcessor.js.map +7 -0
- package/index.d.ts +14 -0
- package/index.d.ts.map +1 -0
- package/index.js +55 -0
- package/index.js.map +7 -0
- package/package.json +82 -0
- package/utils.d.ts +2 -0
- package/utils.d.ts.map +1 -0
- package/utils.js +5 -0
- package/utils.js.map +7 -0
package/.lintstagedrc.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type Plugin from '@vaadin/hilla-generator-core/Plugin.js';
|
|
2
|
+
import type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';
|
|
3
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
4
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
5
|
+
import { type Statement } from 'typescript';
|
|
6
|
+
export type EndpointMethodOperation = ReadonlyDeep<OpenAPIV3.OperationObject>;
|
|
7
|
+
export declare const INIT_TYPE_NAME = "EndpointRequestInit";
|
|
8
|
+
export declare const HILLA_FRONTEND_NAME = "@vaadin/hilla-core";
|
|
9
|
+
export default abstract class EndpointMethodOperationProcessor {
|
|
10
|
+
static createProcessor(httpMethod: OpenAPIV3.HttpMethods, endpointName: string, endpointMethodName: string, operation: EndpointMethodOperation, dependencies: DependencyManager, owner: Plugin): EndpointMethodOperationProcessor | undefined;
|
|
11
|
+
abstract process(outputDir?: string): Promise<Statement | undefined>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=EndpointMethodOperationProcessor.d.ts.map
|
|
@@ -0,0 +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,uBAAuB,CAAC;AAExD,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,gCAAgC;IAC5D,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;IAiB/C,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CACrE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import ClientPlugin from "@vaadin/hilla-generator-plugin-client";
|
|
2
|
+
import equal from "fast-deep-equal";
|
|
3
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
4
|
+
import ts, {} from "typescript";
|
|
5
|
+
import EndpointMethodRequestBodyProcessor from "./EndpointMethodRequestBodyProcessor.js";
|
|
6
|
+
import EndpointMethodResponseProcessor from "./EndpointMethodResponseProcessor.js";
|
|
7
|
+
const INIT_TYPE_NAME = "EndpointRequestInit";
|
|
8
|
+
const HILLA_FRONTEND_NAME = "@vaadin/hilla-core";
|
|
9
|
+
class EndpointMethodOperationProcessor {
|
|
10
|
+
static createProcessor(httpMethod, endpointName, endpointMethodName, operation, dependencies, owner) {
|
|
11
|
+
switch (httpMethod) {
|
|
12
|
+
case OpenAPIV3.HttpMethods.POST:
|
|
13
|
+
return new EndpointMethodOperationPOSTProcessor(
|
|
14
|
+
endpointName,
|
|
15
|
+
endpointMethodName,
|
|
16
|
+
operation,
|
|
17
|
+
dependencies,
|
|
18
|
+
owner
|
|
19
|
+
);
|
|
20
|
+
default:
|
|
21
|
+
owner.logger.warn(`Processing ${httpMethod.toUpperCase()} currently is not supported`);
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class EndpointMethodOperationPOSTProcessor extends EndpointMethodOperationProcessor {
|
|
27
|
+
#dependencies;
|
|
28
|
+
#endpointMethodName;
|
|
29
|
+
#endpointName;
|
|
30
|
+
#operation;
|
|
31
|
+
#owner;
|
|
32
|
+
constructor(endpointName, endpointMethodName, operation, dependencies, owner) {
|
|
33
|
+
super();
|
|
34
|
+
this.#owner = owner;
|
|
35
|
+
this.#dependencies = dependencies;
|
|
36
|
+
this.#endpointName = endpointName;
|
|
37
|
+
this.#endpointMethodName = endpointMethodName;
|
|
38
|
+
this.#operation = operation;
|
|
39
|
+
}
|
|
40
|
+
async process(outputDir) {
|
|
41
|
+
const { exports, imports, paths } = this.#dependencies;
|
|
42
|
+
this.#owner.logger.debug(`${this.#endpointName}.${this.#endpointMethodName} - processing POST method`);
|
|
43
|
+
const initTypeIdentifier = imports.named.getIdentifier(
|
|
44
|
+
paths.createBareModulePath(HILLA_FRONTEND_NAME),
|
|
45
|
+
INIT_TYPE_NAME
|
|
46
|
+
);
|
|
47
|
+
const { initParam, packedParameters, parameters } = new EndpointMethodRequestBodyProcessor(
|
|
48
|
+
this.#operation.requestBody,
|
|
49
|
+
this.#dependencies,
|
|
50
|
+
this.#owner,
|
|
51
|
+
initTypeIdentifier
|
|
52
|
+
).process();
|
|
53
|
+
const methodIdentifier = exports.named.add(this.#endpointMethodName);
|
|
54
|
+
const clientLibIdentifier = imports.default.getIdentifier(
|
|
55
|
+
paths.createRelativePath(await ClientPlugin.getClientFileName(outputDir))
|
|
56
|
+
);
|
|
57
|
+
const callExpression = ts.factory.createCallExpression(
|
|
58
|
+
ts.factory.createPropertyAccessExpression(clientLibIdentifier, ts.factory.createIdentifier("call")),
|
|
59
|
+
void 0,
|
|
60
|
+
[
|
|
61
|
+
ts.factory.createStringLiteral(this.#endpointName),
|
|
62
|
+
ts.factory.createStringLiteral(this.#endpointMethodName),
|
|
63
|
+
packedParameters,
|
|
64
|
+
initParam
|
|
65
|
+
].filter(Boolean)
|
|
66
|
+
);
|
|
67
|
+
const responseType = this.#prepareResponseType();
|
|
68
|
+
return ts.factory.createFunctionDeclaration(
|
|
69
|
+
[ts.factory.createToken(ts.SyntaxKind.AsyncKeyword)],
|
|
70
|
+
void 0,
|
|
71
|
+
methodIdentifier,
|
|
72
|
+
void 0,
|
|
73
|
+
parameters,
|
|
74
|
+
ts.factory.createTypeReferenceNode("Promise", [responseType]),
|
|
75
|
+
ts.factory.createBlock([ts.factory.createReturnStatement(callExpression)])
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
#prepareResponseType() {
|
|
79
|
+
this.#owner.logger.debug(`${this.#endpointName}.${this.#endpointMethodName} POST - processing response type`);
|
|
80
|
+
const responseTypes = Object.entries(this.#operation.responses).flatMap(
|
|
81
|
+
([code, response]) => new EndpointMethodResponseProcessor(code, response, this.#dependencies, this.#owner).process()
|
|
82
|
+
).filter((value, index, arr) => arr.findIndex((v) => equal(v, value)) === index);
|
|
83
|
+
if (responseTypes.length === 0) {
|
|
84
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword);
|
|
85
|
+
}
|
|
86
|
+
return ts.factory.createUnionTypeNode(responseTypes);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
HILLA_FRONTEND_NAME,
|
|
91
|
+
INIT_TYPE_NAME,
|
|
92
|
+
EndpointMethodOperationProcessor as default
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=EndpointMethodOperationProcessor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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-core';\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:\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 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 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,WAAW;AAClB,SAAS,iBAAiB;AAE1B,OAAO,YAA4D;AACnE,OAAO,wCAAwC;AAC/C,OAAO,qCAAqC;AAIrC,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAEnC,MAAO,iCAAwD;AAAA,EAC7D,OAAO,gBACL,YACA,cACA,oBACA,WACA,cACA,OAC8C;AAC9C,YAAQ,YAAY;AAAA,MAClB,KAAK,UAAU,YAAY;AAEzB,eAAO,IAAI;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;A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C,WAAO,GAAG,QAAQ;AAAA,MAChB,CAAC,GAAG,QAAQ,YAAY,GAAG,WAAW,YAAY,CAAC;AAAA,MACnD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG,QAAQ,wBAAwB,WAAW,CAAC,YAAY,CAAC;AAAA,MAC5D,GAAG,QAAQ,YAAY,CAAC,GAAG,QAAQ,sBAAsB,cAAc,CAAC,CAAC;AAAA,IAC3E;AAAA,EACF;AAAA,EAEA,uBAAiC;AAC/B,SAAK,OAAO,OAAO,MAAM,GAAG,KAAK,aAAa,IAAI,KAAK,mBAAmB,kCAAkC;AAE5G,UAAM,gBAAgB,OAAO,QAAQ,KAAK,WAAW,SAAS,EAC3D;AAAA,MAAQ,CAAC,CAAC,MAAM,QAAQ,MACvB,IAAI,gCAAgC,MAAM,UAAU,KAAK,eAAe,KAAK,MAAM,EAAE,QAAQ;AAAA,IAC/F,EACC,OAAO,CAAC,OAAO,OAAO,QAAQ,IAAI,UAAU,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,KAAK;AAEhF,QAAI,cAAc,WAAW,GAAG;AAC9B,aAAO,GAAG,QAAQ,sBAAsB,GAAG,WAAW,WAAW;AAAA,IACnE;AAEA,WAAO,GAAG,QAAQ,oBAAoB,aAAa;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type Plugin from '@vaadin/hilla-generator-core/Plugin.js';
|
|
2
|
+
import type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';
|
|
3
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
4
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
5
|
+
import ts, { type ObjectLiteralExpression, type ParameterDeclaration } from 'typescript';
|
|
6
|
+
export type EndpointMethodRequestBody = ReadonlyDeep<OpenAPIV3.RequestBodyObject>;
|
|
7
|
+
export type EndpointMethodRequestBodyProcessingResult = Readonly<{
|
|
8
|
+
parameters: readonly ParameterDeclaration[];
|
|
9
|
+
packedParameters?: ObjectLiteralExpression;
|
|
10
|
+
initParam: ts.Identifier;
|
|
11
|
+
}>;
|
|
12
|
+
export default class EndpointMethodRequestBodyProcessor {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(requestBody: ReadonlyDeep<OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject> | undefined, dependencies: DependencyManager, owner: Plugin, initTypeIdentifier: ts.Identifier);
|
|
15
|
+
process(): EndpointMethodRequestBodyProcessingResult;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=EndpointMethodRequestBodyProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointMethodRequestBodyProcessor.d.ts","sourceRoot":"","sources":["src/EndpointMethodRequestBodyProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AAOjE,OAAO,KAAK,iBAAiB,MAAM,iEAAiE,CAAC;AACrG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,KAAK,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIzF,MAAM,MAAM,yBAAyB,GAAG,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAElF,MAAM,MAAM,yCAAyC,GAAG,QAAQ,CAAC;IAC/D,UAAU,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC5C,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;IAC3C,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC;CAC1B,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,OAAO,kCAAkC;;gBASnD,WAAW,EAAE,YAAY,CAAC,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,iBAAiB,CAAC,GAAG,SAAS,EAC9F,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,MAAM,EACb,kBAAkB,EAAE,EAAE,CAAC,UAAU;IAQnC,OAAO,IAAI,yCAAyC;CAuErD"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isEmptyObject,
|
|
3
|
+
isObjectSchema
|
|
4
|
+
} from "@vaadin/hilla-generator-core/Schema.js";
|
|
5
|
+
import ts, {} from "typescript";
|
|
6
|
+
import TypeSchemaProcessor from "./TypeSchemaProcessor.js";
|
|
7
|
+
import { defaultMediaType } from "./utils.js";
|
|
8
|
+
class EndpointMethodRequestBodyProcessor {
|
|
9
|
+
static #defaultInitParamName = "init";
|
|
10
|
+
#dependencies;
|
|
11
|
+
#owner;
|
|
12
|
+
#requestBody;
|
|
13
|
+
#initTypeIdentifier;
|
|
14
|
+
constructor(requestBody, dependencies, owner, initTypeIdentifier) {
|
|
15
|
+
this.#owner = owner;
|
|
16
|
+
this.#dependencies = dependencies;
|
|
17
|
+
this.#requestBody = requestBody ? owner.resolver.resolve(requestBody) : void 0;
|
|
18
|
+
this.#initTypeIdentifier = initTypeIdentifier;
|
|
19
|
+
}
|
|
20
|
+
process() {
|
|
21
|
+
if (!this.#requestBody) {
|
|
22
|
+
return {
|
|
23
|
+
initParam: ts.factory.createIdentifier(EndpointMethodRequestBodyProcessor.#defaultInitParamName),
|
|
24
|
+
packedParameters: ts.factory.createObjectLiteralExpression(),
|
|
25
|
+
parameters: [
|
|
26
|
+
ts.factory.createParameterDeclaration(
|
|
27
|
+
void 0,
|
|
28
|
+
void 0,
|
|
29
|
+
EndpointMethodRequestBodyProcessor.#defaultInitParamName,
|
|
30
|
+
ts.factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
31
|
+
ts.factory.createTypeReferenceNode(this.#initTypeIdentifier)
|
|
32
|
+
)
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const parameterData = this.#extractParameterData(this.#requestBody.content[defaultMediaType].schema);
|
|
37
|
+
const parameterNames = parameterData.map(([name]) => name);
|
|
38
|
+
let initParamName = EndpointMethodRequestBodyProcessor.#defaultInitParamName;
|
|
39
|
+
while (parameterNames.includes(initParamName)) {
|
|
40
|
+
initParamName = `_${initParamName}`;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
initParam: ts.factory.createIdentifier(initParamName),
|
|
44
|
+
packedParameters: ts.factory.createObjectLiteralExpression(
|
|
45
|
+
parameterData.map(([name]) => ts.factory.createShorthandPropertyAssignment(name))
|
|
46
|
+
),
|
|
47
|
+
parameters: [
|
|
48
|
+
...parameterData.map(([name, schema]) => {
|
|
49
|
+
const nodes = new TypeSchemaProcessor(schema, this.#dependencies).process();
|
|
50
|
+
return ts.factory.createParameterDeclaration(
|
|
51
|
+
void 0,
|
|
52
|
+
void 0,
|
|
53
|
+
name,
|
|
54
|
+
void 0,
|
|
55
|
+
ts.factory.createUnionTypeNode(nodes)
|
|
56
|
+
);
|
|
57
|
+
}),
|
|
58
|
+
ts.factory.createParameterDeclaration(
|
|
59
|
+
void 0,
|
|
60
|
+
void 0,
|
|
61
|
+
initParamName,
|
|
62
|
+
ts.factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
63
|
+
ts.factory.createTypeReferenceNode(this.#initTypeIdentifier)
|
|
64
|
+
)
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
#extractParameterData(basicSchema) {
|
|
69
|
+
if (!basicSchema) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const { logger, resolver } = this.#owner;
|
|
73
|
+
const resolvedSchema = resolver.resolve(basicSchema);
|
|
74
|
+
if (isObjectSchema(resolvedSchema) && !isEmptyObject(resolvedSchema)) {
|
|
75
|
+
return Object.entries(resolvedSchema.properties);
|
|
76
|
+
}
|
|
77
|
+
logger.warn("A schema provided for endpoint method's 'requestBody' is not supported");
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
EndpointMethodRequestBodyProcessor as default
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=EndpointMethodRequestBodyProcessor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/EndpointMethodRequestBodyProcessor.ts"],
|
|
4
|
+
"sourcesContent": ["import type Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport {\n isEmptyObject,\n isObjectSchema,\n type NonEmptyObjectSchema,\n type Schema,\n} from '@vaadin/hilla-generator-core/Schema.js';\nimport type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { ReadonlyDeep } from 'type-fest';\nimport ts, { type ObjectLiteralExpression, type ParameterDeclaration } from 'typescript';\nimport TypeSchemaProcessor from './TypeSchemaProcessor.js';\nimport { defaultMediaType } from './utils.js';\n\nexport type EndpointMethodRequestBody = ReadonlyDeep<OpenAPIV3.RequestBodyObject>;\n\nexport type EndpointMethodRequestBodyProcessingResult = Readonly<{\n parameters: readonly ParameterDeclaration[];\n packedParameters?: ObjectLiteralExpression;\n initParam: ts.Identifier;\n}>;\n\nexport default class EndpointMethodRequestBodyProcessor {\n static readonly #defaultInitParamName = 'init';\n\n readonly #dependencies: DependencyManager;\n readonly #owner: Plugin;\n readonly #requestBody?: EndpointMethodRequestBody;\n readonly #initTypeIdentifier: ts.Identifier;\n\n constructor(\n requestBody: ReadonlyDeep<OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject> | undefined,\n dependencies: DependencyManager,\n owner: Plugin,\n initTypeIdentifier: ts.Identifier,\n ) {\n this.#owner = owner;\n this.#dependencies = dependencies;\n this.#requestBody = requestBody ? owner.resolver.resolve(requestBody) : undefined;\n this.#initTypeIdentifier = initTypeIdentifier;\n }\n\n process(): EndpointMethodRequestBodyProcessingResult {\n if (!this.#requestBody) {\n return {\n initParam: ts.factory.createIdentifier(EndpointMethodRequestBodyProcessor.#defaultInitParamName),\n packedParameters: ts.factory.createObjectLiteralExpression(),\n parameters: [\n ts.factory.createParameterDeclaration(\n undefined,\n undefined,\n EndpointMethodRequestBodyProcessor.#defaultInitParamName,\n ts.factory.createToken(ts.SyntaxKind.QuestionToken),\n ts.factory.createTypeReferenceNode(this.#initTypeIdentifier),\n ),\n ],\n };\n }\n\n const parameterData = this.#extractParameterData(this.#requestBody.content[defaultMediaType].schema);\n const parameterNames = parameterData.map(([name]) => name);\n let initParamName = EndpointMethodRequestBodyProcessor.#defaultInitParamName;\n\n while (parameterNames.includes(initParamName)) {\n initParamName = `_${initParamName}`;\n }\n\n return {\n initParam: ts.factory.createIdentifier(initParamName),\n packedParameters: ts.factory.createObjectLiteralExpression(\n parameterData.map(([name]) => ts.factory.createShorthandPropertyAssignment(name)),\n ),\n parameters: [\n ...parameterData.map(([name, schema]) => {\n const nodes = new TypeSchemaProcessor(schema, this.#dependencies).process();\n\n return ts.factory.createParameterDeclaration(\n undefined,\n undefined,\n name,\n undefined,\n ts.factory.createUnionTypeNode(nodes),\n );\n }),\n ts.factory.createParameterDeclaration(\n undefined,\n undefined,\n initParamName,\n ts.factory.createToken(ts.SyntaxKind.QuestionToken),\n ts.factory.createTypeReferenceNode(this.#initTypeIdentifier),\n ),\n ],\n };\n }\n\n #extractParameterData(\n basicSchema?: ReadonlyDeep<OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject>,\n ): Array<readonly [string, Schema]> {\n if (!basicSchema) {\n return [];\n }\n\n const { logger, resolver } = this.#owner;\n\n const resolvedSchema = resolver.resolve(basicSchema);\n\n if (isObjectSchema(resolvedSchema) && !isEmptyObject(resolvedSchema)) {\n return Object.entries((resolvedSchema as NonEmptyObjectSchema).properties);\n }\n\n logger.warn(\"A schema provided for endpoint method's 'requestBody' is not supported\");\n return [];\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACE;AAA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C,gBAAM,QAAQ,IAAI,oBAAoB,QAAQ,KAAK,aAAa,EAAE,QAAQ;AAE1E,iBAAO,GAAG,QAAQ;AAAA,YAChB;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,GAAG,QAAQ,oBAAoB,KAAK;AAAA,UACtC;AAAA,QACF,CAAC;AAAA,QACD,GAAG,QAAQ;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA,GAAG,QAAQ,YAAY,GAAG,WAAW,aAAa;AAAA,UAClD,GAAG,QAAQ,wBAAwB,KAAK,mBAAmB;AAAA,QAC7D;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,sBACE,aACkC;AAClC,QAAI,CAAC,aAAa;AAChB,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,EAAE,QAAQ,SAAS,IAAI,KAAK;AAElC,UAAM,iBAAiB,SAAS,QAAQ,WAAW;AAEnD,QAAI,eAAe,cAAc,KAAK,CAAC,cAAc,cAAc,GAAG;AACpE,aAAO,OAAO,QAAS,eAAwC,UAAU;AAAA,IAC3E;AAEA,WAAO,KAAK,wEAAwE;AACpF,WAAO,CAAC;AAAA,EACV;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type Plugin from '@vaadin/hilla-generator-core/Plugin.js';
|
|
2
|
+
import type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';
|
|
3
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
4
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
5
|
+
import type { TypeNode } from 'typescript';
|
|
6
|
+
export type EndpointMethodResponses = ReadonlyDeep<OpenAPIV3.ResponsesObject>;
|
|
7
|
+
export type EndpointMethodResponse = ReadonlyDeep<OpenAPIV3.ResponseObject>;
|
|
8
|
+
export default class EndpointMethodResponseProcessor {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(code: string, response: EndpointMethodResponses[string], dependencyManager: DependencyManager, owner: Plugin);
|
|
11
|
+
process(): readonly TypeNode[];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=EndpointMethodResponseProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointMethodResponseProcessor.d.ts","sourceRoot":"","sources":["src/EndpointMethodResponseProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AACjE,OAAO,KAAK,iBAAiB,MAAM,iEAAiE,CAAC;AACrG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AAC9E,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAE5E,MAAM,CAAC,OAAO,OAAO,+BAA+B;;gBAOhD,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,uBAAuB,CAAC,MAAM,CAAC,EACzC,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM;IAQf,OAAO,IAAI,SAAS,QAAQ,EAAE;CAe/B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import TypeSchemaProcessor from "./TypeSchemaProcessor.js";
|
|
2
|
+
import { defaultMediaType } from "./utils.js";
|
|
3
|
+
class EndpointMethodResponseProcessor {
|
|
4
|
+
#code;
|
|
5
|
+
#dependencies;
|
|
6
|
+
#owner;
|
|
7
|
+
#response;
|
|
8
|
+
constructor(code, response, dependencyManager, owner) {
|
|
9
|
+
this.#code = code;
|
|
10
|
+
this.#owner = owner;
|
|
11
|
+
this.#dependencies = dependencyManager;
|
|
12
|
+
this.#response = owner.resolver.resolve(response);
|
|
13
|
+
}
|
|
14
|
+
process() {
|
|
15
|
+
switch (this.#code) {
|
|
16
|
+
case "200":
|
|
17
|
+
return this.#processOk();
|
|
18
|
+
default:
|
|
19
|
+
this.#owner.logger.warn(`Response code '${this.#code} is not supported'`);
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
#processOk() {
|
|
24
|
+
const rawSchema = this.#response.content?.[defaultMediaType]?.schema;
|
|
25
|
+
return rawSchema ? new TypeSchemaProcessor(rawSchema, this.#dependencies).process() : [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
EndpointMethodResponseProcessor as default
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=EndpointMethodResponseProcessor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/EndpointMethodResponseProcessor.ts"],
|
|
4
|
+
"sourcesContent": ["import type Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { ReadonlyDeep } from 'type-fest';\nimport type { TypeNode } from 'typescript';\nimport TypeSchemaProcessor from './TypeSchemaProcessor.js';\nimport { defaultMediaType } from './utils.js';\n\nexport type EndpointMethodResponses = ReadonlyDeep<OpenAPIV3.ResponsesObject>;\nexport type EndpointMethodResponse = ReadonlyDeep<OpenAPIV3.ResponseObject>;\n\nexport default class EndpointMethodResponseProcessor {\n readonly #code: string;\n readonly #dependencies: DependencyManager;\n readonly #owner: Plugin;\n readonly #response: EndpointMethodResponse;\n\n constructor(\n code: string,\n response: EndpointMethodResponses[string],\n dependencyManager: DependencyManager,\n owner: Plugin,\n ) {\n this.#code = code;\n this.#owner = owner;\n this.#dependencies = dependencyManager;\n this.#response = owner.resolver.resolve(response);\n }\n\n process(): readonly TypeNode[] {\n switch (this.#code) {\n case '200':\n return this.#processOk();\n default:\n this.#owner.logger.warn(`Response code '${this.#code} is not supported'`);\n return [];\n }\n }\n\n #processOk(): readonly TypeNode[] {\n const rawSchema = this.#response.content?.[defaultMediaType]?.schema;\n\n return rawSchema ? new TypeSchemaProcessor(rawSchema, this.#dependencies).process() : [];\n }\n}\n"],
|
|
5
|
+
"mappings": "AAKA,OAAO,yBAAyB;AAChC,SAAS,wBAAwB;AAKjC,MAAO,gCAA8C;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACE,MACA,UACA,mBACA,OACA;AACA,SAAK,QAAQ;AACb,SAAK,SAAS;AACd,SAAK,gBAAgB;AACrB,SAAK,YAAY,MAAM,SAAS,QAAQ,QAAQ;AAAA,EAClD;AAAA,EAEA,UAA+B;AAC7B,YAAQ,KAAK,OAAO;AAAA,MAClB,KAAK;AACH,eAAO,KAAK,WAAW;AAAA,MACzB;AACE,aAAK,OAAO,OAAO,KAAK,kBAAkB,KAAK,KAAK,oBAAoB;AACxE,eAAO,CAAC;AAAA,IACZ;AAAA,EACF;AAAA,EAEA,aAAkC;AAChC,UAAM,YAAY,KAAK,UAAU,UAAU,gBAAgB,GAAG;AAE9D,WAAO,YAAY,IAAI,oBAAoB,WAAW,KAAK,aAAa,EAAE,QAAQ,IAAI,CAAC;AAAA,EACzF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type Plugin from '@vaadin/hilla-generator-core/Plugin.js';
|
|
2
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
3
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
4
|
+
import type { SourceFile } from 'typescript';
|
|
5
|
+
export default class EndpointProcessor {
|
|
6
|
+
#private;
|
|
7
|
+
static create(name: string, owner: Plugin, methods: Map<string, ReadonlyDeep<OpenAPIV3.PathItemObject>>, outputDir?: string): Promise<EndpointProcessor>;
|
|
8
|
+
private constructor();
|
|
9
|
+
process(): Promise<SourceFile>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=EndpointProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointProcessor.d.ts","sourceRoot":"","sources":["src/EndpointProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AAKjE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,YAAY,CAAC;AAMxD,MAAM,CAAC,OAAO,OAAO,iBAAiB;;WACvB,MAAM,CACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,EAC5D,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC;IAoB7B,OAAO;IAYD,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;CAuCrC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import ClientPlugin from "@vaadin/hilla-generator-plugin-client";
|
|
2
|
+
import createSourceFile from "@vaadin/hilla-generator-utils/createSourceFile.js";
|
|
3
|
+
import DependencyManager from "@vaadin/hilla-generator-utils/dependencies/DependencyManager.js";
|
|
4
|
+
import PathManager from "@vaadin/hilla-generator-utils/dependencies/PathManager.js";
|
|
5
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
6
|
+
import EndpointMethodOperationProcessor, {
|
|
7
|
+
HILLA_FRONTEND_NAME,
|
|
8
|
+
INIT_TYPE_NAME
|
|
9
|
+
} from "./EndpointMethodOperationProcessor.js";
|
|
10
|
+
class EndpointProcessor {
|
|
11
|
+
static async create(name, owner, methods, outputDir) {
|
|
12
|
+
const endpoint = new EndpointProcessor(name, owner, methods, outputDir);
|
|
13
|
+
endpoint.#dependencies.imports.default.add(
|
|
14
|
+
endpoint.#dependencies.paths.createRelativePath(await ClientPlugin.getClientFileName(outputDir)),
|
|
15
|
+
"client"
|
|
16
|
+
);
|
|
17
|
+
endpoint.#dependencies.imports.named.add(
|
|
18
|
+
endpoint.#dependencies.paths.createBareModulePath(HILLA_FRONTEND_NAME),
|
|
19
|
+
INIT_TYPE_NAME
|
|
20
|
+
);
|
|
21
|
+
return endpoint;
|
|
22
|
+
}
|
|
23
|
+
#createdFilePaths = new PathManager({ extension: "ts" });
|
|
24
|
+
#dependencies = new DependencyManager(new PathManager({ extension: ".js" }));
|
|
25
|
+
#methods;
|
|
26
|
+
#name;
|
|
27
|
+
#outputDir;
|
|
28
|
+
#owner;
|
|
29
|
+
constructor(name, owner, methods, outputDir) {
|
|
30
|
+
this.#name = name;
|
|
31
|
+
this.#owner = owner;
|
|
32
|
+
this.#methods = methods;
|
|
33
|
+
this.#outputDir = outputDir;
|
|
34
|
+
}
|
|
35
|
+
async process() {
|
|
36
|
+
this.#owner.logger.debug(`Processing endpoint: ${this.#name}`);
|
|
37
|
+
const statements = (await Promise.all(Array.from(this.#methods, async ([method, pathItem]) => this.#processMethod(method, pathItem)))).flatMap((item) => item);
|
|
38
|
+
const { exports, imports } = this.#dependencies;
|
|
39
|
+
return createSourceFile(
|
|
40
|
+
[...imports.toCode(), ...statements, ...exports.toCode()],
|
|
41
|
+
this.#createdFilePaths.createRelativePath(this.#name)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
async #processMethod(method, pathItem) {
|
|
45
|
+
this.#owner.logger.debug(`Processing endpoint method: ${this.#name}.${method}`);
|
|
46
|
+
return (await Promise.all(
|
|
47
|
+
Object.values(OpenAPIV3.HttpMethods).filter((httpMethod) => pathItem[httpMethod]).map(
|
|
48
|
+
async (httpMethod) => EndpointMethodOperationProcessor.createProcessor(
|
|
49
|
+
httpMethod,
|
|
50
|
+
this.#name,
|
|
51
|
+
method,
|
|
52
|
+
pathItem[httpMethod],
|
|
53
|
+
this.#dependencies,
|
|
54
|
+
this.#owner
|
|
55
|
+
)?.process(this.#outputDir)
|
|
56
|
+
)
|
|
57
|
+
)).filter(Boolean);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
EndpointProcessor as default
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=EndpointProcessor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/EndpointProcessor.ts"],
|
|
4
|
+
"sourcesContent": ["import type Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport ClientPlugin from '@vaadin/hilla-generator-plugin-client';\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 { OpenAPIV3 } from 'openapi-types';\nimport type { ReadonlyDeep } from 'type-fest';\nimport type { SourceFile, Statement } from 'typescript';\nimport EndpointMethodOperationProcessor, {\n HILLA_FRONTEND_NAME,\n INIT_TYPE_NAME,\n} from './EndpointMethodOperationProcessor.js';\n\nexport default class EndpointProcessor {\n static async create(\n name: string,\n owner: Plugin,\n methods: Map<string, ReadonlyDeep<OpenAPIV3.PathItemObject>>,\n outputDir?: string,\n ): Promise<EndpointProcessor> {\n const endpoint = new EndpointProcessor(name, owner, methods, outputDir);\n endpoint.#dependencies.imports.default.add(\n endpoint.#dependencies.paths.createRelativePath(await ClientPlugin.getClientFileName(outputDir)),\n 'client',\n );\n endpoint.#dependencies.imports.named.add(\n endpoint.#dependencies.paths.createBareModulePath(HILLA_FRONTEND_NAME),\n INIT_TYPE_NAME,\n );\n return endpoint;\n }\n\n readonly #createdFilePaths = new PathManager({ extension: 'ts' });\n readonly #dependencies = new DependencyManager(new PathManager({ extension: '.js' }));\n readonly #methods: Map<string, ReadonlyDeep<OpenAPIV3.PathItemObject>>;\n readonly #name: string;\n readonly #outputDir: string | undefined;\n readonly #owner: Plugin;\n\n private constructor(\n name: string,\n owner: Plugin,\n methods: Map<string, ReadonlyDeep<OpenAPIV3.PathItemObject>>,\n outputDir?: string,\n ) {\n this.#name = name;\n this.#owner = owner;\n this.#methods = methods;\n this.#outputDir = outputDir;\n }\n\n async process(): Promise<SourceFile> {\n this.#owner.logger.debug(`Processing endpoint: ${this.#name}`);\n\n const statements = (\n await Promise.all(Array.from(this.#methods, async ([method, pathItem]) => this.#processMethod(method, pathItem)))\n ).flatMap((item) => item);\n\n const { exports, imports } = this.#dependencies;\n\n return createSourceFile(\n [...imports.toCode(), ...statements, ...exports.toCode()],\n this.#createdFilePaths.createRelativePath(this.#name),\n );\n }\n\n async #processMethod(\n method: string,\n pathItem: ReadonlyDeep<OpenAPIV3.PathItemObject>,\n ): Promise<readonly Statement[]> {\n this.#owner.logger.debug(`Processing endpoint method: ${this.#name}.${method}`);\n\n return (\n await Promise.all(\n Object.values(OpenAPIV3.HttpMethods)\n .filter((httpMethod) => pathItem[httpMethod])\n .map(\n async (httpMethod) =>\n EndpointMethodOperationProcessor.createProcessor(\n httpMethod,\n this.#name,\n method,\n pathItem[httpMethod]!,\n this.#dependencies,\n this.#owner,\n )?.process(this.#outputDir),\n ),\n )\n ).filter(Boolean) as readonly Statement[];\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAO,kBAAkB;AACzB,OAAO,sBAAsB;AAC7B,OAAO,uBAAuB;AAC9B,OAAO,iBAAiB;AACxB,SAAS,iBAAiB;AAG1B,OAAO;AAAA,EACL;AAAA,EACA;AAAA,OACK;AAEP,MAAO,kBAAgC;AAAA,EACrC,aAAa,OACX,MACA,OACA,SACA,WAC4B;AAC5B,UAAM,WAAW,IAAI,kBAAkB,MAAM,OAAO,SAAS,SAAS;AACtE,aAAS,cAAc,QAAQ,QAAQ;AAAA,MACrC,SAAS,cAAc,MAAM,mBAAmB,MAAM,aAAa,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B,KAAK;AAAA,UACL,KAAK;AAAA,QACP,GAAG,QAAQ,KAAK,UAAU;AAAA,MAC9B;AAAA,IACJ,GACA,OAAO,OAAO;AAAA,EAClB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type Plugin from '@vaadin/hilla-generator-core/Plugin.js';
|
|
2
|
+
import { type Schema } from '@vaadin/hilla-generator-core/Schema.js';
|
|
3
|
+
import { type SourceFile } from 'typescript';
|
|
4
|
+
export declare class EntityProcessor {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(name: string, component: Schema, owner: Plugin);
|
|
7
|
+
process(): SourceFile;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=EntityProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityProcessor.d.ts","sourceRoot":"","sources":["src/EntityProcessor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAGL,KAAK,MAAM,EAWZ,MAAM,wCAAwC,CAAC;AAQhD,OAAW,EAGT,KAAK,UAAU,EAGhB,MAAM,YAAY,CAAC;AAGpB,qBAAa,eAAe;;gBASd,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAiB1D,OAAO,IAAI,UAAU;CA+GtB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { dirname } from "path/posix";
|
|
2
|
+
import {
|
|
3
|
+
convertReferenceSchemaToPath,
|
|
4
|
+
convertReferenceSchemaToSpecifier,
|
|
5
|
+
decomposeSchema,
|
|
6
|
+
isComposedSchema,
|
|
7
|
+
isEmptyObject,
|
|
8
|
+
isEnumSchema,
|
|
9
|
+
isNullableSchema,
|
|
10
|
+
isObjectSchema,
|
|
11
|
+
isReferenceSchema
|
|
12
|
+
} from "@vaadin/hilla-generator-core/Schema.js";
|
|
13
|
+
import {
|
|
14
|
+
convertFullyQualifiedNameToRelativePath,
|
|
15
|
+
simplifyFullyQualifiedName
|
|
16
|
+
} from "@vaadin/hilla-generator-core/utils.js";
|
|
17
|
+
import createSourceFile from "@vaadin/hilla-generator-utils/createSourceFile.js";
|
|
18
|
+
import DependencyManager from "@vaadin/hilla-generator-utils/dependencies/DependencyManager.js";
|
|
19
|
+
import PathManager from "@vaadin/hilla-generator-utils/dependencies/PathManager.js";
|
|
20
|
+
import ts, {
|
|
21
|
+
} from "typescript";
|
|
22
|
+
import TypeSchemaProcessor from "./TypeSchemaProcessor.js";
|
|
23
|
+
class EntityProcessor {
|
|
24
|
+
#component;
|
|
25
|
+
#dependencies;
|
|
26
|
+
#fullyQualifiedName;
|
|
27
|
+
#name;
|
|
28
|
+
#outputPathManager = new PathManager({ extension: "ts" });
|
|
29
|
+
#owner;
|
|
30
|
+
#path;
|
|
31
|
+
constructor(name, component, owner) {
|
|
32
|
+
this.#component = component;
|
|
33
|
+
this.#owner = owner;
|
|
34
|
+
this.#fullyQualifiedName = name;
|
|
35
|
+
this.#name = simplifyFullyQualifiedName(name);
|
|
36
|
+
this.#path = convertFullyQualifiedNameToRelativePath(name);
|
|
37
|
+
this.#dependencies = new DependencyManager(new PathManager({ extension: ".js", relativeTo: dirname(this.#path) }));
|
|
38
|
+
}
|
|
39
|
+
get #id() {
|
|
40
|
+
const id = ts.factory.createIdentifier(this.#name);
|
|
41
|
+
this.#dependencies.exports.default.set(id);
|
|
42
|
+
return id;
|
|
43
|
+
}
|
|
44
|
+
process() {
|
|
45
|
+
this.#owner.logger.debug(`Processing entity: ${this.#name}`);
|
|
46
|
+
const declaration = isEnumSchema(this.#component) ? this.#processEnum(this.#component) : this.#processExtendedClass(this.#component);
|
|
47
|
+
const statements = declaration ? [declaration] : [];
|
|
48
|
+
const { exports, imports } = this.#dependencies;
|
|
49
|
+
return createSourceFile(
|
|
50
|
+
[...imports.toCode(), ...statements, ...exports.toCode()],
|
|
51
|
+
this.#outputPathManager.createRelativePath(this.#path)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
#processClass(schema) {
|
|
55
|
+
const { logger } = this.#owner;
|
|
56
|
+
if (!isObjectSchema(schema)) {
|
|
57
|
+
logger.debug(schema, `Component is not an object: '${this.#fullyQualifiedName}'`);
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
if (isEmptyObject(schema)) {
|
|
61
|
+
logger.debug(`Component has no properties:' ${this.#fullyQualifiedName}'`);
|
|
62
|
+
}
|
|
63
|
+
return ts.factory.createInterfaceDeclaration(
|
|
64
|
+
void 0,
|
|
65
|
+
this.#id,
|
|
66
|
+
void 0,
|
|
67
|
+
void 0,
|
|
68
|
+
this.#processTypeElements(schema)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
#processEnum({ enum: members }) {
|
|
72
|
+
return ts.factory.createEnumDeclaration(
|
|
73
|
+
void 0,
|
|
74
|
+
this.#id,
|
|
75
|
+
members.map((member) => ts.factory.createEnumMember(member, ts.factory.createStringLiteral(member)))
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
#processExtendedClass(schema) {
|
|
79
|
+
const { logger } = this.#owner;
|
|
80
|
+
if (isComposedSchema(schema)) {
|
|
81
|
+
const decomposed = decomposeSchema(schema);
|
|
82
|
+
if (decomposed.length > 2) {
|
|
83
|
+
logger.debug(
|
|
84
|
+
schema,
|
|
85
|
+
`Schema for '${this.#fullyQualifiedName}' has more than two components. This plugin will ignore it.`
|
|
86
|
+
);
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
const [parent, child] = decomposed;
|
|
90
|
+
if (!isReferenceSchema(parent)) {
|
|
91
|
+
logger.debug(parent, "Only reference schema allowed for parent class");
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
const declaration = this.#processClass(child);
|
|
95
|
+
const identifier = this.#processParentClass(parent);
|
|
96
|
+
return declaration && ts.factory.updateInterfaceDeclaration(
|
|
97
|
+
declaration,
|
|
98
|
+
declaration.modifiers,
|
|
99
|
+
declaration.name,
|
|
100
|
+
void 0,
|
|
101
|
+
[
|
|
102
|
+
ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [
|
|
103
|
+
ts.factory.createExpressionWithTypeArguments(identifier, void 0)
|
|
104
|
+
])
|
|
105
|
+
],
|
|
106
|
+
declaration.members
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return this.#processClass(schema);
|
|
110
|
+
}
|
|
111
|
+
#processParentClass(schema) {
|
|
112
|
+
const { imports, paths } = this.#dependencies;
|
|
113
|
+
const specifier = convertReferenceSchemaToSpecifier(schema);
|
|
114
|
+
const path = paths.createRelativePath(convertReferenceSchemaToPath(schema));
|
|
115
|
+
return imports.default.getIdentifier(path) ?? imports.default.add(path, specifier, true);
|
|
116
|
+
}
|
|
117
|
+
#processTypeElements({ properties }) {
|
|
118
|
+
return Object.entries(properties ?? {}).map(([name, schema]) => {
|
|
119
|
+
const [type] = new TypeSchemaProcessor(schema, this.#dependencies).process();
|
|
120
|
+
return ts.factory.createPropertySignature(
|
|
121
|
+
void 0,
|
|
122
|
+
name,
|
|
123
|
+
isNullableSchema(schema) ? ts.factory.createToken(ts.SyntaxKind.QuestionToken) : void 0,
|
|
124
|
+
type
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
EntityProcessor
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=EntityProcessor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/EntityProcessor.ts"],
|
|
4
|
+
"sourcesContent": ["import { dirname } from 'path/posix';\nimport type Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport {\n type EnumSchema,\n type ReferenceSchema,\n type Schema,\n convertReferenceSchemaToPath,\n convertReferenceSchemaToSpecifier,\n decomposeSchema,\n isComposedSchema,\n isEmptyObject,\n isEnumSchema,\n isNullableSchema,\n isObjectSchema,\n isReferenceSchema,\n type ObjectSchema,\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 Identifier,\n type InterfaceDeclaration,\n type SourceFile,\n type Statement,\n type TypeElement,\n} from 'typescript';\nimport TypeSchemaProcessor from './TypeSchemaProcessor.js';\n\nexport class EntityProcessor {\n readonly #component: Schema;\n readonly #dependencies;\n readonly #fullyQualifiedName: string;\n readonly #name: string;\n readonly #outputPathManager = new PathManager({ extension: 'ts' });\n readonly #owner: Plugin;\n readonly #path: string;\n\n constructor(name: string, component: Schema, owner: Plugin) {\n this.#component = component;\n this.#owner = owner;\n this.#fullyQualifiedName = name;\n this.#name = simplifyFullyQualifiedName(name);\n this.#path = convertFullyQualifiedNameToRelativePath(name);\n this.#dependencies = new DependencyManager(new PathManager({ extension: '.js', relativeTo: dirname(this.#path) }));\n }\n\n get #id(): Identifier {\n const id = ts.factory.createIdentifier(this.#name);\n\n this.#dependencies.exports.default.set(id);\n\n return id;\n }\n\n process(): SourceFile {\n this.#owner.logger.debug(`Processing entity: ${this.#name}`);\n\n const declaration = isEnumSchema(this.#component)\n ? this.#processEnum(this.#component)\n : this.#processExtendedClass(this.#component);\n\n const statements = declaration ? [declaration] : [];\n\n const { exports, imports } = this.#dependencies;\n\n return createSourceFile(\n [...imports.toCode(), ...statements, ...exports.toCode()],\n this.#outputPathManager.createRelativePath(this.#path),\n );\n }\n\n #processClass(schema: Schema): InterfaceDeclaration | undefined {\n const { logger } = this.#owner;\n\n if (!isObjectSchema(schema)) {\n logger.debug(schema, `Component is not an object: '${this.#fullyQualifiedName}'`);\n return undefined;\n }\n\n if (isEmptyObject(schema)) {\n logger.debug(`Component has no properties:' ${this.#fullyQualifiedName}'`);\n }\n\n return ts.factory.createInterfaceDeclaration(\n undefined,\n this.#id,\n undefined,\n undefined,\n this.#processTypeElements(schema as ObjectSchema),\n );\n }\n\n #processEnum({ enum: members }: EnumSchema): Statement {\n return ts.factory.createEnumDeclaration(\n undefined,\n this.#id,\n members.map((member) => ts.factory.createEnumMember(member, ts.factory.createStringLiteral(member))),\n );\n }\n\n #processExtendedClass(schema: Schema): Statement | undefined {\n const { logger } = this.#owner;\n\n if (isComposedSchema(schema)) {\n const decomposed = decomposeSchema(schema);\n\n if (decomposed.length > 2) {\n logger.debug(\n schema,\n `Schema for '${this.#fullyQualifiedName}' has more than two components. This plugin will ignore it.`,\n );\n return undefined;\n }\n\n const [parent, child] = decomposed;\n\n if (!isReferenceSchema(parent)) {\n logger.debug(parent, 'Only reference schema allowed for parent class');\n return undefined;\n }\n\n const declaration = this.#processClass(child);\n const identifier = this.#processParentClass(parent);\n\n return (\n declaration &&\n ts.factory.updateInterfaceDeclaration(\n declaration,\n declaration.modifiers,\n declaration.name,\n undefined,\n [\n ts.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [\n ts.factory.createExpressionWithTypeArguments(identifier, undefined),\n ]),\n ],\n declaration.members,\n )\n );\n }\n\n return this.#processClass(schema);\n }\n\n #processParentClass(schema: ReferenceSchema): Identifier {\n const { imports, paths } = this.#dependencies;\n\n const specifier = convertReferenceSchemaToSpecifier(schema);\n const path = paths.createRelativePath(convertReferenceSchemaToPath(schema));\n\n return imports.default.getIdentifier(path) ?? imports.default.add(path, specifier, true);\n }\n\n #processTypeElements({ properties }: ObjectSchema): readonly TypeElement[] {\n return Object.entries(properties ?? {}).map(([name, schema]) => {\n const [type] = new TypeSchemaProcessor(schema, this.#dependencies).process();\n\n return ts.factory.createPropertySignature(\n undefined,\n name,\n isNullableSchema(schema) ? ts.factory.createToken(ts.SyntaxKind.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;AAAA,QACA,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,UACE,GAAG,QAAQ,qBAAqB,GAAG,WAAW,gBAAgB;AAAA,YAC5D,GAAG,QAAQ,kCAAkC,YAAY,MAAS;AAAA,UACpE,CAAC;AAAA,QACH;AAAA,QACA,YAAY;AAAA,MACd;AAAA,IAEJ;AAEA,WAAO,KAAK,cAAc,MAAM;AAAA,EAClC;AAAA,EAEA,oBAAoB,QAAqC;AACvD,UAAM,EAAE,SAAS,MAAM,IAAI,KAAK;AAEhC,UAAM,YAAY,kCAAkC,MAAM;AAC1D,UAAM,OAAO,MAAM,mBAAmB,6BAA6B,MAAM,CAAC;AAE1E,WAAO,QAAQ,QAAQ,cAAc,IAAI,KAAK,QAAQ,QAAQ,IAAI,MAAM,WAAW,IAAI;AAAA,EACzF;AAAA,EAEA,qBAAqB,EAAE,WAAW,GAAyC;AACzE,WAAO,OAAO,QAAQ,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM;AAC9D,YAAM,CAAC,IAAI,IAAI,IAAI,oBAAoB,QAAQ,KAAK,aAAa,EAAE,QAAQ;AAE3E,aAAO,GAAG,QAAQ;AAAA,QAChB;AAAA,QACA;AAAA,QACA,iBAAiB,MAAM,IAAI,GAAG,QAAQ,YAAY,GAAG,WAAW,aAAa,IAAI;AAAA,QACjF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Hilla TypeScript Generator Backbone Plugin
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Schema } from '@vaadin/hilla-generator-core/Schema.js';
|
|
2
|
+
import type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';
|
|
3
|
+
import { type TypeNode } from 'typescript';
|
|
4
|
+
export default class TypeSchemaProcessor {
|
|
5
|
+
#private;
|
|
6
|
+
['constructor']: typeof TypeSchemaProcessor;
|
|
7
|
+
constructor(schema: Schema, dependencies: DependencyManager);
|
|
8
|
+
process(): readonly TypeNode[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=TypeSchemaProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeSchemaProcessor.d.ts","sourceRoot":"","sources":["src/TypeSchemaProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAiBL,KAAK,MAAM,EACZ,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,iBAAiB,MAAM,iEAAiE,CAAC;AACrG,OAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAgC/C,MAAM,CAAC,OAAO,OAAO,mBAAmB;;IAC9B,CAAC,aAAa,CAAC,EAAE,OAAO,mBAAmB,CAAC;gBAIxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB;IAK3D,OAAO,IAAI,SAAS,QAAQ,EAAE;CAwD/B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertReferenceSchemaToPath,
|
|
3
|
+
convertReferenceSchemaToSpecifier,
|
|
4
|
+
decomposeSchema,
|
|
5
|
+
isArraySchema,
|
|
6
|
+
isBooleanSchema,
|
|
7
|
+
isComposedSchema,
|
|
8
|
+
isIntegerSchema,
|
|
9
|
+
isMapSchema,
|
|
10
|
+
isNullableSchema,
|
|
11
|
+
isNumberSchema,
|
|
12
|
+
isReferenceSchema,
|
|
13
|
+
isStringSchema
|
|
14
|
+
} from "@vaadin/hilla-generator-core/Schema.js";
|
|
15
|
+
import ts, {} from "typescript";
|
|
16
|
+
function createBoolean() {
|
|
17
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword);
|
|
18
|
+
}
|
|
19
|
+
function createNumber() {
|
|
20
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);
|
|
21
|
+
}
|
|
22
|
+
function createString() {
|
|
23
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword);
|
|
24
|
+
}
|
|
25
|
+
function createUndefined() {
|
|
26
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword);
|
|
27
|
+
}
|
|
28
|
+
function createUnknown() {
|
|
29
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);
|
|
30
|
+
}
|
|
31
|
+
function unwrapPossiblyNullableSchema(schema) {
|
|
32
|
+
if (isComposedSchema(schema)) {
|
|
33
|
+
const [result] = decomposeSchema(schema);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
return schema;
|
|
37
|
+
}
|
|
38
|
+
class TypeSchemaProcessor {
|
|
39
|
+
#dependencies;
|
|
40
|
+
#schema;
|
|
41
|
+
constructor(schema, dependencies) {
|
|
42
|
+
this.#schema = schema;
|
|
43
|
+
this.#dependencies = dependencies;
|
|
44
|
+
}
|
|
45
|
+
process() {
|
|
46
|
+
let node;
|
|
47
|
+
const unwrappedSchema = unwrapPossiblyNullableSchema(this.#schema);
|
|
48
|
+
if (isReferenceSchema(unwrappedSchema)) {
|
|
49
|
+
node = this.#processReference(unwrappedSchema);
|
|
50
|
+
} else if (isArraySchema(unwrappedSchema)) {
|
|
51
|
+
node = this.#processArray(unwrappedSchema);
|
|
52
|
+
} else if (isMapSchema(unwrappedSchema)) {
|
|
53
|
+
node = this.#processMap(unwrappedSchema);
|
|
54
|
+
} else if (isBooleanSchema(unwrappedSchema)) {
|
|
55
|
+
node = createBoolean();
|
|
56
|
+
} else if (isIntegerSchema(unwrappedSchema) || isNumberSchema(unwrappedSchema)) {
|
|
57
|
+
node = createNumber();
|
|
58
|
+
} else if (isStringSchema(unwrappedSchema)) {
|
|
59
|
+
node = createString();
|
|
60
|
+
} else {
|
|
61
|
+
node = createUnknown();
|
|
62
|
+
}
|
|
63
|
+
return isNullableSchema(this.#schema) ? [node, createUndefined()] : [node];
|
|
64
|
+
}
|
|
65
|
+
#processArray(schema) {
|
|
66
|
+
const nodes = new TypeSchemaProcessor(schema.items, this.#dependencies).process();
|
|
67
|
+
return ts.factory.createTypeReferenceNode("Array", [ts.factory.createUnionTypeNode(nodes)]);
|
|
68
|
+
}
|
|
69
|
+
#processMap({ additionalProperties: valuesType }) {
|
|
70
|
+
let valuesTypeNode;
|
|
71
|
+
if (typeof valuesType !== "boolean") {
|
|
72
|
+
const nodes = new TypeSchemaProcessor(valuesType, this.#dependencies).process();
|
|
73
|
+
valuesTypeNode = ts.factory.createUnionTypeNode(nodes);
|
|
74
|
+
} else {
|
|
75
|
+
valuesTypeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);
|
|
76
|
+
}
|
|
77
|
+
return ts.factory.createTypeReferenceNode("Record", [
|
|
78
|
+
ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
|
|
79
|
+
valuesTypeNode
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
#processReference(schema) {
|
|
83
|
+
const { imports, paths } = this.#dependencies;
|
|
84
|
+
const specifier = convertReferenceSchemaToSpecifier(schema);
|
|
85
|
+
const path = paths.createRelativePath(convertReferenceSchemaToPath(schema));
|
|
86
|
+
const identifier = imports.default.getIdentifier(path) ?? imports.default.add(path, specifier, true);
|
|
87
|
+
return ts.factory.createTypeReferenceNode(identifier);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
TypeSchemaProcessor as default
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=TypeSchemaProcessor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/TypeSchemaProcessor.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type ArraySchema,\n convertReferenceSchemaToPath,\n convertReferenceSchemaToSpecifier,\n decomposeSchema,\n isArraySchema,\n isBooleanSchema,\n isComposedSchema,\n isIntegerSchema,\n isMapSchema,\n isNullableSchema,\n isNumberSchema,\n isReferenceSchema,\n isStringSchema,\n type MapSchema,\n type NonComposedSchema,\n type ReferenceSchema,\n type Schema,\n} from '@vaadin/hilla-generator-core/Schema.js';\nimport type DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';\nimport ts, { type TypeNode } from 'typescript';\n\nfunction createBoolean(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword);\n}\n\nfunction createNumber(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);\n}\n\nfunction createString(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword);\n}\n\nfunction createUndefined(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword);\n}\n\nfunction createUnknown(): TypeNode {\n return ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);\n}\n\nfunction unwrapPossiblyNullableSchema(schema: Schema): NonComposedSchema {\n if (isComposedSchema(schema)) {\n const [result] = decomposeSchema(schema);\n\n return result as NonComposedSchema;\n }\n\n return schema as NonComposedSchema;\n}\n\nexport default class TypeSchemaProcessor {\n declare ['constructor']: typeof TypeSchemaProcessor;\n readonly #dependencies: DependencyManager;\n readonly #schema: Schema;\n\n constructor(schema: Schema, dependencies: DependencyManager) {\n this.#schema = schema;\n this.#dependencies = dependencies;\n }\n\n process(): readonly TypeNode[] {\n let node: TypeNode;\n\n const unwrappedSchema = unwrapPossiblyNullableSchema(this.#schema);\n\n if (isReferenceSchema(unwrappedSchema)) {\n node = this.#processReference(unwrappedSchema);\n } else if (isArraySchema(unwrappedSchema)) {\n node = this.#processArray(unwrappedSchema);\n } else if (isMapSchema(unwrappedSchema)) {\n node = this.#processMap(unwrappedSchema);\n } else if (isBooleanSchema(unwrappedSchema)) {\n node = createBoolean();\n } else if (isIntegerSchema(unwrappedSchema) || isNumberSchema(unwrappedSchema)) {\n node = createNumber();\n } else if (isStringSchema(unwrappedSchema)) {\n node = createString();\n } else {\n node = createUnknown();\n }\n\n return isNullableSchema(this.#schema) ? [node, createUndefined()] : [node];\n }\n\n #processArray(schema: ArraySchema): TypeNode {\n const nodes = new TypeSchemaProcessor(schema.items, this.#dependencies).process();\n\n return ts.factory.createTypeReferenceNode('Array', [ts.factory.createUnionTypeNode(nodes)]);\n }\n\n #processMap({ additionalProperties: valuesType }: MapSchema): TypeNode {\n let valuesTypeNode: TypeNode;\n\n if (typeof valuesType !== 'boolean') {\n const nodes = new TypeSchemaProcessor(valuesType, this.#dependencies).process();\n valuesTypeNode = ts.factory.createUnionTypeNode(nodes);\n } else {\n valuesTypeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);\n }\n\n return ts.factory.createTypeReferenceNode('Record', [\n ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n valuesTypeNode,\n ]);\n }\n\n #processReference(schema: ReferenceSchema): TypeNode {\n const { imports, paths } = this.#dependencies;\n\n const specifier = convertReferenceSchemaToSpecifier(schema);\n const path = paths.createRelativePath(convertReferenceSchemaToPath(schema));\n\n const identifier = imports.default.getIdentifier(path) ?? imports.default.add(path, specifier, true);\n\n return ts.factory.createTypeReferenceNode(identifier);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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
|
+
export declare enum BackbonePluginSourceType {
|
|
4
|
+
Endpoint = "endpoint",
|
|
5
|
+
Entity = "entity"
|
|
6
|
+
}
|
|
7
|
+
export default class BackbonePlugin extends Plugin {
|
|
8
|
+
#private;
|
|
9
|
+
static readonly BACKBONE_PLUGIN_FILE_TAGS = "BACKBONE_PLUGIN_FILE_TAGS";
|
|
10
|
+
['constructor']: typeof BackbonePlugin;
|
|
11
|
+
get path(): string;
|
|
12
|
+
execute(storage: SharedStorage): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +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,wBAAwB;IAClC,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAED,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,MAAM;;IAChD,MAAM,CAAC,QAAQ,CAAC,yBAAyB,+BAA+B;IAChE,CAAC,aAAa,CAAC,EAAE,OAAO,cAAc,CAAC;IAG/C,IAAa,IAAI,IAAI,MAAM,CAE1B;IAEc,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAkD9D"}
|
package/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Plugin from "@vaadin/hilla-generator-core/Plugin.js";
|
|
2
|
+
import EndpointProcessor from "./EndpointProcessor.js";
|
|
3
|
+
import { EntityProcessor } from "./EntityProcessor.js";
|
|
4
|
+
var BackbonePluginSourceType = /* @__PURE__ */ ((BackbonePluginSourceType2) => {
|
|
5
|
+
BackbonePluginSourceType2["Endpoint"] = "endpoint";
|
|
6
|
+
BackbonePluginSourceType2["Entity"] = "entity";
|
|
7
|
+
return BackbonePluginSourceType2;
|
|
8
|
+
})(BackbonePluginSourceType || {});
|
|
9
|
+
class BackbonePlugin extends Plugin {
|
|
10
|
+
static BACKBONE_PLUGIN_FILE_TAGS = "BACKBONE_PLUGIN_FILE_TAGS";
|
|
11
|
+
#tags = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
get path() {
|
|
13
|
+
return import.meta.url;
|
|
14
|
+
}
|
|
15
|
+
async execute(storage) {
|
|
16
|
+
const endpointSourceFiles = await this.#processEndpoints(storage);
|
|
17
|
+
const entitySourceFiles = this.#processEntities(storage);
|
|
18
|
+
endpointSourceFiles.forEach((file) => this.#tags.set(file, "endpoint" /* Endpoint */));
|
|
19
|
+
entitySourceFiles.forEach((file) => this.#tags.set(file, "entity" /* Entity */));
|
|
20
|
+
storage.sources.push(...endpointSourceFiles, ...entitySourceFiles);
|
|
21
|
+
storage.pluginStorage.set(this.constructor.BACKBONE_PLUGIN_FILE_TAGS, this.#tags);
|
|
22
|
+
}
|
|
23
|
+
async #processEndpoints(storage) {
|
|
24
|
+
this.logger.debug("Processing endpoints");
|
|
25
|
+
const endpoints = /* @__PURE__ */ new Map();
|
|
26
|
+
Object.entries(storage.api.paths).filter(([, pathItem]) => !!pathItem).forEach(([path, pathItem]) => {
|
|
27
|
+
const [, endpointName, endpointMethodName] = path.split("/");
|
|
28
|
+
let methods;
|
|
29
|
+
if (endpoints.has(endpointName)) {
|
|
30
|
+
methods = endpoints.get(endpointName);
|
|
31
|
+
} else {
|
|
32
|
+
methods = /* @__PURE__ */ new Map();
|
|
33
|
+
endpoints.set(endpointName, methods);
|
|
34
|
+
}
|
|
35
|
+
methods.set(endpointMethodName, pathItem);
|
|
36
|
+
});
|
|
37
|
+
const processors = await Promise.all(
|
|
38
|
+
[...endpoints.entries()].map(
|
|
39
|
+
async ([endpointName, methods]) => EndpointProcessor.create(endpointName, this, methods, storage.outputDir)
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
return Promise.all(processors.map(async (processor) => processor.process()));
|
|
43
|
+
}
|
|
44
|
+
#processEntities(storage) {
|
|
45
|
+
this.logger.debug("Processing entities");
|
|
46
|
+
return storage.api.components?.schemas ? Object.entries(storage.api.components.schemas).map(
|
|
47
|
+
([name, component]) => new EntityProcessor(name, component, this).process()
|
|
48
|
+
) : [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
BackbonePluginSourceType,
|
|
53
|
+
BackbonePlugin as default
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 EndpointProcessor from './EndpointProcessor.js';\nimport { EntityProcessor } from './EntityProcessor.js';\n\nexport enum BackbonePluginSourceType {\n Endpoint = 'endpoint',\n Entity = 'entity',\n}\n\nexport default class BackbonePlugin extends Plugin {\n static readonly BACKBONE_PLUGIN_FILE_TAGS = 'BACKBONE_PLUGIN_FILE_TAGS';\n declare ['constructor']: typeof BackbonePlugin;\n readonly #tags = new WeakMap<SourceFile, BackbonePluginSourceType>();\n\n override get path(): string {\n return import.meta.url;\n }\n\n override async execute(storage: SharedStorage): Promise<void> {\n const endpointSourceFiles = await this.#processEndpoints(storage);\n const entitySourceFiles = this.#processEntities(storage);\n\n endpointSourceFiles.forEach((file) => this.#tags.set(file, BackbonePluginSourceType.Endpoint));\n entitySourceFiles.forEach((file) => this.#tags.set(file, BackbonePluginSourceType.Entity));\n\n storage.sources.push(...endpointSourceFiles, ...entitySourceFiles);\n storage.pluginStorage.set(this.constructor.BACKBONE_PLUGIN_FILE_TAGS, this.#tags);\n }\n\n async #processEndpoints(storage: SharedStorage): Promise<readonly SourceFile[]> {\n this.logger.debug('Processing endpoints');\n const endpoints = new Map<string, Map<string, ReadonlyDeep<OpenAPIV3.PathItemObject>>>();\n\n Object.entries(storage.api.paths)\n .filter(([, pathItem]) => !!pathItem)\n .forEach(([path, pathItem]) => {\n const [, endpointName, endpointMethodName] = path.split('/');\n\n let methods: Map<string, ReadonlyDeep<OpenAPIV3.PathItemObject>>;\n\n if (endpoints.has(endpointName)) {\n methods = endpoints.get(endpointName)!;\n } else {\n methods = new Map();\n endpoints.set(endpointName, methods);\n }\n\n methods.set(endpointMethodName, pathItem!);\n });\n\n const processors = await Promise.all(\n [...endpoints.entries()].map(async ([endpointName, methods]) =>\n EndpointProcessor.create(endpointName, this, methods, storage.outputDir),\n ),\n );\n\n return Promise.all(processors.map(async (processor) => processor.process()));\n }\n\n #processEntities(storage: SharedStorage): readonly SourceFile[] {\n this.logger.debug('Processing entities');\n\n return storage.api.components?.schemas\n ? Object.entries(storage.api.components.schemas).map(([name, component]) =>\n new EntityProcessor(name, component, this).process(),\n )\n : [];\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,YAAY;AAKnB,OAAO,uBAAuB;AAC9B,SAAS,uBAAuB;AAEzB,IAAK,2BAAL,kBAAKA,8BAAL;AACL,EAAAA,0BAAA,cAAW;AACX,EAAAA,0BAAA,YAAS;AAFC,SAAAA;AAAA,GAAA;AAKZ,MAAO,uBAAqC,OAAO;AAAA,EACjD,OAAgB,4BAA4B;AAAA,EAEnC,QAAQ,oBAAI,QAA8C;AAAA,EAEnE,IAAa,OAAe;AAC1B,WAAO,YAAY;AAAA,EACrB;AAAA,EAEA,MAAe,QAAQ,SAAuC;AAC5D,UAAM,sBAAsB,MAAM,KAAK,kBAAkB,OAAO;AAChE,UAAM,oBAAoB,KAAK,iBAAiB,OAAO;AAEvD,wBAAoB,QAAQ,CAAC,SAAS,KAAK,MAAM,IAAI,MAAM,yBAAiC,CAAC;AAC7F,s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QAAQ;AAAA,IACrD,IACA,CAAC;AAAA,EACP;AACF;",
|
|
6
|
+
"names": ["BackbonePluginSourceType"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vaadin/hilla-generator-plugin-backbone",
|
|
3
|
+
"version": "24.4.0-alpha1",
|
|
4
|
+
"description": "A Hilla TypeScript Generator plugin to generate basic code",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">= 16.13"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"clean:build": "git clean -fx . -e .vite -e node_modules",
|
|
12
|
+
"build": "concurrently npm:build:*",
|
|
13
|
+
"build:esbuild": "tsx ../../../scripts/build.ts",
|
|
14
|
+
"build:dts": "tsc --isolatedModules -p tsconfig.build.json",
|
|
15
|
+
"build:copy": "cd src && copyfiles **/*.d.ts ..",
|
|
16
|
+
"lint": "eslint src test",
|
|
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 -c ../../../.c8rc.json npm test",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"default": "./index.js"
|
|
26
|
+
},
|
|
27
|
+
"./index.js": {
|
|
28
|
+
"default": "./index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/vaadin/hilla.git",
|
|
34
|
+
"directory": "packages/ts/generator-plugin-backbone"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"hilla",
|
|
38
|
+
"typescript",
|
|
39
|
+
"generator"
|
|
40
|
+
],
|
|
41
|
+
"author": "Vaadin Ltd.",
|
|
42
|
+
"license": "Apache 2.0",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/vaadin/hilla/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://hilla.dev",
|
|
47
|
+
"files": [
|
|
48
|
+
"*.{d.ts.map,d.ts,js.map,js}"
|
|
49
|
+
],
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@vaadin/hilla-generator-core": "24.4.0-alpha1",
|
|
55
|
+
"@vaadin/hilla-generator-plugin-client": "24.4.0-alpha1"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@vaadin/hilla-generator-utils": "24.4.0-alpha1",
|
|
59
|
+
"fast-deep-equal": "^3.1.3",
|
|
60
|
+
"openapi-types": "^12.1.3",
|
|
61
|
+
"typescript": "5.3.2"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@vaadin/hilla-generator-core": "24.4.0-alpha1",
|
|
65
|
+
"@vaadin/hilla-generator-plugin-client": "24.4.0-alpha1",
|
|
66
|
+
"@types/chai": "^4.3.6",
|
|
67
|
+
"@types/mocha": "^10.0.2",
|
|
68
|
+
"@types/node": "^20.7.1",
|
|
69
|
+
"@types/sinon": "^10.0.17",
|
|
70
|
+
"@types/sinon-chai": "^3.2.10",
|
|
71
|
+
"c8": "^8.0.1",
|
|
72
|
+
"chai": "^4.3.10",
|
|
73
|
+
"concurrently": "^8.2.1",
|
|
74
|
+
"copyfiles": "^2.4.1",
|
|
75
|
+
"mocha": "^10.2.0",
|
|
76
|
+
"pino": "^8.15.1",
|
|
77
|
+
"rimraf": "^5.0.5",
|
|
78
|
+
"sinon": "^16.0.0",
|
|
79
|
+
"sinon-chai": "^3.7.0",
|
|
80
|
+
"type-fest": "^4.3.2"
|
|
81
|
+
}
|
|
82
|
+
}
|
package/utils.d.ts
ADDED
package/utils.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,qBAAqB,CAAC"}
|
package/utils.js
ADDED