@lorion-org/runtime-config 1.0.0-beta.0

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.
@@ -0,0 +1,52 @@
1
+ import {
2
+ getPublicRuntimeConfigScope,
3
+ projectSectionedRuntimeConfig,
4
+ resolveRuntimeConfigValue,
5
+ type RuntimeConfigFragmentMap,
6
+ } from '@lorion-org/runtime-config';
7
+
8
+ const fragments: RuntimeConfigFragmentMap = new Map([
9
+ [
10
+ 'billing',
11
+ {
12
+ public: {
13
+ apiBase: '/api/billing',
14
+ },
15
+ private: {
16
+ apiSecret: 'secret',
17
+ },
18
+ contexts: {
19
+ tenantA: {
20
+ public: {
21
+ apiBase: '/tenant-a/billing',
22
+ },
23
+ },
24
+ },
25
+ },
26
+ ],
27
+ [
28
+ 'mail',
29
+ {
30
+ public: {
31
+ apiBase: '/api/mail',
32
+ },
33
+ },
34
+ ],
35
+ ]);
36
+
37
+ const runtimeConfig = projectSectionedRuntimeConfig(fragments);
38
+ const tenantApiBase = resolveRuntimeConfigValue(runtimeConfig.public, 'billing', 'apiBase', {
39
+ contextId: 'tenantA',
40
+ });
41
+
42
+ console.log(runtimeConfig.public.billingApiBase);
43
+ // '/api/billing'
44
+
45
+ console.log(runtimeConfig.private.billingApiSecret);
46
+ // 'secret'
47
+
48
+ console.log(tenantApiBase);
49
+ // '/tenant-a/billing'
50
+
51
+ console.log(getPublicRuntimeConfigScope(runtimeConfig, 'billing'));
52
+ // { apiBase: '/api/billing' }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@lorion-org/runtime-config",
3
+ "version": "1.0.0-beta.0",
4
+ "description": "Framework-free runtime-config types and merge helpers.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/lorion-org/lorion.git",
9
+ "directory": "packages/runtime-config"
10
+ },
11
+ "homepage": "https://github.com/lorion-org/lorion/tree/main/packages/runtime-config#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/lorion-org/lorion/issues"
14
+ },
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "main": "./dist/index.cjs",
21
+ "module": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "import": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.js"
28
+ },
29
+ "require": {
30
+ "types": "./dist/index.d.cts",
31
+ "default": "./dist/index.cjs"
32
+ }
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "examples",
38
+ "LICENSE"
39
+ ],
40
+ "keywords": [
41
+ "runtime-config",
42
+ "configuration",
43
+ "environment",
44
+ "typescript"
45
+ ],
46
+ "engines": {
47
+ "node": "^20.19.0 || >=22.12.0"
48
+ },
49
+ "scripts": {
50
+ "build": "tsup src/index.ts --format esm,cjs --dts",
51
+ "clean": "rimraf coverage dist tsconfig.tsbuildinfo",
52
+ "lint": "eslint src --ext .ts",
53
+ "package:check": "pnpm build && pnpm pack --dry-run && publint",
54
+ "test": "vitest run --root ../.. --config vitest.config.mts packages/runtime-config/src",
55
+ "coverage": "node -e \"require('node:fs').mkdirSync('../../coverage/.tmp', { recursive: true })\" && vitest run --coverage --coverage.include=packages/runtime-config/src/**/*.ts --root ../.. --config vitest.config.mts packages/runtime-config/src",
56
+ "typecheck": "tsc -p tsconfig.json --noEmit"
57
+ }
58
+ }