@vaadin/hilla-generator-plugin-backbone 24.4.0-alpha2 → 24.4.0-alpha20
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/EndpointMethodOperationProcessor.d.ts +1 -1
- package/EndpointMethodOperationProcessor.d.ts.map +1 -1
- package/EndpointMethodOperationProcessor.js +1 -1
- package/EndpointMethodOperationProcessor.js.map +1 -1
- package/EndpointProcessor.d.ts.map +1 -1
- package/EndpointProcessor.js.map +2 -2
- package/package.json +6 -6
|
@@ -5,7 +5,7 @@ import type { ReadonlyDeep } from 'type-fest';
|
|
|
5
5
|
import { type Statement } from 'typescript';
|
|
6
6
|
export type EndpointMethodOperation = ReadonlyDeep<OpenAPIV3.OperationObject>;
|
|
7
7
|
export declare const INIT_TYPE_NAME = "EndpointRequestInit";
|
|
8
|
-
export declare const HILLA_FRONTEND_NAME = "@vaadin/hilla-
|
|
8
|
+
export declare const HILLA_FRONTEND_NAME = "@vaadin/hilla-frontend";
|
|
9
9
|
export default abstract class EndpointMethodOperationProcessor {
|
|
10
10
|
static createProcessor(httpMethod: OpenAPIV3.HttpMethods, endpointName: string, endpointMethodName: string, operation: EndpointMethodOperation, dependencies: DependencyManager, owner: Plugin): EndpointMethodOperationProcessor | undefined;
|
|
11
11
|
abstract process(outputDir?: string): Promise<Statement | undefined>;
|
|
@@ -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,
|
|
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;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"}
|
|
@@ -5,7 +5,7 @@ import ts, {} from "typescript";
|
|
|
5
5
|
import EndpointMethodRequestBodyProcessor from "./EndpointMethodRequestBodyProcessor.js";
|
|
6
6
|
import EndpointMethodResponseProcessor from "./EndpointMethodResponseProcessor.js";
|
|
7
7
|
const INIT_TYPE_NAME = "EndpointRequestInit";
|
|
8
|
-
const HILLA_FRONTEND_NAME = "@vaadin/hilla-
|
|
8
|
+
const HILLA_FRONTEND_NAME = "@vaadin/hilla-frontend";
|
|
9
9
|
class EndpointMethodOperationProcessor {
|
|
10
10
|
static createProcessor(httpMethod, endpointName, endpointMethodName, operation, dependencies, owner) {
|
|
11
11
|
switch (httpMethod) {
|
|
@@ -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-
|
|
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:\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
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;AAAA,MACF;AAC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Z,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;
|
|
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;CAsCrC"}
|
package/EndpointProcessor.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 Prom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Q,OAAO,GAAG,GAAG,YAAY,GAAG,QAAQ,OAAO,CAAC;AAAA,MACxD,KAAK,kBAAkB,mBAAmB,KAAK,KAAK;AAAA,IACtD;AAAA,EACF;AAAA,EAEA,MAAM,eACJ,QACA,UAC+B;AAC/B,SAAK,OAAO,OAAO,MAAM,+BAA+B,KAAK,KAAK,IAAI,MAAM,EAAE;AAE9E,YACE,MAAM,QAAQ;AAAA,MACZ,OAAO,OAAO,UAAU,WAAW,EAChC,OAAO,CAAC,eAAe,SAAS,UAAU,CAAC,EAC3C;AAAA,
|
|
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(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,kBA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KAAK;AAAA,UACL,KAAK;AAAA,QACP,GAAG,QAAQ,KAAK,UAAU;AAAA,MAC5B;AAAA,IACJ,GACA,OAAO,OAAO;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-generator-plugin-backbone",
|
|
3
|
-
"version": "24.4.0-
|
|
3
|
+
"version": "24.4.0-alpha20",
|
|
4
4
|
"description": "A Hilla TypeScript Generator plugin to generate basic code",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -51,18 +51,18 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@vaadin/hilla-generator-core": "24.4.0-
|
|
55
|
-
"@vaadin/hilla-generator-plugin-client": "24.4.0-
|
|
54
|
+
"@vaadin/hilla-generator-core": "24.4.0-alpha20",
|
|
55
|
+
"@vaadin/hilla-generator-plugin-client": "24.4.0-alpha20"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@vaadin/hilla-generator-utils": "24.4.0-
|
|
58
|
+
"@vaadin/hilla-generator-utils": "24.4.0-alpha20",
|
|
59
59
|
"fast-deep-equal": "^3.1.3",
|
|
60
60
|
"openapi-types": "^12.1.3",
|
|
61
61
|
"typescript": "5.3.2"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@vaadin/hilla-generator-core": "24.4.0-
|
|
65
|
-
"@vaadin/hilla-generator-plugin-client": "24.4.0-
|
|
64
|
+
"@vaadin/hilla-generator-core": "24.4.0-alpha20",
|
|
65
|
+
"@vaadin/hilla-generator-plugin-client": "24.4.0-alpha20",
|
|
66
66
|
"@types/chai": "^4.3.6",
|
|
67
67
|
"@types/mocha": "^10.0.2",
|
|
68
68
|
"@types/node": "^20.7.1",
|