@webiny/project 0.0.0-unstable.e2758ee1cf → 0.0.0-unstable.e6f0dc8ca7
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/DeployApp.d.ts +0 -1
- package/abstractions/features/DeployApp.js.map +1 -1
- package/abstractions/features/index.d.ts +0 -1
- package/abstractions/features/index.js +0 -1
- package/abstractions/features/index.js.map +1 -1
- package/defineExtension/models/ExtensionDefinitionModel.d.ts +4 -4
- package/defineExtension/models/ExtensionDefinitionModel.js.map +1 -1
- package/defineExtension/models/ExtensionInstanceModel.js +4 -1
- package/defineExtension/models/ExtensionInstanceModel.js.map +1 -1
- package/defineExtension/zodTypes/zodSrcPath.d.ts +1 -1
- package/defineExtension/zodTypes/zodSrcPath.js +11 -0
- package/defineExtension/zodTypes/zodSrcPath.js.map +1 -1
- package/exports/infra/admin.d.ts +0 -1
- package/exports/infra/admin.js +0 -1
- package/exports/infra/admin.js.map +1 -1
- package/exports/infra/api.d.ts +0 -1
- package/exports/infra/api.js +0 -1
- package/exports/infra/api.js.map +1 -1
- package/exports/infra/core.d.ts +0 -1
- package/exports/infra/core.js +0 -1
- package/exports/infra/core.js.map +1 -1
- package/exports/infra.d.ts +8 -0
- package/exports/infra.js +10 -0
- package/exports/{infra/index.js.map → infra.js.map} +1 -1
- package/extensions/AdminBuildParam.d.ts +2 -8
- package/extensions/AdminBuildParam.js +1 -1
- package/extensions/AdminBuildParam.js.map +1 -1
- package/extensions/AdminExtension.d.ts +2 -8
- package/extensions/ApiBuildParam.d.ts +2 -8
- package/extensions/ApiBuildParam.js +4 -4
- package/extensions/ApiBuildParam.js.map +1 -1
- package/extensions/ApiExtension.d.ts +2 -8
- package/extensions/ApiExtension.js +5 -5
- package/extensions/ApiExtension.js.map +1 -1
- package/extensions/DatabaseSetup.d.ts +7 -7
- package/extensions/EnvVar.d.ts +4 -7
- package/extensions/EnvVar.js +4 -0
- package/extensions/EnvVar.js.map +1 -1
- package/extensions/ExtensionDefinitions.d.ts +1 -5
- package/extensions/FeatureFlags.d.ts +17 -79
- package/extensions/FeatureFlags.js +12 -0
- package/extensions/FeatureFlags.js.map +1 -1
- package/extensions/Project/EnsureTelemetryEnabledForOss.js +1 -1
- package/extensions/Project/EnsureTelemetryEnabledForOss.js.map +1 -1
- package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js +1 -0
- package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js.map +1 -1
- package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js +1 -0
- package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js.map +1 -1
- package/extensions/Project/ValidateEncryptionBeforeDeploy.d.ts +12 -0
- package/extensions/Project/ValidateEncryptionBeforeDeploy.js +32 -0
- package/extensions/Project/ValidateEncryptionBeforeDeploy.js.map +1 -0
- package/extensions/Project.js +2 -0
- package/extensions/Project.js.map +1 -1
- package/extensions/ProjectDecorator.d.ts +3 -7
- package/extensions/ProjectId.d.ts +3 -7
- package/extensions/ProjectId.js +1 -1
- package/extensions/ProjectId.js.map +1 -1
- package/extensions/ProjectImplementation.d.ts +3 -9
- package/extensions/Telemetry.d.ts +2 -6
- package/extensions/hooks/AdminAfterBuild.d.ts +2 -6
- package/extensions/hooks/AdminAfterDeploy.d.ts +2 -6
- package/extensions/hooks/AdminBeforeBuild.d.ts +2 -6
- package/extensions/hooks/AdminBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/AdminBeforeWatch.d.ts +2 -6
- package/extensions/hooks/AfterBuild.d.ts +2 -6
- package/extensions/hooks/AfterDeploy.d.ts +2 -6
- package/extensions/hooks/ApiAfterBuild.d.ts +2 -6
- package/extensions/hooks/ApiAfterDeploy.d.ts +2 -6
- package/extensions/hooks/ApiBeforeBuild.d.ts +2 -6
- package/extensions/hooks/ApiBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/ApiBeforeWatch.d.ts +2 -6
- package/extensions/hooks/BeforeBuild.d.ts +2 -6
- package/extensions/hooks/BeforeDeploy.d.ts +2 -6
- package/extensions/hooks/BeforeWatch.d.ts +2 -6
- package/extensions/hooks/CoreAfterBuild.d.ts +2 -6
- package/extensions/hooks/CoreAfterDeploy.d.ts +2 -6
- package/extensions/hooks/CoreBeforeBuild.d.ts +2 -6
- package/extensions/hooks/CoreBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/CoreBeforeWatch.d.ts +2 -6
- package/extensions/index.d.ts +38 -145
- package/extensions/index.js +5 -8
- package/extensions/index.js.map +1 -1
- package/extensions/infra/Ci.d.ts +14 -0
- package/extensions/infra/Ci.js +29 -0
- package/extensions/infra/Ci.js.map +1 -0
- package/extensions/infra/Env.d.ts +6 -0
- package/extensions/infra/Env.js +21 -0
- package/extensions/infra/Env.js.map +1 -1
- package/extensions/infra/index.d.ts +1 -0
- package/extensions/infra/index.js +1 -0
- package/extensions/infra/index.js.map +1 -1
- package/extensions/pulumi/AdminStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/ApiStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/CoreStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/ProductionEnvironments.d.ts +2 -6
- package/extensions/pulumi/ProductionEnvironments.js +16 -1
- package/extensions/pulumi/ProductionEnvironments.js.map +1 -1
- package/extensions/pulumi/PulumiResourceNamePrefix.d.ts +1 -5
- package/extensions/pulumi/index.d.ts +0 -3
- package/extensions/pulumi/index.js +0 -3
- package/extensions/pulumi/index.js.map +1 -1
- package/features/BuildApp/PackagesBuilder/worker.js +1 -1
- package/features/BuildApp/PackagesBuilder/worker.js.map +1 -1
- package/features/GetFeatureFlags/GetFeatureFlags.d.ts +1 -2
- package/features/GetFeatureFlags/GetFeatureFlags.js +1 -2
- package/features/GetFeatureFlags/GetFeatureFlags.js.map +1 -1
- package/features/Watch/initInvocationForwarding.d.ts +1 -1
- package/features/Watch/initInvocationForwarding.js +1 -1
- package/features/Watch/initInvocationForwarding.js.map +1 -1
- package/features/Watch/localInvocationWorker.js +5 -1
- package/features/Watch/localInvocationWorker.js.map +1 -1
- package/features/index.d.ts +0 -1
- package/features/index.js +0 -1
- package/features/index.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +38 -39
- package/services/BuildAppWorkspaceService/BuildAppWorkspaceService.js +4 -4
- package/services/BuildAppWorkspaceService/BuildAppWorkspaceService.js.map +1 -1
- package/services/GetProjectConfigService/GetProjectConfigService.js +2 -1
- package/services/GetProjectConfigService/GetProjectConfigService.js.map +1 -1
- package/services/GetProjectConfigService/ProductionEnvironmentsContext.d.ts +6 -0
- package/services/GetProjectConfigService/ProductionEnvironmentsContext.js +21 -0
- package/services/GetProjectConfigService/ProductionEnvironmentsContext.js.map +1 -0
- package/services/GetProjectConfigService/renderConfigWorker.js +14 -4
- package/services/GetProjectConfigService/renderConfigWorker.js.map +1 -1
- package/services/GetProjectIdService/GetProjectIdService.js +1 -1
- package/services/GetProjectIdService/GetProjectIdService.js.map +1 -1
- package/services/GetProjectService/GetProjectService.js +2 -2
- package/services/GetProjectService/GetProjectService.js.map +1 -1
- package/services/GetProjectVersionService/GetProjectVersionService.js +4 -4
- package/services/GetProjectVersionService/GetProjectVersionService.js.map +1 -1
- package/services/InitProjectSdkService/InitProjectSdkService.js +0 -6
- package/services/InitProjectSdkService/InitProjectSdkService.js.map +1 -1
- package/services/InitProjectSdkService/applyWcpEnvVars.js +10 -8
- package/services/InitProjectSdkService/applyWcpEnvVars.js.map +1 -1
- package/services/InitProjectSdkService/registerPulumiExtensions.js +5 -3
- package/services/InitProjectSdkService/registerPulumiExtensions.js.map +1 -1
- package/services/InstallExtensionService/downloadFolderFromS3.js +33 -42
- package/services/InstallExtensionService/downloadFolderFromS3.js.map +1 -1
- package/services/InstallExtensionService/types.d.ts +4 -0
- package/services/InstallExtensionService/types.js.map +1 -1
- package/services/InstallExtensionService/updateWebinyConfig.js +74 -47
- package/services/InstallExtensionService/updateWebinyConfig.js.map +1 -1
- package/services/ListPackagesService/ListPackagesService.js +1 -1
- package/services/ListPackagesService/ListPackagesService.js.map +1 -1
- package/services/ProjectInfoService/ProjectInfoService.js +3 -3
- package/services/ProjectInfoService/ProjectInfoService.js.map +1 -1
- package/utils/ExtensionSrcResolver.js +2 -1
- package/utils/ExtensionSrcResolver.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/index.js.map +1 -1
- package/utils/requireConfig.js +9 -5
- package/utils/requireConfig.js.map +1 -1
- package/utils/toImportSpecifier.d.ts +5 -0
- package/utils/toImportSpecifier.js +12 -0
- package/utils/toImportSpecifier.js.map +1 -0
- package/abstractions/features/pulumi/AdminPulumi.d.ts +0 -8
- package/abstractions/features/pulumi/AdminPulumi.js +0 -4
- package/abstractions/features/pulumi/AdminPulumi.js.map +0 -1
- package/abstractions/features/pulumi/ApiPulumi.d.ts +0 -8
- package/abstractions/features/pulumi/ApiPulumi.js +0 -4
- package/abstractions/features/pulumi/ApiPulumi.js.map +0 -1
- package/abstractions/features/pulumi/CorePulumi.d.ts +0 -8
- package/abstractions/features/pulumi/CorePulumi.js +0 -4
- package/abstractions/features/pulumi/CorePulumi.js.map +0 -1
- package/abstractions/features/pulumi/index.d.ts +0 -3
- package/abstractions/features/pulumi/index.js +0 -5
- package/abstractions/features/pulumi/index.js.map +0 -1
- package/exports/infra/index.d.ts +0 -8
- package/exports/infra/index.js +0 -10
- package/extensions/pulumi/AdminPulumi.d.ts +0 -8
- package/extensions/pulumi/AdminPulumi.js +0 -25
- package/extensions/pulumi/AdminPulumi.js.map +0 -1
- package/extensions/pulumi/ApiPulumi.d.ts +0 -8
- package/extensions/pulumi/ApiPulumi.js +0 -25
- package/extensions/pulumi/ApiPulumi.js.map +0 -1
- package/extensions/pulumi/CorePulumi.d.ts +0 -8
- package/extensions/pulumi/CorePulumi.js +0 -25
- package/extensions/pulumi/CorePulumi.js.map +0 -1
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.d.ts +0 -18
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.js +0 -15
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.js.map +0 -1
- package/features/Watch/watchers/utils/requireConfig.d.ts +0 -18
- package/features/Watch/watchers/utils/requireConfig.js +0 -15
- package/features/Watch/watchers/utils/requireConfig.js.map +0 -1
- package/features/pulumi/AdminPulumi/AdminPulumi.d.ts +0 -7
- package/features/pulumi/AdminPulumi/AdminPulumi.js +0 -21
- package/features/pulumi/AdminPulumi/AdminPulumi.js.map +0 -1
- package/features/pulumi/AdminPulumi/index.d.ts +0 -1
- package/features/pulumi/AdminPulumi/index.js +0 -3
- package/features/pulumi/AdminPulumi/index.js.map +0 -1
- package/features/pulumi/ApiPulumi/ApiPulumi.d.ts +0 -7
- package/features/pulumi/ApiPulumi/ApiPulumi.js +0 -21
- package/features/pulumi/ApiPulumi/ApiPulumi.js.map +0 -1
- package/features/pulumi/ApiPulumi/index.d.ts +0 -1
- package/features/pulumi/ApiPulumi/index.js +0 -3
- package/features/pulumi/ApiPulumi/index.js.map +0 -1
- package/features/pulumi/CorePulumi/CorePulumi.d.ts +0 -7
- package/features/pulumi/CorePulumi/CorePulumi.js +0 -21
- package/features/pulumi/CorePulumi/CorePulumi.js.map +0 -1
- package/features/pulumi/CorePulumi/index.d.ts +0 -1
- package/features/pulumi/CorePulumi/index.js +0 -3
- package/features/pulumi/CorePulumi/index.js.map +0 -1
- package/features/pulumi/index.d.ts +0 -3
- package/features/pulumi/index.js +0 -5
- package/features/pulumi/index.js.map +0 -1
|
@@ -5,7 +5,6 @@ interface IDeployAppParams {
|
|
|
5
5
|
app: AppName;
|
|
6
6
|
preview?: boolean;
|
|
7
7
|
pulumiArgs?: Record<string, string | boolean | string[] | undefined>;
|
|
8
|
-
dataMigrationLogStreaming?: boolean;
|
|
9
8
|
allowLocalStateFiles?: boolean;
|
|
10
9
|
output?: (pulumiProcess: IPulumiProcess) => Promise<void>;
|
|
11
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","DeployApp"],"sources":["DeployApp.ts"],"sourcesContent":["import { createAbstraction } from \"~/abstractions/createAbstraction.js\";\nimport { type AppName } from \"~/abstractions/types.js\";\nimport { type ExecaChildProcess } from \"execa\";\n\ntype IPulumiProcess = ExecaChildProcess<string>;\n\ninterface IDeployAppParams {\n app: AppName;\n preview?: boolean;\n pulumiArgs?: Record<string, string | boolean | string[] | undefined>;\n
|
|
1
|
+
{"version":3,"names":["createAbstraction","DeployApp"],"sources":["DeployApp.ts"],"sourcesContent":["import { createAbstraction } from \"~/abstractions/createAbstraction.js\";\nimport { type AppName } from \"~/abstractions/types.js\";\nimport { type ExecaChildProcess } from \"execa\";\n\ntype IPulumiProcess = ExecaChildProcess<string>;\n\ninterface IDeployAppParams {\n app: AppName;\n preview?: boolean;\n pulumiArgs?: Record<string, string | boolean | string[] | undefined>;\n allowLocalStateFiles?: boolean;\n output?: (pulumiProcess: IPulumiProcess) => Promise<void>;\n}\n\nexport interface IDeployApp {\n execute(params: IDeployAppParams): Promise<void>;\n}\n\nexport const DeployApp = createAbstraction<IDeployApp>(\"DeployApp\");\n\nexport namespace DeployApp {\n export type Interface = IDeployApp;\n\n export type Params = IDeployAppParams;\n\n export type PulumiProcess = IPulumiProcess;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB;AAkB1B,OAAO,MAAMC,SAAS,GAAGD,iBAAiB,CAAa,WAAW,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BuildApp","BuildExtension","DeployApp","DestroyApp","ExportStack","GetApp","GetAppOutput","GetAppStackOutput","GetLogger","GetProductionEnvironments","GetProject","GetProjectConfig","GetProjectInfo","GetPulumiResourceNamePrefix","InstallExtension","IsCi","IsTelemetryEnabled","IsWcpEnabled","IsWebinyJsRepo","RefreshApp","RunPulumiCommand","ValidateProjectConfig","Watch","GetFeatureFlags"],"sources":["index.ts"],"sourcesContent":["export * from \"./hooks/index.js\";\nexport
|
|
1
|
+
{"version":3,"names":["BuildApp","BuildExtension","DeployApp","DestroyApp","ExportStack","GetApp","GetAppOutput","GetAppStackOutput","GetLogger","GetProductionEnvironments","GetProject","GetProjectConfig","GetProjectInfo","GetPulumiResourceNamePrefix","InstallExtension","IsCi","IsTelemetryEnabled","IsWcpEnabled","IsWebinyJsRepo","RefreshApp","RunPulumiCommand","ValidateProjectConfig","Watch","GetFeatureFlags"],"sources":["index.ts"],"sourcesContent":["export * from \"./hooks/index.js\";\nexport { BuildApp } from \"./BuildApp.js\";\nexport { BuildExtension } from \"./BuildExtension.js\";\nexport { DeployApp } from \"./DeployApp.js\";\nexport { DestroyApp } from \"./DestroyApp.js\";\nexport { ExportStack } from \"./ExportStack.js\";\nexport { GetApp } from \"./GetApp.js\";\nexport { GetAppOutput } from \"./GetAppOutput.js\";\nexport { GetAppStackOutput } from \"./GetAppStackOutput.js\";\nexport { GetLogger } from \"./GetLogger.js\";\nexport { GetProductionEnvironments } from \"./GetProductionEnvironments.js\";\nexport { GetProject } from \"./GetProject.js\";\nexport { GetProjectConfig } from \"./GetProjectConfig.js\";\nexport { GetProjectInfo } from \"./GetProjectInfo.js\";\nexport { GetPulumiResourceNamePrefix } from \"./GetPulumiResourceNamePrefix.js\";\nexport { InstallExtension } from \"./InstallExtension.js\";\nexport { IsCi } from \"./IsCi.js\";\nexport { IsTelemetryEnabled } from \"./IsTelemetryEnabled.js\";\nexport { IsWcpEnabled } from \"./IsWcpEnabled.js\";\nexport { IsWebinyJsRepo } from \"./IsWebinyJsRepo.js\";\nexport { RefreshApp } from \"./RefreshApp.js\";\nexport { RunPulumiCommand } from \"./RunPulumiCommand.js\";\nexport { ValidateProjectConfig } from \"./ValidateProjectConfig.js\";\nexport { Watch } from \"./Watch.js\";\nexport { GetFeatureFlags } from \"./GetFeatureFlags.js\";\n"],"mappings":"AAAA;AACA,SAASA,QAAQ;AACjB,SAASC,cAAc;AACvB,SAASC,SAAS;AAClB,SAASC,UAAU;AACnB,SAASC,WAAW;AACpB,SAASC,MAAM;AACf,SAASC,YAAY;AACrB,SAASC,iBAAiB;AAC1B,SAASC,SAAS;AAClB,SAASC,yBAAyB;AAClC,SAASC,UAAU;AACnB,SAASC,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,2BAA2B;AACpC,SAASC,gBAAgB;AACzB,SAASC,IAAI;AACb,SAASC,kBAAkB;AAC3B,SAASC,YAAY;AACrB,SAASC,cAAc;AACvB,SAASC,UAAU;AACnB,SAASC,gBAAgB;AACzB,SAASC,qBAAqB;AAC9B,SAASC,KAAK;AACd,SAASC,eAAe","ignoreList":[]}
|
|
@@ -7,8 +7,8 @@ export interface ExtensionDefinitionModelParams<TParamsSchema extends z.ZodTypeA
|
|
|
7
7
|
description: string;
|
|
8
8
|
array?: boolean;
|
|
9
9
|
paramsSchema?: TParamsSchema | ((ctx: ExtensionInstanceModelContext) => TParamsSchema);
|
|
10
|
-
build?(params: TParamsSchema
|
|
11
|
-
validate?(params: TParamsSchema): Promise<void> | void;
|
|
10
|
+
build?(params: z.infer<TParamsSchema>, ctx: ExtensionInstanceModelContext): Promise<void> | void;
|
|
11
|
+
validate?(params: z.infer<TParamsSchema>): Promise<void> | void;
|
|
12
12
|
}
|
|
13
13
|
export declare class ExtensionDefinitionModel<TParamsSchema extends z.ZodTypeAny> {
|
|
14
14
|
type: string;
|
|
@@ -16,7 +16,7 @@ export declare class ExtensionDefinitionModel<TParamsSchema extends z.ZodTypeAny
|
|
|
16
16
|
tags: ExtensionTags;
|
|
17
17
|
multiple?: boolean;
|
|
18
18
|
paramsSchema?: TParamsSchema | ((ctx: ExtensionInstanceModelContext) => TParamsSchema);
|
|
19
|
-
build?(params: TParamsSchema
|
|
20
|
-
validate?(params: TParamsSchema): Promise<void> | void;
|
|
19
|
+
build?(params: z.infer<TParamsSchema>, ctx: ExtensionInstanceModelContext): Promise<void> | void;
|
|
20
|
+
validate?(params: z.infer<TParamsSchema>): Promise<void> | void;
|
|
21
21
|
constructor(params: ExtensionDefinitionModelParams<TParamsSchema>);
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ExtensionDefinitionModel","constructor","params","type","tags","description","multiple","array","paramsSchema","build","validate"],"sources":["ExtensionDefinitionModel.ts"],"sourcesContent":["import { type ExtensionTags } from \"~/defineExtension/types.js\";\nimport { type z } from \"zod\";\nimport { type ExtensionInstanceModelContext } from \"~/defineExtension/index.js\";\n\nexport interface ExtensionDefinitionModelParams<TParamsSchema extends z.ZodTypeAny> {\n type: string;\n tags?: ExtensionTags;\n description: string;\n array?: boolean;\n paramsSchema?: TParamsSchema | ((ctx: ExtensionInstanceModelContext) => TParamsSchema);\n\n build?(params: TParamsSchema
|
|
1
|
+
{"version":3,"names":["ExtensionDefinitionModel","constructor","params","type","tags","description","multiple","array","paramsSchema","build","validate"],"sources":["ExtensionDefinitionModel.ts"],"sourcesContent":["import { type ExtensionTags } from \"~/defineExtension/types.js\";\nimport { type z } from \"zod\";\nimport { type ExtensionInstanceModelContext } from \"~/defineExtension/index.js\";\n\nexport interface ExtensionDefinitionModelParams<TParamsSchema extends z.ZodTypeAny> {\n type: string;\n tags?: ExtensionTags;\n description: string;\n array?: boolean;\n paramsSchema?: TParamsSchema | ((ctx: ExtensionInstanceModelContext) => TParamsSchema);\n\n build?(\n params: z.infer<TParamsSchema>,\n ctx: ExtensionInstanceModelContext\n ): Promise<void> | void;\n\n validate?(params: z.infer<TParamsSchema>): Promise<void> | void;\n}\n\nexport class ExtensionDefinitionModel<TParamsSchema extends z.ZodTypeAny> {\n type: string;\n description: string;\n tags: ExtensionTags;\n multiple?: boolean;\n paramsSchema?: TParamsSchema | ((ctx: ExtensionInstanceModelContext) => TParamsSchema);\n\n build?(\n params: z.infer<TParamsSchema>,\n ctx: ExtensionInstanceModelContext\n ): Promise<void> | void;\n\n validate?(params: z.infer<TParamsSchema>): Promise<void> | void;\n\n constructor(params: ExtensionDefinitionModelParams<TParamsSchema>) {\n this.type = params.type;\n this.tags = params.tags || {};\n this.description = params.description;\n this.multiple = params.array;\n this.paramsSchema = params.paramsSchema;\n this.build = params.build;\n this.validate = params.validate;\n }\n}\n"],"mappings":"AAmBA,OAAO,MAAMA,wBAAwB,CAAqC;EActEC,WAAWA,CAACC,MAAqD,EAAE;IAC/D,IAAI,CAACC,IAAI,GAAGD,MAAM,CAACC,IAAI;IACvB,IAAI,CAACC,IAAI,GAAGF,MAAM,CAACE,IAAI,IAAI,CAAC,CAAC;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;IACrC,IAAI,CAACC,QAAQ,GAAGJ,MAAM,CAACK,KAAK;IAC5B,IAAI,CAACC,YAAY,GAAGN,MAAM,CAACM,YAAY;IACvC,IAAI,CAACC,KAAK,GAAGP,MAAM,CAACO,KAAK;IACzB,IAAI,CAACC,QAAQ,GAAGR,MAAM,CAACQ,QAAQ;EACnC;AACJ","ignoreList":[]}
|
|
@@ -18,7 +18,10 @@ export class ExtensionInstanceModel {
|
|
|
18
18
|
const paramsSchema = typeof this.definition.paramsSchema === "function" ? this.definition.paramsSchema(this.context) : this.definition.paramsSchema;
|
|
19
19
|
const validationResult = await paramsSchema.safeParseAsync(this.params);
|
|
20
20
|
if (!validationResult.success) {
|
|
21
|
-
const errorMessages = validationResult.error.
|
|
21
|
+
const errorMessages = validationResult.error.issues.map(err => {
|
|
22
|
+
const field = err.path.length > 0 ? `[${err.path.join(".")}] ` : "";
|
|
23
|
+
return `${field}${err.message}`;
|
|
24
|
+
}).join("; ");
|
|
22
25
|
throw ProjectError.from(`Validation failed for extension of type %s: ${errorMessages}`, this.definition.type);
|
|
23
26
|
}
|
|
24
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProjectError","ExtensionInstanceModel","constructor","definition","params","context","build","validate","validateParams","paramsSchema","validationResult","safeParseAsync","success","errorMessages","error","
|
|
1
|
+
{"version":3,"names":["ProjectError","ExtensionInstanceModel","constructor","definition","params","context","build","validate","validateParams","paramsSchema","validationResult","safeParseAsync","success","errorMessages","error","issues","map","err","field","path","length","join","message","from","type"],"sources":["ExtensionInstanceModel.ts"],"sourcesContent":["import { type ExtensionDefinitionModel } from \"./ExtensionDefinitionModel.js\";\nimport { type z } from \"zod\";\nimport { type ProjectModel } from \"~/models/index.js\";\nimport { ProjectError } from \"~/ProjectError.js\";\n\nexport interface ExtensionInstanceModelContext {\n [key: string]: any;\n\n project: ProjectModel;\n}\n\nexport class ExtensionInstanceModel<TParamsSchema extends z.ZodTypeAny> {\n constructor(\n public definition: ExtensionDefinitionModel<TParamsSchema>,\n public params: z.infer<TParamsSchema>,\n public context: ExtensionInstanceModelContext\n ) {}\n\n async build() {\n return this.definition.build?.(this.params, this.context);\n }\n\n async validate() {\n return this.definition.validate?.(this.params);\n }\n\n async validateParams() {\n if (!this.definition.paramsSchema) {\n return;\n }\n\n const paramsSchema =\n typeof this.definition.paramsSchema === \"function\"\n ? this.definition.paramsSchema(this.context)\n : this.definition.paramsSchema;\n\n const validationResult = await paramsSchema.safeParseAsync(this.params);\n if (!validationResult.success) {\n const errorMessages = validationResult.error.issues\n .map((err: { message: string; path: PropertyKey[] }) => {\n const field = err.path.length > 0 ? `[${err.path.join(\".\")}] ` : \"\";\n return `${field}${err.message}`;\n })\n .join(\"; \");\n\n throw ProjectError.from(\n `Validation failed for extension of type %s: ${errorMessages}`,\n this.definition.type\n );\n }\n }\n}\n"],"mappings":"AAGA,SAASA,YAAY;AAQrB,OAAO,MAAMC,sBAAsB,CAAqC;EACpEC,WAAWA,CACAC,UAAmD,EACnDC,MAA8B,EAC9BC,OAAsC,EAC/C;IAAA,KAHSF,UAAmD,GAAnDA,UAAmD;IAAA,KACnDC,MAA8B,GAA9BA,MAA8B;IAAA,KAC9BC,OAAsC,GAAtCA,OAAsC;EAC9C;EAEH,MAAMC,KAAKA,CAAA,EAAG;IACV,OAAO,IAAI,CAACH,UAAU,CAACG,KAAK,GAAG,IAAI,CAACF,MAAM,EAAE,IAAI,CAACC,OAAO,CAAC;EAC7D;EAEA,MAAME,QAAQA,CAAA,EAAG;IACb,OAAO,IAAI,CAACJ,UAAU,CAACI,QAAQ,GAAG,IAAI,CAACH,MAAM,CAAC;EAClD;EAEA,MAAMI,cAAcA,CAAA,EAAG;IACnB,IAAI,CAAC,IAAI,CAACL,UAAU,CAACM,YAAY,EAAE;MAC/B;IACJ;IAEA,MAAMA,YAAY,GACd,OAAO,IAAI,CAACN,UAAU,CAACM,YAAY,KAAK,UAAU,GAC5C,IAAI,CAACN,UAAU,CAACM,YAAY,CAAC,IAAI,CAACJ,OAAO,CAAC,GAC1C,IAAI,CAACF,UAAU,CAACM,YAAY;IAEtC,MAAMC,gBAAgB,GAAG,MAAMD,YAAY,CAACE,cAAc,CAAC,IAAI,CAACP,MAAM,CAAC;IACvE,IAAI,CAACM,gBAAgB,CAACE,OAAO,EAAE;MAC3B,MAAMC,aAAa,GAAGH,gBAAgB,CAACI,KAAK,CAACC,MAAM,CAC9CC,GAAG,CAAEC,GAA6C,IAAK;QACpD,MAAMC,KAAK,GAAGD,GAAG,CAACE,IAAI,CAACC,MAAM,GAAG,CAAC,GAAG,IAAIH,GAAG,CAACE,IAAI,CAACE,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE;QACnE,OAAO,GAAGH,KAAK,GAAGD,GAAG,CAACK,OAAO,EAAE;MACnC,CAAC,CAAC,CACDD,IAAI,CAAC,IAAI,CAAC;MAEf,MAAMrB,YAAY,CAACuB,IAAI,CACnB,+CAA+CV,aAAa,EAAE,EAC9D,IAAI,CAACV,UAAU,CAACqB,IACpB,CAAC;IACL;EACJ;AACJ","ignoreList":[]}
|
|
@@ -12,5 +12,5 @@ type ZodSrcPathOptions = {
|
|
|
12
12
|
project: IProjectModel;
|
|
13
13
|
abstraction?: Abstraction<any>;
|
|
14
14
|
};
|
|
15
|
-
export declare const zodSrcPath: (options: ZodSrcPathOptions) => z.
|
|
15
|
+
export declare const zodSrcPath: (options: ZodSrcPathOptions) => z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
16
16
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Metadata } from "@webiny/di";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import fs from "fs";
|
|
3
4
|
import path from "path";
|
|
4
5
|
import { ProjectError } from "../../ProjectError.js";
|
|
5
6
|
import { ExtensionSrcResolver } from "../../utils/index.js";
|
|
@@ -32,6 +33,16 @@ export const zodSrcPath = options => {
|
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
// Ensure the resolved path points to a file, not a directory.
|
|
37
|
+
const absolutePath = ExtensionSrcResolver.resolvePath(src, project);
|
|
38
|
+
if (fs.statSync(absolutePath).isDirectory()) {
|
|
39
|
+
ctx.addIssue({
|
|
40
|
+
code: z.ZodIssueCode.custom,
|
|
41
|
+
message: ProjectError.formatMessage(`Expected a file but got a directory: %s. Please provide a path to a specific file.`, src)
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
// If abstraction validation is required
|
|
36
47
|
if (abstraction) {
|
|
37
48
|
const absoluteSrcPath = ExtensionSrcResolver.resolvePath(src, project);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Metadata","z","path","ProjectError","ExtensionSrcResolver","zodSrcPath","options","project","abstraction","getTokenName","token","str","toString","replace","tokenName","undefined","description","string","describe","transform","val","superRefine","src","ctx","existsSync","addIssue","code","ZodIssueCode","custom","message","formatMessage","
|
|
1
|
+
{"version":3,"names":["Metadata","z","fs","path","ProjectError","ExtensionSrcResolver","zodSrcPath","options","project","abstraction","getTokenName","token","str","toString","replace","tokenName","undefined","description","string","describe","transform","val","superRefine","src","ctx","existsSync","addIssue","code","ZodIssueCode","custom","message","formatMessage","absolutePath","resolvePath","statSync","isDirectory","absoluteSrcPath","exportName","basename","extname","exportedImplementation","importFromPath","metadata","metadataName","getAbstraction","defName","isCorrectAbstraction"],"sources":["zodSrcPath.ts"],"sourcesContent":["import { type Abstraction, Metadata } from \"@webiny/di\";\nimport { z } from \"zod\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { type IProjectModel } from \"~/abstractions/models/index.js\";\nimport { ProjectError } from \"~/ProjectError.js\";\nimport { ExtensionSrcResolver } from \"~/utils/index.js\";\n\n/**\n * TypeScript type for source paths.\n * - `/extensions/${string}` - resolves from project root\n * - `@/${string}` or other tsconfig aliases - resolves using tsconfig.json paths\n * - string (absolute path) - treated as absolute path\n */\nexport type SrcPath = `/extensions/${string}` | string;\n\ntype ZodSrcPathOptions = {\n project: IProjectModel;\n abstraction?: Abstraction<any>;\n};\n\nexport const zodSrcPath = (options: ZodSrcPathOptions) => {\n const { project, abstraction } = options;\n\n const getTokenName = (token: symbol) => {\n const str = token.toString();\n return str.replace(/^Symbol\\(/, \"\").replace(/\\)$/, \"\");\n };\n\n const tokenName = abstraction ? getTokenName(abstraction.token) : undefined;\n const description = abstraction\n ? `Path to a file exporting ${tokenName}. Use \"/extensions/...\" to resolve from project root, \"@/...\" for tsconfig path aliases, or provide an absolute path.`\n : `Path: \"/extensions/...\" resolves from project root, \"@/...\" resolves using tsconfig path aliases, or provide an absolute path.`;\n\n return z\n .string()\n .describe(description)\n .transform((val): SrcPath => val as SrcPath)\n .superRefine(async (src, ctx) => {\n // Check if file exists using ExtensionSrcResolver.\n if (!ExtensionSrcResolver.existsSync(src, project)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: ProjectError.formatMessage(\n `File not found: %s. Please check the path and try again.`,\n src\n )\n });\n return;\n }\n\n // Ensure the resolved path points to a file, not a directory.\n const absolutePath = ExtensionSrcResolver.resolvePath(src, project);\n if (fs.statSync(absolutePath).isDirectory()) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: ProjectError.formatMessage(\n `Expected a file but got a directory: %s. Please provide a path to a specific file.`,\n src\n )\n });\n return;\n }\n\n // If abstraction validation is required\n if (abstraction) {\n const absoluteSrcPath = ExtensionSrcResolver.resolvePath(src, project);\n const exportName = path\n .basename(absoluteSrcPath)\n .replace(path.extname(absoluteSrcPath), \"\");\n\n const exportedImplementation = await ExtensionSrcResolver.importFromPath(\n src,\n project\n );\n\n if (!exportedImplementation) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: ProjectError.formatMessage(\n `The file %s must export a class named %s or as a default export.`,\n src,\n exportName\n )\n });\n return;\n }\n\n const metadata = new Metadata(exportedImplementation);\n const metadataName = metadata.getAbstraction().toString();\n const defName = abstraction.toString();\n const isCorrectAbstraction = metadataName === defName;\n\n if (!isCorrectAbstraction) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: ProjectError.formatMessage(\n `The class %s in %s must implement the %s interface.`,\n exportName,\n src,\n tokenName || \"\"\n )\n });\n }\n }\n });\n};\n"],"mappings":"AAAA,SAA2BA,QAAQ,QAAQ,YAAY;AACvD,SAASC,CAAC,QAAQ,KAAK;AACvB,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,SAASC,YAAY;AACrB,SAASC,oBAAoB;;AAE7B;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAO,MAAMC,UAAU,GAAIC,OAA0B,IAAK;EACtD,MAAM;IAAEC,OAAO;IAAEC;EAAY,CAAC,GAAGF,OAAO;EAExC,MAAMG,YAAY,GAAIC,KAAa,IAAK;IACpC,MAAMC,GAAG,GAAGD,KAAK,CAACE,QAAQ,CAAC,CAAC;IAC5B,OAAOD,GAAG,CAACE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;EAC1D,CAAC;EAED,MAAMC,SAAS,GAAGN,WAAW,GAAGC,YAAY,CAACD,WAAW,CAACE,KAAK,CAAC,GAAGK,SAAS;EAC3E,MAAMC,WAAW,GAAGR,WAAW,GACzB,4BAA4BM,SAAS,uHAAuH,GAC5J,gIAAgI;EAEtI,O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AC,CAAC2B,YAAY,CAACC,MAAM;UAC3BC,OAAO,EAAE1B,YAAY,CAAC2B,aAAa,CAC/B,kEAAkE,EAClER,GAAG,EACHc,UACJ;QACJ,CAAC,CAAC;QACF;MACJ;MAEA,MAAMK,QAAQ,GAAG,IAAI1C,QAAQ,CAACwC,sBAAsB,CAAC;MACrD,MAAMG,YAAY,GAAGD,QAAQ,CAACE,cAAc,CAAC,CAAC,CAAC/B,QAAQ,CAAC,CAAC;MACzD,MAAMgC,OAAO,GAAGpC,WAAW,CAACI,QAAQ,CAAC,CAAC;MACtC,MAAMiC,oBAAoB,GAAGH,YAAY,KAAKE,OAAO;MAErD,IAAI,CAACC,oBAAoB,EAAE;QACvBtB,GAAG,CAACE,QAAQ,CAAC;UACTC,IAAI,EAAE1B,CAAC,CAAC2B,YAAY,CAACC,MAAM;UAC3BC,OAAO,EAAE1B,YAAY,CAAC2B,aAAa,CAC/B,qDAAqD,EACrDM,UAAU,EACVd,GAAG,EACHR,SAAS,IAAI,EACjB;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
|
package/exports/infra/admin.d.ts
CHANGED
|
@@ -3,4 +3,3 @@ export { AdminBeforeBuild as AdminBeforeBuildHook } from "../../abstractions/fea
|
|
|
3
3
|
export { AdminAfterDeploy as AdminAfterDeployHook } from "../../abstractions/features/hooks/AdminAfterDeploy.js";
|
|
4
4
|
export { AdminBeforeDeploy as AdminBeforeDeployHook } from "../../abstractions/features/hooks/AdminBeforeDeploy.js";
|
|
5
5
|
export { AdminBeforeWatch as AdminBeforeWatchHook } from "../../abstractions/features/hooks/AdminBeforeWatch.js";
|
|
6
|
-
export { AdminPulumi } from "../../abstractions/features/pulumi/AdminPulumi.js";
|
package/exports/infra/admin.js
CHANGED
|
@@ -3,6 +3,5 @@ export { AdminBeforeBuild as AdminBeforeBuildHook } from "../../abstractions/fea
|
|
|
3
3
|
export { AdminAfterDeploy as AdminAfterDeployHook } from "../../abstractions/features/hooks/AdminAfterDeploy.js";
|
|
4
4
|
export { AdminBeforeDeploy as AdminBeforeDeployHook } from "../../abstractions/features/hooks/AdminBeforeDeploy.js";
|
|
5
5
|
export { AdminBeforeWatch as AdminBeforeWatchHook } from "../../abstractions/features/hooks/AdminBeforeWatch.js";
|
|
6
|
-
export { AdminPulumi } from "../../abstractions/features/pulumi/AdminPulumi.js";
|
|
7
6
|
|
|
8
7
|
//# sourceMappingURL=admin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AdminAfterBuild","AdminAfterBuildHook","AdminBeforeBuild","AdminBeforeBuildHook","AdminAfterDeploy","AdminAfterDeployHook","AdminBeforeDeploy","AdminBeforeDeployHook","AdminBeforeWatch","AdminBeforeWatchHook"
|
|
1
|
+
{"version":3,"names":["AdminAfterBuild","AdminAfterBuildHook","AdminBeforeBuild","AdminBeforeBuildHook","AdminAfterDeploy","AdminAfterDeployHook","AdminBeforeDeploy","AdminBeforeDeployHook","AdminBeforeWatch","AdminBeforeWatchHook"],"sources":["admin.ts"],"sourcesContent":["export { AdminAfterBuild as AdminAfterBuildHook } from \"~/abstractions/features/hooks/AdminAfterBuild.js\";\nexport { AdminBeforeBuild as AdminBeforeBuildHook } from \"~/abstractions/features/hooks/AdminBeforeBuild.js\";\nexport { AdminAfterDeploy as AdminAfterDeployHook } from \"~/abstractions/features/hooks/AdminAfterDeploy.js\";\nexport { AdminBeforeDeploy as AdminBeforeDeployHook } from \"~/abstractions/features/hooks/AdminBeforeDeploy.js\";\nexport { AdminBeforeWatch as AdminBeforeWatchHook } from \"~/abstractions/features/hooks/AdminBeforeWatch.js\";\n"],"mappings":"AAAA,SAASA,eAAe,IAAIC,mBAAmB;AAC/C,SAASC,gBAAgB,IAAIC,oBAAoB;AACjD,SAASC,gBAAgB,IAAIC,oBAAoB;AACjD,SAASC,iBAAiB,IAAIC,qBAAqB;AACnD,SAASC,gBAAgB,IAAIC,oBAAoB","ignoreList":[]}
|
package/exports/infra/api.d.ts
CHANGED
|
@@ -3,4 +3,3 @@ export { ApiBeforeBuild as ApiBeforeBuildHook } from "../../abstractions/feature
|
|
|
3
3
|
export { ApiAfterDeploy as ApiAfterDeployHook } from "../../abstractions/features/hooks/ApiAfterDeploy.js";
|
|
4
4
|
export { ApiBeforeDeploy as ApiBeforeDeployHook } from "../../abstractions/features/hooks/ApiBeforeDeploy.js";
|
|
5
5
|
export { ApiBeforeWatch as ApiBeforeWatchHook } from "../../abstractions/features/hooks/ApiBeforeWatch.js";
|
|
6
|
-
export { ApiPulumi } from "../../abstractions/features/pulumi/ApiPulumi.js";
|
package/exports/infra/api.js
CHANGED
|
@@ -3,6 +3,5 @@ export { ApiBeforeBuild as ApiBeforeBuildHook } from "../../abstractions/feature
|
|
|
3
3
|
export { ApiAfterDeploy as ApiAfterDeployHook } from "../../abstractions/features/hooks/ApiAfterDeploy.js";
|
|
4
4
|
export { ApiBeforeDeploy as ApiBeforeDeployHook } from "../../abstractions/features/hooks/ApiBeforeDeploy.js";
|
|
5
5
|
export { ApiBeforeWatch as ApiBeforeWatchHook } from "../../abstractions/features/hooks/ApiBeforeWatch.js";
|
|
6
|
-
export { ApiPulumi } from "../../abstractions/features/pulumi/ApiPulumi.js";
|
|
7
6
|
|
|
8
7
|
//# sourceMappingURL=api.js.map
|
package/exports/infra/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ApiAfterBuild","ApiAfterBuildHook","ApiBeforeBuild","ApiBeforeBuildHook","ApiAfterDeploy","ApiAfterDeployHook","ApiBeforeDeploy","ApiBeforeDeployHook","ApiBeforeWatch","ApiBeforeWatchHook"
|
|
1
|
+
{"version":3,"names":["ApiAfterBuild","ApiAfterBuildHook","ApiBeforeBuild","ApiBeforeBuildHook","ApiAfterDeploy","ApiAfterDeployHook","ApiBeforeDeploy","ApiBeforeDeployHook","ApiBeforeWatch","ApiBeforeWatchHook"],"sources":["api.ts"],"sourcesContent":["export { ApiAfterBuild as ApiAfterBuildHook } from \"~/abstractions/features/hooks/ApiAfterBuild.js\";\nexport { ApiBeforeBuild as ApiBeforeBuildHook } from \"~/abstractions/features/hooks/ApiBeforeBuild.js\";\nexport { ApiAfterDeploy as ApiAfterDeployHook } from \"~/abstractions/features/hooks/ApiAfterDeploy.js\";\nexport { ApiBeforeDeploy as ApiBeforeDeployHook } from \"~/abstractions/features/hooks/ApiBeforeDeploy.js\";\nexport { ApiBeforeWatch as ApiBeforeWatchHook } from \"~/abstractions/features/hooks/ApiBeforeWatch.js\";\n"],"mappings":"AAAA,SAASA,aAAa,IAAIC,iBAAiB;AAC3C,SAASC,cAAc,IAAIC,kBAAkB;AAC7C,SAASC,cAAc,IAAIC,kBAAkB;AAC7C,SAASC,eAAe,IAAIC,mBAAmB;AAC/C,SAASC,cAAc,IAAIC,kBAAkB","ignoreList":[]}
|
package/exports/infra/core.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ export { CoreAfterBuild as CoreAfterBuildHook } from "../../abstractions/feature
|
|
|
2
2
|
export { CoreBeforeBuild as CoreBeforeBuildHook } from "../../abstractions/features/hooks/CoreBeforeBuild.js";
|
|
3
3
|
export { CoreAfterDeploy as CoreAfterDeployHook } from "../../abstractions/features/hooks/CoreAfterDeploy.js";
|
|
4
4
|
export { CoreBeforeDeploy as CoreBeforeDeployHook } from "../../abstractions/features/hooks/CoreBeforeDeploy.js";
|
|
5
|
-
export { CorePulumi } from "../../abstractions/features/pulumi/CorePulumi.js";
|
package/exports/infra/core.js
CHANGED
|
@@ -2,6 +2,5 @@ export { CoreAfterBuild as CoreAfterBuildHook } from "../../abstractions/feature
|
|
|
2
2
|
export { CoreBeforeBuild as CoreBeforeBuildHook } from "../../abstractions/features/hooks/CoreBeforeBuild.js";
|
|
3
3
|
export { CoreAfterDeploy as CoreAfterDeployHook } from "../../abstractions/features/hooks/CoreAfterDeploy.js";
|
|
4
4
|
export { CoreBeforeDeploy as CoreBeforeDeployHook } from "../../abstractions/features/hooks/CoreBeforeDeploy.js";
|
|
5
|
-
export { CorePulumi } from "../../abstractions/features/pulumi/CorePulumi.js";
|
|
6
5
|
|
|
7
6
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CoreAfterBuild","CoreAfterBuildHook","CoreBeforeBuild","CoreBeforeBuildHook","CoreAfterDeploy","CoreAfterDeployHook","CoreBeforeDeploy","CoreBeforeDeployHook"
|
|
1
|
+
{"version":3,"names":["CoreAfterBuild","CoreAfterBuildHook","CoreBeforeBuild","CoreBeforeBuildHook","CoreAfterDeploy","CoreAfterDeployHook","CoreBeforeDeploy","CoreBeforeDeployHook"],"sources":["core.ts"],"sourcesContent":["export { CoreAfterBuild as CoreAfterBuildHook } from \"~/abstractions/features/hooks/CoreAfterBuild.js\";\nexport { CoreBeforeBuild as CoreBeforeBuildHook } from \"~/abstractions/features/hooks/CoreBeforeBuild.js\";\nexport { CoreAfterDeploy as CoreAfterDeployHook } from \"~/abstractions/features/hooks/CoreAfterDeploy.js\";\nexport { CoreBeforeDeploy as CoreBeforeDeployHook } from \"~/abstractions/features/hooks/CoreBeforeDeploy.js\";\n"],"mappings":"AAAA,SAASA,cAAc,IAAIC,kBAAkB;AAC7C,SAASC,eAAe,IAAIC,mBAAmB;AAC/C,SAASC,eAAe,IAAIC,mBAAmB;AAC/C,SAASC,gBAAgB,IAAIC,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { LoggerService as Logger } from "../abstractions/services/LoggerService.js";
|
|
2
|
+
export { UiService as Ui } from "../abstractions/services/UiService.js";
|
|
3
|
+
export { AfterBuild as AfterBuildHook } from "../abstractions/features/hooks/AfterBuild.js";
|
|
4
|
+
export { BeforeBuild as BeforeBuildHook } from "../abstractions/features/hooks/BeforeBuild.js";
|
|
5
|
+
export { AfterDeploy as AfterDeployHook } from "../abstractions/features/hooks/AfterDeploy.js";
|
|
6
|
+
export { BeforeDeploy as BeforeDeployHook } from "../abstractions/features/hooks/BeforeDeploy.js";
|
|
7
|
+
export { BeforeWatch as BeforeWatchHook } from "../abstractions/features/hooks/BeforeWatch.js";
|
|
8
|
+
export { EnvVar } from "../extensions/EnvVar.js";
|
package/exports/infra.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { LoggerService as Logger } from "../abstractions/services/LoggerService.js";
|
|
2
|
+
export { UiService as Ui } from "../abstractions/services/UiService.js";
|
|
3
|
+
export { AfterBuild as AfterBuildHook } from "../abstractions/features/hooks/AfterBuild.js";
|
|
4
|
+
export { BeforeBuild as BeforeBuildHook } from "../abstractions/features/hooks/BeforeBuild.js";
|
|
5
|
+
export { AfterDeploy as AfterDeployHook } from "../abstractions/features/hooks/AfterDeploy.js";
|
|
6
|
+
export { BeforeDeploy as BeforeDeployHook } from "../abstractions/features/hooks/BeforeDeploy.js";
|
|
7
|
+
export { BeforeWatch as BeforeWatchHook } from "../abstractions/features/hooks/BeforeWatch.js";
|
|
8
|
+
export { EnvVar } from "../extensions/EnvVar.js";
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=infra.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LoggerService","Logger","UiService","Ui","AfterBuild","AfterBuildHook","BeforeBuild","BeforeBuildHook","AfterDeploy","AfterDeployHook","BeforeDeploy","BeforeDeployHook","BeforeWatch","BeforeWatchHook","EnvVar"],"sources":["
|
|
1
|
+
{"version":3,"names":["LoggerService","Logger","UiService","Ui","AfterBuild","AfterBuildHook","BeforeBuild","BeforeBuildHook","AfterDeploy","AfterDeployHook","BeforeDeploy","BeforeDeployHook","BeforeWatch","BeforeWatchHook","EnvVar"],"sources":["infra.ts"],"sourcesContent":["export { LoggerService as Logger } from \"~/abstractions/services/LoggerService.js\";\nexport { UiService as Ui } from \"~/abstractions/services/UiService.js\";\nexport { AfterBuild as AfterBuildHook } from \"~/abstractions/features/hooks/AfterBuild.js\";\nexport { BeforeBuild as BeforeBuildHook } from \"~/abstractions/features/hooks/BeforeBuild.js\";\nexport { AfterDeploy as AfterDeployHook } from \"~/abstractions/features/hooks/AfterDeploy.js\";\nexport { BeforeDeploy as BeforeDeployHook } from \"~/abstractions/features/hooks/BeforeDeploy.js\";\nexport { BeforeWatch as BeforeWatchHook } from \"~/abstractions/features/hooks/BeforeWatch.js\";\nexport { EnvVar } from \"~/extensions/EnvVar.js\";\n"],"mappings":"AAAA,SAASA,aAAa,IAAIC,MAAM;AAChC,SAASC,SAAS,IAAIC,EAAE;AACxB,SAASC,UAAU,IAAIC,cAAc;AACrC,SAASC,WAAW,IAAIC,eAAe;AACvC,SAASC,WAAW,IAAIC,eAAe;AACvC,SAASC,YAAY,IAAIC,gBAAgB;AACzC,SAASC,WAAW,IAAIC,eAAe;AACvC,SAASC,MAAM","ignoreList":[]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const AdminBuildParam: import("~/defineExtension/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
3
|
paramName: z.ZodString;
|
|
4
|
-
value: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny
|
|
5
|
-
},
|
|
6
|
-
value: string | number | boolean | any[] | Record<string, any>;
|
|
7
|
-
paramName: string;
|
|
8
|
-
}, {
|
|
9
|
-
value: string | number | boolean | any[] | Record<string, any>;
|
|
10
|
-
paramName: string;
|
|
11
|
-
}>>;
|
|
4
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>, z.ZodNumber, z.ZodBoolean]>;
|
|
5
|
+
}, z.core.$strip>>;
|
|
@@ -132,7 +132,7 @@ export const AdminBuildParam = defineExtension({
|
|
|
132
132
|
paramsSchema: () => {
|
|
133
133
|
return z.object({
|
|
134
134
|
paramName: z.string(),
|
|
135
|
-
value: z.union([z.string(), z.record(z.any()), z.array(z.any()), z.number(), z.boolean()])
|
|
135
|
+
value: z.union([z.string(), z.record(z.string(), z.any()), z.array(z.any()), z.number(), z.boolean()])
|
|
136
136
|
});
|
|
137
137
|
},
|
|
138
138
|
async build(params, ctx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["z","defineExtension","crypto","path","fs","Node","Project","generateBuildParamsFeature","buildParamsDir","ctx","featureFilePath","join","files","readdirSync","filter","f","startsWith","endsWith","imports","map","file","className","parse","name","registrations","featureContent","writeFileSync","updateExtensionsTsx","extensionsTsxFilePath","project","paths","workspaceFolder","toString","addSourceFileAtPath","source","getSourceFileOrThrow","buildParamsFeatureImport","existingFeatureImport","getImportDeclaration","index","importDeclarations","getImportDeclarations","length","last","getChildIndex","insertImportDeclaration","namedImports","moduleSpecifier","buildParamsFeatureImportPath","existingBuildParamsImport","getNamedImports","hasBuildParamsFeature","some","ni","getName","addNamedImport","registerFeatureImportPath","existingRegisterFeatureImport","hasRegisterFeature","extensionsIdentifier","getFirstDescendant","node","isIdentifier","getText","Error","extensionsArrowFn","getNextSibling","isArrowFunction","extensionsArrowFnFragment","isJsxFragment","currentContent","getFullText","replace","trim","includes","newContent","replaceWithText","save","AdminBuildParam","type","tags","runtimeContext","appName","description","multiple","paramsSchema","object","paramName","string","value","union","record","any","array","number","boolean","build","params","valueStr","JSON","stringify","hash","createHash","update","digest","slice","fileName","filePath","existsSync","mkdirSync","recursive","fileContent"],"sources":["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.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"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,SAASC,eAAe;AACxB,OAAOC,MAAM,MAAM,QAAQ;AAC3B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AACnB,SAASC,IAAI,EAAEC,OAAO,QAAQ,UAAU;AAExC,eAAeC,0BAA0BA,CAACC,cAAsB,EAAEC,GAAQ,EAAE;EACxE,MAAMC,eAAe,GAAGP,IAAI,CAACQ,IAAI,CAACH,cAAc,EAAE,YAAY,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","Node","Project","generateBuildParamsFeature","buildParamsDir","ctx","featureFilePath","join","files","readdirSync","filter","f","startsWith","endsWith","imports","map","file","className","parse","name","registrations","featureContent","writeFileSync","updateExtensionsTsx","extensionsTsxFilePath","project","paths","workspaceFolder","toString","addSourceFileAtPath","source","getSourceFileOrThrow","buildParamsFeatureImport","existingFeatureImport","getImportDeclaration","index","importDeclarations","getImportDeclarations","length","last","getChildIndex","insertImportDeclaration","namedImports","moduleSpecifier","buildParamsFeatureImportPath","existingBuildParamsImport","getNamedImports","hasBuildParamsFeature","some","ni","getName","addNamedImport","registerFeatureImportPath","existingRegisterFeatureImport","hasRegisterFeature","extensionsIdentifier","getFirstDescendant","node","isIdentifier","getText","Error","extensionsArrowFn","getNextSibling","isArrowFunction","extensionsArrowFnFragment","isJsxFragment","currentContent","getFullText","replace","trim","includes","newContent","replaceWithText","save","AdminBuildParam","type","tags","runtimeContext","appName","description","multiple","paramsSchema","object","paramName","string","value","union","record","any","array","number","boolean","build","params","valueStr","JSON","stringify","hash","createHash","update","digest","slice","fileName","filePath","existsSync","mkdirSync","recursive","fileContent"],"sources":["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"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,SAASC,eAAe;AACxB,OAAOC,MAAM,MAAM,QAAQ;AAC3B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AACnB,SAASC,IAAI,EAAEC,OAAO,QAAQ,UAAU;AAExC,eAAeC,0BAA0BA,CAACC,cAAsB,EAAEC,GAAQ,EAAE;EACxE,MAAMC,eAAe,GAAGP,IAAI,CAACQ,IAAI,CAACH,cAAc,EAAE,YAAY,CAAC;;EAE/D;EACA,MAAMI,KAAK,GAAGR,EAAE,CACXS,WAAW,CAACL,cAAc,CAAC,CAC3BM,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACC,UAAU,CAAC,aAAa,CAAC,IAAID,CAAC,CAACE,QAAQ,CA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AEuD,SAAS;MAAEE;IAAM,CAAC,GAAGQ,MAAM;;IAEnC;IACA,MAAMC,QAAQ,GAAGC,IAAI,CAACC,SAAS,CAACX,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;;IAE/C;IACA,MAAMY,IAAI,GAAGnG,MAAM,CAACoG,UAAU,CAAC,QAAQ,CAAC,CAACC,MAAM,CAAChB,SAAS,CAAC,CAACiB,MAAM,CAAC,KAAK,CAAC;IACxE,MAAMnF,SAAS,GAAG,cAAcgF,IAAI,CAACI,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE;IACjD,MAAMC,QAAQ,GAAG,GAAGrF,SAAS,KAAK;IAClC,MAAMsF,QAAQ,GAAGxG,IAAI,CAACQ,IAAI,CAACH,cAAc,EAAEkG,QAAQ,CAAC;;IAEpD;IACA,IAAI,CAACtG,EAAE,CAACwG,UAAU,CAACpG,cAAc,CAAC,EAAE;MAChCJ,EAAE,CAACyG,SAAS,CAACrG,cAAc,EAAE;QAAEsG,SAAS,EAAE;MAAK,CAAC,CAAC;IACrD;;IAEA;IACA,IAAI,CAAC1G,EAAE,CAACwG,UAAU,CAACD,QAAQ,CAAC,EAAE;MAC1B;MACA,MAAMI,WAAW,GAAG;AAChC;AACA,QAAQ1F,SAAS;AACjB,aAAakE,SAAS;AACtB,cAAcW,QAAQ;AACtB;AACA;AACA;AACA,sBAAsB7E,SAAS;AAC/B;AACA;AACA,CAAC;MACWjB,EAAE,CAACsB,aAAa,CAACiF,QAAQ,EAAEI,WAAW,EAAE,MAAM,CAAC;IACnD;;IAEA;IACA,MAAMxG,0BAA0B,CAACC,cAAc,EAAEC,GAAG,CAAC;EACzD;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const AdminExtension: import("~/extensions/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
|
-
src: z.
|
|
3
|
+
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
4
4
|
exportName: z.ZodOptional<z.ZodString>;
|
|
5
|
-
},
|
|
6
|
-
src: string;
|
|
7
|
-
exportName?: string | undefined;
|
|
8
|
-
}, {
|
|
9
|
-
src: string;
|
|
10
|
-
exportName?: string | undefined;
|
|
11
|
-
}>>;
|
|
5
|
+
}, z.core.$strip>>;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const BuildParam: import("~/defineExtension/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
3
|
paramName: z.ZodString;
|
|
4
|
-
value: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny
|
|
5
|
-
},
|
|
6
|
-
value: string | number | boolean | any[] | Record<string, any>;
|
|
7
|
-
paramName: string;
|
|
8
|
-
}, {
|
|
9
|
-
value: string | number | boolean | any[] | Record<string, any>;
|
|
10
|
-
paramName: string;
|
|
11
|
-
}>>;
|
|
4
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodArray<z.ZodAny>, z.ZodNumber, z.ZodBoolean]>;
|
|
5
|
+
}, z.core.$strip>>;
|
|
@@ -15,7 +15,7 @@ export const BuildParam = defineExtension({
|
|
|
15
15
|
paramsSchema: () => {
|
|
16
16
|
return z.object({
|
|
17
17
|
paramName: z.string(),
|
|
18
|
-
value: z.union([z.string(), z.record(z.any()), z.array(z.any()), z.number(), z.boolean()])
|
|
18
|
+
value: z.union([z.string(), z.record(z.string(), z.any()), z.array(z.any()), z.number(), z.boolean()])
|
|
19
19
|
});
|
|
20
20
|
},
|
|
21
21
|
async build(params, ctx) {
|
|
@@ -95,7 +95,7 @@ export default BuildParam.createImplementation({
|
|
|
95
95
|
|
|
96
96
|
// Add the registration to the plugins array.
|
|
97
97
|
const pluginsArray = source.getFirstDescendant(node => Node.isArrayLiteralExpression(node));
|
|
98
|
-
pluginsArray.addElement(`\
|
|
98
|
+
pluginsArray.addElement(`\ncreateRegisterExtensionPlugin(ctx => {\n\tregisterExtension(ctx.container, ${className});\n})`);
|
|
99
99
|
{
|
|
100
100
|
let index = 1;
|
|
101
101
|
const importDeclarations = source.getImportDeclarations();
|
|
@@ -103,11 +103,11 @@ export default BuildParam.createImplementation({
|
|
|
103
103
|
const last = importDeclarations[importDeclarations.length - 1];
|
|
104
104
|
index = last.getChildIndex() + 1;
|
|
105
105
|
}
|
|
106
|
-
const contextPluginImportPath = "@webiny/
|
|
106
|
+
const contextPluginImportPath = "@webiny/handler/plugins/RegisterExtensionPlugin.js";
|
|
107
107
|
const existingContextPluginImport = source.getImportDeclaration(contextPluginImportPath);
|
|
108
108
|
if (!existingContextPluginImport) {
|
|
109
109
|
source.insertImportDeclaration(index, {
|
|
110
|
-
namedImports: ["
|
|
110
|
+
namedImports: ["createRegisterExtensionPlugin"],
|
|
111
111
|
moduleSpecifier: contextPluginImportPath
|
|
112
112
|
});
|
|
113
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["z","Node","Project","defineExtension","crypto","path","fs","BuildParam","type","tags","runtimeContext","appName","description","multiple","paramsSchema","object","paramName","string","value","union","record","any","array","number","boolean","build","params","ctx","extensionsTsFilePath","project","paths","workspaceFolder","join","toString","buildParamsDir","valueStr","JSON","stringify","hash","createHash","update","digest","className","slice","fileName","filePath","existsSync","mkdirSync","recursive","fileContent","writeFileSync","addSourceFileAtPath","source","getSourceFileOrThrow","importPath","relative","dirname","replace","startsWith","existingImportDeclaration","getImportDeclaration","index","importDeclarations","getImportDeclarations","length","last","getChildIndex","insertImportDeclaration","defaultImport","moduleSpecifier","pluginsArray","getFirstDescendant","node","isArrayLiteralExpression","addElement","contextPluginImportPath","existingContextPluginImport","namedImports","save"],"sources":["ApiBuildParam.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport crypto from \"crypto\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport const BuildParam = defineExtension({\n type: \"Api/BuildParam\",\n tags: { runtimeContext: \"app-build\", appName: \"api\" },\n description: \"Add build-time parameter to API app.\",\n multiple: true,\n paramsSchema: () => {\n return z.object({\n paramName: z.string(),\n value: z.union([\n z.string(),\n z.record(z.any()),\n z.array(z.any()),\n z.number(),\n z.boolean()\n ])\n });\n },\n async build(params, ctx) {\n const extensionsTsFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"extensions.ts\")\n .toString();\n\n const buildParamsDir = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"buildParams\")\n .toString();\n\n const { paramName, value } = params;\n\n // Serialize value to a TypeScript literal.\n const valueStr = JSON.stringify(value, null, 4);\n\n // Generate a unique class name based on the paramName.\n const hash = crypto.createHash(\"sha256\").update(paramName).digest(\"hex\");\n const className = `BuildParam_${hash.slice(-10)}`;\n const fileName = `${className}.ts`;\n const filePath = path.join(buildParamsDir, fileName);\n\n // Ensure buildParams directory exists.\n if (!fs.existsSync(buildParamsDir)) {\n fs.mkdirSync(buildParamsDir, { recursive: true });\n }\n\n // Check if file already exists.\n if (fs.existsSync(filePath)) {\n // File exists, just ensure it's imported in extensions.ts\n } else {\n // Create the BuildParam implementation file.\n const fileContent = `import { BuildParam } from \"webiny/api/build-params\";\n\nclass ${className} implements BuildParam.Interface {\n key = \"${paramName}\";\n value = ${valueStr};\n}\n\nexport default BuildParam.createImplementation({\n implementation: ${className},\n dependencies: []\n});\n`;\n fs.writeFileSync(filePath, fileContent, \"utf8\");\n }\n\n // Now update extensions.ts to import and register this BuildParam.\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsFilePath);\n\n // Calculate import path relative to extensions.ts.\n let importPath = path\n .relative(path.dirname(extensionsTsFilePath), filePath)\n .replace(/\\.tsx?$/, \".js\");\n\n // Ensure the path starts with ./\n if (!importPath.startsWith(\".\")) {\n importPath = \"./\" + importPath;\n }\n\n // Check if import already exists.\n const existingImportDeclaration = source.getImportDeclaration(importPath);\n if (existingImportDeclaration) {\n return;\n }\n\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Add import for the BuildParam implementation.\n source.insertImportDeclaration(index, {\n defaultImport: className,\n moduleSpecifier: importPath\n });\n\n // Add the registration to the plugins array.\n const pluginsArray = source.getFirstDescendant(node =>\n Node.isArrayLiteralExpression(node)\n ) as ArrayLiteralExpression;\n\n pluginsArray.addElement(\n `\\
|
|
1
|
+
{"version":3,"names":["z","Node","Project","defineExtension","crypto","path","fs","BuildParam","type","tags","runtimeContext","appName","description","multiple","paramsSchema","object","paramName","string","value","union","record","any","array","number","boolean","build","params","ctx","extensionsTsFilePath","project","paths","workspaceFolder","join","toString","buildParamsDir","valueStr","JSON","stringify","hash","createHash","update","digest","className","slice","fileName","filePath","existsSync","mkdirSync","recursive","fileContent","writeFileSync","addSourceFileAtPath","source","getSourceFileOrThrow","importPath","relative","dirname","replace","startsWith","existingImportDeclaration","getImportDeclaration","index","importDeclarations","getImportDeclarations","length","last","getChildIndex","insertImportDeclaration","defaultImport","moduleSpecifier","pluginsArray","getFirstDescendant","node","isArrayLiteralExpression","addElement","contextPluginImportPath","existingContextPluginImport","namedImports","save"],"sources":["ApiBuildParam.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport crypto from \"crypto\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport const BuildParam = defineExtension({\n type: \"Api/BuildParam\",\n tags: { runtimeContext: \"app-build\", appName: \"api\" },\n description: \"Add build-time parameter to API app.\",\n multiple: true,\n paramsSchema: () => {\n return z.object({\n paramName: z.string(),\n value: z.union([\n z.string(),\n z.record(z.string(), z.any()),\n z.array(z.any()),\n z.number(),\n z.boolean()\n ])\n });\n },\n async build(params, ctx) {\n const extensionsTsFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"extensions.ts\")\n .toString();\n\n const buildParamsDir = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"buildParams\")\n .toString();\n\n const { paramName, value } = params;\n\n // Serialize value to a TypeScript literal.\n const valueStr = JSON.stringify(value, null, 4);\n\n // Generate a unique class name based on the paramName.\n const hash = crypto.createHash(\"sha256\").update(paramName).digest(\"hex\");\n const className = `BuildParam_${hash.slice(-10)}`;\n const fileName = `${className}.ts`;\n const filePath = path.join(buildParamsDir, fileName);\n\n // Ensure buildParams directory exists.\n if (!fs.existsSync(buildParamsDir)) {\n fs.mkdirSync(buildParamsDir, { recursive: true });\n }\n\n // Check if file already exists.\n if (fs.existsSync(filePath)) {\n // File exists, just ensure it's imported in extensions.ts\n } else {\n // Create the BuildParam implementation file.\n const fileContent = `import { BuildParam } from \"webiny/api/build-params\";\n\nclass ${className} implements BuildParam.Interface {\n key = \"${paramName}\";\n value = ${valueStr};\n}\n\nexport default BuildParam.createImplementation({\n implementation: ${className},\n dependencies: []\n});\n`;\n fs.writeFileSync(filePath, fileContent, \"utf8\");\n }\n\n // Now update extensions.ts to import and register this BuildParam.\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsFilePath);\n\n // Calculate import path relative to extensions.ts.\n let importPath = path\n .relative(path.dirname(extensionsTsFilePath), filePath)\n .replace(/\\.tsx?$/, \".js\");\n\n // Ensure the path starts with ./\n if (!importPath.startsWith(\".\")) {\n importPath = \"./\" + importPath;\n }\n\n // Check if import already exists.\n const existingImportDeclaration = source.getImportDeclaration(importPath);\n if (existingImportDeclaration) {\n return;\n }\n\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Add import for the BuildParam implementation.\n source.insertImportDeclaration(index, {\n defaultImport: className,\n moduleSpecifier: importPath\n });\n\n // Add the registration to the plugins array.\n const pluginsArray = source.getFirstDescendant(node =>\n Node.isArrayLiteralExpression(node)\n ) as ArrayLiteralExpression;\n\n pluginsArray.addElement(\n `\\ncreateRegisterExtensionPlugin(ctx => {\\n\\tregisterExtension(ctx.container, ${className});\\n})`\n );\n\n {\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n const contextPluginImportPath = \"@webiny/handler/plugins/RegisterExtensionPlugin.js\";\n const existingContextPluginImport =\n source.getImportDeclaration(contextPluginImportPath);\n if (!existingContextPluginImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"createRegisterExtensionPlugin\"],\n moduleSpecifier: contextPluginImportPath\n });\n }\n }\n\n await source.save();\n }\n});\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,SAASC,IAAI,EAAEC,OAAO,QAAgC,UAAU;AAChE,SAASC,eAAe;AACxB,OAAOC,MAAM,MAAM,QAAQ;AAC3B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AAEnB,OAAO,MAAMC,UAAU,GAAGJ,eAAe,CAAC;EACtCK,IAAI,EAAE,gBAAgB;EACtBC,IAAI,EAAE;IAAEC,cAAc,EAAE,WAAW;IAAEC,OAAO,EAAE;EAAM,CAAC;EACrDC,WAAW,EAAE,sCAAsC;EACnDC,QAAQ,EAAE,IAAI;EACdC,YAAY,EAAEA,CAAA,KAAM;IAChB,OAAOd,CAAC,CAACe,MAAM,CAAC;MACZC,SAAS,EAAEhB,CAAC,CAACiB,MAAM,CAAC,CAAC;MACrBC,KAAK,EAAElB,CAAC,CAACmB,KAAK,CAAC,CACXnB,CAAC,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,kBAAkB,CAACE,MAAM,GAAG,CAAC,CAAC;MAC9DH,KAAK,GAAGI,IAAI,CAACC,aAAa,CAAC,CAAC,GAAG,CAAC;IACpC;;IAEA;IACAd,MAAM,CAACe,uBAAuB,CAACN,KAAK,EAAE;MAClCO,aAAa,EAAE1B,SAAS;MACxB2B,eAAe,EAAEf;IACrB,CAAC,CAAC;;IAEF;IACA,MAAMgB,YAAY,GAAGlB,MAAM,CAACmB,kBAAkB,CAACC,IAAI,IAC/CvE,IAAI,CAACwE,wBAAwB,CAACD,IAAI,CACtC,CAA2B;IAE3BF,YAAY,CAACI,UAAU,CACnB,gFAAgFhC,SAAS,QAC7F,CAAC;IAED;MACI,IAAImB,KAAK,GAAG,CAAC;MAEb,MAAMC,kBAAkB,GAAGV,MAAM,CAACW,qBAAqB,CAAC,CAAC;MACzD,IAAID,kBAAkB,CAACE,MAAM,EAAE;QAC3B,MAAMC,IAAI,GAAGH,kBAAkB,CAACA,kBAAkB,CAACE,MAAM,GAAG,CAAC,CAAC;QAC9DH,KAAK,GAAGI,IAAI,CAACC,aAAa,CAAC,CAAC,GAAG,CAAC;MACpC;MAEA,MAAMS,uBAAuB,GAAG,oDAAoD;MACpF,MAAMC,2BAA2B,GAC7BxB,MAAM,CAACQ,oBAAoB,CAACe,uBAAuB,CAAC;MACxD,IAAI,CAACC,2BAA2B,EAAE;QAC9BxB,MAAM,CAACe,uBAAuB,CAACN,KAAK,EAAE;UAClCgB,YAAY,EAAE,CAAC,+BAA+B,CAAC;UAC/CR,eAAe,EAAEM;QACrB,CAAC,CAAC;MACN;IACJ;IAEA,MAAMvB,MAAM,CAAC0B,IAAI,CAAC,CAAC;EACvB;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const ApiExtension: import("~/extensions/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
|
-
src: z.
|
|
3
|
+
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
4
4
|
exportName: z.ZodOptional<z.ZodString>;
|
|
5
|
-
},
|
|
6
|
-
src: string;
|
|
7
|
-
exportName?: string | undefined;
|
|
8
|
-
}, {
|
|
9
|
-
src: string;
|
|
10
|
-
exportName?: string | undefined;
|
|
11
|
-
}>>;
|
|
5
|
+
}, z.core.$strip>>;
|
|
@@ -78,7 +78,7 @@ export const ApiExtension = defineExtension({
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
const pluginsArray = source.getFirstDescendant(node => Node.isArrayLiteralExpression(node));
|
|
81
|
-
pluginsArray.addElement(`\
|
|
81
|
+
pluginsArray.addElement(`\ncreateRegisterExtensionPlugin(ctx => {\n\tregisterExtension(ctx.container, ${exportNameAlias});\n})`);
|
|
82
82
|
{
|
|
83
83
|
let index = 1;
|
|
84
84
|
const importDeclarations = source.getImportDeclarations();
|
|
@@ -86,12 +86,12 @@ export const ApiExtension = defineExtension({
|
|
|
86
86
|
const last = importDeclarations[importDeclarations.length - 1];
|
|
87
87
|
index = last.getChildIndex() + 1;
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
const existingContextPluginImport = source.getImportDeclaration(
|
|
89
|
+
const registerExtensionPluginImportPath = "@webiny/handler/plugins/RegisterExtensionPlugin.js";
|
|
90
|
+
const existingContextPluginImport = source.getImportDeclaration(registerExtensionPluginImportPath);
|
|
91
91
|
if (!existingContextPluginImport) {
|
|
92
92
|
source.insertImportDeclaration(index, {
|
|
93
|
-
namedImports: ["
|
|
94
|
-
moduleSpecifier:
|
|
93
|
+
namedImports: ["createRegisterExtensionPlugin"],
|
|
94
|
+
moduleSpecifier: registerExtensionPluginImportPath
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|