@webiny/project 6.1.0-beta.3 → 6.2.0-beta.0
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/defineExtension/zodTypes/zodSrcPath.js +11 -0
- package/defineExtension/zodTypes/zodSrcPath.js.map +1 -1
- package/extensions/ApiExtension.js +5 -5
- package/extensions/ApiExtension.js.map +1 -1
- package/features/Watch/initInvocationForwarding.d.ts +1 -1
- package/features/Watch/initInvocationForwarding.js +1 -1
- package/features/Watch/initInvocationForwarding.js.map +1 -1
- package/package.json +20 -22
- package/services/GetProjectVersionService/GetProjectVersionService.js +2 -2
- package/services/GetProjectVersionService/GetProjectVersionService.js.map +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Metadata } from "@webiny/di";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import fs from "fs";
|
|
3
4
|
import path from "path";
|
|
4
5
|
import { ProjectError } from "../../ProjectError.js";
|
|
5
6
|
import { ExtensionSrcResolver } from "../../utils/index.js";
|
|
@@ -32,6 +33,16 @@ export const zodSrcPath = options => {
|
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
// Ensure the resolved path points to a file, not a directory.
|
|
37
|
+
const absolutePath = ExtensionSrcResolver.resolvePath(src, project);
|
|
38
|
+
if (fs.statSync(absolutePath).isDirectory()) {
|
|
39
|
+
ctx.addIssue({
|
|
40
|
+
code: z.ZodIssueCode.custom,
|
|
41
|
+
message: ProjectError.formatMessage(`Expected a file but got a directory: %s. Please provide a path to a specific file.`, src)
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
// If abstraction validation is required
|
|
36
47
|
if (abstraction) {
|
|
37
48
|
const absoluteSrcPath = ExtensionSrcResolver.resolvePath(src, project);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Metadata","z","path","ProjectError","ExtensionSrcResolver","zodSrcPath","options","project","abstraction","getTokenName","token","str","toString","replace","tokenName","undefined","description","string","describe","transform","val","superRefine","src","ctx","existsSync","addIssue","code","ZodIssueCode","custom","message","formatMessage","
|
|
1
|
+
{"version":3,"names":["Metadata","z","fs","path","ProjectError","ExtensionSrcResolver","zodSrcPath","options","project","abstraction","getTokenName","token","str","toString","replace","tokenName","undefined","description","string","describe","transform","val","superRefine","src","ctx","existsSync","addIssue","code","ZodIssueCode","custom","message","formatMessage","absolutePath","resolvePath","statSync","isDirectory","absoluteSrcPath","exportName","basename","extname","exportedImplementation","importFromPath","metadata","metadataName","getAbstraction","defName","isCorrectAbstraction"],"sources":["zodSrcPath.ts"],"sourcesContent":["import { type Abstraction, Metadata } from \"@webiny/di\";\nimport { z } from \"zod\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { type IProjectModel } from \"~/abstractions/models/index.js\";\nimport { ProjectError } from \"~/ProjectError.js\";\nimport { ExtensionSrcResolver } from \"~/utils/index.js\";\n\n/**\n * TypeScript type for source paths.\n * - `/extensions/${string}` - resolves from project root\n * - `@/${string}` or other tsconfig aliases - resolves using tsconfig.json paths\n * - string (absolute path) - treated as absolute path\n */\nexport type SrcPath = `/extensions/${string}` | string;\n\ntype ZodSrcPathOptions = {\n project: IProjectModel;\n abstraction?: Abstraction<any>;\n};\n\nexport const zodSrcPath = (options: ZodSrcPathOptions) => {\n const { project, abstraction } = options;\n\n const getTokenName = (token: symbol) => {\n const str = token.toString();\n return str.replace(/^Symbol\\(/, \"\").replace(/\\)$/, \"\");\n };\n\n const tokenName = abstraction ? getTokenName(abstraction.token) : undefined;\n const description = abstraction\n ? `Path to a file exporting ${tokenName}. Use \"/extensions/...\" to resolve from project root, \"@/...\" for tsconfig path aliases, or provide an absolute path.`\n : `Path: \"/extensions/...\" resolves from project root, \"@/...\" resolves using tsconfig path aliases, or provide an absolute path.`;\n\n return z\n .string()\n .describe(description)\n .transform((val): SrcPath => val as SrcPath)\n .superRefine(async (src, ctx) => {\n // Check if file exists using ExtensionSrcResolver.\n if (!ExtensionSrcResolver.existsSync(src, project)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: ProjectError.formatMessage(\n `File not found: %s. Please check the path and try again.`,\n src\n )\n });\n return;\n }\n\n // Ensure the resolved path points to a file, not a directory.\n const absolutePath = ExtensionSrcResolver.resolvePath(src, project);\n if (fs.statSync(absolutePath).isDirectory()) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: ProjectError.formatMessage(\n `Expected a file but got a directory: %s. Please provide a path to a specific file.`,\n src\n )\n });\n return;\n }\n\n // If abstraction validation is required\n if (abstraction) {\n const absoluteSrcPath = ExtensionSrcResolver.resolvePath(src, project);\n const exportName = path\n .basename(absoluteSrcPath)\n .replace(path.extname(absoluteSrcPath), \"\");\n\n const exportedImplementation = await ExtensionSrcResolver.importFromPath(\n src,\n project\n );\n\n if (!exportedImplementation) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: ProjectError.formatMessage(\n `The file %s must export a class named %s or as a default export.`,\n src,\n exportName\n )\n });\n return;\n }\n\n const metadata = new Metadata(exportedImplementation);\n const metadataName = metadata.getAbstraction().toString();\n const defName = abstraction.toString();\n const isCorrectAbstraction = metadataName === defName;\n\n if (!isCorrectAbstraction) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: ProjectError.formatMessage(\n `The class %s in %s must implement the %s interface.`,\n exportName,\n src,\n tokenName || \"\"\n )\n });\n }\n }\n });\n};\n"],"mappings":"AAAA,SAA2BA,QAAQ,QAAQ,YAAY;AACvD,SAASC,CAAC,QAAQ,KAAK;AACvB,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,SAASC,YAAY;AACrB,SAASC,oBAAoB;;AAE7B;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAO,MAAMC,UAAU,GAAIC,OAA0B,IAAK;EACtD,MAAM;IAAEC,OAAO;IAAEC;EAAY,CAAC,GAAGF,OAAO;EAExC,MAAMG,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BAAoB,CAAC4B,WAAW,CAACV,GAAG,EAAEf,OAAO,CAAC;MACtE,MAAM6B,UAAU,GAAGlC,IAAI,CAClBmC,QAAQ,CAACF,eAAe,CAAC,CACzBtB,OAAO,CAACX,IAAI,CAACoC,OAAO,CAACH,eAAe,CAAC,EAAE,EAAE,CAAC;MAE/C,MAAMI,sBAAsB,GAAG,MAAMnC,oBAAoB,CAACoC,cAAc,CACpElB,GAAG,EACHf,OACJ,CAAC;MAED,IAAI,CAACgC,sBAAsB,EAAE;QACzBhB,GAAG,CAACE,QAAQ,CAAC;UACTC,IAAI,EAAE1B,CAAC,CAAC2B,YAAY,CAACC,MAAM;UAC3BC,OAAO,EAAE1B,YAAY,CAAC2B,aAAa,CAC/B,kEAAkE,EAClER,GAAG,EACHc,UACJ;QACJ,CAAC,CAAC;QACF;MACJ;MAEA,MAAMK,QAAQ,GAAG,IAAI1C,QAAQ,CAACwC,sBAAsB,CAAC;MACrD,MAAMG,YAAY,GAAGD,QAAQ,CAACE,cAAc,CAAC,CAAC,CAAC/B,QAAQ,CAAC,CAAC;MACzD,MAAMgC,OAAO,GAAGpC,WAAW,CAACI,QAAQ,CAAC,CAAC;MACtC,MAAMiC,oBAAoB,GAAGH,YAAY,KAAKE,OAAO;MAErD,IAAI,CAACC,oBAAoB,EAAE;QACvBtB,GAAG,CAACE,QAAQ,CAAC;UACTC,IAAI,EAAE1B,CAAC,CAAC2B,YAAY,CAACC,MAAM;UAC3BC,OAAO,EAAE1B,YAAY,CAAC2B,aAAa,CAC/B,qDAAqD,EACrDM,UAAU,EACVd,GAAG,EACHR,SAAS,IAAI,EACjB;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
|
|
@@ -78,7 +78,7 @@ export const ApiExtension = defineExtension({
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
const pluginsArray = source.getFirstDescendant(node => Node.isArrayLiteralExpression(node));
|
|
81
|
-
pluginsArray.addElement(`\
|
|
81
|
+
pluginsArray.addElement(`\ncreateRegisterExtensionPlugin(ctx => {\n\tregisterExtension(ctx.container, ${exportNameAlias});\n})`);
|
|
82
82
|
{
|
|
83
83
|
let index = 1;
|
|
84
84
|
const importDeclarations = source.getImportDeclarations();
|
|
@@ -86,12 +86,12 @@ export const ApiExtension = defineExtension({
|
|
|
86
86
|
const last = importDeclarations[importDeclarations.length - 1];
|
|
87
87
|
index = last.getChildIndex() + 1;
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
const existingContextPluginImport = source.getImportDeclaration(
|
|
89
|
+
const registerExtensionPluginImportPath = "@webiny/handler/plugins/RegisterExtensionPlugin";
|
|
90
|
+
const existingContextPluginImport = source.getImportDeclaration(registerExtensionPluginImportPath);
|
|
91
91
|
if (!existingContextPluginImport) {
|
|
92
92
|
source.insertImportDeclaration(index, {
|
|
93
|
-
namedImports: ["
|
|
94
|
-
moduleSpecifier:
|
|
93
|
+
namedImports: ["createRegisterExtensionPlugin"],
|
|
94
|
+
moduleSpecifier: registerExtensionPluginImportPath
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defineExtension","zodSrcPath","ExtensionSrcResolver","z","path","Node","Project","crypto","ApiExtension","type","tags","runtimeContext","appName","description","multiple","paramsSchema","project","object","src","exportName","string","optional","build","params","ctx","extensionsTsFilePath","paths","workspaceFolder","join","toString","extensionFilePath","absoluteExtensionFilePath","resolvePath","extensionFileName","basename","parse","name","hash","createHash","update","digest","exportNameAlias","slice","importPath","relative","dirname","replace","addSourceFileAtPath","source","getSourceFileOrThrow","existingImportDeclaration","getImportDeclaration","index","importDeclarations","getImportDeclarations","length","last","getChildIndex","extensionProject","extensionSource","hasDefaultExport","getDefaultExportSymbol","undefined","insertImportDeclaration","defaultImport","moduleSpecifier","namedImports","alias","pluginsArray","getFirstDescendant","node","isArrayLiteralExpression","addElement","
|
|
1
|
+
{"version":3,"names":["defineExtension","zodSrcPath","ExtensionSrcResolver","z","path","Node","Project","crypto","ApiExtension","type","tags","runtimeContext","appName","description","multiple","paramsSchema","project","object","src","exportName","string","optional","build","params","ctx","extensionsTsFilePath","paths","workspaceFolder","join","toString","extensionFilePath","absoluteExtensionFilePath","resolvePath","extensionFileName","basename","parse","name","hash","createHash","update","digest","exportNameAlias","slice","importPath","relative","dirname","replace","addSourceFileAtPath","source","getSourceFileOrThrow","existingImportDeclaration","getImportDeclaration","index","importDeclarations","getImportDeclarations","length","last","getChildIndex","extensionProject","extensionSource","hasDefaultExport","getDefaultExportSymbol","undefined","insertImportDeclaration","defaultImport","moduleSpecifier","namedImports","alias","pluginsArray","getFirstDescendant","node","isArrayLiteralExpression","addElement","registerExtensionPluginImportPath","existingContextPluginImport","save"],"sources":["ApiExtension.ts"],"sourcesContent":["import { defineExtension, zodSrcPath } from \"~/extensions/index.js\";\nimport { ExtensionSrcResolver } from \"@webiny/project\";\nimport { z } from \"zod\";\nimport path from \"path\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport crypto from \"crypto\";\n\nexport const ApiExtension = defineExtension({\n type: \"Api/Extension\",\n tags: { runtimeContext: \"app-build\", appName: \"api\" },\n description: \"Add any API extension.\",\n multiple: true,\n paramsSchema: ({ project }) => {\n return z.object({\n src: zodSrcPath({ project }),\n exportName: z.string().optional()\n });\n },\n async build(params, ctx) {\n const extensionsTsFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"extensions.ts\")\n .toString();\n\n const { src: extensionFilePath } = params;\n\n // Resolve to absolute path for file operations.\n const absoluteExtensionFilePath = ExtensionSrcResolver.resolvePath(\n extensionFilePath,\n ctx.project\n );\n\n const extensionFileName = path.basename(absoluteExtensionFilePath);\n\n // Export name is always the file name without extension.\n const exportName = params.exportName ?? path.parse(extensionFileName).name;\n\n // Alias name is \"ApiExtension_\" + hash of the file path. This way we\n // avoid potential naming conflicts and keep the identifier constant.\n const hash = crypto.createHash(\"sha256\").update(extensionFilePath).digest(\"hex\");\n const exportNameAlias = `ApiExtension_${hash.slice(-10)}`;\n\n // Calculate import path relative to `extensions.ts` file.\n const importPath = path\n .relative(path.dirname(extensionsTsFilePath), absoluteExtensionFilePath)\n .replace(/\\.tsx?$/, \".js\");\n\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsFilePath);\n\n const existingImportDeclaration = source.getImportDeclaration(importPath);\n if (existingImportDeclaration) {\n return;\n }\n\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Check if the file has a default export using AST parsing.\n const extensionProject = new Project();\n extensionProject.addSourceFileAtPath(absoluteExtensionFilePath);\n const extensionSource = extensionProject.getSourceFileOrThrow(absoluteExtensionFilePath);\n const hasDefaultExport = extensionSource.getDefaultExportSymbol() !== undefined;\n\n // Support both default and named exports.\n if (hasDefaultExport) {\n source.insertImportDeclaration(index, {\n defaultImport: exportNameAlias,\n moduleSpecifier: importPath\n });\n } else {\n source.insertImportDeclaration(index, {\n namedImports: [{ name: exportName, alias: exportNameAlias }],\n moduleSpecifier: importPath\n });\n }\n\n const pluginsArray = source.getFirstDescendant(node =>\n Node.isArrayLiteralExpression(node)\n ) as ArrayLiteralExpression;\n\n pluginsArray.addElement(\n `\\ncreateRegisterExtensionPlugin(ctx => {\\n\\tregisterExtension(ctx.container, ${exportNameAlias});\\n})`\n );\n\n {\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n const registerExtensionPluginImportPath =\n \"@webiny/handler/plugins/RegisterExtensionPlugin\";\n const existingContextPluginImport = source.getImportDeclaration(\n registerExtensionPluginImportPath\n );\n if (!existingContextPluginImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"createRegisterExtensionPlugin\"],\n moduleSpecifier: registerExtensionPluginImportPath\n });\n }\n }\n\n await source.save();\n }\n});\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,UAAU;AACpC,SAASC,oBAAoB,QAAQ,iBAAiB;AACtD,SAASC,CAAC,QAAQ,KAAK;AACvB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,IAAI,EAAEC,OAAO,QAAgC,UAAU;AAChE,OAAOC,MAAM,MAAM,QAAQ;AAE3B,OAAO,MAAMC,YAAY,GAAGR,eAAe,CAAC;EACxCS,IAAI,EAAE,eAAe;EACrBC,IAAI,EAAE;IAAEC,cAAc,EAAE,WAAW;IAAEC,OAAO,EAAE;EAAM,CAAC;EACrDC,WAAW,EAAE,wBAAwB;EACrCC,QAAQ,EAAE,IAAI;EACdC,YAAY,EAAEA,CAAC;IAAEC;EAAQ,CAAC,KAAK;IAC3B,OAAOb,CAAC,CAACc,MAAM,CAAC;MACZC,GAAG,EAAEjB,UAAU,CAAC;QAAEe;MAAQ,CAAC,CAAC;MAC5BG,UAAU,EAAEhB,CAAC,CAACiB,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;IACpC,CAAC,CAAC;EACN,CAAC;EACD,MAAMC,KAAKA,CAACC,MAAM,EAAEC,GAAG,EAAE;IACrB,MAAMC,oBAAoB,GAAGD,GAAG,CAACR,OAAO,CAACU,KAAK,CAACC,eAAe,CACzDC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,CAAC,CACtDC,QAAQ,CAAC,CAAC;IAEf,MAAM;MAAEX,GAAG,EAAEY;IAAkB,CAAC,GAAGP,MAAM;;IAEzC;IACA,MAAMQ,yBAAyB,GAAG7B,oBAAoB,CAAC8B,WAAW,CAC9DF,iBAAiB,EACjBN,GAAG,CAACR,OACR,CAAC;IAED,MAAMiB,iBAAiB,GAAG7B,IAAI,CAAC8B,QAAQ,CAACH,yBAAyB,CAAC;;IAElE;IACA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IAAI,CAAC,CAAC;EACvB;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mqtt from "mqtt";
|
|
2
|
-
import {
|
|
2
|
+
import type { ListAppLambdaFunctionsService } from "../../abstractions/index.js";
|
|
3
3
|
export interface IInitInvocationForwardingParams {
|
|
4
4
|
iotEndpoint: string;
|
|
5
5
|
iotEndpointTopic: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { Worker } from "worker_threads";
|
|
3
|
-
import { compress, decompress } from "@webiny/utils/compression/gzip.js";
|
|
3
|
+
import { compress, decompress } from "@webiny/utils/features/compression/legacy/gzip.js";
|
|
4
4
|
import mqtt from "mqtt";
|
|
5
5
|
const WEBINY_WATCH_FN_INVOCATION_EVENT = "webiny.watch.functionInvocation";
|
|
6
6
|
const WEBINY_WATCH_FN_INVOCATION_RESULT_EVENT = "webiny.watch.functionInvocationResult";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["path","Worker","compress","decompress","mqtt","WEBINY_WATCH_FN_INVOCATION_EVENT","WEBINY_WATCH_FN_INVOCATION_RESULT_EVENT","WEBINY_WATCH_FN_INVOCATION_HANDSHAKE_EVENT","WATCH_WORKER_PATH","join","import","meta","dirname","jsonStringifyAndCompress","input","jsonStringInput","JSON","stringify","decompressAndJsonParse","inputBuffer","Buffer","from","jsonStringResult","value","toString","parse","initInvocationForwarding","iotEndpoint","iotEndpointTopic","sessionId","functionsList","client","connectAsync","subscribeAsync","on","_","message","payload","eventType","data","publish","eventId","Date","getTime","originalEventId","compressedResult","compressedError","invokedLambdaFunction","list","find","lambdaFunction","name","functionName","Error","result","Promise","resolve","reject","worker","env","WEBINY_WATCH_LOCAL_INVOCATION","workerData","handler","args","compressedArgs","default","exitHook","unsubscribeExitHook","terminate","success","error","console","log","stack"],"sources":["initInvocationForwarding.ts"],"sourcesContent":["import path from \"path\";\nimport { Worker } from \"worker_threads\";\nimport { compress, decompress } from \"@webiny/utils/compression/gzip.js\";\nimport mqtt from \"mqtt\";\nimport {
|
|
1
|
+
{"version":3,"names":["path","Worker","compress","decompress","mqtt","WEBINY_WATCH_FN_INVOCATION_EVENT","WEBINY_WATCH_FN_INVOCATION_RESULT_EVENT","WEBINY_WATCH_FN_INVOCATION_HANDSHAKE_EVENT","WATCH_WORKER_PATH","join","import","meta","dirname","jsonStringifyAndCompress","input","jsonStringInput","JSON","stringify","decompressAndJsonParse","inputBuffer","Buffer","from","jsonStringResult","value","toString","parse","initInvocationForwarding","iotEndpoint","iotEndpointTopic","sessionId","functionsList","client","connectAsync","subscribeAsync","on","_","message","payload","eventType","data","publish","eventId","Date","getTime","originalEventId","compressedResult","compressedError","invokedLambdaFunction","list","find","lambdaFunction","name","functionName","Error","result","Promise","resolve","reject","worker","env","WEBINY_WATCH_LOCAL_INVOCATION","workerData","handler","args","compressedArgs","default","exitHook","unsubscribeExitHook","terminate","success","error","console","log","stack"],"sources":["initInvocationForwarding.ts"],"sourcesContent":["import path from \"path\";\nimport { Worker } from \"worker_threads\";\nimport { compress, decompress } from \"@webiny/utils/features/compression/legacy/gzip.js\";\nimport mqtt from \"mqtt\";\nimport type { ListAppLambdaFunctionsService } from \"~/abstractions/index.js\";\n\nconst WEBINY_WATCH_FN_INVOCATION_EVENT = \"webiny.watch.functionInvocation\";\nconst WEBINY_WATCH_FN_INVOCATION_RESULT_EVENT = \"webiny.watch.functionInvocationResult\";\nconst WEBINY_WATCH_FN_INVOCATION_HANDSHAKE_EVENT = \"webiny.watch.functionInvocationHandshake\";\n\nconst WATCH_WORKER_PATH = path.join(import.meta.dirname, \"localInvocationWorker.js\");\n\nconst jsonStringifyAndCompress = (input: Record<string, any>): Promise<Buffer> => {\n const jsonStringInput = JSON.stringify(input);\n return compress(jsonStringInput);\n};\n\nconst decompressAndJsonParse = async (input: string) => {\n const inputBuffer = Buffer.from(input);\n const jsonStringResult = await decompress(inputBuffer);\n\n const value = jsonStringResult?.toString\n ? jsonStringResult.toString(\"utf-8\")\n : (jsonStringResult as unknown as string);\n\n return JSON.parse(value);\n};\n\nexport interface IInitInvocationForwardingParams {\n iotEndpoint: string;\n iotEndpointTopic: string;\n sessionId: number;\n functionsList: ListAppLambdaFunctionsService.Result;\n}\n\nexport const initInvocationForwarding = async ({\n iotEndpoint,\n iotEndpointTopic,\n sessionId,\n functionsList\n}: IInitInvocationForwardingParams) => {\n const client = await mqtt.connectAsync(iotEndpoint);\n\n await client.subscribeAsync(iotEndpointTopic);\n\n client.on(\"message\", async (_, message) => {\n const payload = JSON.parse(message.toString());\n\n if (payload.eventType !== WEBINY_WATCH_FN_INVOCATION_EVENT) {\n return;\n }\n\n if (payload.data.sessionId !== sessionId) {\n return;\n }\n\n await client.publish(\n iotEndpointTopic,\n JSON.stringify({\n eventType: WEBINY_WATCH_FN_INVOCATION_HANDSHAKE_EVENT,\n eventId: new Date().getTime(),\n data: {\n originalEventId: payload.eventId,\n compressedResult: null,\n compressedError: null\n }\n })\n );\n\n const invokedLambdaFunction = functionsList.list.find(\n lambdaFunction => lambdaFunction.name === payload.data.functionName\n );\n if (!invokedLambdaFunction) {\n throw new Error(`Lambda function \"${payload.data.functionName}\" not found.`);\n }\n\n try {\n const result = await new Promise<Record<string, any>>(async (resolve, reject) => {\n const worker = new Worker(WATCH_WORKER_PATH, {\n env: { ...payload.data.env, WEBINY_WATCH_LOCAL_INVOCATION: \"1\" },\n workerData: {\n handler: {\n path: invokedLambdaFunction.path,\n args: await decompressAndJsonParse(payload.data.compressedArgs)\n }\n }\n });\n\n const { default: exitHook } = await import(\n /* webpackChunkName: \"exit-hook\" */ \"exit-hook\"\n );\n\n const unsubscribeExitHook = exitHook(async () => {\n await worker.terminate();\n });\n\n worker.on(\"message\", message => {\n unsubscribeExitHook();\n\n const { success, result, error } = JSON.parse(message);\n if (success) {\n resolve(result);\n } else {\n reject(error);\n }\n });\n });\n\n await client.publish(\n iotEndpointTopic,\n JSON.stringify({\n eventType: WEBINY_WATCH_FN_INVOCATION_RESULT_EVENT,\n eventId: new Date().getTime(),\n data: {\n originalEventId: payload.eventId,\n compressedResult: await jsonStringifyAndCompress(result),\n compressedError: null\n }\n })\n );\n } catch (error) {\n console.log(error);\n await client.publish(\n iotEndpointTopic,\n JSON.stringify({\n eventType: WEBINY_WATCH_FN_INVOCATION_RESULT_EVENT,\n eventId: new Date().getTime(),\n data: {\n originalEventId: payload.eventId,\n compressedResult: null,\n compressedError: await jsonStringifyAndCompress({\n message: error.message,\n stack: error.stack\n })\n }\n })\n );\n }\n });\n\n return client;\n};\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,QAAQ,EAAEC,UAAU,QAAQ,mDAAmD;AACxF,OAAOC,IAAI,MAAM,MAAM;AAGvB,MAAMC,gCAAgC,GAAG,iCAAiC;AAC1E,MAAMC,uCAAuC,GAAG,uCAAuC;AACvF,MAAMC,0CAA0C,GAAG,0CAA0C;AAE7F,MAAMC,iBAAiB,GAAGR,IAAI,CAACS,IAAI,CAACC,MAAM,CAACC,IAAI,CAACC,OAAO,EAAE,0BAA0B,CAAC;AAEpF,MAAMC,wBAAwB,GAAIC,KAA0B,IAAsB;EAC9E,MAAMC,eAAe,GAAGC,IAAI,CAACC,SAAS,CAACH,KAAK,CAAC;EAC7C,OAAOZ,QAAQ,CAACa,eAAe,CAAC;AACpC,CAAC;AAED,MAAMG,sBAAsB,GAAG,MAAOJ,KAAa,IAAK;EACpD,MAAMK,WAAW,GAAGC,MAAM,CAACC,IAAI,CAACP,KAAK,CAAC;EACtC,MAAMQ,gBAAgB,GAAG,MAAMnB,UAAU,CAACgB,WAAW,CAAC;EAEtD,MAAMI,KAAK,GAAGD,gBAAgB,EAAEE,QAAQ,GAClCF,gBAAgB,CAACE,QAAQ,CAAC,OAAO,CAAC,GACjCF,gBAAsC;EAE7C,OAAON,IAAI,CAACS,KAAK,CAACF,KAAK,CAAC;A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;IACL,CAAC,CAAC,OAAOwB,KAAK,EAAE;MACZC,OAAO,CAACC,GAAG,CAACF,KAAK,CAAC;MAClB,MAAMvC,MAAM,CAACS,OAAO,CAChBZ,gBAAgB,EAChBZ,IAAI,CAACC,SAAS,CAAC;QACXqB,SAAS,EAAEhC,uCAAuC;QAClDmC,OAAO,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;QAC7BJ,IAAI,EAAE;UACFK,eAAe,EAAEP,OAAO,CAACI,OAAO;UAChCI,gBAAgB,EAAE,IAAI;UACtBC,eAAe,EAAE,MAAMjC,wBAAwB,CAAC;YAC5CuB,OAAO,EAAEkC,KAAK,CAAClC,OAAO;YACtBqC,KAAK,EAAEH,KAAK,CAACG;UACjB,CAAC;QACL;MACJ,CAAC,CACL,CAAC;IACL;EACJ,CAAC,CAAC;EAEF,OAAO1C,MAAM;AACjB,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/project",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -10,23 +10,23 @@
|
|
|
10
10
|
"description": "An SDK for managing Webiny projects.",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/aws-sdk": "6.
|
|
14
|
-
"@webiny/build-tools": "6.
|
|
13
|
+
"@webiny/aws-sdk": "6.2.0-beta.0",
|
|
14
|
+
"@webiny/build-tools": "6.2.0-beta.0",
|
|
15
15
|
"@webiny/di": "0.2.3",
|
|
16
|
-
"@webiny/feature-flags": "6.
|
|
17
|
-
"@webiny/global-config": "6.
|
|
18
|
-
"@webiny/pulumi-sdk": "6.
|
|
19
|
-
"@webiny/react-properties": "6.
|
|
20
|
-
"@webiny/system-requirements": "6.
|
|
21
|
-
"@webiny/telemetry": "6.
|
|
22
|
-
"@webiny/utils": "6.
|
|
23
|
-
"@webiny/wcp": "6.
|
|
16
|
+
"@webiny/feature-flags": "6.2.0-beta.0",
|
|
17
|
+
"@webiny/global-config": "6.2.0-beta.0",
|
|
18
|
+
"@webiny/pulumi-sdk": "6.2.0-beta.0",
|
|
19
|
+
"@webiny/react-properties": "6.2.0-beta.0",
|
|
20
|
+
"@webiny/system-requirements": "6.2.0-beta.0",
|
|
21
|
+
"@webiny/telemetry": "6.2.0-beta.0",
|
|
22
|
+
"@webiny/utils": "6.2.0-beta.0",
|
|
23
|
+
"@webiny/wcp": "6.2.0-beta.0",
|
|
24
24
|
"chalk": "5.6.2",
|
|
25
25
|
"chokidar": "5.0.0",
|
|
26
26
|
"ci-info": "4.4.0",
|
|
27
27
|
"debounce": "3.0.0",
|
|
28
28
|
"deepmerge": "4.3.1",
|
|
29
|
-
"dotenv": "17.
|
|
29
|
+
"dotenv": "17.4.2",
|
|
30
30
|
"execa": "5.1.1",
|
|
31
31
|
"exit-hook": "5.1.0",
|
|
32
32
|
"fast-glob": "3.3.3",
|
|
@@ -34,21 +34,20 @@
|
|
|
34
34
|
"get-tsconfig": "4.13.7",
|
|
35
35
|
"graphql-request": "7.4.0",
|
|
36
36
|
"humanize-duration": "3.33.2",
|
|
37
|
-
"jsdom": "29.0.
|
|
37
|
+
"jsdom": "29.0.2",
|
|
38
38
|
"load-json-file": "7.0.1",
|
|
39
|
-
"lodash": "4.
|
|
40
|
-
"minimatch": "10.2.
|
|
39
|
+
"lodash": "4.18.1",
|
|
40
|
+
"minimatch": "10.2.5",
|
|
41
41
|
"mqtt": "5.15.1",
|
|
42
42
|
"neverthrow": "8.2.0",
|
|
43
|
-
"p-retry": "
|
|
43
|
+
"p-retry": "8.0.0",
|
|
44
44
|
"pino": "10.3.1",
|
|
45
45
|
"pino-pretty": "13.1.3",
|
|
46
|
-
"react": "18.
|
|
47
|
-
"react-dom": "18.
|
|
48
|
-
"read-json-sync": "2.0.1",
|
|
46
|
+
"react": "18.3.1",
|
|
47
|
+
"react-dom": "18.3.1",
|
|
49
48
|
"replace-in-path": "1.1.0",
|
|
50
49
|
"serialize-error": "13.0.1",
|
|
51
|
-
"ts-morph": "
|
|
50
|
+
"ts-morph": "28.0.0",
|
|
52
51
|
"tsx": "4.21.0",
|
|
53
52
|
"write-json-file": "7.0.0",
|
|
54
53
|
"zod": "4.3.6"
|
|
@@ -58,7 +57,6 @@
|
|
|
58
57
|
"@types/humanize-duration": "3.27.4",
|
|
59
58
|
"@types/jsdom": "28.0.1",
|
|
60
59
|
"@types/lodash": "4.17.24",
|
|
61
|
-
"@types/read-json-sync": "2.0.3",
|
|
62
60
|
"rimraf": "6.1.3",
|
|
63
61
|
"type-fest": "5.5.0",
|
|
64
62
|
"typescript": "5.9.3"
|
|
@@ -77,5 +75,5 @@
|
|
|
77
75
|
"access": "public",
|
|
78
76
|
"directory": "dist"
|
|
79
77
|
},
|
|
80
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "3d3148358b6febbc857371930871743bec3b3939"
|
|
81
79
|
}
|
|
@@ -2,7 +2,7 @@ import { createImplementation } from "@webiny/di";
|
|
|
2
2
|
import { findUpSync } from "find-up";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { GetProjectVersionService } from "../../abstractions/index.js";
|
|
5
|
-
import
|
|
5
|
+
import { loadJsonFileSync } from "load-json-file";
|
|
6
6
|
class DefaultGetProjectVersionService {
|
|
7
7
|
cachedProjectVersion = null;
|
|
8
8
|
execute() {
|
|
@@ -17,7 +17,7 @@ class DefaultGetProjectVersionService {
|
|
|
17
17
|
const pkgJsonPath = findUpSync("package.json", {
|
|
18
18
|
cwd: path.dirname(import.meta.dirname)
|
|
19
19
|
});
|
|
20
|
-
const pkgJson = pkgJsonPath ?
|
|
20
|
+
const pkgJson = pkgJsonPath ? loadJsonFileSync(pkgJsonPath) : null;
|
|
21
21
|
if (pkgJson?.version) {
|
|
22
22
|
this.cachedProjectVersion = pkgJson.version;
|
|
23
23
|
return this.cachedProjectVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createImplementation","findUpSync","path","GetProjectVersionService","
|
|
1
|
+
{"version":3,"names":["createImplementation","findUpSync","path","GetProjectVersionService","loadJsonFileSync","DefaultGetProjectVersionService","cachedProjectVersion","execute","envProjectVersion","process","env","WEBINY_VERSION","pkgJsonPath","cwd","dirname","import","meta","pkgJson","version","getProjectVersionService","abstraction","implementation","dependencies"],"sources":["GetProjectVersionService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { findUpSync } from \"find-up\";\nimport path from \"path\";\nimport { GetProjectVersionService } from \"~/abstractions/index.js\";\nimport { loadJsonFileSync } from \"load-json-file\";\nimport type { PackageJson } from \"type-fest\";\n\nclass DefaultGetProjectVersionService implements GetProjectVersionService.Interface {\n cachedProjectVersion: string | null = null;\n\n execute() {\n if (this.cachedProjectVersion) {\n return this.cachedProjectVersion;\n }\n\n const envProjectVersion = process.env.WEBINY_VERSION;\n if (envProjectVersion) {\n this.cachedProjectVersion = envProjectVersion;\n return this.cachedProjectVersion;\n }\n\n const pkgJsonPath = findUpSync(\"package.json\", {\n cwd: path.dirname(import.meta.dirname)\n });\n\n const pkgJson = pkgJsonPath ? (loadJsonFileSync(pkgJsonPath) as PackageJson) : null;\n\n if (pkgJson?.version) {\n this.cachedProjectVersion = pkgJson.version;\n return this.cachedProjectVersion;\n }\n\n return \"0.0.0\";\n }\n}\n\nexport const getProjectVersionService = createImplementation({\n abstraction: GetProjectVersionService,\n implementation: DefaultGetProjectVersionService,\n dependencies: []\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,UAAU,QAAQ,SAAS;AACpC,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,wBAAwB;AACjC,SAASC,gBAAgB,QAAQ,gBAAgB;AAGjD,MAAMC,+BAA+B,CAA+C;EAChFC,oBAAoB,GAAkB,IAAI;EAE1CC,OAAOA,CAAA,EAAG;IACN,IAAI,IAAI,CAACD,oBAAoB,EAAE;MAC3B,OAAO,IAAI,CAACA,oBAAoB;IACpC;IAEA,MAAME,iBAAiB,GAAGC,OAAO,CAACC,GAAG,CAACC,cAAc;IACpD,IAAIH,iBAAiB,EAAE;MACnB,IAAI,CAACF,oBAAoB,GAAGE,iBAAiB;MAC7C,OAAO,IAAI,CAACF,oBAAoB;IACpC;IAEA,MAAMM,WAAW,GAAGX,UAAU,CAAC,cAAc,EAAE;MAC3CY,GAAG,EAAEX,IAAI,CAACY,OAAO,CAACC,MAAM,CAACC,IAAI,CAACF,OAAO;IACzC,CAAC,CAAC;IAEF,MAAMG,OAAO,GAAGL,WAAW,GAAIR,gBAAgB,CAACQ,WAAW,CAAC,GAAmB,IAAI;IAEnF,IAAIK,OAAO,EAAEC,OAAO,EAAE;MAClB,IAAI,CAACZ,oBAAoB,GAAGW,OAAO,CAACC,OAAO;MAC3C,OAAO,IAAI,CAACZ,oBAAoB;IACpC;IAEA,OAAO,OAAO;EAClB;AACJ;AAEA,OAAO,MAAMa,wBAAwB,GAAGnB,oBAAoB,CAAC;EACzDoB,WAAW,EAAEjB,wBAAwB;EACrCkB,cAAc,EAAEhB,+BAA+B;EAC/CiB,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
|