@lorion-org/runtime-config 1.0.0-beta.1 → 1.0.0-beta.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/README.md CHANGED
@@ -290,7 +290,7 @@ projectRuntimeConfigEnvVars(
290
290
  // }
291
291
  ```
292
292
 
293
- Runnable example files live in [`examples/`](./examples).
293
+ Runnable example files live in [`snippets/`](./snippets).
294
294
 
295
295
  ## Local commands
296
296
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lorion-org/runtime-config",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.5",
4
4
  "description": "Framework-free runtime-config types and merge helpers.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,7 +38,6 @@
38
38
  },
39
39
  "files": [
40
40
  "dist",
41
- "examples",
42
41
  "LICENSE",
43
42
  "src/**/*.ts",
44
43
  "!src/**/*.spec.ts"
@@ -1,46 +0,0 @@
1
- import {
2
- projectSectionedRuntimeConfig,
3
- resolveRuntimeConfigValue,
4
- } from '@lorion-org/runtime-config';
5
-
6
- const runtimeConfig = projectSectionedRuntimeConfig(
7
- [
8
- {
9
- scopeId: 'checkout',
10
- config: {
11
- public: {
12
- successPath: '/orders/confirmed',
13
- },
14
- stores: {
15
- 'eu-store': {
16
- public: {
17
- successPath: '/eu-store/orders/confirmed',
18
- },
19
- },
20
- },
21
- },
22
- },
23
- ],
24
- {
25
- contextInputKey: 'stores',
26
- contextOutputKey: '__stores',
27
- },
28
- );
29
-
30
- console.log(runtimeConfig.public);
31
- // {
32
- // checkoutSuccessPath: '/orders/confirmed',
33
- // __stores: {
34
- // 'eu-store': {
35
- // checkoutSuccessPath: '/eu-store/orders/confirmed'
36
- // }
37
- // }
38
- // }
39
-
40
- console.log(
41
- resolveRuntimeConfigValue(runtimeConfig.public, 'checkout', 'successPath', {
42
- contextId: 'eu-store',
43
- contextOutputKey: '__stores',
44
- }),
45
- );
46
- // '/eu-store/orders/confirmed'
@@ -1,25 +0,0 @@
1
- import {
2
- runtimeEnvVarsToShellAssignments,
3
- runtimeEnvVarsToString,
4
- toRuntimeEnvVars,
5
- } from '@lorion-org/runtime-config';
6
-
7
- const envVars = toRuntimeEnvVars(
8
- {
9
- public: {
10
- checkoutSuccessPath: '/orders/confirmed',
11
- },
12
- private: {
13
- checkoutSigningSecret: 'checkout_signing_secret_demo',
14
- },
15
- },
16
- 'APP',
17
- );
18
-
19
- console.log(runtimeEnvVarsToString(envVars));
20
- // APP_PUBLIC_CHECKOUT_SUCCESS_PATH=/orders/confirmed
21
- // APP_PRIVATE_CHECKOUT_SIGNING_SECRET=checkout_signing_secret_demo
22
-
23
- console.log(runtimeEnvVarsToShellAssignments(envVars));
24
- // APP_PUBLIC_CHECKOUT_SUCCESS_PATH='"/orders/confirmed"'
25
- // APP_PRIVATE_CHECKOUT_SIGNING_SECRET='"checkout_signing_secret_demo"'
@@ -1,50 +0,0 @@
1
- import {
2
- projectRuntimeConfigNamespace,
3
- projectRuntimeConfigNamespaces,
4
- } from '@lorion-org/runtime-config';
5
-
6
- const checkoutRuntimeConfig = projectRuntimeConfigNamespace('checkout', {
7
- public: {
8
- successPath: '/orders/confirmed',
9
- },
10
- private: {
11
- signingSecret: 'checkout_signing_secret_demo',
12
- },
13
- });
14
-
15
- console.log(checkoutRuntimeConfig.public.checkout);
16
- // { successPath: '/orders/confirmed' }
17
-
18
- console.log(checkoutRuntimeConfig.checkout);
19
- // { signingSecret: 'checkout_signing_secret_demo' }
20
-
21
- const combinedRuntimeConfig = projectRuntimeConfigNamespaces([
22
- {
23
- scopeId: 'checkout',
24
- config: {
25
- public: {
26
- successPath: '/orders/confirmed',
27
- },
28
- private: {
29
- signingSecret: 'checkout_signing_secret_demo',
30
- },
31
- },
32
- },
33
- {
34
- scopeId: 'payments',
35
- config: {
36
- public: {
37
- configuredProvider: 'payment-provider-stripe',
38
- },
39
- },
40
- },
41
- ]);
42
-
43
- console.log(combinedRuntimeConfig.public.checkout);
44
- // { successPath: '/orders/confirmed' }
45
-
46
- console.log(combinedRuntimeConfig.public.payments);
47
- // { configuredProvider: 'payment-provider-stripe' }
48
-
49
- console.log(combinedRuntimeConfig.checkout);
50
- // { signingSecret: 'checkout_signing_secret_demo' }
@@ -1,32 +0,0 @@
1
- import {
2
- getPrivateRuntimeConfigScope,
3
- getPublicRuntimeConfigScope,
4
- projectRuntimeConfigFragment,
5
- toRuntimeEnvVars,
6
- } from '@lorion-org/runtime-config';
7
-
8
- const runtimeConfig = projectRuntimeConfigFragment('checkout', {
9
- public: {
10
- currency: 'EUR',
11
- successPath: '/orders/confirmed',
12
- },
13
- private: {
14
- signingSecret: 'checkout_signing_secret_demo',
15
- },
16
- });
17
-
18
- console.log(runtimeConfig.public.checkoutCurrency);
19
- // 'EUR'
20
-
21
- console.log(toRuntimeEnvVars(runtimeConfig, 'APP'));
22
- // {
23
- // APP_PUBLIC_CHECKOUT_CURRENCY: 'EUR',
24
- // APP_PUBLIC_CHECKOUT_SUCCESS_PATH: '/orders/confirmed',
25
- // APP_PRIVATE_CHECKOUT_SIGNING_SECRET: 'checkout_signing_secret_demo'
26
- // }
27
-
28
- console.log(getPublicRuntimeConfigScope(runtimeConfig, 'checkout'));
29
- // { currency: 'EUR', successPath: '/orders/confirmed' }
30
-
31
- console.log(getPrivateRuntimeConfigScope(runtimeConfig, 'checkout'));
32
- // { signingSecret: 'checkout_signing_secret_demo' }
@@ -1,57 +0,0 @@
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
- 'checkout',
11
- {
12
- public: {
13
- successPath: '/orders/confirmed',
14
- },
15
- private: {
16
- signingSecret: 'checkout_signing_secret_demo',
17
- },
18
- contexts: {
19
- 'eu-store': {
20
- public: {
21
- successPath: '/eu-store/orders/confirmed',
22
- },
23
- },
24
- },
25
- },
26
- ],
27
- [
28
- 'payments',
29
- {
30
- public: {
31
- configuredProvider: 'payment-provider-stripe',
32
- },
33
- },
34
- ],
35
- ]);
36
-
37
- const runtimeConfig = projectSectionedRuntimeConfig(fragments);
38
- const euStoreSuccessPath = resolveRuntimeConfigValue(
39
- runtimeConfig.public,
40
- 'checkout',
41
- 'successPath',
42
- {
43
- contextId: 'eu-store',
44
- },
45
- );
46
-
47
- console.log(runtimeConfig.public.checkoutSuccessPath);
48
- // '/orders/confirmed'
49
-
50
- console.log(runtimeConfig.private.checkoutSigningSecret);
51
- // 'checkout_signing_secret_demo'
52
-
53
- console.log(euStoreSuccessPath);
54
- // '/eu-store/orders/confirmed'
55
-
56
- console.log(getPublicRuntimeConfigScope(runtimeConfig, 'checkout'));
57
- // { successPath: '/orders/confirmed' }