@webiny/project 6.6.0-alpha.0 → 6.6.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abstractions/features/DestroyApp.d.ts +2 -2
- package/abstractions/features/DestroyApp.js.map +1 -1
- package/abstractions/features/GetAppStackOutput.d.ts +3 -2
- package/abstractions/features/GetAppStackOutput.js.map +1 -1
- package/abstractions/features/Watch.d.ts +2 -0
- package/abstractions/features/Watch.js.map +1 -1
- package/abstractions/services/StackOutputCacheService.d.ts +10 -0
- package/abstractions/services/StackOutputCacheService.js +5 -0
- package/abstractions/services/StackOutputCacheService.js.map +1 -0
- package/abstractions/services/index.d.ts +1 -0
- package/abstractions/services/index.js +1 -0
- package/components/FeatureFlag.d.ts +48 -0
- package/components/FeatureFlag.js +59 -0
- package/components/FeatureFlag.js.map +1 -0
- package/createProjectSdkContainer.js +24 -10
- package/createProjectSdkContainer.js.map +1 -1
- package/decorators/DestroyAppClearStackOutputCache.d.ts +25 -0
- package/decorators/DestroyAppClearStackOutputCache.js +29 -0
- package/decorators/DestroyAppClearStackOutputCache.js.map +1 -0
- package/decorators/GetFeatureFlagsWithLicense.d.ts +0 -1
- package/decorators/GetFeatureFlagsWithLicense.js +28 -20
- package/decorators/GetFeatureFlagsWithLicense.js.map +1 -1
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +1 -0
- package/defineExtension/createExtensionReactComponent.js +9 -1
- package/defineExtension/createExtensionReactComponent.js.map +1 -1
- package/defineExtension/types.d.ts +6 -1
- package/extensions/AdminApiUrl.js +2 -1
- package/extensions/AdminApiUrl.js.map +1 -1
- package/extensions/AdminBuildParam.js +5 -5
- package/extensions/AdminBuildParam.js.map +1 -1
- package/extensions/AdminExtension.d.ts +1 -1
- package/extensions/AdminExtension.js +6 -5
- package/extensions/AdminExtension.js.map +1 -1
- package/extensions/AdminWebsocketsUrl.d.ts +1 -1
- package/extensions/AdminWebsocketsUrl.js +2 -1
- package/extensions/AdminWebsocketsUrl.js.map +1 -1
- package/extensions/ApiBuildParam.js +11 -10
- package/extensions/ApiBuildParam.js.map +1 -1
- package/extensions/ApiExtension.d.ts +1 -1
- package/extensions/ApiExtension.js +8 -5
- package/extensions/ApiExtension.js.map +1 -1
- package/extensions/BugReporter.d.ts +6 -0
- package/extensions/BugReporter.js +34 -0
- package/extensions/BugReporter.js.map +1 -0
- package/extensions/DatabaseSetup.js +2 -1
- package/extensions/DatabaseSetup.js.map +1 -1
- package/extensions/EnvVar.js +2 -1
- package/extensions/EnvVar.js.map +1 -1
- package/extensions/ExtensionDefinitions.js +2 -1
- package/extensions/ExtensionDefinitions.js.map +1 -1
- package/extensions/FeatureFlags.d.ts +22 -11
- package/extensions/FeatureFlags.js +33 -11
- package/extensions/FeatureFlags.js.map +1 -1
- package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js +1 -0
- package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js.map +1 -1
- package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js +1 -0
- package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js.map +1 -1
- package/extensions/Project/ShowConfigChangeInfoBeforeAdminWatch.js +2 -1
- package/extensions/Project/ShowConfigChangeInfoBeforeAdminWatch.js.map +1 -1
- package/extensions/Project/ShowConfigChangeInfoBeforeApiWatch.js +2 -1
- package/extensions/Project/ShowConfigChangeInfoBeforeApiWatch.js.map +1 -1
- package/extensions/Project/WcpInjectTelemetryClientAfterBuild.js +2 -1
- package/extensions/Project/WcpInjectTelemetryClientAfterBuild.js.map +1 -1
- package/extensions/Project/showConfigChangeNotice.d.ts +7 -0
- package/extensions/Project/showConfigChangeNotice.js +9 -0
- package/extensions/Project/showConfigChangeNotice.js.map +1 -0
- package/extensions/ProjectDecorator.js +2 -1
- package/extensions/ProjectDecorator.js.map +1 -1
- package/extensions/ProjectId.js +2 -1
- package/extensions/ProjectId.js.map +1 -1
- package/extensions/ProjectImplementation.js +2 -1
- package/extensions/ProjectImplementation.js.map +1 -1
- package/extensions/Telemetry.js +2 -1
- package/extensions/Telemetry.js.map +1 -1
- package/extensions/api/BackgroundTasks.d.ts +4 -0
- package/extensions/api/BackgroundTasks.js +25 -0
- package/extensions/api/BackgroundTasks.js.map +1 -0
- package/extensions/api/Cms/ModelFieldCompression.d.ts +4 -0
- package/extensions/api/Cms/ModelFieldCompression.js +25 -0
- package/extensions/api/Cms/ModelFieldCompression.js.map +1 -0
- package/extensions/api/Mailer/Smtp.d.ts +8 -0
- package/extensions/api/Mailer/Smtp.js +22 -0
- package/extensions/api/Mailer/Smtp.js.map +1 -0
- package/extensions/api/Mailer/Smtp.test.d.ts +1 -0
- package/extensions/api/Mailer/Smtp.test.js +127 -0
- package/extensions/api/Mailer/Smtp.test.js.map +1 -0
- package/extensions/api/Mailer/SmtpParamsSchema.d.ts +9 -0
- package/extensions/api/Mailer/SmtpParamsSchema.js +17 -0
- package/extensions/api/Mailer/SmtpParamsSchema.js.map +1 -0
- package/extensions/api/index.d.ts +4 -0
- package/extensions/api/index.js +4 -0
- package/extensions/hasDefaultExport.d.ts +2 -0
- package/extensions/hasDefaultExport.js +17 -0
- package/extensions/hasDefaultExport.js.map +1 -0
- package/extensions/hooks/AdminAfterBuild.js +2 -1
- package/extensions/hooks/AdminAfterBuild.js.map +1 -1
- package/extensions/hooks/AdminAfterDeploy.js +2 -1
- package/extensions/hooks/AdminAfterDeploy.js.map +1 -1
- package/extensions/hooks/AdminBeforeBuild.js +2 -1
- package/extensions/hooks/AdminBeforeBuild.js.map +1 -1
- package/extensions/hooks/AdminBeforeDeploy.js +2 -1
- package/extensions/hooks/AdminBeforeDeploy.js.map +1 -1
- package/extensions/hooks/AdminBeforeWatch.js +2 -1
- package/extensions/hooks/AdminBeforeWatch.js.map +1 -1
- package/extensions/hooks/AfterBuild.js +2 -1
- package/extensions/hooks/AfterBuild.js.map +1 -1
- package/extensions/hooks/AfterDeploy.js +2 -1
- package/extensions/hooks/AfterDeploy.js.map +1 -1
- package/extensions/hooks/ApiAfterBuild.js +2 -1
- package/extensions/hooks/ApiAfterBuild.js.map +1 -1
- package/extensions/hooks/ApiAfterDeploy.js +2 -1
- package/extensions/hooks/ApiAfterDeploy.js.map +1 -1
- package/extensions/hooks/ApiBeforeBuild.js +2 -1
- package/extensions/hooks/ApiBeforeBuild.js.map +1 -1
- package/extensions/hooks/ApiBeforeDeploy.js +2 -1
- package/extensions/hooks/ApiBeforeDeploy.js.map +1 -1
- package/extensions/hooks/ApiBeforeWatch.js +2 -1
- package/extensions/hooks/ApiBeforeWatch.js.map +1 -1
- package/extensions/hooks/BeforeBuild.js +2 -1
- package/extensions/hooks/BeforeBuild.js.map +1 -1
- package/extensions/hooks/BeforeDeploy.js +2 -1
- package/extensions/hooks/BeforeDeploy.js.map +1 -1
- package/extensions/hooks/BeforeWatch.js +2 -1
- package/extensions/hooks/BeforeWatch.js.map +1 -1
- package/extensions/hooks/CoreAfterBuild.js +2 -1
- package/extensions/hooks/CoreAfterBuild.js.map +1 -1
- package/extensions/hooks/CoreAfterDeploy.js +2 -1
- package/extensions/hooks/CoreAfterDeploy.js.map +1 -1
- package/extensions/hooks/CoreBeforeBuild.js +2 -1
- package/extensions/hooks/CoreBeforeBuild.js.map +1 -1
- package/extensions/hooks/CoreBeforeDeploy.js +2 -1
- package/extensions/hooks/CoreBeforeDeploy.js.map +1 -1
- package/extensions/hooks/CoreBeforeWatch.js +2 -1
- package/extensions/hooks/CoreBeforeWatch.js.map +1 -1
- package/extensions/hosting/assertHostingType.d.ts +13 -0
- package/extensions/hosting/assertHostingType.js +12 -0
- package/extensions/hosting/assertHostingType.js.map +1 -0
- package/extensions/hosting/extensionImplementations.d.ts +12 -0
- package/extensions/hosting/extensionImplementations.js +4 -0
- package/extensions/hosting/extensionImplementations.js.map +1 -0
- package/extensions/hosting/getExtensionImplementation.d.ts +1 -0
- package/extensions/hosting/getExtensionImplementation.js +9 -0
- package/extensions/hosting/getExtensionImplementation.js.map +1 -0
- package/extensions/hosting/hostingType.d.ts +2 -0
- package/extensions/hosting/hostingType.js +0 -0
- package/extensions/hosting/index.d.ts +4 -0
- package/extensions/hosting/index.js +4 -0
- package/extensions/hosting/registerExtensionImplementation.d.ts +12 -0
- package/extensions/hosting/registerExtensionImplementation.js +13 -0
- package/extensions/hosting/registerExtensionImplementation.js.map +1 -0
- package/extensions/index.d.ts +51 -48
- package/extensions/index.js +8 -11
- package/extensions/index.js.map +1 -1
- package/extensions/infra/Env.js +5 -0
- package/extensions/infra/Env.js.map +1 -1
- package/extensions/pulumi/ProductionEnvironments.js +2 -1
- package/extensions/pulumi/ProductionEnvironments.js.map +1 -1
- package/extensions/pulumi/PulumiResourceNamePrefix.js +2 -1
- package/extensions/pulumi/PulumiResourceNamePrefix.js.map +1 -1
- package/extensions/pulumi/index.d.ts +0 -3
- package/extensions/pulumi/index.js +0 -3
- package/features/Serve/Serve.d.ts +1 -1
- package/features/Serve/Serve.js.map +1 -1
- package/features/Watch/watchers/worker.js +3 -0
- package/features/Watch/watchers/worker.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/package.json +35 -31
- 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/FeatureFlagsContext.d.ts +26 -0
- package/services/GetProjectConfigService/FeatureFlagsContext.js +41 -0
- package/services/GetProjectConfigService/FeatureFlagsContext.js.map +1 -0
- package/services/GetProjectConfigService/GetProjectConfigService.js +14 -11
- package/services/GetProjectConfigService/GetProjectConfigService.js.map +1 -1
- package/services/GetProjectConfigService/LicenseDecoratedFeatureFlags.d.ts +8 -0
- package/services/GetProjectConfigService/LicenseDecoratedFeatureFlags.js +28 -0
- package/services/GetProjectConfigService/LicenseDecoratedFeatureFlags.js.map +1 -0
- package/services/GetProjectConfigService/WcpProjectLicenseContext.d.ts +1 -0
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js +1 -0
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js.map +1 -1
- package/services/GetProjectConfigService/getRenderCacheKey.d.ts +1 -0
- package/services/GetProjectConfigService/getRenderCacheKey.js +13 -0
- package/services/GetProjectConfigService/getRenderCacheKey.js.map +1 -0
- package/services/GetProjectConfigService/nullRenderer.d.ts +4 -0
- package/services/GetProjectConfigService/nullRenderer.js +83 -0
- package/services/GetProjectConfigService/nullRenderer.js.map +1 -0
- package/services/GetProjectConfigService/renderConfig.d.ts +3 -12
- package/services/GetProjectConfigService/renderConfig.js +10 -35
- package/services/GetProjectConfigService/renderConfig.js.map +1 -1
- package/services/GetProjectConfigService/renderExtensions.d.ts +8 -0
- package/services/GetProjectConfigService/renderExtensions.js +52 -0
- package/services/GetProjectConfigService/renderExtensions.js.map +1 -0
- package/services/InitProjectSdkService/InitProjectSdkService.js +12 -9
- 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/PulumiGetStackOutputService/PulumiGetStackOutputService.d.ts +3 -11
- package/services/PulumiGetStackOutputService/PulumiGetStackOutputService.js +7 -64
- package/services/PulumiGetStackOutputService/PulumiGetStackOutputService.js.map +1 -1
- package/services/StackOutputCacheService/StackOutputCacheService.d.ts +18 -0
- package/services/StackOutputCacheService/StackOutputCacheService.js +89 -0
- package/services/StackOutputCacheService/StackOutputCacheService.js.map +1 -0
- package/services/StackOutputCacheService/index.d.ts +1 -0
- package/services/StackOutputCacheService/index.js +1 -0
- package/services/UiService/UiService.d.ts +18 -0
- package/services/UiService/UiService.js +18 -2
- package/services/UiService/UiService.js.map +1 -1
- package/services/ValidateProjectConfigService/ValidateProjectConfigService.js +10 -7
- package/services/ValidateProjectConfigService/ValidateProjectConfigService.js.map +1 -1
- package/services/WcpService/GetProjectEnvironment.js +16 -5
- package/services/WcpService/GetProjectEnvironment.js.map +1 -1
- package/services/WcpService/WcpGqlClient.js +2 -2
- package/services/WcpService/WcpGqlClient.js.map +1 -1
- package/services/WcpService/fetchProjectEnvironmentByApiKey.d.ts +8 -0
- package/services/WcpService/fetchProjectEnvironmentByApiKey.js +21 -0
- package/services/WcpService/fetchProjectEnvironmentByApiKey.js.map +1 -0
- package/services/index.d.ts +1 -0
- package/services/index.js +1 -0
- package/utils/ExtensionSrcResolver.js +2 -2
- package/utils/ExtensionSrcResolver.js.map +1 -1
- package/utils/apiRuntimeEnv.d.ts +2 -2
- package/utils/apiRuntimeEnv.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/trace/TraceRecorder.d.ts +17 -0
- package/utils/trace/TraceRecorder.js +51 -0
- package/utils/trace/TraceRecorder.js.map +1 -0
- package/utils/trace/formatTraceReport.d.ts +2 -0
- package/utils/trace/formatTraceReport.js +53 -0
- package/utils/trace/formatTraceReport.js.map +1 -0
- package/utils/trace/index.d.ts +6 -0
- package/utils/trace/index.js +6 -0
- package/utils/trace/isTraceRequested.d.ts +1 -0
- package/utils/trace/isTraceRequested.js +12 -0
- package/utils/trace/isTraceRequested.js.map +1 -0
- package/utils/trace/startTrace.d.ts +1 -0
- package/utils/trace/startTrace.js +19 -0
- package/utils/trace/startTrace.js.map +1 -0
- package/utils/trace/trace.d.ts +1 -0
- package/utils/trace/trace.js +13 -0
- package/utils/trace/trace.js.map +1 -0
- package/utils/trace/traceAsync.d.ts +1 -0
- package/utils/trace/traceAsync.js +13 -0
- package/utils/trace/traceAsync.js.map +1 -0
- package/components/Wcp.d.ts +0 -19
- package/components/Wcp.js +0 -37
- package/components/Wcp.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/infra/Encryption.d.ts +0 -10
- package/extensions/infra/Encryption.js +0 -36
- package/extensions/infra/Encryption.js.map +0 -1
- package/extensions/infra/Hashing.d.ts +0 -5
- package/extensions/infra/Hashing.js +0 -27
- package/extensions/infra/Hashing.js.map +0 -1
- package/extensions/pulumi/AdminStackOutputValue.d.ts +0 -5
- package/extensions/pulumi/AdminStackOutputValue.js +0 -18
- package/extensions/pulumi/AdminStackOutputValue.js.map +0 -1
- package/extensions/pulumi/ApiStackOutputValue.d.ts +0 -5
- package/extensions/pulumi/ApiStackOutputValue.js +0 -18
- package/extensions/pulumi/ApiStackOutputValue.js.map +0 -1
- package/extensions/pulumi/CoreStackOutputValue.d.ts +0 -5
- package/extensions/pulumi/CoreStackOutputValue.js +0 -18
- package/extensions/pulumi/CoreStackOutputValue.js.map +0 -1
- package/rslib-runtime.js +0 -14
- package/rslib-runtime.js.map +0 -1
- package/services/GetProjectConfigService/renderConfigWorker.d.ts +0 -1
- package/services/GetProjectConfigService/renderConfigWorker.js +0 -57
- package/services/GetProjectConfigService/renderConfigWorker.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineExtension/createExtensionReactComponent.js","sources":["../../src/defineExtension/createExtensionReactComponent.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Property, useIdGenerator } from \"@webiny/react-properties\";\nimport { type DefineExtensionParams } from \"./types.js\";\nimport { type z } from \"zod\";\n\nconst KeyValues = (props: Record<string, any>) => {\n const getId = useIdGenerator(\"\");\n return Object.entries(props).map(([key, value]) => {\n return <Property key={key} name={key} id={getId(key)} value={value} />;\n });\n};\n\ntype ExtensionReactComponentProps<TParamsSchema extends z.ZodTypeAny> = z.infer<TParamsSchema> & {\n remove?: boolean;\n before?: string;\n after?: string;\n name?: string;\n};\n\nexport function createExtensionReactComponent<TParamsSchema extends z.ZodTypeAny>(\n extensionParams: DefineExtensionParams<TParamsSchema>\n) {\n const
|
|
1
|
+
{"version":3,"file":"defineExtension/createExtensionReactComponent.js","sources":["../../src/defineExtension/createExtensionReactComponent.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Property, useIdGenerator } from \"@webiny/react-properties\";\nimport { type DefineExtensionParams } from \"./types.js\";\nimport { type z } from \"zod\";\nimport { assertHostingType } from \"~/extensions/hosting/assertHostingType.js\";\nimport { getExtensionImplementation } from \"~/extensions/hosting/getExtensionImplementation.js\";\n\nconst KeyValues = (props: Record<string, any>) => {\n const getId = useIdGenerator(\"\");\n return Object.entries(props).map(([key, value]) => {\n return <Property key={key} name={key} id={getId(key)} value={value} />;\n });\n};\n\ntype ExtensionReactComponentProps<TParamsSchema extends z.ZodTypeAny> = z.infer<TParamsSchema> & {\n remove?: boolean;\n before?: string;\n after?: string;\n name?: string;\n};\n\nexport function createExtensionReactComponent<TParamsSchema extends z.ZodTypeAny>(\n extensionParams: DefineExtensionParams<TParamsSchema>\n) {\n const ExtensionProperty: React.FC<ExtensionReactComponentProps<TParamsSchema>> = props => {\n const { name, remove, before, after, ...keyValues } = props;\n\n const getId = useIdGenerator(extensionParams.type);\n\n // By passing undefined, we're letting RP generate a unique ID for us.\n const propertyId = useMemo(() => {\n if (extensionParams.multiple) {\n return name ? getId(name) : undefined;\n }\n\n return getId(extensionParams.type);\n }, [name, extensionParams.multiple, getId]);\n\n const propertyName = name || extensionParams.type;\n\n const placeAfter = after !== undefined ? getId(after) : undefined;\n const placeBefore = before !== undefined ? getId(before) : undefined;\n\n // @ts-expect-error move KeyValues back inside the Property component to avoid this error\n const KeyValuesComponent = parentProps => <KeyValues {...parentProps} {...keyValues} />;\n\n return (\n <>\n <Property\n id={propertyId}\n name={propertyName}\n array={extensionParams.multiple}\n remove={remove}\n before={placeBefore}\n after={placeAfter}\n >\n <KeyValuesComponent />\n </Property>\n {extensionParams.render && extensionParams.render(props)}\n </>\n );\n };\n\n const ExtensionReactComponent: React.FC<\n ExtensionReactComponentProps<TParamsSchema>\n > = props => {\n assertHostingType(extensionParams.type, extensionParams.tags.hosting);\n\n /*\n * A hosting package may have registered its own component for this extension type. That\n * component is created by `defineExtension` too, so it finds itself here and renders as\n * usual.\n */\n const Implementation = getExtensionImplementation(extensionParams.type);\n if (Implementation && Implementation !== ExtensionReactComponent) {\n return <Implementation {...props} />;\n }\n\n return <ExtensionProperty {...props} />;\n };\n\n ExtensionReactComponent.displayName = `ExtensionReactComponent(${extensionParams.type})`;\n return ExtensionReactComponent;\n}\n"],"names":["KeyValues","props","getId","useIdGenerator","Object","key","value","Property","createExtensionReactComponent","extensionParams","ExtensionProperty","name","remove","before","after","keyValues","propertyId","useMemo","undefined","propertyName","placeAfter","placeBefore","KeyValuesComponent","parentProps","ExtensionReactComponent","assertHostingType","Implementation","getExtensionImplementation"],"mappings":";;;;AAOA,MAAMA,YAAY,CAACC;IACf,MAAMC,QAAQC,eAAe;IAC7B,OAAOC,OAAO,OAAO,CAACH,OAAO,GAAG,CAAC,CAAC,CAACI,KAAKC,MAAM,GACnC,WAAP,GAAO,oBAACC,UAAQA;YAAC,KAAKF;YAAK,MAAMA;YAAK,IAAIH,MAAMG;YAAM,OAAOC;;AAErE;AASO,SAASE,8BACZC,eAAqD;IAErD,MAAMC,oBAA2ET,CAAAA;QAC7E,MAAM,EAAEU,IAAI,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGC,WAAW,GAAGd;QAEtD,MAAMC,QAAQC,eAAeM,gBAAgB,IAAI;QAGjD,MAAMO,aAAaC,QAAQ;YACvB,IAAIR,gBAAgB,QAAQ,EACxB,OAAOE,OAAOT,MAAMS,QAAQO;YAGhC,OAAOhB,MAAMO,gBAAgB,IAAI;QACrC,GAAG;YAACE;YAAMF,gBAAgB,QAAQ;YAAEP;SAAM;QAE1C,MAAMiB,eAAeR,QAAQF,gBAAgB,IAAI;QAEjD,MAAMW,aAAaN,AAAUI,WAAVJ,QAAsBZ,MAAMY,SAASI;QACxD,MAAMG,cAAcR,AAAWK,WAAXL,SAAuBX,MAAMW,UAAUK;QAG3D,MAAMI,qBAAqBC,CAAAA,cAAAA,WAAAA,GAAe,oBAACvB,WAASA;gBAAE,GAAGuB,WAAW;gBAAG,GAAGR,SAAS;;QAEnF,OAAO,WAAP,GACI,wDACI,oBAACR,UAAQA;YACL,IAAIS;YACJ,MAAMG;YACN,OAAOV,gBAAgB,QAAQ;YAC/B,QAAQG;YACR,QAAQS;YACR,OAAOD;yBAEP,oBAACE,oBAAAA,QAEJb,gBAAgB,MAAM,IAAIA,gBAAgB,MAAM,CAACR;IAG9D;IAEA,MAAMuB,0BAEFvB,CAAAA;QACAwB,kBAAkBhB,gBAAgB,IAAI,EAAEA,gBAAgB,IAAI,CAAC,OAAO;QAOpE,MAAMiB,iBAAiBC,2BAA2BlB,gBAAgB,IAAI;QACtE,IAAIiB,kBAAkBA,mBAAmBF,yBACrC,OAAO,WAAP,GAAO,oBAACE,gBAAmBzB;QAG/B,OAAO,WAAP,GAAO,oBAACS,mBAAsBT;IAClC;IAEAuB,wBAAwB,WAAW,GAAG,CAAC,wBAAwB,EAAEf,gBAAgB,IAAI,CAAC,CAAC,CAAC;IACxF,OAAOe;AACX"}
|
|
@@ -2,14 +2,19 @@ import React from "react";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { type ExtensionInstanceModelContext } from "../defineExtension/index.js";
|
|
4
4
|
import { type AppName } from "../abstractions/types.js";
|
|
5
|
+
import { type ExtensionHosting } from "../extensions/hosting/hostingType.js";
|
|
5
6
|
export type ExtensionTags = {
|
|
6
7
|
[key: string]: string | undefined;
|
|
7
8
|
appName?: AppName;
|
|
8
9
|
runtimeContext?: "app-build" | "project" | "cli" | "pulumi";
|
|
10
|
+
hosting?: ExtensionHosting;
|
|
11
|
+
};
|
|
12
|
+
export type ExtensionDefinitionTags = ExtensionTags & {
|
|
13
|
+
hosting: ExtensionHosting;
|
|
9
14
|
};
|
|
10
15
|
export interface DefineExtensionParams<TParamsSchema extends z.ZodTypeAny> {
|
|
11
16
|
type: string;
|
|
12
|
-
tags:
|
|
17
|
+
tags: ExtensionDefinitionTags;
|
|
13
18
|
description?: string;
|
|
14
19
|
multiple?: boolean;
|
|
15
20
|
paramsSchema?: TParamsSchema | ((ctx: ExtensionInstanceModelContext) => TParamsSchema);
|
|
@@ -5,7 +5,8 @@ import { EnvVar } from "./EnvVar.js";
|
|
|
5
5
|
const AdminApiUrl = defineExtension({
|
|
6
6
|
type: "Admin/ApiUrl",
|
|
7
7
|
tags: {
|
|
8
|
-
runtimeContext: "project"
|
|
8
|
+
runtimeContext: "project",
|
|
9
|
+
hosting: "all"
|
|
9
10
|
},
|
|
10
11
|
description: "Set the API URL the Admin app talks to.",
|
|
11
12
|
paramsSchema: z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/AdminApiUrl.js","sources":["../../src/extensions/AdminApiUrl.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { EnvVar } from \"./EnvVar.js\";\n\n/**\n * Sets the URL the Admin app talks to, baked into the admin bundle as `WEBINY_ADMIN_API_URL`\n * (the admin runtime reads it, else falls back to same-origin). Because the config is evaluated\n * at build time, the value can come from any env var the user chooses, e.g.\n * `<Admin.ApiUrl url={process.env.MY_API_URL} />`.\n */\nexport const AdminApiUrl = defineExtension({\n type: \"Admin/ApiUrl\",\n tags: { runtimeContext: \"project\" },\n description: \"Set the API URL the Admin app talks to.\",\n paramsSchema: z.object({\n url: z\n .string()\n .describe(\"The API origin, e.g. https://api.example.com or http://localhost:3000\")\n }),\n render: props => {\n return <EnvVar varName=\"WEBINY_ADMIN_API_URL\" value={props.url} />;\n }\n});\n"],"names":["AdminApiUrl","defineExtension","z","props","EnvVar"],"mappings":";;;;AAWO,MAAMA,cAAcC,gBAAgB;IACvC,MAAM;IACN,MAAM;QAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"extensions/AdminApiUrl.js","sources":["../../src/extensions/AdminApiUrl.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { EnvVar } from \"./EnvVar.js\";\n\n/**\n * Sets the URL the Admin app talks to, baked into the admin bundle as `WEBINY_ADMIN_API_URL`\n * (the admin runtime reads it, else falls back to same-origin). Because the config is evaluated\n * at build time, the value can come from any env var the user chooses, e.g.\n * `<Admin.ApiUrl url={process.env.MY_API_URL} />`.\n */\nexport const AdminApiUrl = defineExtension({\n type: \"Admin/ApiUrl\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description: \"Set the API URL the Admin app talks to.\",\n paramsSchema: z.object({\n url: z\n .string()\n .describe(\"The API origin, e.g. https://api.example.com or http://localhost:3000\")\n }),\n render: props => {\n return <EnvVar varName=\"WEBINY_ADMIN_API_URL\" value={props.url} />;\n }\n});\n"],"names":["AdminApiUrl","defineExtension","z","props","EnvVar"],"mappings":";;;;AAWO,MAAMA,cAAcC,gBAAgB;IACvC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAW,SAAS;IAAM;IAClD,aAAa;IACb,cAAcC,EAAE,MAAM,CAAC;QACnB,KAAKA,EAAAA,MACM,GACN,QAAQ,CAAC;IAClB;IACA,QAAQC,CAAAA,QACG,WAAP,GAAO,oBAACC,QAAMA;YAAC,SAAQ;YAAuB,OAAOD,MAAM,GAAG;;AAEtE"}
|
|
@@ -94,7 +94,8 @@ const AdminBuildParam = defineExtension({
|
|
|
94
94
|
type: "Admin/BuildParam",
|
|
95
95
|
tags: {
|
|
96
96
|
runtimeContext: "app-build",
|
|
97
|
-
appName: "admin"
|
|
97
|
+
appName: "admin",
|
|
98
|
+
hosting: "all"
|
|
98
99
|
},
|
|
99
100
|
description: "Add build-time parameter to Admin app.",
|
|
100
101
|
multiple: true,
|
|
@@ -119,8 +120,7 @@ const AdminBuildParam = defineExtension({
|
|
|
119
120
|
if (!fs.existsSync(buildParamsDir)) fs.mkdirSync(buildParamsDir, {
|
|
120
121
|
recursive: true
|
|
121
122
|
});
|
|
122
|
-
|
|
123
|
-
const fileContent = `import { BuildParam } from "webiny/admin/build-params";
|
|
123
|
+
const fileContent = `import { BuildParam } from "webiny/admin/build-params";
|
|
124
124
|
|
|
125
125
|
class ${className} implements BuildParam.Interface {
|
|
126
126
|
key = "${paramName}";
|
|
@@ -132,8 +132,8 @@ export default BuildParam.createImplementation({
|
|
|
132
132
|
dependencies: []
|
|
133
133
|
});
|
|
134
134
|
`;
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf8") : void 0;
|
|
136
|
+
if (existing !== fileContent) fs.writeFileSync(filePath, fileContent, "utf8");
|
|
137
137
|
await generateBuildParamsFeature(buildParamsDir, ctx);
|
|
138
138
|
}
|
|
139
139
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/AdminBuildParam.js","sources":["../../src/extensions/AdminBuildParam.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport crypto from \"crypto\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { Node, Project } from \"ts-morph\";\n\nasync function generateBuildParamsFeature(buildParamsDir: string, ctx: any) {\n const featureFilePath = path.join(buildParamsDir, \"feature.ts\");\n\n // Get all BuildParam_*.ts files.\n const files = fs\n .readdirSync(buildParamsDir)\n .filter(f => f.startsWith(\"BuildParam_\") && f.endsWith(\".ts\") && f !== \"feature.ts\");\n\n // Generate imports and registrations.\n const imports = files\n .map(file => {\n const className = path.parse(file).name;\n return `import ${className} from \"./${className}.js\";`;\n })\n .join(\"\\n\");\n\n const registrations = files\n .map(file => {\n const className = path.parse(file).name;\n return ` container.register(${className});`;\n })\n .join(\"\\n\");\n\n const featureContent = `import { createFeature } from \"@webiny/feature/admin\";\nimport { Container } from \"@webiny/di\";\n${imports}\n\nexport const BuildParamsInternalFeature = createFeature({\n name: \"BuildParamsInternal\",\n register(container: Container) {\n${registrations}\n }\n});\n`;\n\n fs.writeFileSync(featureFilePath, featureContent, \"utf8\");\n\n // Now we need to update Extensions.tsx to use RegisterFeature with this feature.\n await updateExtensionsTsx(ctx);\n}\n\nasync function updateExtensionsTsx(ctx: any) {\n const extensionsTsxFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"src\", \"Extensions.tsx\")\n .toString();\n\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsxFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsxFilePath);\n\n // Check if we already have the imports.\n const buildParamsFeatureImport = \"./buildParams/feature.js\";\n const existingFeatureImport = source.getImportDeclaration(buildParamsFeatureImport);\n\n if (!existingFeatureImport) {\n let index = 1;\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Add import for BuildParamsInternalFeature.\n source.insertImportDeclaration(index, {\n namedImports: [\"BuildParamsInternalFeature\"],\n moduleSpecifier: buildParamsFeatureImport\n });\n\n // Add import for BuildParamsFeature.\n const buildParamsFeatureImportPath = \"@webiny/app-admin\";\n const existingBuildParamsImport = source.getImportDeclaration(buildParamsFeatureImportPath);\n\n if (!existingBuildParamsImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"BuildParamsFeature\"],\n moduleSpecifier: buildParamsFeatureImportPath\n });\n } else {\n // Add to existing import if BuildParamsFeature not already there.\n const namedImports = existingBuildParamsImport.getNamedImports();\n const hasBuildParamsFeature = namedImports.some(\n ni => ni.getName() === \"BuildParamsFeature\"\n );\n if (!hasBuildParamsFeature) {\n existingBuildParamsImport.addNamedImport(\"BuildParamsFeature\");\n }\n }\n\n // Add import for RegisterFeature if not present.\n const registerFeatureImportPath = \"@webiny/app-admin\";\n const existingRegisterFeatureImport =\n source.getImportDeclaration(registerFeatureImportPath);\n\n if (existingRegisterFeatureImport) {\n const namedImports = existingRegisterFeatureImport.getNamedImports();\n const hasRegisterFeature = namedImports.some(ni => ni.getName() === \"RegisterFeature\");\n if (!hasRegisterFeature) {\n existingRegisterFeatureImport.addNamedImport(\"RegisterFeature\");\n }\n } else {\n source.insertImportDeclaration(index, {\n namedImports: [\"RegisterFeature\"],\n moduleSpecifier: registerFeatureImportPath\n });\n }\n }\n\n // Now add <RegisterFeature> components to the Extensions component.\n const extensionsIdentifier = source.getFirstDescendant(node => {\n if (!Node.isIdentifier(node)) {\n return false;\n }\n return node.getText() === \"Extensions\";\n });\n\n if (!extensionsIdentifier) {\n throw new Error(\n `Could not find the \"Extensions\" React component in \"${extensionsTsxFilePath}\".`\n );\n }\n\n const extensionsArrowFn = extensionsIdentifier.getNextSibling(node =>\n Node.isArrowFunction(node)\n );\n\n if (!extensionsArrowFn) {\n throw new Error(`Could not find the \"Extensions\" React component arrow function.`);\n }\n\n const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant(node => {\n return Node.isJsxFragment(node);\n });\n\n if (!extensionsArrowFnFragment) {\n throw new Error(`Could not find JSX fragment in Extensions component.`);\n }\n\n const currentContent = extensionsArrowFnFragment\n .getFullText()\n .replace(\"<>\", \"\")\n .replace(\"</>\", \"\")\n .trim();\n\n // Check if we already have the RegisterFeature components.\n if (!currentContent.includes(\"BuildParamsFeature\")) {\n const newContent = `<><RegisterFeature feature={BuildParamsFeature} /><RegisterFeature feature={BuildParamsInternalFeature} />${currentContent}</>`;\n extensionsArrowFnFragment.replaceWithText(newContent);\n }\n\n await source.save();\n}\n\nexport const AdminBuildParam = defineExtension({\n type: \"Admin/BuildParam\",\n tags: { runtimeContext: \"app-build\", appName: \"admin\" },\n description: \"Add build-time parameter to Admin app.\",\n multiple: true,\n paramsSchema: () => {\n return z.object({\n paramName: z.string(),\n value: z.union([\n z.string(),\n z.record(z.string(), z.any()),\n z.array(z.any()),\n z.number(),\n z.boolean()\n ])\n });\n },\n async build(params, ctx) {\n const buildParamsDir = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"src\", \"buildParams\")\n .toString();\n\n const { paramName, value } = params;\n\n // Serialize value to a TypeScript literal.\n const valueStr = JSON.stringify(value, null, 4);\n\n // Generate a unique class name based on the paramName.\n const hash = crypto.createHash(\"sha256\").update(paramName).digest(\"hex\");\n const className = `BuildParam_${hash.slice(-10)}`;\n const fileName = `${className}.ts`;\n const filePath = path.join(buildParamsDir, fileName);\n\n // Ensure buildParams directory exists.\n if (!fs.existsSync(buildParamsDir)) {\n fs.mkdirSync(buildParamsDir, { recursive: true });\n }\n\n // Check if file already exists.\n if (!fs.existsSync(filePath)) {\n // Create the BuildParam implementation file.\n const fileContent = `import { BuildParam } from \"webiny/admin/build-params\";\n\nclass ${className} implements BuildParam.Interface {\n key = \"${paramName}\";\n value = ${valueStr};\n}\n\nexport default BuildParam.createImplementation({\n implementation: ${className},\n dependencies: []\n});\n`;\n fs.writeFileSync(filePath, fileContent, \"utf8\");\n }\n\n // Now we need to generate/update the feature file that imports all BuildParams.\n await generateBuildParamsFeature(buildParamsDir, ctx);\n }\n});\n"],"names":["generateBuildParamsFeature","buildParamsDir","ctx","featureFilePath","path","files","fs","f","imports","file","className","registrations","featureContent","updateExtensionsTsx","extensionsTsxFilePath","project","Project","source","buildParamsFeatureImport","existingFeatureImport","index","importDeclarations","last","buildParamsFeatureImportPath","existingBuildParamsImport","namedImports","hasBuildParamsFeature","ni","registerFeatureImportPath","existingRegisterFeatureImport","hasRegisterFeature","extensionsIdentifier","node","Node","Error","extensionsArrowFn","extensionsArrowFnFragment","currentContent","newContent","AdminBuildParam","defineExtension","z","params","paramName","value","valueStr","JSON","hash","crypto","fileName","filePath","fileContent"],"mappings":";;;;;;AAOA,eAAeA,2BAA2BC,cAAsB,EAAEC,GAAQ;IACtE,MAAMC,kBAAkBC,KAAK,IAAI,CAACH,gBAAgB;IAGlD,MAAMI,QAAQC,GAAAA,WACE,CAACL,gBACZ,MAAM,CAACM,CAAAA,IAAKA,EAAE,UA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,UAAU;YACX,EAAEE,SAAS;;;;oBAIH,EAAEnC,UAAU;;;AAGhC,CAAC;YACWJ,GAAG,aAAa,CAAC4C,UAAUC,aAAa;QAC5C;QAGA,MAAMnD,2BAA2BC,gBAAgBC;IACrD;AACJ"}
|
|
1
|
+
{"version":3,"file":"extensions/AdminBuildParam.js","sources":["../../src/extensions/AdminBuildParam.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport crypto from \"crypto\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { Node, Project } from \"ts-morph\";\n\nasync function generateBuildParamsFeature(buildParamsDir: string, ctx: any) {\n const featureFilePath = path.join(buildParamsDir, \"feature.ts\");\n\n // Get all BuildParam_*.ts files.\n const files = fs\n .readdirSync(buildParamsDir)\n .filter(f => f.startsWith(\"BuildParam_\") && f.endsWith(\".ts\") && f !== \"feature.ts\");\n\n // Generate imports and registrations.\n const imports = files\n .map(file => {\n const className = path.parse(file).name;\n return `import ${className} from \"./${className}.js\";`;\n })\n .join(\"\\n\");\n\n const registrations = files\n .map(file => {\n const className = path.parse(file).name;\n return ` container.register(${className});`;\n })\n .join(\"\\n\");\n\n const featureContent = `import { createFeature } from \"@webiny/feature/admin\";\nimport { Container } from \"@webiny/di\";\n${imports}\n\nexport const BuildParamsInternalFeature = createFeature({\n name: \"BuildParamsInternal\",\n register(container: Container) {\n${registrations}\n }\n});\n`;\n\n fs.writeFileSync(featureFilePath, featureContent, \"utf8\");\n\n // Now we need to update Extensions.tsx to use RegisterFeature with this feature.\n await updateExtensionsTsx(ctx);\n}\n\nasync function updateExtensionsTsx(ctx: any) {\n const extensionsTsxFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"src\", \"Extensions.tsx\")\n .toString();\n\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsxFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsxFilePath);\n\n // Check if we already have the imports.\n const buildParamsFeatureImport = \"./buildParams/feature.js\";\n const existingFeatureImport = source.getImportDeclaration(buildParamsFeatureImport);\n\n if (!existingFeatureImport) {\n let index = 1;\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Add import for BuildParamsInternalFeature.\n source.insertImportDeclaration(index, {\n namedImports: [\"BuildParamsInternalFeature\"],\n moduleSpecifier: buildParamsFeatureImport\n });\n\n // Add import for BuildParamsFeature.\n const buildParamsFeatureImportPath = \"@webiny/app-admin\";\n const existingBuildParamsImport = source.getImportDeclaration(buildParamsFeatureImportPath);\n\n if (!existingBuildParamsImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"BuildParamsFeature\"],\n moduleSpecifier: buildParamsFeatureImportPath\n });\n } else {\n // Add to existing import if BuildParamsFeature not already there.\n const namedImports = existingBuildParamsImport.getNamedImports();\n const hasBuildParamsFeature = namedImports.some(\n ni => ni.getName() === \"BuildParamsFeature\"\n );\n if (!hasBuildParamsFeature) {\n existingBuildParamsImport.addNamedImport(\"BuildParamsFeature\");\n }\n }\n\n // Add import for RegisterFeature if not present.\n const registerFeatureImportPath = \"@webiny/app-admin\";\n const existingRegisterFeatureImport =\n source.getImportDeclaration(registerFeatureImportPath);\n\n if (existingRegisterFeatureImport) {\n const namedImports = existingRegisterFeatureImport.getNamedImports();\n const hasRegisterFeature = namedImports.some(ni => ni.getName() === \"RegisterFeature\");\n if (!hasRegisterFeature) {\n existingRegisterFeatureImport.addNamedImport(\"RegisterFeature\");\n }\n } else {\n source.insertImportDeclaration(index, {\n namedImports: [\"RegisterFeature\"],\n moduleSpecifier: registerFeatureImportPath\n });\n }\n }\n\n // Now add <RegisterFeature> components to the Extensions component.\n const extensionsIdentifier = source.getFirstDescendant(node => {\n if (!Node.isIdentifier(node)) {\n return false;\n }\n return node.getText() === \"Extensions\";\n });\n\n if (!extensionsIdentifier) {\n throw new Error(\n `Could not find the \"Extensions\" React component in \"${extensionsTsxFilePath}\".`\n );\n }\n\n const extensionsArrowFn = extensionsIdentifier.getNextSibling(node =>\n Node.isArrowFunction(node)\n );\n\n if (!extensionsArrowFn) {\n throw new Error(`Could not find the \"Extensions\" React component arrow function.`);\n }\n\n const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant(node => {\n return Node.isJsxFragment(node);\n });\n\n if (!extensionsArrowFnFragment) {\n throw new Error(`Could not find JSX fragment in Extensions component.`);\n }\n\n const currentContent = extensionsArrowFnFragment\n .getFullText()\n .replace(\"<>\", \"\")\n .replace(\"</>\", \"\")\n .trim();\n\n // Check if we already have the RegisterFeature components.\n if (!currentContent.includes(\"BuildParamsFeature\")) {\n const newContent = `<><RegisterFeature feature={BuildParamsFeature} /><RegisterFeature feature={BuildParamsInternalFeature} />${currentContent}</>`;\n extensionsArrowFnFragment.replaceWithText(newContent);\n }\n\n await source.save();\n}\n\nexport const AdminBuildParam = defineExtension({\n type: \"Admin/BuildParam\",\n tags: { runtimeContext: \"app-build\", appName: \"admin\", hosting: \"all\" },\n description: \"Add build-time parameter to Admin app.\",\n multiple: true,\n paramsSchema: () => {\n return z.object({\n paramName: z.string(),\n value: z.union([\n z.string(),\n z.record(z.string(), z.any()),\n z.array(z.any()),\n z.number(),\n z.boolean()\n ])\n });\n },\n async build(params, ctx) {\n const buildParamsDir = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"src\", \"buildParams\")\n .toString();\n\n const { paramName, value } = params;\n\n // Serialize value to a TypeScript literal.\n const valueStr = JSON.stringify(value, null, 4);\n\n // Generate a unique class name based on the paramName.\n const hash = crypto.createHash(\"sha256\").update(paramName).digest(\"hex\");\n const className = `BuildParam_${hash.slice(-10)}`;\n const fileName = `${className}.ts`;\n const filePath = path.join(buildParamsDir, fileName);\n\n // Ensure buildParams directory exists.\n if (!fs.existsSync(buildParamsDir)) {\n fs.mkdirSync(buildParamsDir, { recursive: true });\n }\n\n // Written when missing or when its value changed (a config edit), and left alone when equal,\n // so an unchanged param doesn't trigger a rebuild.\n const fileContent = `import { BuildParam } from \"webiny/admin/build-params\";\n\nclass ${className} implements BuildParam.Interface {\n key = \"${paramName}\";\n value = ${valueStr};\n}\n\nexport default BuildParam.createImplementation({\n implementation: ${className},\n dependencies: []\n});\n`;\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, \"utf8\") : undefined;\n if (existing !== fileContent) {\n fs.writeFileSync(filePath, fileContent, \"utf8\");\n }\n\n // Now we need to generate/update the feature file that imports all BuildParams.\n await generateBuildParamsFeature(buildParamsDir, ctx);\n }\n});\n"],"names":["generateBuildParamsFeature","buildParamsDir","ctx","featureFilePath","path","files","fs","f","imports","file","className","registrations","featureContent","updateExtensionsTsx","extensionsTsxFilePath","project","Project","source","buildParamsFeatureImport","existingFeatureImport","index","importDeclarations","last","buildParamsFeatureImportPath","existingBuildParamsImport","namedImports","hasBuildParamsFeature","ni","registerFeatureImportPath","existingRegisterFeatureImport","hasRegisterFeature","extensionsIdentifier","node","Node","Error","extensionsArrowFn","extensionsArrowFnFragment","currentContent","newContent","AdminBuildParam","defineExtension","z","params","paramName","value","valueStr","JSON","hash","crypto","fileName","filePath","fileContent","existing","undefined"],"mappings":";;;;;;AAOA,eAAeA,2BAA2BC,cAAsB,EAAEC,GAAQ;IACtE,MAAMC,kBAAkBC,KAAK,IAAI,CAACH,gBAAgB;IAGlD,MAAMI,QAAQC,GAAAA,WACE,CAACL,gBACZ,MAAM,CAACM,CAAAA,IAAKA,EAAE,UAAU,CAAC,kBAAkBA,EAAE,QAAQ,CAAC,UAAUA,AAAM,iBAANA;IAGrE,MAAMC,UAAUH,MACX,GAAG,CAACI,CAAAA;QACD,MAAMC,YAAYN,KAAK,KAAK,CAACK,MAAM,IAAI;QACvC,OAAO,CAAC,OAAO,EAAEC,UAAU,SAAS,EAAEA,UAAU,KAAK,CAAC;IAC1D,GACC,IAAI,CAAC;IAEV,MAAMC,gBAAgBN,MACjB,GAAG,CAACI,CAAAA;QACD,MAAMC,YAAYN,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
2
|
+
export declare const AdminExtension: import("~/defineExtension/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
3
|
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
4
4
|
exportName: z.ZodOptional<z.ZodString>;
|
|
5
5
|
}, z.core.$strip>>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { defineExtension, zodSrcPath } from "
|
|
1
|
+
import { defineExtension, zodSrcPath } from "../defineExtension/index.js";
|
|
2
2
|
import { ExtensionSrcResolver } from "../index.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { Node, Project } from "ts-morph";
|
|
6
6
|
import crypto_0 from "crypto";
|
|
7
|
+
import { hasDefaultExport } from "./hasDefaultExport.js";
|
|
7
8
|
const AdminExtension = defineExtension({
|
|
8
9
|
type: "Admin/Extension",
|
|
9
10
|
tags: {
|
|
10
11
|
runtimeContext: "app-build",
|
|
11
|
-
appName: "admin"
|
|
12
|
+
appName: "admin",
|
|
13
|
+
hosting: "all"
|
|
12
14
|
},
|
|
13
15
|
description: "Extend the Admin application with custom functionality.",
|
|
14
16
|
multiple: true,
|
|
@@ -35,14 +37,13 @@ const AdminExtension = defineExtension({
|
|
|
35
37
|
const extensionProject = new Project();
|
|
36
38
|
extensionProject.addSourceFileAtPath(absoluteExtensionFilePath);
|
|
37
39
|
const extensionSource = extensionProject.getSourceFileOrThrow(absoluteExtensionFilePath);
|
|
38
|
-
const hasDefaultExport = void 0 !== extensionSource.getDefaultExportSymbol();
|
|
39
40
|
let index = 1;
|
|
40
41
|
const importDeclarations = source.getImportDeclarations();
|
|
41
42
|
if (importDeclarations.length) {
|
|
42
43
|
const last = importDeclarations[importDeclarations.length - 1];
|
|
43
44
|
index = last.getChildIndex() + 1;
|
|
44
45
|
}
|
|
45
|
-
if (hasDefaultExport) source.insertImportDeclaration(index, {
|
|
46
|
+
if (hasDefaultExport(extensionSource)) source.insertImportDeclaration(index, {
|
|
46
47
|
defaultImport: componentName,
|
|
47
48
|
moduleSpecifier: importPath
|
|
48
49
|
});
|
|
@@ -64,7 +65,7 @@ const AdminExtension = defineExtension({
|
|
|
64
65
|
if (!extensionsArrowFn) throw new Error(`Could not find the "Extensions" React component in "${extensionsTsxFilePath}". Did you maybe change its definition? It should be an arrow function.`);
|
|
65
66
|
const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant((node)=>Node.isJsxFragment(node));
|
|
66
67
|
const extensionsArrowFnFragmentChildrenText = extensionsArrowFnFragment.getFullText().replace("<>", "").replace("</>", "").trim();
|
|
67
|
-
extensionsArrowFnFragment.replaceWithText(
|
|
68
|
+
extensionsArrowFnFragment.replaceWithText(`<>${extensionsArrowFnFragmentChildrenText}<${componentName}/></>`);
|
|
68
69
|
await source.save();
|
|
69
70
|
}
|
|
70
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/AdminExtension.js","sources":["../../src/extensions/AdminExtension.ts"],"sourcesContent":["import { defineExtension
|
|
1
|
+
{"version":3,"file":"extensions/AdminExtension.js","sources":["../../src/extensions/AdminExtension.ts"],"sourcesContent":["import { defineExtension } from \"~/defineExtension/index.js\";\nimport { zodSrcPath } from \"~/defineExtension/index.js\";\nimport { ExtensionSrcResolver } from \"~/index.js\";\nimport { z } from \"zod\";\nimport path from \"path\";\nimport { type JsxFragment, Node, Project } from \"ts-morph\";\nimport crypto from \"crypto\";\nimport { hasDefaultExport } from \"./hasDefaultExport.js\";\n\nexport const AdminExtension = defineExtension({\n type: \"Admin/Extension\",\n tags: { runtimeContext: \"app-build\", appName: \"admin\", hosting: \"all\" },\n description: \"Extend the Admin application with custom functionality.\",\n multiple: true,\n paramsSchema: ({ project }) => {\n return z.object({\n src: zodSrcPath({ project }),\n exportName: z.string().optional()\n });\n },\n async build(params, ctx) {\n const extensionsTsxFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"admin\", \"src\", \"Extensions.tsx\")\n .toString();\n\n const { src: extensionFilePath } = params;\n\n // Resolve to absolute path for file operations.\n const absoluteExtensionFilePath = ExtensionSrcResolver.resolvePath(\n extensionFilePath,\n ctx.project\n );\n\n const extensionFileName = path.basename(absoluteExtensionFilePath);\n\n // Export name can be customized or defaults to the file name without extension.\n const exportName = params.exportName ?? path.parse(extensionFileName).name;\n\n // Generate a constant hash-based component name to avoid using timestamps.\n const hash = crypto.createHash(\"sha256\").update(extensionFilePath).digest(\"hex\");\n const componentName = `AdminExtension_${hash.slice(-10)}`;\n\n const project = new Project();\n\n const importPath = path\n .relative(path.dirname(extensionsTsxFilePath), absoluteExtensionFilePath)\n .replace(/\\.tsx?$/, \".js\");\n\n project.addSourceFileAtPath(extensionsTsxFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsxFilePath);\n\n const existingImportDeclaration = source.getImportDeclaration(importPath);\n if (existingImportDeclaration) {\n return;\n }\n\n // Check if the extension file has a default export or named export.\n const extensionProject = new Project();\n extensionProject.addSourceFileAtPath(absoluteExtensionFilePath);\n const extensionSource = extensionProject.getSourceFileOrThrow(absoluteExtensionFilePath);\n\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Import as default export if available, otherwise import named export.\n if (hasDefaultExport(extensionSource)) {\n source.insertImportDeclaration(index, {\n defaultImport: componentName,\n moduleSpecifier: importPath\n });\n } else {\n source.insertImportDeclaration(index, {\n namedImports: [{ name: exportName, alias: componentName }],\n moduleSpecifier: importPath\n });\n }\n\n const extensionsIdentifier = source.getFirstDescendant(node => {\n if (!Node.isIdentifier(node)) {\n return false;\n }\n\n return node.getText() === \"Extensions\";\n });\n\n if (!extensionsIdentifier) {\n throw new Error(\n `Could not find the \"Extensions\" React component in \"${extensionsTsxFilePath}\". Did you maybe change the name of the component?`\n );\n }\n\n const extensionsArrowFn = extensionsIdentifier.getNextSibling(node =>\n Node.isArrowFunction(node)\n );\n if (!extensionsArrowFn) {\n throw new Error(\n `Could not find the \"Extensions\" React component in \"${extensionsTsxFilePath}\". Did you maybe change its definition? It should be an arrow function.`\n );\n }\n\n const extensionsArrowFnFragment = extensionsArrowFn.getFirstDescendant(node => {\n return Node.isJsxFragment(node);\n }) as JsxFragment;\n\n const extensionsArrowFnFragmentChildrenText = extensionsArrowFnFragment\n .getFullText()\n .replace(\"<>\", \"\")\n .replace(\"</>\", \"\")\n .trim();\n\n /*\n * Append, so extensions mount in the order they're declared, as API extensions register (see\n * ApiExtension). A decorator mounted later wraps the earlier ones, so the last declared\n * extension's decorators are the outermost: project extensions override Webiny's defaults.\n */\n extensionsArrowFnFragment.replaceWithText(\n `<>${extensionsArrowFnFragmentChildrenText}<${componentName}/></>`\n );\n\n await source.save();\n }\n});\n"],"names":["AdminExtension","defineExtension","project","z","zodSrcPath","params","ctx","extensionsTsxFilePath","extensionFilePath","absoluteExtensionFilePath","ExtensionSrcResolver","extensionFileName","path","exportName","hash","crypto","componentName","Project","importPath","source","existingImportDeclaration","extensionProject","extensionSource","index","importDeclarations","last","hasDefaultExport","extensionsIdentifier","node","Node","Error","extensionsArrowFn","extensionsArrowFnFragment","extensionsArrowFnFragmentChildrenText"],"mappings":";;;;;;;AASO,MAAMA,iBAAiBC,gBAAgB;IAC1C,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAa,SAAS;QAAS,SAAS;IAAM;IACtE,aAAa;IACb,UAAU;IACV,cAAc,CAAC,EAAEC,OAAO,EAAE,GACfC,EAAE,MAAM,CAAC;YACZ,KAAKC,WAAW;gBAAEF;YAAQ;YAC1B,YAAYC,EAAE,MAAM,GAAG,QAAQ;QACnC;IAEJ,MAAM,OAAME,MAAM,EAAEC,GAAG;QACnB,MAAMC,wBAAwBD,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CAC1D,IAAI,CAAC,QAAQ,SAAS,OAAO,kBAC7B,QAAQ;QAEb,MAAM,EAAE,KAAKE,iBAAiB,EAAE,GAAGH;QAGnC,MAAM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AAO;QACvB;QAEA,IAAI,CAACD,sBACD,MAAM,IAAIG,MACN,CAAC,oDAAoD,EAAEvB,sBAAsB,kDAAkD,CAAC;QAIxI,MAAMwB,oBAAoBJ,qBAAqB,cAAc,CAACC,CAAAA,OAC1DC,KAAK,eAAe,CAACD;QAEzB,IAAI,CAACG,mBACD,MAAM,IAAID,MACN,CAAC,oDAAoD,EAAEvB,sBAAsB,uEAAuE,CAAC;QAI7J,MAAMyB,4BAA4BD,kBAAkB,kBAAkB,CAACH,CAAAA,OAC5DC,KAAK,aAAa,CAACD;QAG9B,MAAMK,wCAAwCD,0BACzC,WAAW,GACX,OAAO,CAAC,MAAM,IACd,OAAO,CAAC,OAAO,IACf,IAAI;QAOTA,0BAA0B,eAAe,CACrC,CAAC,EAAE,EAAEC,sCAAsC,CAAC,EAAEjB,cAAc,KAAK,CAAC;QAGtE,MAAMG,OAAO,IAAI;IACrB;AACJ"}
|
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
/**
|
|
3
3
|
* Sets a dedicated WebSocket URL for the Admin app, baked into the admin bundle as
|
|
4
4
|
* `WEBINY_ADMIN_WS_API_URL`. This is optional: when omitted, the admin derives the WebSocket URL
|
|
5
|
-
* from the API URL (same origin, http -> ws), which is what the
|
|
5
|
+
* from the API URL (same origin, http -> ws), which is what the standalone hosting type needs by
|
|
6
6
|
* default. Set it only when WebSockets are served from a different origin than the API. Because the
|
|
7
7
|
* config is evaluated at build time, the value can come from any env var the user chooses, e.g.
|
|
8
8
|
* `<Admin.WebsocketsUrl url={process.env.MY_WS_URL} />`.
|
|
@@ -5,7 +5,8 @@ import { EnvVar } from "./EnvVar.js";
|
|
|
5
5
|
const AdminWebsocketsUrl = defineExtension({
|
|
6
6
|
type: "Admin/WebsocketsUrl",
|
|
7
7
|
tags: {
|
|
8
|
-
runtimeContext: "project"
|
|
8
|
+
runtimeContext: "project",
|
|
9
|
+
hosting: "all"
|
|
9
10
|
},
|
|
10
11
|
description: "Set a dedicated WebSocket URL for the Admin app.",
|
|
11
12
|
paramsSchema: z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/AdminWebsocketsUrl.js","sources":["../../src/extensions/AdminWebsocketsUrl.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { EnvVar } from \"./EnvVar.js\";\n\n/**\n * Sets a dedicated WebSocket URL for the Admin app, baked into the admin bundle as\n * `WEBINY_ADMIN_WS_API_URL`. This is optional: when omitted, the admin derives the WebSocket URL\n * from the API URL (same origin, http -> ws), which is what the
|
|
1
|
+
{"version":3,"file":"extensions/AdminWebsocketsUrl.js","sources":["../../src/extensions/AdminWebsocketsUrl.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { EnvVar } from \"./EnvVar.js\";\n\n/**\n * Sets a dedicated WebSocket URL for the Admin app, baked into the admin bundle as\n * `WEBINY_ADMIN_WS_API_URL`. This is optional: when omitted, the admin derives the WebSocket URL\n * from the API URL (same origin, http -> ws), which is what the standalone hosting type needs by\n * default. Set it only when WebSockets are served from a different origin than the API. Because the\n * config is evaluated at build time, the value can come from any env var the user chooses, e.g.\n * `<Admin.WebsocketsUrl url={process.env.MY_WS_URL} />`.\n */\nexport const AdminWebsocketsUrl = defineExtension({\n type: \"Admin/WebsocketsUrl\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description: \"Set a dedicated WebSocket URL for the Admin app.\",\n paramsSchema: z.object({\n url: z\n .string()\n .describe(\"The WebSocket origin, e.g. wss://ws.example.com or ws://localhost:3002\")\n }),\n render: props => {\n return <EnvVar varName=\"WEBINY_ADMIN_WS_API_URL\" value={props.url} />;\n }\n});\n"],"names":["AdminWebsocketsUrl","defineExtension","z","props","EnvVar"],"mappings":";;;;AAaO,MAAMA,qBAAqBC,gBAAgB;IAC9C,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAW,SAAS;IAAM;IAClD,aAAa;IACb,cAAcC,EAAE,MAAM,CAAC;QACnB,KAAKA,EAAAA,MACM,GACN,QAAQ,CAAC;IAClB;IACA,QAAQC,CAAAA,QACG,WAAP,GAAO,oBAACC,QAAMA;YAAC,SAAQ;YAA0B,OAAOD,MAAM,GAAG;;AAEzE"}
|
|
@@ -8,7 +8,8 @@ const BuildParam = defineExtension({
|
|
|
8
8
|
type: "Api/BuildParam",
|
|
9
9
|
tags: {
|
|
10
10
|
runtimeContext: "app-build",
|
|
11
|
-
appName: "api"
|
|
11
|
+
appName: "api",
|
|
12
|
+
hosting: "all"
|
|
12
13
|
},
|
|
13
14
|
description: "Add build-time parameter to API app.",
|
|
14
15
|
multiple: true,
|
|
@@ -34,9 +35,7 @@ const BuildParam = defineExtension({
|
|
|
34
35
|
if (!fs.existsSync(buildParamsDir)) fs.mkdirSync(buildParamsDir, {
|
|
35
36
|
recursive: true
|
|
36
37
|
});
|
|
37
|
-
|
|
38
|
-
else {
|
|
39
|
-
const fileContent = `import { BuildParam } from "webiny/api/build-params";
|
|
38
|
+
const fileContent = `import { BuildParam } from "webiny/api/build-params";
|
|
40
39
|
|
|
41
40
|
class ${className} implements BuildParam.Interface {
|
|
42
41
|
key = "${paramName}";
|
|
@@ -48,8 +47,8 @@ export default BuildParam.createImplementation({
|
|
|
48
47
|
dependencies: []
|
|
49
48
|
});
|
|
50
49
|
`;
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf8") : void 0;
|
|
51
|
+
if (existing !== fileContent) fs.writeFileSync(filePath, fileContent, "utf8");
|
|
53
52
|
const project = new Project();
|
|
54
53
|
project.addSourceFileAtPath(extensionsTsFilePath);
|
|
55
54
|
const source = project.getSourceFileOrThrow(extensionsTsFilePath);
|
|
@@ -68,7 +67,7 @@ export default BuildParam.createImplementation({
|
|
|
68
67
|
moduleSpecifier: importPath
|
|
69
68
|
});
|
|
70
69
|
const pluginsArray = source.getFirstDescendant((node)=>Node.isArrayLiteralExpression(node));
|
|
71
|
-
pluginsArray.addElement(`\
|
|
70
|
+
pluginsArray.addElement(`\ncreateRegisterBuildParamPlugin(ctx => {\n\tregisterExtension(ctx.container, ${className});\n})`);
|
|
72
71
|
{
|
|
73
72
|
let index = 1;
|
|
74
73
|
const importDeclarations = source.getImportDeclarations();
|
|
@@ -77,10 +76,12 @@ export default BuildParam.createImplementation({
|
|
|
77
76
|
index = last.getChildIndex() + 1;
|
|
78
77
|
}
|
|
79
78
|
const contextPluginImportPath = "@webiny/handler/plugins/RegisterExtensionPlugin.js";
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
79
|
+
const existingImport = source.getImportDeclaration(contextPluginImportPath);
|
|
80
|
+
if (existingImport) {
|
|
81
|
+
if (!existingImport.getNamedImports().some((i)=>"createRegisterBuildParamPlugin" === i.getName())) existingImport.addNamedImport("createRegisterBuildParamPlugin");
|
|
82
|
+
} else source.insertImportDeclaration(index, {
|
|
82
83
|
namedImports: [
|
|
83
|
-
"
|
|
84
|
+
"createRegisterBuildParamPlugin"
|
|
84
85
|
],
|
|
85
86
|
moduleSpecifier: contextPluginImportPath
|
|
86
87
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/ApiBuildParam.js","sources":["../../src/extensions/ApiBuildParam.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport crypto from \"crypto\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport const BuildParam = defineExtension({\n type: \"Api/BuildParam\",\n tags: { runtimeContext: \"app-build\", appName: \"api\" },\n description: \"Add build-time parameter to API app.\",\n multiple: true,\n paramsSchema: () => {\n return z.object({\n paramName: z.string(),\n value: z.union([\n z.string(),\n z.record(z.string(), z.any()),\n z.array(z.any()),\n z.number(),\n z.boolean()\n ])\n });\n },\n async build(params, ctx) {\n const extensionsTsFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"extensions.ts\")\n .toString();\n\n const buildParamsDir = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"buildParams\")\n .toString();\n\n const { paramName, value } = params;\n\n // Serialize value to a TypeScript literal.\n const valueStr = JSON.stringify(value, null, 4);\n\n // Generate a unique class name based on the paramName.\n const hash = crypto.createHash(\"sha256\").update(paramName).digest(\"hex\");\n const className = `BuildParam_${hash.slice(-10)}`;\n const fileName = `${className}.ts`;\n const filePath = path.join(buildParamsDir, fileName);\n\n // Ensure buildParams directory exists.\n if (!fs.existsSync(buildParamsDir)) {\n fs.mkdirSync(buildParamsDir, { recursive: true });\n }\n\n //
|
|
1
|
+
{"version":3,"file":"extensions/ApiBuildParam.js","sources":["../../src/extensions/ApiBuildParam.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport crypto from \"crypto\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport const BuildParam = defineExtension({\n type: \"Api/BuildParam\",\n tags: { runtimeContext: \"app-build\", appName: \"api\", hosting: \"all\" },\n description: \"Add build-time parameter to API app.\",\n multiple: true,\n paramsSchema: () => {\n return z.object({\n paramName: z.string(),\n value: z.union([\n z.string(),\n z.record(z.string(), z.any()),\n z.array(z.any()),\n z.number(),\n z.boolean()\n ])\n });\n },\n async build(params, ctx) {\n const extensionsTsFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"extensions.ts\")\n .toString();\n\n const buildParamsDir = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"buildParams\")\n .toString();\n\n const { paramName, value } = params;\n\n // Serialize value to a TypeScript literal.\n const valueStr = JSON.stringify(value, null, 4);\n\n // Generate a unique class name based on the paramName.\n const hash = crypto.createHash(\"sha256\").update(paramName).digest(\"hex\");\n const className = `BuildParam_${hash.slice(-10)}`;\n const fileName = `${className}.ts`;\n const filePath = path.join(buildParamsDir, fileName);\n\n // Ensure buildParams directory exists.\n if (!fs.existsSync(buildParamsDir)) {\n fs.mkdirSync(buildParamsDir, { recursive: true });\n }\n\n // Written when missing or when its value changed (a config edit), and left alone when equal,\n // so an unchanged param doesn't trigger a rebuild.\n const fileContent = `import { BuildParam } from \"webiny/api/build-params\";\n\nclass ${className} implements BuildParam.Interface {\n key = \"${paramName}\";\n value = ${valueStr};\n}\n\nexport default BuildParam.createImplementation({\n implementation: ${className},\n dependencies: []\n});\n`;\n const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, \"utf8\") : undefined;\n if (existing !== fileContent) {\n fs.writeFileSync(filePath, fileContent, \"utf8\");\n }\n\n // Now update extensions.ts to import and register this BuildParam.\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsFilePath);\n\n // Calculate import path relative to extensions.ts.\n let importPath = path\n .relative(path.dirname(extensionsTsFilePath), filePath)\n .replace(/\\.tsx?$/, \".js\");\n\n // Ensure the path starts with ./\n if (!importPath.startsWith(\".\")) {\n importPath = \"./\" + importPath;\n }\n\n // Check if import already exists.\n const existingImportDeclaration = source.getImportDeclaration(importPath);\n if (existingImportDeclaration) {\n return;\n }\n\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Add import for the BuildParam implementation.\n source.insertImportDeclaration(index, {\n defaultImport: className,\n moduleSpecifier: importPath\n });\n\n // Add the registration to the plugins array.\n const pluginsArray = source.getFirstDescendant(node =>\n Node.isArrayLiteralExpression(node)\n ) as ArrayLiteralExpression;\n\n pluginsArray.addElement(\n `\\ncreateRegisterBuildParamPlugin(ctx => {\\n\\tregisterExtension(ctx.container, ${className});\\n})`\n );\n\n {\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Build params get their own plugin type so the API applies them before any feature\n // registers (features read FeatureFlags, a BuildParam, at register() time). ApiExtension\n // imports from the same path, so merge into an existing import rather than skip it.\n const contextPluginImportPath = \"@webiny/handler/plugins/RegisterExtensionPlugin.js\";\n const existingImport = source.getImportDeclaration(contextPluginImportPath);\n if (!existingImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"createRegisterBuildParamPlugin\"],\n moduleSpecifier: contextPluginImportPath\n });\n } else if (\n !existingImport\n .getNamedImports()\n .some(i => i.getName() === \"createRegisterBuildParamPlugin\")\n ) {\n existingImport.addNamedImport(\"createRegisterBuildParamPlugin\");\n }\n }\n\n await source.save();\n }\n});\n"],"names":["BuildParam","defineExtension","z","params","ctx","extensionsTsFilePath","buildParamsDir","paramName","value","valueStr","JSON","hash","crypto","className","fileName","filePath","path","fs","fileContent","existing","undefined","project","Project","source","importPath","existingImportDeclaration","index","importDeclarations","last","pluginsArray","node","Node","contextPluginImportPath","existingImport","i"],"mappings":";;;;;;AAOO,MAAMA,aAAaC,gBAAgB;IACtC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAa,SAAS;QAAO,SAAS;IAAM;IACpE,aAAa;IACb,UAAU;IACV,cAAc,IACHC,EAAE,MAAM,CAAC;YACZ,WAAWA,EAAE,MAAM;YACnB,OAAOA,EAAE,KAAK,CAAC;gBACXA,EAAE,MAAM;gBACRA,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,GAAG;gBAC1BA,EAAE,KAAK,CAACA,EAAE,GAAG;gBACbA,EAAE,MAAM;gBACRA,EAAE,OAAO;aACZ;QACL;IAEJ,MAAM,OAAMC,MAAM,EAAEC,GAAG;QACnB,MAAMC,uBAAuBD,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CACzD,IAAI,CAAC,QAAQ,OAAO,WAA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;YAC3B,MAAMC,OAAOD,kBAAkB,CAACA,mBAAmB,MAAM,GAAG,EAAE;YAC9DD,QAAQE,KAAK,aAAa,KAAK;QACnC;QAGAL,OAAO,uBAAuB,CAACG,OAAO;YAClC,eAAeb;YACf,iBAAiBW;QACrB;QAGA,MAAMK,eAAeN,OAAO,kBAAkB,CAACO,CAAAA,OAC3CC,KAAK,wBAAwB,CAACD;QAGlCD,aAAa,UAAU,CACnB,CAAC,8EAA8E,EAAEhB,UAAU,MAAM,CAAC;QAGtG;YACI,IAAIa,QAAQ;YAEZ,MAAMC,qBAAqBJ,OAAO,qBAAqB;YACvD,IAAII,mBAAmB,MAAM,EAAE;gBAC3B,MAAMC,OAAOD,kBAAkB,CAACA,mBAAmB,MAAM,GAAG,EAAE;gBAC9DD,QAAQE,KAAK,aAAa,KAAK;YACnC;YAKA,MAAMI,0BAA0B;YAChC,MAAMC,iBAAiBV,OAAO,oBAAoB,CAACS;YACnD,IAAKC,gBAKE;gBAAA,IACH,CAACA,eACI,eAAe,GACf,IAAI,CAACC,CAAAA,IAAKA,AAAgB,qCAAhBA,EAAE,OAAO,KAExBD,eAAe,cAAc,CAAC;YAClC,OAVIV,OAAO,uBAAuB,CAACG,OAAO;gBAClC,cAAc;oBAAC;iBAAiC;gBAChD,iBAAiBM;YACrB;QAQR;QAEA,MAAMT,OAAO,IAAI;IACrB;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const ApiExtension: import("~/
|
|
2
|
+
export declare const ApiExtension: import("~/defineExtension/index.js").ExtensionComponent<z.ZodObject<{
|
|
3
3
|
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
4
4
|
exportName: z.ZodOptional<z.ZodString>;
|
|
5
5
|
}, z.core.$strip>>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { defineExtension, zodSrcPath } from "
|
|
1
|
+
import { defineExtension, zodSrcPath } from "../defineExtension/index.js";
|
|
2
2
|
import { ExtensionSrcResolver } from "../index.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { Node, Project } from "ts-morph";
|
|
6
6
|
import crypto_0 from "crypto";
|
|
7
|
+
import { hasDefaultExport } from "./hasDefaultExport.js";
|
|
7
8
|
const ApiExtension = defineExtension({
|
|
8
9
|
type: "Api/Extension",
|
|
9
10
|
tags: {
|
|
10
11
|
runtimeContext: "app-build",
|
|
11
|
-
appName: "api"
|
|
12
|
+
appName: "api",
|
|
13
|
+
hosting: "all"
|
|
12
14
|
},
|
|
13
15
|
description: "Add any API extension.",
|
|
14
16
|
multiple: true,
|
|
@@ -41,8 +43,7 @@ const ApiExtension = defineExtension({
|
|
|
41
43
|
const extensionProject = new Project();
|
|
42
44
|
extensionProject.addSourceFileAtPath(absoluteExtensionFilePath);
|
|
43
45
|
const extensionSource = extensionProject.getSourceFileOrThrow(absoluteExtensionFilePath);
|
|
44
|
-
|
|
45
|
-
if (hasDefaultExport) source.insertImportDeclaration(index, {
|
|
46
|
+
if (hasDefaultExport(extensionSource)) source.insertImportDeclaration(index, {
|
|
46
47
|
defaultImport: exportNameAlias,
|
|
47
48
|
moduleSpecifier: importPath
|
|
48
49
|
});
|
|
@@ -66,7 +67,9 @@ const ApiExtension = defineExtension({
|
|
|
66
67
|
}
|
|
67
68
|
const registerExtensionPluginImportPath = "@webiny/handler/plugins/RegisterExtensionPlugin.js";
|
|
68
69
|
const existingRegisterExtensionPluginImport = source.getImportDeclaration(registerExtensionPluginImportPath);
|
|
69
|
-
if (
|
|
70
|
+
if (existingRegisterExtensionPluginImport) {
|
|
71
|
+
if (!existingRegisterExtensionPluginImport.getNamedImports().some((i)=>"createRegisterExtensionPlugin" === i.getName())) existingRegisterExtensionPluginImport.addNamedImport("createRegisterExtensionPlugin");
|
|
72
|
+
} else source.insertImportDeclaration(index, {
|
|
70
73
|
namedImports: [
|
|
71
74
|
"createRegisterExtensionPlugin"
|
|
72
75
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/ApiExtension.js","sources":["../../src/extensions/ApiExtension.ts"],"sourcesContent":["import { defineExtension
|
|
1
|
+
{"version":3,"file":"extensions/ApiExtension.js","sources":["../../src/extensions/ApiExtension.ts"],"sourcesContent":["import { defineExtension } from \"~/defineExtension/index.js\";\nimport { zodSrcPath } from \"~/defineExtension/index.js\";\nimport { ExtensionSrcResolver } from \"~/index.js\";\nimport { z } from \"zod\";\nimport path from \"path\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport crypto from \"crypto\";\nimport { hasDefaultExport } from \"./hasDefaultExport.js\";\n\nexport const ApiExtension = defineExtension({\n type: \"Api/Extension\",\n tags: { runtimeContext: \"app-build\", appName: \"api\", hosting: \"all\" },\n description: \"Add any API extension.\",\n multiple: true,\n paramsSchema: ({ project }) => {\n return z.object({\n src: zodSrcPath({ project }),\n exportName: z.string().optional()\n });\n },\n async build(params, ctx) {\n const extensionsTsFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"extensions.ts\")\n .toString();\n\n const { src: extensionFilePath } = params;\n\n // Resolve to absolute path for file operations.\n const absoluteExtensionFilePath = ExtensionSrcResolver.resolvePath(\n extensionFilePath,\n ctx.project\n );\n\n const extensionFileName = path.basename(absoluteExtensionFilePath);\n\n // Export name is always the file name without extension.\n const exportName = params.exportName ?? path.parse(extensionFileName).name;\n\n // Alias name is \"ApiExtension_\" + hash of the file path. This way we\n // avoid potential naming conflicts and keep the identifier constant.\n const hash = crypto.createHash(\"sha256\").update(extensionFilePath).digest(\"hex\");\n const exportNameAlias = `ApiExtension_${hash.slice(-10)}`;\n\n // Calculate import path relative to `extensions.ts` file.\n const importPath = path\n .relative(path.dirname(extensionsTsFilePath), absoluteExtensionFilePath)\n .replace(/\\.tsx?$/, \".js\");\n\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsFilePath);\n\n const existingImportDeclaration = source.getImportDeclaration(importPath);\n if (existingImportDeclaration) {\n return;\n }\n\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Check if the file has a default export using AST parsing.\n const extensionProject = new Project();\n extensionProject.addSourceFileAtPath(absoluteExtensionFilePath);\n const extensionSource = extensionProject.getSourceFileOrThrow(absoluteExtensionFilePath);\n\n // Support both default and named exports.\n if (hasDefaultExport(extensionSource)) {\n source.insertImportDeclaration(index, {\n defaultImport: exportNameAlias,\n moduleSpecifier: importPath\n });\n } else {\n source.insertImportDeclaration(index, {\n namedImports: [{ name: exportName, alias: exportNameAlias }],\n moduleSpecifier: importPath\n });\n }\n\n const pluginsArray = source.getFirstDescendant(node =>\n Node.isArrayLiteralExpression(node)\n ) as ArrayLiteralExpression;\n\n pluginsArray.addElement(\n `\\ncreateRegisterExtensionPlugin(ctx => {\\n\\tregisterExtension(ctx.container, ${exportNameAlias});\\n})`\n );\n\n {\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n const registerExtensionPluginImportPath =\n \"@webiny/handler/plugins/RegisterExtensionPlugin.js\";\n const existingRegisterExtensionPluginImport = source.getImportDeclaration(\n registerExtensionPluginImportPath\n );\n if (!existingRegisterExtensionPluginImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"createRegisterExtensionPlugin\"],\n moduleSpecifier: registerExtensionPluginImportPath\n });\n } else if (\n !existingRegisterExtensionPluginImport\n .getNamedImports()\n .some(i => i.getName() === \"createRegisterExtensionPlugin\")\n ) {\n // BuildParam imports `createRegisterBuildParamPlugin` from the same path.\n existingRegisterExtensionPluginImport.addNamedImport(\n \"createRegisterExtensionPlugin\"\n );\n }\n }\n\n await source.save();\n }\n});\n"],"names":["ApiExtension","defineExtension","project","z","zodSrcPath","params","ctx","extensionsTsFilePath","extensionFilePath","absoluteExtensionFilePath","ExtensionSrcResolver","extensionFileName","path","exportName","hash","crypto","exportNameAlias","importPath","Project","source","existingImportDeclaration","index","importDeclarations","last","extensionProject","extensionSource","hasDefaultExport","pluginsArray","node","Node","registerExtensionPluginImportPath","existingRegisterExtensionPluginImport","i"],"mappings":";;;;;;;AASO,MAAMA,eAAeC,gBAAgB;IACxC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAa,SAAS;QAAO,SAAS;IAAM;IACpE,aAAa;IACb,UAAU;IACV,cAAc,CAAC,EAAEC,OAAO,EAAE,GACfC,EAAE,MAAM,CAAC;YACZ,KAAKC,WAAW;gBAAEF;YAAQ;YAC1B,YAAYC,EAAE,MAAM,GAAG,QAAQ;QACnC;IAEJ,MAAM,OAAME,MAAM,EAAEC,GAAG;QACnB,MAAMC,uBAAuBD,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CACzD,IAAI,CAAC,QAAQ,OAAO,WAAW,OAAO,iBACtC,QAAQ;QAEb,MAAM,EAAE,KAAKE,iBAAiB,EAAE,GAAGH;QAGnC,MAAMI,4BAA4BC,qBAAqB,WAAW,CAC9DF,mBACAF,IAAI,OAAO;QAGf,MAAMK,oBAAoBC,KAAK,QAAQ,CAACH;QAGxC,MAAMI,aAAaR,OAAO,UAAU,IAAIO,KAAK,KAAK,CAACD,mBAAmB,IAAI;QAI1E,MAAMG,OAAOC,SAAAA,UAAiB,CAAC,UAAU,MAAM,CAACP,mBAAmB,MAAM,CAAC;QAC1E,MAAMQ,kBAAkB,CAAC,aAAa,EAAEF,KAAK,KAAK,CAAC,MAAM;QAGzD,MAAMG,aAAaL,KAAAA,QACN,CAACA,KAAK,OAAO,CAACL,uBAAuBE,2BAC7C,OAAO,CAAC,WAAW;QAExB,MAAMP,UAAU,IAAIgB;QACpBhB,QAAQ,mBAAmB,CAACK;QAE5B,MAAMY,SAASjB,QAAQ,oBAAoB,CAACK;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WR;QAEA,MAAMX,OAAO,IAAI;IACrB;AACJ"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { BuildParam } from "./ApiBuildParam.js";
|
|
4
|
+
import { AdminBuildParam } from "./AdminBuildParam.js";
|
|
5
|
+
import { defineExtension } from "../defineExtension/index.js";
|
|
6
|
+
const BugReporter = defineExtension({
|
|
7
|
+
type: "Project/BugReporter",
|
|
8
|
+
tags: {
|
|
9
|
+
runtimeContext: "project",
|
|
10
|
+
hosting: "all"
|
|
11
|
+
},
|
|
12
|
+
description: "Point the bug reporter at a GitHub repository, so the API files issues itself.",
|
|
13
|
+
paramsSchema: z.object({
|
|
14
|
+
token: z.string().optional().describe("GitHub PAT with write on BOTH issues and contents. Contents is not optional once anyone pastes a screenshot: issues have no attachment API, so images are committed to a branch. Always pass it through an env var, never a literal, since the value is serialized into the build artifact."),
|
|
15
|
+
repository: z.string().optional().describe("Target repository as `owner/name`. Filing requires this as well as a token; a token on its own leaves the reporter in compose mode."),
|
|
16
|
+
labels: z.string().optional().describe("Comma separated labels applied to every issue. Defaults to `bug`. Every issue also gets `reported-in-app`.")
|
|
17
|
+
}),
|
|
18
|
+
render: ({ token, repository, labels })=>/*#__PURE__*/ react.createElement(react.Fragment, null, token ? /*#__PURE__*/ react.createElement(BuildParam, {
|
|
19
|
+
paramName: "BUG_REPORT_GITHUB_TOKEN",
|
|
20
|
+
value: token
|
|
21
|
+
}) : null, repository ? /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(BuildParam, {
|
|
22
|
+
paramName: "BUG_REPORT_REPOSITORY",
|
|
23
|
+
value: repository
|
|
24
|
+
}), /*#__PURE__*/ react.createElement(AdminBuildParam, {
|
|
25
|
+
paramName: "BUG_REPORT_REPOSITORY",
|
|
26
|
+
value: repository
|
|
27
|
+
})) : null, labels ? /*#__PURE__*/ react.createElement(BuildParam, {
|
|
28
|
+
paramName: "BUG_REPORT_LABELS",
|
|
29
|
+
value: labels
|
|
30
|
+
}) : null)
|
|
31
|
+
});
|
|
32
|
+
export { BugReporter };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=BugReporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions/BugReporter.js","sources":["../../src/extensions/BugReporter.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { BuildParam } from \"./ApiBuildParam.js\";\nimport { AdminBuildParam } from \"./AdminBuildParam.js\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\n\n/*\n * The bug reporter is enabled in every project through DefaultExtensions, so this extension is not\n * what turns it on. Without it the reporter runs in compose mode: the API writes the report up and\n * returns a prefilled GitHub issues/new URL, which the reporter submits under their own account and\n * which needs no credentials. This is what switches it to filing the issue itself.\n *\n * Lives here rather than in @webiny/bug-reporter because that package already depends on\n * @webiny/project-extensions for `Api` and `Admin`, so having the Project namespace reach back into\n * it would close a cycle. Nothing is lost: the render only emits build params, and the API owns every\n * default, so there is one place they live rather than two that can drift.\n */\nexport const BugReporter = defineExtension({\n type: \"Project/BugReporter\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description: \"Point the bug reporter at a GitHub repository, so the API files issues itself.\",\n paramsSchema: z.object({\n token: z\n .string()\n .optional()\n .describe(\n \"GitHub PAT with write on BOTH issues and contents. Contents is not optional once anyone pastes a screenshot: issues have no attachment API, so images are committed to a branch. Always pass it through an env var, never a literal, since the value is serialized into the build artifact.\"\n ),\n repository: z\n .string()\n .optional()\n .describe(\n \"Target repository as `owner/name`. Filing requires this as well as a token; a token on its own leaves the reporter in compose mode.\"\n ),\n labels: z\n .string()\n .optional()\n .describe(\n \"Comma separated labels applied to every issue. Defaults to `bug`. Every issue also gets `reported-in-app`.\"\n )\n }),\n render: ({ token, repository, labels }) => {\n return (\n <>\n {token ? <BuildParam paramName=\"BUG_REPORT_GITHUB_TOKEN\" value={token} /> : null}\n {/*\n * The repository goes to the admin app too, so the dialog can name where a report\n * is headed before the reporter sends it. The token never does: an admin build\n * param is serialized into the browser bundle.\n */}\n {repository ? (\n <>\n <BuildParam paramName=\"BUG_REPORT_REPOSITORY\" value={repository} />\n <AdminBuildParam paramName=\"BUG_REPORT_REPOSITORY\" value={repository} />\n </>\n ) : null}\n {labels ? <BuildParam paramName=\"BUG_REPORT_LABELS\" value={labels} /> : null}\n </>\n );\n }\n});\n"],"names":["BugReporter","defineExtension","z","token","repository","labels","BuildParam","AdminBuildParam"],"mappings":";;;;;AAiBO,MAAMA,cAAcC,gBAAgB;IACvC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAW,SAAS;IAAM;IAClD,aAAa;IACb,cAAcC,EAAE,MAAM,CAAC;QACnB,OAAOA,EAAAA,MACI,GACN,QAAQ,GACR,QAAQ,CACL;QAER,YAAYA,EAAAA,MACD,GACN,QAAQ,GACR,QAAQ,CACL;QAER,QAAQA,EAAAA,MACG,GACN,QAAQ,GACR,QAAQ,CACL;IAEZ;IACA,QAAQ,CAAC,EAAEC,KAAK,EAAEC,UAAU,EAAEC,MAAM,EAAE,GAC3B,WAAP,GACI,0CACKF,QAAQ,WAARA,GAAQ,oBAACG,YAAUA;YAAC,WAAU;YAA0B,OAAOH;aAAY,MAM3EC,aAAa,WAAbA,GACG,wDACI,oBAACE,YAAUA;YAAC,WAAU;YAAwB,OAAOF;0BACrD,oBAACG,iBAAeA;YAAC,WAAU;YAAwB,OAAOH;cAE9D,MACHC,SAAS,WAATA,GAAS,oBAACC,YAAUA;YAAC,WAAU;YAAoB,OAAOD;aAAa;AAIxF"}
|
|
@@ -3,7 +3,8 @@ import { defineExtension } from "../defineExtension/index.js";
|
|
|
3
3
|
const DatabaseSetup = defineExtension({
|
|
4
4
|
type: "Project/DatabaseSetup",
|
|
5
5
|
tags: {
|
|
6
|
-
runtimeContext: "project"
|
|
6
|
+
runtimeContext: "project",
|
|
7
|
+
hosting: "all"
|
|
7
8
|
},
|
|
8
9
|
description: "Define the database setup configuration (ddb, ddb+es, or ddb+os).",
|
|
9
10
|
paramsSchema: z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/DatabaseSetup.js","sources":["../../src/extensions/DatabaseSetup.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { defineExtension } from \"../defineExtension/index.js\";\n\nexport const DatabaseSetup = defineExtension({\n type: \"Project/DatabaseSetup\",\n tags: { runtimeContext: \"project\" },\n description: \"Define the database setup configuration (ddb, ddb+es, or ddb+os).\",\n paramsSchema: z.object({\n setupName: z\n .enum([\"ddb\", \"ddb+es\", \"ddb+os\"])\n .describe(\n \"The database setup type: ddb (DynamoDB only), ddb+es (DynamoDB + ElasticSearch), or ddb+os (DynamoDB + OpenSearch)\"\n )\n })\n});\n"],"names":["DatabaseSetup","defineExtension","z"],"mappings":";;AAGO,MAAMA,gBAAgBC,gBAAgB;IACzC,MAAM;IACN,MAAM;QAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"extensions/DatabaseSetup.js","sources":["../../src/extensions/DatabaseSetup.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { defineExtension } from \"../defineExtension/index.js\";\n\nexport const DatabaseSetup = defineExtension({\n type: \"Project/DatabaseSetup\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description: \"Define the database setup configuration (ddb, ddb+es, or ddb+os).\",\n paramsSchema: z.object({\n setupName: z\n .enum([\"ddb\", \"ddb+es\", \"ddb+os\"])\n .describe(\n \"The database setup type: ddb (DynamoDB only), ddb+es (DynamoDB + ElasticSearch), or ddb+os (DynamoDB + OpenSearch)\"\n )\n })\n});\n"],"names":["DatabaseSetup","defineExtension","z"],"mappings":";;AAGO,MAAMA,gBAAgBC,gBAAgB;IACzC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAW,SAAS;IAAM;IAClD,aAAa;IACb,cAAcC,EAAE,MAAM,CAAC;QACnB,WAAWA,CAAC,CAADA,OACF,CAAC;YAAC;YAAO;YAAU;SAAS,EAChC,QAAQ,CACL;IAEZ;AACJ"}
|
package/extensions/EnvVar.js
CHANGED
|
@@ -3,7 +3,8 @@ import { defineExtension } from "../defineExtension/index.js";
|
|
|
3
3
|
const EnvVar = defineExtension({
|
|
4
4
|
type: "Project/EnvVar",
|
|
5
5
|
tags: {
|
|
6
|
-
runtimeContext: "project"
|
|
6
|
+
runtimeContext: "project",
|
|
7
|
+
hosting: "all"
|
|
7
8
|
},
|
|
8
9
|
description: "Set an environment variable in the project context.",
|
|
9
10
|
multiple: true,
|
package/extensions/EnvVar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/EnvVar.js","sources":["../../src/extensions/EnvVar.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\n\n/**\n * Define an environment variable in the project context.\n */\nexport const EnvVar = defineExtension({\n type: \"Project/EnvVar\",\n tags: { runtimeContext: \"project\" },\n description: \"Set an environment variable in the project context.\",\n multiple: true,\n paramsSchema: z.object({\n // TODO: enable using `name` instead of `varName` for better consistency.\n varName: z.string().describe(\"The environment variable name.\"),\n value: z.string().describe(\"The environment variable value.\")\n })\n});\n"],"names":["EnvVar","defineExtension","z"],"mappings":";;AAMO,MAAMA,SAASC,gBAAgB;IAClC,MAAM;IACN,MAAM;QAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"extensions/EnvVar.js","sources":["../../src/extensions/EnvVar.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\n\n/**\n * Define an environment variable in the project context.\n */\nexport const EnvVar = defineExtension({\n type: \"Project/EnvVar\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description: \"Set an environment variable in the project context.\",\n multiple: true,\n paramsSchema: z.object({\n // TODO: enable using `name` instead of `varName` for better consistency.\n varName: z.string().describe(\"The environment variable name.\"),\n value: z.string().describe(\"The environment variable value.\")\n })\n});\n"],"names":["EnvVar","defineExtension","z"],"mappings":";;AAMO,MAAMA,SAASC,gBAAgB;IAClC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAW,SAAS;IAAM;IAClD,aAAa;IACb,UAAU;IACV,cAAcC,EAAE,MAAM,CAAC;QAEnB,SAASA,EAAE,MAAM,GAAG,QAAQ,CAAC;QAC7B,OAAOA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC/B;AACJ"}
|
|
@@ -3,7 +3,8 @@ import { z } from "zod";
|
|
|
3
3
|
const ExtensionDefinitions = defineExtension({
|
|
4
4
|
type: "Project/ExtensionDefinitions",
|
|
5
5
|
tags: {
|
|
6
|
-
runtimeContext: "project"
|
|
6
|
+
runtimeContext: "project",
|
|
7
|
+
hosting: "all"
|
|
7
8
|
},
|
|
8
9
|
description: "Register additional extension definitions.",
|
|
9
10
|
multiple: true,
|