@powerhousedao/shared 6.1.0-staging.0 → 6.2.0-dev.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 (105) hide show
  1. package/dist/analytics/index.d.ts +1 -1
  2. package/dist/clis/args/access-token.mjs +1 -1
  3. package/dist/clis/args/common-BQ2pvhCr.d.mts.map +1 -1
  4. package/dist/clis/args/{common-DPYlcz-d.mjs → common-fPNESurz.mjs} +4 -9
  5. package/dist/clis/args/common-fPNESurz.mjs.map +1 -0
  6. package/dist/clis/args/common.mjs +1 -1
  7. package/dist/clis/args/connect.d.mts +219 -13
  8. package/dist/clis/args/connect.d.mts.map +1 -1
  9. package/dist/clis/args/connect.mjs +138 -4
  10. package/dist/clis/args/connect.mjs.map +1 -1
  11. package/dist/clis/args/{generate-BJPBa0mK.mjs → generate-CTTdiwMD.mjs} +2 -2
  12. package/dist/clis/args/{generate-BJPBa0mK.mjs.map → generate-CTTdiwMD.mjs.map} +1 -1
  13. package/dist/clis/args/generate.mjs +1 -1
  14. package/dist/clis/args/{help-rztSuf9S.mjs → help-CfBzQJpL.mjs} +3 -3
  15. package/dist/clis/args/{help-rztSuf9S.mjs.map → help-CfBzQJpL.mjs.map} +1 -1
  16. package/dist/clis/args/help.mjs +1 -1
  17. package/dist/clis/args/index.d.mts +3 -3
  18. package/dist/clis/args/index.mjs +5 -5
  19. package/dist/clis/args/init.d.mts +3 -0
  20. package/dist/clis/args/init.d.mts.map +1 -1
  21. package/dist/clis/args/init.mjs +6 -1
  22. package/dist/clis/args/init.mjs.map +1 -1
  23. package/dist/clis/args/inspect.mjs +1 -1
  24. package/dist/clis/args/install.mjs +1 -1
  25. package/dist/clis/args/list.mjs +1 -1
  26. package/dist/clis/args/login.mjs +1 -1
  27. package/dist/clis/args/migrate.mjs +1 -1
  28. package/dist/clis/args/publish.mjs +1 -1
  29. package/dist/clis/args/registry.mjs +1 -1
  30. package/dist/clis/args/{service-LXIFUZ_8.d.mts → service-DbbCQSks.d.mts} +2 -2
  31. package/dist/clis/args/service-DbbCQSks.d.mts.map +1 -0
  32. package/dist/clis/args/service.d.mts +1 -1
  33. package/dist/clis/args/service.mjs +1 -1
  34. package/dist/clis/args/switchboard.mjs +1 -1
  35. package/dist/clis/args/uninstall.mjs +1 -1
  36. package/dist/clis/args/unpublish.mjs +1 -1
  37. package/dist/clis/args/vetra.mjs +1 -1
  38. package/dist/clis/build-config.d.mts.map +1 -1
  39. package/dist/clis/build-config.mjs +2 -1
  40. package/dist/clis/build-config.mjs.map +1 -1
  41. package/dist/clis/constants.d.mts +62 -4
  42. package/dist/clis/constants.d.mts.map +1 -1
  43. package/dist/clis/constants.mjs +8 -3
  44. package/dist/clis/constants.mjs.map +1 -1
  45. package/dist/clis/index.d.mts +690 -16
  46. package/dist/clis/index.d.mts.map +1 -1
  47. package/dist/clis/index.mjs +546 -12
  48. package/dist/clis/index.mjs.map +1 -1
  49. package/dist/config-loader-DORViRnN.js +144 -0
  50. package/dist/config-loader-DORViRnN.js.map +1 -0
  51. package/dist/connect/config-loader.d.ts +78 -0
  52. package/dist/connect/config-loader.d.ts.map +1 -0
  53. package/dist/connect/config-loader.js +2 -0
  54. package/dist/connect/index.d.ts +295 -245
  55. package/dist/connect/index.d.ts.map +1 -1
  56. package/dist/connect/index.js +264 -103
  57. package/dist/connect/index.js.map +1 -1
  58. package/dist/connect/json-adapter.d.ts +24 -0
  59. package/dist/connect/json-adapter.d.ts.map +1 -0
  60. package/dist/connect/json-adapter.js +28 -0
  61. package/dist/connect/json-adapter.js.map +1 -0
  62. package/dist/{constants-xNwF0jSl.d.ts → constants-C_EQX4DY.d.ts} +1 -1
  63. package/dist/constants-C_EQX4DY.d.ts.map +1 -0
  64. package/dist/constants.d.ts +1 -1
  65. package/dist/document-drive/index.d.ts +2 -2
  66. package/dist/document-drive/index.d.ts.map +1 -1
  67. package/dist/document-drive/index.js +6 -10
  68. package/dist/document-drive/index.js.map +1 -1
  69. package/dist/document-model/index.d.ts +5 -5
  70. package/dist/document-model/index.js +212 -64
  71. package/dist/document-model/index.js.map +1 -1
  72. package/dist/document-model/mock.d.ts +1 -1
  73. package/dist/document-model/utils.d.ts +2 -2
  74. package/dist/document-model/utils.js +1 -1
  75. package/dist/{index-C_iVZe7f.d.ts → index-CQDIrK1k.d.ts} +1 -1
  76. package/dist/index-CQDIrK1k.d.ts.map +1 -0
  77. package/dist/{index-DkRWfM_V.d.ts → index-DalC_-i7.d.ts} +46 -3
  78. package/dist/{index-DkRWfM_V.d.ts.map → index-DalC_-i7.d.ts.map} +1 -1
  79. package/dist/index.d.ts +7 -6
  80. package/dist/{mock-Cgn-VBF_.d.ts → mock-CbrXTFOF.d.ts} +1 -1
  81. package/dist/{mock-Cgn-VBF_.d.ts.map → mock-CbrXTFOF.d.ts.map} +1 -1
  82. package/dist/processors/index.d.ts +1 -1
  83. package/dist/registry/index.d.ts +2 -1
  84. package/dist/registry/index.d.ts.map +1 -1
  85. package/dist/registry/index.js.map +1 -1
  86. package/dist/{types-BFDlQkXZ.d.ts → types-C1in4fl3.d.ts} +1 -1
  87. package/dist/{types-BFDlQkXZ.d.ts.map → types-C1in4fl3.d.ts.map} +1 -1
  88. package/dist/{actions-UH5nIJcP.d.ts → types-CC6ib3_2.d.ts} +1330 -1330
  89. package/dist/types-CC6ib3_2.d.ts.map +1 -0
  90. package/dist/{types-WzwAClp2.d.ts → types-CVqmv94G.d.ts} +3 -109
  91. package/dist/types-CVqmv94G.d.ts.map +1 -0
  92. package/dist/types-Daq_zHP_.d.ts +160 -0
  93. package/dist/types-Daq_zHP_.d.ts.map +1 -0
  94. package/dist/{utils-CJF4w5Bp.d.ts → utils-BEByNOHo.d.ts} +1 -1
  95. package/dist/utils-BEByNOHo.d.ts.map +1 -0
  96. package/dist/{utils-bCWnsmtD.js → utils-DKOFCM0Q.js} +1 -1
  97. package/dist/{utils-bCWnsmtD.js.map → utils-DKOFCM0Q.js.map} +1 -1
  98. package/package.json +6 -3
  99. package/dist/actions-UH5nIJcP.d.ts.map +0 -1
  100. package/dist/clis/args/common-DPYlcz-d.mjs.map +0 -1
  101. package/dist/clis/args/service-LXIFUZ_8.d.mts.map +0 -1
  102. package/dist/constants-xNwF0jSl.d.ts.map +0 -1
  103. package/dist/index-C_iVZe7f.d.ts.map +0 -1
  104. package/dist/types-WzwAClp2.d.ts.map +0 -1
  105. package/dist/utils-CJF4w5Bp.d.ts.map +0 -1
