@webiny/project 6.6.0-alpha.1 → 6.6.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ProjectSdk.d.ts +8 -19
- package/ProjectSdk.js +1 -28
- package/ProjectSdk.js.map +1 -1
- package/abstractions/features/hooks/index.d.ts +0 -8
- package/abstractions/features/hooks/index.js +0 -8
- package/abstractions/features/index.d.ts +0 -8
- package/abstractions/features/index.js +0 -8
- package/abstractions/models/IAppModel.d.ts +0 -2
- package/abstractions/models/IProjectModel.d.ts +0 -2
- package/abstractions/services/InitHostingSdkService.d.ts +21 -0
- package/abstractions/services/InitHostingSdkService.js +5 -0
- package/abstractions/services/InitHostingSdkService.js.map +1 -0
- package/abstractions/services/ProjectInfoService/ProjectInfoService.d.ts +6 -6
- package/abstractions/services/ProjectInfoService/ProjectInfoService.js.map +1 -1
- package/abstractions/services/ProjectInfoService/index.d.ts +0 -1
- package/abstractions/services/ProjectInfoService/index.js +0 -1
- package/abstractions/services/index.d.ts +1 -13
- package/abstractions/services/index.js +1 -13
- package/components/FeatureFlag.d.ts +9 -4
- package/components/FeatureFlag.js +6 -7
- package/components/FeatureFlag.js.map +1 -1
- package/createProjectSdkContainer.js +23 -12
- package/createProjectSdkContainer.js.map +1 -1
- package/decorators/GetFeatureFlagsWithLicense.js +1 -0
- package/decorators/GetFeatureFlagsWithLicense.js.map +1 -1
- package/decorators/index.d.ts +0 -6
- package/decorators/index.js +0 -6
- package/defineExtension/createExtensionReactComponent.js +9 -1
- package/defineExtension/createExtensionReactComponent.js.map +1 -1
- package/defineExtension/types.d.ts +7 -2
- package/exports/infra/admin.d.ts +0 -2
- package/exports/infra/admin.js +0 -2
- package/exports/infra/api.d.ts +0 -2
- package/exports/infra/api.js +0 -2
- package/exports/infra/core.d.ts +0 -2
- package/exports/infra/core.js +0 -2
- package/exports/infra.d.ts +0 -2
- package/exports/infra.js +0 -2
- 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/{pulumi/ProductionEnvironments.js → ProductionEnvironments.js} +4 -3
- package/extensions/ProductionEnvironments.js.map +1 -0
- 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.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/Route/ApiRoute.d.ts +23 -0
- package/extensions/api/Route/ApiRoute.js +92 -0
- package/extensions/api/Route/ApiRoute.js.map +1 -0
- package/extensions/api/Route/index.d.ts +2 -0
- package/extensions/api/Route/index.js +2 -0
- package/extensions/api/Route/routePath.d.ts +20 -0
- package/extensions/api/Route/routePath.js +10 -0
- package/extensions/api/Route/routePath.js.map +1 -0
- package/extensions/api/index.d.ts +5 -0
- package/extensions/api/index.js +5 -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/AdminBeforeBuild.js +2 -1
- package/extensions/hooks/AdminBeforeBuild.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/ApiAfterBuild.js +2 -1
- package/extensions/hooks/ApiAfterBuild.js.map +1 -1
- package/extensions/hooks/ApiBeforeBuild.js +2 -1
- package/extensions/hooks/ApiBeforeBuild.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/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/CoreBeforeBuild.js +2 -1
- package/extensions/hooks/CoreBeforeBuild.js.map +1 -1
- package/extensions/hooks/CoreBeforeWatch.js +2 -1
- package/extensions/hooks/CoreBeforeWatch.js.map +1 -1
- package/extensions/hooks/index.d.ts +0 -8
- package/extensions/hooks/index.js +0 -8
- 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 +13 -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 +26 -39
- package/extensions/index.js +10 -21
- package/extensions/index.js.map +1 -1
- package/extensions/infra/Env.js +5 -0
- package/extensions/infra/Env.js.map +1 -1
- package/features/GetProductionEnvironments/GetProductionEnvironments.js +1 -1
- package/features/GetProductionEnvironments/GetProductionEnvironments.js.map +1 -1
- 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/features/hooks/index.d.ts +0 -8
- package/features/hooks/index.js +0 -8
- package/features/index.d.ts +0 -8
- package/features/index.js +0 -8
- package/index.d.ts +0 -4
- package/index.js +1 -5
- package/index.js.map +1 -1
- package/models/AppModel.js +1 -2
- package/models/AppModel.js.map +1 -1
- package/models/ProjectModel.js +0 -2
- package/models/ProjectModel.js.map +1 -1
- package/package.json +29 -34
- package/services/GetAppService/GetAppService.js +1 -3
- package/services/GetAppService/GetAppService.js.map +1 -1
- 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/GetProjectService/GetProjectService.js +0 -2
- package/services/GetProjectService/GetProjectService.js.map +1 -1
- package/services/InitProjectSdkService/InitProjectSdkService.d.ts +6 -2
- package/services/InitProjectSdkService/InitProjectSdkService.js +22 -19
- 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/InitProjectSdkService/registerHooks.js +4 -16
- package/services/InitProjectSdkService/registerHooks.js.map +1 -1
- package/services/ProjectInfoService/ProjectInfoService.d.ts +7 -3
- package/services/ProjectInfoService/ProjectInfoService.js +3 -11
- package/services/ProjectInfoService/ProjectInfoService.js.map +1 -1
- package/services/ProjectInfoService/index.d.ts +0 -1
- package/services/ProjectInfoService/index.js +0 -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/services/index.d.ts +0 -12
- package/services/index.js +0 -12
- 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/env/index.d.ts +0 -1
- package/utils/env/index.js +0 -1
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -0
- package/utils/registerSrcExtensions.d.ts +13 -0
- package/utils/registerSrcExtensions.js +10 -0
- package/utils/registerSrcExtensions.js.map +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/abstractions/features/DeployApp.d.ts +0 -20
- package/abstractions/features/DeployApp.js +0 -5
- package/abstractions/features/DeployApp.js.map +0 -1
- package/abstractions/features/DestroyApp.d.ts +0 -18
- package/abstractions/features/DestroyApp.js +0 -5
- package/abstractions/features/DestroyApp.js.map +0 -1
- package/abstractions/features/ExportStack.d.ts +0 -18
- package/abstractions/features/ExportStack.js +0 -5
- package/abstractions/features/ExportStack.js.map +0 -1
- package/abstractions/features/GetAppOutput.d.ts +0 -18
- package/abstractions/features/GetAppOutput.js +0 -5
- package/abstractions/features/GetAppOutput.js.map +0 -1
- package/abstractions/features/GetAppStackOutput.d.ts +0 -21
- package/abstractions/features/GetAppStackOutput.js +0 -5
- package/abstractions/features/GetAppStackOutput.js.map +0 -1
- package/abstractions/features/GetPulumiResourceNamePrefix.d.ts +0 -7
- package/abstractions/features/GetPulumiResourceNamePrefix.js +0 -5
- package/abstractions/features/GetPulumiResourceNamePrefix.js.map +0 -1
- package/abstractions/features/RefreshApp.d.ts +0 -18
- package/abstractions/features/RefreshApp.js +0 -5
- package/abstractions/features/RefreshApp.js.map +0 -1
- package/abstractions/features/RunPulumiCommand.d.ts +0 -19
- package/abstractions/features/RunPulumiCommand.js +0 -5
- package/abstractions/features/RunPulumiCommand.js.map +0 -1
- package/abstractions/features/hooks/AdminAfterDeploy.d.ts +0 -9
- package/abstractions/features/hooks/AdminAfterDeploy.js +0 -5
- package/abstractions/features/hooks/AdminAfterDeploy.js.map +0 -1
- package/abstractions/features/hooks/AdminBeforeDeploy.d.ts +0 -9
- package/abstractions/features/hooks/AdminBeforeDeploy.js +0 -5
- package/abstractions/features/hooks/AdminBeforeDeploy.js.map +0 -1
- package/abstractions/features/hooks/AfterDeploy.d.ts +0 -9
- package/abstractions/features/hooks/AfterDeploy.js +0 -5
- package/abstractions/features/hooks/AfterDeploy.js.map +0 -1
- package/abstractions/features/hooks/ApiAfterDeploy.d.ts +0 -9
- package/abstractions/features/hooks/ApiAfterDeploy.js +0 -5
- package/abstractions/features/hooks/ApiAfterDeploy.js.map +0 -1
- package/abstractions/features/hooks/ApiBeforeDeploy.d.ts +0 -9
- package/abstractions/features/hooks/ApiBeforeDeploy.js +0 -5
- package/abstractions/features/hooks/ApiBeforeDeploy.js.map +0 -1
- package/abstractions/features/hooks/BeforeDeploy.d.ts +0 -9
- package/abstractions/features/hooks/BeforeDeploy.js +0 -5
- package/abstractions/features/hooks/BeforeDeploy.js.map +0 -1
- package/abstractions/features/hooks/CoreAfterDeploy.d.ts +0 -9
- package/abstractions/features/hooks/CoreAfterDeploy.js +0 -5
- package/abstractions/features/hooks/CoreAfterDeploy.js.map +0 -1
- package/abstractions/features/hooks/CoreBeforeDeploy.d.ts +0 -9
- package/abstractions/features/hooks/CoreBeforeDeploy.js +0 -5
- package/abstractions/features/hooks/CoreBeforeDeploy.js.map +0 -1
- package/abstractions/services/GetPulumiService.d.ts +0 -14
- package/abstractions/services/GetPulumiService.js +0 -5
- package/abstractions/services/GetPulumiService.js.map +0 -1
- package/abstractions/services/IsRemotePulumiBackendService.d.ts +0 -7
- package/abstractions/services/IsRemotePulumiBackendService.js +0 -5
- package/abstractions/services/IsRemotePulumiBackendService.js.map +0 -1
- package/abstractions/services/ListAppLambdaFunctionsService.d.ts +0 -23
- package/abstractions/services/ListAppLambdaFunctionsService.js +0 -5
- package/abstractions/services/ListAppLambdaFunctionsService.js.map +0 -1
- package/abstractions/services/ListDeployedEnvironmentsService.d.ts +0 -12
- package/abstractions/services/ListDeployedEnvironmentsService.js +0 -5
- package/abstractions/services/ListDeployedEnvironmentsService.js.map +0 -1
- package/abstractions/services/ProjectInfoService/GetPulumiVersionService.d.ts +0 -12
- package/abstractions/services/ProjectInfoService/GetPulumiVersionService.js +0 -5
- package/abstractions/services/ProjectInfoService/GetPulumiVersionService.js.map +0 -1
- package/abstractions/services/PulumiExportService.d.ts +0 -13
- package/abstractions/services/PulumiExportService.js +0 -6
- package/abstractions/services/PulumiExportService.js.map +0 -1
- package/abstractions/services/PulumiGetConfigPassphraseService.d.ts +0 -7
- package/abstractions/services/PulumiGetConfigPassphraseService.js +0 -5
- package/abstractions/services/PulumiGetConfigPassphraseService.js.map +0 -1
- package/abstractions/services/PulumiGetSecretsProviderService.d.ts +0 -7
- package/abstractions/services/PulumiGetSecretsProviderService.js +0 -5
- package/abstractions/services/PulumiGetSecretsProviderService.js.map +0 -1
- package/abstractions/services/PulumiGetStackOutputService.d.ts +0 -13
- package/abstractions/services/PulumiGetStackOutputService.js +0 -5
- package/abstractions/services/PulumiGetStackOutputService.js.map +0 -1
- package/abstractions/services/PulumiImportService.d.ts +0 -8
- package/abstractions/services/PulumiImportService.js +0 -5
- package/abstractions/services/PulumiImportService.js.map +0 -1
- package/abstractions/services/PulumiLoginService.d.ts +0 -16
- package/abstractions/services/PulumiLoginService.js +0 -5
- package/abstractions/services/PulumiLoginService.js.map +0 -1
- package/abstractions/services/PulumiSelectStackService.d.ts +0 -10
- package/abstractions/services/PulumiSelectStackService.js +0 -5
- package/abstractions/services/PulumiSelectStackService.js.map +0 -1
- package/abstractions/services/StackOutputCacheService.d.ts +0 -10
- package/abstractions/services/StackOutputCacheService.js +0 -5
- package/abstractions/services/StackOutputCacheService.js.map +0 -1
- package/abstractions/services/WatchedLambdaFunctionsService.d.ts +0 -28
- package/abstractions/services/WatchedLambdaFunctionsService.js +0 -5
- package/abstractions/services/WatchedLambdaFunctionsService.js.map +0 -1
- package/decorators/DeployAppClearWatchedLambdaFunctions.d.ts +0 -17
- package/decorators/DeployAppClearWatchedLambdaFunctions.js +0 -32
- package/decorators/DeployAppClearWatchedLambdaFunctions.js.map +0 -1
- package/decorators/DeployAppRefreshStackOutputCache.d.ts +0 -17
- package/decorators/DeployAppRefreshStackOutputCache.js +0 -32
- package/decorators/DeployAppRefreshStackOutputCache.js.map +0 -1
- package/decorators/DeployAppWithHooks.d.ts +0 -17
- package/decorators/DeployAppWithHooks.js +0 -58
- package/decorators/DeployAppWithHooks.js.map +0 -1
- package/decorators/DeployAppWithWatchedLambdaReplacement.d.ts +0 -17
- package/decorators/DeployAppWithWatchedLambdaReplacement.js +0 -39
- package/decorators/DeployAppWithWatchedLambdaReplacement.js.map +0 -1
- package/decorators/DestroyAppClearStackOutputCache.d.ts +0 -25
- package/decorators/DestroyAppClearStackOutputCache.js +0 -29
- package/decorators/DestroyAppClearStackOutputCache.js.map +0 -1
- package/decorators/GetPulumiServiceWithDownloadInfo.d.ts +0 -11
- package/decorators/GetPulumiServiceWithDownloadInfo.js +0 -27
- package/decorators/GetPulumiServiceWithDownloadInfo.js.map +0 -1
- package/extensions/ApiMaxBundleSize.d.ts +0 -4
- package/extensions/ApiMaxBundleSize.js +0 -23
- package/extensions/ApiMaxBundleSize.js.map +0 -1
- package/extensions/hooks/AdminAfterDeploy.d.ts +0 -4
- package/extensions/hooks/AdminAfterDeploy.js +0 -22
- package/extensions/hooks/AdminAfterDeploy.js.map +0 -1
- package/extensions/hooks/AdminBeforeDeploy.d.ts +0 -4
- package/extensions/hooks/AdminBeforeDeploy.js +0 -22
- package/extensions/hooks/AdminBeforeDeploy.js.map +0 -1
- package/extensions/hooks/AfterDeploy.d.ts +0 -4
- package/extensions/hooks/AfterDeploy.js +0 -21
- package/extensions/hooks/AfterDeploy.js.map +0 -1
- package/extensions/hooks/ApiAfterDeploy.d.ts +0 -4
- package/extensions/hooks/ApiAfterDeploy.js +0 -22
- package/extensions/hooks/ApiAfterDeploy.js.map +0 -1
- package/extensions/hooks/ApiBeforeDeploy.d.ts +0 -4
- package/extensions/hooks/ApiBeforeDeploy.js +0 -22
- package/extensions/hooks/ApiBeforeDeploy.js.map +0 -1
- package/extensions/hooks/BeforeDeploy.d.ts +0 -4
- package/extensions/hooks/BeforeDeploy.js +0 -21
- package/extensions/hooks/BeforeDeploy.js.map +0 -1
- package/extensions/hooks/CoreAfterDeploy.d.ts +0 -4
- package/extensions/hooks/CoreAfterDeploy.js +0 -22
- package/extensions/hooks/CoreAfterDeploy.js.map +0 -1
- package/extensions/hooks/CoreBeforeDeploy.d.ts +0 -4
- package/extensions/hooks/CoreBeforeDeploy.js +0 -22
- package/extensions/hooks/CoreBeforeDeploy.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/extensions/pulumi/ProductionEnvironments.js.map +0 -1
- package/extensions/pulumi/PulumiResourceNamePrefix.d.ts +0 -4
- package/extensions/pulumi/PulumiResourceNamePrefix.js +0 -15
- package/extensions/pulumi/PulumiResourceNamePrefix.js.map +0 -1
- package/extensions/pulumi/index.d.ts +0 -5
- package/extensions/pulumi/index.js +0 -5
- package/features/DeployApp/DeployApp.d.ts +0 -14
- package/features/DeployApp/DeployApp.js +0 -86
- package/features/DeployApp/DeployApp.js.map +0 -1
- package/features/DeployApp/index.d.ts +0 -1
- package/features/DeployApp/index.js +0 -1
- package/features/DestroyApp/DestroyApp.d.ts +0 -14
- package/features/DestroyApp/DestroyApp.js +0 -66
- package/features/DestroyApp/DestroyApp.js.map +0 -1
- package/features/DestroyApp/index.d.ts +0 -1
- package/features/DestroyApp/index.js +0 -1
- package/features/ExportStack/ExportStack.d.ts +0 -9
- package/features/ExportStack/ExportStack.js +0 -26
- package/features/ExportStack/ExportStack.js.map +0 -1
- package/features/ExportStack/index.d.ts +0 -1
- package/features/ExportStack/index.js +0 -1
- package/features/GetAppOutput/GetAppOutput.d.ts +0 -12
- package/features/GetAppOutput/GetAppOutput.js +0 -51
- package/features/GetAppOutput/GetAppOutput.js.map +0 -1
- package/features/GetAppOutput/index.d.ts +0 -1
- package/features/GetAppOutput/index.js +0 -1
- package/features/GetAppStackOutput/GetAppStackOutput.d.ts +0 -10
- package/features/GetAppStackOutput/GetAppStackOutput.js +0 -26
- package/features/GetAppStackOutput/GetAppStackOutput.js.map +0 -1
- package/features/GetAppStackOutput/index.d.ts +0 -1
- package/features/GetAppStackOutput/index.js +0 -1
- package/features/GetPulumiResourceNamePrefix/GetPulumiResourceNamePrefix.d.ts +0 -7
- package/features/GetPulumiResourceNamePrefix/GetPulumiResourceNamePrefix.js +0 -25
- package/features/GetPulumiResourceNamePrefix/GetPulumiResourceNamePrefix.js.map +0 -1
- package/features/GetPulumiResourceNamePrefix/index.d.ts +0 -1
- package/features/GetPulumiResourceNamePrefix/index.js +0 -1
- package/features/RefreshApp/RefreshApp.d.ts +0 -13
- package/features/RefreshApp/RefreshApp.js +0 -64
- package/features/RefreshApp/RefreshApp.js.map +0 -1
- package/features/RefreshApp/index.d.ts +0 -1
- package/features/RefreshApp/index.js +0 -1
- package/features/RunPulumiCommand/RunPulumiCommand.d.ts +0 -13
- package/features/RunPulumiCommand/RunPulumiCommand.js +0 -61
- package/features/RunPulumiCommand/RunPulumiCommand.js.map +0 -1
- package/features/RunPulumiCommand/index.d.ts +0 -1
- package/features/RunPulumiCommand/index.js +0 -1
- package/features/Watch/handler/handler.zip +0 -0
- package/features/Watch/initInvocationForwarding.d.ts +0 -9
- package/features/Watch/initInvocationForwarding.js +0 -91
- package/features/Watch/initInvocationForwarding.js.map +0 -1
- package/features/Watch/localInvocationWorker.js +0 -31
- package/features/Watch/localInvocationWorker.js.map +0 -1
- package/features/hooks/AdminAfterDeploy/AdminBeforeBuild.d.ts +0 -7
- package/features/hooks/AdminAfterDeploy/AdminBeforeBuild.js +0 -25
- package/features/hooks/AdminAfterDeploy/AdminBeforeBuild.js.map +0 -1
- package/features/hooks/AdminAfterDeploy/index.d.ts +0 -1
- package/features/hooks/AdminAfterDeploy/index.js +0 -1
- package/features/hooks/AdminBeforeDeploy/AdminBeforeDeploy.d.ts +0 -7
- package/features/hooks/AdminBeforeDeploy/AdminBeforeDeploy.js +0 -25
- package/features/hooks/AdminBeforeDeploy/AdminBeforeDeploy.js.map +0 -1
- package/features/hooks/AdminBeforeDeploy/index.d.ts +0 -1
- package/features/hooks/AdminBeforeDeploy/index.js +0 -1
- package/features/hooks/AfterDeploy/AfterDeploy.d.ts +0 -7
- package/features/hooks/AfterDeploy/AfterDeploy.js +0 -25
- package/features/hooks/AfterDeploy/AfterDeploy.js.map +0 -1
- package/features/hooks/AfterDeploy/index.d.ts +0 -1
- package/features/hooks/AfterDeploy/index.js +0 -1
- package/features/hooks/ApiAfterDeploy/ApiBeforeBuild.d.ts +0 -7
- package/features/hooks/ApiAfterDeploy/ApiBeforeBuild.js +0 -25
- package/features/hooks/ApiAfterDeploy/ApiBeforeBuild.js.map +0 -1
- package/features/hooks/ApiAfterDeploy/index.d.ts +0 -1
- package/features/hooks/ApiAfterDeploy/index.js +0 -1
- package/features/hooks/ApiBeforeDeploy/ApiBeforeDeploy.d.ts +0 -7
- package/features/hooks/ApiBeforeDeploy/ApiBeforeDeploy.js +0 -25
- package/features/hooks/ApiBeforeDeploy/ApiBeforeDeploy.js.map +0 -1
- package/features/hooks/ApiBeforeDeploy/index.d.ts +0 -1
- package/features/hooks/ApiBeforeDeploy/index.js +0 -1
- package/features/hooks/BeforeDeploy/BeforeDeploy.d.ts +0 -7
- package/features/hooks/BeforeDeploy/BeforeDeploy.js +0 -25
- package/features/hooks/BeforeDeploy/BeforeDeploy.js.map +0 -1
- package/features/hooks/BeforeDeploy/index.d.ts +0 -1
- package/features/hooks/BeforeDeploy/index.js +0 -1
- package/features/hooks/CoreAfterDeploy/CoreBeforeBuild.d.ts +0 -7
- package/features/hooks/CoreAfterDeploy/CoreBeforeBuild.js +0 -25
- package/features/hooks/CoreAfterDeploy/CoreBeforeBuild.js.map +0 -1
- package/features/hooks/CoreAfterDeploy/index.d.ts +0 -1
- package/features/hooks/CoreAfterDeploy/index.js +0 -1
- package/features/hooks/CoreBeforeDeploy/CoreBeforeDeploy.d.ts +0 -7
- package/features/hooks/CoreBeforeDeploy/CoreBeforeDeploy.js +0 -25
- package/features/hooks/CoreBeforeDeploy/CoreBeforeDeploy.js.map +0 -1
- package/features/hooks/CoreBeforeDeploy/index.d.ts +0 -1
- package/features/hooks/CoreBeforeDeploy/index.js +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
- package/services/InitProjectSdkService/registerPulumiExtensions.d.ts +0 -4
- package/services/InitProjectSdkService/registerPulumiExtensions.js +0 -16
- package/services/InitProjectSdkService/registerPulumiExtensions.js.map +0 -1
- package/services/IsRemotePulumiBackendService/IsRemotePulumiBackendService.d.ts +0 -14
- package/services/IsRemotePulumiBackendService/IsRemotePulumiBackendService.js +0 -15
- package/services/IsRemotePulumiBackendService/IsRemotePulumiBackendService.js.map +0 -1
- package/services/IsRemotePulumiBackendService/index.d.ts +0 -1
- package/services/IsRemotePulumiBackendService/index.js +0 -1
- package/services/ListAppLambdaFunctionsService/ListAppLambdaFunctionsService.d.ts +0 -18
- package/services/ListAppLambdaFunctionsService/ListAppLambdaFunctionsService.js +0 -61
- package/services/ListAppLambdaFunctionsService/ListAppLambdaFunctionsService.js.map +0 -1
- package/services/ListAppLambdaFunctionsService/index.d.ts +0 -1
- package/services/ListAppLambdaFunctionsService/index.js +0 -1
- package/services/ListDeployedEnvironmentsService/ListDeployedEnvironmentsService.d.ts +0 -7
- package/services/ListDeployedEnvironmentsService/ListDeployedEnvironmentsService.js +0 -30
- package/services/ListDeployedEnvironmentsService/ListDeployedEnvironmentsService.js.map +0 -1
- package/services/ListDeployedEnvironmentsService/index.d.ts +0 -1
- package/services/ListDeployedEnvironmentsService/index.js +0 -1
- package/services/ProjectInfoService/GetPulumiVersionService.d.ts +0 -5
- package/services/ProjectInfoService/GetPulumiVersionService.js +0 -46
- package/services/ProjectInfoService/GetPulumiVersionService.js.map +0 -1
- package/services/PulumiExportService/PulumiExportService.d.ts +0 -13
- package/services/PulumiExportService/PulumiExportService.js +0 -50
- package/services/PulumiExportService/PulumiExportService.js.map +0 -1
- package/services/PulumiExportService/index.d.ts +0 -1
- package/services/PulumiExportService/index.js +0 -1
- package/services/PulumiGetConfigPassphraseService/PulumiGetConfigPassphraseService.d.ts +0 -5
- package/services/PulumiGetConfigPassphraseService/PulumiGetConfigPassphraseService.js +0 -15
- package/services/PulumiGetConfigPassphraseService/PulumiGetConfigPassphraseService.js.map +0 -1
- package/services/PulumiGetConfigPassphraseService/index.d.ts +0 -1
- package/services/PulumiGetConfigPassphraseService/index.js +0 -1
- package/services/PulumiGetSecretsProviderService/PulumiGetSecretsProviderService.d.ts +0 -5
- package/services/PulumiGetSecretsProviderService/PulumiGetSecretsProviderService.js +0 -15
- package/services/PulumiGetSecretsProviderService/PulumiGetSecretsProviderService.js.map +0 -1
- package/services/PulumiGetSecretsProviderService/index.d.ts +0 -1
- package/services/PulumiGetSecretsProviderService/index.js +0 -1
- package/services/PulumiGetStackOutputService/PulumiGetStackOutputService.d.ts +0 -12
- package/services/PulumiGetStackOutputService/PulumiGetStackOutputService.js +0 -64
- package/services/PulumiGetStackOutputService/PulumiGetStackOutputService.js.map +0 -1
- package/services/PulumiGetStackOutputService/index.d.ts +0 -1
- package/services/PulumiGetStackOutputService/index.js +0 -1
- package/services/PulumiGetStackOutputService/mapStackOutput.d.ts +0 -1
- package/services/PulumiGetStackOutputService/mapStackOutput.js +0 -22
- package/services/PulumiGetStackOutputService/mapStackOutput.js.map +0 -1
- package/services/PulumiImportService/PulumiImportService.d.ts +0 -10
- package/services/PulumiImportService/PulumiImportService.js +0 -60
- package/services/PulumiImportService/PulumiImportService.js.map +0 -1
- package/services/PulumiImportService/index.d.ts +0 -1
- package/services/PulumiImportService/index.js +0 -1
- package/services/PulumiLoginService/PulumiLoginService.d.ts +0 -10
- package/services/PulumiLoginService/PulumiLoginService.js +0 -54
- package/services/PulumiLoginService/PulumiLoginService.js.map +0 -1
- package/services/PulumiLoginService/index.d.ts +0 -1
- package/services/PulumiLoginService/index.js +0 -1
- package/services/PulumiSelectStackService/PulumiSelectStackService.d.ts +0 -15
- package/services/PulumiSelectStackService/PulumiSelectStackService.js +0 -102
- package/services/PulumiSelectStackService/PulumiSelectStackService.js.map +0 -1
- package/services/PulumiSelectStackService/index.d.ts +0 -1
- package/services/PulumiSelectStackService/index.js +0 -1
- package/services/StackOutputCacheService/StackOutputCacheService.d.ts +0 -18
- package/services/StackOutputCacheService/StackOutputCacheService.js +0 -89
- package/services/StackOutputCacheService/StackOutputCacheService.js.map +0 -1
- package/services/StackOutputCacheService/index.d.ts +0 -1
- package/services/StackOutputCacheService/index.js +0 -1
- package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.d.ts +0 -13
- package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.js +0 -54
- package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.js.map +0 -1
- package/services/WatchedLambdaFunctionsService/index.d.ts +0 -1
- package/services/WatchedLambdaFunctionsService/index.js +0 -1
- package/utils/env/withPulumiConfigPassphrase.d.ts +0 -1
- package/utils/env/withPulumiConfigPassphrase.js +0 -7
- package/utils/env/withPulumiConfigPassphrase.js.map +0 -1
- /package/extensions/{pulumi/ProductionEnvironments.d.ts → ProductionEnvironments.d.ts} +0 -0
- /package/{features/Watch/localInvocationWorker.d.ts → extensions/api/Mailer/Smtp.test.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/InitProjectSdkService/applyWcpEnvVars.js","sources":["../../../src/services/InitProjectSdkService/applyWcpEnvVars.ts"],"sourcesContent":["import { encrypt, decrypt } from \"@webiny/wcp\";\nimport type { ILicense } from \"@webiny/wcp/types\";\nimport { Container } from \"@webiny/di\";\nimport {\n GetProjectIdService,\n LoggerService,\n ProjectSdkParamsService,\n WcpService\n} from \"~/abstractions/index.js\";\n\nexport const applyWcpEnvVars = async (container: Container) => {\n /**\n * The environment variables we set via these hooks are the following:\n * - WCP_PROJECT_ENVIRONMENT - contains encrypted data about the deployed project environment\n * - WEBINY_PROJECT_API_KEY / WCP_PROJECT_ENVIRONMENT_API_KEY - for easier access, we also set the API key\n * - WCP_PROJECT_LICENSE - contains encrypted license data\n */\n\n /**\n * There are multiple ways the hooks below prepare the WCP-enabled project for deployment.\n * 1. If `WCP_PROJECT_ENVIRONMENT` metadata env var is defined, we decrypt it, retrieve the\n * API key from it, and assign it as the `WEBINY_PROJECT_API_KEY` and `WCP_PROJECT_ENVIRONMENT_API_KEY` env vars.\n * 2. If `WEBINY_PROJECT_API_KEY` or `WCP_PROJECT_ENVIRONMENT_API_KEY` env var is defined, then we use that as the\n * project environment API key. We use that to load the project environment data\n * and to also assign the `WCP_PROJECT_ENVIRONMENT` metadata env var.\n * 3. If none of the above is defined, we retrieve (or create) the project environment,\n * retrieve its API key and again assign it as `WEBINY_PROJECT_API_KEY` and `WCP_PROJECT_ENVIRONMENT_API_KEY` env vars.\n * As in 2), we also assign the `WCP_PROJECT_ENVIRONMENT` metadata env var.\n */\n\n const getProjectIdService = container.resolve(GetProjectIdService);\n const wcpService = container.resolve(WcpService);\n const loggerService = container.resolve(LoggerService);\n const projectSdkParamsService = container.resolve(ProjectSdkParamsService);\n\n const wcpProjectId = await getProjectIdService.execute();\n\n // If the project isn't linked with WCP, do nothing.\n if (!wcpProjectId) {\n loggerService.debug(\n 'Was not able to determine the WCP project ID. Skipping the setting of \"WCP_PROJECT_ENVIRONMENT\" and \"WCP_PROJECT_ENVIRONMENT_API_KEY\" env vars.'\n );\n return;\n }\n\n // Case 1: For development purposes, we allow setting the WCP_PROJECT_ENVIRONMENT env var directly.\n if (process.env.WCP_PROJECT_ENVIRONMENT) {\n loggerService.info(\n 'The \"WCP_PROJECT_ENVIRONMENT\" env var is already set. Using that value and skipping the rest of the process.'\n );\n // If we have WCP_PROJECT_ENVIRONMENT env var, we set the WEBINY_PROJECT_API_KEY and WCP_PROJECT_ENVIRONMENT_API_KEY too.\n const decryptedProjectEnvironment = decrypt(process.env.WCP_PROJECT_ENVIRONMENT);\n process.env.WEBINY_PROJECT_API_KEY = decryptedProjectEnvironment.apiKey;\n process.env.WCP_PROJECT_ENVIRONMENT_API_KEY = decryptedProjectEnvironment.apiKey;\n return;\n }\n\n // The `id` has the orgId/projectId structure, for example `my-org-x/my-project-y`.\n const [orgId, projectId] = wcpProjectId.split(\"/\");\n\n // Check if API key is already set (prefer WEBINY_PROJECT_API_KEY over WCP_PROJECT_ENVIRONMENT_API_KEY).\n const apiKey =\n process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;\n\n const sdkParams = projectSdkParamsService.get();\n const env = sdkParams.env;\n\n let projectEnvironment;\n if (apiKey) {\n projectEnvironment = await wcpService.getProjectEnvironment({ apiKey });\n } else {\n const isValidId = orgId && projectId;\n if (!isValidId) {\n loggerService.error(\n { orgId, projectId, wcpProjectId },\n `The project ID, specified in \"webiny.config.tsx\" file, seems to be invalid.`\n );\n throw new Error(\n `It seems the project ID, specified in \"webiny.config.tsx\" file, is invalid.`\n );\n }\n\n // If there is no API key, that means we need to retrieve the currently logged-in user.\n const user = await wcpService.getUser();\n if (!user) {\n throw new Error(\n `It seems you are not logged into your WCP project. Please log in using the \"yarn webiny login\" command.`\n );\n }\n\n const project = user.projects.find(item => item.id === projectId);\n if (!project) {\n loggerService.error(\n { projects: user.projects },\n `The \"${projectId}\" project doesn't exist or you don't belong to it.`\n );\n throw new Error(\n `It seems you don't belong to the current project or the current project has been deleted.`\n );\n }\n\n loggerService.debug(\n `Retrieving the \"${env}\" project environment for the \"${project.name}\" project.`\n );\n\n projectEnvironment = await wcpService.getProjectEnvironment({\n orgId,\n projectId,\n userId: user.id,\n environmentId: env\n });\n }\n\n // Validate the project environment belongs to the correct org and project\n if (projectEnvironment.org.id !== orgId) {\n loggerService.error(\n `The \"${projectEnvironment.name}\" project environment doesn't belong to the \"${orgId}\" organization.`\n );\n throw new Error(\n `Cannot retrieve project environment because the \"${projectEnvironment.name}\" project environment doesn't belong to the \"${orgId}\" organization. Please check your WCP project ID (currently set to \"${wcpProjectId}\").`\n );\n }\n\n if (projectEnvironment.project.id !== projectId) {\n loggerService.error(\n `The \"${projectEnvironment.name}\" project environment doesn't belong to the \"${projectId}\" project.`\n );\n throw new Error(\n `Cannot retrieve project environment because the \"${projectEnvironment.name}\" project environment doesn't belong to the \"${wcpProjectId}\" project. Please check your WCP project ID (currently set to \"${wcpProjectId}\").`\n );\n }\n\n if (projectEnvironment && projectEnvironment.status !== \"enabled\") {\n loggerService.error(\n `The \"${projectEnvironment.name}\" project environment has been disabled.`\n );\n throw new Error(\n `Cannot retrieve project environment because the \"${projectEnvironment.name}\" project environment has been disabled.`\n );\n }\n\n // Fetch license\n let license: ILicense | null = null;\n if (projectEnvironment.apiKey) {\n license = await wcpService.getProjectLicense({\n apiKey: projectEnvironment.apiKey,\n orgId,\n projectId\n });\n }\n\n // Assign `WCP_PROJECT_ENVIRONMENT`, `WEBINY_PROJECT_API_KEY`, `WCP_PROJECT_ENVIRONMENT_API_KEY`, and `WCP_PROJECT_LICENSE`.\n const wcpProjectEnvironment = {\n id: projectEnvironment.id,\n apiKey: projectEnvironment.apiKey,\n org: { id: projectEnvironment.org.id },\n project: { id: projectEnvironment.project.id }\n };\n\n process.env.WCP_PROJECT_ENVIRONMENT = encrypt(wcpProjectEnvironment);\n process.env.WEBINY_PROJECT_API_KEY = projectEnvironment.apiKey;\n process.env.WCP_PROJECT_ENVIRONMENT_API_KEY = projectEnvironment.apiKey;\n if (license) {\n const licenseDto = license.toDto();\n if (licenseDto) {\n process.env.WCP_PROJECT_LICENSE = JSON.stringify(licenseDto);\n }\n }\n\n loggerService.debug(\n {\n id: projectEnvironment.id,\n apiKey: projectEnvironment.apiKey.replace(/./g, \"#\"),\n org: { id: projectEnvironment.org.id },\n project: { id: projectEnvironment.project.id },\n license: license ? \"present\" : \"not fetched\"\n },\n `WCP project environment \"${projectEnvironment.name}\" (ID: ${projectEnvironment.id}) has been set.`\n );\n};\n"],"names":["applyWcpEnvVars","container","getProjectIdService","GetProjectIdService","wcpService","WcpService","loggerService","LoggerService","projectSdkParamsService","ProjectSdkParamsService","wcpProjectId","process","decryptedProjectEnvironment","decrypt","orgId","projectId","apiKey","sdkParams","env","projectEnvironment","isValidId","Error","user","project","item","license","wcpProjectEnvironment","encrypt","licenseDto","JSON"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W,wBAAwB;QAC1B,IAAIP,mBAAmB,EAAE;QACzB,QAAQA,mBAAmB,MAAM;QACjC,KAAK;YAAE,IAAIA,mBAAmB,GAAG,CAAC,EAAE;QAAC;QACrC,SAAS;YAAE,IAAIA,mBAAmB,OAAO,CAAC,EAAE;QAAC;IACjD;IAEAR,QAAQ,GAAG,CAAC,uBAAuB,GAAGgB,QAAQD;IAC9Cf,QAAQ,GAAG,CAAC,sBAAsB,GAAGQ,mBAAmB,MAAM;IAC9DR,QAAQ,GAAG,CAAC,+BAA+B,GAAGQ,mBAAmB,MAAM;IACvE,IAAIM,SAAS;QACT,MAAMG,aAAaH,QAAQ,KAAK;QAChC,IAAIG,YACAjB,QAAQ,GAAG,CAAC,mBAAmB,GAAGkB,KAAK,SAAS,CAACD;IAEzD;IAEAtB,cAAc,KAAK,CACf;QACI,IAAIa,mBAAmB,EAAE;QACzB,QAAQA,mBAAmB,MAAM,CAAC,OAAO,CAAC,MAAM;QAChD,KAAK;YAAE,IAAIA,mBAAmB,GAAG,CAAC,EAAE;QAAC;QACrC,SAAS;YAAE,IAAIA,mBAAmB,OAAO,CAAC,EAAE;QAAC;QAC7C,SAASM,UAAU,YAAY;IACnC,GACA,CAAC,yBAAyB,EAAEN,mBAAmB,IAAI,CAAC,OAAO,EAAEA,mBAAmB,EAAE,CAAC,eAAe,CAAC;AAE3G"}
|
|
1
|
+
{"version":3,"file":"services/InitProjectSdkService/applyWcpEnvVars.js","sources":["../../../src/services/InitProjectSdkService/applyWcpEnvVars.ts"],"sourcesContent":["import { encrypt, decrypt } from \"@webiny/wcp\";\nimport type { ILicense } from \"@webiny/wcp/types\";\nimport { Container } from \"@webiny/di\";\nimport {\n GetProjectIdService,\n LoggerService,\n ProjectSdkParamsService,\n WcpService\n} from \"~/abstractions/index.js\";\n\n/*\n * Fetches the project license and puts it in `WCP_PROJECT_LICENSE`, which is where the config render\n * reads it from. License-gated feature flags decide which extensions the rendered config contains,\n * so a missing license silently produces a config without them.\n */\nconst applyProjectLicense = async (\n wcpService: WcpService.Interface,\n params: { apiKey: string; orgId: string; projectId: string }\n): Promise<ILicense | null> => {\n if (!params.apiKey) {\n return null;\n }\n\n const license = await wcpService.getProjectLicense(params);\n if (!license) {\n return null;\n }\n\n const licenseDto = license.toDto();\n if (licenseDto) {\n process.env.WCP_PROJECT_LICENSE = JSON.stringify(licenseDto);\n }\n\n return license;\n};\n\nexport const applyWcpEnvVars = async (container: Container) => {\n /**\n * The environment variables we set via these hooks are the following:\n * - WCP_PROJECT_ENVIRONMENT - contains encrypted data about the deployed project environment\n * - WEBINY_PROJECT_API_KEY / WCP_PROJECT_ENVIRONMENT_API_KEY - for easier access, we also set the API key\n * - WCP_PROJECT_LICENSE - contains encrypted license data\n */\n\n /**\n * There are multiple ways the hooks below prepare the WCP-enabled project for deployment.\n * 1. If `WCP_PROJECT_ENVIRONMENT` metadata env var is defined, we decrypt it, retrieve the\n * API key from it, and assign it as the `WEBINY_PROJECT_API_KEY` and `WCP_PROJECT_ENVIRONMENT_API_KEY` env vars.\n * 2. If `WEBINY_PROJECT_API_KEY` or `WCP_PROJECT_ENVIRONMENT_API_KEY` env var is defined, then we use that as the\n * project environment API key. We use that to load the project environment data\n * and to also assign the `WCP_PROJECT_ENVIRONMENT` metadata env var.\n * 3. If none of the above is defined, we retrieve (or create) the project environment,\n * retrieve its API key and again assign it as `WEBINY_PROJECT_API_KEY` and `WCP_PROJECT_ENVIRONMENT_API_KEY` env vars.\n * As in 2), we also assign the `WCP_PROJECT_ENVIRONMENT` metadata env var.\n */\n\n const getProjectIdService = container.resolve(GetProjectIdService);\n const wcpService = container.resolve(WcpService);\n const loggerService = container.resolve(LoggerService);\n const projectSdkParamsService = container.resolve(ProjectSdkParamsService);\n\n const wcpProjectId = await getProjectIdService.execute();\n\n // If the project isn't linked with WCP, do nothing.\n if (!wcpProjectId) {\n loggerService.debug(\n 'Was not able to determine the WCP project ID. Skipping the setting of \"WCP_PROJECT_ENVIRONMENT\" and \"WCP_PROJECT_ENVIRONMENT_API_KEY\" env vars.'\n );\n return;\n }\n\n // The `id` has the orgId/projectId structure, for example `my-org-x/my-project-y`.\n const [orgId, projectId] = wcpProjectId.split(\"/\");\n\n // Case 1: For development purposes, we allow setting the WCP_PROJECT_ENVIRONMENT env var directly.\n if (process.env.WCP_PROJECT_ENVIRONMENT) {\n loggerService.info(\n 'The \"WCP_PROJECT_ENVIRONMENT\" env var is already set. Using that value instead of looking the environment up.'\n );\n // If we have WCP_PROJECT_ENVIRONMENT env var, we set the WEBINY_PROJECT_API_KEY and WCP_PROJECT_ENVIRONMENT_API_KEY too.\n const decryptedProjectEnvironment = decrypt(process.env.WCP_PROJECT_ENVIRONMENT);\n process.env.WEBINY_PROJECT_API_KEY = decryptedProjectEnvironment.apiKey;\n process.env.WCP_PROJECT_ENVIRONMENT_API_KEY = decryptedProjectEnvironment.apiKey;\n\n // Build and watch processes inherit `WCP_PROJECT_LICENSE` along with this variable, so they\n // already have one. Someone who sets `WCP_PROJECT_ENVIRONMENT` by hand, in CI for instance,\n // usually doesn't, and without it the config renders as though the project had no license.\n //\n // Only if the environment belongs to the project this config names, though. Otherwise the\n // config would render with another project's entitlements. This path has never checked\n // that, and failing here would break setups that work today, so a mismatch skips the\n // license with a warning instead, the same as if it had never been fetched.\n const suppliedOrgId = decryptedProjectEnvironment.org?.id;\n const suppliedProjectId = decryptedProjectEnvironment.project?.id;\n const belongsToThisProject = suppliedOrgId === orgId && suppliedProjectId === projectId;\n\n if (!process.env.WCP_PROJECT_LICENSE && !belongsToThisProject) {\n loggerService.warn(\n { suppliedOrgId, suppliedProjectId, wcpProjectId },\n `\"WCP_PROJECT_ENVIRONMENT\" belongs to \"${suppliedOrgId}/${suppliedProjectId}\", not to \"${wcpProjectId}\". Not fetching its license.`\n );\n }\n\n if (!process.env.WCP_PROJECT_LICENSE && belongsToThisProject) {\n await applyProjectLicense(wcpService, {\n apiKey: decryptedProjectEnvironment.apiKey,\n orgId,\n projectId\n });\n }\n\n return;\n }\n\n // Check if API key is already set (prefer WEBINY_PROJECT_API_KEY over WCP_PROJECT_ENVIRONMENT_API_KEY).\n const apiKey =\n process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;\n\n const sdkParams = projectSdkParamsService.get();\n const env = sdkParams.env;\n\n let projectEnvironment;\n if (apiKey) {\n // The org and project let the lookup use WCP's cacheable REST endpoint.\n projectEnvironment = await wcpService.getProjectEnvironment({ apiKey, orgId, projectId });\n } else {\n const isValidId = orgId && projectId;\n if (!isValidId) {\n loggerService.error(\n { orgId, projectId, wcpProjectId },\n `The project ID, specified in \"webiny.config.tsx\" file, seems to be invalid.`\n );\n throw new Error(\n `It seems the project ID, specified in \"webiny.config.tsx\" file, is invalid.`\n );\n }\n\n // If there is no API key, that means we need to retrieve the currently logged-in user.\n const user = await wcpService.getUser();\n if (!user) {\n throw new Error(\n `It seems you are not logged into your WCP project. Please log in using the \"yarn webiny login\" command.`\n );\n }\n\n const project = user.projects.find(item => item.id === projectId);\n if (!project) {\n loggerService.error(\n { projects: user.projects },\n `The \"${projectId}\" project doesn't exist or you don't belong to it.`\n );\n throw new Error(\n `It seems you don't belong to the current project or the current project has been deleted.`\n );\n }\n\n loggerService.debug(\n `Retrieving the \"${env}\" project environment for the \"${project.name}\" project.`\n );\n\n projectEnvironment = await wcpService.getProjectEnvironment({\n orgId,\n projectId,\n userId: user.id,\n environmentId: env\n });\n }\n\n // Validate the project environment belongs to the correct org and project\n if (projectEnvironment.org.id !== orgId) {\n loggerService.error(\n `The \"${projectEnvironment.name}\" project environment doesn't belong to the \"${orgId}\" organization.`\n );\n throw new Error(\n `Cannot retrieve project environment because the \"${projectEnvironment.name}\" project environment doesn't belong to the \"${orgId}\" organization. Please check your WCP project ID (currently set to \"${wcpProjectId}\").`\n );\n }\n\n if (projectEnvironment.project.id !== projectId) {\n loggerService.error(\n `The \"${projectEnvironment.name}\" project environment doesn't belong to the \"${projectId}\" project.`\n );\n throw new Error(\n `Cannot retrieve project environment because the \"${projectEnvironment.name}\" project environment doesn't belong to the \"${wcpProjectId}\" project. Please check your WCP project ID (currently set to \"${wcpProjectId}\").`\n );\n }\n\n if (projectEnvironment && projectEnvironment.status !== \"enabled\") {\n loggerService.error(\n `The \"${projectEnvironment.name}\" project environment has been disabled.`\n );\n throw new Error(\n `Cannot retrieve project environment because the \"${projectEnvironment.name}\" project environment has been disabled.`\n );\n }\n\n const license = await applyProjectLicense(wcpService, {\n apiKey: projectEnvironment.apiKey,\n orgId,\n projectId\n });\n\n // Assign `WCP_PROJECT_ENVIRONMENT`, `WEBINY_PROJECT_API_KEY` and `WCP_PROJECT_ENVIRONMENT_API_KEY`. The license was assigned above.\n const wcpProjectEnvironment = {\n id: projectEnvironment.id,\n apiKey: projectEnvironment.apiKey,\n org: { id: projectEnvironment.org.id },\n project: { id: projectEnvironment.project.id }\n };\n\n process.env.WCP_PROJECT_ENVIRONMENT = encrypt(wcpProjectEnvironment);\n process.env.WEBINY_PROJECT_API_KEY = projectEnvironment.apiKey;\n process.env.WCP_PROJECT_ENVIRONMENT_API_KEY = projectEnvironment.apiKey;\n\n loggerService.debug(\n {\n id: projectEnvironment.id,\n apiKey: projectEnvironment.apiKey.replace(/./g, \"#\"),\n org: { id: projectEnvironment.org.id },\n project: { id: projectEnvironment.project.id },\n license: license ? \"present\" : \"not fetched\"\n },\n `WCP project environment \"${projectEnvironment.name}\" (ID: ${projectEnvironment.id}) has been set.`\n );\n};\n"],"names":["applyProjectLicense","wcpService","params","license","licenseDto","process","JSON","applyWcpEnvVars","container","getProjectIdService","GetProjectIdService","WcpService","loggerService","LoggerService","projectSdkParamsService","ProjectSdkParamsService","wcpProjectId","orgId","projectId","decryptedProjectEnvironment","decrypt","suppliedOrgId","suppliedProjectId","belongsToThisProject","apiKey","sdkParams","env","projectEnvironment","isValidId","Error","user","project","item","wcpProjectEnvironment","encrypt"],"mappings":";;AAeA,MAAMA,sBAAsB,OACxBC,YACAC;IAEA,IAAI,CAAC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AC,EAAE;QAAC;QAC7C,SAASxB,UAAU,YAAY;IACnC,GACA,CAAC,yBAAyB,EAAEwB,mBAAmB,IAAI,CAAC,OAAO,EAAEA,mBAAmB,EAAE,CAAC,eAAe,CAAC;AAE3G"}
|
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AdminAfterBuild,
|
|
1
|
+
import { registerSrcExtensions } from "../../utils/index.js";
|
|
2
|
+
import { AdminAfterBuild, AdminBeforeBuild, AdminBeforeWatch, AfterBuild, ApiAfterBuild, ApiBeforeBuild, ApiBeforeWatch, BeforeBuild, BeforeWatch, CoreAfterBuild, CoreBeforeBuild, CoreBeforeWatch } from "../../extensions/hooks/index.js";
|
|
3
3
|
const registerHooks = async (container, projectExtensions, project)=>{
|
|
4
4
|
const hooksExtensions = [
|
|
5
5
|
...projectExtensions.extensionsByType(AdminAfterBuild),
|
|
6
6
|
...projectExtensions.extensionsByType(BeforeBuild),
|
|
7
7
|
...projectExtensions.extensionsByType(BeforeWatch),
|
|
8
8
|
...projectExtensions.extensionsByType(AfterBuild),
|
|
9
|
-
...projectExtensions.extensionsByType(BeforeDeploy),
|
|
10
|
-
...projectExtensions.extensionsByType(AfterDeploy),
|
|
11
9
|
...projectExtensions.extensionsByType(AdminBeforeBuild),
|
|
12
|
-
...projectExtensions.extensionsByType(AdminBeforeDeploy),
|
|
13
10
|
...projectExtensions.extensionsByType(AdminBeforeWatch),
|
|
14
|
-
...projectExtensions.extensionsByType(AdminAfterBuild),
|
|
15
|
-
...projectExtensions.extensionsByType(AdminAfterDeploy),
|
|
16
11
|
...projectExtensions.extensionsByType(ApiBeforeBuild),
|
|
17
|
-
...projectExtensions.extensionsByType(ApiBeforeDeploy),
|
|
18
12
|
...projectExtensions.extensionsByType(ApiBeforeWatch),
|
|
19
13
|
...projectExtensions.extensionsByType(ApiAfterBuild),
|
|
20
|
-
...projectExtensions.extensionsByType(ApiAfterDeploy),
|
|
21
14
|
...projectExtensions.extensionsByType(CoreBeforeBuild),
|
|
22
|
-
...projectExtensions.extensionsByType(CoreBeforeDeploy),
|
|
23
15
|
...projectExtensions.extensionsByType(CoreBeforeWatch),
|
|
24
|
-
...projectExtensions.extensionsByType(CoreAfterBuild)
|
|
25
|
-
...projectExtensions.extensionsByType(CoreAfterDeploy)
|
|
16
|
+
...projectExtensions.extensionsByType(CoreAfterBuild)
|
|
26
17
|
];
|
|
27
|
-
|
|
28
|
-
const hookImpl = await ExtensionSrcResolver.importFromPath(hookExtension.params.src, project);
|
|
29
|
-
container.register(hookImpl).inSingletonScope();
|
|
30
|
-
}
|
|
18
|
+
await registerSrcExtensions(container, hooksExtensions, project);
|
|
31
19
|
};
|
|
32
20
|
export { registerHooks };
|
|
33
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/InitProjectSdkService/registerHooks.js","sources":["../../../src/services/InitProjectSdkService/registerHooks.ts"],"sourcesContent":["import { type IProjectModel } from \"~/abstractions/models/index.js\";\nimport { type IProjectConfigModel } from \"~/abstractions/models/index.js\";\nimport { Container } from \"@webiny/di\";\nimport {
|
|
1
|
+
{"version":3,"file":"services/InitProjectSdkService/registerHooks.js","sources":["../../../src/services/InitProjectSdkService/registerHooks.ts"],"sourcesContent":["import { type IProjectModel } from \"~/abstractions/models/index.js\";\nimport { type IProjectConfigModel } from \"~/abstractions/models/index.js\";\nimport { Container } from \"@webiny/di\";\nimport { registerSrcExtensions } from \"~/utils/index.js\";\nimport {\n AdminAfterBuild as AdminAfterBuildExt,\n AdminBeforeBuild as AdminBeforeBuildExt,\n AdminBeforeWatch as AdminBeforeWatchExt,\n AfterBuild as AfterBuildExt,\n BeforeWatch as BeforeWatchExt,\n ApiAfterBuild as ApiAfterBuildExt,\n ApiBeforeBuild as ApiBeforeBuildExt,\n ApiBeforeWatch as ApiBeforeWatchExt,\n BeforeBuild as BeforeBuildExt,\n CoreAfterBuild as CoreAfterBuildExt,\n CoreBeforeBuild as CoreBeforeBuildExt,\n CoreBeforeWatch as CoreBeforeWatchExt\n} from \"~/extensions/hooks/index.js\";\n\nexport const registerHooks = async (\n container: Container,\n projectExtensions: IProjectConfigModel,\n project: IProjectModel\n) => {\n const hooksExtensions = [\n ...projectExtensions.extensionsByType(AdminAfterBuildExt),\n ...projectExtensions.extensionsByType(BeforeBuildExt),\n ...projectExtensions.extensionsByType(BeforeWatchExt),\n ...projectExtensions.extensionsByType(AfterBuildExt),\n ...projectExtensions.extensionsByType(AdminBeforeBuildExt),\n ...projectExtensions.extensionsByType(AdminBeforeWatchExt),\n ...projectExtensions.extensionsByType(ApiBeforeBuildExt),\n ...projectExtensions.extensionsByType(ApiBeforeWatchExt),\n ...projectExtensions.extensionsByType(ApiAfterBuildExt),\n ...projectExtensions.extensionsByType(CoreBeforeBuildExt),\n ...projectExtensions.extensionsByType(CoreBeforeWatchExt),\n ...projectExtensions.extensionsByType(CoreAfterBuildExt)\n ];\n\n await registerSrcExtensions(container, hooksExtensions, project);\n};\n"],"names":["registerHooks","container","projectExtensions","project","hooksExtensions","AdminAfterBuildExt","BeforeBuildExt","BeforeWatchExt","AfterBuildExt","AdminBeforeBuildExt","AdminBeforeWatchExt","ApiBeforeBuildExt","ApiBeforeWatchExt","ApiAfterBuildExt","CoreBeforeBuildExt","CoreBeforeWatchExt","CoreAfterBuildExt","registerSrcExtensions"],"mappings":";;AAmBO,MAAMA,gBAAgB,OACzBC,WACAC,mBACAC;IAEA,MAAMC,kBAAkB;WACjBF,kBAAkB,gBAAgB,CAACG;WACnCH,kBAAkB,gBAAgB,CAACI;WACnCJ,kBAAkB,gBAAgB,CAACK;WACnCL,kBAAkB,gBAAgB,CAACM;WACnCN,kBAAkB,gBAAgB,CAACO;WACnCP,kBAAkB,gBAAgB,CAACQ;WACnCR,kBAAkB,gBAAgB,CAACS;WACnCT,kBAAkB,gBAAgB,CAACU;WACnCV,kBAAkB,gBAAgB,CAACW;WACnCX,kBAAkB,gBAAgB,CAACY;WACnCZ,kBAAkB,gBAAgB,CAACa;WACnCb,kBAAkB,gBAAgB,CAACc;KACzC;IAED,MAAMC,sBAAsBhB,WAAWG,iBAAiBD;AAC5D"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { ProjectInfoService
|
|
1
|
+
import { ProjectInfoService } from "../../abstractions/index.js";
|
|
2
|
+
import { GetIsCiService } from "../../abstractions/index.js";
|
|
3
|
+
import { GetNpmVersionService } from "../../abstractions/index.js";
|
|
4
|
+
import { GetNpxVersionService } from "../../abstractions/index.js";
|
|
5
|
+
import { GetYarnVersionService } from "../../abstractions/index.js";
|
|
6
|
+
import { GetProjectVersionService } from "../../abstractions/index.js";
|
|
2
7
|
import { IProjectInfoServiceResult } from "../../abstractions/services/ProjectInfoService/ProjectInfoService.js";
|
|
3
8
|
export declare class DefaultProjectInfoService implements ProjectInfoService.Interface {
|
|
4
9
|
private getIsCi;
|
|
5
10
|
private getNpmVersion;
|
|
6
11
|
private getNpxVersion;
|
|
7
|
-
private getPulumiVersion;
|
|
8
12
|
private getYarnVersion;
|
|
9
13
|
private getProjectVersion;
|
|
10
|
-
constructor(getIsCi: GetIsCiService.Interface, getNpmVersion: GetNpmVersionService.Interface, getNpxVersion: GetNpxVersionService.Interface,
|
|
14
|
+
constructor(getIsCi: GetIsCiService.Interface, getNpmVersion: GetNpmVersionService.Interface, getNpxVersion: GetNpxVersionService.Interface, getYarnVersion: GetYarnVersionService.Interface, getProjectVersion: GetProjectVersionService.Interface);
|
|
11
15
|
execute(): Promise<IProjectInfoServiceResult>;
|
|
12
16
|
}
|
|
13
17
|
export declare const projectInfoService: import("@webiny/di").Implementation<typeof DefaultProjectInfoService>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { createImplementation } from "@webiny/di";
|
|
2
|
-
import { GetIsCiService, GetNpmVersionService, GetNpxVersionService, GetProjectVersionService,
|
|
2
|
+
import { GetIsCiService, GetNpmVersionService, GetNpxVersionService, GetProjectVersionService, GetYarnVersionService, ProjectInfoService } from "../../abstractions/index.js";
|
|
3
3
|
class DefaultProjectInfoService {
|
|
4
|
-
constructor(getIsCi, getNpmVersion, getNpxVersion,
|
|
4
|
+
constructor(getIsCi, getNpmVersion, getNpxVersion, getYarnVersion, getProjectVersion){
|
|
5
5
|
this.getIsCi = getIsCi;
|
|
6
6
|
this.getNpmVersion = getNpmVersion;
|
|
7
7
|
this.getNpxVersion = getNpxVersion;
|
|
8
|
-
this.getPulumiVersion = getPulumiVersion;
|
|
9
8
|
this.getYarnVersion = getYarnVersion;
|
|
10
9
|
this.getProjectVersion = getProjectVersion;
|
|
11
10
|
}
|
|
@@ -16,7 +15,6 @@ class DefaultProjectInfoService {
|
|
|
16
15
|
const npmVersion = this.getNpmVersion.execute();
|
|
17
16
|
const npxVersion = this.getNpxVersion.execute();
|
|
18
17
|
const yarnVersion = this.getYarnVersion.execute();
|
|
19
|
-
const [pulumiVersion, pulumiAwsVersion] = this.getPulumiVersion.execute();
|
|
20
18
|
return {
|
|
21
19
|
webiny: {
|
|
22
20
|
version: this.getProjectVersion.execute(),
|
|
@@ -35,12 +33,7 @@ class DefaultProjectInfoService {
|
|
|
35
33
|
yarn: yarnVersion,
|
|
36
34
|
isCI: isCI
|
|
37
35
|
},
|
|
38
|
-
|
|
39
|
-
"@pulumi/pulumi": pulumiVersion,
|
|
40
|
-
"@pulumi/aws": pulumiAwsVersion,
|
|
41
|
-
secretsProvider: process.env.PULUMI_SECRETS_PROVIDER || "",
|
|
42
|
-
usingPassword: !!process.env.PULUMI_CONFIG_PASSPHRASE
|
|
43
|
-
}
|
|
36
|
+
sections: []
|
|
44
37
|
};
|
|
45
38
|
}
|
|
46
39
|
}
|
|
@@ -51,7 +44,6 @@ const projectInfoService = createImplementation({
|
|
|
51
44
|
GetIsCiService,
|
|
52
45
|
GetNpmVersionService,
|
|
53
46
|
GetNpxVersionService,
|
|
54
|
-
GetPulumiVersionService,
|
|
55
47
|
GetYarnVersionService,
|
|
56
48
|
GetProjectVersionService
|
|
57
49
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/ProjectInfoService/ProjectInfoService.js","sources":["../../../src/services/ProjectInfoService/ProjectInfoService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\
|
|
1
|
+
{"version":3,"file":"services/ProjectInfoService/ProjectInfoService.js","sources":["../../../src/services/ProjectInfoService/ProjectInfoService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { ProjectInfoService } from \"~/abstractions/index.js\";\nimport { GetIsCiService } from \"~/abstractions/index.js\";\nimport { GetNpmVersionService } from \"~/abstractions/index.js\";\nimport { GetNpxVersionService } from \"~/abstractions/index.js\";\nimport { GetYarnVersionService } from \"~/abstractions/index.js\";\nimport { GetProjectVersionService } from \"~/abstractions/index.js\";\nimport { IProjectInfoServiceResult } from \"~/abstractions/services/ProjectInfoService/ProjectInfoService.js\";\n\nexport class DefaultProjectInfoService implements ProjectInfoService.Interface {\n constructor(\n private getIsCi: GetIsCiService.Interface,\n private getNpmVersion: GetNpmVersionService.Interface,\n private getNpxVersion: GetNpxVersionService.Interface,\n private getYarnVersion: GetYarnVersionService.Interface,\n private getProjectVersion: GetProjectVersionService.Interface\n ) {}\n\n async execute() {\n const wcpProjectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID || \"\";\n // const wcpUser = await getUser().catch(() => null);\n // oxlint-disable-next-line typescript/no-unused-vars\n const wcpUsingProjectEnvironmentApiKey = Boolean(\n process.env.WEBINY_PROJECT_API_KEY ||\n process.env.WCP_PROJECT_ENVIRONMENT_API_KEY ||\n process.env.WCP_ENVIRONMENT_API_KEY\n );\n\n const isCI = this.getIsCi.execute();\n const npmVersion = this.getNpmVersion.execute();\n const npxVersion = this.getNpxVersion.execute();\n const yarnVersion = this.getYarnVersion.execute();\n\n return {\n webiny: {\n version: this.getProjectVersion.execute(),\n debugEnabled: process.env.DEBUG === \"true\",\n featureFlags: process.env.WEBINY_FEATURE_FLAGS || {}\n },\n wcp: {\n projectId: wcpProjectId,\n // user: wcpUser?.email || \"N/A\",\n usingProjectEnvironmentApiKey: false // wcpUsingProject\n },\n host: {\n os: `${process.platform} (${process.arch})`,\n nodeJs: process.version,\n npm: npmVersion,\n npx: npxVersion,\n yarn: yarnVersion,\n isCI: isCI\n },\n sections: []\n } as IProjectInfoServiceResult;\n }\n}\n\nexport const projectInfoService = createImplementation({\n abstraction: ProjectInfoService,\n implementation: DefaultProjectInfoService,\n dependencies: [\n GetIsCiService,\n GetNpmVersionService,\n GetNpxVersionService,\n GetYarnVersionService,\n GetProjectVersionService\n ]\n});\n"],"names":["DefaultProjectInfoService","getIsCi","getNpmVersion","getNpxVersion","getYarnVersion","getProjectVersion","wcpProjectId","process","Boolean","isCI","npmVersion","npxVersion","yarnVersion","projectInfoService","createImplementation","ProjectInfoService","GetIsCiService","GetNpmVersionService","GetNpxVersionService","GetYarnVersionService","GetProjectVersionService"],"mappings":";;AASO,MAAMA;IACT,YACYC,OAAiC,EACjCC,aAA6C,EAC7CC,aAA6C,EAC7CC,cAA+C,EAC/CC,iBAAqD,CAC/D;aALUJ,OAAO,GAAPA;aACAC,aAAa,GAAbA;aACAC,aAAa,GAAbA;aACAC,cAAc,GAAdA;aACAC,iBAAiB,GAAjBA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,eAAeC,QAAQ,GAAG,CAAC,iBAAiB,IAAIA,QAAQ,GAAG,CAAC,cAAc,IAAI;QAG3CC,QACrCD,QAAQ,GAAG,CAAC,sBAAsB,IAClCA,QAAQ,GAAG,CAAC,+BAA+B,IAC3CA,QAAQ,GAAG,CAAC,uBAAuB;QAGvC,MAAME,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO;QACjC,MAAMC,aAAa,IAAI,CAAC,aAAa,CAAC,OAAO;QAC7C,MAAMC,aAAa,IAAI,CAAC,aAAa,CAAC,OAAO;QAC7C,MAAMC,cAAc,IAAI,CAAC,cAAc,CAAC,OAAO;QAE/C,OAAO;YACH,QAAQ;gBACJ,SAAS,IAAI,CAAC,iBAAiB,CAAC,OAAO;gBACvC,cAAcL,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK;gBAC/B,cAAcA,QAAQ,GAAG,CAAC,oBAAoB,IAAI,CAAC;YACvD;YACA,KAAK;gBACD,WAAWD;gBAEX,+BAA+B;YACnC;YACA,MAAM;gBACF,IAAI,GAAGC,QAAQ,QAAQ,CAAC,EAAE,EAAEA,QAAQ,IAAI,CAAC,CAAC,CAAC;gBAC3C,QAAQA,QAAQ,OAAO;gBACvB,KAAKG;gBACL,KAAKC;gBACL,MAAMC;gBACN,MAAMH;YACV;YACA,UAAU,EAAE;QAChB;IACJ;AACJ;AAEO,MAAMI,qBAAqBC,qBAAqB;IACnD,aAAaC;IACb,gBAAgBf;IAChB,cAAc;QACVgB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { createImplementation } from "@webiny/di";
|
|
2
2
|
import { ValidateProjectConfigService } from "../../abstractions/index.js";
|
|
3
3
|
import { ProjectError } from "../../ProjectError.js";
|
|
4
|
+
import { traceAsync } from "../../utils/trace/index.js";
|
|
4
5
|
class DefaultValidateProjectConfigService {
|
|
5
6
|
async execute(projectConfig) {
|
|
6
7
|
const extensionTypes = Object.keys(projectConfig.config);
|
|
7
8
|
for (const extensionType of extensionTypes){
|
|
8
9
|
const extensionsCollection = projectConfig.extensionsByType(extensionType);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
await traceAsync(`validate "${extensionType}"`, async ()=>{
|
|
11
|
+
for (const extension of extensionsCollection){
|
|
12
|
+
await extension.validateParams();
|
|
13
|
+
if (extension.validate) try {
|
|
14
|
+
await extension.validate();
|
|
15
|
+
} catch (error) {
|
|
16
|
+
throw ProjectError.from(`Validation failed for extension of type %s: ${error.message}`, extensionType);
|
|
17
|
+
}
|
|
15
18
|
}
|
|
16
|
-
}
|
|
19
|
+
});
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/ValidateProjectConfigService/ValidateProjectConfigService.js","sources":["../../../src/services/ValidateProjectConfigService/ValidateProjectConfigService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { ValidateProjectConfigService } from \"~/abstractions/index.js\";\nimport { ProjectError } from \"~/ProjectError.js\";\n\nexport class DefaultValidateProjectConfigService implements ValidateProjectConfigService.Interface {\n async execute(projectConfig: ValidateProjectConfigService.Params): Promise<void> {\n const extensionTypes = Object.keys(projectConfig.config);\n for (const extensionType of extensionTypes) {\n const extensionsCollection = projectConfig.extensionsByType(extensionType);\n for (const extension of extensionsCollection) {\n
|
|
1
|
+
{"version":3,"file":"services/ValidateProjectConfigService/ValidateProjectConfigService.js","sources":["../../../src/services/ValidateProjectConfigService/ValidateProjectConfigService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { ValidateProjectConfigService } from \"~/abstractions/index.js\";\nimport { ProjectError } from \"~/ProjectError.js\";\nimport { traceAsync } from \"~/utils/trace/index.js\";\n\nexport class DefaultValidateProjectConfigService implements ValidateProjectConfigService.Interface {\n async execute(projectConfig: ValidateProjectConfigService.Params): Promise<void> {\n const extensionTypes = Object.keys(projectConfig.config);\n for (const extensionType of extensionTypes) {\n const extensionsCollection = projectConfig.extensionsByType(extensionType);\n\n // Validation is serial, and an extension is free to hit the network or the filesystem in\n // its `validate`, so each type is timed separately.\n await traceAsync(`validate \"${extensionType}\"`, async () => {\n for (const extension of extensionsCollection) {\n await extension.validateParams();\n\n if (extension.validate) {\n try {\n await extension.validate();\n } catch (error) {\n throw ProjectError.from(\n `Validation failed for extension of type %s: ${error.message}`,\n extensionType\n );\n }\n }\n }\n });\n }\n }\n}\n\nexport const validateProjectConfigService = createImplementation({\n abstraction: ValidateProjectConfigService,\n implementation: DefaultValidateProjectConfigService,\n dependencies: []\n});\n"],"names":["DefaultValidateProjectConfigService","projectConfig","extensionTypes","Object","extensionType","extensionsCollection","traceAsync","extension","error","ProjectError","validateProjectConfigService","createImplementation","ValidateProjectConfigService"],"mappings":";;;;AAKO,MAAMA;IACT,MAAM,QAAQC,aAAkD,EAAiB;QAC7E,MAAMC,iBAAiBC,OAAO,IAAI,CAACF,cAAc,MAAM;QACvD,KAAK,MAAMG,iBAAiBF,eAAgB;YACxC,MAAMG,uBAAuBJ,cAAc,gBAAgB,CAACG;YAI5D,MAAME,WAAW,CAAC,UAAU,EAAEF,cAAc,CAAC,CAAC,EAAE;gBAC5C,KAAK,MAAMG,aAAaF,qBAAsB;oBAC1C,MAAME,UAAU,cAAc;oBAE9B,IAAIA,UAAU,QAAQ,EAClB,IAAI;wBACA,MAAMA,UAAU,QAAQ;oBAC5B,EAAE,OAAOC,OAAO;wBACZ,MAAMC,aAAa,IAAI,CACnB,CAAC,4CAA4C,EAAED,MAAM,OAAO,EAAE,EAC9DJ;oBAER;gBAER;YACJ;QACJ;IACJ;AACJ;AAEO,MAAMM,+BAA+BC,qBAAqB;IAC7D,aAAaC;IACb,gBAAgBZ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WcpGqlClient } from "./WcpGqlClient.js";
|
|
2
|
+
import { fetchProjectEnvironmentByApiKey } from "./fetchProjectEnvironmentByApiKey.js";
|
|
2
3
|
import { WcpEnvironmentModel } from "../../models/index.js";
|
|
3
4
|
const ENVIRONMENT_FIELDS = `
|
|
4
5
|
fragment EnvironmentFields on Environment {
|
|
@@ -64,11 +65,21 @@ class GetProjectEnvironment {
|
|
|
64
65
|
async execute(params) {
|
|
65
66
|
const { localStorageService } = this.di;
|
|
66
67
|
const { orgId, projectId, userId, environmentId, apiKey } = params;
|
|
67
|
-
if (apiKey)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
if (apiKey) {
|
|
69
|
+
if (orgId && projectId) try {
|
|
70
|
+
const environment = await fetchProjectEnvironmentByApiKey({
|
|
71
|
+
apiKey,
|
|
72
|
+
orgId,
|
|
73
|
+
projectId
|
|
74
|
+
});
|
|
75
|
+
return WcpEnvironmentModel.fromDto(environment);
|
|
76
|
+
} catch {}
|
|
77
|
+
return WcpGqlClient.execute(GET_ENVIRONMENT, {
|
|
78
|
+
apiKey
|
|
79
|
+
}).then((response)=>WcpEnvironmentModel.fromDto(response.projects.getEnvironment)).catch(()=>{
|
|
80
|
+
throw new Error("It seems the API key you provided is incorrect or disabled. Please double check the API key and try again.");
|
|
81
|
+
});
|
|
82
|
+
}
|
|
72
83
|
const pat = localStorageService.get("wcpPat");
|
|
73
84
|
if (!pat) throw new Error('It seems you are not logged in. Please login using the "webiny login" command.');
|
|
74
85
|
const headers = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/WcpService/GetProjectEnvironment.js","sources":["../../../src/services/WcpService/GetProjectEnvironment.ts"],"sourcesContent":["import { LocalStorageService } from \"~/abstractions/index.js\";\nimport { WcpGqlClient } from \"./WcpGqlClient.js\";\nimport { IGetProjectEnvironmentParams } from \"~/abstractions/services/WcpService.js\";\nimport { IWcpEnvironmentDto } from \"~/abstractions/models/index.js\";\nimport { WcpEnvironmentModel } from \"~/models/index.js\";\n\nconst ENVIRONMENT_FIELDS = /* GraphQL */ `\n fragment EnvironmentFields on Environment {\n id\n status\n name\n apiKey\n org {\n id\n name\n }\n project {\n id\n name\n }\n user {\n id\n email\n }\n }\n`;\n\nconst CREATE_ENVIRONMENT = /* GraphQL */ `\n ${ENVIRONMENT_FIELDS}\n mutation CreateEnvironment(\n $orgId: ID!\n $projectId: ID!\n $userId: ID\n $data: CreateEnvironmentDataInput!\n ) {\n projects {\n createEnvironment(orgId: $orgId, projectId: $projectId, userId: $userId, data: $data) {\n ...EnvironmentFields\n }\n }\n }\n`;\n\nexport interface ICreateEnvironmentParams {\n projects: {\n createEnvironment: IWcpEnvironmentDto;\n };\n}\n\nconst GET_ENVIRONMENT = /* GraphQL */ `\n ${ENVIRONMENT_FIELDS}\n query GetEnvironment(\n $environmentId: ID\n $orgId: ID\n $projectId: ID\n $userId: ID\n $apiKey: String\n ) {\n projects {\n getEnvironment(\n environmentId: $environmentId\n orgId: $orgId\n projectId: $projectId\n userId: $userId\n apiKey: $apiKey\n ) {\n ...EnvironmentFields\n }\n }\n }\n`;\n\nexport interface IGetEnvironmentResponse {\n projects: {\n getEnvironment: IWcpEnvironmentDto;\n };\n}\n\nexport interface IGetProjectEnvironmentDi {\n localStorageService: LocalStorageService.Interface;\n}\n\nexport class GetProjectEnvironment {\n di: IGetProjectEnvironmentDi;\n\n constructor(di: IGetProjectEnvironmentDi) {\n this.di = di;\n }\n\n async execute(params: IGetProjectEnvironmentParams): Promise<WcpEnvironmentModel> {\n const { localStorageService } = this.di;\n const { orgId, projectId, userId, environmentId, apiKey } = params;\n\n if (apiKey) {\n return WcpGqlClient.execute<IGetEnvironmentResponse>(GET_ENVIRONMENT, { apiKey })\n .then(response => WcpEnvironmentModel.fromDto(response.projects.getEnvironment))\n .catch(() => {\n throw new Error(\n `It seems the API key you provided is incorrect or disabled. Please double check the API key and try again.`\n );\n });\n }\n\n const pat = localStorageService.get(\"wcpPat\");\n if (!pat) {\n throw new Error(\n `It seems you are not logged in. Please login using the \"webiny login\" command.`\n );\n }\n\n const headers = { authorization: pat };\n return WcpGqlClient.execute<IGetEnvironmentResponse>(\n GET_ENVIRONMENT,\n {\n orgId,\n projectId,\n userId,\n environmentId,\n apiKey\n },\n headers\n )\n .then(async response => WcpEnvironmentModel.fromDto(response.projects.getEnvironment))\n .catch(() => {\n return WcpGqlClient.execute<ICreateEnvironmentParams>(\n CREATE_ENVIRONMENT,\n {\n orgId,\n projectId,\n userId,\n data: {\n name: environmentId\n }\n },\n headers\n ).then(response => response.projects.createEnvironment);\n });\n }\n}\n"],"names":["ENVIRONMENT_FIELDS","CREATE_ENVIRONMENT","GET_ENVIRONMENT","GetProjectEnvironment","di","params","localStorageService","orgId","projectId","userId","environmentId","apiKey","
|
|
1
|
+
{"version":3,"file":"services/WcpService/GetProjectEnvironment.js","sources":["../../../src/services/WcpService/GetProjectEnvironment.ts"],"sourcesContent":["import { LocalStorageService } from \"~/abstractions/index.js\";\nimport { WcpGqlClient } from \"./WcpGqlClient.js\";\nimport { fetchProjectEnvironmentByApiKey } from \"./fetchProjectEnvironmentByApiKey.js\";\nimport { IGetProjectEnvironmentParams } from \"~/abstractions/services/WcpService.js\";\nimport { IWcpEnvironmentDto } from \"~/abstractions/models/index.js\";\nimport { WcpEnvironmentModel } from \"~/models/index.js\";\n\nconst ENVIRONMENT_FIELDS = /* GraphQL */ `\n fragment EnvironmentFields on Environment {\n id\n status\n name\n apiKey\n org {\n id\n name\n }\n project {\n id\n name\n }\n user {\n id\n email\n }\n }\n`;\n\nconst CREATE_ENVIRONMENT = /* GraphQL */ `\n ${ENVIRONMENT_FIELDS}\n mutation CreateEnvironment(\n $orgId: ID!\n $projectId: ID!\n $userId: ID\n $data: CreateEnvironmentDataInput!\n ) {\n projects {\n createEnvironment(orgId: $orgId, projectId: $projectId, userId: $userId, data: $data) {\n ...EnvironmentFields\n }\n }\n }\n`;\n\nexport interface ICreateEnvironmentParams {\n projects: {\n createEnvironment: IWcpEnvironmentDto;\n };\n}\n\nconst GET_ENVIRONMENT = /* GraphQL */ `\n ${ENVIRONMENT_FIELDS}\n query GetEnvironment(\n $environmentId: ID\n $orgId: ID\n $projectId: ID\n $userId: ID\n $apiKey: String\n ) {\n projects {\n getEnvironment(\n environmentId: $environmentId\n orgId: $orgId\n projectId: $projectId\n userId: $userId\n apiKey: $apiKey\n ) {\n ...EnvironmentFields\n }\n }\n }\n`;\n\nexport interface IGetEnvironmentResponse {\n projects: {\n getEnvironment: IWcpEnvironmentDto;\n };\n}\n\nexport interface IGetProjectEnvironmentDi {\n localStorageService: LocalStorageService.Interface;\n}\n\nexport class GetProjectEnvironment {\n di: IGetProjectEnvironmentDi;\n\n constructor(di: IGetProjectEnvironmentDi) {\n this.di = di;\n }\n\n async execute(params: IGetProjectEnvironmentParams): Promise<WcpEnvironmentModel> {\n const { localStorageService } = this.di;\n const { orgId, projectId, userId, environmentId, apiKey } = params;\n\n if (apiKey) {\n // The cacheable REST endpoint needs the org and project in its URL. When a caller has\n // them, try it first. Anything but a clean answer falls through to the GraphQL query\n // below, which keeps every failure reported exactly as it was before the endpoint\n // existed, and keeps working against a WCP that doesn't have the endpoint.\n if (orgId && projectId) {\n try {\n const environment = await fetchProjectEnvironmentByApiKey({\n apiKey,\n orgId,\n projectId\n });\n\n return WcpEnvironmentModel.fromDto(environment);\n } catch {\n // Fall through to GraphQL.\n }\n }\n\n return WcpGqlClient.execute<IGetEnvironmentResponse>(GET_ENVIRONMENT, { apiKey })\n .then(response => WcpEnvironmentModel.fromDto(response.projects.getEnvironment))\n .catch(() => {\n throw new Error(\n `It seems the API key you provided is incorrect or disabled. Please double check the API key and try again.`\n );\n });\n }\n\n const pat = localStorageService.get(\"wcpPat\");\n if (!pat) {\n throw new Error(\n `It seems you are not logged in. Please login using the \"webiny login\" command.`\n );\n }\n\n const headers = { authorization: pat };\n return WcpGqlClient.execute<IGetEnvironmentResponse>(\n GET_ENVIRONMENT,\n {\n orgId,\n projectId,\n userId,\n environmentId,\n apiKey\n },\n headers\n )\n .then(async response => WcpEnvironmentModel.fromDto(response.projects.getEnvironment))\n .catch(() => {\n return WcpGqlClient.execute<ICreateEnvironmentParams>(\n CREATE_ENVIRONMENT,\n {\n orgId,\n projectId,\n userId,\n data: {\n name: environmentId\n }\n },\n headers\n ).then(response => response.projects.createEnvironment);\n });\n }\n}\n"],"names":["ENVIRONMENT_FIELDS","CREATE_ENVIRONMENT","GET_ENVIRONMENT","GetProjectEnvironment","di","params","localStorageService","orgId","projectId","userId","environmentId","apiKey","environment","fetchProjectEnvironmentByApiKey","WcpEnvironmentModel","WcpGqlClient","response","Error","pat","headers"],"mappings":";;;AAOA,MAAMA,qBAAmC,CAAC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CAAAA,WAAYA,SAAS,QAAQ,CAAC,iBAAiB;IAElE;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getWcpGqlApiUrl } from "@webiny/wcp";
|
|
2
|
-
import { request } from "graphql-request";
|
|
3
2
|
class WcpGqlClient {
|
|
4
|
-
static execute(query, variables = {}, headers = {}) {
|
|
3
|
+
static async execute(query, variables = {}, headers = {}) {
|
|
4
|
+
const { request } = await import("graphql-request");
|
|
5
5
|
const wcpApiUrl = getWcpGqlApiUrl();
|
|
6
6
|
return request(wcpApiUrl, query, variables, headers);
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/WcpService/WcpGqlClient.js","sources":["../../../src/services/WcpService/WcpGqlClient.ts"],"sourcesContent":["import { getWcpGqlApiUrl } from \"@webiny/wcp\";\
|
|
1
|
+
{"version":3,"file":"services/WcpService/WcpGqlClient.js","sources":["../../../src/services/WcpService/WcpGqlClient.ts"],"sourcesContent":["import { getWcpGqlApiUrl } from \"@webiny/wcp\";\n\nexport class WcpGqlClient {\n static async execute<TData extends Record<string, any> = Record<string, any>>(\n query: string,\n variables: Record<string, any> = {},\n headers: HeadersInit = {}\n ) {\n // Loaded here rather than at the top of the file: `graphql-request` pulls in all of\n // `graphql`, about 140 modules, and every CLI command would load it just to register this\n // service. Most commands never send a GraphQL request to WCP, since the environment lookup\n // uses the REST endpoint first.\n const { request } = await import(\"graphql-request\");\n\n const wcpApiUrl = getWcpGqlApiUrl();\n return request(wcpApiUrl, query, variables, headers) as Promise<TData>;\n }\n}\n"],"names":["WcpGqlClient","query","variables","headers","request","wcpApiUrl","getWcpGqlApiUrl"],"mappings":";AAEO,MAAMA;IACT,aAAa,QACTC,KAAa,EACbC,YAAiC,CAAC,CAAC,EACnCC,UAAuB,CAAC,CAAC,EAC3B;QAKE,MAAM,EAAEC,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC;QAEjC,MAAMC,YAAYC;QAClB,OAAOF,QAAQC,WAAWJ,OAAOC,WAAWC;IAChD;AACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type IWcpEnvironmentDto } from "../../abstractions/models/index.js";
|
|
2
|
+
interface FetchProjectEnvironmentByApiKeyParams {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
orgId: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const fetchProjectEnvironmentByApiKey: (params: FetchProjectEnvironmentByApiKeyParams) => Promise<IWcpEnvironmentDto>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getWcpApiUrl } from "@webiny/wcp";
|
|
2
|
+
const TIMEOUT_MS = 10000;
|
|
3
|
+
const fetchProjectEnvironmentByApiKey = async (params)=>{
|
|
4
|
+
const { apiKey, orgId, projectId } = params;
|
|
5
|
+
const orgPath = encodeURIComponent(orgId);
|
|
6
|
+
const projectPath = encodeURIComponent(projectId);
|
|
7
|
+
const url = getWcpApiUrl(`/orgs/${orgPath}/projects/${projectPath}/environment`);
|
|
8
|
+
const response = await fetch(url, {
|
|
9
|
+
headers: {
|
|
10
|
+
authorization: apiKey
|
|
11
|
+
},
|
|
12
|
+
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
13
|
+
});
|
|
14
|
+
if (!response.ok) throw new Error(`WCP returned ${response.status} for the project environment.`);
|
|
15
|
+
const body = await response.json();
|
|
16
|
+
if (!body.environment) throw new Error("WCP returned no project environment.");
|
|
17
|
+
return body.environment;
|
|
18
|
+
};
|
|
19
|
+
export { fetchProjectEnvironmentByApiKey };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=fetchProjectEnvironmentByApiKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services/WcpService/fetchProjectEnvironmentByApiKey.js","sources":["../../../src/services/WcpService/fetchProjectEnvironmentByApiKey.ts"],"sourcesContent":["import { getWcpApiUrl } from \"@webiny/wcp\";\nimport { type IWcpEnvironmentDto } from \"~/abstractions/models/index.js\";\n\n// Long enough for a cold start behind a cache miss (about 2s), short enough that a stuck request\n// still leaves time to fall back to the GraphQL query.\nconst TIMEOUT_MS = 10_000;\n\ninterface FetchProjectEnvironmentByApiKeyParams {\n apiKey: string;\n orgId: string;\n projectId: string;\n}\n\n/*\n * Looks up a project environment through WCP's REST endpoint rather than its GraphQL API.\n *\n * The CLI does this on every command, and a GraphQL POST can never be cached, so it was a full round\n * trip to WCP every time: about 500ms. This endpoint is a GET that CloudFront caches per API key,\n * so a repeat lookup comes back from the edge in tens of milliseconds. It returns the same fields as\n * the GraphQL query.\n *\n * Throws on anything other than a successful response, including a disabled environment, a key\n * from another project, or a WCP without this route. Callers fall back to the GraphQL query, which\n * reports those cases the way it always has.\n */\nexport const fetchProjectEnvironmentByApiKey = async (\n params: FetchProjectEnvironmentByApiKeyParams\n): Promise<IWcpEnvironmentDto> => {\n const { apiKey, orgId, projectId } = params;\n\n const orgPath = encodeURIComponent(orgId);\n const projectPath = encodeURIComponent(projectId);\n const url = getWcpApiUrl(`/orgs/${orgPath}/projects/${projectPath}/environment`);\n\n const response = await fetch(url, {\n headers: { authorization: apiKey },\n signal: AbortSignal.timeout(TIMEOUT_MS)\n });\n\n if (!response.ok) {\n throw new Error(`WCP returned ${response.status} for the project environment.`);\n }\n\n const body: { environment?: IWcpEnvironmentDto } = await response.json();\n if (!body.environment) {\n throw new Error(\"WCP returned no project environment.\");\n }\n\n return body.environment;\n};\n"],"names":["TIMEOUT_MS","fetchProjectEnvironmentByApiKey","params","apiKey","orgId","projectId","orgPath","encodeURIComponent","projectPath","url","getWcpApiUrl","response","fetch","AbortSignal","Error","body"],"mappings":";AAKA,MAAMA,aAAa;AAoBZ,MAAMC,kCAAkC,OAC3CC;IAEA,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAE,GAAGH;IAErC,MAAMI,UAAUC,mBAAmBH;IACnC,MAAMI,cAAcD,mBAAmBF;IACvC,MAAMI,MAAMC,aAAa,CAAC,MAAM,EAAEJ,QAAQ,UAAU,EAAEE,YAAY,YAAY,CAAC;IAE/E,MAAMG,WAAW,MAAMC,MAAMH,KAAK;QAC9B,SAAS;YAAE,eAAeN;QAAO;QACjC,QAAQU,YAAY,OAAO,CAACb;IAChC;IAEA,IAAI,CAACW,SAAS,EAAE,EACZ,MAAM,IAAIG,MAAM,CAAC,aAAa,EAAEH,SAAS,MAAM,CAAC,6BAA6B,CAAC;IAGlF,MAAMI,OAA6C,MAAMJ,SAAS,IAAI;IACtE,IAAI,CAACI,KAAK,WAAW,EACjB,MAAM,IAAID,MAAM;IAGpB,OAAOC,KAAK,WAAW;AAC3B"}
|
package/services/index.d.ts
CHANGED
|
@@ -10,9 +10,6 @@ export * from "./GetProjectInstallationIdService/index.js";
|
|
|
10
10
|
export * from "./GetProjectVersionService/index.js";
|
|
11
11
|
export * from "./InitProjectSdkService/index.js";
|
|
12
12
|
export * from "./InstallExtensionService/index.js";
|
|
13
|
-
export * from "./IsRemotePulumiBackendService/index.js";
|
|
14
|
-
export * from "./ListAppLambdaFunctionsService/index.js";
|
|
15
|
-
export * from "./ListDeployedEnvironmentsService/index.js";
|
|
16
13
|
export * from "./ListPackagesInAppWorkspaceService/index.js";
|
|
17
14
|
export * from "./ListPackagesService/index.js";
|
|
18
15
|
export * from "./LoadEnvVarsService/index.js";
|
|
@@ -20,17 +17,8 @@ export * from "./LocalStorageService/index.js";
|
|
|
20
17
|
export * from "./LoggerService/index.js";
|
|
21
18
|
export * from "./ProjectInfoService/index.js";
|
|
22
19
|
export * from "./ProjectSdkParamsService/index.js";
|
|
23
|
-
export * from "./PulumiGetConfigPassphraseService/index.js";
|
|
24
|
-
export * from "./PulumiGetSecretsProviderService/index.js";
|
|
25
|
-
export * from "./PulumiExportService/index.js";
|
|
26
|
-
export * from "./PulumiImportService/index.js";
|
|
27
|
-
export * from "./PulumiGetStackOutputService/index.js";
|
|
28
|
-
export * from "./PulumiLoginService/index.js";
|
|
29
|
-
export * from "./PulumiSelectStackService/index.js";
|
|
30
20
|
export * from "./SetProjectIdService/index.js";
|
|
31
|
-
export * from "./StackOutputCacheService/index.js";
|
|
32
21
|
export * from "./StdioService/index.js";
|
|
33
22
|
export * from "./UiService/index.js";
|
|
34
23
|
export * from "./ValidateProjectConfigService/index.js";
|
|
35
|
-
export * from "./WatchedLambdaFunctionsService/index.js";
|
|
36
24
|
export * from "./WcpService/index.js";
|
package/services/index.js
CHANGED
|
@@ -10,9 +10,6 @@ export * from "./GetProjectInstallationIdService/index.js";
|
|
|
10
10
|
export * from "./GetProjectVersionService/index.js";
|
|
11
11
|
export * from "./InitProjectSdkService/index.js";
|
|
12
12
|
export * from "./InstallExtensionService/index.js";
|
|
13
|
-
export * from "./IsRemotePulumiBackendService/index.js";
|
|
14
|
-
export * from "./ListAppLambdaFunctionsService/index.js";
|
|
15
|
-
export * from "./ListDeployedEnvironmentsService/index.js";
|
|
16
13
|
export * from "./ListPackagesInAppWorkspaceService/index.js";
|
|
17
14
|
export * from "./ListPackagesService/index.js";
|
|
18
15
|
export * from "./LoadEnvVarsService/index.js";
|
|
@@ -20,17 +17,8 @@ export * from "./LocalStorageService/index.js";
|
|
|
20
17
|
export * from "./LoggerService/index.js";
|
|
21
18
|
export * from "./ProjectInfoService/index.js";
|
|
22
19
|
export * from "./ProjectSdkParamsService/index.js";
|
|
23
|
-
export * from "./PulumiGetConfigPassphraseService/index.js";
|
|
24
|
-
export * from "./PulumiGetSecretsProviderService/index.js";
|
|
25
|
-
export * from "./PulumiExportService/index.js";
|
|
26
|
-
export * from "./PulumiImportService/index.js";
|
|
27
|
-
export * from "./PulumiGetStackOutputService/index.js";
|
|
28
|
-
export * from "./PulumiLoginService/index.js";
|
|
29
|
-
export * from "./PulumiSelectStackService/index.js";
|
|
30
20
|
export * from "./SetProjectIdService/index.js";
|
|
31
|
-
export * from "./StackOutputCacheService/index.js";
|
|
32
21
|
export * from "./StdioService/index.js";
|
|
33
22
|
export * from "./UiService/index.js";
|
|
34
23
|
export * from "./ValidateProjectConfigService/index.js";
|
|
35
|
-
export * from "./WatchedLambdaFunctionsService/index.js";
|
|
36
24
|
export * from "./WcpService/index.js";
|
|
@@ -14,10 +14,10 @@ class ExtensionSrcResolver {
|
|
|
14
14
|
}
|
|
15
15
|
static resolvePath(filePath, project) {
|
|
16
16
|
if (filePath.startsWith("/extensions/")) return project.paths.rootFolder.join(filePath).toString();
|
|
17
|
-
{
|
|
17
|
+
else {
|
|
18
18
|
const resolved = this.resolvePathAlias(filePath, project);
|
|
19
19
|
if (resolved) return resolved;
|
|
20
|
-
return filePath;
|
|
20
|
+
else return filePath;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
static existsSync(filePath, project) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/ExtensionSrcResolver.js","sources":["../../src/utils/ExtensionSrcResolver.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { getTsconfig } from \"get-tsconfig\";\nimport { toImportSpecifier } from \"./toImportSpecifier.js\";\nimport { type IProjectModel } from \"~/abstractions/models/index.js\";\n\nexport class ExtensionSrcResolver {\n private static pathMappings: { [key: string]: string[] } | null = null;\n\n /**\n * Import a module from a given file path.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns the default export or named export matching the filename.\n */\n static async importFromPath(filePath: string, project: IProjectModel) {\n const importPath = this.resolvePath(filePath, project);\n const exportName = path.basename(filePath).replace(path.extname(filePath), \"\");\n\n const importedModule = await import(toImportSpecifier(importPath));\n\n // Support both default and named exports.\n // Check for 'default' property existence rather than truthiness.\n return (\n (\"default\" in importedModule && importedModule.default) || importedModule[exportName]\n );\n }\n\n /**\n * Resolve a file path to an absolute path.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns the absolute path without importing.\n */\n static resolvePath(filePath: string, project: IProjectModel): string {\n if (filePath.startsWith(\"/extensions/\")) {\n // Resolve from project root.\n return project.paths.rootFolder.join(filePath).toString();\n } else {\n // Try to resolve using tsconfig path aliases.\n const resolved = this.resolvePathAlias(filePath, project);\n if (resolved) {\n return resolved;\n } else {\n // Treat as absolute path.\n return filePath;\n }\n }\n }\n\n /**\n * Check if a file exists at the given path.\n * Resolves the path using the same logic as resolvePath before checking.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns true if the file exists, false otherwise.\n */\n static existsSync(filePath: string, project: IProjectModel): boolean {\n const absolutePath = this.resolvePath(filePath, project);\n return fs.existsSync(absolutePath);\n }\n\n private static resolvePathAlias(filePath: string, project: IProjectModel): string | null {\n const projectRoot = project.paths.rootFolder.toString();\n\n // Load path mappings from tsconfig if not already cached.\n if (this.pathMappings === null) {\n this.loadPathMappings(project);\n }\n\n if (!this.pathMappings) {\n return null;\n }\n\n // Try to match against each path pattern.\n for (const [pattern, targets] of Object.entries(this.pathMappings)) {\n const match = this.matchPattern(filePath, pattern);\n if (match !== null) {\n // Use the first mapping.\n const target = targets[0];\n const resolvedPath = this.replacePlaceholder(target, match);\n return path.resolve(projectRoot, resolvedPath);\n }\n }\n\n return null;\n }\n\n private static loadPathMappings(project: IProjectModel): void {\n const tsConfigPath = project.paths.tsConfigFile.toString();\n\n try {\n // Use get-tsconfig to parse tsconfig with extends resolution.\n const tsconfig = getTsconfig(tsConfigPath);\n\n if (tsconfig?.config.compilerOptions?.paths) {\n this.pathMappings = tsconfig.config.compilerOptions.paths;\n } else {\n this.pathMappings = {};\n }\n } catch {\n // Ignore tsconfig parsing errors.\n this.pathMappings = {};\n }\n }\n\n private static matchPattern(importPath: string, pattern: string): string | null {\n // Handle wildcard patterns like \"@/*\" or \"@extensions/*\".\n if (pattern.endsWith(\"/*\")) {\n const prefix = pattern.slice(0, -2);\n // Only match if there's a slash after the prefix.\n if (importPath.startsWith(prefix + \"/\")) {\n return importPath.slice(prefix.length + 1);\n }\n } else if (pattern === importPath) {\n return \"\";\n }\n\n return null;\n }\n\n private static replacePlaceholder(mapping: string, match: string): string {\n // Replace wildcard with the matched part.\n if (mapping.endsWith(\"/*\")) {\n return mapping.slice(0, -2) + \"/\" + match;\n }\n return mapping;\n }\n}\n"],"names":["ExtensionSrcResolver","filePath","project","importPath","exportName","path","importedModule","toImportSpecifier","resolved","absolutePath","fs","projectRoot","pattern","targets","Object","match","target","resolvedPath","tsConfigPath","tsconfig","getTsconfig","prefix","mapping"],"mappings":";;;;AAMO,MAAMA;;aACM,YAAY,GAAuC;;IASlE,aAAa,eAAeC,QAAgB,EAAEC,OAAsB,EAAE;QAClE,MAAMC,aAAa,IAAI,CAAC,WAAW,CAACF,UAAUC;QAC9C,MAAME,aAAaC,KAAK,QAAQ,CAACJ,UAAU,OAAO,CAACI,KAAK,OAAO,CAACJ,WAAW;QAE3E,MAAMK,iBAAiB,MAAM,MAAM,CAACC,kBAAkBJ;QAItD,OACK,aAAaG,kBAAkBA,eAAe,OAAO,IAAKA,cAAc,CAACF,WAAW;IAE7F;IASA,OAAO,YAAYH,QAAgB,EAAEC,OAAsB,EAAU;QACjE,IAAID,SAAS,UAAU,CAAC,iBAEpB,OAAOC,QAAQ,KAAK,CAAC,UAAU,CAAC,IAAI,CAACD,UAAU,QAAQ;
|
|
1
|
+
{"version":3,"file":"utils/ExtensionSrcResolver.js","sources":["../../src/utils/ExtensionSrcResolver.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { getTsconfig } from \"get-tsconfig\";\nimport { toImportSpecifier } from \"./toImportSpecifier.js\";\nimport { type IProjectModel } from \"~/abstractions/models/index.js\";\n\nexport class ExtensionSrcResolver {\n private static pathMappings: { [key: string]: string[] } | null = null;\n\n /**\n * Import a module from a given file path.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns the default export or named export matching the filename.\n */\n static async importFromPath(filePath: string, project: IProjectModel) {\n const importPath = this.resolvePath(filePath, project);\n const exportName = path.basename(filePath).replace(path.extname(filePath), \"\");\n\n const importedModule = await import(toImportSpecifier(importPath));\n\n // Support both default and named exports.\n // Check for 'default' property existence rather than truthiness.\n return (\n (\"default\" in importedModule && importedModule.default) || importedModule[exportName]\n );\n }\n\n /**\n * Resolve a file path to an absolute path.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns the absolute path without importing.\n */\n static resolvePath(filePath: string, project: IProjectModel): string {\n if (filePath.startsWith(\"/extensions/\")) {\n // Resolve from project root.\n return project.paths.rootFolder.join(filePath).toString();\n } else {\n // Try to resolve using tsconfig path aliases.\n const resolved = this.resolvePathAlias(filePath, project);\n if (resolved) {\n return resolved;\n } else {\n // Treat as absolute path.\n return filePath;\n }\n }\n }\n\n /**\n * Check if a file exists at the given path.\n * Resolves the path using the same logic as resolvePath before checking.\n * - If path starts with \"/extensions/\", it resolves from project root\n * - If path matches tsconfig path alias (e.g., \"@/*\"), it resolves using tsconfig\n * - Otherwise, treats path as absolute\n * Returns true if the file exists, false otherwise.\n */\n static existsSync(filePath: string, project: IProjectModel): boolean {\n const absolutePath = this.resolvePath(filePath, project);\n return fs.existsSync(absolutePath);\n }\n\n private static resolvePathAlias(filePath: string, project: IProjectModel): string | null {\n const projectRoot = project.paths.rootFolder.toString();\n\n // Load path mappings from tsconfig if not already cached.\n if (this.pathMappings === null) {\n this.loadPathMappings(project);\n }\n\n if (!this.pathMappings) {\n return null;\n }\n\n // Try to match against each path pattern.\n for (const [pattern, targets] of Object.entries(this.pathMappings)) {\n const match = this.matchPattern(filePath, pattern);\n if (match !== null) {\n // Use the first mapping.\n const target = targets[0];\n const resolvedPath = this.replacePlaceholder(target, match);\n return path.resolve(projectRoot, resolvedPath);\n }\n }\n\n return null;\n }\n\n private static loadPathMappings(project: IProjectModel): void {\n const tsConfigPath = project.paths.tsConfigFile.toString();\n\n try {\n // Use get-tsconfig to parse tsconfig with extends resolution.\n const tsconfig = getTsconfig(tsConfigPath);\n\n if (tsconfig?.config.compilerOptions?.paths) {\n this.pathMappings = tsconfig.config.compilerOptions.paths;\n } else {\n this.pathMappings = {};\n }\n } catch {\n // Ignore tsconfig parsing errors.\n this.pathMappings = {};\n }\n }\n\n private static matchPattern(importPath: string, pattern: string): string | null {\n // Handle wildcard patterns like \"@/*\" or \"@extensions/*\".\n if (pattern.endsWith(\"/*\")) {\n const prefix = pattern.slice(0, -2);\n // Only match if there's a slash after the prefix.\n if (importPath.startsWith(prefix + \"/\")) {\n return importPath.slice(prefix.length + 1);\n }\n } else if (pattern === importPath) {\n return \"\";\n }\n\n return null;\n }\n\n private static replacePlaceholder(mapping: string, match: string): string {\n // Replace wildcard with the matched part.\n if (mapping.endsWith(\"/*\")) {\n return mapping.slice(0, -2) + \"/\" + match;\n }\n return mapping;\n }\n}\n"],"names":["ExtensionSrcResolver","filePath","project","importPath","exportName","path","importedModule","toImportSpecifier","resolved","absolutePath","fs","projectRoot","pattern","targets","Object","match","target","resolvedPath","tsConfigPath","tsconfig","getTsconfig","prefix","mapping"],"mappings":";;;;AAMO,MAAMA;;aACM,YAAY,GAAuC;;IASlE,aAAa,eAAeC,QAAgB,EAAEC,OAAsB,EAAE;QAClE,MAAMC,aAAa,IAAI,CAAC,WAAW,CAACF,UAAUC;QAC9C,MAAME,aAAaC,KAAK,QAAQ,CAACJ,UAAU,OAAO,CAACI,KAAK,OAAO,CAACJ,WAAW;QAE3E,MAAMK,iBAAiB,MAAM,MAAM,CAACC,kBAAkBJ;QAItD,OACK,aAAaG,kBAAkBA,eAAe,OAAO,IAAKA,cAAc,CAACF,WAAW;IAE7F;IASA,OAAO,YAAYH,QAAgB,EAAEC,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;YAEJ,IAAI,CAAC,YAAY,GAAG,CAAC;QACzB;IACJ;IAEA,OAAe,aAAahB,UAAkB,EAAES,OAAe,EAAiB;QAE5E,IAAIA,QAAQ,QAAQ,CAAC,OAAO;YACxB,MAAMS,SAAST,QAAQ,KAAK,CAAC,GAAG;YAEhC,IAAIT,WAAW,UAAU,CAACkB,SAAS,MAC/B,OAAOlB,WAAW,KAAK,CAACkB,OAAO,MAAM,GAAG;QAEhD,OAAO,IAAIT,YAAYT,YACnB,OAAO;QAGX,OAAO;IACX;IAEA,OAAe,mBAAmBmB,OAAe,EAAEP,KAAa,EAAU;QAEtE,IAAIO,QAAQ,QAAQ,CAAC,OACjB,OAAOA,QAAQ,KAAK,CAAC,GAAG,MAAM,MAAMP;QAExC,OAAOO;IACX;AACJ"}
|
package/utils/apiRuntimeEnv.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Environment variable name prefixes that are safe to expose to the api RUNTIME — as opposed to
|
|
3
3
|
* build-time-only vars (notably `WCP_PROJECT_LICENSE`, which the runtime deliberately re-fetches a
|
|
4
4
|
* fresh copy of). This is the single source of truth shared by both hosting types: the AWS Lambda sets
|
|
5
|
-
* exactly these on the function, and the
|
|
5
|
+
* exactly these on the function, and the standalone server spawns its api process with exactly
|
|
6
6
|
* these. `WCP_PROJECT_LICENSE` is excluded simply by not being listed.
|
|
7
7
|
*/
|
|
8
8
|
export declare const API_RUNTIME_ENV_PREFIXES: string[];
|
|
@@ -12,7 +12,7 @@ export declare const API_RUNTIME_ENV_PREFIXES: string[];
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function pickApiRuntimeEnvVariables(env?: NodeJS.ProcessEnv): Record<string, string>;
|
|
14
14
|
/**
|
|
15
|
-
* Env for a spawned
|
|
15
|
+
* Env for a spawned standalone server process: the api runtime allowlist (see above) PLUS the
|
|
16
16
|
* system vars the process needs to run. This is the hybrid the server uses instead of inheriting the
|
|
17
17
|
* whole environment — it forwards the same app vars as the Lambda (no arbitrary leakage) while still
|
|
18
18
|
* keeping the process runnable.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/apiRuntimeEnv.js","sources":["../../src/utils/apiRuntimeEnv.ts"],"sourcesContent":["/**\n * Environment variable name prefixes that are safe to expose to the api RUNTIME — as opposed to\n * build-time-only vars (notably `WCP_PROJECT_LICENSE`, which the runtime deliberately re-fetches a\n * fresh copy of). This is the single source of truth shared by both hosting types: the AWS Lambda sets\n * exactly these on the function, and the
|
|
1
|
+
{"version":3,"file":"utils/apiRuntimeEnv.js","sources":["../../src/utils/apiRuntimeEnv.ts"],"sourcesContent":["/**\n * Environment variable name prefixes that are safe to expose to the api RUNTIME — as opposed to\n * build-time-only vars (notably `WCP_PROJECT_LICENSE`, which the runtime deliberately re-fetches a\n * fresh copy of). This is the single source of truth shared by both hosting types: the AWS Lambda sets\n * exactly these on the function, and the standalone server spawns its api process with exactly\n * these. `WCP_PROJECT_LICENSE` is excluded simply by not being listed.\n */\nexport const API_RUNTIME_ENV_PREFIXES = [\n // Covers WEBINY_API_*, WEBINY_PROJECT_API_KEY, WEBINY_ADMIN_*, WEBINY_SQL_FILENAME, etc.\n \"WEBINY_\",\n // Covers WCP_PROJECT_ENVIRONMENT + WCP_PROJECT_ENVIRONMENT_API_KEY (needed to fetch the license),\n // but NOT WCP_PROJECT_LICENSE (build-time only).\n \"WCP_PROJECT_ENVIRONMENT\",\n \"OKTA_\",\n \"AUTH0_\"\n];\n\n/**\n * Pick the api runtime env vars from `env` (the allowlist above), plus `DEBUG`. Returns a plain\n * string map suitable for a Lambda's env or a spawned server process's env.\n */\nexport function pickApiRuntimeEnvVariables(\n env: NodeJS.ProcessEnv = process.env\n): Record<string, string> {\n const picked: Record<string, string> = {\n // Among other things, this determines how much detail runtime errors reveal.\n DEBUG: String(env.DEBUG)\n };\n\n for (const key of Object.keys(env)) {\n const value = env[key];\n if (\n value !== undefined &&\n API_RUNTIME_ENV_PREFIXES.some(prefix => key.startsWith(prefix))\n ) {\n picked[key] = String(value);\n }\n }\n\n return picked;\n}\n\n/**\n * System env vars a spawned server process needs to actually run — TLS trust (custom CAs, e.g.\n * portless), temp dirs, locale, PATH, etc. The AWS Lambda gets these from its own managed runtime;\n * a spawned Node process gets NOTHING unless we pass them (an explicit `env` replaces, not merges).\n * Kept explicit (not \"everything non-Webiny\") so arbitrary user vars don't silently leak into the\n * runtime — matching Lambda, which forwards only the app allowlist.\n */\nconst SYSTEM_ENV_NAMES = [\n \"PATH\",\n \"HOME\",\n \"TMPDIR\",\n \"TMP\",\n \"TEMP\",\n \"TZ\",\n \"LANG\",\n \"LC_ALL\",\n \"SHELL\",\n \"USER\",\n \"LOGNAME\",\n \"PWD\",\n \"HOSTNAME\",\n \"TERM\",\n \"SSL_CERT_FILE\",\n \"SSL_CERT_DIR\"\n];\n\n// NODE_* covers NODE_OPTIONS / NODE_EXTRA_CA_CERTS / NODE_ENV; LC_* covers locale categories.\nconst SYSTEM_ENV_PREFIXES = [\"NODE_\", \"LC_\"];\n\n/**\n * Env for a spawned standalone server process: the api runtime allowlist (see above) PLUS the\n * system vars the process needs to run. This is the hybrid the server uses instead of inheriting the\n * whole environment — it forwards the same app vars as the Lambda (no arbitrary leakage) while still\n * keeping the process runnable.\n */\nexport function pickServerRuntimeEnvVariables(\n env: NodeJS.ProcessEnv = process.env\n): Record<string, string> {\n const picked = pickApiRuntimeEnvVariables(env);\n\n for (const key of Object.keys(env)) {\n const value = env[key];\n if (value === undefined) {\n continue;\n }\n const isSystem =\n SYSTEM_ENV_NAMES.includes(key) ||\n SYSTEM_ENV_PREFIXES.some(prefix => key.startsWith(prefix));\n if (isSystem) {\n picked[key] = String(value);\n }\n }\n\n return picked;\n}\n"],"names":["API_RUNTIME_ENV_PREFIXES","pickApiRuntimeEnvVariables","env","process","picked","String","key","Object","value","undefined","prefix","SYSTEM_ENV_NAMES","SYSTEM_ENV_PREFIXES","pickServerRuntimeEnvVariables","isSystem"],"mappings":"AAOO,MAAMA,2BAA2B;IAEpC;IAGA;IACA;IACA;CACH;AAMM,SAASC,2BACZC,MAAyBC,QAAQ,GAAG;IAEpC,MAAMC,SAAiC;QAEnC,OAAOC,OAAOH,IAAI,KAAK;IAC3B;IAEA,KAAK,MAAMI,OAAOC,OAAO,IAAI,CAACL,KAAM;QAChC,MAAMM,QAAQN,GAAG,CAACI,IAAI;QACtB,IACIE,AAAUC,WAAVD,SACAR,yBAAyB,IAAI,CAACU,CAAAA,SAAUJ,IAAI,UAAU,CAACI,UAEvDN,MAAM,CAACE,IAAI,GAAGD,OAAOG;IAE7B;IAEA,OAAOJ;AACX;AASA,MAAMO,mBAAmB;IACrB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAGD,MAAMC,sBAAsB;IAAC;IAAS;CAAM;AAQrC,SAASC,8BACZX,MAAyBC,QAAQ,GAAG;IAEpC,MAAMC,SAASH,2BAA2BC;IAE1C,KAAK,MAAMI,OAAOC,OAAO,IAAI,CAACL,KAAM;QAChC,MAAMM,QAAQN,GAAG,CAACI,IAAI;QACtB,IAAIE,AAAUC,WAAVD,OACA;QAEJ,MAAMM,WACFH,iBAAiB,QAAQ,CAACL,QAC1BM,oBAAoB,IAAI,CAACF,CAAAA,SAAUJ,IAAI,UAAU,CAACI;QACtD,IAAII,UACAV,MAAM,CAACE,IAAI,GAAGD,OAAOG;IAE7B;IAEA,OAAOJ;AACX"}
|
package/utils/env/index.d.ts
CHANGED
package/utils/env/index.js
CHANGED
package/utils/index.d.ts
CHANGED
|
@@ -9,5 +9,7 @@ export * from "./isValidVariantName.js";
|
|
|
9
9
|
export * from "./measureDuration.js";
|
|
10
10
|
export * from "./requireConfig.js";
|
|
11
11
|
export * from "./toImportSpecifier.js";
|
|
12
|
+
export * from "./trace/index.js";
|
|
12
13
|
export * from "./projectSdkContext.js";
|
|
13
14
|
export * from "./registerExtension.js";
|
|
15
|
+
export * from "./registerSrcExtensions.js";
|