sitero 0.1.4 → 0.1.5
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/dist/export/index.js +2 -0
- package/dist/src/env/public-env.js +57 -0
- package/dist/src/env/runtime-public-env-script.js +21 -0
- package/dist/types/export/index.d.ts +1 -0
- package/dist/types/export/index.d.ts.map +1 -1
- package/dist/types/src/cms/client/interfaces/pages/(auth)/layout.d.ts +1 -1
- package/dist/types/src/env/index.d.ts +3 -0
- package/dist/types/src/env/index.d.ts.map +1 -0
- package/dist/types/src/env/public-env.d.ts +25 -0
- package/dist/types/src/env/public-env.d.ts.map +1 -0
- package/dist/types/src/env/runtime-public-env-script.d.ts +6 -0
- package/dist/types/src/env/runtime-public-env-script.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/export/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from 'sitero-domain';
|
|
2
|
+
export { getRuntimePublicEnv, getServerPublicEnv, publicEnv } from '../src/env/public-env.js';
|
|
3
|
+
export { RuntimePublicEnvScript } from '../src/env/runtime-public-env-script.js';
|
|
2
4
|
export { isFileLocked } from '../src/core/domain/resources/file/utils/is-file-locked.js';
|
|
3
5
|
export { isFolderLocked } from '../src/core/domain/resources/folder/utils/is-folder-locked.js';
|
|
4
6
|
export { normalizeFolderKey } from '../src/core/domain/resources/folder/utils/normalize-folder-key.js';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function getRequiredEnv(key) {
|
|
2
|
+
const value = process.env[key]?.trim();
|
|
3
|
+
if (!value) {
|
|
4
|
+
throw new Error(
|
|
5
|
+
`[sitero] Missing required runtime public environment variable: ${key}`
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
function getRequiredUrlEnv(key) {
|
|
11
|
+
const value = getRequiredEnv(key);
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(value);
|
|
14
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
15
|
+
throw new Error("Unsupported URL protocol");
|
|
16
|
+
}
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`[sitero] Invalid runtime public environment variable: ${key} must be an absolute HTTP(S) URL.`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function getServerPublicEnv() {
|
|
25
|
+
return {
|
|
26
|
+
APP_NAME: getRequiredEnv("APP_NAME"),
|
|
27
|
+
WEB_URL: getRequiredUrlEnv("WEB_URL"),
|
|
28
|
+
API_URL: getRequiredUrlEnv("API_URL"),
|
|
29
|
+
STORAGE_URL: getRequiredUrlEnv("STORAGE_URL")
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function getRuntimePublicEnv() {
|
|
33
|
+
if (typeof window === "undefined") return getServerPublicEnv();
|
|
34
|
+
const env = window.__RUNTIME_PUBLIC_ENV__;
|
|
35
|
+
if (!env) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
"[sitero] Runtime public environment is unavailable. Ensure the root layout renders RuntimePublicEnvScript."
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return env;
|
|
41
|
+
}
|
|
42
|
+
const publicEnv = {
|
|
43
|
+
get APP_NAME() {
|
|
44
|
+
return getRuntimePublicEnv().APP_NAME;
|
|
45
|
+
},
|
|
46
|
+
get WEB_URL() {
|
|
47
|
+
return getRuntimePublicEnv().WEB_URL;
|
|
48
|
+
},
|
|
49
|
+
get API_URL() {
|
|
50
|
+
return getRuntimePublicEnv().API_URL;
|
|
51
|
+
},
|
|
52
|
+
get STORAGE_URL() {
|
|
53
|
+
return getRuntimePublicEnv().STORAGE_URL;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { getRuntimePublicEnv, getServerPublicEnv, publicEnv };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import Script from 'next/script';
|
|
3
|
+
import { getServerPublicEnv } from './public-env.js';
|
|
4
|
+
|
|
5
|
+
function serializeForInlineScript(value) {
|
|
6
|
+
return JSON.stringify(value).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
7
|
+
}
|
|
8
|
+
function RuntimePublicEnvScript() {
|
|
9
|
+
const env = getServerPublicEnv();
|
|
10
|
+
const content = `window.__RUNTIME_PUBLIC_ENV__=${serializeForInlineScript(env)};`;
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
Script,
|
|
13
|
+
{
|
|
14
|
+
id: "runtime-public-env",
|
|
15
|
+
strategy: "beforeInteractive",
|
|
16
|
+
dangerouslySetInnerHTML: { __html: content }
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { RuntimePublicEnvScript };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "sitero-domain";
|
|
2
|
+
export { type RuntimePublicEnv, getServerPublicEnv, getRuntimePublicEnv, publicEnv, RuntimePublicEnvScript, } from "../src/env";
|
|
2
3
|
export { type AdminFull, type FileFull, type FileCard, isFileLocked, type FolderFull, isFolderLocked, normalizeFolderKey, fileManagerDoubleClick, type PostFull, type PostListCard, type ConfigFull, ROOT_FOLDER, ROOT_FOLDER_ID, ROOT_FOLDER_NAME, SIMPLE_UPLOAD_FOLDER_KEY, SIMPLE_UPLOAD_FOLDER_NAME, type StaticAdmins, type StaticTopics, getTopicCategories, getTopicPosts, getTopicProducts, getTopicSubcategories, hasTopicRole, isContentTopic, isProductTopic, type StaticPages, type StaticInquiry, type StaticConfigs, type SeoMetadataField, type PostField, type SiteConfig, type StaticEmails, } from "../src/core/domain";
|
|
3
4
|
export { CMS_PATHS, API_PATHS, NEW_TAB_REL, NEW_TAB_TARGET, DATE_FORMAT_OPTIONS, CMS_LOCALES_MAP, CMS_LOCALES_ARRAY, CMS_DEFAULT_LOCALE, } from "../src/constants";
|
|
4
5
|
export { type Result, findTranslation, createBuildTranslations, cn, debounce, ensureArray, joinUrl, normalizeSlug, parsePositiveInt, toIsoTime, localeToFlagEmoji, createVersion, normalizeUnorderedCacheKey, dateToUi, deepMerge, TIME, type ListItemStates, DO_NOT_FETCH_KEY, schemas, } from "../src/shared";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../export/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAK9B,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,YAAY,EAEZ,KAAK,UAAU,EACf,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EAEtB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,UAAU,EAEf,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,yBAAyB,EAIzB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAEL,KAAK,MAAM,EAGX,eAAe,EACf,uBAAuB,EAGvB,EAAE,EACF,QAAQ,EACR,WAAW,EACX,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,0BAA0B,EAC1B,QAAQ,EACR,SAAS,EAGT,IAAI,EAGJ,KAAK,cAAc,EACnB,gBAAgB,EAGhB,OAAO,GACR,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../export/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAK9B,OAAO,EACL,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,YAAY,EAEZ,KAAK,UAAU,EACf,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EAEtB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,UAAU,EAEf,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,yBAAyB,EAIzB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAEL,KAAK,MAAM,EAGX,eAAe,EACf,uBAAuB,EAGvB,EAAE,EACF,QAAQ,EACR,WAAW,EACX,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,0BAA0B,EAC1B,QAAQ,EACR,SAAS,EAGT,IAAI,EAGJ,KAAK,cAAc,EACnB,gBAAgB,EAGhB,OAAO,GACR,MAAM,eAAe,CAAC"}
|
|
@@ -8,5 +8,5 @@ import { type ReactNode } from "react";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function createAuthLayout(): ({ children }: Readonly<{
|
|
10
10
|
children: ReactNode;
|
|
11
|
-
}>) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> |
|
|
11
|
+
}>) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
12
12
|
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,GACV,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type RuntimePublicEnv = {
|
|
2
|
+
APP_NAME: string;
|
|
3
|
+
WEB_URL: string;
|
|
4
|
+
API_URL: string;
|
|
5
|
+
STORAGE_URL: string;
|
|
6
|
+
};
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
__RUNTIME_PUBLIC_ENV__?: RuntimePublicEnv;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reads Sitero's fixed public deployment contract from the Node process.
|
|
14
|
+
* The values are safe to expose to browser code, but must still be explicitly
|
|
15
|
+
* injected through RuntimePublicEnvScript.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getServerPublicEnv(): RuntimePublicEnv;
|
|
18
|
+
export declare function getRuntimePublicEnv(): RuntimePublicEnv;
|
|
19
|
+
/**
|
|
20
|
+
* Compatibility facade for modules that need public configuration in either
|
|
21
|
+
* server or browser code. Values are deliberately read lazily so a standalone
|
|
22
|
+
* server can receive new deployment env values after a restart.
|
|
23
|
+
*/
|
|
24
|
+
export declare const publicEnv: RuntimePublicEnv;
|
|
25
|
+
//# sourceMappingURL=public-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-env.d.ts","sourceRoot":"","sources":["../../../../src/env/public-env.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,sBAAsB,CAAC,EAAE,gBAAgB,CAAC;KAC3C;CACF;AA2BD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,gBAAgB,CAOrD;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAStD;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,gBAavB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes deployment-time public configuration available before client modules
|
|
3
|
+
* hydrate. Only non-secret values from RuntimePublicEnv may be serialized.
|
|
4
|
+
*/
|
|
5
|
+
export declare function RuntimePublicEnvScript(): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=runtime-public-env-script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-public-env-script.d.ts","sourceRoot":"","sources":["../../../../src/env/runtime-public-env-script.tsx"],"names":[],"mappings":"AAYA;;;GAGG;AAEH,wBAAgB,sBAAsB,4CAWrC"}
|