@webiny/project 6.6.0-alpha.11 → 6.6.0-alpha.13
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/components/FeatureFlag.js +9 -9
- package/components/FeatureFlag.js.map +1 -1
- package/defineExtension/createExtensionReactComponent.js.map +1 -1
- package/extensions/AdminWebsocketsUrl.d.ts +5 -3
- package/extensions/AdminWebsocketsUrl.js +1 -1
- package/extensions/AdminWebsocketsUrl.js.map +1 -1
- package/extensions/DatabaseSetup.d.ts +1 -0
- package/extensions/DatabaseSetup.js +4 -3
- package/extensions/DatabaseSetup.js.map +1 -1
- package/extensions/FeatureFlags.d.ts +1 -0
- package/extensions/FeatureFlags.js +1 -0
- package/extensions/FeatureFlags.js.map +1 -1
- package/extensions/api/BackgroundTasks.js +1 -1
- package/extensions/api/BackgroundTasks.js.map +1 -1
- package/extensions/api/Cms/ModelFieldCompression.js +1 -1
- package/extensions/api/Cms/ModelFieldCompression.js.map +1 -1
- package/extensions/api/Route/ApiRoute.js +1 -1
- package/extensions/api/Route/ApiRoute.js.map +1 -1
- package/extensions/api/Route/routePath.d.ts +2 -1
- package/extensions/api/Route/routePath.js.map +1 -1
- package/extensions/api/index.d.ts +0 -2
- package/extensions/api/index.js +0 -2
- package/extensions/index.d.ts +8 -13
- package/extensions/index.js +2 -3
- package/extensions/index.js.map +1 -1
- package/features/BuildApp/PackagesBuilder/worker.js +6 -6
- package/features/BuildApp/PackagesBuilder/worker.js.map +1 -1
- package/features/Watch/watchers/worker.js +6 -6
- package/features/Watch/watchers/worker.js.map +1 -1
- package/package.json +18 -19
- package/services/GetProjectConfigService/EnvContext.js.map +1 -1
- package/services/GetProjectConfigService/FeatureFlagsContext.js.map +1 -1
- package/services/GetProjectConfigService/ProductionEnvironmentsContext.js.map +1 -1
- package/services/GetProjectConfigService/WcpProjectLicenseContext.d.ts +1 -0
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js +2 -1
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js.map +1 -1
- package/services/InstallExtensionService/updateWebinyConfig.js +9 -23
- package/services/InstallExtensionService/updateWebinyConfig.js.map +1 -1
- package/services/SetProjectIdService/SetProjectIdService.js +2 -7
- package/services/SetProjectIdService/SetProjectIdService.js.map +1 -1
- package/utils/ensureNamedImport.d.ts +12 -0
- package/utils/ensureNamedImport.js +27 -0
- package/utils/ensureNamedImport.js.map +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/extensions/api/Mailer/Smtp.d.ts +0 -8
- package/extensions/api/Mailer/Smtp.js +0 -22
- package/extensions/api/Mailer/Smtp.js.map +0 -1
- package/extensions/api/Mailer/Smtp.test.d.ts +0 -1
- package/extensions/api/Mailer/Smtp.test.js +0 -127
- package/extensions/api/Mailer/Smtp.test.js.map +0 -1
- package/extensions/api/Mailer/SmtpParamsSchema.d.ts +0 -9
- package/extensions/api/Mailer/SmtpParamsSchema.js +0 -17
- package/extensions/api/Mailer/SmtpParamsSchema.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/project",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -13,36 +13,35 @@
|
|
|
13
13
|
"description": "An SDK for managing Webiny projects.",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
16
|
+
"@webiny/build-tools": "6.6.0-alpha.13",
|
|
17
17
|
"@webiny/di": "2.0.0",
|
|
18
|
-
"@webiny/feature-flags": "6.6.0-alpha.
|
|
19
|
-
"@webiny/global-config": "6.6.0-alpha.
|
|
20
|
-
"@webiny/react-properties": "6.6.0-alpha.
|
|
21
|
-
"@webiny/system-requirements": "6.6.0-alpha.
|
|
22
|
-
"@webiny/telemetry": "6.6.0-alpha.
|
|
23
|
-
"@webiny/wcp": "6.6.0-alpha.
|
|
18
|
+
"@webiny/feature-flags": "6.6.0-alpha.13",
|
|
19
|
+
"@webiny/global-config": "6.6.0-alpha.13",
|
|
20
|
+
"@webiny/react-properties": "6.6.0-alpha.13",
|
|
21
|
+
"@webiny/system-requirements": "6.6.0-alpha.13",
|
|
22
|
+
"@webiny/telemetry": "6.6.0-alpha.13",
|
|
23
|
+
"@webiny/wcp": "6.6.0-alpha.13",
|
|
24
24
|
"chalk": "6.0.1",
|
|
25
25
|
"chokidar": "6.0.0",
|
|
26
|
-
"ci-info": "4.
|
|
27
|
-
"debounce": "
|
|
26
|
+
"ci-info": "4.5.0",
|
|
27
|
+
"debounce": "4.0.0",
|
|
28
28
|
"deepmerge": "4.3.1",
|
|
29
|
-
"dotenv": "18.0.
|
|
30
|
-
"email-addresses": "5.0.0",
|
|
29
|
+
"dotenv": "18.0.10",
|
|
31
30
|
"exit-hook": "5.1.0",
|
|
32
31
|
"fast-glob": "3.3.3",
|
|
33
32
|
"find-up": "8.0.0",
|
|
34
33
|
"get-tsconfig": "4.14.3",
|
|
35
34
|
"graphql-request": "7.4.0",
|
|
36
|
-
"humanize-duration": "3.35.
|
|
35
|
+
"humanize-duration": "3.35.1",
|
|
37
36
|
"load-json-file": "7.0.1",
|
|
38
|
-
"mobx": "7.1.
|
|
39
|
-
"mobx-react-lite": "5.1.
|
|
37
|
+
"mobx": "7.1.7",
|
|
38
|
+
"mobx-react-lite": "5.1.3",
|
|
40
39
|
"neverthrow": "8.2.0",
|
|
41
40
|
"pino": "10.4.0",
|
|
42
41
|
"pino-pretty": "13.2.0",
|
|
43
42
|
"react": "19.3.1",
|
|
44
43
|
"react-reconciler": "0.34.0",
|
|
45
|
-
"serialize-error": "13.0
|
|
44
|
+
"serialize-error": "13.1.0",
|
|
46
45
|
"ts-morph": "28.0.0",
|
|
47
46
|
"tsx": "4.23.15",
|
|
48
47
|
"wrap-ansi": "10.0.2",
|
|
@@ -54,10 +53,10 @@
|
|
|
54
53
|
"@types/humanize-duration": "3.27.4",
|
|
55
54
|
"@types/lodash": "4.17.27",
|
|
56
55
|
"@types/react-reconciler": "0.34.1",
|
|
57
|
-
"rimraf": "6.1.
|
|
58
|
-
"type-fest": "
|
|
56
|
+
"rimraf": "6.1.4",
|
|
57
|
+
"type-fest": "6.0.3",
|
|
59
58
|
"typescript": "7.0.2",
|
|
60
|
-
"vitest": "5.
|
|
59
|
+
"vitest": "5.1.1"
|
|
61
60
|
},
|
|
62
61
|
"adio": {
|
|
63
62
|
"ignore": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/GetProjectConfigService/EnvContext.js","sources":["../../../src/services/GetProjectConfigService/EnvContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\n\nexport interface EnvContextValue {\n env: string;\n variant?: string;\n region?: string;\n}\n\nexport interface EnvProviderProps extends Partial<EnvContextValue> {\n children: React.ReactNode;\n}\n\nconst EnvContext = createContext<EnvContextValue | null>(null);\n\n/*\n * Takes the environment explicitly. It used to read it back out of `WBY_PROJECT_SDK_CONTEXT`, which\n * was the only way to get it across to the child process the config was rendered in. The render\n * happens in the caller's process now, so the values are simply passed down.\n */\nexport const EnvProvider = ({ children, env, variant, region }: EnvProviderProps) => {\n const value: EnvContextValue = {\n env: env || \"dev\",\n variant,\n region\n };\n\n return <EnvContext.Provider value={value}>{children}</EnvContext.Provider>;\n};\n\nexport const useEnv = () => {\n const context = useContext(EnvContext);\n if (!context) {\n throw new Error(\"useEnv must be used within an EnvProvider\");\n }\n return context.env;\n};\n\nexport const useVariant = () => {\n const context = useContext(EnvContext);\n if (!context) {\n throw new Error(\"useVariant must be used within an EnvProvider\");\n }\n return context.variant;\n};\n\nexport const useRegion = () => {\n const context = useContext(EnvContext);\n if (!context) {\n throw new Error(\"useRegion must be used within an EnvProvider\");\n }\n return context.region;\n};\n\nexport const useEnvContext = () => {\n const context = useContext(EnvContext);\n if (!context) {\n throw new Error(\"useEnvContext must be used within an EnvProvider\");\n }\n return context;\n};\n"],"names":["EnvContext","createContext","EnvProvider","children","env","variant","region","value","useEnv","context","useContext","Error","useVariant","useRegion","useEnvContext"],"mappings":";AAYA,MAAMA,aAAa,
|
|
1
|
+
{"version":3,"file":"services/GetProjectConfigService/EnvContext.js","sources":["../../../src/services/GetProjectConfigService/EnvContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\n\nexport interface EnvContextValue {\n env: string;\n variant?: string;\n region?: string;\n}\n\nexport interface EnvProviderProps extends Partial<EnvContextValue> {\n children: React.ReactNode;\n}\n\nconst EnvContext = createContext<EnvContextValue | null>(null);\n\n/*\n * Takes the environment explicitly. It used to read it back out of `WBY_PROJECT_SDK_CONTEXT`, which\n * was the only way to get it across to the child process the config was rendered in. The render\n * happens in the caller's process now, so the values are simply passed down.\n */\nexport const EnvProvider = ({ children, env, variant, region }: EnvProviderProps) => {\n const value: EnvContextValue = {\n env: env || \"dev\",\n variant,\n region\n };\n\n return <EnvContext.Provider value={value}>{children}</EnvContext.Provider>;\n};\n\nexport const useEnv = () => {\n const context = useContext(EnvContext);\n if (!context) {\n throw new Error(\"useEnv must be used within an EnvProvider\");\n }\n return context.env;\n};\n\nexport const useVariant = () => {\n const context = useContext(EnvContext);\n if (!context) {\n throw new Error(\"useVariant must be used within an EnvProvider\");\n }\n return context.variant;\n};\n\nexport const useRegion = () => {\n const context = useContext(EnvContext);\n if (!context) {\n throw new Error(\"useRegion must be used within an EnvProvider\");\n }\n return context.region;\n};\n\nexport const useEnvContext = () => {\n const context = useContext(EnvContext);\n if (!context) {\n throw new Error(\"useEnvContext must be used within an EnvProvider\");\n }\n return context;\n};\n"],"names":["EnvContext","createContext","EnvProvider","children","env","variant","region","value","useEnv","context","useContext","Error","useVariant","useRegion","useEnvContext"],"mappings":";AAYA,MAAMA,aAAa,WAAbA,GAAaC,cAAsC;AAOlD,MAAMC,cAAc,CAAC,EAAEC,QAAQ,EAAEC,GAAG,EAAEC,OAAO,EAAEC,MAAM,EAAoB;IAC5E,MAAMC,QAAyB;QAC3B,KAAKH,OAAO;QACZC;QACAC;IACJ;IAEA,OAAO,WAAP,GAAO,oBAACN,WAAW,QAAQ;QAAC,OAAOO;OAAQJ;AAC/C;AAEO,MAAMK,SAAS;IAClB,MAAMC,UAAUC,WAAWV;IAC3B,IAAI,CAACS,SACD,MAAM,IAAIE,MAAM;IAEpB,OAAOF,QAAQ,GAAG;AACtB;AAEO,MAAMG,aAAa;IACtB,MAAMH,UAAUC,WAAWV;IAC3B,IAAI,CAACS,SACD,MAAM,IAAIE,MAAM;IAEpB,OAAOF,QAAQ,OAAO;AAC1B;AAEO,MAAMI,YAAY;IACrB,MAAMJ,UAAUC,WAAWV;IAC3B,IAAI,CAACS,SACD,MAAM,IAAIE,MAAM;IAEpB,OAAOF,QAAQ,MAAM;AACzB;AAEO,MAAMK,gBAAgB;IACzB,MAAML,UAAUC,WAAWV;IAC3B,IAAI,CAACS,SACD,MAAM,IAAIE,MAAM;IAEpB,OAAOF;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/GetProjectConfigService/FeatureFlagsContext.js","sources":["../../../src/services/GetProjectConfigService/FeatureFlagsContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport { makeAutoObservable } from \"mobx\";\nimport { observer } from \"mobx-react-lite\";\nimport { FeatureFlags } from \"@webiny/feature-flags\";\nimport type { IFeatureFlagsDto } from \"@webiny/feature-flags\";\nimport { useWcpProjectLicense } from \"./WcpProjectLicenseContext.js\";\nimport { LicenseDecoratedFeatureFlags } from \"./LicenseDecoratedFeatureFlags.js\";\n\nclass FeatureFlagsStore {\n dto: IFeatureFlagsDto = {};\n ready = false;\n\n constructor() {\n makeAutoObservable(this);\n }\n\n set(dto: IFeatureFlagsDto) {\n this.dto = dto;\n this.ready = true;\n }\n}\n\nconst store = new FeatureFlagsStore();\n\nexport function setProjectFeatureFlags(dto: IFeatureFlagsDto) {\n store.set(dto);\n}\n\nconst FeatureFlagsContext = createContext<FeatureFlags | null>(null);\n\nexport const FeatureFlagsProvider = observer(({ children }: { children: React.ReactNode }) => {\n const license = useWcpProjectLicense();\n const flags = license.hasLicense\n ? new LicenseDecoratedFeatureFlags(store.dto, license)\n : new FeatureFlags(store.dto);\n\n return <FeatureFlagsContext.Provider value={flags}>{children}</FeatureFlagsContext.Provider>;\n});\n\nexport const FeatureFlagsGate = observer(\n ({ children, skip }: { children: React.ReactNode; skip?: boolean }) => {\n if (!store.ready && !skip) {\n return null;\n }\n\n return <>{children}</>;\n }\n);\n\nexport function useProjectFeatureFlags(): FeatureFlags {\n const context = useContext(FeatureFlagsContext);\n if (!context) {\n throw new Error(\"useProjectFeatureFlags must be used within a FeatureFlagsProvider\");\n }\n return context;\n}\n"],"names":["FeatureFlagsStore","makeAutoObservable","dto","store","setProjectFeatureFlags","FeatureFlagsContext","createContext","FeatureFlagsProvider","observer","children","license","useWcpProjectLicense","flags","LicenseDecoratedFeatureFlags","FeatureFlags","FeatureFlagsGate","skip","useProjectFeatureFlags","context","useContext","Error"],"mappings":";;;;;;AAQA,MAAMA;IAIF,aAAc;aAHd,GAAG,GAAqB,CAAC;aACzB,KAAK,GAAG;QAGJC,mBAAmB,IAAI;IAC3B;IAEA,IAAIC,GAAqB,EAAE;QACvB,IAAI,CAAC,GAAG,GAAGA;QACX,IAAI,CAAC,KAAK,GAAG;IACjB;AACJ;AAEA,MAAMC,QAAQ,IAAIH;AAEX,SAASI,uBAAuBF,GAAqB;IACxDC,MAAM,GAAG,CAACD;AACd;AAEA,MAAMG,sBAAsB,
|
|
1
|
+
{"version":3,"file":"services/GetProjectConfigService/FeatureFlagsContext.js","sources":["../../../src/services/GetProjectConfigService/FeatureFlagsContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport { makeAutoObservable } from \"mobx\";\nimport { observer } from \"mobx-react-lite\";\nimport { FeatureFlags } from \"@webiny/feature-flags\";\nimport type { IFeatureFlagsDto } from \"@webiny/feature-flags\";\nimport { useWcpProjectLicense } from \"./WcpProjectLicenseContext.js\";\nimport { LicenseDecoratedFeatureFlags } from \"./LicenseDecoratedFeatureFlags.js\";\n\nclass FeatureFlagsStore {\n dto: IFeatureFlagsDto = {};\n ready = false;\n\n constructor() {\n makeAutoObservable(this);\n }\n\n set(dto: IFeatureFlagsDto) {\n this.dto = dto;\n this.ready = true;\n }\n}\n\nconst store = new FeatureFlagsStore();\n\nexport function setProjectFeatureFlags(dto: IFeatureFlagsDto) {\n store.set(dto);\n}\n\nconst FeatureFlagsContext = createContext<FeatureFlags | null>(null);\n\nexport const FeatureFlagsProvider = observer(({ children }: { children: React.ReactNode }) => {\n const license = useWcpProjectLicense();\n const flags = license.hasLicense\n ? new LicenseDecoratedFeatureFlags(store.dto, license)\n : new FeatureFlags(store.dto);\n\n return <FeatureFlagsContext.Provider value={flags}>{children}</FeatureFlagsContext.Provider>;\n});\n\nexport const FeatureFlagsGate = observer(\n ({ children, skip }: { children: React.ReactNode; skip?: boolean }) => {\n if (!store.ready && !skip) {\n return null;\n }\n\n return <>{children}</>;\n }\n);\n\nexport function useProjectFeatureFlags(): FeatureFlags {\n const context = useContext(FeatureFlagsContext);\n if (!context) {\n throw new Error(\"useProjectFeatureFlags must be used within a FeatureFlagsProvider\");\n }\n return context;\n}\n"],"names":["FeatureFlagsStore","makeAutoObservable","dto","store","setProjectFeatureFlags","FeatureFlagsContext","createContext","FeatureFlagsProvider","observer","children","license","useWcpProjectLicense","flags","LicenseDecoratedFeatureFlags","FeatureFlags","FeatureFlagsGate","skip","useProjectFeatureFlags","context","useContext","Error"],"mappings":";;;;;;AAQA,MAAMA;IAIF,aAAc;aAHd,GAAG,GAAqB,CAAC;aACzB,KAAK,GAAG;QAGJC,mBAAmB,IAAI;IAC3B;IAEA,IAAIC,GAAqB,EAAE;QACvB,IAAI,CAAC,GAAG,GAAGA;QACX,IAAI,CAAC,KAAK,GAAG;IACjB;AACJ;AAEA,MAAMC,QAAQ,IAAIH;AAEX,SAASI,uBAAuBF,GAAqB;IACxDC,MAAM,GAAG,CAACD;AACd;AAEA,MAAMG,sBAAsB,WAAtBA,GAAsBC,cAAmC;AAExD,MAAMC,uBAAuBC,SAAS,CAAC,EAAEC,QAAQ,EAAiC;IACrF,MAAMC,UAAUC;IAChB,MAAMC,QAAQF,QAAQ,UAAU,GAC1B,IAAIG,6BAA6BV,MAAM,GAAG,EAAEO,WAC5C,IAAII,aAAaX,MAAM,GAAG;IAEhC,OAAO,WAAP,GAAO,oBAACE,oBAAoB,QAAQ;QAAC,OAAOO;OAAQH;AACxD;AAEO,MAAMM,mBAAmBP,SAC5B,CAAC,EAAEC,QAAQ,EAAEO,IAAI,EAAiD;IAC9D,IAAI,CAACb,MAAM,KAAK,IAAI,CAACa,MACjB,OAAO;IAGX,OAAO,WAAP,GAAO,0CAAGP;AACd;AAGG,SAASQ;IACZ,MAAMC,UAAUC,WAAWd;IAC3B,IAAI,CAACa,SACD,MAAM,IAAIE,MAAM;IAEpB,OAAOF;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/GetProjectConfigService/ProductionEnvironmentsContext.js","sources":["../../../src/services/GetProjectConfigService/ProductionEnvironmentsContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useState } from \"react\";\n\ninterface ProductionEnvironmentsContextValue {\n prodEnvs: string[];\n setProdEnvs: React.Dispatch<React.SetStateAction<string[]>>;\n}\n\nconst ProductionEnvironmentsContext = createContext<ProductionEnvironmentsContextValue | null>(\n null\n);\n\nexport const ProductionEnvironmentsCollector: React.FC<{ children: React.ReactNode }> = ({\n children\n}) => {\n const [prodEnvs, setProdEnvs] = useState<string[]>([]);\n return (\n <ProductionEnvironmentsContext.Provider value={{ prodEnvs, setProdEnvs }}>\n {children}\n </ProductionEnvironmentsContext.Provider>\n );\n};\n\nexport const useProductionEnvironments = (): string[] => {\n return useContext(ProductionEnvironmentsContext)?.prodEnvs ?? [];\n};\n\nexport const useRegisterProductionEnvironments = () => {\n return useContext(ProductionEnvironmentsContext)?.setProdEnvs ?? null;\n};\n"],"names":["ProductionEnvironmentsContext","createContext","ProductionEnvironmentsCollector","children","prodEnvs","setProdEnvs","useState","useProductionEnvironments","useContext","useRegisterProductionEnvironments"],"mappings":";AAOA,MAAMA,gCAAgC,
|
|
1
|
+
{"version":3,"file":"services/GetProjectConfigService/ProductionEnvironmentsContext.js","sources":["../../../src/services/GetProjectConfigService/ProductionEnvironmentsContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useState } from \"react\";\n\ninterface ProductionEnvironmentsContextValue {\n prodEnvs: string[];\n setProdEnvs: React.Dispatch<React.SetStateAction<string[]>>;\n}\n\nconst ProductionEnvironmentsContext = createContext<ProductionEnvironmentsContextValue | null>(\n null\n);\n\nexport const ProductionEnvironmentsCollector: React.FC<{ children: React.ReactNode }> = ({\n children\n}) => {\n const [prodEnvs, setProdEnvs] = useState<string[]>([]);\n return (\n <ProductionEnvironmentsContext.Provider value={{ prodEnvs, setProdEnvs }}>\n {children}\n </ProductionEnvironmentsContext.Provider>\n );\n};\n\nexport const useProductionEnvironments = (): string[] => {\n return useContext(ProductionEnvironmentsContext)?.prodEnvs ?? [];\n};\n\nexport const useRegisterProductionEnvironments = () => {\n return useContext(ProductionEnvironmentsContext)?.setProdEnvs ?? null;\n};\n"],"names":["ProductionEnvironmentsContext","createContext","ProductionEnvironmentsCollector","children","prodEnvs","setProdEnvs","useState","useProductionEnvironments","useContext","useRegisterProductionEnvironments"],"mappings":";AAOA,MAAMA,gCAAgC,WAAhCA,GAAgCC,cAClC;AAGG,MAAMC,kCAA2E,CAAC,EACrFC,QAAQ,EACX;IACG,MAAM,CAACC,UAAUC,YAAY,GAAGC,SAAmB,EAAE;IACrD,OAAO,WAAP,GACI,oBAACN,8BAA8B,QAAQ;QAAC,OAAO;YAAEI;YAAUC;QAAY;OAClEF;AAGb;AAEO,MAAMI,4BAA4B,IAC9BC,WAAWR,gCAAgC,YAAY,EAAE;AAG7D,MAAMS,oCAAoC,IACtCD,WAAWR,gCAAgC,eAAe"}
|
|
@@ -8,6 +8,7 @@ export interface WcpProjectLicenseContextValue {
|
|
|
8
8
|
canUseFileManagerThreatDetection: () => boolean;
|
|
9
9
|
canUseWorkflows: () => boolean;
|
|
10
10
|
canUseHcmsFieldPermissions: () => boolean;
|
|
11
|
+
canUseAiPowerups: () => boolean;
|
|
11
12
|
}
|
|
12
13
|
export declare const WcpProjectLicenseProvider: React.FC<{
|
|
13
14
|
children: React.ReactNode;
|
|
@@ -22,7 +22,8 @@ const WcpProjectLicenseProvider = ({ children })=>{
|
|
|
22
22
|
canUsePrivateFiles: ()=>license?.canUsePrivateFiles() ?? false,
|
|
23
23
|
canUseFileManagerThreatDetection: ()=>license?.canUseFileManagerThreatDetection() ?? false,
|
|
24
24
|
canUseWorkflows: ()=>license?.canUseWorkflows() ?? false,
|
|
25
|
-
canUseHcmsFieldPermissions: ()=>license?.canUseHcmsFieldPermissions() ?? false
|
|
25
|
+
canUseHcmsFieldPermissions: ()=>license?.canUseHcmsFieldPermissions() ?? false,
|
|
26
|
+
canUseAiPowerups: ()=>license?.canUseAiPowerups() ?? false
|
|
26
27
|
};
|
|
27
28
|
return /*#__PURE__*/ react.createElement(WcpProjectLicenseContext.Provider, {
|
|
28
29
|
value: value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/GetProjectConfigService/WcpProjectLicenseContext.js","sources":["../../../src/services/GetProjectConfigService/WcpProjectLicenseContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\";\nimport { License } from \"@webiny/wcp\";\nimport type { DecryptedWcpProjectLicense } from \"@webiny/wcp/types.js\";\n\nexport interface WcpProjectLicenseContextValue {\n hasLicense: boolean;\n canUseMultiTenancy: () => boolean;\n canUseLanguages: () => boolean;\n canUseTeams: () => boolean;\n canUsePrivateFiles: () => boolean;\n canUseFileManagerThreatDetection: () => boolean;\n canUseWorkflows: () => boolean;\n canUseHcmsFieldPermissions: () => boolean;\n}\n\nconst WcpProjectLicenseContext = createContext<WcpProjectLicenseContextValue | null>(null);\n\nexport const WcpProjectLicenseProvider: React.FC<{ children: React.ReactNode }> = ({\n children\n}) => {\n const license = useMemo(() => {\n const licenseEnv = process.env.WCP_PROJECT_LICENSE;\n if (!licenseEnv) {\n return null;\n }\n\n try {\n const licenseDto = JSON.parse(licenseEnv) as DecryptedWcpProjectLicense;\n return License.fromLicenseDto(licenseDto);\n } catch (e) {\n console.warn(\n \"Failed to parse WCP_PROJECT_LICENSE environment variable. Expected valid JSON with DecryptedWcpProjectLicense format:\",\n e\n );\n return null;\n }\n }, []);\n\n const hasLicense = !!license;\n\n const value: WcpProjectLicenseContextValue = {\n hasLicense,\n canUseMultiTenancy: () => hasLicense,\n canUseLanguages: () => license?.canUseLanguages() ?? false,\n canUseTeams: () => license?.canUseTeams() ?? false,\n canUsePrivateFiles: () => license?.canUsePrivateFiles() ?? false,\n canUseFileManagerThreatDetection: () =>\n license?.canUseFileManagerThreatDetection() ?? false,\n canUseWorkflows: () => license?.canUseWorkflows() ?? false,\n canUseHcmsFieldPermissions: () => license?.canUseHcmsFieldPermissions() ?? false\n };\n\n return (\n <WcpProjectLicenseContext.Provider value={value}>\n {children}\n </WcpProjectLicenseContext.Provider>\n );\n};\n\nexport const useWcpProjectLicense = () => {\n const context = useContext(WcpProjectLicenseContext);\n if (!context) {\n throw new Error(\"useWcpProjectLicense must be used within a WcpProjectLicenseProvider\");\n }\n return context;\n};\n"],"names":["WcpProjectLicenseContext","createContext","WcpProjectLicenseProvider","children","license","useMemo","licenseEnv","process","licenseDto","JSON","License","e","console","hasLicense","value","useWcpProjectLicense","context","useContext","Error"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"services/GetProjectConfigService/WcpProjectLicenseContext.js","sources":["../../../src/services/GetProjectConfigService/WcpProjectLicenseContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\";\nimport { License } from \"@webiny/wcp\";\nimport type { DecryptedWcpProjectLicense } from \"@webiny/wcp/types.js\";\n\nexport interface WcpProjectLicenseContextValue {\n hasLicense: boolean;\n canUseMultiTenancy: () => boolean;\n canUseLanguages: () => boolean;\n canUseTeams: () => boolean;\n canUsePrivateFiles: () => boolean;\n canUseFileManagerThreatDetection: () => boolean;\n canUseWorkflows: () => boolean;\n canUseHcmsFieldPermissions: () => boolean;\n canUseAiPowerups: () => boolean;\n}\n\nconst WcpProjectLicenseContext = createContext<WcpProjectLicenseContextValue | null>(null);\n\nexport const WcpProjectLicenseProvider: React.FC<{ children: React.ReactNode }> = ({\n children\n}) => {\n const license = useMemo(() => {\n const licenseEnv = process.env.WCP_PROJECT_LICENSE;\n if (!licenseEnv) {\n return null;\n }\n\n try {\n const licenseDto = JSON.parse(licenseEnv) as DecryptedWcpProjectLicense;\n return License.fromLicenseDto(licenseDto);\n } catch (e) {\n console.warn(\n \"Failed to parse WCP_PROJECT_LICENSE environment variable. Expected valid JSON with DecryptedWcpProjectLicense format:\",\n e\n );\n return null;\n }\n }, []);\n\n const hasLicense = !!license;\n\n const value: WcpProjectLicenseContextValue = {\n hasLicense,\n canUseMultiTenancy: () => hasLicense,\n canUseLanguages: () => license?.canUseLanguages() ?? false,\n canUseTeams: () => license?.canUseTeams() ?? false,\n canUsePrivateFiles: () => license?.canUsePrivateFiles() ?? false,\n canUseFileManagerThreatDetection: () =>\n license?.canUseFileManagerThreatDetection() ?? false,\n canUseWorkflows: () => license?.canUseWorkflows() ?? false,\n canUseHcmsFieldPermissions: () => license?.canUseHcmsFieldPermissions() ?? false,\n canUseAiPowerups: () => license?.canUseAiPowerups() ?? false\n };\n\n return (\n <WcpProjectLicenseContext.Provider value={value}>\n {children}\n </WcpProjectLicenseContext.Provider>\n );\n};\n\nexport const useWcpProjectLicense = () => {\n const context = useContext(WcpProjectLicenseContext);\n if (!context) {\n throw new Error(\"useWcpProjectLicense must be used within a WcpProjectLicenseProvider\");\n }\n return context;\n};\n"],"names":["WcpProjectLicenseContext","createContext","WcpProjectLicenseProvider","children","license","useMemo","licenseEnv","process","licenseDto","JSON","License","e","console","hasLicense","value","useWcpProjectLicense","context","useContext","Error"],"mappings":";;AAgBA,MAAMA,2BAA2B,WAA3BA,GAA2BC,cAAoD;AAE9E,MAAMC,4BAAqE,CAAC,EAC/EC,QAAQ,EACX;IACG,MAAMC,UAAUC,QAAQ;QACpB,MAAMC,aAAaC,QAAQ,GAAG,CAAC,mBAAmB;QAClD,IAAI,CAACD,YACD,OAAO;QAGX,IAAI;YACA,MAAME,aAAaC,KAAK,KAAK,CAACH;YAC9B,OAAOI,QAAQ,cAAc,CAACF;QAClC,EAAE,OAAOG,GAAG;YACRC,QAAQ,IAAI,CACR,yHACAD;YAEJ,OAAO;QACX;IACJ,GAAG,EAAE;IAEL,MAAME,aAAa,CAAC,CAACT;IAErB,MAAMU,QAAuC;QACzCD;QACA,oBAAoB,IAAMA;QAC1B,iBAAiB,IAAMT,SAAS,qBAAqB;QACrD,aAAa,IAAMA,SAAS,iBAAiB;QAC7C,oBAAoB,IAAMA,SAAS,wBAAwB;QAC3D,kCAAkC,IAC9BA,SAAS,sCAAsC;QACnD,iBAAiB,IAAMA,SAAS,qBAAqB;QACrD,4BAA4B,IAAMA,SAAS,gCAAgC;QAC3E,kBAAkB,IAAMA,SAAS,sBAAsB;IAC3D;IAEA,OAAO,WAAP,GACI,oBAACJ,yBAAyB,QAAQ;QAAC,OAAOc;OACrCX;AAGb;AAEO,MAAMY,uBAAuB;IAChC,MAAMC,UAAUC,WAAWjB;IAC3B,IAAI,CAACgB,SACD,MAAM,IAAIE,MAAM;IAEpB,OAAOF;AACX"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
+
import { Project } from "ts-morph";
|
|
3
|
+
import { ensureNamedImport } from "../../utils/ensureNamedImport.js";
|
|
2
4
|
const serializePropsToJsx = (props)=>{
|
|
3
5
|
const attributes = [];
|
|
4
6
|
for (const [key, value] of Object.entries(props)){
|
|
@@ -37,29 +39,13 @@ const updateWebinyConfig = async (params)=>{
|
|
|
37
39
|
const { projectRoot, webinyConfigTsx } = params;
|
|
38
40
|
const webinyConfigPath = `${projectRoot}/webiny.config.tsx`;
|
|
39
41
|
let content = fs.readFileSync(webinyConfigPath, "utf-8");
|
|
40
|
-
if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0)
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
...existingSpecifiers,
|
|
48
|
-
importStatement.specifier
|
|
49
|
-
].join(", ");
|
|
50
|
-
const updatedImportLine = `import { ${updatedSpecifiers} } from "${importStatement.path}";`;
|
|
51
|
-
content = content.replace(existingImportRegex, updatedImportLine);
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
const importLine = `import { ${importStatement.specifier} } from "${importStatement.path}";`;
|
|
55
|
-
const importRegex = /^import\s+.*?from\s+["'].*?["'];?\s*$/gm;
|
|
56
|
-
const matches = Array.from(content.matchAll(importRegex));
|
|
57
|
-
if (matches.length > 0) {
|
|
58
|
-
const lastImport = matches[matches.length - 1];
|
|
59
|
-
const lastImportEnd = lastImport.index + lastImport[0].length;
|
|
60
|
-
content = content.slice(0, lastImportEnd) + "\n" + importLine + content.slice(lastImportEnd);
|
|
61
|
-
} else content = importLine + "\n\n" + content;
|
|
62
|
-
}
|
|
42
|
+
if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0) {
|
|
43
|
+
const tsMorphProject = new Project({
|
|
44
|
+
useInMemoryFileSystem: true
|
|
45
|
+
});
|
|
46
|
+
const sourceFile = tsMorphProject.createSourceFile("webiny.config.tsx", content);
|
|
47
|
+
for (const importStatement of webinyConfigTsx.imports)ensureNamedImport(sourceFile, importStatement.specifier, importStatement.path);
|
|
48
|
+
content = sourceFile.getFullText();
|
|
63
49
|
}
|
|
64
50
|
if (webinyConfigTsx.component) content = addComponentToExtensions(content, webinyConfigTsx.component.name, webinyConfigTsx.component.props);
|
|
65
51
|
if (webinyConfigTsx.components && webinyConfigTsx.components.length > 0) for (const component of webinyConfigTsx.components)content = addComponentToExtensions(content, component.name, component.props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/InstallExtensionService/updateWebinyConfig.js","sources":["../../../src/services/InstallExtensionService/updateWebinyConfig.ts"],"sourcesContent":["import fs from \"fs\";\nimport { ExtensionWebinyConfigTsx } from \"./types.js\";\n\ninterface UpdateWebinyConfigParams {\n projectRoot: string;\n webinyConfigTsx: ExtensionWebinyConfigTsx;\n}\n\n/**\n * Serializes a props object to JSX attribute syntax.\n * Examples:\n * - { secretKey: \"value\" } => 'secretKey={\"value\"}'\n * - { enabled: true } => 'enabled={true}'\n * - { count: 42 } => 'count={42}'\n * - { config: { key: \"value\" } } => 'config={{\"key\":\"value\"}}'\n */\nconst serializePropsToJsx = (props: Record<string, any>): string => {\n const attributes: string[] = [];\n\n for (const [key, value] of Object.entries(props)) {\n // Skip undefined values.\n if (value === undefined) {\n continue;\n }\n\n // Determine the serialization based on value type.\n let serializedValue: string;\n\n if (typeof value === \"string\") {\n // Strings: use JSON.stringify to handle escaping, then wrap in curly braces.\n serializedValue = `{${JSON.stringify(value)}}`;\n } else if (typeof value === \"number\" || typeof value === \"boolean\") {\n // Numbers and booleans: wrap in curly braces without quotes.\n serializedValue = `{${value}}`;\n } else if (value === null) {\n // Null values.\n serializedValue = `{null}`;\n } else if (Array.isArray(value) || typeof value === \"object\") {\n // Arrays and objects: use JSON.stringify, then wrap in curly braces.\n serializedValue = `{${JSON.stringify(value)}}`;\n } else {\n // Fallback for any other types.\n serializedValue = `{${JSON.stringify(value)}}`;\n }\n\n attributes.push(`${key}=${serializedValue}`);\n }\n\n return attributes.join(\" \");\n};\n\n/**\n * Adds a component to the Extensions function in the webiny.config.tsx content.\n */\nconst addComponentToExtensions = (\n content: string,\n componentName: string,\n props?: Record<string, any>\n): string => {\n // Serialize props to JSX attributes.\n const propsString = props ? serializePropsToJsx(props) : \"\";\n\n // Generate component tag with or without props.\n const componentTag = propsString\n ? `<${componentName} ${propsString} />`\n : `<${componentName} />`;\n\n // Check if component already exists.\n if (content.includes(componentTag)) {\n return content;\n }\n\n // Find the Extensions function's return statement and add component before the final </>.\n // Strategy: Find \"export const Extensions\" block, then find the last </> and insert before it.\n const extensionsFuncRegex = /export const Extensions = \\(\\) => \\{[\\s\\S]*?\\};/;\n const extensionsFuncMatch = content.match(extensionsFuncRegex);\n\n if (!extensionsFuncMatch) {\n return content;\n }\n\n const funcContent = extensionsFuncMatch[0];\n // Find all </> in the function - the last one closes the return statement.\n const closingTags = [...funcContent.matchAll(/<\\/>/g)];\n\n if (closingTags.length === 0) {\n return content;\n }\n\n const lastClosingTag = closingTags[closingTags.length - 1];\n const lastClosingTagIndex = lastClosingTag.index!;\n\n // Find the indentation of the line containing the last </>.\n const beforeClosing = funcContent.substring(0, lastClosingTagIndex);\n const lines = beforeClosing.split(\"\\n\");\n const lastLine = lines[lines.length - 1];\n const indent = lastLine.match(/^(\\s*)/)?.[1] || \" \";\n\n // Insert the component before the last </>.\n const newFuncContent =\n funcContent.substring(0, lastClosingTagIndex) +\n `${indent}${componentTag}\\n${indent}` +\n funcContent.substring(lastClosingTagIndex);\n\n return content.replace(extensionsFuncRegex, newFuncContent);\n};\n\n/**\n * Update the webiny.config.tsx file to add extension imports and component.\n */\nexport const updateWebinyConfig = async (params: UpdateWebinyConfigParams): Promise<void> => {\n const { projectRoot, webinyConfigTsx } = params;\n\n const webinyConfigPath = `${projectRoot}/webiny.config.tsx`;\n\n // Read the current webiny.config.tsx\n let content = fs.readFileSync(webinyConfigPath, \"utf-8\");\n\n // Add imports at the top (after existing imports)\n if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0) {\n for (const importStatement of webinyConfigTsx.imports) {\n // Check if we need to add to an existing import from the same path.\n const existingImportRegex = new RegExp(\n `import\\\\s+{([^}]+)}\\\\s+from\\\\s+[\"']${importStatement.path.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}[\"'];?`,\n \"m\"\n );\n const existingImportMatch = content.match(existingImportRegex);\n\n if (existingImportMatch) {\n // Import from this path exists, check if specifier is already imported.\n const existingSpecifiers = existingImportMatch[1].split(\",\").map(s => s.trim());\n\n if (!existingSpecifiers.includes(importStatement.specifier)) {\n // Append the new specifier to the existing import.\n const updatedSpecifiers = [\n ...existingSpecifiers,\n importStatement.specifier\n ].join(\", \");\n const updatedImportLine = `import { ${updatedSpecifiers} } from \"${importStatement.path}\";`;\n content = content.replace(existingImportRegex, updatedImportLine);\n }\n } else {\n // No existing import from this path, add a new import line.\n const importLine = `import { ${importStatement.specifier} } from \"${importStatement.path}\";`;\n\n // Find the position after the last import or at the beginning.\n const importRegex = /^import\\s+.*?from\\s+[\"'].*?[\"'];?\\s*$/gm;\n const matches = Array.from(content.matchAll(importRegex));\n\n if (matches.length > 0) {\n // Add after the last import.\n const lastImport = matches[matches.length - 1];\n const lastImportEnd = lastImport.index! + lastImport[0].length;\n content =\n content.slice(0, lastImportEnd) +\n \"\\n\" +\n importLine +\n content.slice(lastImportEnd);\n } else {\n // No imports found, add at the beginning.\n content = importLine + \"\\n\\n\" + content;\n }\n }\n }\n }\n\n // Add component to the Extensions function.\n if (webinyConfigTsx.component) {\n content = addComponentToExtensions(\n content,\n webinyConfigTsx.component.name,\n webinyConfigTsx.component.props\n );\n }\n\n // Add multiple components to the Extensions function.\n if (webinyConfigTsx.components && webinyConfigTsx.components.length > 0) {\n for (const component of webinyConfigTsx.components) {\n content = addComponentToExtensions(content, component.name, component.props);\n }\n }\n\n // Write the updated content back\n fs.writeFileSync(webinyConfigPath, content, \"utf-8\");\n};\n"],"names":["serializePropsToJsx","props","attributes","key","value","Object","undefined","serializedValue","JSON","Array","addComponentToExtensions","content","componentName","propsString","componentTag","extensionsFuncRegex","extensionsFuncMatch","funcContent","closingTags","lastClosingTag","lastClosingTagIndex","beforeClosing","lines","lastLine","indent","newFuncContent","updateWebinyConfig","params","projectRoot","webinyConfigTsx","webinyConfigPath","fs","importStatement","existingImportRegex","RegExp","existingImportMatch","existingSpecifiers","s","updatedSpecifiers","updatedImportLine","importLine","importRegex","matches","lastImport","lastImportEnd","component"],"mappings":";AAgBA,MAAMA,sBAAsB,CAACC;IACzB,MAAMC,aAAuB,EAAE;IAE/B,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAO,OAAO,CAACJ,OAAQ;QAE9C,IAAIG,AAAUE,WAAVF,OACA;QAIJ,IAAIG;QAEJ,IAAI,AAAiB,YAAjB,OAAOH,OAEPG,kBAAkB,CAAC,CAAC,EAAEC,KAAK,SAAS,CAACJ,OAAO,CAAC,CAAC;aAC3C,IAAI,AAAiB,YAAjB,OAAOA,SAAsB,AAAiB,aAAjB,OAAOA,OAE3CG,kBAAkB,CAAC,CAAC,EAAEH,MAAM,CAAC,CAAC;aAC3B,IAAIA,AAAU,SAAVA,OAEPG,kBAAkB;aACXE,MAAM,OAAO,CAACL,QAErBG,kBAAkB,CAAC,CAAC,EAAEC,KAAK,SAAS,CAACJ,OAAO,CAAC,CAAC;QAMlDF,WAAW,IAAI,CAAC,GAAGC,IAAI,CAAC,EAAEI,iBAAiB;IAC/C;IAEA,OAAOL,WAAW,IAAI,CAAC;AAC3B;AAKA,MAAMQ,2BAA2B,CAC7BC,SACAC,eACAX;IAGA,MAAMY,cAAcZ,QAAQD,oBAAoBC,SAAS;IAGzD,MAAMa,eAAeD,cACf,CAAC,CAAC,EAAED,cAAc,CAAC,EAAEC,YAAY,GAAG,CAAC,GACrC,CAAC,CAAC,EAAED,cAAc,GAAG,CAAC;IAG5B,IAAID,QAAQ,QAAQ,CAACG,eACjB,OAAOH;IAKX,MAAMI,sBAAsB;IAC5B,MAAMC,sBAAsBL,QAAQ,KAAK,CAACI;IAE1C,IAAI,CAACC,qBACD,OAAOL;IAGX,MAAMM,cAAcD,mBAAmB,CAAC,EAAE;IAE1C,MAA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AAMM,oBAAoB;uBACnBF;oBACHJ,gBAAgB,SAAS;iBAC5B,CAAC,IAAI,CAAC;gBACP,MAAMO,oBAAoB,CAAC,SAAS,EAAED,kBAAkB,SAAS,EAAEN,gBAAgB,IAAI,CAAC,EAAE,CAAC;gBAC3FrB,UAAUA,QAAQ,OAAO,CAACsB,qBAAqBM;YACnD;QACJ,OAAO;YAEH,MAAMC,aAAa,CAAC,SAAS,EAAER,gBAAgB,SAAS,CAAC,SAAS,EAAEA,gBAAgB,IAAI,CAAC,EAAE,CAAC;YAG5F,MAAMS,cAAc;YACpB,MAAMC,UAAUjC,MAAM,IAAI,CAACE,QAAQ,QAAQ,CAAC8B;YAE5C,IAAIC,QAAQ,MAAM,GAAG,GAAG;gBAEpB,MAAMC,aAAaD,OAAO,CAACA,QAAQ,MAAM,GAAG,EAAE;gBAC9C,MAAME,gBAAgBD,WAAW,KAAK,GAAIA,UAAU,CAAC,EAAE,CAAC,MAAM;gBAC9DhC,UACIA,QAAQ,KAAK,CAAC,GAAGiC,iBACjB,OACAJ,aACA7B,QAAQ,KAAK,CAACiC;YACtB,OAEIjC,UAAU6B,aAAa,SAAS7B;QAExC;IACJ;IAIJ,IAAIkB,gBAAgB,SAAS,EACzBlB,UAAUD,yBACNC,SACAkB,gBAAgB,SAAS,CAAC,IAAI,EAC9BA,gBAAgB,SAAS,CAAC,KAAK;IAKvC,IAAIA,gBAAgB,UAAU,IAAIA,gBAAgB,UAAU,CAAC,MAAM,GAAG,GAClE,KAAK,MAAMgB,aAAahB,gBAAgB,UAAU,CAC9ClB,UAAUD,yBAAyBC,SAASkC,UAAU,IAAI,EAAEA,UAAU,KAAK;IAKnFd,GAAG,aAAa,CAACD,kBAAkBnB,SAAS;AAChD"}
|
|
1
|
+
{"version":3,"file":"services/InstallExtensionService/updateWebinyConfig.js","sources":["../../../src/services/InstallExtensionService/updateWebinyConfig.ts"],"sourcesContent":["import fs from \"fs\";\nimport { Project as TsMorphProject } from \"ts-morph\";\nimport { ensureNamedImport } from \"~/utils/ensureNamedImport.js\";\nimport { ExtensionWebinyConfigTsx } from \"./types.js\";\n\ninterface UpdateWebinyConfigParams {\n projectRoot: string;\n webinyConfigTsx: ExtensionWebinyConfigTsx;\n}\n\n/**\n * Serializes a props object to JSX attribute syntax.\n * Examples:\n * - { secretKey: \"value\" } => 'secretKey={\"value\"}'\n * - { enabled: true } => 'enabled={true}'\n * - { count: 42 } => 'count={42}'\n * - { config: { key: \"value\" } } => 'config={{\"key\":\"value\"}}'\n */\nconst serializePropsToJsx = (props: Record<string, any>): string => {\n const attributes: string[] = [];\n\n for (const [key, value] of Object.entries(props)) {\n // Skip undefined values.\n if (value === undefined) {\n continue;\n }\n\n // Determine the serialization based on value type.\n let serializedValue: string;\n\n if (typeof value === \"string\") {\n // Strings: use JSON.stringify to handle escaping, then wrap in curly braces.\n serializedValue = `{${JSON.stringify(value)}}`;\n } else if (typeof value === \"number\" || typeof value === \"boolean\") {\n // Numbers and booleans: wrap in curly braces without quotes.\n serializedValue = `{${value}}`;\n } else if (value === null) {\n // Null values.\n serializedValue = `{null}`;\n } else if (Array.isArray(value) || typeof value === \"object\") {\n // Arrays and objects: use JSON.stringify, then wrap in curly braces.\n serializedValue = `{${JSON.stringify(value)}}`;\n } else {\n // Fallback for any other types.\n serializedValue = `{${JSON.stringify(value)}}`;\n }\n\n attributes.push(`${key}=${serializedValue}`);\n }\n\n return attributes.join(\" \");\n};\n\n/**\n * Adds a component to the Extensions function in the webiny.config.tsx content.\n */\nconst addComponentToExtensions = (\n content: string,\n componentName: string,\n props?: Record<string, any>\n): string => {\n // Serialize props to JSX attributes.\n const propsString = props ? serializePropsToJsx(props) : \"\";\n\n // Generate component tag with or without props.\n const componentTag = propsString\n ? `<${componentName} ${propsString} />`\n : `<${componentName} />`;\n\n // Check if component already exists.\n if (content.includes(componentTag)) {\n return content;\n }\n\n // Find the Extensions function's return statement and add component before the final </>.\n // Strategy: Find \"export const Extensions\" block, then find the last </> and insert before it.\n const extensionsFuncRegex = /export const Extensions = \\(\\) => \\{[\\s\\S]*?\\};/;\n const extensionsFuncMatch = content.match(extensionsFuncRegex);\n\n if (!extensionsFuncMatch) {\n return content;\n }\n\n const funcContent = extensionsFuncMatch[0];\n // Find all </> in the function - the last one closes the return statement.\n const closingTags = [...funcContent.matchAll(/<\\/>/g)];\n\n if (closingTags.length === 0) {\n return content;\n }\n\n const lastClosingTag = closingTags[closingTags.length - 1];\n const lastClosingTagIndex = lastClosingTag.index!;\n\n // Find the indentation of the line containing the last </>.\n const beforeClosing = funcContent.substring(0, lastClosingTagIndex);\n const lines = beforeClosing.split(\"\\n\");\n const lastLine = lines[lines.length - 1];\n const indent = lastLine.match(/^(\\s*)/)?.[1] || \" \";\n\n // Insert the component before the last </>.\n const newFuncContent =\n funcContent.substring(0, lastClosingTagIndex) +\n `${indent}${componentTag}\\n${indent}` +\n funcContent.substring(lastClosingTagIndex);\n\n return content.replace(extensionsFuncRegex, newFuncContent);\n};\n\n/**\n * Update the webiny.config.tsx file to add extension imports and component.\n */\nexport const updateWebinyConfig = async (params: UpdateWebinyConfigParams): Promise<void> => {\n const { projectRoot, webinyConfigTsx } = params;\n\n const webinyConfigPath = `${projectRoot}/webiny.config.tsx`;\n\n // Read the current webiny.config.tsx\n let content = fs.readFileSync(webinyConfigPath, \"utf-8\");\n\n // Add imports, parsed rather than matched, so a commented-out import or an unusual import shape\n // is not mistaken for the one the extension needs.\n if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0) {\n const tsMorphProject = new TsMorphProject({ useInMemoryFileSystem: true });\n const sourceFile = tsMorphProject.createSourceFile(\"webiny.config.tsx\", content);\n\n for (const importStatement of webinyConfigTsx.imports) {\n ensureNamedImport(sourceFile, importStatement.specifier, importStatement.path);\n }\n\n content = sourceFile.getFullText();\n }\n\n // Add component to the Extensions function.\n if (webinyConfigTsx.component) {\n content = addComponentToExtensions(\n content,\n webinyConfigTsx.component.name,\n webinyConfigTsx.component.props\n );\n }\n\n // Add multiple components to the Extensions function.\n if (webinyConfigTsx.components && webinyConfigTsx.components.length > 0) {\n for (const component of webinyConfigTsx.components) {\n content = addComponentToExtensions(content, component.name, component.props);\n }\n }\n\n // Write the updated content back\n fs.writeFileSync(webinyConfigPath, content, \"utf-8\");\n};\n"],"names":["serializePropsToJsx","props","attributes","key","value","Object","undefined","serializedValue","JSON","Array","addComponentToExtensions","content","componentName","propsString","componentTag","extensionsFuncRegex","extensionsFuncMatch","funcContent","closingTags","lastClosingTag","lastClosingTagIndex","beforeClosing","lines","lastLine","indent","newFuncContent","updateWebinyConfig","params","projectRoot","webinyConfigTsx","webinyConfigPath","fs","tsMorphProject","TsMorphProject","sourceFile","importStatement","ensureNamedImport","component"],"mappings":";;;AAkBA,MAAMA,sBAAsB,CAACC;IACzB,MAAMC,aAAuB,EAAE;IAE/B,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAO,OAAO,CAACJ,OAAQ;QAE9C,IAAIG,AAAUE,WAAVF,OACA;QAIJ,IAAIG;QAEJ,IAAI,AAAiB,YAAjB,OAAOH,OAEPG,kBAAkB,CAAC,CAAC,EAAEC,KAAK,SAAS,CAACJ,OAAO,CAAC,CAAC;aAC3C,IAAI,AAAiB,YAAjB,OAAOA,SAAsB,AAAiB,aAAjB,OAAOA,OAE3CG,kBAAkB,CAAC,CAAC,EAAEH,MAAM,CAAC,CAAC;aAC3B,IAAIA,AAAU,SAAVA,OAEPG,kBAAkB;aACXE,MAAM,OAAO,CAACL,QAErBG,kBAAkB,CAAC,CAAC,EAAEC,KAAK,SAAS,CAACJ,OAAO,CAAC,CAAC;QAMlDF,WAAW,IAAI,CAAC,GAAGC,IAAI,CAAC,EAAEI,iBAAiB;IAC/C;IAEA,OAAOL,WAAW,IAAI,CAAC;AAC3B;AAKA,MAAMQ,2BAA2B,CAC7BC,SACAC,eACAX;IAGA,MAAMY,cAAcZ,QAAQD,oBAAoBC,SAAS;IAGzD,MAAMa,eAAeD,cACf,CAAC,CAAC,EAAED,cAA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B,OAAO,CACjDO,kBAAkBF,YAAYC,gBAAgB,SAAS,EAAEA,gBAAgB,IAAI;QAGjFxB,UAAUuB,WAAW,WAAW;IACpC;IAGA,IAAIL,gBAAgB,SAAS,EACzBlB,UAAUD,yBACNC,SACAkB,gBAAgB,SAAS,CAAC,IAAI,EAC9BA,gBAAgB,SAAS,CAAC,KAAK;IAKvC,IAAIA,gBAAgB,UAAU,IAAIA,gBAAgB,UAAU,CAAC,MAAM,GAAG,GAClE,KAAK,MAAMQ,aAAaR,gBAAgB,UAAU,CAC9ClB,UAAUD,yBAAyBC,SAAS0B,UAAU,IAAI,EAAEA,UAAU,KAAK;IAKnFN,GAAG,aAAa,CAACD,kBAAkBnB,SAAS;AAChD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createImplementation } from "@webiny/di";
|
|
2
2
|
import { GetProjectService, SetProjectIdService } from "../../abstractions/index.js";
|
|
3
3
|
import { Project, SyntaxKind } from "ts-morph";
|
|
4
|
+
import { ensureNamedImport } from "../../utils/ensureNamedImport.js";
|
|
4
5
|
class DefaultSetProjectIdService {
|
|
5
6
|
constructor(getProjectService){
|
|
6
7
|
this.getProjectService = getProjectService;
|
|
@@ -10,13 +11,7 @@ class DefaultSetProjectIdService {
|
|
|
10
11
|
const webinyConfigFileTsx = project.paths.webinyConfigFile.toString();
|
|
11
12
|
const tsMorphProject = new Project();
|
|
12
13
|
const sourceFile = tsMorphProject.addSourceFileAtPath(webinyConfigFileTsx);
|
|
13
|
-
|
|
14
|
-
if (!hasProjectImport) sourceFile.insertImportDeclaration(0, {
|
|
15
|
-
namedImports: [
|
|
16
|
-
"Project"
|
|
17
|
-
],
|
|
18
|
-
moduleSpecifier: "webiny/extensions"
|
|
19
|
-
});
|
|
14
|
+
ensureNamedImport(sourceFile, "Project", "webiny/extensions");
|
|
20
15
|
const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement);
|
|
21
16
|
const existingProjectIdEl = jsxElements.find((el)=>"Project.Id" === el.getTagNameNode().getText());
|
|
22
17
|
if (existingProjectIdEl) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/SetProjectIdService/SetProjectIdService.js","sources":["../../../src/services/SetProjectIdService/SetProjectIdService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { GetProjectService, SetProjectIdService } from \"~/abstractions/index.js\";\nimport { Project as TsMorphProject, SyntaxKind } from \"ts-morph\";\n\nclass DefaultSetProjectIdService implements SetProjectIdService.Interface {\n constructor(private getProjectService: GetProjectService.Interface) {}\n\n async execute(id: string, options: SetProjectIdService.Options = {}) {\n const project = this.getProjectService.execute();\n const webinyConfigFileTsx = project.paths.webinyConfigFile.toString();\n\n const tsMorphProject = new TsMorphProject();\n const sourceFile = tsMorphProject.addSourceFileAtPath(webinyConfigFileTsx);\n\n
|
|
1
|
+
{"version":3,"file":"services/SetProjectIdService/SetProjectIdService.js","sources":["../../../src/services/SetProjectIdService/SetProjectIdService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { GetProjectService, SetProjectIdService } from \"~/abstractions/index.js\";\nimport { Project as TsMorphProject, SyntaxKind } from \"ts-morph\";\nimport { ensureNamedImport } from \"~/utils/ensureNamedImport.js\";\n\nclass DefaultSetProjectIdService implements SetProjectIdService.Interface {\n constructor(private getProjectService: GetProjectService.Interface) {}\n\n async execute(id: string, options: SetProjectIdService.Options = {}) {\n const project = this.getProjectService.execute();\n const webinyConfigFileTsx = project.paths.webinyConfigFile.toString();\n\n const tsMorphProject = new TsMorphProject();\n const sourceFile = tsMorphProject.addSourceFileAtPath(webinyConfigFileTsx);\n\n ensureNamedImport(sourceFile, \"Project\", \"webiny/extensions\");\n\n const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement);\n\n // Check for existing <Project.Id />.\n const existingProjectIdEl = jsxElements.find(\n el => el.getTagNameNode().getText() === \"Project.Id\"\n );\n if (existingProjectIdEl) {\n if (options.force !== true) {\n throw new Error(\"Project.Id already exists in the file.\");\n }\n // Update the id attribute in-place.\n const idAttr = existingProjectIdEl\n .getAttributes()\n .find(attr => attr.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === \"id\");\n if (idAttr) {\n idAttr.replaceWithText(`id={\"${id}\"}`);\n } else {\n existingProjectIdEl.replaceWithText(`<Project.Id id={\"${id}\"} />`);\n }\n await sourceFile.save();\n return;\n }\n\n /* Determine the insertion point — after the last <Project.*> element that is a\n direct child of the outermost JSX fragment (i.e. not inside a conditional expression).\n Fall back to inserting after the opening tag of the outermost JSX fragment. */\n const fragment = sourceFile.getFirstDescendantByKind(SyntaxKind.JsxFragment);\n const projectEls = jsxElements.filter(\n el =>\n el.getTagNameNode().getText().startsWith(\"Project.\") &&\n el.getParent()?.getParent() === fragment\n );\n\n if (projectEls.length > 0) {\n const lastProjectEl = projectEls[projectEls.length - 1];\n sourceFile.insertText(\n lastProjectEl.getEnd(),\n `\\n <Project.Id id={\"${id}\"} />`\n );\n } else {\n // Fallback: insert as first child of the outermost JSX fragment.\n if (!fragment) {\n throw new Error(\n `Could not find a JSX fragment or <Project.*> element to anchor <Project.Id /> in ${webinyConfigFileTsx}`\n );\n }\n const openingFragment = fragment.getOpeningFragment();\n sourceFile.insertText(\n openingFragment.getEnd(),\n `\\n <Project.Id id={\"${id}\"} />`\n );\n }\n\n await sourceFile.save();\n }\n}\n\nexport const setProjectIdService = createImplementation({\n abstraction: SetProjectIdService,\n implementation: DefaultSetProjectIdService,\n dependencies: [GetProjectService]\n});\n"],"names":["DefaultSetProjectIdService","getProjectService","id","options","project","webinyConfigFileTsx","tsMorphProject","TsMorphProject","sourceFile","ensureNamedImport","jsxElements","SyntaxKind","existingProjectIdEl","el","Error","idAttr","attr","fragment","projectEls","lastProjectEl","openingFragment","setProjectIdService","createImplementation","SetProjectIdService","GetProjectService"],"mappings":";;;;AAKA,MAAMA;IACF,YAAoBC,iBAA8C,CAAE;aAAhDA,iBAAiB,GAAjBA;IA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AC,iFAAiF,EAAET,qBAAqB;YAGjH,MAAMe,kBAAkBH,SAAS,kBAAkB;YACnDT,WAAW,UAAU,CACjBY,gBAAgB,MAAM,IACtB,CAAC,+BAA+B,EAAElB,GAAG,KAAK,CAAC;QAEnD;QAEA,MAAMM,WAAW,IAAI;IACzB;AACJ;AAEO,MAAMa,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBvB;IAChB,cAAc;QAACwB;KAAkB;AACrC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SourceFile } from "ts-morph";
|
|
2
|
+
/**
|
|
3
|
+
* Makes sure `name` is imported from `moduleSpecifier` in the given file, as a value under its own
|
|
4
|
+
* name, so it can be used in JSX.
|
|
5
|
+
*
|
|
6
|
+
* Checks every import from the module, not only the first: a file can import from one module on
|
|
7
|
+
* several lines, and adding the name to one line when another already has it declares it twice.
|
|
8
|
+
* If the name is imported only as a type, that import becomes a value import, since a second,
|
|
9
|
+
* value import of the same name is also a duplicate. Otherwise a missing name goes into the first
|
|
10
|
+
* import from the module that takes named imports, or onto a new import line after the last one.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ensureNamedImport: (sourceFile: SourceFile, name: string, moduleSpecifier: string) => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const ensureNamedImport = (sourceFile, name, moduleSpecifier)=>{
|
|
2
|
+
const moduleDeclarations = sourceFile.getImportDeclarations().filter((declaration)=>declaration.getModuleSpecifierValue() === moduleSpecifier);
|
|
3
|
+
const declarations = moduleDeclarations.filter((declaration)=>!declaration.isTypeOnly());
|
|
4
|
+
const isImported = declarations.some((declaration)=>declaration.getNamedImports().some((namedImport)=>namedImport.getName() === name && !namedImport.getAliasNode() && !namedImport.isTypeOnly()));
|
|
5
|
+
if (isImported) return;
|
|
6
|
+
for (const declaration of moduleDeclarations){
|
|
7
|
+
const typeOnlyImport = declaration.getNamedImports().find((namedImport)=>namedImport.getName() === name && !namedImport.getAliasNode());
|
|
8
|
+
if (!typeOnlyImport) continue;
|
|
9
|
+
if (typeOnlyImport.isTypeOnly()) return void typeOnlyImport.setIsTypeOnly(false);
|
|
10
|
+
const isOnlyName = 1 === declaration.getNamedImports().length && !declaration.getDefaultImport();
|
|
11
|
+
if (isOnlyName) return void declaration.setIsTypeOnly(false);
|
|
12
|
+
typeOnlyImport.remove();
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
const target = declarations.find((declaration)=>!declaration.getNamespaceImport());
|
|
16
|
+
if (target) return void target.addNamedImport(name);
|
|
17
|
+
const index = sourceFile.getImportDeclarations().length;
|
|
18
|
+
sourceFile.insertImportDeclaration(index, {
|
|
19
|
+
namedImports: [
|
|
20
|
+
name
|
|
21
|
+
],
|
|
22
|
+
moduleSpecifier
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export { ensureNamedImport };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=ensureNamedImport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/ensureNamedImport.js","sources":["../../src/utils/ensureNamedImport.ts"],"sourcesContent":["import type { SourceFile } from \"ts-morph\";\n\n/**\n * Makes sure `name` is imported from `moduleSpecifier` in the given file, as a value under its own\n * name, so it can be used in JSX.\n *\n * Checks every import from the module, not only the first: a file can import from one module on\n * several lines, and adding the name to one line when another already has it declares it twice.\n * If the name is imported only as a type, that import becomes a value import, since a second,\n * value import of the same name is also a duplicate. Otherwise a missing name goes into the first\n * import from the module that takes named imports, or onto a new import line after the last one.\n */\nexport const ensureNamedImport = (\n sourceFile: SourceFile,\n name: string,\n moduleSpecifier: string\n) => {\n const moduleDeclarations = sourceFile\n .getImportDeclarations()\n .filter(declaration => declaration.getModuleSpecifierValue() === moduleSpecifier);\n const declarations = moduleDeclarations.filter(declaration => !declaration.isTypeOnly());\n\n const isImported = declarations.some(declaration => {\n return declaration.getNamedImports().some(namedImport => {\n return (\n namedImport.getName() === name &&\n !namedImport.getAliasNode() &&\n !namedImport.isTypeOnly()\n );\n });\n });\n\n if (isImported) {\n return;\n }\n\n for (const declaration of moduleDeclarations) {\n const typeOnlyImport = declaration.getNamedImports().find(namedImport => {\n return namedImport.getName() === name && !namedImport.getAliasNode();\n });\n if (!typeOnlyImport) {\n continue;\n }\n\n // `import { Infra, type Api }`: drop the `type` on the name.\n if (typeOnlyImport.isTypeOnly()) {\n typeOnlyImport.setIsTypeOnly(false);\n return;\n }\n\n // `import type { Api }`: the name is all it imports, so drop the `type` on the line.\n const isOnlyName =\n declaration.getNamedImports().length === 1 && !declaration.getDefaultImport();\n if (isOnlyName) {\n declaration.setIsTypeOnly(false);\n return;\n }\n\n // `import type { Api, Admin }`: take the name out and add it as a value below.\n typeOnlyImport.remove();\n break;\n }\n\n const target = declarations.find(declaration => !declaration.getNamespaceImport());\n if (target) {\n target.addNamedImport(name);\n return;\n }\n\n const index = sourceFile.getImportDeclarations().length;\n sourceFile.insertImportDeclaration(index, {\n namedImports: [name],\n moduleSpecifier\n });\n};\n"],"names":["ensureNamedImport","sourceFile","name","moduleSpecifier","moduleDeclarations","declaration","declarations","isImported","namedImport","typeOnlyImport","isOnlyName","target","index"],"mappings":"AAYO,MAAMA,oBAAoB,CAC7BC,YACAC,MACAC;IAEA,MAAMC,qBAAqBH,WACtB,qBAAqB,GACrB,MAAM,CAACI,CAAAA,cAAeA,YAAY,uBAAuB,OAAOF;IACrE,MAAMG,eAAeF,mBAAmB,MAAM,CAACC,CAAAA,cAAe,CAACA,YAAY,UAAU;IAErF,MAAME,aAAaD,aAAa,IAAI,CAACD,CAAAA,cAC1BA,YAAY,eAAe,GAAG,IAAI,CAACG,CAAAA,cAElCA,YAAY,OAAO,OAAON,QAC1B,CAACM,YAAY,YAAY,MACzB,CAACA,YAAY,UAAU;IAKnC,IAAID,YACA;IAGJ,KAAK,MAAMF,eAAeD,mBAAoB;QAC1C,MAAMK,iBAAiBJ,YAAY,eAAe,GAAG,IAAI,CAACG,CAAAA,cAC/CA,YAAY,OAAO,OAAON,QAAQ,CAACM,YAAY,YAAY;QAEtE,IAAI,CAACC,gBACD;QAIJ,IAAIA,eAAe,UAAU,IAAI,YAC7BA,eAAe,aAAa,CAAC;QAKjC,MAAMC,aACFL,AAAyC,MAAzCA,YAAY,eAAe,GAAG,MAAM,IAAU,CAACA,YAAY,gBAAgB;QAC/E,IAAIK,YAAY,YACZL,YAAY,aAAa,CAAC;QAK9BI,eAAe,MAAM;QACrB;IACJ;IAEA,MAAME,SAASL,aAAa,IAAI,CAACD,CAAAA,cAAe,CAACA,YAAY,kBAAkB;IAC/E,IAAIM,QAAQ,YACRA,OAAO,cAAc,CAACT;IAI1B,MAAMU,QAAQX,WAAW,qBAAqB,GAAG,MAAM;IACvDA,WAAW,uBAAuB,CAACW,OAAO;QACtC,cAAc;YAACV;SAAK;QACpBC;IACJ;AACJ"}
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const Smtp: import("~/defineExtension/index.js").ExtensionComponent<import("zod").ZodObject<{
|
|
2
|
-
host: import("zod").ZodString;
|
|
3
|
-
port: import("zod").ZodNumber;
|
|
4
|
-
user: import("zod").ZodString;
|
|
5
|
-
password: import("zod").ZodString;
|
|
6
|
-
from: import("zod").ZodString;
|
|
7
|
-
replyTo: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
-
}, import("zod/v4/core").$strip>>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import { defineExtension } from "../../../defineExtension/index.js";
|
|
3
|
-
import { BuildParam } from "../../ApiBuildParam.js";
|
|
4
|
-
import { SmtpParamsSchema } from "./SmtpParamsSchema.js";
|
|
5
|
-
const Smtp = defineExtension({
|
|
6
|
-
type: "Api/Mailer/Smtp",
|
|
7
|
-
tags: {
|
|
8
|
-
runtimeContext: "project",
|
|
9
|
-
hosting: "all"
|
|
10
|
-
},
|
|
11
|
-
description: "Configure mailer SMTP transport settings via code. Always pass the password through a build-time env var, e.g. `password={process.env.SMTP_PASSWORD!}` — the value is serialized into the build artifact, so hard-coding it would commit the secret to source control.",
|
|
12
|
-
paramsSchema: SmtpParamsSchema,
|
|
13
|
-
render (params) {
|
|
14
|
-
return /*#__PURE__*/ react.createElement(BuildParam, {
|
|
15
|
-
paramName: "Mailer.SmtpSettings",
|
|
16
|
-
value: params
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
export { Smtp };
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=Smtp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/api/Mailer/Smtp.js","sources":["../../../../src/extensions/api/Mailer/Smtp.tsx"],"sourcesContent":["import React from \"react\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { BuildParam } from \"~/extensions/ApiBuildParam.js\";\nimport { SmtpParamsSchema } from \"./SmtpParamsSchema.js\";\n\nexport const Smtp = defineExtension({\n type: \"Api/Mailer/Smtp\",\n tags: { runtimeContext: \"project\", hosting: \"all\" },\n description:\n \"Configure mailer SMTP transport settings via code. Always pass the password through a build-time env var, e.g. `password={process.env.SMTP_PASSWORD!}` — the value is serialized into the build artifact, so hard-coding it would commit the secret to source control.\",\n paramsSchema: SmtpParamsSchema,\n render(params) {\n return <BuildParam paramName=\"Mailer.SmtpSettings\" value={params} />;\n }\n});\n"],"names":["Smtp","defineExtension","SmtpParamsSchema","params","BuildParam"],"mappings":";;;;AAKO,MAAMA,OAAOC,gBAAgB;IAChC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAW,SAAS;IAAM;IAClD,aACI;IACJ,cAAcC;IACd,QAAOC,MAAM;QACT,OAAO,WAAP,GAAO,oBAACC,YAAUA;YAAC,WAAU;YAAsB,OAAOD;;IAC9D;AACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { SmtpParamsSchema } from "./SmtpParamsSchema.js";
|
|
3
|
-
const validParams = {
|
|
4
|
-
host: "smtp.example.com",
|
|
5
|
-
port: 587,
|
|
6
|
-
user: "smtp-user",
|
|
7
|
-
password: "secret",
|
|
8
|
-
from: "Webiny <test@webiny.com>",
|
|
9
|
-
replyTo: "No-reply <no-reply@webiny.com>"
|
|
10
|
-
};
|
|
11
|
-
describe("Smtp paramsSchema", ()=>{
|
|
12
|
-
describe("valid inputs", ()=>{
|
|
13
|
-
it("accepts a complete valid config", async ()=>{
|
|
14
|
-
const result = await SmtpParamsSchema.safeParseAsync(validParams);
|
|
15
|
-
expect(result.success).toBe(true);
|
|
16
|
-
});
|
|
17
|
-
it("accepts config without replyTo (it is optional)", async ()=>{
|
|
18
|
-
const { replyTo: _, ...params } = validParams;
|
|
19
|
-
const result = await SmtpParamsSchema.safeParseAsync(params);
|
|
20
|
-
expect(result.success).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
it("accepts bare addr-spec for from and replyTo", async ()=>{
|
|
23
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
24
|
-
...validParams,
|
|
25
|
-
from: "test@webiny.com",
|
|
26
|
-
replyTo: "no-reply@webiny.com"
|
|
27
|
-
});
|
|
28
|
-
expect(result.success).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe("react-properties serialization bug", ()=>{
|
|
32
|
-
it("password={} reproduces the 'expected string, received object' error", async ()=>{
|
|
33
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
34
|
-
...validParams,
|
|
35
|
-
password: {}
|
|
36
|
-
});
|
|
37
|
-
expect(result.success).toBe(false);
|
|
38
|
-
const issue = result.error?.issues[0];
|
|
39
|
-
expect(issue?.code).toBe("invalid_type");
|
|
40
|
-
expect(issue?.path).toEqual([
|
|
41
|
-
"password"
|
|
42
|
-
]);
|
|
43
|
-
expect(issue?.message).toBe("Invalid input: expected string, received object");
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe("required string fields", ()=>{
|
|
47
|
-
it("rejects missing host", async ()=>{
|
|
48
|
-
const { host: _, ...params } = validParams;
|
|
49
|
-
const result = await SmtpParamsSchema.safeParseAsync(params);
|
|
50
|
-
expect(result.success).toBe(false);
|
|
51
|
-
});
|
|
52
|
-
it("rejects empty host", async ()=>{
|
|
53
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
54
|
-
...validParams,
|
|
55
|
-
host: ""
|
|
56
|
-
});
|
|
57
|
-
expect(result.success).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
it("rejects missing user", async ()=>{
|
|
60
|
-
const { user: _, ...params } = validParams;
|
|
61
|
-
const result = await SmtpParamsSchema.safeParseAsync(params);
|
|
62
|
-
expect(result.success).toBe(false);
|
|
63
|
-
});
|
|
64
|
-
it("rejects empty user", async ()=>{
|
|
65
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
66
|
-
...validParams,
|
|
67
|
-
user: ""
|
|
68
|
-
});
|
|
69
|
-
expect(result.success).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
it("rejects missing password", async ()=>{
|
|
72
|
-
const { password: _, ...params } = validParams;
|
|
73
|
-
const result = await SmtpParamsSchema.safeParseAsync(params);
|
|
74
|
-
expect(result.success).toBe(false);
|
|
75
|
-
});
|
|
76
|
-
it("rejects empty password", async ()=>{
|
|
77
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
78
|
-
...validParams,
|
|
79
|
-
password: ""
|
|
80
|
-
});
|
|
81
|
-
expect(result.success).toBe(false);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe("port validation", ()=>{
|
|
85
|
-
it("rejects port 0", async ()=>{
|
|
86
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
87
|
-
...validParams,
|
|
88
|
-
port: 0
|
|
89
|
-
});
|
|
90
|
-
expect(result.success).toBe(false);
|
|
91
|
-
});
|
|
92
|
-
it("rejects negative port", async ()=>{
|
|
93
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
94
|
-
...validParams,
|
|
95
|
-
port: -1
|
|
96
|
-
});
|
|
97
|
-
expect(result.success).toBe(false);
|
|
98
|
-
});
|
|
99
|
-
it("rejects fractional port", async ()=>{
|
|
100
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
101
|
-
...validParams,
|
|
102
|
-
port: 587.5
|
|
103
|
-
});
|
|
104
|
-
expect(result.success).toBe(false);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
describe("email address validation", ()=>{
|
|
108
|
-
it("rejects invalid from address", async ()=>{
|
|
109
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
110
|
-
...validParams,
|
|
111
|
-
from: "not-an-email"
|
|
112
|
-
});
|
|
113
|
-
expect(result.success).toBe(false);
|
|
114
|
-
expect(result.error?.issues[0].message).toBe("Invalid email address.");
|
|
115
|
-
});
|
|
116
|
-
it("rejects invalid replyTo address", async ()=>{
|
|
117
|
-
const result = await SmtpParamsSchema.safeParseAsync({
|
|
118
|
-
...validParams,
|
|
119
|
-
replyTo: "not-an-email"
|
|
120
|
-
});
|
|
121
|
-
expect(result.success).toBe(false);
|
|
122
|
-
expect(result.error?.issues[0].message).toBe("Invalid email address.");
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
//# sourceMappingURL=Smtp.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/api/Mailer/Smtp.test.js","sources":["../../../../src/extensions/api/Mailer/Smtp.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { SmtpParamsSchema as schema } from \"./SmtpParamsSchema.js\";\n\nconst validParams = {\n host: \"smtp.example.com\",\n port: 587,\n user: \"smtp-user\",\n password: \"secret\",\n from: \"Webiny <test@webiny.com>\",\n replyTo: \"No-reply <no-reply@webiny.com>\"\n};\n\ndescribe(\"Smtp paramsSchema\", () => {\n describe(\"valid inputs\", () => {\n it(\"accepts a complete valid config\", async () => {\n const result = await schema.safeParseAsync(validParams);\n expect(result.success).toBe(true);\n });\n\n it(\"accepts config without replyTo (it is optional)\", async () => {\n const { replyTo: _, ...params } = validParams;\n const result = await schema.safeParseAsync(params);\n expect(result.success).toBe(true);\n });\n\n it(\"accepts bare addr-spec for from and replyTo\", async () => {\n const result = await schema.safeParseAsync({\n ...validParams,\n from: \"test@webiny.com\",\n replyTo: \"no-reply@webiny.com\"\n });\n expect(result.success).toBe(true);\n });\n });\n\n describe(\"react-properties serialization bug\", () => {\n // When process.env.SMTP_PASSWORD is undefined at build time,\n // react-properties' buildRoots treats value===undefined as \"no value, build from\n // children\". The password Property has no children, so buildRoots returns {}.\n // Zod then validates {} against z.string() → \"expected string, received object\".\n it(\"password={} reproduces the 'expected string, received object' error\", async () => {\n const result = await schema.safeParseAsync({ ...validParams, password: {} });\n expect(result.success).toBe(false);\n const issue = result.error?.issues[0];\n expect(issue?.code).toBe(\"invalid_type\");\n expect(issue?.path).toEqual([\"password\"]);\n expect(issue?.message).toBe(\"Invalid input: expected string, received object\");\n });\n });\n\n describe(\"required string fields\", () => {\n it(\"rejects missing host\", async () => {\n const { host: _, ...params } = validParams;\n const result = await schema.safeParseAsync(params);\n expect(result.success).toBe(false);\n });\n\n it(\"rejects empty host\", async () => {\n const result = await schema.safeParseAsync({ ...validParams, host: \"\" });\n expect(result.success).toBe(false);\n });\n\n it(\"rejects missing user\", async () => {\n const { user: _, ...params } = validParams;\n const result = await schema.safeParseAsync(params);\n expect(result.success).toBe(false);\n });\n\n it(\"rejects empty user\", async () => {\n const result = await schema.safeParseAsync({ ...validParams, user: \"\" });\n expect(result.success).toBe(false);\n });\n\n it(\"rejects missing password\", async () => {\n const { password: _, ...params } = validParams;\n const result = await schema.safeParseAsync(params);\n expect(result.success).toBe(false);\n });\n\n it(\"rejects empty password\", async () => {\n const result = await schema.safeParseAsync({ ...validParams, password: \"\" });\n expect(result.success).toBe(false);\n });\n });\n\n describe(\"port validation\", () => {\n it(\"rejects port 0\", async () => {\n const result = await schema.safeParseAsync({ ...validParams, port: 0 });\n expect(result.success).toBe(false);\n });\n\n it(\"rejects negative port\", async () => {\n const result = await schema.safeParseAsync({ ...validParams, port: -1 });\n expect(result.success).toBe(false);\n });\n\n it(\"rejects fractional port\", async () => {\n const result = await schema.safeParseAsync({ ...validParams, port: 587.5 });\n expect(result.success).toBe(false);\n });\n });\n\n describe(\"email address validation\", () => {\n it(\"rejects invalid from address\", async () => {\n const result = await schema.safeParseAsync({ ...validParams, from: \"not-an-email\" });\n expect(result.success).toBe(false);\n expect(result.error?.issues[0].message).toBe(\"Invalid email address.\");\n });\n\n it(\"rejects invalid replyTo address\", async () => {\n const result = await schema.safeParseAsync({\n ...validParams,\n replyTo: \"not-an-email\"\n });\n expect(result.success).toBe(false);\n expect(result.error?.issues[0].message).toBe(\"Invalid email address.\");\n });\n });\n});\n"],"names":["validParams","describe","it","result","schema","expect","_","params","issue"],"mappings":";;AAGA,MAAMA,cAAc;IAChB,MAAM;IACN,MAAM;IACN,MAAM;IACN,UAAU;IACV,MAAM;IACN,SAAS;AACb;AAEAC,SAAS,qBAAqB;IAC1BA,SAAS,gBAAgB;QACrBC,GAAG,mCAAmC;YAClC,MAAMC,SAAS,MAAMC,iBAAAA,cAAqB,CAACJ;YAC3CK,OAAOF,OAAO,OAAO,EAAE,IAAI,CAAC;QAChC;QAEAD,GAAG,mDAAmD;YAClD,MAAM,EAAE,SAASI,CAAC,EAAE,GAAGC,QAAQ,GAAGP;YAClC,MAAMG,SAAS,MAAMC,iBAAAA,cAAqB,CAACG;YAC3CF,OAAOF,OAAO,OAAO,EAAE,IAAI,CAAC;QAChC;QAEAD,GAAG,+CAA+C;YAC9C,MAAMC,SAAS,MAAMC,iBAAAA,cAAqB,CAAC;gBACvC,GAAGJ,WAAW;gBACd,MAAM;gBACN,SAAS;YACb;YACAK,OAAOF,OAAO,OAAO,EAAE,IAAI,CAAC;QAChC;IACJ;I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|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import email_addresses from "email-addresses";
|
|
3
|
-
const isMailboxAddress = (value)=>null !== email_addresses.parseOneAddress(value);
|
|
4
|
-
const mailboxAddress = z.string().refine(isMailboxAddress, {
|
|
5
|
-
message: "Invalid email address."
|
|
6
|
-
});
|
|
7
|
-
const SmtpParamsSchema = z.object({
|
|
8
|
-
host: z.string().min(1).describe("SMTP server hostname."),
|
|
9
|
-
port: z.number().int().positive().describe("SMTP server port."),
|
|
10
|
-
user: z.string().min(1).describe("SMTP authentication username."),
|
|
11
|
-
password: z.string().min(1).describe("SMTP authentication password. Pass via env var (e.g. `process.env.SMTP_PASSWORD!`), never hard-code."),
|
|
12
|
-
from: mailboxAddress.describe("Default 'from' address."),
|
|
13
|
-
replyTo: mailboxAddress.optional().describe("Default 'reply-to' address.")
|
|
14
|
-
});
|
|
15
|
-
export { SmtpParamsSchema };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=SmtpParamsSchema.js.map
|