@kitsy/cnos-docs 1.3.0 → 1.4.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.
- package/docs/api/runtime.mdx +51 -0
- package/docs/cli/value.mdx +35 -0
- package/docs/cli/vault.mdx +2 -0
- package/docs/getting-started/quick-start.mdx +2 -0
- package/docs/getting-started/your-first-project.mdx +1 -1
- package/docs/guides/profiles.mdx +7 -1
- package/docs/guides/secrets.mdx +2 -0
- package/docs/reference/manifest.mdx +1 -0
- package/docs/reference/namespaces.mdx +21 -1
- package/package.json +1 -1
package/docs/api/runtime.mdx
CHANGED
|
@@ -5,6 +5,8 @@ description: Use the default CNOS runtime singleton from the root package.
|
|
|
5
5
|
|
|
6
6
|
# Singleton Runtime
|
|
7
7
|
|
|
8
|
+
Use the default server/runtime singleton when your process is started through `cnos run`, or when you want the zero-config default entrypoint.
|
|
9
|
+
|
|
8
10
|
```ts
|
|
9
11
|
import cnos from '@kitsy/cnos';
|
|
10
12
|
|
|
@@ -14,3 +16,52 @@ cnos('value.app.name');
|
|
|
14
16
|
cnos.value('app.name');
|
|
15
17
|
cnos.secret('app.token');
|
|
16
18
|
```
|
|
19
|
+
|
|
20
|
+
## Available methods
|
|
21
|
+
|
|
22
|
+
The runtime currently exposes:
|
|
23
|
+
|
|
24
|
+
- `cnos(key)` as shorthand for `cnos.read(key)`
|
|
25
|
+
- `cnos.read(key)`
|
|
26
|
+
- `cnos.require(key)`
|
|
27
|
+
- `cnos.readOr(key, fallback)`
|
|
28
|
+
- `cnos.value(path)`
|
|
29
|
+
- `cnos.secret(path)`
|
|
30
|
+
- `cnos.meta(path)`
|
|
31
|
+
- `cnos.inspect(key)`
|
|
32
|
+
- `cnos.toNamespace(namespace)`
|
|
33
|
+
- `cnos.toEnv()`
|
|
34
|
+
- `cnos.toPublicEnv()`
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import cnos from '@kitsy/cnos';
|
|
40
|
+
|
|
41
|
+
await cnos.ready();
|
|
42
|
+
|
|
43
|
+
const appName = cnos.value('app.name');
|
|
44
|
+
const dbPassword = cnos.secret('db.password');
|
|
45
|
+
const profile = cnos.meta('profile');
|
|
46
|
+
const port = cnos.readOr('value.server.port', 3000);
|
|
47
|
+
const flags = cnos.toNamespace('flags');
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Typed values
|
|
51
|
+
|
|
52
|
+
CNOS values are not limited to strings. If the underlying config stores numbers, booleans, arrays, or objects, runtime reads return those values as-is.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
const enabled = cnos.value<boolean>('flags.upi_enabled');
|
|
56
|
+
const params = cnos.read<string[]>('value.api.default_query_params');
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## What does not exist
|
|
60
|
+
|
|
61
|
+
The current v1 runtime does not expose helper methods such as:
|
|
62
|
+
|
|
63
|
+
- `readAsString()`
|
|
64
|
+
- `readAsNumber()`
|
|
65
|
+
- `readAsBoolean()`
|
|
66
|
+
|
|
67
|
+
Use `read<T>()`, `require<T>()`, or the namespace helpers instead.
|
package/docs/cli/value.mdx
CHANGED
|
@@ -11,3 +11,38 @@ cnos value get app.name
|
|
|
11
11
|
cnos value list --prefix app.
|
|
12
12
|
cnos value delete app.name
|
|
13
13
|
```
|
|
14
|
+
|
|
15
|
+
## Typed input
|
|
16
|
+
|
|
17
|
+
`cnos value set` parses the input as YAML before writing it. That means you can store more than strings.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cnos value set server.port 3000
|
|
21
|
+
cnos value set flags.upi_enabled false
|
|
22
|
+
cnos value set api.default_query_params '["ab", "bc"]'
|
|
23
|
+
cnos value set app.theme '{ primary: blue, density: compact }'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Those values are stored and read back as:
|
|
27
|
+
|
|
28
|
+
- number
|
|
29
|
+
- boolean
|
|
30
|
+
- array
|
|
31
|
+
- object
|
|
32
|
+
|
|
33
|
+
## Read forms
|
|
34
|
+
|
|
35
|
+
The most common CLI read forms are:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
cnos value get app.name
|
|
39
|
+
cnos get value app.name
|
|
40
|
+
cnos get value.app.name
|
|
41
|
+
cnos read value.app.name
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Notes
|
|
45
|
+
|
|
46
|
+
- Values are private by default.
|
|
47
|
+
- To expose a value to browser/public surfaces, use `cnos promote`.
|
|
48
|
+
- To expose a value as shell env, map it through `envMapping.explicit` or `cnos promote --to env`.
|
package/docs/cli/vault.mdx
CHANGED
|
@@ -12,3 +12,5 @@ cnos vault list
|
|
|
12
12
|
cnos vault logout default
|
|
13
13
|
cnos vault remove default
|
|
14
14
|
```
|
|
15
|
+
|
|
16
|
+
For local vaults, `cnos vault create <name>` initializes the encrypted keystore immediately. CNOS prompts for a passphrase if one is not already available through `CNOS_SECRET_PASSPHRASE_<VAULT>`, `CNOS_SECRET_PASSPHRASE`, or the OS keychain. `cnos vault auth <name>` re-authenticates an existing vault and fails on wrong credentials.
|
|
@@ -9,6 +9,7 @@ description: Go from zero to a running CNOS-backed project in a few minutes.
|
|
|
9
9
|
cnos init
|
|
10
10
|
cnos value set app.name demo
|
|
11
11
|
cnos value set server.port 3000
|
|
12
|
+
cnos value set api.default_query_params '["ab", "bc"]'
|
|
12
13
|
cnos read value.app.name
|
|
13
14
|
cnos run -- node server.js
|
|
14
15
|
```
|
|
@@ -29,4 +30,5 @@ import { createCnos } from '@kitsy/cnos/configure';
|
|
|
29
30
|
|
|
30
31
|
const runtime = await createCnos();
|
|
31
32
|
console.log(runtime.value('app.name'));
|
|
33
|
+
console.log(runtime.read<string[]>('value.api.default_query_params'));
|
|
32
34
|
```
|
package/docs/guides/profiles.mdx
CHANGED
|
@@ -8,8 +8,14 @@ description: Create explicit overlays for stage, prod, and other environments.
|
|
|
8
8
|
Profiles are explicit overlays, not implicit defaults.
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
cnos profile create stage
|
|
11
|
+
cnos profile create stage
|
|
12
12
|
cnos use --profile stage
|
|
13
13
|
cnos value set app.apiBaseUrl https://api.stage
|
|
14
14
|
cnos diff base stage
|
|
15
15
|
```
|
|
16
|
+
|
|
17
|
+
Profiles inherit values from `base` by default. For a clean profile with no base fallback:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cnos profile create isolated --no-inherit
|
|
21
|
+
```
|
package/docs/guides/secrets.mdx
CHANGED
|
@@ -13,6 +13,8 @@ cnos vault auth default
|
|
|
13
13
|
cnos secret set app.token super-secret --vault default
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
`cnos vault create default` initializes the local encrypted vault immediately. If CNOS cannot resolve a passphrase from env or keychain, it prompts interactively. `cnos vault auth default` is only for re-authenticating an existing vault and rejects wrong passphrases.
|
|
17
|
+
|
|
16
18
|
CI-backed vault:
|
|
17
19
|
|
|
18
20
|
```bash
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Namespaces
|
|
3
|
-
description: Understand value, secret, meta, public, and
|
|
3
|
+
description: Understand value, secret, meta, public, env, and custom data namespaces.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Namespaces
|
|
@@ -10,8 +10,28 @@ Primary namespaces:
|
|
|
10
10
|
- `value.*`
|
|
11
11
|
- `secret.*`
|
|
12
12
|
- `meta.*`
|
|
13
|
+
- `process.*` for server-only ambient runtime state
|
|
14
|
+
- custom data namespaces such as `flags.*` or `config.*` when declared in `.cnos/cnos.yml`
|
|
13
15
|
|
|
14
16
|
Derived surfaces:
|
|
15
17
|
|
|
16
18
|
- `public.*` for promoted browser-safe values
|
|
17
19
|
- explicit env exports through `envMapping.explicit`
|
|
20
|
+
|
|
21
|
+
Custom data namespaces can be:
|
|
22
|
+
|
|
23
|
+
- read at runtime with `cnos('flags.upi_enabled')`
|
|
24
|
+
- written through the CLI with `cnos set flags.upi_enabled false`
|
|
25
|
+
- promoted to `public.*` when the namespace is `shareable: true`
|
|
26
|
+
- exported through `envMapping.explicit`
|
|
27
|
+
|
|
28
|
+
`process.*` is built in and read-only. Typical keys include:
|
|
29
|
+
|
|
30
|
+
- `process.cwd`
|
|
31
|
+
- `process.platform`
|
|
32
|
+
- `process.arch`
|
|
33
|
+
- `process.node.version`
|
|
34
|
+
- `process.args.raw`
|
|
35
|
+
- `process.env.PATH`
|
|
36
|
+
|
|
37
|
+
`process.*` cannot be promoted or exported.
|