@vaadin/hilla-generator-plugin-push 24.7.0-alpha10 → 24.7.0-alpha11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Plugin from '@vaadin/hilla-generator-core/Plugin.js';
|
|
2
|
-
import type SharedStorage from '@vaadin/hilla-generator-core/SharedStorage.js';
|
|
2
|
+
import type { SharedStorage } from '@vaadin/hilla-generator-core/SharedStorage.js';
|
|
3
3
|
export default class PushPlugin extends Plugin {
|
|
4
4
|
#private;
|
|
5
5
|
['constructor']: typeof PushPlugin;
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wCAAwC,CAAC;AAC5D,OAAO,KAAK,aAAa,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wCAAwC,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAanF,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,MAAM;;IA+BpC,CAAC,aAAa,CAAC,EAAE,OAAO,UAAU,CAAC;IAE3C,IAAa,IAAI,IAAI,MAAM,CAE1B;IAGc,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAa9D"}
|
package/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport type SharedStorage from '@vaadin/hilla-generator-core/SharedStorage.js';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { ReadonlyObjectDeep } from 'type-fest/source/readonly-deep';\nimport { type EndpointOperations, PushProcessor } from './PushProcessor.js';\n\ntype ExtendedMediaTypeSchema = Readonly<{ 'x-class-name': string }> &\n ReadonlyObjectDeep<OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject>;\n\nconst classesToReplace: readonly string[] = [\n 'com.vaadin.hilla.runtime.transfertypes.Flux',\n 'com.vaadin.hilla.runtime.transfertypes.EndpointSubscription',\n];\n\nexport default class PushPlugin extends Plugin {\n /**\n * Collects methods that must be patched by checking their `x-class-name` value\n */\n static #collectPatchableMethods(paths: ReadonlyObjectDeep<OpenAPIV3.PathsObject>) {\n return Object.entries(paths).reduce((acc, [key, path]) => {\n const response = path?.post?.responses[200] as ReadonlyObjectDeep<OpenAPIV3.ResponseObject> | undefined;\n const schema = response?.content?.['application/json']?.schema as ExtendedMediaTypeSchema | undefined;\n const className = schema?.['x-class-name'];\n const [, endpoint, method] = key.split('/');\n\n if (className && classesToReplace.includes(className)) {\n if (acc.has(endpoint)) {\n acc.get(endpoint)!.methodsToPatch.push(method);\n } else {\n acc.set(endpoint, { methodsToPatch: [method], removeInitImport: true });\n }\n } else {\n // Not all methods will be patched, let's keep the init import\n // eslint-disable-next-line no-lonely-if\n if (acc.has(endpoint)) {\n acc.get(endpoint)!.removeInitImport = false;\n } else {\n acc.set(endpoint, { methodsToPatch: [], removeInitImport: false });\n }\n }\n\n return acc;\n }, new Map<string, EndpointOperations>());\n }\n\n declare ['constructor']: typeof PushPlugin;\n\n override get path(): string {\n return import.meta.url;\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n override async execute(storage: SharedStorage): Promise<void> {\n const { api, sources } = storage;\n const endpointMethodMap = this.constructor.#collectPatchableMethods(api.paths);\n\n for (let i = 0; i < sources.length; i++) {\n const { fileName } = sources[i];\n const endpoint = fileName.substring(0, fileName.indexOf('.ts'));\n\n if (endpointMethodMap.has(endpoint)) {\n sources[i] = new PushProcessor(sources[i], endpointMethodMap.get(endpoint)!).process();\n }\n }\n }\n}\n"],
|
|
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 { ReadonlyObjectDeep } from 'type-fest/source/readonly-deep';\nimport { type EndpointOperations, PushProcessor } from './PushProcessor.js';\n\ntype ExtendedMediaTypeSchema = Readonly<{ 'x-class-name': string }> &\n ReadonlyObjectDeep<OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject>;\n\nconst classesToReplace: readonly string[] = [\n 'com.vaadin.hilla.runtime.transfertypes.Flux',\n 'com.vaadin.hilla.runtime.transfertypes.EndpointSubscription',\n];\n\nexport default class PushPlugin extends Plugin {\n /**\n * Collects methods that must be patched by checking their `x-class-name` value\n */\n static #collectPatchableMethods(paths: ReadonlyObjectDeep<OpenAPIV3.PathsObject>) {\n return Object.entries(paths).reduce((acc, [key, path]) => {\n const response = path?.post?.responses[200] as ReadonlyObjectDeep<OpenAPIV3.ResponseObject> | undefined;\n const schema = response?.content?.['application/json']?.schema as ExtendedMediaTypeSchema | undefined;\n const className = schema?.['x-class-name'];\n const [, endpoint, method] = key.split('/');\n\n if (className && classesToReplace.includes(className)) {\n if (acc.has(endpoint)) {\n acc.get(endpoint)!.methodsToPatch.push(method);\n } else {\n acc.set(endpoint, { methodsToPatch: [method], removeInitImport: true });\n }\n } else {\n // Not all methods will be patched, let's keep the init import\n // eslint-disable-next-line no-lonely-if\n if (acc.has(endpoint)) {\n acc.get(endpoint)!.removeInitImport = false;\n } else {\n acc.set(endpoint, { methodsToPatch: [], removeInitImport: false });\n }\n }\n\n return acc;\n }, new Map<string, EndpointOperations>());\n }\n\n declare ['constructor']: typeof PushPlugin;\n\n override get path(): string {\n return import.meta.url;\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n override async execute(storage: SharedStorage): Promise<void> {\n const { api, sources } = storage;\n const endpointMethodMap = this.constructor.#collectPatchableMethods(api.paths);\n\n for (let i = 0; i < sources.length; i++) {\n const { fileName } = sources[i];\n const endpoint = fileName.substring(0, fileName.indexOf('.ts'));\n\n if (endpointMethodMap.has(endpoint)) {\n sources[i] = new PushProcessor(sources[i], endpointMethodMap.get(endpoint)!).process();\n }\n }\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,YAAY;AAInB,SAAkC,qBAAqB;AAKvD,MAAM,mBAAsC;AAAA,EAC1C;AAAA,EACA;AACF;AAEA,MAAO,mBAAiC,OAAO;AAAA;AAAA;AAAA;AAAA,EAI7C,OAAO,yBAAyB,OAAkD;AAChF,WAAO,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,MAAM;AACxD,YAAM,WAAW,MAAM,MAAM,UAAU,GAAG;AAC1C,YAAM,SAAS,UAAU,UAAU,kBAAkB,GAAG;AACxD,YAAM,YAAY,SAAS,cAAc;AACzC,YAAM,CAAC,EAAE,UAAU,MAAM,IAAI,IAAI,MAAM,GAAG;AAE1C,UAAI,aAAa,iBAAiB,SAAS,SAAS,GAAG;AACrD,YAAI,IAAI,IAAI,QAAQ,GAAG;AACrB,cAAI,IAAI,QAAQ,EAAG,eAAe,KAAK,MAAM;AAAA,QAC/C,OAAO;AACL,cAAI,IAAI,UAAU,EAAE,gBAAgB,CAAC,MAAM,GAAG,kBAAkB,KAAK,CAAC;AAAA,QACxE;AAAA,MACF,OAAO;AAGL,YAAI,IAAI,IAAI,QAAQ,GAAG;AACrB,cAAI,IAAI,QAAQ,EAAG,mBAAmB;AAAA,QACxC,OAAO;AACL,cAAI,IAAI,UAAU,EAAE,gBAAgB,CAAC,GAAG,kBAAkB,MAAM,CAAC;AAAA,QACnE;AAAA,MACF;AAEA,aAAO;AAAA,IACT,GAAG,oBAAI,IAAgC,CAAC;AAAA,EAC1C;AAAA,EAIA,IAAa,OAAe;AAC1B,WAAO,YAAY;AAAA,EACrB;AAAA;AAAA,EAGA,MAAe,QAAQ,SAAuC;AAC5D,UAAM,EAAE,KAAK,QAAQ,IAAI;AACzB,UAAM,oBAAoB,KAAK,YAAY,yBAAyB,IAAI,KAAK;AAE7E,aAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,YAAM,EAAE,SAAS,IAAI,QAAQ,CAAC;AAC9B,YAAM,WAAW,SAAS,UAAU,GAAG,SAAS,QAAQ,KAAK,CAAC;AAE9D,UAAI,kBAAkB,IAAI,QAAQ,GAAG;AACnC,gBAAQ,CAAC,IAAI,IAAI,cAAc,QAAQ,CAAC,GAAG,kBAAkB,IAAI,QAAQ,CAAE,EAAE,QAAQ;AAAA,MACvF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-generator-plugin-push",
|
|
3
|
-
"version": "24.7.0-
|
|
3
|
+
"version": "24.7.0-alpha11",
|
|
4
4
|
"description": "A Hilla TypeScript Generator plugin to add push support",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@vaadin/hilla-generator-core": "24.7.0-
|
|
56
|
-
"@vaadin/hilla-generator-plugin-client": "24.7.0-
|
|
57
|
-
"@vaadin/hilla-generator-utils": "24.7.0-
|
|
55
|
+
"@vaadin/hilla-generator-core": "24.7.0-alpha11",
|
|
56
|
+
"@vaadin/hilla-generator-plugin-client": "24.7.0-alpha11",
|
|
57
|
+
"@vaadin/hilla-generator-utils": "24.7.0-alpha11",
|
|
58
58
|
"fast-deep-equal": "3.1.3",
|
|
59
59
|
"openapi-types": "12.1.3",
|
|
60
60
|
"typescript": "5.7.3"
|