@kitsy/cnos 1.1.1 → 1.2.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.
Files changed (62) hide show
  1. package/README.md +4 -1
  2. package/dist/browser/index.cjs +94 -0
  3. package/dist/browser/index.d.cts +16 -0
  4. package/dist/browser/index.d.ts +16 -0
  5. package/dist/browser/index.js +67 -0
  6. package/dist/build/index.cjs +2100 -0
  7. package/dist/build/index.d.cts +5 -0
  8. package/dist/build/index.d.ts +5 -0
  9. package/dist/build/index.js +14 -0
  10. package/dist/{chunk-JPJ3S3CO.js → chunk-APCTXRUN.js} +620 -426
  11. package/dist/{chunk-PBU5NAX4.js → chunk-EIN55XXA.js} +1 -1
  12. package/dist/chunk-JUHPBAEH.js +20 -0
  13. package/dist/{chunk-L3HOQHCH.js → chunk-MLQGYCO7.js} +1 -1
  14. package/dist/chunk-PQ4KSV76.js +50 -0
  15. package/dist/{chunk-7GNXYEO6.js → chunk-RD5WMHPM.js} +1 -1
  16. package/dist/chunk-SO5XREEU.js +179 -0
  17. package/dist/{chunk-QKJ6QLRS.js → chunk-SXTMTACL.js} +2 -2
  18. package/dist/{chunk-X4GOXEKX.js → chunk-WHUGFPE4.js} +1 -1
  19. package/dist/{chunk-M4S6PYM5.js → chunk-ZA74BO47.js} +1 -1
  20. package/dist/{envNaming-BrOk5ndZ.d.cts → envNaming-BTJpH93W.d.cts} +1 -1
  21. package/dist/{envNaming-DCaNdnrF.d.ts → envNaming-CcsqAel3.d.ts} +1 -1
  22. package/dist/index.cjs +294 -133
  23. package/dist/index.d.cts +4 -3
  24. package/dist/index.d.ts +4 -3
  25. package/dist/index.js +14 -132
  26. package/dist/internal.cjs +479 -61
  27. package/dist/internal.d.cts +29 -3
  28. package/dist/internal.d.ts +29 -3
  29. package/dist/internal.js +27 -1
  30. package/dist/plugin/basic-schema.cjs +3 -3
  31. package/dist/plugin/basic-schema.d.cts +1 -1
  32. package/dist/plugin/basic-schema.d.ts +1 -1
  33. package/dist/plugin/basic-schema.js +2 -2
  34. package/dist/plugin/cli-args.cjs +3 -3
  35. package/dist/plugin/cli-args.d.cts +1 -1
  36. package/dist/plugin/cli-args.d.ts +1 -1
  37. package/dist/plugin/cli-args.js +2 -2
  38. package/dist/plugin/dotenv.cjs +9 -9
  39. package/dist/plugin/dotenv.d.cts +2 -2
  40. package/dist/plugin/dotenv.d.ts +2 -2
  41. package/dist/plugin/dotenv.js +2 -2
  42. package/dist/plugin/env-export.cjs +46 -64
  43. package/dist/plugin/env-export.d.cts +2 -2
  44. package/dist/plugin/env-export.d.ts +2 -2
  45. package/dist/plugin/env-export.js +2 -2
  46. package/dist/plugin/filesystem.cjs +10 -10
  47. package/dist/plugin/filesystem.d.cts +1 -1
  48. package/dist/plugin/filesystem.d.ts +1 -1
  49. package/dist/plugin/filesystem.js +2 -2
  50. package/dist/plugin/process-env.cjs +9 -9
  51. package/dist/plugin/process-env.d.cts +2 -2
  52. package/dist/plugin/process-env.d.ts +2 -2
  53. package/dist/plugin/process-env.js +2 -2
  54. package/dist/{plugin-BVNEHj19.d.cts → plugin-DkOIT5uI.d.cts} +30 -2
  55. package/dist/{plugin-BVNEHj19.d.ts → plugin-DkOIT5uI.d.ts} +30 -2
  56. package/dist/runtime/index.cjs +2288 -0
  57. package/dist/runtime/index.d.cts +23 -0
  58. package/dist/runtime/index.d.ts +23 -0
  59. package/dist/runtime/index.js +190 -0
  60. package/dist/{toPublicEnv-Gwz3xTK0.d.ts → toPublicEnv-C9clvXLo.d.ts} +1 -1
  61. package/dist/{toPublicEnv-Dd152fFy.d.cts → toPublicEnv-DvFeV3qG.d.cts} +1 -1
  62. package/package.json +16 -1
