@webiny/project 0.0.0-unstable.ac6ebf63c6 → 0.0.0-unstable.c27f4d8a31
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/ProjectSdk.d.ts +1 -0
- package/ProjectSdk.js +4 -1
- package/ProjectSdk.js.map +1 -1
- package/abstractions/features/GetFeatureFlags.d.ts +8 -0
- package/abstractions/features/GetFeatureFlags.js +4 -0
- package/abstractions/features/GetFeatureFlags.js.map +1 -0
- package/abstractions/features/index.d.ts +1 -0
- package/abstractions/features/index.js +1 -0
- package/abstractions/features/index.js.map +1 -1
- package/abstractions/services/WatchedLambdaFunctionsService.d.ts +12 -7
- package/abstractions/services/WatchedLambdaFunctionsService.js.map +1 -1
- package/components/Wcp.d.ts +2 -0
- package/components/Wcp.js +8 -1
- package/components/Wcp.js.map +1 -1
- package/createProjectSdkContainer.js +4 -1
- package/createProjectSdkContainer.js.map +1 -1
- package/decorators/DeployAppClearWatchedLambdaFunctions.d.ts +3 -2
- package/decorators/DeployAppClearWatchedLambdaFunctions.js +11 -5
- package/decorators/DeployAppClearWatchedLambdaFunctions.js.map +1 -1
- package/decorators/DeployAppWithWatchedLambdaReplacement.d.ts +3 -2
- package/decorators/DeployAppWithWatchedLambdaReplacement.js +16 -7
- package/decorators/DeployAppWithWatchedLambdaReplacement.js.map +1 -1
- package/decorators/GetFeatureFlagsWithLicense.d.ts +13 -0
- package/decorators/GetFeatureFlagsWithLicense.js +71 -0
- package/decorators/GetFeatureFlagsWithLicense.js.map +1 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +1 -0
- package/decorators/index.js.map +1 -1
- package/defineExtension/createExtensionReactComponent.js +2 -6
- package/defineExtension/createExtensionReactComponent.js.map +1 -1
- package/defineExtension/index.d.ts +0 -1
- package/defineExtension/index.js +0 -1
- package/defineExtension/index.js.map +1 -1
- package/defineExtension/models/ExtensionDefinitionModel.d.ts +4 -4
- package/defineExtension/models/ExtensionDefinitionModel.js.map +1 -1
- package/defineExtension/models/ExtensionInstanceModel.js +1 -1
- package/defineExtension/models/ExtensionInstanceModel.js.map +1 -1
- package/defineExtension/zodTypes/zodSrcPath.d.ts +2 -1
- package/defineExtension/zodTypes/zodSrcPath.js +7 -14
- package/defineExtension/zodTypes/zodSrcPath.js.map +1 -1
- package/exports/infra/index.d.ts +1 -1
- package/exports/infra/index.js +1 -1
- package/exports/infra/index.js.map +1 -1
- package/extensions/AdminBuildParam.d.ts +5 -0
- package/extensions/AdminBuildParam.js +184 -0
- package/extensions/AdminBuildParam.js.map +1 -0
- package/extensions/AdminExtension.d.ts +5 -0
- package/extensions/AdminExtension.js +99 -0
- package/extensions/AdminExtension.js.map +1 -0
- package/extensions/ApiBuildParam.d.ts +5 -0
- package/extensions/ApiBuildParam.js +119 -0
- package/extensions/ApiBuildParam.js.map +1 -0
- package/extensions/ApiExtension.d.ts +5 -0
- package/{defineExtension/defineApiExtension.js → extensions/ApiExtension.js} +14 -22
- package/extensions/ApiExtension.js.map +1 -0
- package/extensions/DatabaseSetup.d.ts +6 -6
- package/extensions/EnvVar.d.ts +1 -7
- package/extensions/ExtensionDefinitions.d.ts +1 -5
- package/extensions/FeatureFlags.d.ts +18 -0
- package/extensions/FeatureFlags.js +43 -0
- package/extensions/FeatureFlags.js.map +1 -0
- package/extensions/Project/EnsureTelemetryEnabledForOss.js +1 -1
- package/extensions/Project/EnsureTelemetryEnabledForOss.js.map +1 -1
- package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js +1 -0
- package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js.map +1 -1
- package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js +1 -0
- package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js.map +1 -1
- package/extensions/ProjectDecorator.d.ts +2 -6
- package/extensions/ProjectId.d.ts +2 -6
- package/extensions/ProjectImplementation.d.ts +2 -8
- package/extensions/Telemetry.d.ts +1 -5
- package/extensions/hooks/AdminAfterBuild.d.ts +2 -6
- package/extensions/hooks/AdminAfterDeploy.d.ts +2 -6
- package/extensions/hooks/AdminBeforeBuild.d.ts +2 -6
- package/extensions/hooks/AdminBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/AdminBeforeWatch.d.ts +2 -6
- package/extensions/hooks/AfterBuild.d.ts +2 -6
- package/extensions/hooks/AfterDeploy.d.ts +2 -6
- package/extensions/hooks/ApiAfterBuild.d.ts +2 -6
- package/extensions/hooks/ApiAfterDeploy.d.ts +2 -6
- package/extensions/hooks/ApiBeforeBuild.d.ts +2 -6
- package/extensions/hooks/ApiBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/ApiBeforeWatch.d.ts +2 -6
- package/extensions/hooks/BeforeBuild.d.ts +2 -6
- package/extensions/hooks/BeforeDeploy.d.ts +2 -6
- package/extensions/hooks/BeforeWatch.d.ts +2 -6
- package/extensions/hooks/CoreAfterBuild.d.ts +2 -6
- package/extensions/hooks/CoreAfterDeploy.d.ts +2 -6
- package/extensions/hooks/CoreBeforeBuild.d.ts +2 -6
- package/extensions/hooks/CoreBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/CoreBeforeWatch.d.ts +2 -6
- package/extensions/index.d.ts +46 -53
- package/extensions/index.js +12 -2
- package/extensions/index.js.map +1 -1
- package/extensions/pulumi/AdminPulumi.d.ts +2 -6
- package/extensions/pulumi/AdminStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/ApiPulumi.d.ts +2 -6
- package/extensions/pulumi/ApiStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/CorePulumi.d.ts +2 -6
- package/extensions/pulumi/CoreStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/ProductionEnvironments.d.ts +2 -6
- package/extensions/pulumi/PulumiResourceNamePrefix.d.ts +1 -5
- package/features/BuildApp/PackagesBuilder/worker.js +1 -1
- package/features/BuildApp/PackagesBuilder/worker.js.map +1 -1
- package/features/GetFeatureFlags/GetFeatureFlags.d.ts +10 -0
- package/features/GetFeatureFlags/GetFeatureFlags.js +29 -0
- package/features/GetFeatureFlags/GetFeatureFlags.js.map +1 -0
- package/features/GetFeatureFlags/index.d.ts +1 -0
- package/features/GetFeatureFlags/index.js +3 -0
- package/features/GetFeatureFlags/index.js.map +1 -0
- package/features/Watch/Watch.js +1 -0
- package/features/Watch/Watch.js.map +1 -1
- package/features/Watch/localInvocationWorker.js +5 -1
- package/features/Watch/localInvocationWorker.js.map +1 -1
- package/features/Watch/replaceLambdaFunctions.d.ts +2 -1
- package/features/Watch/replaceLambdaFunctions.js +5 -1
- package/features/Watch/replaceLambdaFunctions.js.map +1 -1
- package/features/index.d.ts +1 -0
- package/features/index.js +1 -0
- package/features/index.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/package.json +22 -20
- package/services/GetProjectConfigService/GetProjectConfigService.js +2 -1
- package/services/GetProjectConfigService/GetProjectConfigService.js.map +1 -1
- package/services/GetProjectConfigService/WcpProjectLicenseContext.d.ts +1 -0
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js +2 -1
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js.map +1 -1
- package/services/GetProjectConfigService/renderConfigWorker.js +12 -3
- package/services/GetProjectConfigService/renderConfigWorker.js.map +1 -1
- package/services/GetProjectIdService/GetProjectIdService.js +1 -1
- package/services/GetProjectIdService/GetProjectIdService.js.map +1 -1
- package/services/InitProjectSdkService/applyWcpEnvVars.js +10 -8
- package/services/InitProjectSdkService/applyWcpEnvVars.js.map +1 -1
- package/services/InitProjectSdkService/registerDecorators.js +2 -2
- package/services/InitProjectSdkService/registerDecorators.js.map +1 -1
- package/services/InitProjectSdkService/registerHooks.js +2 -2
- package/services/InitProjectSdkService/registerHooks.js.map +1 -1
- package/services/InitProjectSdkService/registerImplementations.js +2 -2
- package/services/InitProjectSdkService/registerImplementations.js.map +1 -1
- package/services/InitProjectSdkService/registerPulumiExtensions.js +2 -2
- package/services/InitProjectSdkService/registerPulumiExtensions.js.map +1 -1
- package/services/InstallExtensionService/InstallExtensionService.d.ts +1 -1
- package/services/InstallExtensionService/InstallExtensionService.js +4 -4
- package/services/InstallExtensionService/InstallExtensionService.js.map +1 -1
- package/services/InstallExtensionService/mergePackageJson.js +4 -4
- package/services/InstallExtensionService/mergePackageJson.js.map +1 -1
- package/services/InstallExtensionService/types.d.ts +4 -0
- package/services/InstallExtensionService/types.js.map +1 -1
- package/services/InstallExtensionService/updateWebinyConfig.js +74 -47
- package/services/InstallExtensionService/updateWebinyConfig.js.map +1 -1
- package/services/ListAppLambdaFunctionsService/ListAppLambdaFunctionsService.js +1 -1
- package/services/ListAppLambdaFunctionsService/ListAppLambdaFunctionsService.js.map +1 -1
- package/services/ProjectInfoService/ProjectInfoService.js +2 -2
- package/services/ProjectInfoService/ProjectInfoService.js.map +1 -1
- package/services/SetProjectIdService/SetProjectIdService.js +28 -18
- package/services/SetProjectIdService/SetProjectIdService.js.map +1 -1
- package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.d.ts +4 -4
- package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.js +26 -20
- package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.js.map +1 -1
- package/utils/ExtensionSrcResolver.d.ts +33 -0
- package/utils/ExtensionSrcResolver.js +120 -0
- package/utils/ExtensionSrcResolver.js.map +1 -0
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -1
- package/utils/index.js.map +1 -1
- package/utils/requireConfig.js +9 -5
- package/utils/requireConfig.js.map +1 -1
- package/utils/toImportSpecifier.d.ts +5 -0
- package/utils/toImportSpecifier.js +12 -0
- package/utils/toImportSpecifier.js.map +1 -0
- package/defineExtension/defineApiExtension.d.ts +0 -17
- package/defineExtension/defineApiExtension.js.map +0 -1
- package/exports/extensions.d.ts +0 -1
- package/exports/extensions.js +0 -3
- package/exports/extensions.js.map +0 -1
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.d.ts +0 -18
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.js +0 -15
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.js.map +0 -1
- package/features/Watch/watchers/utils/requireConfig.d.ts +0 -18
- package/features/Watch/watchers/utils/requireConfig.js +0 -15
- package/features/Watch/watchers/utils/requireConfig.js.map +0 -1
- package/utils/ImplPathResolver.d.ts +0 -10
- package/utils/ImplPathResolver.js +0 -27
- package/utils/ImplPathResolver.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { defineExtension, zodSrcPath } from "./index.js";
|
|
2
|
+
import { ExtensionSrcResolver } from "@webiny/project";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { Node, Project } from "ts-morph";
|
|
6
|
+
import crypto from "crypto";
|
|
7
|
+
export const AdminExtension = defineExtension({
|
|
8
|
+
type: "Admin/Extension",
|
|
9
|
+
tags: {
|
|
10
|
+
runtimeContext: "app-build",
|
|
11
|
+
appName: "admin"
|
|
12
|
+
},
|
|
13
|
+
description: "Extend the Admin application with custom functionality.",
|
|
14
|
+
multiple: true,
|
|
15
|
+
paramsSchema: ({
|
|
16
|
+
project
|
|
17
|
+
}) => {
|
|
18
|
+
return z.object({
|
|
19
|
+
src: zodSrcPath({
|
|
20
|
+
project
|
|
21
|
+
}),
|
|
22
|
+
exportName: z.string().optional()
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
async build(params, ctx) {
|
|
26
|
+
const extensionsTsxFilePath = ctx.project.paths.workspaceFolder.join("apps", "admin", "src", "Extensions.tsx").toString();
|
|
27
|
+
const {
|
|
28
|
+
src: extensionFilePath
|
|
29
|
+
} = params;
|
|
30
|
+
|
|
31
|
+
// Resolve to absolute path for file operations.
|
|
32
|
+
const absoluteExtensionFilePath = ExtensionSrcResolver.resolvePath(extensionFilePath, ctx.project);
|
|
33
|
+
const extensionFileName = path.basename(absoluteExtensionFilePath);
|
|
34
|
+
|
|
35
|
+
// Export name can be customized or defaults to the file name without extension.
|
|
36
|
+
const exportName = params.exportName ?? path.parse(extensionFileName).name;
|
|
37
|
+
|
|
38
|
+
// Generate a constant hash-based component name to avoid using timestamps.
|
|
39
|
+
const hash = crypto.createHash("sha256").update(extensionFilePath).digest("hex");
|
|
40
|
+
const componentName = `AdminExtension_${hash.slice(-10)}`;
|
|
41
|
+
const project = new Project();
|
|
42
|
+
const importPath = path.relative(path.dirname(extensionsTsxFilePath), absoluteExtensionFilePath).replace(/\.tsx?$/, ".js");
|
|
43
|
+
project.addSourceFileAtPath(extensionsTsxFilePath);
|
|
44
|
+
const source = project.getSourceFileOrThrow(extensionsTsxFilePath);
|
|
45
|
+
const existingImportDeclaration = source.getImportDeclaration(importPath);
|
|
46
|
+
if (existingImportDeclaration) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Check if the extension file has a default export or named export.
|
|
51
|
+
const extensionProject = new Project();
|
|
52
|
+
extensionProject.addSourceFileAtPath(absoluteExtensionFilePath);
|
|
53
|
+
const extensionSource = extensionProject.getSourceFileOrThrow(absoluteExtensionFilePath);
|
|
54
|
+
const hasDefaultExport = extensionSource.getDefaultExportSymbol() !== undefined;
|
|
55
|
+
let index = 1;
|
|
56
|
+
const importDeclarations = source.getImportDeclarations();
|
|
57
|
+
if (importDeclarations.length) {
|
|
58
|
+
const last = importDeclarations[importDeclarations.length - 1];
|
|
59
|
+
index = last.getChildIndex() + 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Import as default export if available, otherwise import named export.
|
|
63
|
+
if (hasDefaultExport) {
|
|
64
|
+
source.insertImportDeclaration(index, {
|
|
65
|
+
defaultImport: componentName,
|
|
66
|
+
moduleSpecifier: importPath
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
source.insertImportDeclaration(index, {
|
|
70
|
+
namedImports: [{
|
|
71
|
+
name: exportName,
|
|
72
|
+
alias: componentName
|
|
73
|
+
}],
|
|
74
|
+
moduleSpecifier: importPath
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const extensionsIdentifier = source.getFirstDescendant(node => {
|
|
78
|
+
if (!Node.isIdentifier(node)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return node.getText() === "Extensions";
|
|
82
|
+
});
|
|
83
|
+
if (!extensionsIdentifier) {
|
|
84
|
+
throw new Error(`Could not find the "Extensions" React component in "${extensionsTsxFilePath}". Did you maybe change the name of the component?`);
|
|
85
|
+
}
|
|
86
|
+
const extensionsArrowFn = extensionsIdentifier.getNextSibling(node => Node.isArrowFunction(node));
|
|
87
|
+
if (!extensionsArrowFn) {
|
|
88
|
+
throw new Error(`Could not find the "Extensions" React component in "${extensionsTsxFilePath}". Did you maybe change its definition? It should be an arrow function.`);
|
|
89
|
+
}
|
|
90
|
+
const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant(node => {
|
|
91
|
+
return Node.isJsxFragment(node);
|
|
92
|
+
});
|
|
93
|
+
const extensionsArrowFnFragmentChildrenText = extensionsArrowFnFragment.getFullText().replace("<>", "").replace("</>", "").trim();
|
|
94
|
+
extensionsArrowFnFragment.replaceWithText(`<><${componentName}/>${extensionsArrowFnFragmentChildrenText}</>`);
|
|
95
|
+
await source.save();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=AdminExtension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defineExtension","zodSrcPath","ExtensionSrcResolver","z","path","Node","Project","crypto","AdminExtension","type","tags","runtimeContext","appName","description","multiple","paramsSchema","project","object","src","exportName","string","optional","build","params","ctx","extensionsTsxFilePath","paths","workspaceFolder","join","toString","extensionFilePath","absoluteExtensionFilePath","resolvePath","extensionFileName","basename","parse","name","hash","createHash","update","digest","componentName","slice","importPath","relative","dirname","replace","addSourceFileAtPath","source","getSourceFileOrThrow","existingImportDeclaration","getImportDeclaration","extensionProject","extensionSource","hasDefaultExport","getDefaultExportSymbol","undefined","index","importDeclarations","getImportDeclarations","length","last","getChildIndex","insertImportDeclaration","defaultImport","moduleSpecifier","namedImports","alias","extensionsIdentifier","getFirstDescendant","node","isIdentifier","getText","Error","extensionsArrowFn","getNextSibling","isArrowFunction","extensionsArrowFnFragment","isJsxFragment","extensionsArrowFnFragmentChildrenText","getFullText","trim","replaceWithText","save"],"sources":["AdminExtension.ts"],"sourcesContent":["import { defineExtension, zodSrcPath } from \"~/extensions/index.js\";\nimport { ExtensionSrcResolver } from \"@webiny/project\";\nimport { z } from \"zod\";\nimport path from \"path\";\nimport { type JsxFragment, Node, Project } from \"ts-morph\";\nimport crypto from \"crypto\";\n\nexport const AdminExtension = defineExtension({\n type: \"Admin/Extension\",\n tags: { runtimeContext: \"app-build\", appName: \"admin\" },\n description: \"Extend the Admin application with custom functionality.\",\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 extensionsTsxFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"src\", \"Extensions.tsx\")\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 can be customized or defaults to the file name without extension.\n const exportName = params.exportName ?? path.parse(extensionFileName).name;\n\n // Generate a constant hash-based component name to avoid using timestamps.\n const hash = crypto.createHash(\"sha256\").update(extensionFilePath).digest(\"hex\");\n const componentName = `AdminExtension_${hash.slice(-10)}`;\n\n const project = new Project();\n\n const importPath = path\n .relative(path.dirname(extensionsTsxFilePath), absoluteExtensionFilePath)\n .replace(/\\.tsx?$/, \".js\");\n\n project.addSourceFileAtPath(extensionsTsxFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsxFilePath);\n\n const existingImportDeclaration = source.getImportDeclaration(importPath);\n if (existingImportDeclaration) {\n return;\n }\n\n // Check if the extension file has a default export or named export.\n const extensionProject = new Project();\n extensionProject.addSourceFileAtPath(absoluteExtensionFilePath);\n const extensionSource = extensionProject.getSourceFileOrThrow(absoluteExtensionFilePath);\n const hasDefaultExport = extensionSource.getDefaultExportSymbol() !== undefined;\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 // Import as default export if available, otherwise import named export.\n if (hasDefaultExport) {\n source.insertImportDeclaration(index, {\n defaultImport: componentName,\n moduleSpecifier: importPath\n });\n } else {\n source.insertImportDeclaration(index, {\n namedImports: [{ name: exportName, alias: componentName }],\n moduleSpecifier: importPath\n });\n }\n\n const extensionsIdentifier = source.getFirstDescendant(node => {\n if (!Node.isIdentifier(node)) {\n return false;\n }\n\n return node.getText() === \"Extensions\";\n });\n\n if (!extensionsIdentifier) {\n throw new Error(\n `Could not find the \"Extensions\" React component in \"${extensionsTsxFilePath}\". Did you maybe change the name of the component?`\n );\n }\n\n const extensionsArrowFn = extensionsIdentifier.getNextSibling(node =>\n Node.isArrowFunction(node)\n );\n if (!extensionsArrowFn) {\n throw new Error(\n `Could not find the \"Extensions\" React component in \"${extensionsTsxFilePath}\". Did you maybe change its definition? It should be an arrow function.`\n );\n }\n\n const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant(node => {\n return Node.isJsxFragment(node);\n }) as JsxFragment;\n\n const extensionsArrowFnFragmentChildrenText = extensionsArrowFnFragment\n .getFullText()\n .replace(\"<>\", \"\")\n .replace(\"</>\", \"\")\n .trim();\n\n extensionsArrowFnFragment.replaceWithText(\n `<><${componentName}/>${extensionsArrowFnFragmentChildrenText}</>`\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;AAC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ignoreList":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const BuildParam: import("~/defineExtension/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
|
+
paramName: z.ZodString;
|
|
4
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>, z.ZodNumber, z.ZodBoolean]>;
|
|
5
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Node, Project } from "ts-morph";
|
|
3
|
+
import { defineExtension } from "../defineExtension/index.js";
|
|
4
|
+
import crypto from "crypto";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
export const BuildParam = defineExtension({
|
|
8
|
+
type: "Api/BuildParam",
|
|
9
|
+
tags: {
|
|
10
|
+
runtimeContext: "app-build",
|
|
11
|
+
appName: "api"
|
|
12
|
+
},
|
|
13
|
+
description: "Add build-time parameter to API app.",
|
|
14
|
+
multiple: true,
|
|
15
|
+
paramsSchema: () => {
|
|
16
|
+
return z.object({
|
|
17
|
+
paramName: z.string(),
|
|
18
|
+
value: z.union([z.string(), z.record(z.string(), z.any()), z.array(z.any()), z.number(), z.boolean()])
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
async build(params, ctx) {
|
|
22
|
+
const extensionsTsFilePath = ctx.project.paths.workspaceFolder.join("apps", "api", "graphql", "src", "extensions.ts").toString();
|
|
23
|
+
const buildParamsDir = ctx.project.paths.workspaceFolder.join("apps", "api", "graphql", "src", "buildParams").toString();
|
|
24
|
+
const {
|
|
25
|
+
paramName,
|
|
26
|
+
value
|
|
27
|
+
} = params;
|
|
28
|
+
|
|
29
|
+
// Serialize value to a TypeScript literal.
|
|
30
|
+
const valueStr = JSON.stringify(value, null, 4);
|
|
31
|
+
|
|
32
|
+
// Generate a unique class name based on the paramName.
|
|
33
|
+
const hash = crypto.createHash("sha256").update(paramName).digest("hex");
|
|
34
|
+
const className = `BuildParam_${hash.slice(-10)}`;
|
|
35
|
+
const fileName = `${className}.ts`;
|
|
36
|
+
const filePath = path.join(buildParamsDir, fileName);
|
|
37
|
+
|
|
38
|
+
// Ensure buildParams directory exists.
|
|
39
|
+
if (!fs.existsSync(buildParamsDir)) {
|
|
40
|
+
fs.mkdirSync(buildParamsDir, {
|
|
41
|
+
recursive: true
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Check if file already exists.
|
|
46
|
+
if (fs.existsSync(filePath)) {
|
|
47
|
+
// File exists, just ensure it's imported in extensions.ts
|
|
48
|
+
} else {
|
|
49
|
+
// Create the BuildParam implementation file.
|
|
50
|
+
const fileContent = `import { BuildParam } from "webiny/api/build-params";
|
|
51
|
+
|
|
52
|
+
class ${className} implements BuildParam.Interface {
|
|
53
|
+
key = "${paramName}";
|
|
54
|
+
value = ${valueStr};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default BuildParam.createImplementation({
|
|
58
|
+
implementation: ${className},
|
|
59
|
+
dependencies: []
|
|
60
|
+
});
|
|
61
|
+
`;
|
|
62
|
+
fs.writeFileSync(filePath, fileContent, "utf8");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Now update extensions.ts to import and register this BuildParam.
|
|
66
|
+
const project = new Project();
|
|
67
|
+
project.addSourceFileAtPath(extensionsTsFilePath);
|
|
68
|
+
const source = project.getSourceFileOrThrow(extensionsTsFilePath);
|
|
69
|
+
|
|
70
|
+
// Calculate import path relative to extensions.ts.
|
|
71
|
+
let importPath = path.relative(path.dirname(extensionsTsFilePath), filePath).replace(/\.tsx?$/, ".js");
|
|
72
|
+
|
|
73
|
+
// Ensure the path starts with ./
|
|
74
|
+
if (!importPath.startsWith(".")) {
|
|
75
|
+
importPath = "./" + importPath;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Check if import already exists.
|
|
79
|
+
const existingImportDeclaration = source.getImportDeclaration(importPath);
|
|
80
|
+
if (existingImportDeclaration) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
let index = 1;
|
|
84
|
+
const importDeclarations = source.getImportDeclarations();
|
|
85
|
+
if (importDeclarations.length) {
|
|
86
|
+
const last = importDeclarations[importDeclarations.length - 1];
|
|
87
|
+
index = last.getChildIndex() + 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Add import for the BuildParam implementation.
|
|
91
|
+
source.insertImportDeclaration(index, {
|
|
92
|
+
defaultImport: className,
|
|
93
|
+
moduleSpecifier: importPath
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Add the registration to the plugins array.
|
|
97
|
+
const pluginsArray = source.getFirstDescendant(node => Node.isArrayLiteralExpression(node));
|
|
98
|
+
pluginsArray.addElement(`\ncreateContextPlugin(ctx => {\n\tregisterExtension(ctx.container, ${className});\n})`);
|
|
99
|
+
{
|
|
100
|
+
let index = 1;
|
|
101
|
+
const importDeclarations = source.getImportDeclarations();
|
|
102
|
+
if (importDeclarations.length) {
|
|
103
|
+
const last = importDeclarations[importDeclarations.length - 1];
|
|
104
|
+
index = last.getChildIndex() + 1;
|
|
105
|
+
}
|
|
106
|
+
const contextPluginImportPath = "@webiny/api/plugins/ContextPlugin";
|
|
107
|
+
const existingContextPluginImport = source.getImportDeclaration(contextPluginImportPath);
|
|
108
|
+
if (!existingContextPluginImport) {
|
|
109
|
+
source.insertImportDeclaration(index, {
|
|
110
|
+
namedImports: ["createContextPlugin"],
|
|
111
|
+
moduleSpecifier: contextPluginImportPath
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
await source.save();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=ApiBuildParam.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["z","Node","Project","defineExtension","crypto","path","fs","BuildParam","type","tags","runtimeContext","appName","description","multiple","paramsSchema","object","paramName","string","value","union","record","any","array","number","boolean","build","params","ctx","extensionsTsFilePath","project","paths","workspaceFolder","join","toString","buildParamsDir","valueStr","JSON","stringify","hash","createHash","update","digest","className","slice","fileName","filePath","existsSync","mkdirSync","recursive","fileContent","writeFileSync","addSourceFileAtPath","source","getSourceFileOrThrow","importPath","relative","dirname","replace","startsWith","existingImportDeclaration","getImportDeclaration","index","importDeclarations","getImportDeclarations","length","last","getChildIndex","insertImportDeclaration","defaultImport","moduleSpecifier","pluginsArray","getFirstDescendant","node","isArrayLiteralExpression","addElement","contextPluginImportPath","existingContextPluginImport","namedImports","save"],"sources":["ApiBuildParam.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport crypto from \"crypto\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport const BuildParam = defineExtension({\n type: \"Api/BuildParam\",\n tags: { runtimeContext: \"app-build\", appName: \"api\" },\n description: \"Add build-time parameter to API app.\",\n multiple: true,\n paramsSchema: () => {\n return z.object({\n paramName: z.string(),\n value: z.union([\n z.string(),\n z.record(z.string(), z.any()),\n z.array(z.any()),\n z.number(),\n z.boolean()\n ])\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 buildParamsDir = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"buildParams\")\n .toString();\n\n const { paramName, value } = params;\n\n // Serialize value to a TypeScript literal.\n const valueStr = JSON.stringify(value, null, 4);\n\n // Generate a unique class name based on the paramName.\n const hash = crypto.createHash(\"sha256\").update(paramName).digest(\"hex\");\n const className = `BuildParam_${hash.slice(-10)}`;\n const fileName = `${className}.ts`;\n const filePath = path.join(buildParamsDir, fileName);\n\n // Ensure buildParams directory exists.\n if (!fs.existsSync(buildParamsDir)) {\n fs.mkdirSync(buildParamsDir, { recursive: true });\n }\n\n // Check if file already exists.\n if (fs.existsSync(filePath)) {\n // File exists, just ensure it's imported in extensions.ts\n } else {\n // Create the BuildParam implementation file.\n const fileContent = `import { BuildParam } from \"webiny/api/build-params\";\n\nclass ${className} implements BuildParam.Interface {\n key = \"${paramName}\";\n value = ${valueStr};\n}\n\nexport default BuildParam.createImplementation({\n implementation: ${className},\n dependencies: []\n});\n`;\n fs.writeFileSync(filePath, fileContent, \"utf8\");\n }\n\n // Now update extensions.ts to import and register this BuildParam.\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsFilePath);\n\n // Calculate import path relative to extensions.ts.\n let importPath = path\n .relative(path.dirname(extensionsTsFilePath), filePath)\n .replace(/\\.tsx?$/, \".js\");\n\n // Ensure the path starts with ./\n if (!importPath.startsWith(\".\")) {\n importPath = \"./\" + importPath;\n }\n\n // Check if import already exists.\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 // Add import for the BuildParam implementation.\n source.insertImportDeclaration(index, {\n defaultImport: className,\n moduleSpecifier: importPath\n });\n\n // Add the registration to the plugins array.\n const pluginsArray = source.getFirstDescendant(node =>\n Node.isArrayLiteralExpression(node)\n ) as ArrayLiteralExpression;\n\n pluginsArray.addElement(\n `\\ncreateContextPlugin(ctx => {\\n\\tregisterExtension(ctx.container, ${className});\\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 contextPluginImportPath = \"@webiny/api/plugins/ContextPlugin\";\n const existingContextPluginImport =\n source.getImportDeclaration(contextPluginImportPath);\n if (!existingContextPluginImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"createContextPlugin\"],\n moduleSpecifier: contextPluginImportPath\n });\n }\n }\n\n await source.save();\n }\n});\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,SAASC,IAAI,EAAEC,OAAO,QAAgC,UAAU;AAChE,SAASC,eAAe;AACxB,OAAOC,MAAM,MAAM,QAAQ;AAC3B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AAEnB,OAAO,MAAMC,UAAU,GAAGJ,eAAe,CAAC;EACtCK,IAAI,EAAE,gBAAgB;EACtBC,IAAI,EAAE;IAAEC,cAAc,EAAE,WAAW;IAAEC,OAAO,EAAE;EAAM,CAAC;EACrDC,WAAW,EAAE,sCAAsC;EACnDC,QAAQ,EAAE,IAAI;EACdC,YAAY,EAAEA,CAAA,KAAM;IAChB,OAAOd,CAAC,CAACe,MAAM,CAAC;MACZC,SAAS,EAAEhB,CAAC,CAACiB,MAAM,CAAC,CAAC;MACrBC,KAAK,EAAElB,CAAC,CAACmB,KAAK,CAAC,CACXnB,CAAC,CAACiB,MAAM,CAAC,CAAC,EACVjB,CAAC,CAACoB,MAAM,CAACpB,CAAC,CAACiB,MAAM,CAAC,CAAC,EAAEjB,CAAC,CAACqB,GAAG,CAAC,CAAC,CAAC,EAC7BrB,CAAC,CAACsB,KAAK,CAACtB,CAAC,CAACqB,GAAG,CAAC,CAAC,CAAC,EAChBrB,CAAC,CAACuB,MAAM,CAAC,CAAC,EACVvB,CAAC,CAACwB,OAAO,CAAC,CAAC,CACd;IACL,CAAC,CAAC;EACN,CAAC;EACD,MAAMC,KAAKA,CAACC,MAAM,EAAEC,GAAG,EAAE;IACrB,MAAMC,oBAAoB,GAAGD,GAAG,CAACE,OAAO,CAACC,KAAK,CAACC,eAAe,CACzDC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,CAAC,CACtDC,QAAQ,C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,MAAM,EAAE;QAC3B,MAAMC,IAAI,GAAGH,kBAAkB,CAACA,kBAAkB,CAACE,MAAM,GAAG,CAAC,CAAC;QAC9DH,KAAK,GAAGI,IAAI,CAACC,aAAa,CAAC,CAAC,GAAG,CAAC;MACpC;MAEA,MAAMS,uBAAuB,GAAG,mCAAmC;MACnE,MAAMC,2BAA2B,GAC7BxB,MAAM,CAACQ,oBAAoB,CAACe,uBAAuB,CAAC;MACxD,IAAI,CAACC,2BAA2B,EAAE;QAC9BxB,MAAM,CAACe,uBAAuB,CAACN,KAAK,EAAE;UAClCgB,YAAY,EAAE,CAAC,qBAAqB,CAAC;UACrCR,eAAe,EAAEM;QACrB,CAAC,CAAC;MACN;IACJ;IAEA,MAAMvB,MAAM,CAAC0B,IAAI,CAAC,CAAC;EACvB;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
+
import { defineExtension, zodSrcPath } from "./index.js";
|
|
2
|
+
import { ExtensionSrcResolver } from "@webiny/project";
|
|
1
3
|
import { z } from "zod";
|
|
2
|
-
import { Node, Project } from "ts-morph";
|
|
3
|
-
import { defineExtension } from "./index.js";
|
|
4
|
-
import { zodSrcPath } from "./zodTypes/zodSrcPath.js";
|
|
5
4
|
import path from "path";
|
|
5
|
+
import { Node, Project } from "ts-morph";
|
|
6
6
|
import crypto from "crypto";
|
|
7
|
-
export const
|
|
8
|
-
type:
|
|
7
|
+
export const ApiExtension = defineExtension({
|
|
8
|
+
type: "Api/Extension",
|
|
9
9
|
tags: {
|
|
10
10
|
runtimeContext: "app-build",
|
|
11
11
|
appName: "api"
|
|
12
12
|
},
|
|
13
|
-
description:
|
|
13
|
+
description: "Add any API extension.",
|
|
14
14
|
multiple: true,
|
|
15
15
|
paramsSchema: ({
|
|
16
16
|
project
|
|
17
17
|
}) => {
|
|
18
18
|
return z.object({
|
|
19
19
|
src: zodSrcPath({
|
|
20
|
-
project
|
|
21
|
-
abstraction: params.abstraction
|
|
20
|
+
project
|
|
22
21
|
}),
|
|
23
22
|
exportName: z.string().optional()
|
|
24
23
|
});
|
|
@@ -29,26 +28,19 @@ export const defineApiExtension = params => defineExtension({
|
|
|
29
28
|
src: extensionFilePath
|
|
30
29
|
} = params;
|
|
31
30
|
|
|
32
|
-
// Resolve to absolute path for file operations
|
|
33
|
-
|
|
34
|
-
if (extensionFilePath.startsWith("/extensions/")) {
|
|
35
|
-
// Resolve from project root
|
|
36
|
-
absoluteExtensionFilePath = ctx.project.paths.rootFolder.join(extensionFilePath).toString();
|
|
37
|
-
} else {
|
|
38
|
-
// Treat as absolute path
|
|
39
|
-
absoluteExtensionFilePath = extensionFilePath;
|
|
40
|
-
}
|
|
31
|
+
// Resolve to absolute path for file operations.
|
|
32
|
+
const absoluteExtensionFilePath = ExtensionSrcResolver.resolvePath(extensionFilePath, ctx.project);
|
|
41
33
|
const extensionFileName = path.basename(absoluteExtensionFilePath);
|
|
42
34
|
|
|
43
|
-
//
|
|
35
|
+
// Export name is always the file name without extension.
|
|
44
36
|
const exportName = params.exportName ?? path.parse(extensionFileName).name;
|
|
45
37
|
|
|
46
|
-
//
|
|
47
|
-
//
|
|
38
|
+
// Alias name is "ApiExtension_" + hash of the file path. This way we
|
|
39
|
+
// avoid potential naming conflicts and keep the identifier constant.
|
|
48
40
|
const hash = crypto.createHash("sha256").update(extensionFilePath).digest("hex");
|
|
49
41
|
const exportNameAlias = `ApiExtension_${hash.slice(-10)}`;
|
|
50
42
|
|
|
51
|
-
//
|
|
43
|
+
// Calculate import path relative to `extensions.ts` file.
|
|
52
44
|
const importPath = path.relative(path.dirname(extensionsTsFilePath), absoluteExtensionFilePath).replace(/\.tsx?$/, ".js");
|
|
53
45
|
const project = new Project();
|
|
54
46
|
project.addSourceFileAtPath(extensionsTsFilePath);
|
|
@@ -107,4 +99,4 @@ export const defineApiExtension = params => defineExtension({
|
|
|
107
99
|
}
|
|
108
100
|
});
|
|
109
101
|
|
|
110
|
-
//# sourceMappingURL=
|
|
102
|
+
//# sourceMappingURL=ApiExtension.js.map
|
|
@@ -0,0 +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","contextPluginImportPath","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 `\\ncreateContextPlugin(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 contextPluginImportPath = \"@webiny/api/plugins/ContextPlugin\";\n const existingContextPluginImport =\n source.getImportDeclaration(contextPluginImportPath);\n if (!existingContextPluginImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"createContextPlugin\"],\n moduleSpecifier: contextPluginImportPath\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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J;IAEA,MAAMzB,MAAM,CAAC2B,IAAI,CAAC,CAAC;EACvB;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const DatabaseSetup: import("../defineExtension/defineExtension.js").ExtensionComponent<z.ZodObject<{
|
|
3
|
-
setupName: z.ZodEnum<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}>>;
|
|
3
|
+
setupName: z.ZodEnum<{
|
|
4
|
+
ddb: "ddb";
|
|
5
|
+
"ddb+es": "ddb+es";
|
|
6
|
+
"ddb+os": "ddb+os";
|
|
7
|
+
}>;
|
|
8
|
+
}, z.core.$strip>>;
|
package/extensions/EnvVar.d.ts
CHANGED
|
@@ -2,10 +2,4 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const EnvVar: import("~/defineExtension/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
3
|
varName: z.ZodString;
|
|
4
4
|
value: z.ZodString;
|
|
5
|
-
},
|
|
6
|
-
value: string;
|
|
7
|
-
varName: string;
|
|
8
|
-
}, {
|
|
9
|
-
value: string;
|
|
10
|
-
varName: string;
|
|
11
|
-
}>>;
|
|
5
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const FeatureFlags: import("~/defineExtension/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
|
+
features: z.ZodObject<{
|
|
4
|
+
multiTenancy: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
+
advancedPublishingWorkflow: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
advancedAccessControlLayer: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
7
|
+
teams: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
privateFiles: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
folderLevelPermissions: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
hcmsFieldPermissions: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
}, z.core.$strip>]>>;
|
|
12
|
+
auditLogs: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
recordLocking: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
fileManager: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
threatDetection: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { BuildParam } from "./ApiBuildParam.js";
|
|
4
|
+
import { AdminBuildParam } from "./AdminBuildParam.js";
|
|
5
|
+
import { defineExtension } from "../defineExtension/index.js";
|
|
6
|
+
export const FeatureFlags = defineExtension({
|
|
7
|
+
type: "FeatureFlags",
|
|
8
|
+
tags: {
|
|
9
|
+
runtimeContext: "project"
|
|
10
|
+
},
|
|
11
|
+
description: "Enable or disable WCP features.",
|
|
12
|
+
paramsSchema: z.object({
|
|
13
|
+
// Follows `IFeatureFlagsDto` from `packages/feature-flags/src/types.ts`.
|
|
14
|
+
features: z.object({
|
|
15
|
+
multiTenancy: z.boolean().optional(),
|
|
16
|
+
advancedPublishingWorkflow: z.boolean().optional(),
|
|
17
|
+
advancedAccessControlLayer: z.union([z.boolean(), z.object({
|
|
18
|
+
teams: z.boolean().optional(),
|
|
19
|
+
privateFiles: z.boolean().optional(),
|
|
20
|
+
folderLevelPermissions: z.boolean().optional(),
|
|
21
|
+
hcmsFieldPermissions: z.boolean().optional()
|
|
22
|
+
})]).optional(),
|
|
23
|
+
auditLogs: z.boolean().optional(),
|
|
24
|
+
recordLocking: z.boolean().optional(),
|
|
25
|
+
fileManager: z.object({
|
|
26
|
+
threatDetection: z.boolean().optional()
|
|
27
|
+
}).optional()
|
|
28
|
+
})
|
|
29
|
+
}),
|
|
30
|
+
render: ({
|
|
31
|
+
features = {}
|
|
32
|
+
}) => {
|
|
33
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BuildParam, {
|
|
34
|
+
paramName: "FeatureFlags",
|
|
35
|
+
value: features
|
|
36
|
+
}), /*#__PURE__*/React.createElement(AdminBuildParam, {
|
|
37
|
+
paramName: "FeatureFlags",
|
|
38
|
+
value: features
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=FeatureFlags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","z","BuildParam","AdminBuildParam","defineExtension","FeatureFlags","type","tags","runtimeContext","description","paramsSchema","object","features","multiTenancy","boolean","optional","advancedPublishingWorkflow","advancedAccessControlLayer","union","teams","privateFiles","folderLevelPermissions","hcmsFieldPermissions","auditLogs","recordLocking","fileManager","threatDetection","render","createElement","Fragment","paramName","value"],"sources":["FeatureFlags.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { BuildParam } from \"./ApiBuildParam.js\";\nimport { AdminBuildParam } from \"./AdminBuildParam.js\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\n\nexport const FeatureFlags = defineExtension({\n type: \"FeatureFlags\",\n tags: { runtimeContext: \"project\" },\n description: \"Enable or disable WCP features.\",\n paramsSchema: z.object({\n // Follows `IFeatureFlagsDto` from `packages/feature-flags/src/types.ts`.\n features: z.object({\n multiTenancy: z.boolean().optional(),\n advancedPublishingWorkflow: z.boolean().optional(),\n advancedAccessControlLayer: z\n .union([\n z.boolean(),\n z.object({\n teams: z.boolean().optional(),\n privateFiles: z.boolean().optional(),\n folderLevelPermissions: z.boolean().optional(),\n hcmsFieldPermissions: z.boolean().optional()\n })\n ])\n .optional(),\n auditLogs: z.boolean().optional(),\n recordLocking: z.boolean().optional(),\n fileManager: z\n .object({\n threatDetection: z.boolean().optional()\n })\n .optional()\n })\n }),\n render: ({ features = {} }) => {\n return (\n <>\n <BuildParam paramName=\"FeatureFlags\" value={features} />\n <AdminBuildParam paramName=\"FeatureFlags\" value={features} />\n </>\n );\n }\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,CAAC,QAAQ,KAAK;AACvB,SAASC,UAAU;AACnB,SAASC,eAAe;AACxB,SAASC,eAAe;AAExB,OAAO,MAAMC,YAAY,GAAGD,eAAe,CAAC;EACxCE,IAAI,EAAE,cAAc;EACpBC,IAAI,EAAE;IAAEC,cAAc,EAAE;EAAU,CAAC;EACnCC,WAAW,EAAE,iCAAiC;EAC9CC,YAAY,EAAET,CAAC,CAACU,MAAM,CAAC;IACnB;IACAC,QAAQ,EAAEX,CAAC,CAACU,MAAM,CAAC;MACfE,YAAY,EAAEZ,CAAC,CAACa,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;MACpCC,0BAA0B,EAAEf,CAAC,CAACa,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;MAClDE,0BAA0B,EAAEhB,CAAC,CACxBiB,KAAK,CAAC,CACHjB,CAAC,CAACa,OAAO,CAAC,CAAC,EACXb,CAAC,CAACU,MAAM,CAAC;QACLQ,KAAK,EAAElB,CAAC,CAACa,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;QAC7BK,YAAY,EAAEnB,CAAC,CAACa,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;QACpCM,sBAAsB,EAAEpB,CAAC,CAACa,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;QAC9CO,oBAAoB,EAAErB,CAAC,CAACa,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC;MAC/C,CAAC,CAAC,CACL,CAAC,CACDA,QAAQ,CAAC,CAAC;MACfQ,SAAS,EAAEtB,CAAC,CAACa,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;MACjCS,aAAa,EAAEvB,CAAC,CAACa,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;MACrCU,WAAW,EAAExB,CAAC,CACTU,MAAM,CAAC;QACJe,eAAe,EAAEzB,CAAC,CAACa,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC;MAC1C,CAAC,CAAC,CACDA,QAAQ,CAAC;IAClB,CAAC;EACL,CAAC,CAAC;EACFY,MAAM,EAAEA,CAAC;IAAEf,QAAQ,GAAG,CAAC;EAAE,CAAC,KAAK;IAC3B,oBACIZ,KAAA,CAAA4B,aAAA,CAAA5B,KAAA,CAAA6B,QAAA,qBACI7B,KAAA,CAAA4B,aAAA,CAAC1B,UAAU;MAAC4B,SAAS,EAAC,cAAc;MAACC,KAAK,EAAEnB;IAAS,CAAE,CAAC,eACxDZ,KAAA,CAAA4B,aAAA,CAACzB,eAAe;MAAC2B,SAAS,EAAC,cAAc;MAACC,KAAK,EAAEnB;IAAS,CAAE,CAC9D,CAAC;EAEX;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -23,7 +23,7 @@ class EnsureTelemetryEnabledForOssImpl {
|
|
|
23
23
|
|
|
24
24
|
// If telemetry is disabled and WCP is not connected, throw an error
|
|
25
25
|
if (!telemetryEnabled && !wcpEnabled) {
|
|
26
|
-
const message = [`You are trying to deploy your project, but telemetry is currently disabled.`, `The open-source edition of Webiny requires telemetry to be enabled.`, `
|
|
26
|
+
const message = [`You are trying to deploy your project, but telemetry is currently disabled.`, `The open-source edition of Webiny requires telemetry to be enabled.`, `To proceed with the deployment, please re-enable telemetry or upgrade your project via https://www.webiny.com/pricing.`, `Learn more: https://webiny.link/telemetry-oss`].join(" ");
|
|
27
27
|
const error = new Error("Cannot deploy with telemetry disabled in OSS edition.");
|
|
28
28
|
throw GracefulError.from(error, message);
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BeforeDeploy","IsCi","IsTelemetryEnabled","IsWcpEnabled","IsWebinyJsRepo","GracefulError","EnsureTelemetryEnabledForOssImpl","constructor","isTelemetryEnabled","isWcpEnabled","isWebinyJsRepo","isCi","execute","isDevRepo","telemetryEnabled","wcpEnabled","message","join","error","Error","from","EnsureTelemetryEnabledForOss","createImplementation","implementation","dependencies"],"sources":["EnsureTelemetryEnabledForOss.ts"],"sourcesContent":["import {\n BeforeDeploy,\n IsCi,\n IsTelemetryEnabled,\n IsWcpEnabled,\n IsWebinyJsRepo\n} from \"~/abstractions/index.js\";\nimport { GracefulError } from \"@webiny/project\";\n\nclass EnsureTelemetryEnabledForOssImpl implements BeforeDeploy.Interface {\n constructor(\n private isTelemetryEnabled: IsTelemetryEnabled.Interface,\n private isWcpEnabled: IsWcpEnabled.Interface,\n private isWebinyJsRepo: IsWebinyJsRepo.Interface,\n private isCi: IsCi.Interface\n ) {}\n\n async execute() {\n // Skip telemetry checks in CI environments\n if (this.isCi.execute()) {\n return;\n }\n\n // Don't enforce telemetry validation in the webiny-js development repository\n const isDevRepo = this.isWebinyJsRepo.execute();\n if (isDevRepo) {\n return;\n }\n\n const telemetryEnabled = await this.isTelemetryEnabled.execute();\n const wcpEnabled = await this.isWcpEnabled.execute();\n\n // If telemetry is disabled and WCP is not connected, throw an error\n if (!telemetryEnabled && !wcpEnabled) {\n const message = [\n `You are trying to deploy your project, but telemetry is currently disabled.`,\n `The open-source edition of Webiny requires telemetry to be enabled.`,\n `
|
|
1
|
+
{"version":3,"names":["BeforeDeploy","IsCi","IsTelemetryEnabled","IsWcpEnabled","IsWebinyJsRepo","GracefulError","EnsureTelemetryEnabledForOssImpl","constructor","isTelemetryEnabled","isWcpEnabled","isWebinyJsRepo","isCi","execute","isDevRepo","telemetryEnabled","wcpEnabled","message","join","error","Error","from","EnsureTelemetryEnabledForOss","createImplementation","implementation","dependencies"],"sources":["EnsureTelemetryEnabledForOss.ts"],"sourcesContent":["import {\n BeforeDeploy,\n IsCi,\n IsTelemetryEnabled,\n IsWcpEnabled,\n IsWebinyJsRepo\n} from \"~/abstractions/index.js\";\nimport { GracefulError } from \"@webiny/project\";\n\nclass EnsureTelemetryEnabledForOssImpl implements BeforeDeploy.Interface {\n constructor(\n private isTelemetryEnabled: IsTelemetryEnabled.Interface,\n private isWcpEnabled: IsWcpEnabled.Interface,\n private isWebinyJsRepo: IsWebinyJsRepo.Interface,\n private isCi: IsCi.Interface\n ) {}\n\n async execute() {\n // Skip telemetry checks in CI environments\n if (this.isCi.execute()) {\n return;\n }\n\n // Don't enforce telemetry validation in the webiny-js development repository\n const isDevRepo = this.isWebinyJsRepo.execute();\n if (isDevRepo) {\n return;\n }\n\n const telemetryEnabled = await this.isTelemetryEnabled.execute();\n const wcpEnabled = await this.isWcpEnabled.execute();\n\n // If telemetry is disabled and WCP is not connected, throw an error\n if (!telemetryEnabled && !wcpEnabled) {\n const message = [\n `You are trying to deploy your project, but telemetry is currently disabled.`,\n `The open-source edition of Webiny requires telemetry to be enabled.`,\n `To proceed with the deployment, please re-enable telemetry or upgrade your project via https://www.webiny.com/pricing.`,\n `Learn more: https://webiny.link/telemetry-oss`\n ].join(\" \");\n\n const error = new Error(\"Cannot deploy with telemetry disabled in OSS edition.\");\n\n throw GracefulError.from(error, message);\n }\n }\n}\n\nexport const EnsureTelemetryEnabledForOss = BeforeDeploy.createImplementation({\n implementation: EnsureTelemetryEnabledForOssImpl,\n dependencies: [IsTelemetryEnabled, IsWcpEnabled, IsWebinyJsRepo, IsCi]\n});\n"],"mappings":"AAAA,SACIA,YAAY,EACZC,IAAI,EACJC,kBAAkB,EAClBC,YAAY,EACZC,cAAc;AAElB,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,MAAMC,gCAAgC,CAAmC;EACrEC,WAAWA,CACCC,kBAAgD,EAChDC,YAAoC,EACpCC,cAAwC,EACxCC,IAAoB,EAC9B;IAAA,KAJUH,kBAAgD,GAAhDA,kBAAgD;IAAA,KAChDC,YAAoC,GAApCA,YAAoC;IAAA,KACpCC,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,IAAoB,GAApBA,IAAoB;EAC7B;EAEH,MAAMC,OAAOA,CAAA,EAAG;IACZ;IACA,IAAI,IAAI,CAACD,IAAI,CAACC,OAAO,CAAC,CAAC,EAAE;MACrB;IACJ;;IAEA;IACA,MAAMC,SAAS,GAAG,IAAI,CAACH,cAAc,CAACE,OAAO,CAAC,CAAC;IAC/C,IAAIC,SAAS,EAAE;MACX;IACJ;IAEA,MAAMC,gBAAgB,GAAG,MAAM,IAAI,CAACN,kBAAkB,CAACI,OAAO,CAAC,CAAC;IAChE,MAAMG,UAAU,GAAG,MAAM,IAAI,CAACN,YAAY,CAACG,OAAO,CAAC,CAAC;;IAEpD;IACA,IAAI,CAACE,gBAAgB,IAAI,CAACC,UAAU,EAAE;MAClC,MAAMC,OAAO,GAAG,CACZ,6EAA6E,EAC7E,qEAAqE,EACrE,wHAAwH,EACxH,+CAA+C,CAClD,CAACC,IAAI,CAAC,GAAG,CAAC;MAEX,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAAC,uDAAuD,CAAC;MAEhF,MAAMd,aAAa,CAACe,IAAI,CAACF,KAAK,EAAEF,OAAO,CAAC;IAC5C;EACJ;AACJ;AAEA,OAAO,MAAMK,4BAA4B,GAAGrB,YAAY,CAACsB,oBAAoB,CAAC;EAC1EC,cAAc,EAAEjB,gCAAgC;EAChDkB,YAAY,EAAE,CAACtB,kBAAkB,EAAEC,YAAY,EAAEC,cAAc,EAAEH,IAAI;AACzE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -12,6 +12,7 @@ class SetAdminAppEnvVarsBeforeBuildImpl {
|
|
|
12
12
|
const projectVersion = this.getProjectVersionService.execute();
|
|
13
13
|
const telemetry = await this.isTelemetryEnabled.execute();
|
|
14
14
|
if (projectId) {
|
|
15
|
+
process.env.REACT_APP_WEBINY_PROJECT_ID = projectId;
|
|
15
16
|
process.env.REACT_APP_WCP_PROJECT_ID = projectId;
|
|
16
17
|
}
|
|
17
18
|
if (!("REACT_APP_WEBINY_TELEMETRY" in process.env)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AdminBeforeBuild","GetProjectIdService","GetProjectVersionService","IsTelemetryEnabled","globalConfig","isCI","SetAdminAppEnvVarsBeforeBuildImpl","constructor","isTelemetryEnabled","getProjectIdService","getProjectVersionService","execute","projectId","projectVersion","telemetry","process","env","REACT_APP_WCP_PROJECT_ID","REACT_APP_WEBINY_TELEMETRY","String","REACT_APP_WEBINY_TELEMETRY_USER_ID","get","newUser","Boolean","toString","REACT_APP_WEBINY_TELEMETRY_NEW_USER","INLINE_RUNTIME_CHUNK","REACT_APP_IS_CI","REACT_APP_WEBINY_VERSION","SetAdminAppEnvVarsBeforeBuild","createImplementation","implementation","dependencies"],"sources":["SetAdminAppEnvVarsBeforeBuild.ts"],"sourcesContent":["import {\n AdminBeforeBuild,\n GetProjectIdService,\n GetProjectVersionService,\n IsTelemetryEnabled\n} from \"~/abstractions/index.js\";\nimport { globalConfig } from \"@webiny/global-config\";\nimport { isCI } from \"ci-info\";\n\nclass SetAdminAppEnvVarsBeforeBuildImpl implements AdminBeforeBuild.Interface {\n constructor(\n private isTelemetryEnabled: IsTelemetryEnabled.Interface,\n private getProjectIdService: GetProjectIdService.Interface,\n private getProjectVersionService: GetProjectVersionService.Interface\n ) {}\n\n async execute() {\n const projectId = await this.getProjectIdService.execute();\n const projectVersion = this.getProjectVersionService.execute();\n\n const telemetry = await this.isTelemetryEnabled.execute();\n\n if (projectId) {\n process.env.REACT_APP_WCP_PROJECT_ID = projectId;\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY\" in process.env)) {\n process.env.REACT_APP_WEBINY_TELEMETRY = String(telemetry);\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY_USER_ID\" in process.env)) {\n process.env.REACT_APP_WEBINY_TELEMETRY_USER_ID = globalConfig.get(\"id\");\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY_NEW_USER\" in process.env)) {\n const newUser = Boolean(globalConfig.get(\"newUser\")).toString();\n process.env.REACT_APP_WEBINY_TELEMETRY_NEW_USER = newUser;\n }\n\n if (!(\"INLINE_RUNTIME_CHUNK\" in process.env)) {\n process.env.INLINE_RUNTIME_CHUNK = \"true\";\n }\n\n if (!(\"REACT_APP_IS_CI\" in process.env)) {\n process.env.REACT_APP_IS_CI = Boolean(isCI).toString();\n }\n\n if (!(\"REACT_APP_WEBINY_VERSION\" in process.env)) {\n process.env.REACT_APP_WEBINY_VERSION = projectVersion;\n }\n }\n}\n\nexport const SetAdminAppEnvVarsBeforeBuild = AdminBeforeBuild.createImplementation({\n implementation: SetAdminAppEnvVarsBeforeBuildImpl,\n dependencies: [IsTelemetryEnabled, GetProjectIdService, GetProjectVersionService]\n});\n"],"mappings":"AAAA,SACIA,gBAAgB,EAChBC,mBAAmB,EACnBC,wBAAwB,EACxBC,kBAAkB;AAEtB,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,IAAI,QAAQ,SAAS;AAE9B,MAAMC,iCAAiC,CAAuC;EAC1EC,WAAWA,CACCC,kBAAgD,EAChDC,mBAAkD,EAClDC,wBAA4D,EACtE;IAAA,KAHUF,kBAAgD,GAAhDA,kBAAgD;IAAA,KAChDC,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,wBAA4D,GAA5DA,wBAA4D;EACrE;EAEH,MAAMC,OAAOA,CAAA,EAAG;IACZ,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACH,mBAAmB,CAACE,OAAO,CAAC,CAAC;IAC1D,MAAME,cAAc,GAAG,IAAI,CAACH,wBAAwB,CAACC,OAAO,CAAC,CAAC;IAE9D,MAAMG,SAAS,GAAG,MAAM,IAAI,CAACN,kBAAkB,CAACG,OAAO,CAAC,CAAC;IAEzD,IAAIC,SAAS,EAAE;MACXG,OAAO,CAACC,GAAG,CAACC,
|
|
1
|
+
{"version":3,"names":["AdminBeforeBuild","GetProjectIdService","GetProjectVersionService","IsTelemetryEnabled","globalConfig","isCI","SetAdminAppEnvVarsBeforeBuildImpl","constructor","isTelemetryEnabled","getProjectIdService","getProjectVersionService","execute","projectId","projectVersion","telemetry","process","env","REACT_APP_WEBINY_PROJECT_ID","REACT_APP_WCP_PROJECT_ID","REACT_APP_WEBINY_TELEMETRY","String","REACT_APP_WEBINY_TELEMETRY_USER_ID","get","newUser","Boolean","toString","REACT_APP_WEBINY_TELEMETRY_NEW_USER","INLINE_RUNTIME_CHUNK","REACT_APP_IS_CI","REACT_APP_WEBINY_VERSION","SetAdminAppEnvVarsBeforeBuild","createImplementation","implementation","dependencies"],"sources":["SetAdminAppEnvVarsBeforeBuild.ts"],"sourcesContent":["import {\n AdminBeforeBuild,\n GetProjectIdService,\n GetProjectVersionService,\n IsTelemetryEnabled\n} from \"~/abstractions/index.js\";\nimport { globalConfig } from \"@webiny/global-config\";\nimport { isCI } from \"ci-info\";\n\nclass SetAdminAppEnvVarsBeforeBuildImpl implements AdminBeforeBuild.Interface {\n constructor(\n private isTelemetryEnabled: IsTelemetryEnabled.Interface,\n private getProjectIdService: GetProjectIdService.Interface,\n private getProjectVersionService: GetProjectVersionService.Interface\n ) {}\n\n async execute() {\n const projectId = await this.getProjectIdService.execute();\n const projectVersion = this.getProjectVersionService.execute();\n\n const telemetry = await this.isTelemetryEnabled.execute();\n\n if (projectId) {\n process.env.REACT_APP_WEBINY_PROJECT_ID = projectId;\n process.env.REACT_APP_WCP_PROJECT_ID = projectId;\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY\" in process.env)) {\n process.env.REACT_APP_WEBINY_TELEMETRY = String(telemetry);\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY_USER_ID\" in process.env)) {\n process.env.REACT_APP_WEBINY_TELEMETRY_USER_ID = globalConfig.get(\"id\");\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY_NEW_USER\" in process.env)) {\n const newUser = Boolean(globalConfig.get(\"newUser\")).toString();\n process.env.REACT_APP_WEBINY_TELEMETRY_NEW_USER = newUser;\n }\n\n if (!(\"INLINE_RUNTIME_CHUNK\" in process.env)) {\n process.env.INLINE_RUNTIME_CHUNK = \"true\";\n }\n\n if (!(\"REACT_APP_IS_CI\" in process.env)) {\n process.env.REACT_APP_IS_CI = Boolean(isCI).toString();\n }\n\n if (!(\"REACT_APP_WEBINY_VERSION\" in process.env)) {\n process.env.REACT_APP_WEBINY_VERSION = projectVersion;\n }\n }\n}\n\nexport const SetAdminAppEnvVarsBeforeBuild = AdminBeforeBuild.createImplementation({\n implementation: SetAdminAppEnvVarsBeforeBuildImpl,\n dependencies: [IsTelemetryEnabled, GetProjectIdService, GetProjectVersionService]\n});\n"],"mappings":"AAAA,SACIA,gBAAgB,EAChBC,mBAAmB,EACnBC,wBAAwB,EACxBC,kBAAkB;AAEtB,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,IAAI,QAAQ,SAAS;AAE9B,MAAMC,iCAAiC,CAAuC;EAC1EC,WAAWA,CACCC,kBAAgD,EAChDC,mBAAkD,EAClDC,wBAA4D,EACtE;IAAA,KAHUF,kBAAgD,GAAhDA,kBAAgD;IAAA,KAChDC,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,wBAA4D,GAA5DA,wBAA4D;EACrE;EAEH,MAAMC,OAAOA,CAAA,EAAG;IACZ,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACH,mBAAmB,CAACE,OAAO,CAAC,CAAC;IAC1D,MAAME,cAAc,GAAG,IAAI,CAACH,wBAAwB,CAACC,OAAO,CAAC,CAAC;IAE9D,MAAMG,SAAS,GAAG,MAAM,IAAI,CAACN,kBAAkB,CAACG,OAAO,CAAC,CAAC;IAEzD,IAAIC,SAAS,EAAE;MACXG,OAAO,CAACC,GAAG,CAACC,2BAA2B,GAAGL,SAAS;MACnDG,OAAO,CAACC,GAAG,CAACE,wBAAwB,GAAGN,SAAS;IACpD;IAEA,IAAI,EAAE,4BAA4B,IAAIG,OAAO,CAACC,GAAG,CAAC,EAAE;MAChDD,OAAO,CAACC,GAAG,CAACG,0BAA0B,GAAGC,MAAM,CAACN,SAAS,CAAC;IAC9D;IAEA,IAAI,EAAE,oCAAoC,IAAIC,OAAO,CAACC,GAAG,CAAC,EAAE;MACxDD,OAAO,CAACC,GAAG,CAACK,kCAAkC,GAAGjB,YAAY,CAACkB,GAAG,CAAC,IAAI,CAAC;IAC3E;IAEA,IAAI,EAAE,qCAAqC,IAAIP,OAAO,CAACC,GAAG,CAAC,EAAE;MACzD,MAAMO,OAAO,GAAGC,OAAO,CAACpB,YAAY,CAACkB,GAAG,CAAC,SAAS,CAAC,CAAC,CAACG,QAAQ,CAAC,CAAC;MAC/DV,OAAO,CAACC,GAAG,CAACU,mCAAmC,GAAGH,OAAO;IAC7D;IAEA,IAAI,EAAE,sBAAsB,IAAIR,OAAO,CAACC,GAAG,CAAC,EAAE;MAC1CD,OAAO,CAACC,GAAG,CAACW,oBAAoB,GAAG,MAAM;IAC7C;IAEA,IAAI,EAAE,iBAAiB,IAAIZ,OAAO,CAACC,GAAG,CAAC,EAAE;MACrCD,OAAO,CAACC,GAAG,CAACY,eAAe,GAAGJ,OAAO,CAACnB,IAAI,CAAC,CAACoB,QAAQ,CAAC,CAAC;IAC1D;IAEA,IAAI,EAAE,0BAA0B,IAAIV,OAAO,CAACC,GAAG,CAAC,EAAE;MAC9CD,OAAO,CAACC,GAAG,CAACa,wBAAwB,GAAGhB,cAAc;IACzD;EACJ;AACJ;AAEA,OAAO,MAAMiB,6BAA6B,GAAG9B,gBAAgB,CAAC+B,oBAAoB,CAAC;EAC/EC,cAAc,EAAE1B,iCAAiC;EACjD2B,YAAY,EAAE,CAAC9B,kBAAkB,EAAEF,mBAAmB,EAAEC,wBAAwB;AACpF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -12,6 +12,7 @@ class SetAdminAppEnvVarsBeforeWatchImpl {
|
|
|
12
12
|
const projectVersion = this.getProjectVersionService.execute();
|
|
13
13
|
const telemetry = await this.isTelemetryEnabled.execute();
|
|
14
14
|
if (projectId) {
|
|
15
|
+
process.env.REACT_APP_WEBINY_PROJECT_ID = projectId;
|
|
15
16
|
process.env.REACT_APP_WCP_PROJECT_ID = projectId;
|
|
16
17
|
}
|
|
17
18
|
if (!("REACT_APP_WEBINY_TELEMETRY" in process.env)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AdminBeforeWatch","IsTelemetryEnabled","GetProjectIdService","GetProjectVersionService","globalConfig","isCI","SetAdminAppEnvVarsBeforeWatchImpl","constructor","isTelemetryEnabled","getProjectIdService","getProjectVersionService","execute","projectId","projectVersion","telemetry","process","env","REACT_APP_WCP_PROJECT_ID","REACT_APP_WEBINY_TELEMETRY","String","REACT_APP_WEBINY_TELEMETRY_USER_ID","get","newUser","Boolean","toString","REACT_APP_WEBINY_TELEMETRY_NEW_USER","INLINE_RUNTIME_CHUNK","REACT_APP_IS_CI","REACT_APP_WEBINY_VERSION","SetAdminAppEnvVarsBeforeWatch","createImplementation","implementation","dependencies"],"sources":["SetAdminAppEnvVarsBeforeWatch.ts"],"sourcesContent":["import {\n AdminBeforeWatch,\n IsTelemetryEnabled,\n GetProjectIdService,\n GetProjectVersionService\n} from \"~/abstractions/index.js\";\nimport { globalConfig } from \"@webiny/global-config\";\nimport { isCI } from \"ci-info\";\n\nclass SetAdminAppEnvVarsBeforeWatchImpl implements AdminBeforeWatch.Interface {\n constructor(\n private isTelemetryEnabled: IsTelemetryEnabled.Interface,\n private getProjectIdService: GetProjectIdService.Interface,\n private getProjectVersionService: GetProjectVersionService.Interface\n ) {}\n\n async execute() {\n const projectId = await this.getProjectIdService.execute();\n const projectVersion = this.getProjectVersionService.execute();\n\n const telemetry = await this.isTelemetryEnabled.execute();\n\n if (projectId) {\n process.env.REACT_APP_WCP_PROJECT_ID = projectId;\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY\" in process.env)) {\n process.env.REACT_APP_WEBINY_TELEMETRY = String(telemetry);\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY_USER_ID\" in process.env)) {\n process.env.REACT_APP_WEBINY_TELEMETRY_USER_ID = globalConfig.get(\"id\");\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY_NEW_USER\" in process.env)) {\n const newUser = Boolean(globalConfig.get(\"newUser\")).toString();\n process.env.REACT_APP_WEBINY_TELEMETRY_NEW_USER = newUser;\n }\n\n if (!(\"INLINE_RUNTIME_CHUNK\" in process.env)) {\n process.env.INLINE_RUNTIME_CHUNK = \"true\";\n }\n\n if (!(\"REACT_APP_IS_CI\" in process.env)) {\n process.env.REACT_APP_IS_CI = Boolean(isCI).toString();\n }\n\n if (!(\"REACT_APP_WEBINY_VERSION\" in process.env)) {\n process.env.REACT_APP_WEBINY_VERSION = projectVersion;\n }\n }\n}\n\nexport const SetAdminAppEnvVarsBeforeWatch = AdminBeforeWatch.createImplementation({\n implementation: SetAdminAppEnvVarsBeforeWatchImpl,\n dependencies: [IsTelemetryEnabled, GetProjectIdService, GetProjectVersionService]\n});\n"],"mappings":"AAAA,SACIA,gBAAgB,EAChBC,kBAAkB,EAClBC,mBAAmB,EACnBC,wBAAwB;AAE5B,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,IAAI,QAAQ,SAAS;AAE9B,MAAMC,iCAAiC,CAAuC;EAC1EC,WAAWA,CACCC,kBAAgD,EAChDC,mBAAkD,EAClDC,wBAA4D,EACtE;IAAA,KAHUF,kBAAgD,GAAhDA,kBAAgD;IAAA,KAChDC,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,wBAA4D,GAA5DA,wBAA4D;EACrE;EAEH,MAAMC,OAAOA,CAAA,EAAG;IACZ,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACH,mBAAmB,CAACE,OAAO,CAAC,CAAC;IAC1D,MAAME,cAAc,GAAG,IAAI,CAACH,wBAAwB,CAACC,OAAO,CAAC,CAAC;IAE9D,MAAMG,SAAS,GAAG,MAAM,IAAI,CAACN,kBAAkB,CAACG,OAAO,CAAC,CAAC;IAEzD,IAAIC,SAAS,EAAE;MACXG,OAAO,CAACC,GAAG,CAACC,
|
|
1
|
+
{"version":3,"names":["AdminBeforeWatch","IsTelemetryEnabled","GetProjectIdService","GetProjectVersionService","globalConfig","isCI","SetAdminAppEnvVarsBeforeWatchImpl","constructor","isTelemetryEnabled","getProjectIdService","getProjectVersionService","execute","projectId","projectVersion","telemetry","process","env","REACT_APP_WEBINY_PROJECT_ID","REACT_APP_WCP_PROJECT_ID","REACT_APP_WEBINY_TELEMETRY","String","REACT_APP_WEBINY_TELEMETRY_USER_ID","get","newUser","Boolean","toString","REACT_APP_WEBINY_TELEMETRY_NEW_USER","INLINE_RUNTIME_CHUNK","REACT_APP_IS_CI","REACT_APP_WEBINY_VERSION","SetAdminAppEnvVarsBeforeWatch","createImplementation","implementation","dependencies"],"sources":["SetAdminAppEnvVarsBeforeWatch.ts"],"sourcesContent":["import {\n AdminBeforeWatch,\n IsTelemetryEnabled,\n GetProjectIdService,\n GetProjectVersionService\n} from \"~/abstractions/index.js\";\nimport { globalConfig } from \"@webiny/global-config\";\nimport { isCI } from \"ci-info\";\n\nclass SetAdminAppEnvVarsBeforeWatchImpl implements AdminBeforeWatch.Interface {\n constructor(\n private isTelemetryEnabled: IsTelemetryEnabled.Interface,\n private getProjectIdService: GetProjectIdService.Interface,\n private getProjectVersionService: GetProjectVersionService.Interface\n ) {}\n\n async execute() {\n const projectId = await this.getProjectIdService.execute();\n const projectVersion = this.getProjectVersionService.execute();\n\n const telemetry = await this.isTelemetryEnabled.execute();\n\n if (projectId) {\n process.env.REACT_APP_WEBINY_PROJECT_ID = projectId;\n process.env.REACT_APP_WCP_PROJECT_ID = projectId;\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY\" in process.env)) {\n process.env.REACT_APP_WEBINY_TELEMETRY = String(telemetry);\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY_USER_ID\" in process.env)) {\n process.env.REACT_APP_WEBINY_TELEMETRY_USER_ID = globalConfig.get(\"id\");\n }\n\n if (!(\"REACT_APP_WEBINY_TELEMETRY_NEW_USER\" in process.env)) {\n const newUser = Boolean(globalConfig.get(\"newUser\")).toString();\n process.env.REACT_APP_WEBINY_TELEMETRY_NEW_USER = newUser;\n }\n\n if (!(\"INLINE_RUNTIME_CHUNK\" in process.env)) {\n process.env.INLINE_RUNTIME_CHUNK = \"true\";\n }\n\n if (!(\"REACT_APP_IS_CI\" in process.env)) {\n process.env.REACT_APP_IS_CI = Boolean(isCI).toString();\n }\n\n if (!(\"REACT_APP_WEBINY_VERSION\" in process.env)) {\n process.env.REACT_APP_WEBINY_VERSION = projectVersion;\n }\n }\n}\n\nexport const SetAdminAppEnvVarsBeforeWatch = AdminBeforeWatch.createImplementation({\n implementation: SetAdminAppEnvVarsBeforeWatchImpl,\n dependencies: [IsTelemetryEnabled, GetProjectIdService, GetProjectVersionService]\n});\n"],"mappings":"AAAA,SACIA,gBAAgB,EAChBC,kBAAkB,EAClBC,mBAAmB,EACnBC,wBAAwB;AAE5B,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,IAAI,QAAQ,SAAS;AAE9B,MAAMC,iCAAiC,CAAuC;EAC1EC,WAAWA,CACCC,kBAAgD,EAChDC,mBAAkD,EAClDC,wBAA4D,EACtE;IAAA,KAHUF,kBAAgD,GAAhDA,kBAAgD;IAAA,KAChDC,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,wBAA4D,GAA5DA,wBAA4D;EACrE;EAEH,MAAMC,OAAOA,CAAA,EAAG;IACZ,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACH,mBAAmB,CAACE,OAAO,CAAC,CAAC;IAC1D,MAAME,cAAc,GAAG,IAAI,CAACH,wBAAwB,CAACC,OAAO,CAAC,CAAC;IAE9D,MAAMG,SAAS,GAAG,MAAM,IAAI,CAACN,kBAAkB,CAACG,OAAO,CAAC,CAAC;IAEzD,IAAIC,SAAS,EAAE;MACXG,OAAO,CAACC,GAAG,CAACC,2BAA2B,GAAGL,SAAS;MACnDG,OAAO,C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
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const ProjectDecorator: import("../defineExtension/defineExtension.js").ExtensionComponent<z.ZodObject<{
|
|
3
|
-
src: z.
|
|
4
|
-
},
|
|
5
|
-
src: string;
|
|
6
|
-
}, {
|
|
7
|
-
src: string;
|
|
8
|
-
}>>;
|
|
3
|
+
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
4
|
+
}, z.core.$strip>>;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const ProjectId: import("../defineExtension/defineExtension.js").ExtensionComponent<z.ZodObject<{
|
|
3
|
-
id: z.
|
|
4
|
-
},
|
|
5
|
-
id: string;
|
|
6
|
-
}, {
|
|
7
|
-
id: string;
|
|
8
|
-
}>>;
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
}, z.core.$strip>>;
|