@@ -0,0 +1,144 @@
1
+ import { isPlainObject } from "remeda";
2
+ //#region connect/runtime-config.ts
3
+ /**
4
+ * Default values for every Connect-relevant field. Merged with the
5
+ * `connect.*` block of whatever `powerhouse.config.json` Connect is pointed
6
+ * at, so the SPA never has to guard against undefined fields.
7
+ *
8
+ * Scoped to fields Connect actually reads at runtime — build-time concerns
9
+ * (studio port, switchboard port, reactor.*, auth.*) live in the source
10
+ * config but are not Connect's business and not represented here.
11
+ *
12
+ * Single source of truth for defaults across Connect's runtime read (via
13
+ * ConfigLoader merge), the dist emitter, and the codegen scaffold template.
14
+ */
15
+ const DEFAULT_CONNECT_CONFIG = {
16
+ branding: {
17
+ appName: "Powerhouse Connect",
18
+ homeBackground: null
19
+ },
20
+ app: {
21
+ logLevel: "info",
22
+ basePath: "/"
23
+ },
24
+ packages: {
25
+ externalEnabled: true,
26
+ liveReload: false
27
+ },
28
+ drives: {
29
+ allowAddDrive: true,
30
+ defaultDrives: [],
31
+ sections: {
32
+ remote: {
33
+ enabled: true,
34
+ allowAdd: true,
35
+ allowDelete: true
36
+ },
37
+ local: {
38
+ enabled: true,
39
+ allowAdd: true,
40
+ allowDelete: true
41
+ }
42
+ }
43
+ },
44
+ renown: {
45
+ url: "https://www.renown.id",
46
+ networkId: "eip155",
47
+ chainId: 1
48
+ },
49
+ sentry: {
50
+ dsn: null,
51
+ env: "dev",
52
+ tracing: false
53
+ }
54
+ };
55
+ function buildRuntimeConfig(source, projectInfo) {
56
+ const result = {
57
+ schemaVersion: 2,
58
+ packages: source.packages ?? [],
59
+ localPackage: projectInfo,
60
+ connect: source.connect ?? {}
61
+ };
62
+ if (typeof source.packageRegistryUrl === "string" && source.packageRegistryUrl !== "") result.packageRegistryUrl = source.packageRegistryUrl;
63
+ return result;
64
+ }
65
+ //#endregion
66
+ //#region connect/config-loader.ts
67
+ /**
68
+ * Deep-merge `patch` into `base`. Object fields recurse; arrays and
69
+ * primitives replace. `undefined` in patch leaves the base value
70
+ * untouched (no unset). `null` in patch overwrites with null.
71
+ *
72
+ * Exported for unit tests; consumers use ConfigLoader.write() which
73
+ * applies this internally.
74
+ */
75
+ function deepMerge(base, patch) {
76
+ if (!isPlainObject(base) || !isPlainObject(patch)) return patch;
77
+ const result = { ...base };
78
+ for (const [key, patchValue] of Object.entries(patch)) {
79
+ if (patchValue === void 0) continue;
80
+ const baseValue = result[key];
81
+ if (isPlainObject(baseValue) && isPlainObject(patchValue)) result[key] = deepMerge(baseValue, patchValue);
82
+ else result[key] = patchValue;
83
+ }
84
+ return result;
85
+ }
86
+ /**
87
+ * Pluggable loader on top of a `ConfigAdapter`.
88
+ *
89
+ * Responsibilities:
90
+ * - merge-with-defaults on read (so consumers never see a partial connect block)
91
+ * - in-process caching (call `invalidate()` to force re-read)
92
+ * - deep-merge for partial writes; writes the merged whole back through the adapter
93
+ *
94
+ * The cache is module-instance scoped — every `new ConfigLoader(...)` has
95
+ * its own cache. The browser SPA constructs the loader once at boot; the
96
+ * CLI typically constructs a fresh loader per command.
97
+ */
98
+ var ConfigLoader = class {
99
+ cache;
100
+ constructor(adapter, defaults = DEFAULT_CONNECT_CONFIG) {
101
+ this.adapter = adapter;
102
+ this.defaults = defaults;
103
+ }
104
+ /** Returns the config with the default connect block merged in.
105
+ * Cached after the first successful call. */
106
+ async read() {
107
+ if (this.cache) return this.cache;
108
+ const raw = await this.adapter.read();
109
+ const obj = isPlainObject(raw) ? raw : {};
110
+ const connectRaw = isPlainObject(obj.connect) ? obj.connect : {};
111
+ this.cache = {
112
+ ...obj,
113
+ connect: deepMerge(this.defaults, connectRaw)
114
+ };
115
+ return this.cache;
116
+ }
117
+ /**
118
+ * Returns the cached config synchronously. Throws if `read()` has not
119
+ * resolved yet — matches Connect's `getRuntimeConfig()` shape.
120
+ */
121
+ getCached() {
122
+ if (!this.cache) throw new Error(`ConfigLoader (${this.adapter.source}): cache empty; call read() first.`);
123
+ return this.cache;
124
+ }
125
+ /** Drop the in-memory cache. Next `read()` re-fetches from the adapter. */
126
+ invalidate() {
127
+ this.cache = void 0;
128
+ }
129
+ /**
130
+ * Deep-merge `patch` into the current config and persist via the adapter.
131
+ * Returns the new full config (also updates the cache). Arrays in `patch`
132
+ * replace — they do NOT append.
133
+ */
134
+ async write(patch) {
135
+ const next = deepMerge(await this.read(), patch);
136
+ await this.adapter.write(next);
137
+ this.cache = next;
138
+ return next;
139
+ }
140
+ };
141
+ //#endregion
142
+ export { buildRuntimeConfig as i, deepMerge as n, DEFAULT_CONNECT_CONFIG as r, ConfigLoader as t };
143
+
144
+ //# sourceMappingURL=config-loader-DORViRnN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-loader-DORViRnN.js","names":[],"sources":["../connect/runtime-config.ts","../connect/config-loader.ts"],"sourcesContent":["import type {\n PHConnectRuntimeConfig,\n PowerhouseConfig,\n PowerhousePackage,\n} from \"../clis/types.js\";\n\nexport type RuntimePowerhouseConfig = {\n schemaVersion: 2;\n packages: PowerhousePackage[];\n packageRegistryUrl?: string;\n localPackage: { name: string; version: string } | null;\n connect: PHConnectRuntimeConfig;\n};\n\n/**\n * Default values for every Connect-relevant field. Merged with the\n * `connect.*` block of whatever `powerhouse.config.json` Connect is pointed\n * at, so the SPA never has to guard against undefined fields.\n *\n * Scoped to fields Connect actually reads at runtime — build-time concerns\n * (studio port, switchboard port, reactor.*, auth.*) live in the source\n * config but are not Connect's business and not represented here.\n *\n * Single source of truth for defaults across Connect's runtime read (via\n * ConfigLoader merge), the dist emitter, and the codegen scaffold template.\n */\nexport const DEFAULT_CONNECT_CONFIG: PHConnectRuntimeConfig = {\n branding: {\n appName: \"Powerhouse Connect\",\n homeBackground: null,\n },\n app: {\n logLevel: \"info\",\n basePath: \"/\",\n },\n packages: {\n externalEnabled: true,\n liveReload: false,\n },\n drives: {\n allowAddDrive: true,\n defaultDrives: [],\n sections: {\n remote: { enabled: true, allowAdd: true, allowDelete: true },\n local: { enabled: true, allowAdd: true, allowDelete: true },\n },\n },\n renown: {\n url: \"https://www.renown.id\",\n networkId: \"eip155\",\n chainId: 1,\n },\n sentry: {\n // `dsn: null` is the disabled-Sentry state — the SPA never loads the\n // Sentry SDK chunk. Override via `ph connect config --sentry-dsn ...`\n // or by including `connect.sentry.dsn` in PH_CONNECT_CONFIG_JSON.\n dsn: null,\n env: \"dev\",\n tracing: false,\n },\n};\n\nexport function buildRuntimeConfig(\n source: Pick<PowerhouseConfig, \"packages\" | \"connect\" | \"packageRegistryUrl\">,\n projectInfo: { name: string; version: string } | null,\n): RuntimePowerhouseConfig {\n const result: RuntimePowerhouseConfig = {\n schemaVersion: 2,\n packages: source.packages ?? [],\n localPackage: projectInfo,\n connect: source.connect ?? {},\n };\n if (\n typeof source.packageRegistryUrl === \"string\" &&\n source.packageRegistryUrl !== \"\"\n ) {\n result.packageRegistryUrl = source.packageRegistryUrl;\n }\n return result;\n}\n","// Environment-neutral config loader. Wraps a `ConfigAdapter` (the IO layer)\n// with in-process caching and deep-merge-with-defaults reads.\n//\n// No validation. The loader trusts that whatever bytes the adapter returns\n// can be merged into the default Connect config; missing or partial fields\n// fall back to DEFAULT_CONNECT_CONFIG, so the SPA always sees a complete\n// `connect.*` block.\n//\n// Top-level fields outside `connect.*` (e.g. `studio.port` in the source\n// powerhouse.config.json) pass through untouched on both read and write.\n// They're not Connect's concern, but a write-back round-trip preserves\n// them so editing tools don't accidentally drop them.\n\nimport { isPlainObject } from \"remeda\";\nimport type { PHConnectRuntimeConfig } from \"../clis/types.js\";\nimport { DEFAULT_CONNECT_CONFIG } from \"./runtime-config.js\";\n\n/** Recursive Partial. Arrays are leaves — `write({ packages: [...] })`\n * replaces the array, it doesn't merge. */\nexport type DeepPartial<T> =\n T extends Array<infer U>\n ? Array<U>\n : T extends object\n ? { [K in keyof T]?: DeepPartial<T[K]> }\n : T;\n\n/**\n * Shape returned by `ConfigLoader.read()`. The loader is Connect-scoped:\n * it guarantees `connect` is present and fully populated from\n * DEFAULT_CONNECT_CONFIG, but lets any other top-level fields pass\n * through unchanged so source-config-only fields (studio, reactor, auth,\n * documentModelsDir, etc.) survive a read+write round-trip.\n */\nexport type ConfigShape = Record<string, unknown> & {\n connect: PHConnectRuntimeConfig;\n};\n\n/**\n * Abstract IO layer for `powerhouse.config.json`.\n *\n * Implementations decide where bytes come from and go to. The shipped\n * adapter is `JsonConfigAdapter` (reads via fetch in the browser, fs in\n * Node; writes via fs in Node, throws in the browser). Future adapters\n * (remote-JSON, GraphQL) plug in without changing the loader or any\n * consumer.\n */\nexport interface ConfigAdapter {\n /** Read raw JSON-parsed payload from the backing store. */\n read(): Promise<unknown>;\n /** Persist a fully-formed config. */\n write(next: ConfigShape): Promise<void>;\n /** Human-readable description used in errors and logs. */\n readonly source: string;\n}\n\n/**\n * Deep-merge `patch` into `base`. Object fields recurse; arrays and\n * primitives replace. `undefined` in patch leaves the base value\n * untouched (no unset). `null` in patch overwrites with null.\n *\n * Exported for unit tests; consumers use ConfigLoader.write() which\n * applies this internally.\n */\nexport function deepMerge<T>(base: T, patch: DeepPartial<T>): T {\n if (!isPlainObject(base) || !isPlainObject(patch)) {\n return patch as T;\n }\n const result: Record<string, unknown> = { ...base };\n for (const [key, patchValue] of Object.entries(patch)) {\n if (patchValue === undefined) continue;\n const baseValue = result[key];\n if (isPlainObject(baseValue) && isPlainObject(patchValue)) {\n result[key] = deepMerge(\n baseValue,\n patchValue as DeepPartial<typeof baseValue>,\n );\n } else {\n result[key] = patchValue;\n }\n }\n return result as T;\n}\n\n/**\n * Pluggable loader on top of a `ConfigAdapter`.\n *\n * Responsibilities:\n * - merge-with-defaults on read (so consumers never see a partial connect block)\n * - in-process caching (call `invalidate()` to force re-read)\n * - deep-merge for partial writes; writes the merged whole back through the adapter\n *\n * The cache is module-instance scoped — every `new ConfigLoader(...)` has\n * its own cache. The browser SPA constructs the loader once at boot; the\n * CLI typically constructs a fresh loader per command.\n */\nexport class ConfigLoader {\n private cache: ConfigShape | undefined;\n\n constructor(\n private readonly adapter: ConfigAdapter,\n private readonly defaults: PHConnectRuntimeConfig = DEFAULT_CONNECT_CONFIG,\n ) {}\n\n /** Returns the config with the default connect block merged in.\n * Cached after the first successful call. */\n async read(): Promise<ConfigShape> {\n if (this.cache) return this.cache;\n const raw = await this.adapter.read();\n const obj = isPlainObject(raw) ? raw : {};\n const connectRaw = isPlainObject(obj.connect) ? obj.connect : {};\n this.cache = {\n ...obj,\n connect: deepMerge(\n this.defaults,\n connectRaw as DeepPartial<PHConnectRuntimeConfig>,\n ),\n };\n return this.cache;\n }\n\n /**\n * Returns the cached config synchronously. Throws if `read()` has not\n * resolved yet — matches Connect's `getRuntimeConfig()` shape.\n */\n getCached(): ConfigShape {\n if (!this.cache) {\n throw new Error(\n `ConfigLoader (${this.adapter.source}): cache empty; call read() first.`,\n );\n }\n return this.cache;\n }\n\n /** Drop the in-memory cache. Next `read()` re-fetches from the adapter. */\n invalidate(): void {\n this.cache = undefined;\n }\n\n /**\n * Deep-merge `patch` into the current config and persist via the adapter.\n * Returns the new full config (also updates the cache). Arrays in `patch`\n * replace — they do NOT append.\n */\n async write(patch: DeepPartial<ConfigShape>): Promise<ConfigShape> {\n const current = await this.read();\n const next = deepMerge(current, patch);\n await this.adapter.write(next);\n this.cache = next;\n return next;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAa,yBAAiD;CAC5D,UAAU;EACR,SAAS;EACT,gBAAgB;EACjB;CACD,KAAK;EACH,UAAU;EACV,UAAU;EACX;CACD,UAAU;EACR,iBAAiB;EACjB,YAAY;EACb;CACD,QAAQ;EACN,eAAe;EACf,eAAe,EAAE;EACjB,UAAU;GACR,QAAQ;IAAE,SAAS;IAAM,UAAU;IAAM,aAAa;IAAM;GAC5D,OAAO;IAAE,SAAS;IAAM,UAAU;IAAM,aAAa;IAAM;GAC5D;EACF;CACD,QAAQ;EACN,KAAK;EACL,WAAW;EACX,SAAS;EACV;CACD,QAAQ;EAIN,KAAK;EACL,KAAK;EACL,SAAS;EACV;CACF;AAED,SAAgB,mBACd,QACA,aACyB;CACzB,MAAM,SAAkC;EACtC,eAAe;EACf,UAAU,OAAO,YAAY,EAAE;EAC/B,cAAc;EACd,SAAS,OAAO,WAAW,EAAE;EAC9B;AACD,KACE,OAAO,OAAO,uBAAuB,YACrC,OAAO,uBAAuB,GAE9B,QAAO,qBAAqB,OAAO;AAErC,QAAO;;;;;;;;;;;;ACfT,SAAgB,UAAa,MAAS,OAA0B;AAC9D,KAAI,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,MAAM,CAC/C,QAAO;CAET,MAAM,SAAkC,EAAE,GAAG,MAAM;AACnD,MAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,MAAM,EAAE;AACrD,MAAI,eAAe,KAAA,EAAW;EAC9B,MAAM,YAAY,OAAO;AACzB,MAAI,cAAc,UAAU,IAAI,cAAc,WAAW,CACvD,QAAO,OAAO,UACZ,WACA,WACD;MAED,QAAO,OAAO;;AAGlB,QAAO;;;;;;;;;;;;;;AAeT,IAAa,eAAb,MAA0B;CACxB;CAEA,YACE,SACA,WAAoD,wBACpD;AAFiB,OAAA,UAAA;AACA,OAAA,WAAA;;;;CAKnB,MAAM,OAA6B;AACjC,MAAI,KAAK,MAAO,QAAO,KAAK;EAC5B,MAAM,MAAM,MAAM,KAAK,QAAQ,MAAM;EACrC,MAAM,MAAM,cAAc,IAAI,GAAG,MAAM,EAAE;EACzC,MAAM,aAAa,cAAc,IAAI,QAAQ,GAAG,IAAI,UAAU,EAAE;AAChE,OAAK,QAAQ;GACX,GAAG;GACH,SAAS,UACP,KAAK,UACL,WACD;GACF;AACD,SAAO,KAAK;;;;;;CAOd,YAAyB;AACvB,MAAI,CAAC,KAAK,MACR,OAAM,IAAI,MACR,iBAAiB,KAAK,QAAQ,OAAO,oCACtC;AAEH,SAAO,KAAK;;;CAId,aAAmB;AACjB,OAAK,QAAQ,KAAA;;;;;;;CAQf,MAAM,MAAM,OAAuD;EAEjE,MAAM,OAAO,UADG,MAAM,KAAK,MAAM,EACD,MAAM;AACtC,QAAM,KAAK,QAAQ,MAAM,KAAK;AAC9B,OAAK,QAAQ;AACb,SAAO"}
@@ -0,0 +1,78 @@
1
+ import { p as PHConnectRuntimeConfig } from "../types-Daq_zHP_.js";
2
+ //#region connect/config-loader.d.ts
3
+ /** Recursive Partial. Arrays are leaves — `write({ packages: [...] })`
4
+ * replaces the array, it doesn't merge. */
5
+ type DeepPartial<T> = T extends Array<infer U> ? Array<U> : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
6
+ /**
7
+ * Shape returned by `ConfigLoader.read()`. The loader is Connect-scoped:
8
+ * it guarantees `connect` is present and fully populated from
9
+ * DEFAULT_CONNECT_CONFIG, but lets any other top-level fields pass
10
+ * through unchanged so source-config-only fields (studio, reactor, auth,
11
+ * documentModelsDir, etc.) survive a read+write round-trip.
12
+ */
13
+ type ConfigShape = Record<string, unknown> & {
14
+ connect: PHConnectRuntimeConfig;
15
+ };
16
+ /**
17
+ * Abstract IO layer for `powerhouse.config.json`.
18
+ *
19
+ * Implementations decide where bytes come from and go to. The shipped
20
+ * adapter is `JsonConfigAdapter` (reads via fetch in the browser, fs in
21
+ * Node; writes via fs in Node, throws in the browser). Future adapters
22
+ * (remote-JSON, GraphQL) plug in without changing the loader or any
23
+ * consumer.
24
+ */
25
+ interface ConfigAdapter {
26
+ /** Read raw JSON-parsed payload from the backing store. */
27
+ read(): Promise<unknown>;
28
+ /** Persist a fully-formed config. */
29
+ write(next: ConfigShape): Promise<void>;
30
+ /** Human-readable description used in errors and logs. */
31
+ readonly source: string;
32
+ }
33
+ /**
34
+ * Deep-merge `patch` into `base`. Object fields recurse; arrays and
35
+ * primitives replace. `undefined` in patch leaves the base value
36
+ * untouched (no unset). `null` in patch overwrites with null.
37
+ *
38
+ * Exported for unit tests; consumers use ConfigLoader.write() which
39
+ * applies this internally.
40
+ */
41
+ declare function deepMerge<T>(base: T, patch: DeepPartial<T>): T;
42
+ /**
43
+ * Pluggable loader on top of a `ConfigAdapter`.
44
+ *
45
+ * Responsibilities:
46
+ * - merge-with-defaults on read (so consumers never see a partial connect block)
47
+ * - in-process caching (call `invalidate()` to force re-read)
48
+ * - deep-merge for partial writes; writes the merged whole back through the adapter
49
+ *
50
+ * The cache is module-instance scoped — every `new ConfigLoader(...)` has
51
+ * its own cache. The browser SPA constructs the loader once at boot; the
52
+ * CLI typically constructs a fresh loader per command.
53
+ */
54
+ declare class ConfigLoader {
55
+ private readonly adapter;
56
+ private readonly defaults;
57
+ private cache;
58
+ constructor(adapter: ConfigAdapter, defaults?: PHConnectRuntimeConfig);
59
+ /** Returns the config with the default connect block merged in.
60
+ * Cached after the first successful call. */
61
+ read(): Promise<ConfigShape>;
62
+ /**
63
+ * Returns the cached config synchronously. Throws if `read()` has not
64
+ * resolved yet — matches Connect's `getRuntimeConfig()` shape.
65
+ */
66
+ getCached(): ConfigShape;
67
+ /** Drop the in-memory cache. Next `read()` re-fetches from the adapter. */
68
+ invalidate(): void;
69
+ /**
70
+ * Deep-merge `patch` into the current config and persist via the adapter.
71
+ * Returns the new full config (also updates the cache). Arrays in `patch`
72
+ * replace — they do NOT append.
73
+ */
74
+ write(patch: DeepPartial<ConfigShape>): Promise<ConfigShape>;
75
+ }
76
+ //#endregion
77
+ export { ConfigAdapter, ConfigLoader, ConfigShape, DeepPartial, deepMerge };
78
+ //# sourceMappingURL=config-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-loader.d.ts","names":[],"sources":["../../connect/config-loader.ts"],"mappings":";;;;KAmBY,WAAA,MACV,CAAA,SAAU,KAAA,YACN,KAAA,CAAM,CAAA,IACN,CAAA,gCACgB,CAAA,IAAK,WAAA,CAAY,CAAA,CAAE,CAAA,OACjC,CAAA;;;;;;;;KASI,WAAA,GAAc,MAAA;EACxB,OAAA,EAAS,sBAAA;AAAA;;;;;;;;;;UAYM,aAAA;EAvBN;EAyBT,IAAA,IAAQ,OAAA;EAzBiB;EA2BzB,KAAA,CAAM,IAAA,EAAM,WAAA,GAAc,OAAA;EA3Ba;EAAA,SA6B9B,MAAA;AAAA;;AAnBX;;;;;;;iBA8BgB,SAAA,GAAA,CAAa,IAAA,EAAM,CAAA,EAAG,KAAA,EAAO,WAAA,CAAY,CAAA,IAAK,CAAA;;AAjB9D;;;;;;;;;;;cAiDa,YAAA;EAAA,iBAIQ,OAAA;EAAA,iBACA,QAAA;EAAA,QAJX,KAAA;cAGW,OAAA,EAAS,aAAA,EACT,QAAA,GAAU,sBAAA;EAhDd;AAWjB;EA0CQ,IAAA,CAAA,GAAQ,OAAA,CAAQ,WAAA;EA1CC;;;;EA6DvB,SAAA,CAAA,GAAa,WAAA;EA7DgD;EAuE7D,UAAA,CAAA;EAvEwB;;;;;EAgFlB,KAAA,CAAM,KAAA,EAAO,WAAA,CAAY,WAAA,IAAe,OAAA,CAAQ,WAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import { n as deepMerge, t as ConfigLoader } from "../config-loader-DORViRnN.js";
2
+ export { ConfigLoader, deepMerge };