@webiny/project 6.0.0-rc.1 → 6.0.0-rc.3
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/exports/extensions.d.ts +1 -0
- package/exports/extensions.js +1 -0
- package/exports/extensions.js.map +1 -1
- package/extensions/AdminBuildParam.d.ts +11 -0
- package/extensions/AdminBuildParam.js +184 -0
- package/extensions/AdminBuildParam.js.map +1 -0
- package/extensions/AdminExtension.d.ts +11 -0
- package/extensions/AdminExtension.js +99 -0
- package/extensions/AdminExtension.js.map +1 -0
- package/extensions/ApiBuildParam.d.ts +11 -0
- package/extensions/ApiBuildParam.js +119 -0
- package/extensions/ApiBuildParam.js.map +1 -0
- package/extensions/ApiExtension.d.ts +11 -0
- package/{defineExtension/defineApiExtension.js → extensions/ApiExtension.js} +13 -15
- package/extensions/ApiExtension.js.map +1 -0
- package/extensions/FeatureFlags.d.ts +92 -0
- package/extensions/FeatureFlags.js +43 -0
- package/extensions/FeatureFlags.js.map +1 -0
- package/extensions/index.d.ts +109 -0
- package/extensions/index.js +12 -2
- package/extensions/index.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/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/package.json +14 -13
- 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/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/defineExtension/defineApiExtension.d.ts +0 -17
- package/defineExtension/defineApiExtension.js.map +0 -1
|
@@ -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.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/buildParams";
|
|
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.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/buildParams\";\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,EA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BAA2B,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":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ApiExtension: import("~/extensions/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
|
+
src: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
4
|
+
exportName: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
src: string;
|
|
7
|
+
exportName?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
src: string;
|
|
10
|
+
exportName?: string | undefined;
|
|
11
|
+
}>>;
|
|
@@ -1,25 +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
|
-
import { ExtensionSrcResolver } from "../utils/index.js";
|
|
6
4
|
import path from "path";
|
|
5
|
+
import { Node, Project } from "ts-morph";
|
|
7
6
|
import crypto from "crypto";
|
|
8
|
-
export const
|
|
9
|
-
type:
|
|
7
|
+
export const ApiExtension = defineExtension({
|
|
8
|
+
type: "Api/Extension",
|
|
10
9
|
tags: {
|
|
11
10
|
runtimeContext: "app-build",
|
|
12
11
|
appName: "api"
|
|
13
12
|
},
|
|
14
|
-
description:
|
|
13
|
+
description: "Add any API extension.",
|
|
15
14
|
multiple: true,
|
|
16
15
|
paramsSchema: ({
|
|
17
16
|
project
|
|
18
17
|
}) => {
|
|
19
18
|
return z.object({
|
|
20
19
|
src: zodSrcPath({
|
|
21
|
-
project
|
|
22
|
-
abstraction: params.abstraction
|
|
20
|
+
project
|
|
23
21
|
}),
|
|
24
22
|
exportName: z.string().optional()
|
|
25
23
|
});
|
|
@@ -30,19 +28,19 @@ export const defineApiExtension = params => defineExtension({
|
|
|
30
28
|
src: extensionFilePath
|
|
31
29
|
} = params;
|
|
32
30
|
|
|
33
|
-
// Resolve to absolute path for file operations
|
|
31
|
+
// Resolve to absolute path for file operations.
|
|
34
32
|
const absoluteExtensionFilePath = ExtensionSrcResolver.resolvePath(extensionFilePath, ctx.project);
|
|
35
33
|
const extensionFileName = path.basename(absoluteExtensionFilePath);
|
|
36
34
|
|
|
37
|
-
//
|
|
35
|
+
// Export name is always the file name without extension.
|
|
38
36
|
const exportName = params.exportName ?? path.parse(extensionFileName).name;
|
|
39
37
|
|
|
40
|
-
//
|
|
41
|
-
//
|
|
38
|
+
// Alias name is "ApiExtension_" + hash of the file path. This way we
|
|
39
|
+
// avoid potential naming conflicts and keep the identifier constant.
|
|
42
40
|
const hash = crypto.createHash("sha256").update(extensionFilePath).digest("hex");
|
|
43
41
|
const exportNameAlias = `ApiExtension_${hash.slice(-10)}`;
|
|
44
42
|
|
|
45
|
-
//
|
|
43
|
+
// Calculate import path relative to `extensions.ts` file.
|
|
46
44
|
const importPath = path.relative(path.dirname(extensionsTsFilePath), absoluteExtensionFilePath).replace(/\.tsx?$/, ".js");
|
|
47
45
|
const project = new Project();
|
|
48
46
|
project.addSourceFileAtPath(extensionsTsFilePath);
|
|
@@ -101,4 +99,4 @@ export const defineApiExtension = params => defineExtension({
|
|
|
101
99
|
}
|
|
102
100
|
});
|
|
103
101
|
|
|
104
|
-
//# 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,CAACH,yBAAyB,CAAC;;IAElE;IACA,MA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I,CAAC,CAAC;EACvB;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
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<[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
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
teams?: boolean | undefined;
|
|
13
|
+
privateFiles?: boolean | undefined;
|
|
14
|
+
folderLevelPermissions?: boolean | undefined;
|
|
15
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
teams?: boolean | undefined;
|
|
18
|
+
privateFiles?: boolean | undefined;
|
|
19
|
+
folderLevelPermissions?: boolean | undefined;
|
|
20
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
21
|
+
}>]>>;
|
|
22
|
+
auditLogs: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
recordLocking: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
fileManager: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
threatDetection: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
threatDetection?: boolean | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
threatDetection?: boolean | undefined;
|
|
30
|
+
}>>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
multiTenancy?: boolean | undefined;
|
|
33
|
+
advancedPublishingWorkflow?: boolean | undefined;
|
|
34
|
+
advancedAccessControlLayer?: boolean | {
|
|
35
|
+
teams?: boolean | undefined;
|
|
36
|
+
privateFiles?: boolean | undefined;
|
|
37
|
+
folderLevelPermissions?: boolean | undefined;
|
|
38
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
auditLogs?: boolean | undefined;
|
|
41
|
+
recordLocking?: boolean | undefined;
|
|
42
|
+
fileManager?: {
|
|
43
|
+
threatDetection?: boolean | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
multiTenancy?: boolean | undefined;
|
|
47
|
+
advancedPublishingWorkflow?: boolean | undefined;
|
|
48
|
+
advancedAccessControlLayer?: boolean | {
|
|
49
|
+
teams?: boolean | undefined;
|
|
50
|
+
privateFiles?: boolean | undefined;
|
|
51
|
+
folderLevelPermissions?: boolean | undefined;
|
|
52
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
auditLogs?: boolean | undefined;
|
|
55
|
+
recordLocking?: boolean | undefined;
|
|
56
|
+
fileManager?: {
|
|
57
|
+
threatDetection?: boolean | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
features: {
|
|
62
|
+
multiTenancy?: boolean | undefined;
|
|
63
|
+
advancedPublishingWorkflow?: boolean | undefined;
|
|
64
|
+
advancedAccessControlLayer?: boolean | {
|
|
65
|
+
teams?: boolean | undefined;
|
|
66
|
+
privateFiles?: boolean | undefined;
|
|
67
|
+
folderLevelPermissions?: boolean | undefined;
|
|
68
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
auditLogs?: boolean | undefined;
|
|
71
|
+
recordLocking?: boolean | undefined;
|
|
72
|
+
fileManager?: {
|
|
73
|
+
threatDetection?: boolean | undefined;
|
|
74
|
+
} | undefined;
|
|
75
|
+
};
|
|
76
|
+
}, {
|
|
77
|
+
features: {
|
|
78
|
+
multiTenancy?: boolean | undefined;
|
|
79
|
+
advancedPublishingWorkflow?: boolean | undefined;
|
|
80
|
+
advancedAccessControlLayer?: boolean | {
|
|
81
|
+
teams?: boolean | undefined;
|
|
82
|
+
privateFiles?: boolean | undefined;
|
|
83
|
+
folderLevelPermissions?: boolean | undefined;
|
|
84
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
auditLogs?: boolean | undefined;
|
|
87
|
+
recordLocking?: boolean | undefined;
|
|
88
|
+
fileManager?: {
|
|
89
|
+
threatDetection?: boolean | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
};
|
|
92
|
+
}>>;
|
|
@@ -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":[]}
|
package/extensions/index.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ import { ProjectId } from "./ProjectId.js";
|
|
|
5
5
|
import { Telemetry } from "./Telemetry.js";
|
|
6
6
|
import { EnvVar } from "./EnvVar.js";
|
|
7
7
|
import { DatabaseSetup } from "./DatabaseSetup.js";
|
|
8
|
+
import { FeatureFlags } from "./FeatureFlags.js";
|
|
9
|
+
import { BuildParam } from "./ApiBuildParam.js";
|
|
10
|
+
import { AdminBuildParam } from "./AdminBuildParam.js";
|
|
11
|
+
import { AdminExtension } from "./AdminExtension.js";
|
|
12
|
+
import { ApiExtension } from "./ApiExtension.js";
|
|
8
13
|
import { AdminAfterBuild, AdminAfterDeploy, AdminBeforeBuild, AdminBeforeDeploy, AdminBeforeWatch, AfterBuild, AfterDeploy, BeforeDeploy, BeforeWatch, ApiAfterBuild, ApiAfterDeploy, ApiBeforeBuild, ApiBeforeDeploy, ApiBeforeWatch, BeforeBuild, CoreAfterBuild, CoreAfterDeploy, CoreBeforeBuild, CoreBeforeDeploy, CoreBeforeWatch } from "./hooks/index.js";
|
|
9
14
|
import { AdminPulumi, ApiPulumi, CorePulumi, ProductionEnvironments, PulumiResourceNamePrefix, CoreStackOutputValue, ApiStackOutputValue, AdminStackOutputValue } from "./pulumi/index.js";
|
|
10
15
|
export { Telemetry };
|
|
@@ -13,7 +18,12 @@ export { ProjectDecorator };
|
|
|
13
18
|
export { ProjectImplementation };
|
|
14
19
|
export { ExtensionDefinitions };
|
|
15
20
|
export { EnvVar };
|
|
21
|
+
export { FeatureFlags };
|
|
16
22
|
export { DatabaseSetup };
|
|
23
|
+
export { BuildParam };
|
|
24
|
+
export { AdminBuildParam };
|
|
25
|
+
export { AdminExtension };
|
|
26
|
+
export { ApiExtension };
|
|
17
27
|
export { BeforeBuild };
|
|
18
28
|
export { BeforeDeploy };
|
|
19
29
|
export { BeforeWatch };
|
|
@@ -75,6 +85,96 @@ export declare const definitions: (import("../defineExtension/index.js").Extensi
|
|
|
75
85
|
}, {
|
|
76
86
|
value: string;
|
|
77
87
|
varName: string;
|
|
88
|
+
}>> | import("../defineExtension/index.js").ExtensionDefinitionModel<import("zod").ZodObject<{
|
|
89
|
+
features: import("zod").ZodObject<{
|
|
90
|
+
multiTenancy: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
91
|
+
advancedPublishingWorkflow: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
92
|
+
advancedAccessControlLayer: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodBoolean, import("zod").ZodObject<{
|
|
93
|
+
teams: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
94
|
+
privateFiles: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
95
|
+
folderLevelPermissions: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
96
|
+
hcmsFieldPermissions: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
97
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
98
|
+
teams?: boolean | undefined;
|
|
99
|
+
privateFiles?: boolean | undefined;
|
|
100
|
+
folderLevelPermissions?: boolean | undefined;
|
|
101
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
102
|
+
}, {
|
|
103
|
+
teams?: boolean | undefined;
|
|
104
|
+
privateFiles?: boolean | undefined;
|
|
105
|
+
folderLevelPermissions?: boolean | undefined;
|
|
106
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
107
|
+
}>]>>;
|
|
108
|
+
auditLogs: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
109
|
+
recordLocking: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
110
|
+
fileManager: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
111
|
+
threatDetection: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
112
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
113
|
+
threatDetection?: boolean | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
threatDetection?: boolean | undefined;
|
|
116
|
+
}>>;
|
|
117
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
118
|
+
multiTenancy?: boolean | undefined;
|
|
119
|
+
advancedPublishingWorkflow?: boolean | undefined;
|
|
120
|
+
advancedAccessControlLayer?: boolean | {
|
|
121
|
+
teams?: boolean | undefined;
|
|
122
|
+
privateFiles?: boolean | undefined;
|
|
123
|
+
folderLevelPermissions?: boolean | undefined;
|
|
124
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
auditLogs?: boolean | undefined;
|
|
127
|
+
recordLocking?: boolean | undefined;
|
|
128
|
+
fileManager?: {
|
|
129
|
+
threatDetection?: boolean | undefined;
|
|
130
|
+
} | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
multiTenancy?: boolean | undefined;
|
|
133
|
+
advancedPublishingWorkflow?: boolean | undefined;
|
|
134
|
+
advancedAccessControlLayer?: boolean | {
|
|
135
|
+
teams?: boolean | undefined;
|
|
136
|
+
privateFiles?: boolean | undefined;
|
|
137
|
+
folderLevelPermissions?: boolean | undefined;
|
|
138
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
139
|
+
} | undefined;
|
|
140
|
+
auditLogs?: boolean | undefined;
|
|
141
|
+
recordLocking?: boolean | undefined;
|
|
142
|
+
fileManager?: {
|
|
143
|
+
threatDetection?: boolean | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
}>;
|
|
146
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
147
|
+
features: {
|
|
148
|
+
multiTenancy?: boolean | undefined;
|
|
149
|
+
advancedPublishingWorkflow?: boolean | undefined;
|
|
150
|
+
advancedAccessControlLayer?: boolean | {
|
|
151
|
+
teams?: boolean | undefined;
|
|
152
|
+
privateFiles?: boolean | undefined;
|
|
153
|
+
folderLevelPermissions?: boolean | undefined;
|
|
154
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
155
|
+
} | undefined;
|
|
156
|
+
auditLogs?: boolean | undefined;
|
|
157
|
+
recordLocking?: boolean | undefined;
|
|
158
|
+
fileManager?: {
|
|
159
|
+
threatDetection?: boolean | undefined;
|
|
160
|
+
} | undefined;
|
|
161
|
+
};
|
|
162
|
+
}, {
|
|
163
|
+
features: {
|
|
164
|
+
multiTenancy?: boolean | undefined;
|
|
165
|
+
advancedPublishingWorkflow?: boolean | undefined;
|
|
166
|
+
advancedAccessControlLayer?: boolean | {
|
|
167
|
+
teams?: boolean | undefined;
|
|
168
|
+
privateFiles?: boolean | undefined;
|
|
169
|
+
folderLevelPermissions?: boolean | undefined;
|
|
170
|
+
hcmsFieldPermissions?: boolean | undefined;
|
|
171
|
+
} | undefined;
|
|
172
|
+
auditLogs?: boolean | undefined;
|
|
173
|
+
recordLocking?: boolean | undefined;
|
|
174
|
+
fileManager?: {
|
|
175
|
+
threatDetection?: boolean | undefined;
|
|
176
|
+
} | undefined;
|
|
177
|
+
};
|
|
78
178
|
}>> | import("../defineExtension/index.js").ExtensionDefinitionModel<import("zod").ZodObject<{
|
|
79
179
|
prefix: import("zod").ZodString;
|
|
80
180
|
}, "strip", import("zod").ZodTypeAny, {
|
|
@@ -102,6 +202,15 @@ export declare const definitions: (import("../defineExtension/index.js").Extensi
|
|
|
102
202
|
setupName: "ddb" | "ddb+es" | "ddb+os";
|
|
103
203
|
}, {
|
|
104
204
|
setupName: "ddb" | "ddb+es" | "ddb+os";
|
|
205
|
+
}>> | import("../defineExtension/index.js").ExtensionDefinitionModel<import("zod").ZodObject<{
|
|
206
|
+
paramName: import("zod").ZodString;
|
|
207
|
+
value: import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>, import("zod").ZodArray<import("zod").ZodAny, "many">, import("zod").ZodNumber, import("zod").ZodBoolean]>;
|
|
208
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
209
|
+
value: string | number | boolean | any[] | Record<string, any>;
|
|
210
|
+
paramName: string;
|
|
211
|
+
}, {
|
|
212
|
+
value: string | number | boolean | any[] | Record<string, any>;
|
|
213
|
+
paramName: string;
|
|
105
214
|
}>>)[];
|
|
106
215
|
export { Project } from "./Project.js";
|
|
107
216
|
export * from "../defineExtension/index.js";
|
package/extensions/index.js
CHANGED
|
@@ -5,6 +5,11 @@ import { ProjectId } from "./ProjectId.js";
|
|
|
5
5
|
import { Telemetry } from "./Telemetry.js";
|
|
6
6
|
import { EnvVar } from "./EnvVar.js";
|
|
7
7
|
import { DatabaseSetup } from "./DatabaseSetup.js";
|
|
8
|
+
import { FeatureFlags } from "./FeatureFlags.js";
|
|
9
|
+
import { BuildParam } from "./ApiBuildParam.js";
|
|
10
|
+
import { AdminBuildParam } from "./AdminBuildParam.js";
|
|
11
|
+
import { AdminExtension } from "./AdminExtension.js";
|
|
12
|
+
import { ApiExtension } from "./ApiExtension.js";
|
|
8
13
|
|
|
9
14
|
// Hooks.
|
|
10
15
|
import { AdminAfterBuild, AdminAfterDeploy, AdminBeforeBuild, AdminBeforeDeploy, AdminBeforeWatch, AfterBuild, AfterDeploy, BeforeDeploy, BeforeWatch, ApiAfterBuild, ApiAfterDeploy, ApiBeforeBuild, ApiBeforeDeploy, ApiBeforeWatch, BeforeBuild, CoreAfterBuild, CoreAfterDeploy, CoreBeforeBuild, CoreBeforeDeploy, CoreBeforeWatch } from "./hooks/index.js";
|
|
@@ -19,7 +24,12 @@ export { ProjectDecorator };
|
|
|
19
24
|
export { ProjectImplementation };
|
|
20
25
|
export { ExtensionDefinitions };
|
|
21
26
|
export { EnvVar };
|
|
27
|
+
export { FeatureFlags };
|
|
22
28
|
export { DatabaseSetup };
|
|
29
|
+
export { BuildParam };
|
|
30
|
+
export { AdminBuildParam };
|
|
31
|
+
export { AdminExtension };
|
|
32
|
+
export { ApiExtension };
|
|
23
33
|
|
|
24
34
|
// Hooks.
|
|
25
35
|
export { BeforeBuild };
|
|
@@ -54,11 +64,11 @@ export { ApiStackOutputValue };
|
|
|
54
64
|
export { AdminStackOutputValue };
|
|
55
65
|
|
|
56
66
|
// Definitions (used internally). 👇
|
|
57
|
-
export const definitions = [Telemetry.def, ProjectId.def, ProjectDecorator.def, ProjectImplementation.def, ExtensionDefinitions.def, EnvVar.def,
|
|
67
|
+
export const definitions = [Telemetry.def, ProjectId.def, ProjectDecorator.def, ProjectImplementation.def, ExtensionDefinitions.def, EnvVar.def, FeatureFlags.def,
|
|
58
68
|
// Hooks.
|
|
59
69
|
AdminAfterBuild.def, AdminAfterDeploy.def, BeforeBuild.def, BeforeDeploy.def, BeforeWatch.def, AfterBuild.def, AfterDeploy.def, AdminBeforeBuild.def, AdminBeforeDeploy.def, AdminBeforeWatch.def, ApiAfterBuild.def, ApiAfterDeploy.def, ApiBeforeBuild.def, ApiBeforeDeploy.def, ApiBeforeWatch.def, CoreAfterBuild.def, CoreAfterDeploy.def, CoreBeforeBuild.def, CoreBeforeDeploy.def, CoreBeforeWatch.def,
|
|
60
70
|
// Pulumi.
|
|
61
|
-
CorePulumi.def, PulumiResourceNamePrefix.def, ProductionEnvironments.def, CoreStackOutputValue.def, ApiStackOutputValue.def, AdminStackOutputValue.def, DatabaseSetup.def];
|
|
71
|
+
AdminPulumi.def, ApiPulumi.def, CorePulumi.def, PulumiResourceNamePrefix.def, ProductionEnvironments.def, CoreStackOutputValue.def, ApiStackOutputValue.def, AdminStackOutputValue.def, DatabaseSetup.def, BuildParam.def, AdminBuildParam.def, AdminExtension.def, ApiExtension.def];
|
|
62
72
|
export { Project } from "./Project.js";
|
|
63
73
|
export * from "../defineExtension/index.js";
|
|
64
74
|
|
package/extensions/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ExtensionDefinitions","ProjectDecorator","ProjectImplementation","ProjectId","Telemetry","EnvVar","DatabaseSetup","AdminAfterBuild","AdminAfterDeploy","AdminBeforeBuild","AdminBeforeDeploy","AdminBeforeWatch","AfterBuild","AfterDeploy","BeforeDeploy","BeforeWatch","ApiAfterBuild","ApiAfterDeploy","ApiBeforeBuild","ApiBeforeDeploy","ApiBeforeWatch","BeforeBuild","CoreAfterBuild","CoreAfterDeploy","CoreBeforeBuild","CoreBeforeDeploy","CoreBeforeWatch","AdminPulumi","ApiPulumi","CorePulumi","ProductionEnvironments","PulumiResourceNamePrefix","CoreStackOutputValue","ApiStackOutputValue","AdminStackOutputValue","definitions","def","Project"],"sources":["index.ts"],"sourcesContent":["import { ExtensionDefinitions } from \"./ExtensionDefinitions.js\";\nimport { ProjectDecorator } from \"./ProjectDecorator.js\";\nimport { ProjectImplementation } from \"./ProjectImplementation.js\";\nimport { ProjectId } from \"./ProjectId.js\";\nimport { Telemetry } from \"./Telemetry.js\";\nimport { EnvVar } from \"./EnvVar.js\";\nimport { DatabaseSetup } from \"./DatabaseSetup.js\";\n\n// Hooks.\nimport {\n AdminAfterBuild,\n AdminAfterDeploy,\n AdminBeforeBuild,\n AdminBeforeDeploy,\n AdminBeforeWatch,\n AfterBuild,\n AfterDeploy,\n BeforeDeploy,\n BeforeWatch,\n ApiAfterBuild,\n ApiAfterDeploy,\n ApiBeforeBuild,\n ApiBeforeDeploy,\n ApiBeforeWatch,\n BeforeBuild,\n CoreAfterBuild,\n CoreAfterDeploy,\n CoreBeforeBuild,\n CoreBeforeDeploy,\n CoreBeforeWatch\n} from \"./hooks/index.js\";\n\n// Pulumi.\nimport {\n AdminPulumi,\n ApiPulumi,\n CorePulumi,\n ProductionEnvironments,\n PulumiResourceNamePrefix,\n CoreStackOutputValue,\n ApiStackOutputValue,\n AdminStackOutputValue\n} from \"./pulumi/index.js\";\n\n// Exports.\nexport { Telemetry };\nexport { ProjectId };\nexport { ProjectDecorator };\nexport { ProjectImplementation };\nexport { ExtensionDefinitions };\nexport { EnvVar };\nexport { DatabaseSetup };\n\n// Hooks.\nexport { BeforeBuild };\nexport { BeforeDeploy };\nexport { BeforeWatch };\nexport { AfterBuild };\nexport { AfterDeploy };\nexport { AdminBeforeBuild };\nexport { AdminBeforeDeploy };\nexport { AdminBeforeWatch };\nexport { AdminAfterBuild };\nexport { AdminAfterDeploy };\nexport { ApiBeforeBuild };\nexport { ApiBeforeDeploy };\nexport { ApiBeforeWatch };\nexport { ApiAfterBuild };\nexport { ApiAfterDeploy };\nexport { CoreBeforeBuild };\nexport { CoreBeforeDeploy };\nexport { CoreBeforeWatch };\nexport { CoreAfterBuild };\nexport { CoreAfterDeploy };\n\n// Pulumi.\nexport { CorePulumi };\nexport { AdminPulumi };\nexport { ApiPulumi };\nexport { PulumiResourceNamePrefix };\nexport { ProductionEnvironments };\nexport { CoreStackOutputValue };\nexport { ApiStackOutputValue };\nexport { AdminStackOutputValue };\n\n// Definitions (used internally). 👇\nexport const definitions = [\n Telemetry.def,\n ProjectId.def,\n ProjectDecorator.def,\n ProjectImplementation.def,\n ExtensionDefinitions.def,\n EnvVar.def,\n\n // Hooks.\n AdminAfterBuild.def,\n AdminAfterDeploy.def,\n BeforeBuild.def,\n BeforeDeploy.def,\n BeforeWatch.def,\n AfterBuild.def,\n AfterDeploy.def,\n AdminBeforeBuild.def,\n AdminBeforeDeploy.def,\n AdminBeforeWatch.def,\n ApiAfterBuild.def,\n ApiAfterDeploy.def,\n ApiBeforeBuild.def,\n ApiBeforeDeploy.def,\n ApiBeforeWatch.def,\n CoreAfterBuild.def,\n CoreAfterDeploy.def,\n CoreBeforeBuild.def,\n CoreBeforeDeploy.def,\n CoreBeforeWatch.def,\n\n // Pulumi.\n CorePulumi.def,\n PulumiResourceNamePrefix.def,\n ProductionEnvironments.def,\n CoreStackOutputValue.def,\n ApiStackOutputValue.def,\n AdminStackOutputValue.def,\n DatabaseSetup.def\n];\n\nexport { Project } from \"./Project.js\";\n\nexport * from \"../defineExtension/index.js\";\n"],"mappings":"AAAA,SAASA,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,qBAAqB;AAC9B,SAASC,SAAS;AAClB,SAASC,SAAS;AAClB,SAASC,MAAM;AACf,SAASC,aAAa;;
|
|
1
|
+
{"version":3,"names":["ExtensionDefinitions","ProjectDecorator","ProjectImplementation","ProjectId","Telemetry","EnvVar","DatabaseSetup","FeatureFlags","BuildParam","AdminBuildParam","AdminExtension","ApiExtension","AdminAfterBuild","AdminAfterDeploy","AdminBeforeBuild","AdminBeforeDeploy","AdminBeforeWatch","AfterBuild","AfterDeploy","BeforeDeploy","BeforeWatch","ApiAfterBuild","ApiAfterDeploy","ApiBeforeBuild","ApiBeforeDeploy","ApiBeforeWatch","BeforeBuild","CoreAfterBuild","CoreAfterDeploy","CoreBeforeBuild","CoreBeforeDeploy","CoreBeforeWatch","AdminPulumi","ApiPulumi","CorePulumi","ProductionEnvironments","PulumiResourceNamePrefix","CoreStackOutputValue","ApiStackOutputValue","AdminStackOutputValue","definitions","def","Project"],"sources":["index.ts"],"sourcesContent":["import { ExtensionDefinitions } from \"./ExtensionDefinitions.js\";\nimport { ProjectDecorator } from \"./ProjectDecorator.js\";\nimport { ProjectImplementation } from \"./ProjectImplementation.js\";\nimport { ProjectId } from \"./ProjectId.js\";\nimport { Telemetry } from \"./Telemetry.js\";\nimport { EnvVar } from \"./EnvVar.js\";\nimport { DatabaseSetup } from \"./DatabaseSetup.js\";\nimport { FeatureFlags } from \"./FeatureFlags.js\";\nimport { BuildParam } from \"./ApiBuildParam.js\";\nimport { AdminBuildParam } from \"./AdminBuildParam.js\";\nimport { AdminExtension } from \"./AdminExtension.js\";\nimport { ApiExtension } from \"./ApiExtension.js\";\n\n// Hooks.\nimport {\n AdminAfterBuild,\n AdminAfterDeploy,\n AdminBeforeBuild,\n AdminBeforeDeploy,\n AdminBeforeWatch,\n AfterBuild,\n AfterDeploy,\n BeforeDeploy,\n BeforeWatch,\n ApiAfterBuild,\n ApiAfterDeploy,\n ApiBeforeBuild,\n ApiBeforeDeploy,\n ApiBeforeWatch,\n BeforeBuild,\n CoreAfterBuild,\n CoreAfterDeploy,\n CoreBeforeBuild,\n CoreBeforeDeploy,\n CoreBeforeWatch\n} from \"./hooks/index.js\";\n\n// Pulumi.\nimport {\n AdminPulumi,\n ApiPulumi,\n CorePulumi,\n ProductionEnvironments,\n PulumiResourceNamePrefix,\n CoreStackOutputValue,\n ApiStackOutputValue,\n AdminStackOutputValue\n} from \"./pulumi/index.js\";\n\n// Exports.\nexport { Telemetry };\nexport { ProjectId };\nexport { ProjectDecorator };\nexport { ProjectImplementation };\nexport { ExtensionDefinitions };\nexport { EnvVar };\nexport { FeatureFlags };\nexport { DatabaseSetup };\nexport { BuildParam };\nexport { AdminBuildParam };\nexport { AdminExtension };\nexport { ApiExtension };\n\n// Hooks.\nexport { BeforeBuild };\nexport { BeforeDeploy };\nexport { BeforeWatch };\nexport { AfterBuild };\nexport { AfterDeploy };\nexport { AdminBeforeBuild };\nexport { AdminBeforeDeploy };\nexport { AdminBeforeWatch };\nexport { AdminAfterBuild };\nexport { AdminAfterDeploy };\nexport { ApiBeforeBuild };\nexport { ApiBeforeDeploy };\nexport { ApiBeforeWatch };\nexport { ApiAfterBuild };\nexport { ApiAfterDeploy };\nexport { CoreBeforeBuild };\nexport { CoreBeforeDeploy };\nexport { CoreBeforeWatch };\nexport { CoreAfterBuild };\nexport { CoreAfterDeploy };\n\n// Pulumi.\nexport { CorePulumi };\nexport { AdminPulumi };\nexport { ApiPulumi };\nexport { PulumiResourceNamePrefix };\nexport { ProductionEnvironments };\nexport { CoreStackOutputValue };\nexport { ApiStackOutputValue };\nexport { AdminStackOutputValue };\n\n// Definitions (used internally). 👇\nexport const definitions = [\n Telemetry.def,\n ProjectId.def,\n ProjectDecorator.def,\n ProjectImplementation.def,\n ExtensionDefinitions.def,\n EnvVar.def,\n FeatureFlags.def,\n\n // Hooks.\n AdminAfterBuild.def,\n AdminAfterDeploy.def,\n BeforeBuild.def,\n BeforeDeploy.def,\n BeforeWatch.def,\n AfterBuild.def,\n AfterDeploy.def,\n AdminBeforeBuild.def,\n AdminBeforeDeploy.def,\n AdminBeforeWatch.def,\n ApiAfterBuild.def,\n ApiAfterDeploy.def,\n ApiBeforeBuild.def,\n ApiBeforeDeploy.def,\n ApiBeforeWatch.def,\n CoreAfterBuild.def,\n CoreAfterDeploy.def,\n CoreBeforeBuild.def,\n CoreBeforeDeploy.def,\n CoreBeforeWatch.def,\n\n // Pulumi.\n AdminPulumi.def,\n ApiPulumi.def,\n CorePulumi.def,\n PulumiResourceNamePrefix.def,\n ProductionEnvironments.def,\n CoreStackOutputValue.def,\n ApiStackOutputValue.def,\n AdminStackOutputValue.def,\n DatabaseSetup.def,\n BuildParam.def,\n AdminBuildParam.def,\n AdminExtension.def,\n ApiExtension.def\n];\n\nexport { Project } from \"./Project.js\";\n\nexport * from \"../defineExtension/index.js\";\n"],"mappings":"AAAA,SAASA,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,qBAAqB;AAC9B,SAASC,SAAS;AAClB,SAASC,SAAS;AAClB,SAASC,MAAM;AACf,SAASC,aAAa;AACtB,SAASC,YAAY;AACrB,SAASC,UAAU;AACnB,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,SAASC,YAAY;;AAErB;AACA,SACIC,eAAe,EACfC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,gBAAgB,EAChBC,UAAU,EACVC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,gBAAgB,EAChBC,eAAe;;AAGnB;AACA,SACIC,WAAW,EACXC,SAAS,EACTC,UAAU,EACVC,sBAAsB,EACtBC,wBAAwB,EACxBC,oBAAoB,EACpBC,mBAAmB,EACnBC,qBAAqB;;AAGzB;AACA,SAASnC,SAAS;AAClB,SAASD,SAAS;AAClB,SAASF,gBAAgB;AACzB,SAASC,qBAAqB;AAC9B,SAASF,oBAAoB;AAC7B,SAASK,MAAM;AACf,SAASE,YAAY;AACrB,SAASD,aAAa;AACtB,SAASE,UAAU;AACnB,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,SAASC,YAAY;;AAErB;AACA,SAASe,WAAW;AACpB,SAASP,YAAY;AACrB,SAASC,WAAW;AACpB,SAASH,UAAU;AACnB,SAASC,WAAW;AACpB,SAASJ,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AACzB,SAASJ,eAAe;AACxB,SAASC,gBAAgB;AACzB,SAASU,cAAc;AACvB,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,SAASJ,aAAa;AACtB,SAASC,cAAc;AACvB,SAASO,eAAe;AACxB,SAASC,gBAAgB;AACzB,SAASC,eAAe;AACxB,SAASJ,cAAc;AACvB,SAASC,eAAe;;AAExB;AACA,SAASM,UAAU;AACnB,SAASF,WAAW;AACp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AAC+B,GAAG,EAClB9B,YAAY,CAAC8B,GAAG,CACnB;AAED,SAASC,OAAO;AAEhB","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FeatureFlags } from "@webiny/feature-flags";
|
|
2
|
+
import { GetFeatureFlags } from "../../abstractions/index.js";
|
|
3
|
+
import { GetProjectConfig } from "../../abstractions/index.js";
|
|
4
|
+
declare class DefaultGetFeatureFlags implements GetFeatureFlags.Interface {
|
|
5
|
+
private getProjectConfig;
|
|
6
|
+
constructor(getProjectConfig: GetProjectConfig.Interface);
|
|
7
|
+
execute(): Promise<FeatureFlags>;
|
|
8
|
+
}
|
|
9
|
+
export declare const getFeatureFlags: import("@webiny/di").Implementation<typeof DefaultGetFeatureFlags>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/di";
|
|
2
|
+
import { FeatureFlags } from "@webiny/feature-flags";
|
|
3
|
+
import { GetFeatureFlags } from "../../abstractions/index.js";
|
|
4
|
+
import { GetProjectConfig } from "../../abstractions/index.js";
|
|
5
|
+
import { FeatureFlags as FeatureFlagsExtension } from "../../extensions/FeatureFlags.js";
|
|
6
|
+
class DefaultGetFeatureFlags {
|
|
7
|
+
constructor(getProjectConfig) {
|
|
8
|
+
this.getProjectConfig = getProjectConfig;
|
|
9
|
+
}
|
|
10
|
+
async execute() {
|
|
11
|
+
const projectConfig = await this.getProjectConfig.execute({
|
|
12
|
+
tags: {
|
|
13
|
+
runtimeContext: "project"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const extensions = projectConfig.extensionsByType(FeatureFlagsExtension);
|
|
17
|
+
if (extensions.length === 0) {
|
|
18
|
+
return new FeatureFlags({});
|
|
19
|
+
}
|
|
20
|
+
return FeatureFlags.fromDto(extensions[0].params.features);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export const getFeatureFlags = createImplementation({
|
|
24
|
+
abstraction: GetFeatureFlags,
|
|
25
|
+
implementation: DefaultGetFeatureFlags,
|
|
26
|
+
dependencies: [GetProjectConfig]
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=GetFeatureFlags.js.map
|