@webiny/app-admin 6.6.0-alpha.1 → 6.6.0-alpha.3
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/base/resolveApiUrl.d.ts +10 -0
- package/base/resolveApiUrl.js +11 -3
- package/base/resolveApiUrl.js.map +1 -1
- package/package.json +20 -20
package/base/resolveApiUrl.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composition-root bootstrap: works out the API, GraphQL and WebSocket URLs that
|
|
3
|
+
* `createRootContainer` seeds `EnvConfig` with.
|
|
4
|
+
*
|
|
5
|
+
* Plain functions rather than a feature on purpose. `EnvConfig` IS the abstraction here, and
|
|
6
|
+
* everything downstream injects it (`WebinySdk`, `MainGraphQLClient`, `WcpService`, ...). These run
|
|
7
|
+
* one step earlier, to produce the values that configure it, so a container is not yet available to
|
|
8
|
+
* resolve them from. That's also why this is one of the few places allowed to read `process.env`
|
|
9
|
+
* directly, alongside the other env reads sitting inline in `createRootContainer`.
|
|
10
|
+
*/
|
|
1
11
|
export declare const resolveApiUrl: () => string;
|
|
2
12
|
export declare const resolveGraphqlUrl: () => string;
|
|
3
13
|
export declare const resolveWebsocketUrl: () => string;
|
package/base/resolveApiUrl.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
const toAbsoluteUrl = (url)=>{
|
|
2
|
+
if ("u" < typeof window) return url;
|
|
3
|
+
return new URL(url, window.location.origin).toString().replace(/\/+$/, "");
|
|
4
|
+
};
|
|
1
5
|
const resolveApiUrl = ()=>{
|
|
2
6
|
const url = process.env.WEBINY_ADMIN_API_URL;
|
|
3
|
-
if (url && "undefined" !== url) return url;
|
|
7
|
+
if (url && "undefined" !== url) return toAbsoluteUrl(url);
|
|
4
8
|
return "u" > typeof window ? window.location.origin : "";
|
|
5
9
|
};
|
|
6
10
|
const resolveGraphqlUrl = ()=>`${resolveApiUrl()}/graphql`;
|
|
@@ -8,11 +12,15 @@ const resolveWebsocketUrl = ()=>{
|
|
|
8
12
|
const awsExplicit = process.env.REACT_APP_WEBSOCKET_URL;
|
|
9
13
|
if (awsExplicit && "undefined" !== awsExplicit) return awsExplicit;
|
|
10
14
|
const serverExplicit = process.env.WEBINY_ADMIN_WS_API_URL;
|
|
11
|
-
if (serverExplicit && "undefined" !== serverExplicit) return serverExplicit;
|
|
15
|
+
if (serverExplicit && "undefined" !== serverExplicit) return toWebsocketUrl(serverExplicit);
|
|
12
16
|
const apiUrl = process.env.WEBINY_ADMIN_API_URL;
|
|
13
|
-
if (apiUrl && "undefined" !== apiUrl) return apiUrl
|
|
17
|
+
if (apiUrl && "undefined" !== apiUrl) return toWebsocketUrl(apiUrl);
|
|
14
18
|
return "";
|
|
15
19
|
};
|
|
20
|
+
const toWebsocketUrl = (url)=>{
|
|
21
|
+
if (/^wss?:\/\//.test(url)) return url;
|
|
22
|
+
return toAbsoluteUrl(url).replace(/^http/, "ws");
|
|
23
|
+
};
|
|
16
24
|
export { resolveApiUrl, resolveGraphqlUrl, resolveWebsocketUrl };
|
|
17
25
|
|
|
18
26
|
//# sourceMappingURL=resolveApiUrl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base/resolveApiUrl.js","sources":["../../src/base/resolveApiUrl.ts"],"sourcesContent":["// Prefer the configured API URL (baked by `<Admin.ApiUrl>` into WEBINY_ADMIN_API_URL); else\n// same-origin (a deployed self-hosted admin served behind the same domain as the API needs no\n// baked-in URL). Never return the literal string \"undefined\".\nexport const resolveApiUrl = (): string => {\n const url = process.env.WEBINY_ADMIN_API_URL;\n if (url && url !== \"undefined\") {\n return url;\n }\n return typeof window !== \"undefined\" ? window.location.origin : \"\";\n};\n\n// The GraphQL endpoint derived from the resolved API URL.\nexport const resolveGraphqlUrl = (): string => `${resolveApiUrl()}/graphql`;\n\n// Resolve the WebSocket URL for the admin, in order:\n// 1. REACT_APP_WEBSOCKET_URL — AWS: the dedicated API Gateway WebSocket URL.\n// 2. WEBINY_ADMIN_WS_API_URL — self-hosted: a dedicated WS URL (baked via `<Admin.WebsocketsUrl>`),\n// only needed when WS is served from a different origin than the API.\n// 3. derived from the API URL — self-hosted default: the server handles WS upgrades on its own\n// origin, so use the API origin with http(s) swapped for ws(s).\n// Returns \"\" when none is configured (real-time updates are then disabled). This is one of the few\n// spots allowed to read process.env — it runs at the admin composition root, like resolveApiUrl.\nexport const resolveWebsocketUrl = (): string => {\n const awsExplicit = process.env.REACT_APP_WEBSOCKET_URL;\n if (awsExplicit && awsExplicit !== \"undefined\") {\n return awsExplicit;\n }\n\n const serverExplicit = process.env.WEBINY_ADMIN_WS_API_URL;\n if (serverExplicit && serverExplicit !== \"undefined\") {\n return serverExplicit;\n }\n\n const apiUrl = process.env.WEBINY_ADMIN_API_URL;\n if (apiUrl && apiUrl !== \"undefined\") {\n return apiUrl
|
|
1
|
+
{"version":3,"file":"base/resolveApiUrl.js","sources":["../../src/base/resolveApiUrl.ts"],"sourcesContent":["/**\n * Composition-root bootstrap: works out the API, GraphQL and WebSocket URLs that\n * `createRootContainer` seeds `EnvConfig` with.\n *\n * Plain functions rather than a feature on purpose. `EnvConfig` IS the abstraction here, and\n * everything downstream injects it (`WebinySdk`, `MainGraphQLClient`, `WcpService`, ...). These run\n * one step earlier, to produce the values that configure it, so a container is not yet available to\n * resolve them from. That's also why this is one of the few places allowed to read `process.env`\n * directly, alongside the other env reads sitting inline in `createRootContainer`.\n */\n\n/**\n * Resolves a configured API URL to an absolute one against the page origin, so the value baked into\n * the bundle can be relative.\n *\n * That's what lets one build run anywhere. `WEBINY_ADMIN_API_URL=/api` works on http://localhost:3001\n * behind the dev proxy, on a portless domain like https://wby6.localhost, and behind a reverse proxy\n * in production, because the origin is filled in by the browser rather than at build time. An absolute\n * value still passes through unchanged.\n */\nconst toAbsoluteUrl = (url: string): string => {\n if (typeof window === \"undefined\") {\n return url;\n }\n\n // `new URL` appends a trailing slash to a bare origin; callers append their own path segments.\n return new URL(url, window.location.origin).toString().replace(/\\/+$/, \"\");\n};\n\n// Prefer the configured API URL (baked by `<Admin.ApiUrl>` into WEBINY_ADMIN_API_URL); else\n// same-origin (a deployed self-hosted admin served behind the same domain as the API needs no\n// baked-in URL). Never return the literal string \"undefined\".\nexport const resolveApiUrl = (): string => {\n const url = process.env.WEBINY_ADMIN_API_URL;\n if (url && url !== \"undefined\") {\n return toAbsoluteUrl(url);\n }\n return typeof window !== \"undefined\" ? window.location.origin : \"\";\n};\n\n// The GraphQL endpoint derived from the resolved API URL.\nexport const resolveGraphqlUrl = (): string => `${resolveApiUrl()}/graphql`;\n\n// Resolve the WebSocket URL for the admin, in order:\n// 1. REACT_APP_WEBSOCKET_URL — AWS: the dedicated API Gateway WebSocket URL.\n// 2. WEBINY_ADMIN_WS_API_URL — self-hosted: a dedicated WS URL (baked via `<Admin.WebsocketsUrl>`),\n// only needed when WS is served from a different origin than the API.\n// 3. derived from the API URL — self-hosted default: the server handles WS upgrades on its own\n// origin, so use the API origin with http(s) swapped for ws(s).\n// Returns \"\" when none is configured (real-time updates are then disabled). This is one of the few\n// spots allowed to read process.env — it runs at the admin composition root, like resolveApiUrl.\nexport const resolveWebsocketUrl = (): string => {\n const awsExplicit = process.env.REACT_APP_WEBSOCKET_URL;\n if (awsExplicit && awsExplicit !== \"undefined\") {\n return awsExplicit;\n }\n\n const serverExplicit = process.env.WEBINY_ADMIN_WS_API_URL;\n if (serverExplicit && serverExplicit !== \"undefined\") {\n return toWebsocketUrl(serverExplicit);\n }\n\n const apiUrl = process.env.WEBINY_ADMIN_API_URL;\n if (apiUrl && apiUrl !== \"undefined\") {\n return toWebsocketUrl(apiUrl);\n }\n\n return \"\";\n};\n\n/**\n * Turns a configured value into a WebSocket URL the browser can dial.\n *\n * Resolved against the page origin before the scheme is swapped, because a relative value like\n * `/api` has no scheme to swap: the prefix replacement alone would hand back `/api` unchanged, which\n * connects to nothing. A value that already names a ws(s) origin passes straight through.\n */\nconst toWebsocketUrl = (url: string): string => {\n if (/^wss?:\\/\\//.test(url)) {\n return url;\n }\n\n return toAbsoluteUrl(url).replace(/^http/, \"ws\");\n};\n"],"names":["toAbsoluteUrl","url","window","URL","resolveApiUrl","process","resolveGraphqlUrl","resolveWebsocketUrl","awsExplicit","serverExplicit","toWebsocketUrl","apiUrl"],"mappings":"AAoBA,MAAMA,gBAAgB,CAACC;IACnB,IAAI,AAAkB,MAAlB,OAAOC,QACP,OAAOD;IAIX,OAAO,IAAIE,IAAIF,KAAKC,OAAO,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ;AAC3E;AAKO,MAAME,gBAAgB;IACzB,MAAMH,MAAMI,QAAQ,GAAG,CAAC,oBAAoB;IAC5C,IAAIJ,OAAOA,AAAQ,gBAARA,KACP,OAAOD,cAAcC;IAEzB,OAAO,AAAkB,MAAlB,OAAOC,SAAyBA,OAAO,QAAQ,CAAC,MAAM,GAAG;AACpE;AAGO,MAAMI,oBAAoB,IAAc,GAAGF,gBAAgB,QAAQ,CAAC;AAUpE,MAAMG,sBAAsB;IAC/B,MAAMC,cAAcH,QAAQ,GAAG,CAAC,uBAAuB;IACvD,IAAIG,eAAeA,AAAgB,gBAAhBA,aACf,OAAOA;IAGX,MAAMC,iBAAiBJ,QAAQ,GAAG,CAAC,uBAAuB;IAC1D,IAAII,kBAAkBA,AAAmB,gBAAnBA,gBAClB,OAAOC,eAAeD;IAG1B,MAAME,SAASN,QAAQ,GAAG,CAAC,oBAAoB;IAC/C,IAAIM,UAAUA,AAAW,gBAAXA,QACV,OAAOD,eAAeC;IAG1B,OAAO;AACX;AASA,MAAMD,iBAAiB,CAACT;IACpB,IAAI,aAAa,IAAI,CAACA,MAClB,OAAOA;IAGX,OAAOD,cAAcC,KAAK,OAAO,CAAC,SAAS;AAC/C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-admin",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -24,25 +24,25 @@
|
|
|
24
24
|
"@iconify/json": "2.2.518",
|
|
25
25
|
"@lexical/utils": "0.49.0",
|
|
26
26
|
"@types/react": "18.3.31",
|
|
27
|
-
"@webiny/admin-ui": "6.6.0-alpha.
|
|
28
|
-
"@webiny/app": "6.6.0-alpha.
|
|
27
|
+
"@webiny/admin-ui": "6.6.0-alpha.3",
|
|
28
|
+
"@webiny/app": "6.6.0-alpha.3",
|
|
29
29
|
"@webiny/di": "1.1.0",
|
|
30
|
-
"@webiny/feature": "6.6.0-alpha.
|
|
31
|
-
"@webiny/feature-flags": "6.6.0-alpha.
|
|
32
|
-
"@webiny/form": "6.6.0-alpha.
|
|
33
|
-
"@webiny/icons": "6.6.0-alpha.
|
|
34
|
-
"@webiny/lexical-converter": "6.6.0-alpha.
|
|
35
|
-
"@webiny/lexical-editor": "6.6.0-alpha.
|
|
36
|
-
"@webiny/lexical-nodes": "6.6.0-alpha.
|
|
37
|
-
"@webiny/lexical-theme": "6.6.0-alpha.
|
|
38
|
-
"@webiny/plugins": "6.6.0-alpha.
|
|
39
|
-
"@webiny/react-composition": "6.6.0-alpha.
|
|
40
|
-
"@webiny/react-properties": "6.6.0-alpha.
|
|
41
|
-
"@webiny/sdk": "6.6.0-alpha.
|
|
42
|
-
"@webiny/telemetry": "6.6.0-alpha.
|
|
43
|
-
"@webiny/utils": "6.6.0-alpha.
|
|
44
|
-
"@webiny/validation": "6.6.0-alpha.
|
|
45
|
-
"@webiny/wcp": "6.6.0-alpha.
|
|
30
|
+
"@webiny/feature": "6.6.0-alpha.3",
|
|
31
|
+
"@webiny/feature-flags": "6.6.0-alpha.3",
|
|
32
|
+
"@webiny/form": "6.6.0-alpha.3",
|
|
33
|
+
"@webiny/icons": "6.6.0-alpha.3",
|
|
34
|
+
"@webiny/lexical-converter": "6.6.0-alpha.3",
|
|
35
|
+
"@webiny/lexical-editor": "6.6.0-alpha.3",
|
|
36
|
+
"@webiny/lexical-nodes": "6.6.0-alpha.3",
|
|
37
|
+
"@webiny/lexical-theme": "6.6.0-alpha.3",
|
|
38
|
+
"@webiny/plugins": "6.6.0-alpha.3",
|
|
39
|
+
"@webiny/react-composition": "6.6.0-alpha.3",
|
|
40
|
+
"@webiny/react-properties": "6.6.0-alpha.3",
|
|
41
|
+
"@webiny/sdk": "6.6.0-alpha.3",
|
|
42
|
+
"@webiny/telemetry": "6.6.0-alpha.3",
|
|
43
|
+
"@webiny/utils": "6.6.0-alpha.3",
|
|
44
|
+
"@webiny/validation": "6.6.0-alpha.3",
|
|
45
|
+
"@webiny/wcp": "6.6.0-alpha.3",
|
|
46
46
|
"bytes": "3.1.2",
|
|
47
47
|
"classnames": "2.5.1",
|
|
48
48
|
"graphql": "16.14.2",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/react-transition-group": "4.4.12",
|
|
77
77
|
"@types/store": "2.0.5",
|
|
78
78
|
"@types/tinycolor2": "1.4.6",
|
|
79
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
79
|
+
"@webiny/build-tools": "6.6.0-alpha.3",
|
|
80
80
|
"rimraf": "6.1.3",
|
|
81
81
|
"typescript": "7.0.2",
|
|
82
82
|
"vitest": "4.1.11"
|