@@ -0,0 +1,23 @@
1
+ import { g as LogicalKey } from '../plugin-DkOIT5uI.cjs';
2
+
3
+ interface CnosSingleton {
4
+ <T = unknown>(key: LogicalKey): T | undefined;
5
+ read<T = unknown>(key: LogicalKey): T | undefined;
6
+ require<T = unknown>(key: LogicalKey): T;
7
+ readOr<T>(key: LogicalKey, fallback: T): T;
8
+ value<T = unknown>(path: string): T | undefined;
9
+ secret<T = unknown>(path: string): T | undefined;
10
+ meta<T = unknown>(path: string): T | undefined;
11
+ ready(): Promise<void>;
12
+ }
13
+ declare const cnos: CnosSingleton & {
14
+ read<T = unknown>(key: LogicalKey): T | undefined;
15
+ require<T = unknown>(key: LogicalKey): T;
16
+ readOr<T>(key: LogicalKey, fallback: T): T;
17
+ value<T = unknown>(path: string): T | undefined;
18
+ secret<T = unknown>(path: string): T | undefined;
19
+ meta<T = unknown>(path: string): T | undefined;
20
+ ready(): Promise<void>;
21
+ };
22
+
23
+ export { type CnosSingleton, cnos as default };
@@ -0,0 +1,23 @@
1
+ import { g as LogicalKey } from '../plugin-DkOIT5uI.js';
2
+
3
+ interface CnosSingleton {
4
+ <T = unknown>(key: LogicalKey): T | undefined;
5
+ read<T = unknown>(key: LogicalKey): T | undefined;
6
+ require<T = unknown>(key: LogicalKey): T;
7
+ readOr<T>(key: LogicalKey, fallback: T): T;
8
+ value<T = unknown>(path: string): T | undefined;
9
+ secret<T = unknown>(path: string): T | undefined;
10
+ meta<T = unknown>(path: string): T | undefined;
11
+ ready(): Promise<void>;
12
+ }
13
+ declare const cnos: CnosSingleton & {
14
+ read<T = unknown>(key: LogicalKey): T | undefined;
15
+ require<T = unknown>(key: LogicalKey): T;
16
+ readOr<T>(key: LogicalKey, fallback: T): T;
17
+ value<T = unknown>(path: string): T | undefined;
18
+ secret<T = unknown>(path: string): T | undefined;
19
+ meta<T = unknown>(path: string): T | undefined;
20
+ ready(): Promise<void>;
21
+ };
22
+
23
+ export { type CnosSingleton, cnos as default };
@@ -0,0 +1,190 @@
1
+ import {
2
+ readRuntimeGraphFromEnv
3
+ } from "../chunk-PQ4KSV76.js";
4
+ import {
5
+ createCnos,
6
+ getSingletonReady,
7
+ getSingletonRuntime,
8
+ setSingletonReady,
9
+ setSingletonRuntime
10
+ } from "../chunk-SO5XREEU.js";
11
+ import "../chunk-SXTMTACL.js";
12
+ import "../chunk-WHUGFPE4.js";
13
+ import "../chunk-MLQGYCO7.js";
14
+ import "../chunk-ZA74BO47.js";
15
+ import "../chunk-RD5WMHPM.js";
16
+ import "../chunk-EIN55XXA.js";
17
+ import {
18
+ inspectValue,
19
+ readOrValue,
20
+ readValue,
21
+ requireValue,
22
+ toEnv,
23
+ toLogicalKey,
24
+ toNamespaceObject,
25
+ toPublicEnv
26
+ } from "../chunk-APCTXRUN.js";
27
+
28
+ // src/runtime/index.ts
29
+ var NOT_READY_MESSAGE = "CNOS not initialized. Call await cnos.ready() or use cnos run.";
30
+ function getRuntimeOrThrow() {
31
+ const runtime = getSingletonRuntime();
32
+ if (!runtime) {
33
+ throw new Error(NOT_READY_MESSAGE);
34
+ }
35
+ return runtime;
36
+ }
37
+ function attachBootstrappedGraph(graph) {
38
+ if (getSingletonRuntime()) {
39
+ return;
40
+ }
41
+ const bootstrappedManifest = {
42
+ version: 1,
43
+ project: {
44
+ name: "bootstrapped"
45
+ },
46
+ workspaces: {
47
+ global: {
48
+ enabled: Boolean(graph.workspace.globalRoot),
49
+ ...graph.workspace.globalRoot ? {
50
+ root: graph.workspace.globalRoot
51
+ } : {},
52
+ allowWrite: false
53
+ },
54
+ items: {},
55
+ ...graph.workspace.workspaceSource === "implicit" ? {} : {
56
+ default: graph.workspace.workspaceId
57
+ }
58
+ },
59
+ profiles: {
60
+ default: graph.profile,
61
+ resolveFrom: ["default"]
62
+ },
63
+ plugins: {
64
+ loaders: [],
65
+ resolver: "profile-aware",
66
+ validators: [],
67
+ exporters: [],
68
+ inspectors: []
69
+ },
70
+ sources: {},
71
+ resolution: {
72
+ precedence: [],
73
+ arrayPolicy: "replace"
74
+ },
75
+ envMapping: {
76
+ explicit: {}
77
+ },
78
+ public: {
79
+ promote: [],
80
+ frameworks: {}
81
+ },
82
+ namespaces: {},
83
+ vaults: {},
84
+ writePolicy: {
85
+ define: {
86
+ defaultProfile: graph.profile,
87
+ targets: {
88
+ value: "./values/app.yml",
89
+ secret: "./secrets/app.yml"
90
+ }
91
+ }
92
+ },
93
+ schema: {}
94
+ };
95
+ const runtime = {
96
+ manifest: bootstrappedManifest,
97
+ plugins: [],
98
+ graph,
99
+ read(key) {
100
+ return readValue(graph, key);
101
+ },
102
+ require(key) {
103
+ return requireValue(graph, key);
104
+ },
105
+ readOr(key, fallback) {
106
+ return readOrValue(graph, key, fallback);
107
+ },
108
+ value(path) {
109
+ return readValue(graph, toLogicalKey("value", path));
110
+ },
111
+ secret(path) {
112
+ return readValue(graph, toLogicalKey("secret", path));
113
+ },
114
+ meta(path) {
115
+ return readValue(graph, toLogicalKey("meta", path));
116
+ },
117
+ inspect(key) {
118
+ return inspectValue(graph, key);
119
+ },
120
+ toObject() {
121
+ return toNamespaceObject(graph);
122
+ },
123
+ toNamespace(namespace) {
124
+ return toNamespaceObject(graph, namespace);
125
+ },
126
+ toEnv(options) {
127
+ return toEnv(graph, bootstrappedManifest, options);
128
+ },
129
+ toPublicEnv(options) {
130
+ return toPublicEnv(graph, bootstrappedManifest, options);
131
+ }
132
+ };
133
+ setSingletonRuntime(runtime);
134
+ }
135
+ function bootstrapFromProcessEnv() {
136
+ if (typeof process === "undefined") {
137
+ return;
138
+ }
139
+ try {
140
+ const graph = readRuntimeGraphFromEnv(process.env);
141
+ if (graph) {
142
+ attachBootstrappedGraph(graph);
143
+ }
144
+ } catch {
145
+ }
146
+ }
147
+ bootstrapFromProcessEnv();
148
+ var cnos = Object.assign(
149
+ ((key) => readValue(getRuntimeOrThrow().graph, key)),
150
+ {
151
+ read(key) {
152
+ return readValue(getRuntimeOrThrow().graph, key);
153
+ },
154
+ require(key) {
155
+ return requireValue(getRuntimeOrThrow().graph, key);
156
+ },
157
+ readOr(key, fallback) {
158
+ return readOrValue(getRuntimeOrThrow().graph, key, fallback);
159
+ },
160
+ value(path) {
161
+ return readValue(getRuntimeOrThrow().graph, toLogicalKey("value", path));
162
+ },
163
+ secret(path) {
164
+ return readValue(getRuntimeOrThrow().graph, toLogicalKey("secret", path));
165
+ },
166
+ meta(path) {
167
+ return readValue(getRuntimeOrThrow().graph, toLogicalKey("meta", path));
168
+ },
169
+ async ready() {
170
+ if (getSingletonRuntime()) {
171
+ return;
172
+ }
173
+ const existing = getSingletonReady();
174
+ if (existing) {
175
+ await existing;
176
+ return;
177
+ }
178
+ const readyPromise = createCnos().then((runtime) => {
179
+ setSingletonRuntime(runtime);
180
+ return runtime;
181
+ });
182
+ setSingletonReady(readyPromise);
183
+ await readyPromise;
184
+ }
185
+ }
186
+ );
187
+ var runtime_default = cnos;
188
+ export {
189
+ runtime_default as default
190
+ };
@@ -1,4 +1,4 @@
1
- import { R as ResolvedGraph, N as NormalizedManifest, T as ToEnvOptions, h as ToPublicEnvOptions } from './plugin-BVNEHj19.js';
1
+ import { R as ResolvedGraph, N as NormalizedManifest, T as ToEnvOptions, h as ToPublicEnvOptions } from './plugin-DkOIT5uI.js';
2
2
 
