@webiny/project 6.6.0-alpha.1 → 6.6.0-alpha.10
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/abstractions/features/GetAppStackOutput.d.ts +3 -2
- package/abstractions/features/GetAppStackOutput.js.map +1 -1
- package/components/FeatureFlag.d.ts +9 -4
- package/components/FeatureFlag.js +6 -7
- package/components/FeatureFlag.js.map +1 -1
- package/createProjectSdkContainer.js +22 -9
- package/createProjectSdkContainer.js.map +1 -1
- package/decorators/GetFeatureFlagsWithLicense.js +1 -0
- package/decorators/GetFeatureFlagsWithLicense.js.map +1 -1
- package/defineExtension/createExtensionReactComponent.js +9 -1
- package/defineExtension/createExtensionReactComponent.js.map +1 -1
- package/defineExtension/types.d.ts +6 -1
- package/extensions/AdminApiUrl.js +2 -1
- package/extensions/AdminApiUrl.js.map +1 -1
- package/extensions/AdminBuildParam.js +5 -5
- package/extensions/AdminBuildParam.js.map +1 -1
- package/extensions/AdminExtension.d.ts +1 -1
- package/extensions/AdminExtension.js +6 -5
- package/extensions/AdminExtension.js.map +1 -1
- package/extensions/AdminWebsocketsUrl.d.ts +1 -1
- package/extensions/AdminWebsocketsUrl.js +2 -1
- package/extensions/AdminWebsocketsUrl.js.map +1 -1
- package/extensions/ApiBuildParam.js +11 -10
- package/extensions/ApiBuildParam.js.map +1 -1
- package/extensions/ApiExtension.d.ts +1 -1
- package/extensions/ApiExtension.js +8 -5
- package/extensions/ApiExtension.js.map +1 -1
- package/extensions/BugReporter.d.ts +6 -0
- package/extensions/BugReporter.js +34 -0
- package/extensions/BugReporter.js.map +1 -0
- package/extensions/DatabaseSetup.js +2 -1
- package/extensions/DatabaseSetup.js.map +1 -1
- package/extensions/EnvVar.js +2 -1
- package/extensions/EnvVar.js.map +1 -1
- package/extensions/ExtensionDefinitions.js +2 -1
- package/extensions/ExtensionDefinitions.js.map +1 -1
- package/extensions/FeatureFlags.d.ts +7 -1
- package/extensions/FeatureFlags.js +12 -2
- package/extensions/FeatureFlags.js.map +1 -1
- package/extensions/Project/WcpInjectTelemetryClientAfterBuild.js.map +1 -1
- package/extensions/Project/showConfigChangeNotice.d.ts +1 -1
- package/extensions/Project/showConfigChangeNotice.js.map +1 -1
- package/extensions/ProjectDecorator.js +2 -1
- package/extensions/ProjectDecorator.js.map +1 -1
- package/extensions/ProjectId.js +2 -1
- package/extensions/ProjectId.js.map +1 -1
- package/extensions/ProjectImplementation.js +2 -1
- package/extensions/ProjectImplementation.js.map +1 -1
- package/extensions/Telemetry.js +2 -1
- package/extensions/Telemetry.js.map +1 -1
- package/extensions/api/BackgroundTasks.d.ts +4 -0
- package/extensions/api/BackgroundTasks.js +25 -0
- package/extensions/api/BackgroundTasks.js.map +1 -0
- package/extensions/api/Cms/ModelFieldCompression.d.ts +4 -0
- package/extensions/api/Cms/ModelFieldCompression.js +25 -0
- package/extensions/api/Cms/ModelFieldCompression.js.map +1 -0
- package/extensions/api/Mailer/Smtp.d.ts +8 -0
- package/extensions/api/Mailer/Smtp.js +22 -0
- package/extensions/api/Mailer/Smtp.js.map +1 -0
- package/extensions/api/Mailer/Smtp.test.d.ts +1 -0
- package/extensions/api/Mailer/Smtp.test.js +127 -0
- package/extensions/api/Mailer/Smtp.test.js.map +1 -0
- package/extensions/api/Mailer/SmtpParamsSchema.d.ts +9 -0
- package/extensions/api/Mailer/SmtpParamsSchema.js +17 -0
- package/extensions/api/Mailer/SmtpParamsSchema.js.map +1 -0
- package/extensions/api/index.d.ts +4 -0
- package/extensions/api/index.js +4 -0
- package/extensions/hasDefaultExport.d.ts +2 -0
- package/extensions/hasDefaultExport.js +17 -0
- package/extensions/hasDefaultExport.js.map +1 -0
- package/extensions/hooks/AdminAfterBuild.js +2 -1
- package/extensions/hooks/AdminAfterBuild.js.map +1 -1
- package/extensions/hooks/AdminAfterDeploy.js +2 -1
- package/extensions/hooks/AdminAfterDeploy.js.map +1 -1
- package/extensions/hooks/AdminBeforeBuild.js +2 -1
- package/extensions/hooks/AdminBeforeBuild.js.map +1 -1
- package/extensions/hooks/AdminBeforeDeploy.js +2 -1
- package/extensions/hooks/AdminBeforeDeploy.js.map +1 -1
- package/extensions/hooks/AdminBeforeWatch.js +2 -1
- package/extensions/hooks/AdminBeforeWatch.js.map +1 -1
- package/extensions/hooks/AfterBuild.js +2 -1
- package/extensions/hooks/AfterBuild.js.map +1 -1
- package/extensions/hooks/AfterDeploy.js +2 -1
- package/extensions/hooks/AfterDeploy.js.map +1 -1
- package/extensions/hooks/ApiAfterBuild.js +2 -1
- package/extensions/hooks/ApiAfterBuild.js.map +1 -1
- package/extensions/hooks/ApiAfterDeploy.js +2 -1
- package/extensions/hooks/ApiAfterDeploy.js.map +1 -1
- package/extensions/hooks/ApiBeforeBuild.js +2 -1
- package/extensions/hooks/ApiBeforeBuild.js.map +1 -1
- package/extensions/hooks/ApiBeforeDeploy.js +2 -1
- package/extensions/hooks/ApiBeforeDeploy.js.map +1 -1
- package/extensions/hooks/ApiBeforeWatch.js +2 -1
- package/extensions/hooks/ApiBeforeWatch.js.map +1 -1
- package/extensions/hooks/BeforeBuild.js +2 -1
- package/extensions/hooks/BeforeBuild.js.map +1 -1
- package/extensions/hooks/BeforeDeploy.js +2 -1
- package/extensions/hooks/BeforeDeploy.js.map +1 -1
- package/extensions/hooks/BeforeWatch.js +2 -1
- package/extensions/hooks/BeforeWatch.js.map +1 -1
- package/extensions/hooks/CoreAfterBuild.js +2 -1
- package/extensions/hooks/CoreAfterBuild.js.map +1 -1
- package/extensions/hooks/CoreAfterDeploy.js +2 -1
- package/extensions/hooks/CoreAfterDeploy.js.map +1 -1
- package/extensions/hooks/CoreBeforeBuild.js +2 -1
- package/extensions/hooks/CoreBeforeBuild.js.map +1 -1
- package/extensions/hooks/CoreBeforeDeploy.js +2 -1
- package/extensions/hooks/CoreBeforeDeploy.js.map +1 -1
- package/extensions/hooks/CoreBeforeWatch.js +2 -1
- package/extensions/hooks/CoreBeforeWatch.js.map +1 -1
- package/extensions/hosting/assertHostingType.d.ts +13 -0
- package/extensions/hosting/assertHostingType.js +12 -0
- package/extensions/hosting/assertHostingType.js.map +1 -0
- package/extensions/hosting/extensionImplementations.d.ts +12 -0
- package/extensions/hosting/extensionImplementations.js +4 -0
- package/extensions/hosting/extensionImplementations.js.map +1 -0
- package/extensions/hosting/getExtensionImplementation.d.ts +1 -0
- package/extensions/hosting/getExtensionImplementation.js +9 -0
- package/extensions/hosting/getExtensionImplementation.js.map +1 -0
- package/extensions/hosting/hostingType.d.ts +2 -0
- package/extensions/hosting/hostingType.js +0 -0
- package/extensions/hosting/index.d.ts +4 -0
- package/extensions/hosting/index.js +4 -0
- package/extensions/hosting/registerExtensionImplementation.d.ts +12 -0
- package/extensions/hosting/registerExtensionImplementation.js +13 -0
- package/extensions/hosting/registerExtensionImplementation.js.map +1 -0
- package/extensions/index.d.ts +27 -29
- package/extensions/index.js +8 -11
- package/extensions/index.js.map +1 -1
- package/extensions/infra/Env.js +5 -0
- package/extensions/infra/Env.js.map +1 -1
- package/extensions/pulumi/ProductionEnvironments.js +2 -1
- package/extensions/pulumi/ProductionEnvironments.js.map +1 -1
- package/extensions/pulumi/PulumiResourceNamePrefix.js +2 -1
- package/extensions/pulumi/PulumiResourceNamePrefix.js.map +1 -1
- package/extensions/pulumi/index.d.ts +0 -3
- package/extensions/pulumi/index.js +0 -3
- package/features/Serve/Serve.d.ts +1 -1
- package/features/Serve/Serve.js.map +1 -1
- package/features/Watch/watchers/worker.js +3 -0
- package/features/Watch/watchers/worker.js.map +1 -1
- package/package.json +34 -33
- package/services/GetProjectConfigService/ConfigRenderErrorBoundary.d.ts +15 -0
- package/services/GetProjectConfigService/ConfigRenderErrorBoundary.js +23 -0
- package/services/GetProjectConfigService/ConfigRenderErrorBoundary.js.map +1 -0
- package/services/GetProjectConfigService/EnvContext.d.ts +3 -2
- package/services/GetProjectConfigService/EnvContext.js +4 -6
- package/services/GetProjectConfigService/EnvContext.js.map +1 -1
- package/services/GetProjectConfigService/GetProjectConfigService.js +14 -11
- package/services/GetProjectConfigService/GetProjectConfigService.js.map +1 -1
- package/services/GetProjectConfigService/LicenseDecoratedFeatureFlags.js +1 -0
- package/services/GetProjectConfigService/LicenseDecoratedFeatureFlags.js.map +1 -1
- package/services/GetProjectConfigService/WcpProjectLicenseContext.d.ts +1 -0
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js +1 -0
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js.map +1 -1
- package/services/GetProjectConfigService/getRenderCacheKey.d.ts +1 -0
- package/services/GetProjectConfigService/getRenderCacheKey.js +13 -0
- package/services/GetProjectConfigService/getRenderCacheKey.js.map +1 -0
- package/services/GetProjectConfigService/nullRenderer.d.ts +4 -0
- package/services/GetProjectConfigService/nullRenderer.js +83 -0
- package/services/GetProjectConfigService/nullRenderer.js.map +1 -0
- package/services/GetProjectConfigService/renderConfig.d.ts +3 -12
- package/services/GetProjectConfigService/renderConfig.js +10 -35
- package/services/GetProjectConfigService/renderConfig.js.map +1 -1
- package/services/GetProjectConfigService/renderExtensions.d.ts +8 -0
- package/services/GetProjectConfigService/renderExtensions.js +52 -0
- package/services/GetProjectConfigService/renderExtensions.js.map +1 -0
- package/services/InitProjectSdkService/InitProjectSdkService.js +5 -8
- package/services/InitProjectSdkService/InitProjectSdkService.js.map +1 -1
- package/services/InitProjectSdkService/applyWcpEnvVars.js +27 -9
- package/services/InitProjectSdkService/applyWcpEnvVars.js.map +1 -1
- package/services/ValidateProjectConfigService/ValidateProjectConfigService.js +10 -7
- package/services/ValidateProjectConfigService/ValidateProjectConfigService.js.map +1 -1
- package/services/WcpService/GetProjectEnvironment.js +16 -5
- package/services/WcpService/GetProjectEnvironment.js.map +1 -1
- package/services/WcpService/WcpGqlClient.js +2 -2
- package/services/WcpService/WcpGqlClient.js.map +1 -1
- package/services/WcpService/fetchProjectEnvironmentByApiKey.d.ts +8 -0
- package/services/WcpService/fetchProjectEnvironmentByApiKey.js +21 -0
- package/services/WcpService/fetchProjectEnvironmentByApiKey.js.map +1 -0
- package/utils/ExtensionSrcResolver.js +2 -2
- package/utils/ExtensionSrcResolver.js.map +1 -1
- package/utils/apiRuntimeEnv.d.ts +2 -2
- package/utils/apiRuntimeEnv.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/trace/TraceRecorder.d.ts +17 -0
- package/utils/trace/TraceRecorder.js +51 -0
- package/utils/trace/TraceRecorder.js.map +1 -0
- package/utils/trace/formatTraceReport.d.ts +2 -0
- package/utils/trace/formatTraceReport.js +53 -0
- package/utils/trace/formatTraceReport.js.map +1 -0
- package/utils/trace/index.d.ts +6 -0
- package/utils/trace/index.js +6 -0
- package/utils/trace/isTraceRequested.d.ts +1 -0
- package/utils/trace/isTraceRequested.js +12 -0
- package/utils/trace/isTraceRequested.js.map +1 -0
- package/utils/trace/startTrace.d.ts +1 -0
- package/utils/trace/startTrace.js +19 -0
- package/utils/trace/startTrace.js.map +1 -0
- package/utils/trace/trace.d.ts +1 -0
- package/utils/trace/trace.js +13 -0
- package/utils/trace/trace.js.map +1 -0
- package/utils/trace/traceAsync.d.ts +1 -0
- package/utils/trace/traceAsync.js +13 -0
- package/utils/trace/traceAsync.js.map +1 -0
- package/extensions/ApiMaxBundleSize.d.ts +0 -4
- package/extensions/ApiMaxBundleSize.js +0 -23
- package/extensions/ApiMaxBundleSize.js.map +0 -1
- package/extensions/infra/Encryption.d.ts +0 -10
- package/extensions/infra/Encryption.js +0 -36
- package/extensions/infra/Encryption.js.map +0 -1
- package/extensions/infra/Hashing.d.ts +0 -5
- package/extensions/infra/Hashing.js +0 -27
- package/extensions/infra/Hashing.js.map +0 -1
- package/extensions/pulumi/AdminStackOutputValue.d.ts +0 -5
- package/extensions/pulumi/AdminStackOutputValue.js +0 -18
- package/extensions/pulumi/AdminStackOutputValue.js.map +0 -1
- package/extensions/pulumi/ApiStackOutputValue.d.ts +0 -5
- package/extensions/pulumi/ApiStackOutputValue.js +0 -18
- package/extensions/pulumi/ApiStackOutputValue.js.map +0 -1
- package/extensions/pulumi/CoreStackOutputValue.d.ts +0 -5
- package/extensions/pulumi/CoreStackOutputValue.js +0 -18
- package/extensions/pulumi/CoreStackOutputValue.js.map +0 -1
- package/rslib-runtime.js +0 -14
- package/rslib-runtime.js.map +0 -1
- package/services/GetProjectConfigService/renderConfigWorker.d.ts +0 -1
- package/services/GetProjectConfigService/renderConfigWorker.js +0 -64
- package/services/GetProjectConfigService/renderConfigWorker.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type AppName } from "../../abstractions/types.js";
|
|
2
2
|
export interface IStackOutput {
|
|
3
3
|
/**
|
|
4
|
-
* There is a possibility for a user to add stuff to the stack output.
|
|
4
|
+
* There is a possibility for a user to add stuff to the stack output. Pulumi outputs can be
|
|
5
|
+
* objects too, for example the Cognito user pool's password policy.
|
|
5
6
|
*/
|
|
6
|
-
[key: string]: string | string[] | undefined | number | number[] | boolean;
|
|
7
|
+
[key: string]: string | string[] | undefined | number | number[] | boolean | object;
|
|
7
8
|
}
|
|
8
9
|
export interface ICoreStackOutput extends IStackOutput {
|
|
9
10
|
deploymentId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractions/features/GetAppStackOutput.js","sources":["../../../src/abstractions/features/GetAppStackOutput.ts"],"sourcesContent":["import { createAbstraction } from \"~/abstractions/createAbstraction.js\";\nimport { type AppName } from \"~/abstractions/types.js\";\n\nexport interface IStackOutput {\n /**\n * There is a possibility for a user to add stuff to the stack output.\n */\n [key: string]: string | string[] | undefined | number | number[] | boolean;\n}\n\n// This interface is later extended in downstream packages (e.g., @webiny/project-aws).\n// TODO: because some of these are AWS specific, we should consider moving these to\n// TODO: @webiny/project-aws. Would've done it, but didn't have time.\nexport interface ICoreStackOutput extends IStackOutput {\n deploymentId: string;\n iotAuthorizerName: string;\n}\n\nexport type IGetAppStackOutputResult<TOutput extends IStackOutput = IStackOutput> = TOutput | null;\n\nexport interface IGetAppStackOutput {\n execute<TOutput extends IStackOutput = IStackOutput>(\n appName: AppName\n ): Promise<IGetAppStackOutputResult<TOutput>>;\n}\n\nexport const GetAppStackOutput = createAbstraction<IGetAppStackOutput>(\"GetAppStackOutput\");\n\nexport namespace GetAppStackOutput {\n export type Interface = IGetAppStackOutput;\n export type Result = IGetAppStackOutputResult;\n export type StackOutput = IStackOutput;\n}\n"],"names":["GetAppStackOutput","createAbstraction"],"mappings":";
|
|
1
|
+
{"version":3,"file":"abstractions/features/GetAppStackOutput.js","sources":["../../../src/abstractions/features/GetAppStackOutput.ts"],"sourcesContent":["import { createAbstraction } from \"~/abstractions/createAbstraction.js\";\nimport { type AppName } from \"~/abstractions/types.js\";\n\nexport interface IStackOutput {\n /**\n * There is a possibility for a user to add stuff to the stack output. Pulumi outputs can be\n * objects too, for example the Cognito user pool's password policy.\n */\n [key: string]: string | string[] | undefined | number | number[] | boolean | object;\n}\n\n// This interface is later extended in downstream packages (e.g., @webiny/project-aws).\n// TODO: because some of these are AWS specific, we should consider moving these to\n// TODO: @webiny/project-aws. Would've done it, but didn't have time.\nexport interface ICoreStackOutput extends IStackOutput {\n deploymentId: string;\n iotAuthorizerName: string;\n}\n\nexport type IGetAppStackOutputResult<TOutput extends IStackOutput = IStackOutput> = TOutput | null;\n\nexport interface IGetAppStackOutput {\n execute<TOutput extends IStackOutput = IStackOutput>(\n appName: AppName\n ): Promise<IGetAppStackOutputResult<TOutput>>;\n}\n\nexport const GetAppStackOutput = createAbstraction<IGetAppStackOutput>(\"GetAppStackOutput\");\n\nexport namespace GetAppStackOutput {\n export type Interface = IGetAppStackOutput;\n export type Result = IGetAppStackOutputResult;\n export type StackOutput = IStackOutput;\n}\n"],"names":["GetAppStackOutput","createAbstraction"],"mappings":";AA2BO,MAAMA,oBAAoBC,kBAAsC"}
|
|
@@ -23,12 +23,17 @@ declare function CanUseFileManagerThreatDetection({ children }: {
|
|
|
23
23
|
declare function CanUseHcmsFieldPermissions({ children }: {
|
|
24
24
|
children: React.ReactNode;
|
|
25
25
|
}): React.JSX.Element;
|
|
26
|
-
declare function CanUseRemoteComponents({ children }: {
|
|
27
|
-
children: React.ReactNode;
|
|
28
|
-
}): React.JSX.Element;
|
|
29
26
|
declare function CanUseAiPowerups({ children }: {
|
|
30
27
|
children: React.ReactNode;
|
|
31
28
|
}): React.JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* Webhooks are on unless the project sets `webhooks: false`, so this can't go through `CanUse`:
|
|
31
|
+
* `isEnabled` reads an unset flag as off (and, for a flag the license doesn't list, as off without a
|
|
32
|
+
* license).
|
|
33
|
+
*/
|
|
34
|
+
declare function CanUseWebhooks({ children }: {
|
|
35
|
+
children: React.ReactNode;
|
|
36
|
+
}): React.JSX.Element | null;
|
|
32
37
|
export declare const FeatureFlag: {
|
|
33
38
|
CanUse: typeof CanUse;
|
|
34
39
|
CanUseMultiTenancy: typeof CanUseMultiTenancy;
|
|
@@ -37,7 +42,7 @@ export declare const FeatureFlag: {
|
|
|
37
42
|
CanUsePrivateFiles: typeof CanUsePrivateFiles;
|
|
38
43
|
CanUseFileManagerThreatDetection: typeof CanUseFileManagerThreatDetection;
|
|
39
44
|
CanUseHcmsFieldPermissions: typeof CanUseHcmsFieldPermissions;
|
|
40
|
-
CanUseRemoteComponents: typeof CanUseRemoteComponents;
|
|
41
45
|
CanUseAiPowerups: typeof CanUseAiPowerups;
|
|
46
|
+
CanUseWebhooks: typeof CanUseWebhooks;
|
|
42
47
|
};
|
|
43
48
|
export {};
|
|
@@ -34,16 +34,15 @@ function CanUseHcmsFieldPermissions({ children }) {
|
|
|
34
34
|
name: "advancedAccessControlLayer.hcmsFieldPermissions"
|
|
35
35
|
}, children);
|
|
36
36
|
}
|
|
37
|
-
function CanUseRemoteComponents({ children }) {
|
|
38
|
-
return /*#__PURE__*/ react.createElement(CanUse, {
|
|
39
|
-
name: "remoteComponents"
|
|
40
|
-
}, children);
|
|
41
|
-
}
|
|
42
37
|
function CanUseAiPowerups({ children }) {
|
|
43
38
|
return /*#__PURE__*/ react.createElement(CanUse, {
|
|
44
39
|
name: "aiPowerups"
|
|
45
40
|
}, children);
|
|
46
41
|
}
|
|
42
|
+
function CanUseWebhooks({ children }) {
|
|
43
|
+
const flags = useProjectFeatureFlags();
|
|
44
|
+
return flags.isExplicitlyDisabled("webhooks") ? null : /*#__PURE__*/ react.createElement(react.Fragment, null, children);
|
|
45
|
+
}
|
|
47
46
|
const FeatureFlag = {
|
|
48
47
|
CanUse: CanUse,
|
|
49
48
|
CanUseMultiTenancy: CanUseMultiTenancy,
|
|
@@ -52,8 +51,8 @@ const FeatureFlag = {
|
|
|
52
51
|
CanUsePrivateFiles: CanUsePrivateFiles,
|
|
53
52
|
CanUseFileManagerThreatDetection: CanUseFileManagerThreatDetection,
|
|
54
53
|
CanUseHcmsFieldPermissions: CanUseHcmsFieldPermissions,
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
CanUseAiPowerups: CanUseAiPowerups,
|
|
55
|
+
CanUseWebhooks: CanUseWebhooks
|
|
57
56
|
};
|
|
58
57
|
export { FeatureFlag };
|
|
59
58
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/FeatureFlag.js","sources":["../../src/components/FeatureFlag.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FeatureFlagName } from \"@webiny/feature-flags\";\nimport { useProjectFeatureFlags } from \"~/services/GetProjectConfigService/FeatureFlagsContext.js\";\n\ninterface CanUseProps {\n name: FeatureFlagName;\n children: React.ReactNode;\n}\n\nfunction CanUse({ name, children }: CanUseProps) {\n const flags = useProjectFeatureFlags();\n return flags.isEnabled(name) ? <>{children}</> : null;\n}\n\nfunction CanUseMultiTenancy({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"multiTenancy\">{children}</CanUse>;\n}\n\nfunction CanUseWorkflows({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"advancedPublishingWorkflow\">{children}</CanUse>;\n}\n\nfunction CanUseTeams({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"advancedAccessControlLayer.teams\">{children}</CanUse>;\n}\n\nfunction CanUsePrivateFiles({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"advancedAccessControlLayer.privateFiles\">{children}</CanUse>;\n}\n\nfunction CanUseFileManagerThreatDetection({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"fileManager.threatDetection\">{children}</CanUse>;\n}\n\nfunction CanUseHcmsFieldPermissions({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"advancedAccessControlLayer.hcmsFieldPermissions\">{children}</CanUse>;\n}\n\nfunction
|
|
1
|
+
{"version":3,"file":"components/FeatureFlag.js","sources":["../../src/components/FeatureFlag.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FeatureFlagName } from \"@webiny/feature-flags\";\nimport { useProjectFeatureFlags } from \"~/services/GetProjectConfigService/FeatureFlagsContext.js\";\n\ninterface CanUseProps {\n name: FeatureFlagName;\n children: React.ReactNode;\n}\n\nfunction CanUse({ name, children }: CanUseProps) {\n const flags = useProjectFeatureFlags();\n return flags.isEnabled(name) ? <>{children}</> : null;\n}\n\nfunction CanUseMultiTenancy({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"multiTenancy\">{children}</CanUse>;\n}\n\nfunction CanUseWorkflows({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"advancedPublishingWorkflow\">{children}</CanUse>;\n}\n\nfunction CanUseTeams({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"advancedAccessControlLayer.teams\">{children}</CanUse>;\n}\n\nfunction CanUsePrivateFiles({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"advancedAccessControlLayer.privateFiles\">{children}</CanUse>;\n}\n\nfunction CanUseFileManagerThreatDetection({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"fileManager.threatDetection\">{children}</CanUse>;\n}\n\nfunction CanUseHcmsFieldPermissions({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"advancedAccessControlLayer.hcmsFieldPermissions\">{children}</CanUse>;\n}\n\nfunction CanUseAiPowerups({ children }: { children: React.ReactNode }) {\n return <CanUse name=\"aiPowerups\">{children}</CanUse>;\n}\n\n/**\n * Webhooks are on unless the project sets `webhooks: false`, so this can't go through `CanUse`:\n * `isEnabled` reads an unset flag as off (and, for a flag the license doesn't list, as off without a\n * license).\n */\nfunction CanUseWebhooks({ children }: { children: React.ReactNode }) {\n const flags = useProjectFeatureFlags();\n return flags.isExplicitlyDisabled(\"webhooks\") ? null : <>{children}</>;\n}\n\nexport const FeatureFlag = {\n CanUse,\n CanUseMultiTenancy,\n CanUseWorkflows,\n CanUseTeams,\n CanUsePrivateFiles,\n CanUseFileManagerThreatDetection,\n CanUseHcmsFieldPermissions,\n CanUseAiPowerups,\n CanUseWebhooks\n};\n"],"names":["CanUse","name","children","flags","useProjectFeatureFlags","CanUseMultiTenancy","CanUseWorkflows","CanUseTeams","CanUsePrivateFiles","CanUseFileManagerThreatDetection","CanUseHcmsFieldPermissions","CanUseAiPowerups","CanUseWebhooks","FeatureFlag"],"mappings":";;AASA,SAASA,OAAO,EAAEC,IAAI,EAAEC,QAAQ,EAAe;IAC3C,MAAMC,QAAQC;IACd,OAAOD,MAAM,SAAS,CAACF,QAAQ,WAARA,GAAQ,0CAAGC,YAAe;AACrD;AAEA,SAASG,mBAAmB,EAAEH,QAAQ,EAAiC;IACnE,OAAO,WAAP,GAAO,oBAACF,QAAMA;QAAC,MAAK;OAAgBE;AACxC;AAEA,SAASI,gBAAgB,EAAEJ,QAAQ,EAAiC;IAChE,OAAO,WAAP,GAAO,oBAACF,QAAMA;QAAC,MAAK;OAA8BE;AACtD;AAEA,SAASK,YAAY,EAAEL,QAAQ,EAAiC;IAC5D,OAAO,WAAP,GAAO,oBAACF,QAAMA;QAAC,MAAK;OAAoCE;AAC5D;AAEA,SAASM,mBAAmB,EAAEN,QAAQ,EAAiC;IACnE,OAAO,WAAP,GAAO,oBAACF,QAAMA;QAAC,MAAK;OAA2CE;AACnE;AAEA,SAASO,iCAAiC,EAAEP,QAAQ,EAAiC;IACjF,OAAO,WAAP,GAAO,oBAACF,QAAMA;QAAC,MAAK;OAA+BE;AACvD;AAEA,SAASQ,2BAA2B,EAAER,QAAQ,EAAiC;IAC3E,OAAO,WAAP,GAAO,oBAACF,QAAMA;QAAC,MAAK;OAAmDE;AAC3E;AAEA,SAASS,iBAAiB,EAAET,QAAQ,EAAiC;IACjE,OAAO,WAAP,GAAO,oBAACF,QAAMA;QAAC,MAAK;OAAcE;AACtC;AAOA,SAASU,eAAe,EAAEV,QAAQ,EAAiC;IAC/D,MAAMC,QAAQC;IACd,OAAOD,MAAM,oBAAoB,CAAC,cAAc,OAAO,WAAP,GAAO,0CAAGD;AAC9D;AAEO,MAAMW,cAAc;IACvBb,QAAAA;IACAK,oBAAAA;IACAC,iBAAAA;IACAC,aAAAA;IACAC,oBAAAA;IACAC,kCAAAA;IACAC,4BAAAA;IACAC,kBAAAA;IACAC,gBAAAA;AACJ"}
|
|
@@ -3,6 +3,9 @@ import { adminAfterBuild, adminBeforeBuild, adminBeforeWatch, afterBuild, apiAft
|
|
|
3
3
|
import { buildAppWorkspaceService, buildProjectWorkspaceService, getAppPackagesService, getAppService, getCwdService, getIsCiService, getNpmVersionService, getNpxVersionService, getProjectConfigService, getProjectIdService, getProjectInstallationIdService, getProjectService, getProjectVersionService, getPulumiVersionService, getYarnVersionService, initProjectSdkService, installExtensionService, listPackagesInAppWorkspaceService, listPackagesService, loadEnvVarsService, localStorageService, loggerService, projectInfoService, projectSdkParamsService, setProjectIdService, stackOutputCacheService, stdioService, uiService, validateProjectConfigService, wcpService } from "./services/index.js";
|
|
4
4
|
import { BuildProjectWorkspaceService, GetProjectConfig, InitProjectSdkService, LoadEnvVarsService, LoggerService, ProjectSdkParamsService, ValidateProjectConfig } from "./abstractions/index.js";
|
|
5
5
|
import { getFeatureFlagsWithLicense } from "./decorators/index.js";
|
|
6
|
+
import { traceAsync } from "./utils/trace/index.js";
|
|
7
|
+
import { applyEnvVars } from "./services/InitProjectSdkService/applyEnvVars.js";
|
|
8
|
+
import { applyWcpEnvVars } from "./services/InitProjectSdkService/applyWcpEnvVars.js";
|
|
6
9
|
const createProjectSdkContainer = async (params, register)=>{
|
|
7
10
|
const container = new Container();
|
|
8
11
|
container.register(getAppService).inSingletonScope();
|
|
@@ -66,17 +69,27 @@ const createProjectSdkContainer = async (params, register)=>{
|
|
|
66
69
|
container.registerComposite(coreBeforeWatch);
|
|
67
70
|
container.resolve(ProjectSdkParamsService).set(params);
|
|
68
71
|
register?.(container);
|
|
69
|
-
|
|
70
|
-
await
|
|
72
|
+
const loadEnvVars = container.resolve(LoadEnvVarsService);
|
|
73
|
+
await traceAsync("load env vars", ()=>loadEnvVars.execute());
|
|
74
|
+
const buildProjectWorkspace = container.resolve(BuildProjectWorkspaceService);
|
|
75
|
+
await traceAsync("build project workspace", ()=>buildProjectWorkspace.execute());
|
|
71
76
|
const logger = container.resolve(LoggerService);
|
|
72
77
|
logger.log("Initializing Project SDK container...");
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
await
|
|
78
|
+
const projectConfigGetter = container.resolve(GetProjectConfig);
|
|
79
|
+
const getProjectExtensions = ()=>projectConfigGetter.execute({
|
|
80
|
+
tags: {
|
|
81
|
+
runtimeContext: "project"
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const initialProjectExtensions = await traceAsync("read project ID and env vars", ()=>getProjectExtensions());
|
|
85
|
+
applyEnvVars(initialProjectExtensions);
|
|
86
|
+
await traceAsync("apply WCP env vars", ()=>applyWcpEnvVars(container));
|
|
87
|
+
const projectExtensions = await traceAsync("get project extensions", ()=>getProjectExtensions());
|
|
88
|
+
applyEnvVars(projectExtensions);
|
|
89
|
+
const projectConfigValidator = container.resolve(ValidateProjectConfig);
|
|
90
|
+
await traceAsync("validate project extensions", ()=>projectConfigValidator.execute(projectExtensions));
|
|
91
|
+
const initProjectSdk = container.resolve(InitProjectSdkService);
|
|
92
|
+
await traceAsync("register project SDK extensions", ()=>initProjectSdk.execute(container));
|
|
80
93
|
return container;
|
|
81
94
|
};
|
|
82
95
|
export { createProjectSdkContainer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProjectSdkContainer.js","sources":["../src/createProjectSdkContainer.ts"],"sourcesContent":["import { Container } from \"@webiny/di\";\nimport {\n beforeBuild,\n afterBuild,\n beforeWatch,\n adminAfterBuild,\n adminBeforeBuild,\n adminBeforeWatch,\n apiAfterBuild,\n apiBeforeBuild,\n apiBeforeWatch,\n coreAfterBuild,\n coreBeforeBuild,\n coreBeforeWatch,\n buildApp,\n getApp,\n getLogger,\n getProductionEnvironments,\n getProject,\n getProjectConfig,\n getProjectInfo,\n getFeatureFlags,\n installExtension,\n isCi,\n isTelemetryEnabled,\n isWcpEnabled,\n isWebinyJsRepo,\n validateProjectConfig,\n watch,\n serve\n} from \"./features/index.js\";\n\nimport {\n getAppService,\n buildAppWorkspaceService,\n buildProjectWorkspaceService,\n getAppPackagesService,\n getCwdService,\n getIsCiService,\n getNpmVersionService,\n getNpxVersionService,\n getProjectConfigService,\n getProjectIdService,\n getProjectInstallationIdService,\n getProjectService,\n getProjectVersionService,\n getPulumiVersionService,\n getYarnVersionService,\n initProjectSdkService,\n installExtensionService,\n listPackagesInAppWorkspaceService,\n listPackagesService,\n loadEnvVarsService,\n localStorageService,\n loggerService,\n projectInfoService,\n projectSdkParamsService,\n setProjectIdService,\n stackOutputCacheService,\n stdioService,\n uiService,\n validateProjectConfigService,\n wcpService\n} from \"./services/index.js\";\n\nimport {\n GetProjectConfig,\n BuildProjectWorkspaceService,\n ProjectSdkParamsService,\n LoadEnvVarsService,\n ValidateProjectConfig,\n LoggerService,\n InitProjectSdkService\n} from \"~/abstractions/index.js\";\nimport { getFeatureFlagsWithLicense } from \"./decorators/index.js\";\n\nexport const createProjectSdkContainer = async (\n params: Partial<ProjectSdkParamsService.Params>,\n register?: (container: Container) => void\n) => {\n const container = new Container();\n\n // Services.\n container.register(getAppService).inSingletonScope();\n container.register(buildAppWorkspaceService).inSingletonScope();\n container.register(buildProjectWorkspaceService).inSingletonScope();\n container.register(getAppPackagesService).inSingletonScope();\n container.register(getCwdService).inSingletonScope();\n container.register(getIsCiService).inSingletonScope();\n container.register(getNpmVersionService).inSingletonScope();\n container.register(getNpxVersionService).inSingletonScope();\n container.register(getProjectConfigService).inSingletonScope();\n container.register(getProjectIdService).inSingletonScope();\n container.register(getProjectInstallationIdService).inSingletonScope();\n container.register(getProjectService).inSingletonScope();\n container.register(getProjectVersionService).inSingletonScope();\n container.register(getPulumiVersionService).inSingletonScope();\n container.register(getYarnVersionService).inSingletonScope();\n container.register(initProjectSdkService).inSingletonScope();\n container.register(installExtensionService).inSingletonScope();\n container.register(listPackagesInAppWorkspaceService).inSingletonScope();\n container.register(listPackagesService).inSingletonScope();\n container.register(loadEnvVarsService).inSingletonScope();\n container.register(localStorageService).inSingletonScope();\n container.register(loggerService).inSingletonScope();\n container.register(projectInfoService).inSingletonScope();\n container.register(projectSdkParamsService).inSingletonScope();\n container.register(setProjectIdService).inSingletonScope();\n container.register(stackOutputCacheService).inSingletonScope();\n container.register(stdioService).inSingletonScope();\n container.register(uiService).inSingletonScope();\n container.register(validateProjectConfigService).inSingletonScope();\n container.register(wcpService).inSingletonScope();\n\n // Features.\n container.register(buildApp).inSingletonScope();\n container.register(getApp).inSingletonScope();\n container.register(getLogger).inSingletonScope();\n container.register(getProductionEnvironments).inSingletonScope();\n container.register(getProject).inSingletonScope();\n container.register(getProjectConfig).inSingletonScope();\n container.register(getProjectInfo).inSingletonScope();\n container.register(installExtension).inSingletonScope();\n container.register(isCi).inSingletonScope();\n container.register(isTelemetryEnabled).inSingletonScope();\n container.register(isWcpEnabled).inSingletonScope();\n container.register(isWebinyJsRepo).inSingletonScope();\n container.register(getFeatureFlags).inSingletonScope();\n container.register(validateProjectConfig).inSingletonScope();\n container.register(watch).inSingletonScope();\n container.register(serve).inSingletonScope();\n container.registerDecorator(getFeatureFlagsWithLicense);\n\n // Hooks (cloud-agnostic: build + watch).\n container.registerComposite(beforeBuild);\n container.registerComposite(afterBuild);\n container.registerComposite(beforeWatch);\n container.registerComposite(apiBeforeBuild);\n container.registerComposite(apiBeforeWatch);\n container.registerComposite(apiAfterBuild);\n container.registerComposite(adminBeforeBuild);\n container.registerComposite(adminBeforeWatch);\n container.registerComposite(adminAfterBuild);\n container.registerComposite(coreBeforeBuild);\n container.registerComposite(coreAfterBuild);\n container.registerComposite(coreBeforeWatch);\n\n // Initialize project SDK.\n container.resolve(ProjectSdkParamsService).set(params);\n\n // Allow hosting-specific registrations (e.g. project-aws, project-server).\n // Must run before workspace services execute so decorators are in place.\n register?.(container);\n\n await container.resolve(LoadEnvVarsService).execute();\n await container.resolve(BuildProjectWorkspaceService).execute();\n\n const logger = container.resolve(LoggerService);\n logger.log(\"Initializing Project SDK container...\");\n\n const projectExtensions = await container.resolve(GetProjectConfig).execute({\n tags: { runtimeContext: \"project\" }\n });\n\n await container.resolve(ValidateProjectConfig).execute(projectExtensions);\n\n // Initialize project SDK extensions (env vars, hooks, pulumi, implementations, decorators).\n await container.resolve(InitProjectSdkService).execute(container);\n\n return container;\n};\n"],"names":["createProjectSdkContainer","params","register","container","Container","getAppService","buildAppWorkspaceService","buildProjectWorkspaceService","getAppPackagesService","getCwdService","getIsCiService","getNpmVersionService","getNpxVersionService","getProjectConfigService","getProjectIdService","getProjectInstallationIdService","getProjectService","getProjectVersionService","getPulumiVersionService","getYarnVersionService","initProjectSdkService","installExtensionService","listPackagesInAppWorkspaceService","listPackagesService","loadEnvVarsService","localStorageService","loggerService","projectInfoService","projectSdkParamsService","setProjectIdService","stackOutputCacheService","stdioService","uiService","validateProjectConfigService","wcpService","buildApp","getApp","getLogger","getProductionEnvironments","getProject","getProjectConfig","getProjectInfo","installExtension","isCi","isTelemetryEnabled","isWcpEnabled","isWebinyJsRepo","getFeatureFlags","validateProjectConfig","watch","serve","getFeatureFlagsWithLicense","beforeBuild","afterBuild","beforeWatch","apiBeforeBuild","apiBeforeWatch","apiAfterBuild","adminBeforeBuild","adminBeforeWatch","adminAfterBuild","coreBeforeBuild","coreAfterBuild","coreBeforeWatch","ProjectSdkParamsService","LoadEnvVarsService","BuildProjectWorkspaceService","logger","LoggerService","projectExtensions","GetProjectConfig","ValidateProjectConfig","InitProjectSdkService"],"mappings":";;;;;AA4EO,MAAMA,4BAA4B,OACrCC,QACAC;IAEA,MAAMC,YAAY,IAAIC;IAGtBD,UAAU,QAAQ,CAACE,eAAe,gBAAgB;IAClDF,UAAU,QAAQ,CAACG,0BAA0B,gBAAgB;IAC7DH,UAAU,QAAQ,CAACI,8BAA8B,gBAAgB;IACjEJ,UAAU,QAAQ,CAACK,uBAAuB,gBAAgB;IAC1DL,UAAU,QAAQ,CAACM,eAAe,gBAAgB;IAClDN,UAAU,QAAQ,CAACO,gBAAgB,gBAAgB;IACnDP,UAAU,QAAQ,CAACQ,sBAAsB,gBAAgB;IACzDR,UAAU,QAAQ,CAACS,sBAAsB,gBAAgB;IACzDT,UAAU,QAAQ,CAACU,yBAAyB,gBAAgB;IAC5DV,UAAU,QAAQ,CAACW,qBAAqB,gBAAgB;IACxDX,UAAU,QAAQ,CAACY,iCAAiC,gBAAgB;IACpEZ,UAAU,QAAQ,CAACa,mBAAmB,gBAAgB;IACtDb,UAAU,QAAQ,CAACc,0BAA0B,gBAAgB;IAC7Dd,UAAU,QAAQ,CAACe,yBAAyB,gBAAgB;IAC5Df,UAAU,QAAQ,CAACgB,uBAAuB,gBAAgB;IAC1DhB,UAAU,QAAQ,CAACiB,uBAAuB,gBAAgB;IAC1DjB,UAAU,QAAQ,CAACkB,yBAAyB,gBAAgB;IAC5DlB,UAAU,QAAQ,CAACmB,mCAAmC,gBAAgB;IACtEnB,UAAU,QAAQ,CAACoB,qBAAqB,gBAAgB;IACxDpB,UAAU,QAAQ,CAACqB,oBAAoB,gBAAgB;IACvDrB,UAAU,QAAQ,CAACsB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,UAAU,iBAAiB,CAACkD;IAC5BlD,UAAU,iBAAiB,CAACmD;IAC5BnD,UAAU,iBAAiB,CAACoD;IAC5BpD,UAAU,iBAAiB,CAACqD;IAC5BrD,UAAU,iBAAiB,CAACsD;IAC5BtD,UAAU,iBAAiB,CAACuD;IAC5BvD,UAAU,iBAAiB,CAACwD;IAC5BxD,UAAU,iBAAiB,CAACyD;IAC5BzD,UAAU,iBAAiB,CAAC0D;IAC5B1D,UAAU,iBAAiB,CAAC2D;IAC5B3D,UAAU,iBAAiB,CAAC4D;IAG5B5D,UAAU,OAAO,CAAC6D,yBAAyB,GAAG,CAAC/D;IAI/CC,WAAWC;IAEX,MAAMA,UAAU,OAAO,CAAC8D,oBAAoB,OAAO;IACnD,MAAM9D,UAAU,OAAO,CAAC+D,8BAA8B,OAAO;IAE7D,MAAMC,SAAShE,UAAU,OAAO,CAACiE;IACjCD,OAAO,GAAG,CAAC;IAEX,MAAME,oBAAoB,MAAMlE,UAAU,OAAO,CAACmE,kBAAkB,OAAO,CAAC;QACxE,MAAM;YAAE,gBAAgB;QAAU;IACtC;IAEA,MAAMnE,UAAU,OAAO,CAACoE,uBAAuB,OAAO,CAACF;IAGvD,MAAMlE,UAAU,OAAO,CAACqE,uBAAuB,OAAO,CAACrE;IAEvD,OAAOA;AACX"}
|
|
1
|
+
{"version":3,"file":"createProjectSdkContainer.js","sources":["../src/createProjectSdkContainer.ts"],"sourcesContent":["import { Container } from \"@webiny/di\";\nimport {\n beforeBuild,\n afterBuild,\n beforeWatch,\n adminAfterBuild,\n adminBeforeBuild,\n adminBeforeWatch,\n apiAfterBuild,\n apiBeforeBuild,\n apiBeforeWatch,\n coreAfterBuild,\n coreBeforeBuild,\n coreBeforeWatch,\n buildApp,\n getApp,\n getLogger,\n getProductionEnvironments,\n getProject,\n getProjectConfig,\n getProjectInfo,\n getFeatureFlags,\n installExtension,\n isCi,\n isTelemetryEnabled,\n isWcpEnabled,\n isWebinyJsRepo,\n validateProjectConfig,\n watch,\n serve\n} from \"./features/index.js\";\n\nimport {\n getAppService,\n buildAppWorkspaceService,\n buildProjectWorkspaceService,\n getAppPackagesService,\n getCwdService,\n getIsCiService,\n getNpmVersionService,\n getNpxVersionService,\n getProjectConfigService,\n getProjectIdService,\n getProjectInstallationIdService,\n getProjectService,\n getProjectVersionService,\n getPulumiVersionService,\n getYarnVersionService,\n initProjectSdkService,\n installExtensionService,\n listPackagesInAppWorkspaceService,\n listPackagesService,\n loadEnvVarsService,\n localStorageService,\n loggerService,\n projectInfoService,\n projectSdkParamsService,\n setProjectIdService,\n stackOutputCacheService,\n stdioService,\n uiService,\n validateProjectConfigService,\n wcpService\n} from \"./services/index.js\";\n\nimport {\n GetProjectConfig,\n BuildProjectWorkspaceService,\n ProjectSdkParamsService,\n LoadEnvVarsService,\n ValidateProjectConfig,\n LoggerService,\n InitProjectSdkService\n} from \"~/abstractions/index.js\";\nimport { getFeatureFlagsWithLicense } from \"./decorators/index.js\";\nimport { traceAsync } from \"./utils/trace/index.js\";\nimport { applyEnvVars } from \"./services/InitProjectSdkService/applyEnvVars.js\";\nimport { applyWcpEnvVars } from \"./services/InitProjectSdkService/applyWcpEnvVars.js\";\n\nexport const createProjectSdkContainer = async (\n params: Partial<ProjectSdkParamsService.Params>,\n register?: (container: Container) => void\n) => {\n const container = new Container();\n\n // Services.\n container.register(getAppService).inSingletonScope();\n container.register(buildAppWorkspaceService).inSingletonScope();\n container.register(buildProjectWorkspaceService).inSingletonScope();\n container.register(getAppPackagesService).inSingletonScope();\n container.register(getCwdService).inSingletonScope();\n container.register(getIsCiService).inSingletonScope();\n container.register(getNpmVersionService).inSingletonScope();\n container.register(getNpxVersionService).inSingletonScope();\n container.register(getProjectConfigService).inSingletonScope();\n container.register(getProjectIdService).inSingletonScope();\n container.register(getProjectInstallationIdService).inSingletonScope();\n container.register(getProjectService).inSingletonScope();\n container.register(getProjectVersionService).inSingletonScope();\n container.register(getPulumiVersionService).inSingletonScope();\n container.register(getYarnVersionService).inSingletonScope();\n container.register(initProjectSdkService).inSingletonScope();\n container.register(installExtensionService).inSingletonScope();\n container.register(listPackagesInAppWorkspaceService).inSingletonScope();\n container.register(listPackagesService).inSingletonScope();\n container.register(loadEnvVarsService).inSingletonScope();\n container.register(localStorageService).inSingletonScope();\n container.register(loggerService).inSingletonScope();\n container.register(projectInfoService).inSingletonScope();\n container.register(projectSdkParamsService).inSingletonScope();\n container.register(setProjectIdService).inSingletonScope();\n container.register(stackOutputCacheService).inSingletonScope();\n container.register(stdioService).inSingletonScope();\n container.register(uiService).inSingletonScope();\n container.register(validateProjectConfigService).inSingletonScope();\n container.register(wcpService).inSingletonScope();\n\n // Features.\n container.register(buildApp).inSingletonScope();\n container.register(getApp).inSingletonScope();\n container.register(getLogger).inSingletonScope();\n container.register(getProductionEnvironments).inSingletonScope();\n container.register(getProject).inSingletonScope();\n container.register(getProjectConfig).inSingletonScope();\n container.register(getProjectInfo).inSingletonScope();\n container.register(installExtension).inSingletonScope();\n container.register(isCi).inSingletonScope();\n container.register(isTelemetryEnabled).inSingletonScope();\n container.register(isWcpEnabled).inSingletonScope();\n container.register(isWebinyJsRepo).inSingletonScope();\n container.register(getFeatureFlags).inSingletonScope();\n container.register(validateProjectConfig).inSingletonScope();\n container.register(watch).inSingletonScope();\n container.register(serve).inSingletonScope();\n container.registerDecorator(getFeatureFlagsWithLicense);\n\n // Hooks (cloud-agnostic: build + watch).\n container.registerComposite(beforeBuild);\n container.registerComposite(afterBuild);\n container.registerComposite(beforeWatch);\n container.registerComposite(apiBeforeBuild);\n container.registerComposite(apiBeforeWatch);\n container.registerComposite(apiAfterBuild);\n container.registerComposite(adminBeforeBuild);\n container.registerComposite(adminBeforeWatch);\n container.registerComposite(adminAfterBuild);\n container.registerComposite(coreBeforeBuild);\n container.registerComposite(coreAfterBuild);\n container.registerComposite(coreBeforeWatch);\n\n // Initialize project SDK.\n container.resolve(ProjectSdkParamsService).set(params);\n\n // Allow hosting-specific registrations (e.g. project-aws, project-standalone).\n // Must run before workspace services execute so decorators are in place.\n register?.(container);\n\n const loadEnvVars = container.resolve(LoadEnvVarsService);\n await traceAsync(\"load env vars\", () => loadEnvVars.execute());\n\n const buildProjectWorkspace = container.resolve(BuildProjectWorkspaceService);\n await traceAsync(\"build project workspace\", () => buildProjectWorkspace.execute());\n\n const logger = container.resolve(LoggerService);\n logger.log(\"Initializing Project SDK container...\");\n\n const projectConfigGetter = container.resolve(GetProjectConfig);\n const getProjectExtensions = () => {\n return projectConfigGetter.execute({\n tags: { runtimeContext: \"project\" }\n });\n };\n\n /*\n * The WCP license is an input to the config render: license-gated feature flags decide which\n * extensions the config contains. Fetching the license needs the WCP project ID, though, and\n * unless `WEBINY_PROJECT_ID` is set, the ID comes from the config as well. So the config is read\n * once to learn the project ID and the env vars it sets (a project can supply its WCP API key\n * that way), the WCP env vars and license are fetched, and only then is the config read that\n * every later step uses.\n *\n * The render cache is keyed on the license, so that second read renders again when a license\n * arrived, and is a plain cache hit for a project that isn't linked to WCP.\n */\n const initialProjectExtensions = await traceAsync(\"read project ID and env vars\", () => {\n return getProjectExtensions();\n });\n applyEnvVars(initialProjectExtensions);\n\n await traceAsync(\"apply WCP env vars\", () => applyWcpEnvVars(container));\n\n const projectExtensions = await traceAsync(\"get project extensions\", () => {\n return getProjectExtensions();\n });\n\n // The licensed render can contain extensions the first one didn't, env vars among them.\n // `applyEnvVars` never overwrites a variable that's already set, so running it again is safe.\n applyEnvVars(projectExtensions);\n\n const projectConfigValidator = container.resolve(ValidateProjectConfig);\n await traceAsync(\"validate project extensions\", () => {\n return projectConfigValidator.execute(projectExtensions);\n });\n\n // Initialize project SDK extensions (env vars, hooks, pulumi, implementations, decorators).\n const initProjectSdk = container.resolve(InitProjectSdkService);\n await traceAsync(\"register project SDK extensions\", () => initProjectSdk.execute(container));\n\n return container;\n};\n"],"names":["createProjectSdkContainer","params","register","container","Container","getAppService","buildAppWorkspaceService","buildProjectWorkspaceService","getAppPackagesService","getCwdService","getIsCiService","getNpmVersionService","getNpxVersionService","getProjectConfigService","getProjectIdService","getProjectInstallationIdService","getProjectService","getProjectVersionService","getPulumiVersionService","getYarnVersionService","initProjectSdkService","installExtensionService","listPackagesInAppWorkspaceService","listPackagesService","loadEnvVarsService","localStorageService","loggerService","projectInfoService","projectSdkParamsService","setProjectIdService","stackOutputCacheService","stdioService","uiService","validateProjectConfigService","wcpService","buildApp","getApp","getLogger","getProductionEnvironments","getProject","getProjectConfig","getProjectInfo","installExtension","isCi","isTelemetryEnabled","isWcpEnabled","isWebinyJsRepo","getFeatureFlags","validateProjectConfig","watch","serve","getFeatureFlagsWithLicense","beforeBuild","afterBuild","beforeWatch","apiBeforeBuild","apiBeforeWatch","apiAfterBuild","adminBeforeBuild","adminBeforeWatch","adminAfterBuild","coreBeforeBuild","coreAfterBuild","coreBeforeWatch","ProjectSdkParamsService","loadEnvVars","LoadEnvVarsService","traceAsync","buildProjectWorkspace","BuildProjectWorkspaceService","logger","LoggerService","projectConfigGetter","GetProjectConfig","getProjectExtensions","initialProjectExtensions","applyEnvVars","applyWcpEnvVars","projectExtensions","projectConfigValidator","ValidateProjectConfig","initProjectSdk","InitProjectSdkService"],"mappings":";;;;;;;;AA+EO,MAAMA,4BAA4B,OACrCC,QACAC;IAEA,MAAMC,YAAY,IAAIC;IAGtBD,UAAU,QAAQ,CAACE,eAAe,gBAAgB;IAClDF,UAAU,QAAQ,CAACG,0BAA0B,gBAAgB;IAC7DH,UAAU,QAAQ,CAACI,8BAA8B,gBAAgB;IACjEJ,UAAU,QAAQ,CAACK,uBAAuB,gBAAgB;IAC1DL,UAAU,QAAQ,CAACM,eAAe,gBAAgB;IAClDN,UAAU,QAAQ,CAACO,gBAAgB,gBAAgB;IACnDP,UAAU,QAAQ,CAACQ,sBAAsB,gBAAgB;IACzDR,UAAU,QAAQ,CAACS,sBAAsB,gBAAgB;IACzDT,UAAU,QAAQ,CAACU,yBAAyB,gBAAgB;IAC5DV,UAAU,QAAQ,CAACW,qBAAqB,gBAAgB;I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AC/B,MAAM;gBAAE,gBAAgB;YAAU;QACtC;IAcJ,MAAMG,2BAA2B,MAAMR,WAAW,gCAAgC,IACvEO;IAEXE,aAAaD;IAEb,MAAMR,WAAW,sBAAsB,IAAMU,gBAAgB1E;IAE7D,MAAM2E,oBAAoB,MAAMX,WAAW,0BAA0B,IAC1DO;IAKXE,aAAaE;IAEb,MAAMC,yBAAyB5E,UAAU,OAAO,CAAC6E;IACjD,MAAMb,WAAW,+BAA+B,IACrCY,uBAAuB,OAAO,CAACD;IAI1C,MAAMG,iBAAiB9E,UAAU,OAAO,CAAC+E;IACzC,MAAMf,WAAW,mCAAmC,IAAMc,eAAe,OAAO,CAAC9E;IAEjF,OAAOA;AACX"}
|
|
@@ -3,6 +3,7 @@ import { FeatureFlags } from "@webiny/feature-flags";
|
|
|
3
3
|
import { GetFeatureFlags } from "../abstractions/index.js";
|
|
4
4
|
const LICENSE_CHECKS = {
|
|
5
5
|
multiTenancy: (l)=>l.canUseFeature("multiTenancy"),
|
|
6
|
+
languages: (l)=>l.canUseLanguages(),
|
|
6
7
|
advancedPublishingWorkflow: (l)=>l.canUseWorkflows(),
|
|
7
8
|
advancedAccessControlLayer: (l)=>l.canUseAacl(),
|
|
8
9
|
"advancedAccessControlLayer.teams": (l)=>l.canUseTeams(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators/GetFeatureFlagsWithLicense.js","sources":["../../src/decorators/GetFeatureFlagsWithLicense.ts"],"sourcesContent":["import { License } from \"@webiny/wcp\";\nimport type { ILicense, DecryptedWcpProjectLicense } from \"@webiny/wcp/types.js\";\nimport { FeatureFlags } from \"@webiny/feature-flags\";\nimport type { FeatureFlagName } from \"@webiny/feature-flags\";\nimport { GetFeatureFlags } from \"~/abstractions/index.js\";\n\nconst LICENSE_CHECKS: Record<string, (license: ILicense) => boolean> = {\n multiTenancy: l => l.canUseFeature(\"multiTenancy\"),\n advancedPublishingWorkflow: l => l.canUseWorkflows(),\n advancedAccessControlLayer: l => l.canUseAacl(),\n \"advancedAccessControlLayer.teams\": l => l.canUseTeams(),\n \"advancedAccessControlLayer.privateFiles\": l => l.canUsePrivateFiles(),\n \"advancedAccessControlLayer.folderLevelPermissions\": l => l.canUseFolderLevelPermissions(),\n \"advancedAccessControlLayer.hcmsFieldPermissions\": l => l.canUseHcmsFieldPermissions(),\n auditLogs: l => l.canUseAuditLogs(),\n recordLocking: l => l.canUseRecordLocking(),\n \"fileManager.threatDetection\": l => l.canUseFileManagerThreatDetection(),\n abTesting: l => l.canUseAbTesting()\n};\n\nclass BuildLicenseDecoratedFeatureFlags extends FeatureFlags {\n constructor(\n private base: FeatureFlags,\n private license: ILicense\n ) {\n super(base.toDto());\n }\n\n override isEnabled(name: FeatureFlagName): boolean {\n const check = LICENSE_CHECKS[name];\n if (check) {\n if (!check(this.license)) {\n return false;\n }\n return !this.base.isExplicitlyDisabled(name);\n }\n if (!this.license.getRawLicense()) {\n return false;\n }\n return !this.base.isExplicitlyDisabled(name);\n }\n}\n\nclass GetFeatureFlagsWithLicenseDecorator implements GetFeatureFlags.Interface {\n constructor(private decoratee: GetFeatureFlags.Interface) {}\n\n async execute(): Promise<FeatureFlags> {\n const userFlags = await this.decoratee.execute();\n const license = this.getLicenseFromEnv();\n return new BuildLicenseDecoratedFeatureFlags(userFlags, license);\n }\n\n private getLicenseFromEnv(): ILicense {\n const licenseEnv = process.env.WCP_PROJECT_LICENSE;\n if (!licenseEnv) {\n return License.fromLicenseDto(null);\n }\n\n try {\n const licenseDto = JSON.parse(licenseEnv) as DecryptedWcpProjectLicense;\n return License.fromLicenseDto(licenseDto);\n } catch {\n return License.fromLicenseDto(null);\n }\n }\n}\n\nexport const getFeatureFlagsWithLicense = GetFeatureFlags.createDecorator({\n decorator: GetFeatureFlagsWithLicenseDecorator,\n dependencies: []\n});\n"],"names":["LICENSE_CHECKS","l","BuildLicenseDecoratedFeatureFlags","FeatureFlags","base","license","name","check","GetFeatureFlagsWithLicenseDecorator","decoratee","userFl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AiB;QACtC,OAAO,IAAIH,kCAAkCQ,WAAWL;IAC5D;IAEQ,oBAA8B;QAClC,MAAMM,aAAaC,QAAQ,GAAG,CAAC,mBAAmB;QAClD,IAAI,CAACD,YACD,OAAOE,QAAQ,cAAc,CAAC;QAGlC,IAAI;YACA,MAAMC,aAAaC,KAAK,KAAK,CAACJ;YAC9B,OAAOE,QAAQ,cAAc,CAACC;QAClC,EAAE,OAAM;YACJ,OAAOD,QAAQ,cAAc,CAAC;QAClC;IACJ;AACJ;AAEO,MAAMG,6BAA6BC,gBAAgB,eAAe,CAAC;IACtE,WAAWT;IACX,cAAc,EAAE;AACpB"}
|
|
1
|
+
{"version":3,"file":"decorators/GetFeatureFlagsWithLicense.js","sources":["../../src/decorators/GetFeatureFlagsWithLicense.ts"],"sourcesContent":["import { License } from \"@webiny/wcp\";\nimport type { ILicense, DecryptedWcpProjectLicense } from \"@webiny/wcp/types.js\";\nimport { FeatureFlags } from \"@webiny/feature-flags\";\nimport type { FeatureFlagName } from \"@webiny/feature-flags\";\nimport { GetFeatureFlags } from \"~/abstractions/index.js\";\n\nconst LICENSE_CHECKS: Record<string, (license: ILicense) => boolean> = {\n multiTenancy: l => l.canUseFeature(\"multiTenancy\"),\n languages: l => l.canUseLanguages(),\n advancedPublishingWorkflow: l => l.canUseWorkflows(),\n advancedAccessControlLayer: l => l.canUseAacl(),\n \"advancedAccessControlLayer.teams\": l => l.canUseTeams(),\n \"advancedAccessControlLayer.privateFiles\": l => l.canUsePrivateFiles(),\n \"advancedAccessControlLayer.folderLevelPermissions\": l => l.canUseFolderLevelPermissions(),\n \"advancedAccessControlLayer.hcmsFieldPermissions\": l => l.canUseHcmsFieldPermissions(),\n auditLogs: l => l.canUseAuditLogs(),\n recordLocking: l => l.canUseRecordLocking(),\n \"fileManager.threatDetection\": l => l.canUseFileManagerThreatDetection(),\n abTesting: l => l.canUseAbTesting()\n};\n\nclass BuildLicenseDecoratedFeatureFlags extends FeatureFlags {\n constructor(\n private base: FeatureFlags,\n private license: ILicense\n ) {\n super(base.toDto());\n }\n\n override isEnabled(name: FeatureFlagName): boolean {\n const check = LICENSE_CHECKS[name];\n if (check) {\n if (!check(this.license)) {\n return false;\n }\n return !this.base.isExplicitlyDisabled(name);\n }\n if (!this.license.getRawLicense()) {\n return false;\n }\n return !this.base.isExplicitlyDisabled(name);\n }\n}\n\nclass GetFeatureFlagsWithLicenseDecorator implements GetFeatureFlags.Interface {\n constructor(private decoratee: GetFeatureFlags.Interface) {}\n\n async execute(): Promise<FeatureFlags> {\n const userFlags = await this.decoratee.execute();\n const license = this.getLicenseFromEnv();\n return new BuildLicenseDecoratedFeatureFlags(userFlags, license);\n }\n\n private getLicenseFromEnv(): ILicense {\n const licenseEnv = process.env.WCP_PROJECT_LICENSE;\n if (!licenseEnv) {\n return License.fromLicenseDto(null);\n }\n\n try {\n const licenseDto = JSON.parse(licenseEnv) as DecryptedWcpProjectLicense;\n return License.fromLicenseDto(licenseDto);\n } catch {\n return License.fromLicenseDto(null);\n }\n }\n}\n\nexport const getFeatureFlagsWithLicense = GetFeatureFlags.createDecorator({\n decorator: GetFeatureFlagsWithLicenseDecorator,\n dependencies: []\n});\n"],"names":["LICENSE_CHECKS","l","BuildLicenseDecoratedFeatureFlags","FeatureFlags","base","license","name","check","GetFeatureFlagsWithLicenseDecorator","decoratee","userFlags","licenseEnv","process","License","licenseDto","JSON","getFeatureFlagsWithLicense","GetFeatureFlags"],"mappings":";;;AAMA,MAAMA,iBAAiE;IACnE,cAAcC,CAAAA,IAAKA,EAAE,aAAa,CAAC;IACnC,WAAWA,CAAAA,IAAKA,EAAE,eAAe;IACjC,4BAA4BA,CAAAA,IAAKA,EAAE,eAAe;IAClD,4BAA4BA,CAAAA,IAAKA,EAAE,UAAU;IAC7C,oCAAoCA,CAAAA,IAAKA,EAAE,WAAW;IACtD,2CAA2CA,CAAAA,IAAKA,EAAE,kBAAkB;IACpE,qDAAqDA,CAAAA,IAAKA,EAAE,4BAA4B;IACxF,mDA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tE,WAAWT;IACX,cAAc,EAAE;AACpB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import react, { useMemo } from "react";
|
|
2
2
|
import { Property, useIdGenerator } from "@webiny/react-properties";
|
|
3
|
+
import { assertHostingType } from "../extensions/hosting/assertHostingType.js";
|
|
4
|
+
import { getExtensionImplementation } from "../extensions/hosting/getExtensionImplementation.js";
|
|
3
5
|
const KeyValues = (props)=>{
|
|
4
6
|
const getId = useIdGenerator("");
|
|
5
7
|
return Object.entries(props).map(([key, value])=>/*#__PURE__*/ react.createElement(Property, {
|
|
@@ -10,7 +12,7 @@ const KeyValues = (props)=>{
|
|
|
10
12
|
}));
|
|
11
13
|
};
|
|
12
14
|
function createExtensionReactComponent(extensionParams) {
|
|
13
|
-
const
|
|
15
|
+
const ExtensionProperty = (props)=>{
|
|
14
16
|
const { name, remove, before, after, ...keyValues } = props;
|
|
15
17
|
const getId = useIdGenerator(extensionParams.type);
|
|
16
18
|
const propertyId = useMemo(()=>{
|
|
@@ -37,6 +39,12 @@ function createExtensionReactComponent(extensionParams) {
|
|
|
37
39
|
after: placeAfter
|
|
38
40
|
}, /*#__PURE__*/ react.createElement(KeyValuesComponent, null)), extensionParams.render && extensionParams.render(props));
|
|
39
41
|
};
|
|
42
|
+
const ExtensionReactComponent = (props)=>{
|
|
43
|
+
assertHostingType(extensionParams.type, extensionParams.tags.hosting);
|
|
44
|
+
const Implementation = getExtensionImplementation(extensionParams.type);
|
|
45
|
+
if (Implementation && Implementation !== ExtensionReactComponent) return /*#__PURE__*/ react.createElement(Implementation, props);
|
|
46
|
+
return /*#__PURE__*/ react.createElement(ExtensionProperty, props);
|
|
47
|
+
};
|
|
40
48
|
ExtensionReactComponent.displayName = `ExtensionReactComponent(${extensionParams.type})`;
|
|
41
49
|
return ExtensionReactComponent;
|
|
42
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineExtension/createExtensionReactComponent.js","sources":["../../src/defineExtension/createExtensionReactComponent.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Property, useIdGenerator } from \"@webiny/react-properties\";\nimport { type DefineExtensionParams } from \"./types.js\";\nimport { type z } from \"zod\";\n\nconst KeyValues = (props: Record<string, any>) => {\n const getId = useIdGenerator(\"\");\n return Object.entries(props).map(([key, value]) => {\n return <Property key={key} name={key} id={getId(key)} value={value} />;\n });\n};\n\ntype ExtensionReactComponentProps<TParamsSchema extends z.ZodTypeAny> = z.infer<TParamsSchema> & {\n remove?: boolean;\n before?: string;\n after?: string;\n name?: string;\n};\n\nexport function createExtensionReactComponent<TParamsSchema extends z.ZodTypeAny>(\n extensionParams: DefineExtensionParams<TParamsSchema>\n) {\n const
|
|
1
|
+
{"version":3,"file":"defineExtension/createExtensionReactComponent.js","sources":["../../src/defineExtension/createExtensionReactComponent.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Property, useIdGenerator } from \"@webiny/react-properties\";\nimport { type DefineExtensionParams } from \"./types.js\";\nimport { type z } from \"zod\";\nimport { assertHostingType } from \"~/extensions/hosting/assertHostingType.js\";\nimport { getExtensionImplementation } from \"~/extensions/hosting/getExtensionImplementation.js\";\n\nconst KeyValues = (props: Record<string, any>) => {\n const getId = useIdGenerator(\"\");\n return Object.entries(props).map(([key, value]) => {\n return <Property key={key} name={key} id={getId(key)} value={value} />;\n });\n};\n\ntype ExtensionReactComponentProps<TParamsSchema extends z.ZodTypeAny> = z.infer<TParamsSchema> & {\n remove?: boolean;\n before?: string;\n after?: string;\n name?: string;\n};\n\nexport function createExtensionReactComponent<TParamsSchema extends z.ZodTypeAny>(\n extensionParams: DefineExtensionParams<TParamsSchema>\n) {\n const ExtensionProperty: React.FC<ExtensionReactComponentProps<TParamsSchema>> = props => {\n const { name, remove, before, after, ...keyValues } = props;\n\n const getId = useIdGenerator(extensionParams.type);\n\n // By passing undefined, we're letting RP generate a unique ID for us.\n const propertyId = useMemo(() => {\n if (extensionParams.multiple) {\n return name ? getId(name) : undefined;\n }\n\n return getId(extensionParams.type);\n }, [name, extensionParams.multiple, getId]);\n\n const propertyName = name || extensionParams.type;\n\n const placeAfter = after !== undefined ? getId(after) : undefined;\n const placeBefore = before !== undefined ? getId(before) : undefined;\n\n // @ts-expect-error move KeyValues back inside the Property component to avoid this error\n const KeyValuesComponent = parentProps => <KeyValues {...parentProps} {...keyValues} />;\n\n return (\n <>\n <Property\n id={propertyId}\n name={propertyName}\n array={extensionParams.multiple}\n remove={remove}\n before={placeBefore}\n after={placeAfter}\n >\n <KeyValuesComponent />\n </Property>\n {extensionParams.render && extensionParams.render(props)}\n </>\n );\n };\n\n const ExtensionReactComponent: React.FC<\n ExtensionReactComponentProps<TParamsSchema>\n > = props => {\n assertHostingType(extensionParams.type, extensionParams.tags.hosting);\n\n /*\n * A hosting package may have registered its own component for this extension type. That\n * component is created by `defineExtension` too, so it finds itself here and renders as\n * usual.\n */\n const Implementation = getExtensionImplementation(extensionParams.type);\n if (Implementation && Implementation !== ExtensionReactComponent) {\n return <Implementation {...props} />;\n }\n\n return <ExtensionProperty {...props} />;\n };\n\n ExtensionReactComponent.displayName = `ExtensionReactComponent(${extensionParams.type})`;\n return ExtensionReactComponent;\n}\n"],"names":["KeyValues","props","getId","useIdGenerator","Object","key","value","Property","createExtensionReactComponent","extensionParams","ExtensionProperty","name","remove","before","after","keyValues","propertyId","useMemo","undefined","propertyName","placeAfter","placeBefore","KeyValuesComponent","parentProps","ExtensionReactComponent","assertHostingType","Implementation","getExtensionImplementation"],"mappings":";;;;AAOA,MAAMA,YAAY,CAACC;IACf,MAAMC,QAAQC,eAAe;IAC7B,OAAOC,OAAO,OAAO,CAACH,OAAO,GAAG,CAAC,CAAC,CAACI,KAAKC,MAAM,GACnC,WAAP,GAAO,oBAACC,UAAQA;YAAC,KAAKF;YAAK,MAAMA;YAAK,IAAIH,MAAMG;YAAM,OAAOC;;AAErE;AASO,SAASE,8BACZC,eAAqD;IAErD,MAAMC,oBAA2ET,CAAAA;QAC7E,MAAM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
|
3
3
|
import { type ExtensionInstanceModelContext } from "../defineExtension/index.js";
|
|
4
4
|
import { type AppName } from "../abstractions/types.js";
|
|
5
|
+
import { type ExtensionHosting } from "../extensions/hosting/hostingType.js";
|
|
5
6
|
export type ExtensionTags = {
|
|
6
7
|
[key: string]: string | undefined;
|
|
7
8
|
appName?: AppName;
|
|
8
9
|
runtimeContext?: "app-build" | "project" | "cli" | "pulumi";
|
|
10
|
+
hosting?: ExtensionHosting;
|
|
11
|
+
};
|
|
12
|
+
export type ExtensionDefinitionTags = ExtensionTags & {
|
|
13
|
+
hosting: ExtensionHosting;
|
|
9
14
|
};
|
|
10
15
|
export interface DefineExtensionParams<TParamsSchema extends z.ZodTypeAny> {
|
|
11
16
|
type: string;
|
|
12
|
-
tags:
|
|
17
|
+
tags: ExtensionDefinitionTags;
|
|
13
18
|
description?: string;
|
|
14
19
|
multiple?: boolean;
|
|
15
20
|
paramsSchema?: TParamsSchema | ((ctx: ExtensionInstanceModelContext) => TParamsSchema);
|
|
@@ -5,7 +5,8 @@ import { EnvVar } from "./EnvVar.js";
|
|
|
5
5
|
const AdminApiUrl = defineExtension({
|
|
6
6
|
type: "Admin/ApiUrl",
|
|
7
7
|
tags: {
|
|
8
|
-
runtimeContext: "project"
|
|
8
|
+
runtimeContext: "project",
|
|
9
|
+
hosting: "all"
|
|
9
10
|
},
|
|
10
11
|
description: "Set the API URL the Admin app talks to.",
|
|
11
12
|
paramsSchema: z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/AdminApiUrl.js","sources":["../../src/extensions/AdminApiUrl.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { EnvVar } from \"./EnvVar.js\";\n\n/**\n * Sets the URL the Admin app talks to, baked into the admin bundle as `WEBINY_ADMIN_API_URL`\n * (the admin runtime reads it, else falls back to same-origin). Because the config is evaluated\n * at build time, the value can come from any env var the user chooses, e.g.\n * `<Admin.ApiUrl url={process.env.MY_API_URL} />`.\n */\nexport const AdminApiUrl = defineExtension({\n type: \"Admin/ApiUrl\",\n tags: { runtimeContext: \"project\" },\n description: \"Set the API URL the Admin app talks to.\",\n paramsSchema: z.object({\n url: z\n .string()\n .describe(\"The API origin, e.g. https://api.example.com or http://localhost:3000\")\n }),\n render: props => {\n return <EnvVar varName=\"WEBINY_ADMIN_API_URL\" value={props.url} />;\n }\n});\n"],"names":["AdminApiUrl","defineExtension","z","props","EnvVar"],"mappings":";;;;AAWO,MAAMA,cAAcC,gBAAgB;IACvC,MAAM;IACN,MAAM;QAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"extensions/AdminApiUrl.js","sources":["../../src/extensions/AdminApiUrl.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { EnvVar } from \"./EnvVar.js\";\n\n/**\n * Sets the URL the Admin app talks to, baked into the admin bundle as `WEBINY_ADMIN_API_URL`\n * (the admin runtime reads it, else falls back to same-origin). Because the config is evaluated\n * at build time, the value can come from any env var the user chooses, e.g.\n * `<Admin.ApiUrl url={process.env.MY_API_URL} />`.\n */\nexport const AdminApiUrl = defineExtension({\n type: \"Admin/ApiUrl\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description: \"Set the API URL the Admin app talks to.\",\n paramsSchema: z.object({\n url: z\n .string()\n .describe(\"The API origin, e.g. https://api.example.com or http://localhost:3000\")\n }),\n render: props => {\n return <EnvVar varName=\"WEBINY_ADMIN_API_URL\" value={props.url} />;\n }\n});\n"],"names":["AdminApiUrl","defineExtension","z","props","EnvVar"],"mappings":";;;;AAWO,MAAMA,cAAcC,gBAAgB;IACvC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAW,SAAS;IAAM;IAClD,aAAa;IACb,cAAcC,EAAE,MAAM,CAAC;QACnB,KAAKA,EAAAA,MACM,GACN,QAAQ,CAAC;IAClB;IACA,QAAQC,CAAAA,QACG,WAAP,GAAO,oBAACC,QAAMA;YAAC,SAAQ;YAAuB,OAAOD,MAAM,GAAG;;AAEtE"}
|
|
@@ -94,7 +94,8 @@ const AdminBuildParam = defineExtension({
|
|
|
94
94
|
type: "Admin/BuildParam",
|
|
95
95
|
tags: {
|
|
96
96
|
runtimeContext: "app-build",
|
|
97
|
-
appName: "admin"
|
|
97
|
+
appName: "admin",
|
|
98
|
+
hosting: "all"
|
|
98
99
|
},
|
|
99
100
|
description: "Add build-time parameter to Admin app.",
|
|
100
101
|
multiple: true,
|
|
@@ -119,8 +120,7 @@ const AdminBuildParam = defineExtension({
|
|
|
119
120
|
if (!fs.existsSync(buildParamsDir)) fs.mkdirSync(buildParamsDir, {
|
|
120
121
|
recursive: true
|
|
121
122
|
});
|
|
122
|
-
|
|
123
|
-
const fileContent = `import { BuildParam } from "webiny/admin/build-params";
|
|
123
|
+
const fileContent = `import { BuildParam } from "webiny/admin/build-params";
|
|
124
124
|
|
|
125
125
|
class ${className} implements BuildParam.Interface {
|
|
126
126
|
key = "${paramName}";
|
|
@@ -132,8 +132,8 @@ export default BuildParam.createImplementation({
|
|
|
132
132
|
dependencies: []
|
|
133
133
|
});
|
|
134
134
|
`;
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf8") : void 0;
|
|
136
|
+
if (existing !== fileContent) fs.writeFileSync(filePath, fileContent, "utf8");
|
|
137
137
|
await generateBuildParamsFeature(buildParamsDir, ctx);
|
|
138
138
|
}
|
|
139
139
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/AdminBuildParam.js","sources":["../../src/extensions/AdminBuildParam.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport crypto from \"crypto\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { Node, Project } from \"ts-morph\";\n\nasync function generateBuildParamsFeature(buildParamsDir: string, ctx: any) {\n const featureFilePath = path.join(buildParamsDir, \"feature.ts\");\n\n // Get all BuildParam_*.ts files.\n const files = fs\n .readdirSync(buildParamsDir)\n .filter(f => f.startsWith(\"BuildParam_\") && f.endsWith(\".ts\") && f !== \"feature.ts\");\n\n // Generate imports and registrations.\n const imports = files\n .map(file => {\n const className = path.parse(file).name;\n return `import ${className} from \"./${className}.js\";`;\n })\n .join(\"\\n\");\n\n const registrations = files\n .map(file => {\n const className = path.parse(file).name;\n return ` container.register(${className});`;\n })\n .join(\"\\n\");\n\n const featureContent = `import { createFeature } from \"@webiny/feature/admin\";\nimport { Container } from \"@webiny/di\";\n${imports}\n\nexport const BuildParamsInternalFeature = createFeature({\n name: \"BuildParamsInternal\",\n register(container: Container) {\n${registrations}\n }\n});\n`;\n\n fs.writeFileSync(featureFilePath, featureContent, \"utf8\");\n\n // Now we need to update Extensions.tsx to use RegisterFeature with this feature.\n await updateExtensionsTsx(ctx);\n}\n\nasync function updateExtensionsTsx(ctx: any) {\n const extensionsTsxFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"src\", \"Extensions.tsx\")\n .toString();\n\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsxFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsxFilePath);\n\n // Check if we already have the imports.\n const buildParamsFeatureImport = \"./buildParams/feature.js\";\n const existingFeatureImport = source.getImportDeclaration(buildParamsFeatureImport);\n\n if (!existingFeatureImport) {\n let index = 1;\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 BuildParamsInternalFeature.\n source.insertImportDeclaration(index, {\n namedImports: [\"BuildParamsInternalFeature\"],\n moduleSpecifier: buildParamsFeatureImport\n });\n\n // Add import for BuildParamsFeature.\n const buildParamsFeatureImportPath = \"@webiny/app-admin\";\n const existingBuildParamsImport = source.getImportDeclaration(buildParamsFeatureImportPath);\n\n if (!existingBuildParamsImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"BuildParamsFeature\"],\n moduleSpecifier: buildParamsFeatureImportPath\n });\n } else {\n // Add to existing import if BuildParamsFeature not already there.\n const namedImports = existingBuildParamsImport.getNamedImports();\n const hasBuildParamsFeature = namedImports.some(\n ni => ni.getName() === \"BuildParamsFeature\"\n );\n if (!hasBuildParamsFeature) {\n existingBuildParamsImport.addNamedImport(\"BuildParamsFeature\");\n }\n }\n\n // Add import for RegisterFeature if not present.\n const registerFeatureImportPath = \"@webiny/app-admin\";\n const existingRegisterFeatureImport =\n source.getImportDeclaration(registerFeatureImportPath);\n\n if (existingRegisterFeatureImport) {\n const namedImports = existingRegisterFeatureImport.getNamedImports();\n const hasRegisterFeature = namedImports.some(ni => ni.getName() === \"RegisterFeature\");\n if (!hasRegisterFeature) {\n existingRegisterFeatureImport.addNamedImport(\"RegisterFeature\");\n }\n } else {\n source.insertImportDeclaration(index, {\n namedImports: [\"RegisterFeature\"],\n moduleSpecifier: registerFeatureImportPath\n });\n }\n }\n\n // Now add <RegisterFeature> components to the Extensions component.\n const extensionsIdentifier = source.getFirstDescendant(node => {\n if (!Node.isIdentifier(node)) {\n return false;\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}\".`\n );\n }\n\n const extensionsArrowFn = extensionsIdentifier.getNextSibling(node =>\n Node.isArrowFunction(node)\n );\n\n if (!extensionsArrowFn) {\n throw new Error(`Could not find the \"Extensions\" React component arrow function.`);\n }\n\n const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant(node => {\n return Node.isJsxFragment(node);\n });\n\n if (!extensionsArrowFnFragment) {\n throw new Error(`Could not find JSX fragment in Extensions component.`);\n }\n\n const currentContent = extensionsArrowFnFragment\n .getFullText()\n .replace(\"<>\", \"\")\n .replace(\"</>\", \"\")\n .trim();\n\n // Check if we already have the RegisterFeature components.\n if (!currentContent.includes(\"BuildParamsFeature\")) {\n const newContent = `<><RegisterFeature feature={BuildParamsFeature} /><RegisterFeature feature={BuildParamsInternalFeature} />${currentContent}</>`;\n extensionsArrowFnFragment.replaceWithText(newContent);\n }\n\n await source.save();\n}\n\nexport const AdminBuildParam = defineExtension({\n type: \"Admin/BuildParam\",\n tags: { runtimeContext: \"app-build\", appName: \"admin\" },\n description: \"Add build-time parameter to Admin 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 buildParamsDir = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"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 // Create the BuildParam implementation file.\n const fileContent = `import { BuildParam } from \"webiny/admin/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 we need to generate/update the feature file that imports all BuildParams.\n await generateBuildParamsFeature(buildParamsDir, ctx);\n }\n});\n"],"names":["generateBuildParamsFeature","buildParamsDir","ctx","featureFilePath","path","files","fs","f","imports","file","className","registrations","featureContent","updateExtensionsTsx","extensionsTsxFilePath","project","Project","source","buildParamsFeatureImport","existingFeatureImport","index","importDeclarations","last","buildParamsFeatureImportPath","existingBuildParamsImport","namedImports","hasBuildParamsFeature","ni","registerFeatureImportPath","existingRegisterFeatureImport","hasRegisterFeature","extensionsIdentifier","node","Node","Error","extensionsArrowFn","extensionsArrowFnFragment","currentContent","newContent","AdminBuildParam","defineExtension","z","params","paramName","value","valueStr","JSON","hash","crypto","fileName","filePath","fileContent"],"mappings":";;;;;;AAOA,eAAeA,2BAA2BC,cAAsB,EAAEC,GAAQ;IACtE,MAAMC,kBAAkBC,KAAK,IAAI,CAACH,gBAAgB;IAGlD,MAAMI,QAAQC,GAAAA,WACE,CAACL,gBACZ,MAAM,CAACM,CAAAA,IAAKA,EAAE,UAAU,CAAC,kBAAkBA,EAAE,QAAQ,CAAC,UAAUA,AAAM,iBAANA;IAGrE,MAAMC,UAAUH,MACX,GAAG,CAACI,CAAAA;QACD,MAAMC,YAAYN,KAAK,KAAK,CAACK,MAAM,IAAI;QACvC,OAAO,CAAC,OAAO,EAAEC,UAAU,SAAS,EAAEA,UAAU,KAAK,CAAC;IAC1D,GACC,IAAI,CAAC;IAEV,MAAMC,gBAAgBN,MACjB,GAAG,CAACI,CAAAA;QACD,MAAMC,YAAYN,KAAK,KAAK,CAACK,MAAM,IAAI;QACvC,OAAO,CAAC,2BAA2B,EAAEC,UAAU,EAAE,CAAC;IACtD,GACC,IAAI,CAAC;IAEV,MAAME,iBAAiB,CAAC;;AAE5B,EAAEJ,QAAQ;;;;;AAKV,EAAEG,cAAc;;;AAGhB,CAAC;IAEGL,GAAG,aAAa,CAACH,iBAAiBS,gBAAgB;IAGlD,MAAMC,oBAAoBX;AAC9B;AAEA,eAAeW,oBAAoBX,GAAQ;IACvC,MAAMY,wBAAwBZ,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CAC1D,IAAI,CAAC,QAAQ,SAAS,OAAO,kBAC7B,QAAQ;IAEb,MAAMa,UAAU,IAAIC;IACpBD,QAAQ,mBAAmB,CAACD;IAE5B,MAAMG,SAASF,QAAQ,oBAAoB,CA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A,UAAiB,CAAC,UAAU,MAAM,CAACL,WAAW,MAAM,CAAC;QAClE,MAAMjC,YAAY,CAAC,WAAW,EAAEqC,KAAK,KAAK,CAAC,MAAM;QACjD,MAAME,WAAW,GAAGvC,UAAU,GAAG,CAAC;QAClC,MAAMwC,WAAW9C,KAAK,IAAI,CAACH,gBAAgBgD;QAG3C,IAAI,CAAC3C,GAAG,UAAU,CAACL,iBACfK,GAAG,SAAS,CAACL,gBAAgB;YAAE,WAAW;QAAK;QAInD,IAAI,CAACK,GAAG,UAAU,CAAC4C,WAAW;YAE1B,MAAMC,cAAc,CAAC;;MAE3B,EAAEzC,UAAU;WACP,EAAEiC,UAAU;YACX,EAAEE,SAAS;;;;oBAIH,EAAEnC,UAAU;;;AAGhC,CAAC;YACWJ,GAAG,aAAa,CAAC4C,UAAUC,aAAa;QAC5C;QAGA,MAAMnD,2BAA2BC,gBAAgBC;IACrD;AACJ"}
|
|
1
|
+
{"version":3,"file":"extensions/AdminBuildParam.js","sources":["../../src/extensions/AdminBuildParam.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport crypto from \"crypto\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { Node, Project } from \"ts-morph\";\n\nasync function generateBuildParamsFeature(buildParamsDir: string, ctx: any) {\n const featureFilePath = path.join(buildParamsDir, \"feature.ts\");\n\n // Get all BuildParam_*.ts files.\n const files = fs\n .readdirSync(buildParamsDir)\n .filter(f => f.startsWith(\"BuildParam_\") && f.endsWith(\".ts\") && f !== \"feature.ts\");\n\n // Generate imports and registrations.\n const imports = files\n .map(file => {\n const className = path.parse(file).name;\n return `import ${className} from \"./${className}.js\";`;\n })\n .join(\"\\n\");\n\n const registrations = files\n .map(file => {\n const className = path.parse(file).name;\n return ` container.register(${className});`;\n })\n .join(\"\\n\");\n\n const featureContent = `import { createFeature } from \"@webiny/feature/admin\";\nimport { Container } from \"@webiny/di\";\n${imports}\n\nexport const BuildParamsInternalFeature = createFeature({\n name: \"BuildParamsInternal\",\n register(container: Container) {\n${registrations}\n }\n});\n`;\n\n fs.writeFileSync(featureFilePath, featureContent, \"utf8\");\n\n // Now we need to update Extensions.tsx to use RegisterFeature with this feature.\n await updateExtensionsTsx(ctx);\n}\n\nasync function updateExtensionsTsx(ctx: any) {\n const extensionsTsxFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"src\", \"Extensions.tsx\")\n .toString();\n\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsxFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsxFilePath);\n\n // Check if we already have the imports.\n const buildParamsFeatureImport = \"./buildParams/feature.js\";\n const existingFeatureImport = source.getImportDeclaration(buildParamsFeatureImport);\n\n if (!existingFeatureImport) {\n let index = 1;\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 BuildParamsInternalFeature.\n source.insertImportDeclaration(index, {\n namedImports: [\"BuildParamsInternalFeature\"],\n moduleSpecifier: buildParamsFeatureImport\n });\n\n // Add import for BuildParamsFeature.\n const buildParamsFeatureImportPath = \"@webiny/app-admin\";\n const existingBuildParamsImport = source.getImportDeclaration(buildParamsFeatureImportPath);\n\n if (!existingBuildParamsImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"BuildParamsFeature\"],\n moduleSpecifier: buildParamsFeatureImportPath\n });\n } else {\n // Add to existing import if BuildParamsFeature not already there.\n const namedImports = existingBuildParamsImport.getNamedImports();\n const hasBuildParamsFeature = namedImports.some(\n ni => ni.getName() === \"BuildParamsFeature\"\n );\n if (!hasBuildParamsFeature) {\n existingBuildParamsImport.addNamedImport(\"BuildParamsFeature\");\n }\n }\n\n // Add import for RegisterFeature if not present.\n const registerFeatureImportPath = \"@webiny/app-admin\";\n const existingRegisterFeatureImport =\n source.getImportDeclaration(registerFeatureImportPath);\n\n if (existingRegisterFeatureImport) {\n const namedImports = existingRegisterFeatureImport.getNamedImports();\n const hasRegisterFeature = namedImports.some(ni => ni.getName() === \"RegisterFeature\");\n if (!hasRegisterFeature) {\n existingRegisterFeatureImport.addNamedImport(\"RegisterFeature\");\n }\n } else {\n source.insertImportDeclaration(index, {\n namedImports: [\"RegisterFeature\"],\n moduleSpecifier: registerFeatureImportPath\n });\n }\n }\n\n // Now add <RegisterFeature> components to the Extensions component.\n const extensionsIdentifier = source.getFirstDescendant(node => {\n if (!Node.isIdentifier(node)) {\n return false;\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}\".`\n );\n }\n\n const extensionsArrowFn = extensionsIdentifier.getNextSibling(node =>\n Node.isArrowFunction(node)\n );\n\n if (!extensionsArrowFn) {\n throw new Error(`Could not find the \"Extensions\" React component arrow function.`);\n }\n\n const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant(node => {\n return Node.isJsxFragment(node);\n });\n\n if (!extensionsArrowFnFragment) {\n throw new Error(`Could not find JSX fragment in Extensions component.`);\n }\n\n const currentContent = extensionsArrowFnFragment\n .getFullText()\n .replace(\"<>\", \"\")\n .replace(\"</>\", \"\")\n .trim();\n\n // Check if we already have the RegisterFeature components.\n if (!currentContent.includes(\"BuildParamsFeature\")) {\n const newContent = `<><RegisterFeature feature={BuildParamsFeature} /><RegisterFeature feature={BuildParamsInternalFeature} />${currentContent}</>`;\n extensionsArrowFnFragment.replaceWithText(newContent);\n }\n\n await source.save();\n}\n\nexport const AdminBuildParam = defineExtension({\n type: \"Admin/BuildParam\",\n tags: { runtimeContext: \"app-build\", appName: \"admin\", hosting: \"all\" },\n description: \"Add build-time parameter to Admin 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 buildParamsDir = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"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 // Written when missing or when its value changed (a config edit), and left alone when equal,\n // so an unchanged param doesn't trigger a rebuild.\n const fileContent = `import { BuildParam } from \"webiny/admin/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 const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, \"utf8\") : undefined;\n if (existing !== fileContent) {\n fs.writeFileSync(filePath, fileContent, \"utf8\");\n }\n\n // Now we need to generate/update the feature file that imports all BuildParams.\n await generateBuildParamsFeature(buildParamsDir, ctx);\n }\n});\n"],"names":["generateBuildParamsFeature","buildParamsDir","ctx","featureFilePath","path","files","fs","f","imports","file","className","registrations","featureContent","updateExtensionsTsx","extensionsTsxFilePath","project","Project","source","buildParamsFeatureImport","existingFeatureImport","index","importDeclarations","last","buildParamsFeatureImportPath","existingBuildParamsImport","namedImports","hasBuildParamsFeature","ni","registerFeatureImportPath","existingRegisterFeatureImport","hasRegisterFeature","extensionsIdentifier","node","Node","Error","extensionsArrowFn","extensionsArrowFnFragment","currentContent","newContent","AdminBuildParam","defineExtension","z","params","paramName","value","valueStr","JSON","hash","crypto","fileName","filePath","fileContent","existing","undefined"],"mappings":";;;;;;AAOA,eAAeA,2BAA2BC,cAAsB,EAAEC,GAAQ;IACtE,MAAMC,kBAAkBC,KAAK,IAAI,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;QAKnD,MAAMkD,cAAc,CAAC;;MAEvB,EAAEzC,UAAU;WACP,EAAEiC,UAAU;YACX,EAAEE,SAAS;;;;oBAIH,EAAEnC,UAAU;;;AAGhC,CAAC;QACO,MAAM0C,WAAW9C,GAAG,UAAU,CAAC4C,YAAY5C,GAAG,YAAY,CAAC4C,UAAU,UAAUG;QAC/E,IAAID,aAAaD,aACb7C,GAAG,aAAa,CAAC4C,UAAUC,aAAa;QAI5C,MAAMnD,2BAA2BC,gBAAgBC;IACrD;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const AdminExtension: import("~/
|
|
2
|
+
export declare const AdminExtension: import("~/defineExtension/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
3
|
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
4
4
|
exportName: z.ZodOptional<z.ZodString>;
|
|
5
5
|
}, z.core.$strip>>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { defineExtension, zodSrcPath } from "
|
|
1
|
+
import { defineExtension, zodSrcPath } from "../defineExtension/index.js";
|
|
2
2
|
import { ExtensionSrcResolver } from "../index.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { Node, Project } from "ts-morph";
|
|
6
6
|
import crypto_0 from "crypto";
|
|
7
|
+
import { hasDefaultExport } from "./hasDefaultExport.js";
|
|
7
8
|
const AdminExtension = defineExtension({
|
|
8
9
|
type: "Admin/Extension",
|
|
9
10
|
tags: {
|
|
10
11
|
runtimeContext: "app-build",
|
|
11
|
-
appName: "admin"
|
|
12
|
+
appName: "admin",
|
|
13
|
+
hosting: "all"
|
|
12
14
|
},
|
|
13
15
|
description: "Extend the Admin application with custom functionality.",
|
|
14
16
|
multiple: true,
|
|
@@ -35,14 +37,13 @@ const AdminExtension = defineExtension({
|
|
|
35
37
|
const extensionProject = new Project();
|
|
36
38
|
extensionProject.addSourceFileAtPath(absoluteExtensionFilePath);
|
|
37
39
|
const extensionSource = extensionProject.getSourceFileOrThrow(absoluteExtensionFilePath);
|
|
38
|
-
const hasDefaultExport = void 0 !== extensionSource.getDefaultExportSymbol();
|
|
39
40
|
let index = 1;
|
|
40
41
|
const importDeclarations = source.getImportDeclarations();
|
|
41
42
|
if (importDeclarations.length) {
|
|
42
43
|
const last = importDeclarations[importDeclarations.length - 1];
|
|
43
44
|
index = last.getChildIndex() + 1;
|
|
44
45
|
}
|
|
45
|
-
if (hasDefaultExport) source.insertImportDeclaration(index, {
|
|
46
|
+
if (hasDefaultExport(extensionSource)) source.insertImportDeclaration(index, {
|
|
46
47
|
defaultImport: componentName,
|
|
47
48
|
moduleSpecifier: importPath
|
|
48
49
|
});
|
|
@@ -64,7 +65,7 @@ const AdminExtension = defineExtension({
|
|
|
64
65
|
if (!extensionsArrowFn) throw new Error(`Could not find the "Extensions" React component in "${extensionsTsxFilePath}". Did you maybe change its definition? It should be an arrow function.`);
|
|
65
66
|
const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant((node)=>Node.isJsxFragment(node));
|
|
66
67
|
const extensionsArrowFnFragmentChildrenText = extensionsArrowFnFragment.getFullText().replace("<>", "").replace("</>", "").trim();
|
|
67
|
-
extensionsArrowFnFragment.replaceWithText(
|
|
68
|
+
extensionsArrowFnFragment.replaceWithText(`<>${extensionsArrowFnFragmentChildrenText}<${componentName}/></>`);
|
|
68
69
|
await source.save();
|
|
69
70
|
}
|
|
70
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/AdminExtension.js","sources":["../../src/extensions/AdminExtension.ts"],"sourcesContent":["import { defineExtension
|
|
1
|
+
{"version":3,"file":"extensions/AdminExtension.js","sources":["../../src/extensions/AdminExtension.ts"],"sourcesContent":["import { defineExtension } from \"~/defineExtension/index.js\";\nimport { zodSrcPath } from \"~/defineExtension/index.js\";\nimport { ExtensionSrcResolver } from \"~/index.js\";\nimport { z } from \"zod\";\nimport path from \"path\";\nimport { type JsxFragment, Node, Project } from \"ts-morph\";\nimport crypto from \"crypto\";\nimport { hasDefaultExport } from \"./hasDefaultExport.js\";\n\nexport const AdminExtension = defineExtension({\n type: \"Admin/Extension\",\n tags: { runtimeContext: \"app-build\", appName: \"admin\", hosting: \"all\" },\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\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(extensionSource)) {\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 /*\n * Append, so extensions mount in the order they're declared, as API extensions register (see\n * ApiExtension). A decorator mounted later wraps the earlier ones, so the last declared\n * extension's decorators are the outermost: project extensions override Webiny's defaults.\n */\n extensionsArrowFnFragment.replaceWithText(\n `<>${extensionsArrowFnFragmentChildrenText}<${componentName}/></>`\n );\n\n await source.save();\n }\n});\n"],"names":["AdminExtension","defineExtension","project","z","zodSrcPath","params","ctx","extensionsTsxFilePath","extensionFilePath","absoluteExtensionFilePath","ExtensionSrcResolver","extensionFileName","path","exportName","hash","crypto","componentName","Project","importPath","source","existingImportDeclaration","extensionProject","extensionSource","index","importDeclarations","last","hasDefaultExport","extensionsIdentifier","node","Node","Error","extensionsArrowFn","extensionsArrowFnFragment","extensionsArrowFnFragmentChildrenText"],"mappings":";;;;;;;AASO,MAAMA,iBAAiBC,gBAAgB;IAC1C,MAAM;IACN,MAAM;QAAE,gB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AmB,MAAM,GAAG,EAAE;YAC9DD,QAAQE,KAAK,aAAa,KAAK;QACnC;QAGA,IAAIC,iBAAiBJ,kBACjBH,OAAO,uBAAuB,CAACI,OAAO;YAClC,eAAeP;YACf,iBAAiBE;QACrB;aAEAC,OAAO,uBAAuB,CAACI,OAAO;YAClC,cAAc;gBAAC;oBAAE,MAAMV;oBAAY,OAAOG;gBAAc;aAAE;YAC1D,iBAAiBE;QACrB;QAGJ,MAAMS,uBAAuBR,OAAO,kBAAkB,CAACS,CAAAA;YACnD,IAAI,CAACC,KAAK,YAAY,CAACD,OACnB,OAAO;YAGX,OAAOA,AAAmB,iBAAnBA,KAAK,OAAO;QACvB;QAEA,IAAI,CAACD,sBACD,MAAM,IAAIG,MACN,CAAC,oDAAoD,EAAEvB,sBAAsB,kDAAkD,CAAC;QAIxI,MAAMwB,oBAAoBJ,qBAAqB,cAAc,CAACC,CAAAA,OAC1DC,KAAK,eAAe,CAACD;QAEzB,IAAI,CAACG,mBACD,MAAM,IAAID,MACN,CAAC,oDAAoD,EAAEvB,sBAAsB,uEAAuE,CAAC;QAI7J,MAAMyB,4BAA4BD,kBAAkB,kBAAkB,CAACH,CAAAA,OAC5DC,KAAK,aAAa,CAACD;QAG9B,MAAMK,wCAAwCD,0BACzC,WAAW,GACX,OAAO,CAAC,MAAM,IACd,OAAO,CAAC,OAAO,IACf,IAAI;QAOTA,0BAA0B,eAAe,CACrC,CAAC,EAAE,EAAEC,sCAAsC,CAAC,EAAEjB,cAAc,KAAK,CAAC;QAGtE,MAAMG,OAAO,IAAI;IACrB;AACJ"}
|
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
/**
|
|
3
3
|
* Sets a dedicated WebSocket URL for the Admin app, baked into the admin bundle as
|
|
4
4
|
* `WEBINY_ADMIN_WS_API_URL`. This is optional: when omitted, the admin derives the WebSocket URL
|
|
5
|
-
* from the API URL (same origin, http -> ws), which is what the
|
|
5
|
+
* from the API URL (same origin, http -> ws), which is what the standalone hosting type needs by
|
|
6
6
|
* default. Set it only when WebSockets are served from a different origin than the API. Because the
|
|
7
7
|
* config is evaluated at build time, the value can come from any env var the user chooses, e.g.
|
|
8
8
|
* `<Admin.WebsocketsUrl url={process.env.MY_WS_URL} />`.
|
|
@@ -5,7 +5,8 @@ import { EnvVar } from "./EnvVar.js";
|
|
|
5
5
|
const AdminWebsocketsUrl = defineExtension({
|
|
6
6
|
type: "Admin/WebsocketsUrl",
|
|
7
7
|
tags: {
|
|
8
|
-
runtimeContext: "project"
|
|
8
|
+
runtimeContext: "project",
|
|
9
|
+
hosting: "all"
|
|
9
10
|
},
|
|
10
11
|
description: "Set a dedicated WebSocket URL for the Admin app.",
|
|
11
12
|
paramsSchema: z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/AdminWebsocketsUrl.js","sources":["../../src/extensions/AdminWebsocketsUrl.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { EnvVar } from \"./EnvVar.js\";\n\n/**\n * Sets a dedicated WebSocket URL for the Admin app, baked into the admin bundle as\n * `WEBINY_ADMIN_WS_API_URL`. This is optional: when omitted, the admin derives the WebSocket URL\n * from the API URL (same origin, http -> ws), which is what the
|
|
1
|
+
{"version":3,"file":"extensions/AdminWebsocketsUrl.js","sources":["../../src/extensions/AdminWebsocketsUrl.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { EnvVar } from \"./EnvVar.js\";\n\n/**\n * Sets a dedicated WebSocket URL for the Admin app, baked into the admin bundle as\n * `WEBINY_ADMIN_WS_API_URL`. This is optional: when omitted, the admin derives the WebSocket URL\n * from the API URL (same origin, http -> ws), which is what the standalone hosting type needs by\n * default. Set it only when WebSockets are served from a different origin than the API. Because the\n * config is evaluated at build time, the value can come from any env var the user chooses, e.g.\n * `<Admin.WebsocketsUrl url={process.env.MY_WS_URL} />`.\n */\nexport const AdminWebsocketsUrl = defineExtension({\n type: \"Admin/WebsocketsUrl\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description: \"Set a dedicated WebSocket URL for the Admin app.\",\n paramsSchema: z.object({\n url: z\n .string()\n .describe(\"The WebSocket origin, e.g. wss://ws.example.com or ws://localhost:3002\")\n }),\n render: props => {\n return <EnvVar varName=\"WEBINY_ADMIN_WS_API_URL\" value={props.url} />;\n }\n});\n"],"names":["AdminWebsocketsUrl","defineExtension","z","props","EnvVar"],"mappings":";;;;AAaO,MAAMA,qBAAqBC,gBAAgB;IAC9C,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAW,SAAS;IAAM;IAClD,aAAa;IACb,cAAcC,EAAE,MAAM,CAAC;QACnB,KAAKA,EAAAA,MACM,GACN,QAAQ,CAAC;IAClB;IACA,QAAQC,CAAAA,QACG,WAAP,GAAO,oBAACC,QAAMA;YAAC,SAAQ;YAA0B,OAAOD,MAAM,GAAG;;AAEzE"}
|