@venizia/ardor-kernel 0.4.1 → 0.4.2
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/README.md
CHANGED
|
@@ -21,7 +21,7 @@ which re-exports this package.
|
|
|
21
21
|
| Bindings | `CoreBindings`, `LocalStorageKeys` |
|
|
22
22
|
| Constants | `RequestMethods`, `RequestTypes`, `RequestBodyTypes`, `RequestCountData`, `HeaderConstants`, `Environments`, `App` |
|
|
23
23
|
| Network | `NetworkHeaders`, `RequestBodyEncoder`, `ResponseReader`, `AuthRecovery`, `AuthTokenStore` (the fetch transport is IGNIS's `NodeFetchNetworkRequest`) |
|
|
24
|
-
| Helpers | `Logger`, `BaseHelper
|
|
24
|
+
| Helpers | `Logger`, `BaseHelper` |
|
|
25
25
|
| Utilities | `isDefined`, `isString`, `isNumber`, `isObject`, `isBrowser`, `isValidDate`, `isEditableTarget`, `toDataUrl` |
|
|
26
26
|
| Types | `IdType`, `AnyType`, `AnyObject`, `ValueOrPromise`, `ValueOf`, `TConstValue`, `TPaths`, `TFullPaths`, `ISendParams`, `IRestDataProviderOptions`, `IApplicationInfo`, ... |
|
|
27
27
|
|
|
@@ -3,14 +3,26 @@
|
|
|
3
3
|
* The preset image writes it at container start, from the environment variables that start with `VITE_`.
|
|
4
4
|
*/
|
|
5
5
|
export declare const RUNTIME_CONFIG_GLOBAL = "__APP_CONFIG__";
|
|
6
|
+
interface IRuntimeConfigOptions {
|
|
7
|
+
key: string;
|
|
8
|
+
buildTimeEnv?: Record<string, unknown>;
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
}
|
|
6
11
|
/**
|
|
7
12
|
* One config value: the runtime one (`window.__APP_CONFIG__`), else the build-time one
|
|
8
13
|
* (`buildTimeEnv`, passed by the app as `import.meta.env`), else `defaultValue`. Only a non-empty
|
|
9
14
|
* string counts, and a missing global is not an error.
|
|
15
|
+
*
|
|
16
|
+
* With `required: true` the result is a `string`: when all three are absent it throws, naming the
|
|
17
|
+
* key and never a value. Without it, the result is `string | undefined`.
|
|
10
18
|
*/
|
|
11
|
-
export declare const getRuntimeConfig:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
export declare const getRuntimeConfig: {
|
|
20
|
+
(opts: IRuntimeConfigOptions & {
|
|
21
|
+
required: true;
|
|
22
|
+
}): string;
|
|
23
|
+
(opts: IRuntimeConfigOptions & {
|
|
24
|
+
required?: boolean;
|
|
25
|
+
}): string | undefined;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
16
28
|
//# sourceMappingURL=runtime-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-config.d.ts","sourceRoot":"","sources":["../../src/utilities/runtime-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-config.d.ts","sourceRoot":"","sources":["../../src/utilities/runtime-config.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAmBtD,UAAU,qBAAqB;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE;IAC7B,CAAC,IAAI,EAAE,qBAAqB,GAAG;QAAE,QAAQ,EAAE,IAAI,CAAA;KAAE,GAAG,MAAM,CAAC;IAC3D,CAAC,IAAI,EAAE,qBAAqB,GAAG;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,GAAG,SAAS,CAAC;CAgB5E,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getError } from '@venizia/ignis-inversion';
|
|
1
2
|
/**
|
|
2
3
|
* The name `config.js` writes the runtime config under: `window.__APP_CONFIG__`, a record of strings.
|
|
3
4
|
* The preset image writes it at container start, from the environment variables that start with `VITE_`.
|
|
@@ -19,11 +20,20 @@ const readString = (opts) => {
|
|
|
19
20
|
* One config value: the runtime one (`window.__APP_CONFIG__`), else the build-time one
|
|
20
21
|
* (`buildTimeEnv`, passed by the app as `import.meta.env`), else `defaultValue`. Only a non-empty
|
|
21
22
|
* string counts, and a missing global is not an error.
|
|
23
|
+
*
|
|
24
|
+
* With `required: true` the result is a `string`: when all three are absent it throws, naming the
|
|
25
|
+
* key and never a value. Without it, the result is `string | undefined`.
|
|
22
26
|
*/
|
|
23
27
|
export const getRuntimeConfig = (opts) => {
|
|
24
|
-
const { key, buildTimeEnv, defaultValue } = opts;
|
|
25
|
-
|
|
28
|
+
const { key, buildTimeEnv, defaultValue, required } = opts;
|
|
29
|
+
const value = readString({ source: Reflect.get(globalThis, RUNTIME_CONFIG_GLOBAL), key }) ??
|
|
26
30
|
readString({ source: buildTimeEnv, key }) ??
|
|
27
|
-
defaultValue
|
|
31
|
+
defaultValue;
|
|
32
|
+
if (required && value === undefined) {
|
|
33
|
+
throw getError({
|
|
34
|
+
message: `[getRuntimeConfig] '${key}' is required and not set | Write it to config.js (a VITE_ variable of the container, listed in APP_REQUIRED_ENV), or pass it in buildTimeEnv or defaultValue`,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
28
38
|
};
|
|
29
39
|
//# sourceMappingURL=runtime-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-config.js","sourceRoot":"","sources":["../../src/utilities/runtime-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAEtD,MAAM,UAAU,GAAG,CAAC,IAAsC,EAAsB,EAAE;IAChF,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE7B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CA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CAAC,CAAC,SAAS,CAAC;AACvE,CAAC,CAAC;AAQF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAGzB,CAAC,IAAoD,EAAU,EAAE;IACnE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAE3D,MAAM,KAAK,GACT,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE,GAAG,EAAE,CAAC;QAC3E,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC;QACzC,YAAY,CAAC;IAEf,IAAI,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,uBAAuB,GAAG,+JAA+J;SACnM,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAe,CAAC;AACzB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ardor-kernel",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "ARDOR kernel - the isomorphic core of the ARDOR frontend framework: application base on IGNIS inversion, service and CRUD bases, request/auth constants, binding keys, logger, network fetchers and socket client. No React and no react-admin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ardor",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@size-limit/preset-small-lib": "^14.2.0",
|
|
70
70
|
"@types/bun": "^1.4.3",
|
|
71
|
-
"@venizia/dev-configs": "^0.4.
|
|
72
|
-
"@venizia/ignis-connectors": "^0.4.
|
|
73
|
-
"@venizia/ignis-filter": "^0.4.
|
|
74
|
-
"@venizia/ignis-helpers": "^0.4.
|
|
75
|
-
"@venizia/ignis-inversion": "^0.4.
|
|
76
|
-
"@venizia/ignis-kernel": "^0.4.
|
|
71
|
+
"@venizia/dev-configs": "^0.4.2",
|
|
72
|
+
"@venizia/ignis-connectors": "^0.4.2",
|
|
73
|
+
"@venizia/ignis-filter": "^0.4.2",
|
|
74
|
+
"@venizia/ignis-helpers": "^0.4.2",
|
|
75
|
+
"@venizia/ignis-inversion": "^0.4.2",
|
|
76
|
+
"@venizia/ignis-kernel": "^0.4.2",
|
|
77
77
|
"eslint": "^10.13.0",
|
|
78
78
|
"oxlint": "1.89.0",
|
|
79
79
|
"oxlint-tsgolint": "7.0.2004",
|