3
3
  declare function toEnv(graph: ResolvedGraph, manifest: NormalizedManifest, options?: ToEnvOptions): Record<string, string>;
4
4
 
@@ -1,4 +1,4 @@
1
- import { R as ResolvedGraph, N as NormalizedManifest, T as ToEnvOptions, h as ToPublicEnvOptions } from './plugin-BVNEHj19.cjs';
1
+ import { R as ResolvedGraph, N as NormalizedManifest, T as ToEnvOptions, h as ToPublicEnvOptions } from './plugin-DkOIT5uI.cjs';
2
2
 
3
3
  declare function toEnv(graph: ResolvedGraph, manifest: NormalizedManifest, options?: ToEnvOptions): Record<string, string>;
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitsy/cnos",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Batteries-included CNOS runtime package wired with the official plugins.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -17,6 +17,21 @@
17
17
  "import": "./dist/internal.js",
18
18
  "require": "./dist/internal.cjs"
19
19
  },
20
+ "./runtime": {
21
+ "types": "./dist/runtime/index.d.ts",
22
+ "import": "./dist/runtime/index.js",
23
+ "require": "./dist/runtime/index.cjs"
24
+ },
25
+ "./browser": {
26
+ "types": "./dist/browser/index.d.ts",
27
+ "import": "./dist/browser/index.js",
28
+ "require": "./dist/browser/index.cjs"
29
+ },
30
+ "./build": {
31
+ "types": "./dist/build/index.d.ts",
32
+ "import": "./dist/build/index.js",
33
+ "require": "./dist/build/index.cjs"
34
+ },
20
35
  "./plugins/filesystem": {
21
36
  "types": "./dist/plugin/filesystem.d.ts",
22
37
  "import": "./dist/plugin/filesystem.js",