gencow 0.1.299 → 0.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 (149) hide show
  1. package/bin/gencow.mjs +0 -6
  2. package/core/package.json +1 -1
  3. package/docs/packaging.md +14 -4
  4. package/lib/cli-artifact-guard.mjs +53 -3
  5. package/lib/cli-dev-runtime.mjs +1 -0
  6. package/lib/cli-project-runtime.mjs +26 -14
  7. package/lib/codegen-command.mjs +16 -0
  8. package/lib/coding-guardrails.mjs +2 -0
  9. package/lib/dashboard-artifact.mjs +65 -0
  10. package/lib/dashboard-assets.mjs +20 -0
  11. package/lib/db-command.mjs +121 -80
  12. package/lib/db-migration-command-steps.mjs +19 -16
  13. package/lib/db-push-command.mjs +1 -1
  14. package/lib/deploy-codegen-preflight.mjs +1 -0
  15. package/lib/dev-cloud-command.mjs +1 -1
  16. package/lib/dev-local-command.mjs +19 -56
  17. package/lib/document-local-converter.mjs +11 -0
  18. package/lib/local-dashboard-plan.mjs +60 -0
  19. package/lib/local-database-commands.mjs +127 -0
  20. package/lib/local-development-migrations.mjs +157 -0
  21. package/lib/local-drizzle-database.config.mjs +10 -0
  22. package/lib/local-runtime-features.mjs +12 -0
  23. package/lib/rag-selection.mjs +7 -0
  24. package/lib/runtime-local-worker.mjs +116 -0
  25. package/lib/runtime-mode.mjs +3 -0
  26. package/lib/standalone-codegen-adapter.mjs +91 -0
  27. package/lib/ts-codegen-import-extension.mjs +228 -19
  28. package/package.json +16 -9
  29. package/runtime/config.mjs +218 -2
  30. package/runtime/engine/chunk-2HA4CUMS.mjs +90 -0
  31. package/runtime/engine/chunk-2JLO3KMM.mjs +305 -0
  32. package/runtime/engine/chunk-2SR2M7SR.mjs +1045 -0
  33. package/runtime/engine/chunk-3D7MHEUC.mjs +253 -0
  34. package/runtime/engine/chunk-3R7COBWG.mjs +309 -0
  35. package/runtime/engine/chunk-3ZKA54UW.mjs +1560 -0
  36. package/runtime/engine/chunk-45I4YR2J.mjs +9 -0
  37. package/runtime/engine/chunk-4MLRXO7F.mjs +74 -0
  38. package/runtime/engine/chunk-5575APCJ.mjs +215 -0
  39. package/runtime/engine/chunk-5GUJZQF3.mjs +114 -0
  40. package/runtime/engine/chunk-5MXY3T75.mjs +428 -0
  41. package/runtime/engine/chunk-5TACQ2US.mjs +44 -0
  42. package/runtime/engine/chunk-66G4YEDT.mjs +3104 -0
  43. package/runtime/engine/chunk-67YO53WW.mjs +1426 -0
  44. package/runtime/engine/chunk-6GQRM7XY.mjs +87 -0
  45. package/runtime/engine/chunk-6JO72SPP.mjs +68 -0
  46. package/runtime/engine/chunk-6W653LXI.mjs +13 -0
  47. package/runtime/engine/chunk-7ITSMI3S.mjs +69 -0
  48. package/runtime/engine/chunk-7KUJ2H2S.mjs +128 -0
  49. package/runtime/engine/chunk-A5BMQ5IC.mjs +45 -0
  50. package/runtime/engine/chunk-ADF3UR6L.mjs +428 -0
  51. package/runtime/engine/chunk-AEBW7XZJ.mjs +4510 -0
  52. package/runtime/engine/chunk-AGPQ5XIV.mjs +156 -0
  53. package/runtime/engine/chunk-CPU4OZSX.mjs +753 -0
  54. package/runtime/engine/chunk-CSWPPWBL.mjs +50 -0
  55. package/runtime/engine/chunk-DPWXSMWO.mjs +53 -0
  56. package/runtime/engine/chunk-EAIELFKU.mjs +151 -0
  57. package/runtime/engine/chunk-EDU5CBKT.mjs +10 -0
  58. package/runtime/engine/chunk-EQCTAET7.mjs +173 -0
  59. package/runtime/engine/chunk-EQCXDF2Z.mjs +70 -0
  60. package/runtime/engine/chunk-F3G4UGV4.mjs +330 -0
  61. package/runtime/engine/chunk-F62NUNOO.mjs +26 -0
  62. package/runtime/engine/chunk-FKPNIFRP.mjs +2492 -0
  63. package/runtime/engine/chunk-FM23RGVI.mjs +81 -0
  64. package/runtime/engine/chunk-FW5AK4YP.mjs +1041 -0
  65. package/runtime/engine/chunk-GDWYAGWV.mjs +23 -0
  66. package/runtime/engine/chunk-GO5PZUYW.mjs +53 -0
  67. package/runtime/engine/chunk-GOLP7OSG.mjs +340 -0
  68. package/runtime/engine/chunk-GSLM44EF.mjs +242 -0
  69. package/runtime/engine/chunk-GYAJ7OX2.mjs +125 -0
  70. package/runtime/engine/chunk-I3GWR43K.mjs +14 -0
  71. package/runtime/engine/chunk-IFMOTJNU.mjs +106 -0
  72. package/runtime/engine/chunk-IKQKBE2G.mjs +128 -0
  73. package/runtime/engine/chunk-ITH2NEKM.mjs +282 -0
  74. package/runtime/engine/chunk-J6SDRCG4.mjs +96 -0
  75. package/runtime/engine/chunk-JODRNM3S.mjs +29596 -0
  76. package/runtime/engine/chunk-JUDKX53X.mjs +137 -0
  77. package/runtime/engine/chunk-K2YZVPJ4.mjs +827 -0
  78. package/runtime/engine/chunk-KEZJUXEE.mjs +151 -0
  79. package/runtime/engine/chunk-KVLTJFCH.mjs +234 -0
  80. package/runtime/engine/chunk-KX2PRQPS.mjs +126 -0
  81. package/runtime/engine/chunk-LEW5ZMLR.mjs +76 -0
  82. package/runtime/engine/chunk-LINVSJEM.mjs +175 -0
  83. package/runtime/engine/chunk-M7K2ICSM.mjs +11 -0
  84. package/runtime/engine/chunk-MZXDXSDC.mjs +292 -0
  85. package/runtime/engine/chunk-N2TA2IK2.mjs +678 -0
  86. package/runtime/engine/chunk-N4LTCKJP.mjs +695 -0
  87. package/runtime/engine/chunk-N6GCLOUX.mjs +13 -0
  88. package/runtime/engine/chunk-NAG2OXS5.mjs +37 -0
  89. package/runtime/engine/chunk-NNZ2QJUG.mjs +381 -0
  90. package/runtime/engine/chunk-NZPPLDNW.mjs +15 -0
  91. package/runtime/engine/chunk-ODWM57W6.mjs +138 -0
  92. package/runtime/engine/chunk-P5IIXAIE.mjs +23 -0
  93. package/runtime/engine/chunk-PBOXB2BV.mjs +6 -0
  94. package/runtime/engine/chunk-PMOJLN2P.mjs +8 -0
  95. package/runtime/engine/chunk-PZFMKFHO.mjs +180 -0
  96. package/runtime/engine/chunk-QL2TQX2N.mjs +114 -0
  97. package/runtime/engine/chunk-RITT2RSJ.mjs +258 -0
  98. package/runtime/engine/chunk-RODBVJ5M.mjs +135 -0
  99. package/runtime/engine/chunk-RW65MPVY.mjs +261 -0
  100. package/runtime/engine/chunk-S67UYPB6.mjs +25 -0
  101. package/runtime/engine/chunk-SVJCOUI3.mjs +47 -0
  102. package/runtime/engine/chunk-TCN3ZASV.mjs +957 -0
  103. package/runtime/engine/chunk-U2NRG6KC.mjs +32 -0
  104. package/runtime/engine/chunk-UM3F7HUV.mjs +432 -0
  105. package/runtime/engine/chunk-VWU7JJ3P.mjs +146 -0
  106. package/runtime/engine/chunk-WDTKPPMU.mjs +310 -0
  107. package/runtime/engine/chunk-WJOO4XTB.mjs +31 -0
  108. package/runtime/engine/chunk-XNFVL2OY.mjs +63 -0
  109. package/runtime/engine/chunk-XPWJXP2J.mjs +58 -0
  110. package/runtime/engine/chunk-Y3HSBJ3I.mjs +1132 -0
  111. package/runtime/engine/chunk-YMH4RYSX.mjs +317 -0
  112. package/runtime/engine/chunk-YNOMPSGS.mjs +8 -0
  113. package/runtime/engine/chunk-YRBAYTEZ.mjs +251 -0
  114. package/runtime/engine/chunk-YRHM272W.mjs +528 -0
  115. package/runtime/engine/chunk-ZQUZAGIQ.mjs +149 -0
  116. package/runtime/engine/chunk-ZXMM7QFP.mjs +176 -0
  117. package/runtime/engine/chunk-ZZJSIPV2.mjs +262 -0
  118. package/runtime/engine/composition.mjs +325 -0
  119. package/runtime/engine/document-local.mjs +504 -0
  120. package/runtime/engine/graph.json +4134 -0
  121. package/runtime/engine/index.mjs +265 -0
  122. package/runtime/engine/local-postgres-support.mjs +69 -0
  123. package/runtime/engine/local.mjs +3275 -0
  124. package/runtime/engine/pglite-directory-lock.mjs +8 -0
  125. package/runtime/engine/rag.mjs +11 -0
  126. package/runtime/engine/search.mjs +18 -0
  127. package/runtime/framework-migrations/foundation-bootstrap/rag.sql +115 -0
  128. package/runtime/framework-migrations/foundation-bootstrap/workflow.sql +194 -0
  129. package/runtime/framework-migrations/journal-bootstrap/migration.sql +26 -0
  130. package/runtime/framework-migrations/manifest.json +56 -0
  131. package/runtime/framework-migrations/rag/20261006111509_mushy_warhawk/migration.sql +121 -0
  132. package/runtime/framework-migrations/rag/20261013234621_rag_v2_lifecycle_markers/migration.sql +6 -0
  133. package/runtime/framework-migrations/workflow/20261006111508_perpetual_star_brand/migration.sql +31 -0
  134. package/runtime/runtime-metadata.json +27 -0
  135. package/runtime/tooling.mjs +10399 -8951
  136. package/scripts/bundle-runtime-config.mjs +23 -0
  137. package/scripts/bundle-runtime.mjs +100 -0
  138. package/scripts/bundle-runtime.test.mjs +33 -0
  139. package/scripts/bundle-shared.mjs +3 -0
  140. package/scripts/copy-dashboard.mjs +16 -0
  141. package/scripts/pre-publish-check.mjs +23 -11
  142. package/templateFeature/sso/sso-auth-callback.tsx +37 -5
  143. package/templateFeature/tools/manifest.json +2 -1
  144. package/templateFeature/tools/tools.ts +3 -3
  145. package/runtime/server.mjs +0 -14389
  146. package/scripts/bundle-server.mjs +0 -223
  147. package/server/config.js +0 -1
  148. package/server/index.js +0 -1
  149. package/server/package.json +0 -6
@@ -0,0 +1,695 @@
1
+ import {
2
+ assertRuntimeFileSize
3
+ } from "./chunk-GDWYAGWV.mjs";
4
+ import {
5
+ RuntimeCompositionError,
6
+ runtimeStartupError
7
+ } from "./chunk-IFMOTJNU.mjs";
8
+ import {
9
+ MAX_FILE_SIZE,
10
+ RuntimeDiagnosticError,
11
+ runtimeDiagnostic
12
+ } from "./chunk-AEBW7XZJ.mjs";
13
+
14
+ // ../client/dist/adapters/procedure-rpc/codec.js
15
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
16
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
17
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
18
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
19
+ };
20
+ var _ProcedureRpcLinkCodec_instances;
21
+ var _ProcedureRpcLinkCodec_deserializeFormData;
22
+ var MAX_RPC_BLOBS = 16;
23
+ var MAX_RPC_META_ITEMS = 2048;
24
+ var MAX_RPC_META_PATH_DEPTH = 64;
25
+ var PROCEDURE_RPC_DATA_FIELD = "data";
26
+ var CYCLIC_RPC_PAYLOAD_MESSAGE = "Cyclic RPC payloads cannot be encoded.";
27
+ var RPC_BUILT_IN_TYPES = {
28
+ BIGINT: 0,
29
+ DATE: 1,
30
+ NAN: 2,
31
+ UNDEFINED: 3,
32
+ URL: 4,
33
+ REGEXP: 5,
34
+ SET: 6,
35
+ MAP: 7
36
+ };
37
+ function objectHasOwn(o, key) {
38
+ return Object.prototype.hasOwnProperty.call(o, key);
39
+ }
40
+ function isRecord(value) {
41
+ return typeof value === "object" && value !== null;
42
+ }
43
+ function isRpcSerializedPayload(value) {
44
+ if (!isRecord(value))
45
+ return false;
46
+ if (!objectHasOwn(value, "json"))
47
+ return false;
48
+ if (!objectHasOwn(value, "meta"))
49
+ return true;
50
+ return value.meta === void 0 || Array.isArray(value.meta);
51
+ }
52
+ function formDataToRecord(form) {
53
+ const record = {};
54
+ for (const [key, value] of form.entries()) {
55
+ if (!objectHasOwn(record, key)) {
56
+ record[key] = value;
57
+ continue;
58
+ }
59
+ const existing = record[key];
60
+ record[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];
61
+ }
62
+ return record;
63
+ }
64
+ var ProcedureRpcDecodeError = class extends Error {
65
+ constructor(message) {
66
+ super(message);
67
+ this.status = 400;
68
+ this.code = "RPC_DECODE_ERROR";
69
+ this.name = "ProcedureRpcDecodeError";
70
+ }
71
+ };
72
+ var ProcedureRpcJsonSerializer = class {
73
+ serialize(data, path = [], meta = [], maps = [], blobs = [], ancestors = /* @__PURE__ */ new WeakSet()) {
74
+ const traversable = typeof FormData !== "undefined" && data instanceof FormData || data instanceof Set || data instanceof Map || Array.isArray(data) || isRecord(data);
75
+ if (traversable) {
76
+ if (ancestors.has(data)) {
77
+ throw new TypeError(CYCLIC_RPC_PAYLOAD_MESSAGE);
78
+ }
79
+ ancestors.add(data);
80
+ }
81
+ try {
82
+ if (typeof FormData !== "undefined" && data instanceof FormData) {
83
+ return this.serialize(formDataToRecord(data), path, meta, maps, blobs, ancestors);
84
+ }
85
+ if (data instanceof Blob) {
86
+ maps.push(path);
87
+ blobs.push(data);
88
+ return [null, meta, maps, blobs];
89
+ }
90
+ if (typeof data === "bigint") {
91
+ meta.push([RPC_BUILT_IN_TYPES.BIGINT, ...path]);
92
+ return [data.toString(), meta, maps, blobs];
93
+ }
94
+ if (data instanceof Date) {
95
+ meta.push([RPC_BUILT_IN_TYPES.DATE, ...path]);
96
+ return [Number.isNaN(data.getTime()) ? null : data.toISOString(), meta, maps, blobs];
97
+ }
98
+ if (Number.isNaN(data)) {
99
+ meta.push([RPC_BUILT_IN_TYPES.NAN, ...path]);
100
+ return [null, meta, maps, blobs];
101
+ }
102
+ if (data instanceof URL) {
103
+ meta.push([RPC_BUILT_IN_TYPES.URL, ...path]);
104
+ return [data.toString(), meta, maps, blobs];
105
+ }
106
+ if (data instanceof RegExp) {
107
+ meta.push([RPC_BUILT_IN_TYPES.REGEXP, ...path]);
108
+ return [data.toString(), meta, maps, blobs];
109
+ }
110
+ if (data instanceof Set) {
111
+ const result = this.serialize(Array.from(data), path, meta, maps, blobs, ancestors);
112
+ meta.push([RPC_BUILT_IN_TYPES.SET, ...path]);
113
+ return result;
114
+ }
115
+ if (data instanceof Map) {
116
+ const result = this.serialize(Array.from(data.entries()), path, meta, maps, blobs, ancestors);
117
+ meta.push([RPC_BUILT_IN_TYPES.MAP, ...path]);
118
+ return result;
119
+ }
120
+ if (Array.isArray(data)) {
121
+ const json = data.map((item, index) => {
122
+ if (item === void 0) {
123
+ meta.push([RPC_BUILT_IN_TYPES.UNDEFINED, ...path, index]);
124
+ return null;
125
+ }
126
+ return this.serialize(item, [...path, index], meta, maps, blobs, ancestors)[0];
127
+ });
128
+ return [json, meta, maps, blobs];
129
+ }
130
+ if (isRecord(data)) {
131
+ const json = {};
132
+ for (const key in data) {
133
+ if (key === "toJSON" && typeof data[key] === "function") {
134
+ continue;
135
+ }
136
+ json[key] = this.serialize(data[key], [...path, key], meta, maps, blobs, ancestors)[0];
137
+ }
138
+ return [json, meta, maps, blobs];
139
+ }
140
+ return [data, meta, maps, blobs];
141
+ } finally {
142
+ if (traversable)
143
+ ancestors.delete(data);
144
+ }
145
+ }
146
+ deserialize(json, meta, maps, getBlob) {
147
+ if (meta.length > MAX_RPC_META_ITEMS) {
148
+ throw new ProcedureRpcDecodeError(`RPC payload meta exceeds maximum item count (${MAX_RPC_META_ITEMS}).`);
149
+ }
150
+ const ref = { data: json };
151
+ if (maps && getBlob) {
152
+ if (maps.length > MAX_RPC_BLOBS) {
153
+ throw new ProcedureRpcDecodeError(`RPC payload exceeds maximum blob count (${MAX_RPC_BLOBS}).`);
154
+ }
155
+ maps.forEach((segments, index) => {
156
+ let currentRef = ref;
157
+ let prevSegment = "data";
158
+ for (const segment of segments) {
159
+ currentRef = currentRef[prevSegment];
160
+ prevSegment = segment;
161
+ if (!objectHasOwn(currentRef, prevSegment)) {
162
+ throw new ProcedureRpcDecodeError(`Invalid RPC payload path during blob deserialization. Path segment: ${String(prevSegment)}`);
163
+ }
164
+ }
165
+ currentRef[prevSegment] = getBlob(index);
166
+ });
167
+ }
168
+ for (const item of meta) {
169
+ if (item.length - 1 > MAX_RPC_META_PATH_DEPTH) {
170
+ throw new ProcedureRpcDecodeError(`RPC payload meta path exceeds maximum depth (${MAX_RPC_META_PATH_DEPTH}).`);
171
+ }
172
+ const type = item[0];
173
+ let currentRef = ref;
174
+ let prevSegment = "data";
175
+ for (let index = 1; index < item.length; index++) {
176
+ currentRef = currentRef[prevSegment];
177
+ prevSegment = item[index];
178
+ if (!objectHasOwn(currentRef, prevSegment)) {
179
+ throw new ProcedureRpcDecodeError(`Invalid RPC payload path during deserialization. Path segment: ${String(prevSegment)}`);
180
+ }
181
+ }
182
+ switch (type) {
183
+ case RPC_BUILT_IN_TYPES.BIGINT:
184
+ currentRef[prevSegment] = BigInt(currentRef[prevSegment]);
185
+ break;
186
+ case RPC_BUILT_IN_TYPES.DATE:
187
+ currentRef[prevSegment] = new Date(currentRef[prevSegment] ?? "Invalid Date");
188
+ break;
189
+ case RPC_BUILT_IN_TYPES.NAN:
190
+ currentRef[prevSegment] = Number.NaN;
191
+ break;
192
+ case RPC_BUILT_IN_TYPES.UNDEFINED:
193
+ currentRef[prevSegment] = void 0;
194
+ break;
195
+ case RPC_BUILT_IN_TYPES.URL:
196
+ currentRef[prevSegment] = new URL(currentRef[prevSegment]);
197
+ break;
198
+ case RPC_BUILT_IN_TYPES.REGEXP: {
199
+ const rawValue = currentRef[prevSegment];
200
+ if (typeof rawValue !== "string") {
201
+ throw new ProcedureRpcDecodeError("Invalid RPC payload for RegExp deserialization.");
202
+ }
203
+ const match = rawValue.match(/^\/(.*)\/([a-z]*)$/);
204
+ if (!match) {
205
+ throw new ProcedureRpcDecodeError("Invalid RPC payload for RegExp deserialization.");
206
+ }
207
+ const [, pattern, flags] = match;
208
+ currentRef[prevSegment] = new RegExp(pattern, flags);
209
+ break;
210
+ }
211
+ case RPC_BUILT_IN_TYPES.SET:
212
+ currentRef[prevSegment] = new Set(currentRef[prevSegment]);
213
+ break;
214
+ case RPC_BUILT_IN_TYPES.MAP:
215
+ currentRef[prevSegment] = new Map(currentRef[prevSegment]);
216
+ break;
217
+ }
218
+ }
219
+ return ref.data;
220
+ }
221
+ };
222
+ var ProcedureRpcLinkCodec = class {
223
+ constructor(_options = {}) {
224
+ _ProcedureRpcLinkCodec_instances.add(this);
225
+ this.serializer = new ProcedureRpcJsonSerializer();
226
+ }
227
+ /** Deserialize wire JSON (`{ json, meta }` or plain JSON) to a JavaScript value. */
228
+ decodeWirePayload(body) {
229
+ if (body instanceof FormData) {
230
+ return __classPrivateFieldGet(this, _ProcedureRpcLinkCodec_instances, "m", _ProcedureRpcLinkCodec_deserializeFormData).call(this, body);
231
+ }
232
+ if (isRpcSerializedPayload(body)) {
233
+ return this.serializer.deserialize(body.json, body.meta ?? []);
234
+ }
235
+ return body;
236
+ }
237
+ /** Serialize a value to procedure RPC wire shape (`{ json, meta? }`). */
238
+ encodeWirePayload(value) {
239
+ const [json, meta, _maps, _blobs] = this.serializer.serialize(value);
240
+ return { json, meta: meta.length > 0 ? meta : void 0 };
241
+ }
242
+ /**
243
+ * Encode a procedure call for `POST /api/mutation` (procedure multipart when blobs present).
244
+ * Returns JSON `{ json, meta? }` when no blobs are present, otherwise `multipart/form-data`.
245
+ */
246
+ encodeProcedureCall(payload) {
247
+ const [json, meta, maps, blobs] = this.serializer.serialize(payload);
248
+ if (blobs.length === 0) {
249
+ return { json, meta: meta.length > 0 ? meta : void 0 };
250
+ }
251
+ if (blobs.length > MAX_RPC_BLOBS) {
252
+ throw new ProcedureRpcDecodeError(`RPC payload exceeds maximum blob count (${MAX_RPC_BLOBS}).`);
253
+ }
254
+ const form = new FormData();
255
+ form.set(PROCEDURE_RPC_DATA_FIELD, JSON.stringify({
256
+ json,
257
+ meta: meta.length > 0 ? meta : void 0,
258
+ maps
259
+ }));
260
+ blobs.forEach((blob, index) => {
261
+ form.set(String(index), blob);
262
+ });
263
+ return form;
264
+ }
265
+ /**
266
+ * Parse an incoming procedure call body (JSON, wire-wrapped JSON, or multipart FormData).
267
+ */
268
+ decodeProcedureRpcBody(body) {
269
+ const decoded = this.decodeWirePayload(body);
270
+ if (!isRecord(decoded))
271
+ return { name: void 0, args: void 0 };
272
+ return { name: decoded.name, args: decoded.args };
273
+ }
274
+ /** Decode `multipart/form-data` procedure RPC envelope (`data` + indexed blob parts). */
275
+ decodeProcedureMultipart(form) {
276
+ return this.decodeProcedureRpcBody(form);
277
+ }
278
+ };
279
+ _ProcedureRpcLinkCodec_instances = /* @__PURE__ */ new WeakSet(), _ProcedureRpcLinkCodec_deserializeFormData = function _ProcedureRpcLinkCodec_deserializeFormData2(form) {
280
+ const dataField = form.get(PROCEDURE_RPC_DATA_FIELD);
281
+ if (dataField === null) {
282
+ if (form.has("_mutation")) {
283
+ throw new ProcedureRpcDecodeError('Legacy multipart layout is not supported for procedure RPC. Use the "data" field envelope.');
284
+ }
285
+ throw new ProcedureRpcDecodeError('Missing required multipart field "data".');
286
+ }
287
+ if (typeof dataField !== "string") {
288
+ throw new ProcedureRpcDecodeError('Multipart field "data" must be a JSON string.');
289
+ }
290
+ let parsed;
291
+ try {
292
+ parsed = JSON.parse(dataField);
293
+ } catch {
294
+ throw new ProcedureRpcDecodeError('Invalid JSON in multipart field "data".');
295
+ }
296
+ const maps = parsed.maps ?? [];
297
+ if (!Array.isArray(maps)) {
298
+ throw new ProcedureRpcDecodeError('Multipart field "data" must include a "maps" array.');
299
+ }
300
+ const allowedKeys = /* @__PURE__ */ new Set([PROCEDURE_RPC_DATA_FIELD]);
301
+ for (let index = 0; index < maps.length; index++) {
302
+ allowedKeys.add(String(index));
303
+ }
304
+ for (const key of form.keys()) {
305
+ if (!allowedKeys.has(key)) {
306
+ throw new ProcedureRpcDecodeError(`Unexpected multipart field "${key}".`);
307
+ }
308
+ }
309
+ for (let index = 0; index < maps.length; index++) {
310
+ const part = form.get(String(index));
311
+ if (part === null || !(part instanceof Blob)) {
312
+ throw new ProcedureRpcDecodeError(`Missing blob part "${index}".`);
313
+ }
314
+ }
315
+ return this.serializer.deserialize(parsed.json, parsed.meta ?? [], maps, (index) => form.get(String(index)));
316
+ };
317
+
318
+ // ../client/dist/adapters/procedure-rpc/handler.js
319
+ var ProcedureRpcHandler = class {
320
+ constructor(options = {}) {
321
+ const codec = new ProcedureRpcLinkCodec(options);
322
+ this.codec = codec;
323
+ }
324
+ decodeProcedureRpcBody(body) {
325
+ return this.codec.decodeProcedureRpcBody(body);
326
+ }
327
+ decodeProcedureMultipart(form) {
328
+ return this.codec.decodeProcedureMultipart(form);
329
+ }
330
+ encodeWirePayload(value) {
331
+ return this.codec.encodeWirePayload(value);
332
+ }
333
+ encodeProcedureCall(payload) {
334
+ return this.codec.encodeProcedureCall(payload);
335
+ }
336
+ };
337
+
338
+ // ../runtime/dist/adapters/storage/upload-limits.js
339
+ var MULTIPART_OVERHEAD_BYTES = 1024 * 1024;
340
+ function snapshotRuntimeUploadLimitsInput(input) {
341
+ const { maxFileSizeBytes, maxMultipartBodyBytes, maxFilesPerRequest } = input;
342
+ return Object.freeze({
343
+ ...maxFileSizeBytes !== void 0 ? { maxFileSizeBytes } : {},
344
+ ...maxMultipartBodyBytes !== void 0 ? { maxMultipartBodyBytes } : {},
345
+ ...maxFilesPerRequest !== void 0 ? { maxFilesPerRequest } : {}
346
+ });
347
+ }
348
+ function resolveRuntimeUploadLimits(input = {}) {
349
+ if (!input || typeof input !== "object" || Array.isArray(input))
350
+ throw runtimeStartupError("RUNTIME_STORAGE_CONFIG_INVALID", "Supply a trusted upload-limit configuration object before restarting.");
351
+ const supplied = snapshotRuntimeUploadLimitsInput(input);
352
+ const maxFileSizeBytes = supplied.maxFileSizeBytes === void 0 ? MAX_FILE_SIZE : supplied.maxFileSizeBytes;
353
+ const maxMultipartBodyBytes = supplied.maxMultipartBodyBytes === void 0 ? maxFileSizeBytes + MULTIPART_OVERHEAD_BYTES : supplied.maxMultipartBodyBytes;
354
+ const maxFilesPerRequest = supplied.maxFilesPerRequest === void 0 ? MAX_RPC_BLOBS : supplied.maxFilesPerRequest;
355
+ if (![maxFileSizeBytes, maxMultipartBodyBytes, maxFilesPerRequest].every((value) => Number.isSafeInteger(value) && value > 0) || maxMultipartBodyBytes < maxFileSizeBytes + MULTIPART_OVERHEAD_BYTES || maxFilesPerRequest > MAX_RPC_BLOBS) {
356
+ throw runtimeStartupError("RUNTIME_STORAGE_CONFIG_INVALID", "Set positive safe-integer upload limits in bytes and a file count from 1 to 16. maxMultipartBodyBytes must be at least maxFileSizeBytes + 1048576 (1 MiB overhead). Correct trusted storage configuration and restart; no provider was allocated.");
357
+ }
358
+ return Object.freeze({ maxFileSizeBytes, maxMultipartBodyBytes, maxFilesPerRequest });
359
+ }
360
+ function assertRuntimeMultipartFiles(form, limits) {
361
+ let files = 0;
362
+ for (const entry of form.values()) {
363
+ const value = entry;
364
+ if (!(value instanceof Blob))
365
+ continue;
366
+ assertRuntimeFileSize(value.size, limits.maxFileSizeBytes);
367
+ files++;
368
+ }
369
+ if (files <= limits.maxFilesPerRequest)
370
+ return;
371
+ throw new RuntimeDiagnosticError({
372
+ code: "RUNTIME_RPC_FILE_COUNT_EXCEEDED",
373
+ stage: "request",
374
+ capability: "storage",
375
+ servingStarted: "unchanged",
376
+ dataImpact: "none",
377
+ retryable: false,
378
+ retryPrecondition: "Reduce the file count before submitting a fresh request.",
379
+ nextAction: `No RPC handler ran. Submit at most ${limits.maxFilesPerRequest} file parts per request within the file and encoded-body limits.`
380
+ });
381
+ }
382
+
383
+ // ../runtime/dist/adapters/storage/azure-errors.js
384
+ function providerFields(error) {
385
+ try {
386
+ if (!error || typeof error !== "object")
387
+ return {};
388
+ const value = error;
389
+ return { status: value.statusCode, code: value.code ?? value.details?.errorCode, name: value.name };
390
+ } catch {
391
+ return {};
392
+ }
393
+ }
394
+ function isAzureObjectAbsent(error) {
395
+ const value = providerFields(error);
396
+ return value.status === 404 && value.code === "BlobNotFound";
397
+ }
398
+ function isAzureObjectHeadAbsent(error) {
399
+ const value = providerFields(error);
400
+ return value.status === 404 && (value.code === void 0 || value.code === "" || value.code === "BlobNotFound");
401
+ }
402
+ function azureObjectNotFound() {
403
+ return new RuntimeDiagnosticError({
404
+ code: "RUNTIME_STORAGE_OBJECT_NOT_FOUND",
405
+ stage: "request",
406
+ servingStarted: "unchanged",
407
+ dataImpact: "none",
408
+ retryable: false,
409
+ retryPrecondition: "Use a stored object ID that exists in the selected catalog.",
410
+ nextAction: "Use ctx.storage.getMeta to verify an existing object; re-upload the missing file or refresh Files to select another object before retrying. No file changed.",
411
+ capability: "storage"
412
+ });
413
+ }
414
+ function azureMetadataInvalid() {
415
+ return new RuntimeDiagnosticError({
416
+ code: "RUNTIME_STORAGE_METADATA_INVALID",
417
+ stage: "request",
418
+ servingStarted: "unchanged",
419
+ dataImpact: "none",
420
+ retryable: false,
421
+ retryPrecondition: "Restore valid object metadata through its storage owner before repeating the read.",
422
+ nextAction: "Verify the selected object's metadata encoding with the trusted storage owner; do not blindly repeat mutations.",
423
+ capability: "storage"
424
+ });
425
+ }
426
+ async function azureStorageCall(write, operation) {
427
+ try {
428
+ return await operation();
429
+ } catch (error) {
430
+ if (runtimeDiagnostic(error))
431
+ throw error;
432
+ const value = providerFields(error);
433
+ const denied = value.status === 401 || value.status === 403;
434
+ const timeout = value.status === 408 || value.code === "ETIMEDOUT" || value.code === "ESOCKETTIMEDOUT" || value.code === "REQUEST_ABORTED_ERROR" || value.name === "AbortError";
435
+ throw new RuntimeDiagnosticError({
436
+ code: denied ? "RUNTIME_STORAGE_ACCESS_DENIED" : timeout ? "RUNTIME_STORAGE_PROVIDER_TIMEOUT" : "RUNTIME_STORAGE_PROVIDER_UNAVAILABLE",
437
+ stage: "request",
438
+ servingStarted: "unchanged",
439
+ capability: "storage",
440
+ dataImpact: write ? "unknown" : "none",
441
+ retryable: !write && !denied,
442
+ retryPrecondition: denied ? "Restore verified selected-provider credentials and container access before retrying." : "Restore verified storage availability before retrying; verify existing object effects before repeating a write.",
443
+ nextAction: denied ? "Verify the captured storage credentials and container permissions in the trusted bootstrap, then restart and check provider readiness." : "Check selected storage provider readiness and the object's current state; do not blindly retry a write."
444
+ });
445
+ }
446
+ }
447
+
448
+ // ../runtime/dist/adapters/storage/azure-namespace.js
449
+ import { createHash, randomUUID } from "node:crypto";
450
+ var uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
451
+ var unsafe = /[\\\u0000-\u001f\u007f]/u;
452
+ var escapedTraversal = /%(?:2e|2f|5c|25)/iu;
453
+ function invalidScope() {
454
+ const failure = runtimeStartupError("RUNTIME_STORAGE_CONFIG_INVALID", "Configure the selected Azure endpoint/container and existing app namespace or explicitly confirm exclusive container ownership in trusted storage configuration; preserve data and signing keys.", "none", "storage");
455
+ throw new RuntimeCompositionError({ ...failure.diagnostic, correlationId: randomUUID() });
456
+ }
457
+ function safeSegments(value) {
458
+ return !unsafe.test(value) && !escapedTraversal.test(value) && value.split("/").every((segment) => segment !== "." && segment !== ".." && segment !== "");
459
+ }
460
+ function captureAzureStorageNamespace(value) {
461
+ if (value === void 0)
462
+ return Object.freeze({ kind: "container", ownership: "exclusive-app" });
463
+ try {
464
+ if (!value || typeof value !== "object" || Array.isArray(value))
465
+ invalidScope();
466
+ const prototype = Object.getPrototypeOf(value);
467
+ if (prototype !== Object.prototype && prototype !== null)
468
+ invalidScope();
469
+ const descriptors = Object.getOwnPropertyDescriptors(value);
470
+ if (Reflect.ownKeys(value).some((key) => typeof key !== "string" || !Object.hasOwn(descriptors[key], "value")))
471
+ invalidScope();
472
+ const kind = descriptors.kind?.value;
473
+ const allowed = kind === "app" ? ["kind", "appName", "prefix"] : ["kind", "ownership"];
474
+ if (Reflect.ownKeys(value).some((key) => !allowed.includes(key)))
475
+ invalidScope();
476
+ if (kind === "container" && descriptors.ownership?.value === "exclusive-app")
477
+ return Object.freeze({ kind, ownership: "exclusive-app" });
478
+ if (kind !== "app")
479
+ invalidScope();
480
+ const appName = descriptors.appName?.value;
481
+ const rawPrefix = descriptors.prefix?.value;
482
+ if (typeof appName !== "string" || !appName.trim() || !safeSegments(appName) || typeof rawPrefix !== "string")
483
+ invalidScope();
484
+ const prefix = rawPrefix.trim().replace(/^\/+|\/+$/gu, "");
485
+ if (prefix && !safeSegments(prefix))
486
+ invalidScope();
487
+ encodeURIComponent(prefix);
488
+ encodeURIComponent(appName);
489
+ return Object.freeze({ kind, appName, prefix });
490
+ } catch {
491
+ return invalidScope();
492
+ }
493
+ }
494
+ function invalidId() {
495
+ throw new RuntimeDiagnosticError({
496
+ code: "RUNTIME_STORAGE_OBJECT_ID_INVALID",
497
+ stage: "request",
498
+ capability: "storage",
499
+ correlationId: `storage_${randomUUID()}`,
500
+ servingStarted: "unchanged",
501
+ dataImpact: "none",
502
+ retryable: false,
503
+ retryPrecondition: "Use an object ID issued by the selected application's storage layout.",
504
+ nextAction: "Supply this app's opaque storage ID, not a blob path or provider URL; do not replay earlier writes."
505
+ });
506
+ }
507
+ function azureNamespaceResolver(accountUrl, container, input) {
508
+ try {
509
+ const url = new URL(accountUrl);
510
+ if (url.protocol !== "https:" || url.username || url.password || url.pathname !== "/" || url.search || url.hash || !/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/u.test(container))
511
+ invalidScope();
512
+ } catch {
513
+ invalidScope();
514
+ }
515
+ const namespace = captureAzureStorageNamespace(input);
516
+ const prefix = namespace.kind === "app" ? `${namespace.prefix ? namespace.prefix + "/" : ""}apps/${encodeURIComponent(namespace.appName)}/objects/` : void 0;
517
+ const key = (id) => {
518
+ if (typeof id !== "string" || !id || Buffer.from(id, "utf8").toString("utf8") !== id || unsafe.test(id) || /^[a-z][a-z0-9+.-]*:\/\//iu.test(id) || id.startsWith("/") || id.split("/").some((segment) => segment === "." || segment === ".."))
519
+ invalidId();
520
+ if (namespace.kind === "app" && !uuid.test(id))
521
+ invalidId();
522
+ return prefix === void 0 ? id : prefix + id;
523
+ };
524
+ return Object.freeze({
525
+ namespace,
526
+ prefix,
527
+ key,
528
+ catalog: createHash("sha256").update(JSON.stringify([accountUrl, container, namespace])).digest("hex"),
529
+ publicId(providerKey) {
530
+ try {
531
+ if (typeof providerKey !== "string" || prefix !== void 0 && !providerKey.startsWith(prefix))
532
+ throw Error();
533
+ const id = prefix === void 0 ? providerKey : providerKey.slice(prefix.length);
534
+ key(id);
535
+ return id;
536
+ } catch {
537
+ throw azureMetadataInvalid();
538
+ }
539
+ }
540
+ });
541
+ }
542
+ function captureAzureNamespaceOption(input, explicit = false) {
543
+ const descriptor = Object.getOwnPropertyDescriptor(input, "namespace");
544
+ if (!descriptor && "namespace" in input || descriptor && !Object.hasOwn(descriptor, "value") || explicit && descriptor?.value === void 0)
545
+ invalidScope();
546
+ return descriptor?.value === void 0 ? void 0 : captureAzureStorageNamespace(descriptor.value);
547
+ }
548
+
549
+ // ../runtime/dist/adapters/storage/storage-id.js
550
+ import { Buffer as Buffer2 } from "node:buffer";
551
+ var filesystemMetadataSuffix = ".gencow-meta.json";
552
+ var filesystemMetadataMaxSerializedBytes = 64 * 1024;
553
+ var filesystemLegacyMetadataSuffix = ".meta";
554
+ var filesystemRootOwnerFilename = ".gencow-storage-owner.json";
555
+ var filesystemReadGrantKeyFilename = ".gencow-storage-read-grant.key";
556
+ var filesystemUploadSessionsDirectory = ".gencow-upload-sessions-v1";
557
+ var filesystemRootInternalDirectories = [
558
+ ".cache",
559
+ ".uploads",
560
+ filesystemUploadSessionsDirectory
561
+ ];
562
+ function isValidStorageObjectId(value) {
563
+ if (typeof value !== "string" || value.length === 0 || value === "." || value === ".." || value.startsWith(".") || /[\\/\u0000-\u001f\u007f]/u.test(value) || value.endsWith(filesystemMetadataSuffix) || value.endsWith(filesystemLegacyMetadataSuffix) || /%(?:2e|2f|5c|00)/iu.test(value) || Buffer2.from(value, "utf8").toString("utf8") !== value || Buffer2.byteLength(value, "utf8") + Buffer2.byteLength(filesystemMetadataSuffix, "utf8") > 255)
564
+ return false;
565
+ return true;
566
+ }
567
+
568
+ // ../runtime/dist/adapters/storage/administration-values.js
569
+ import { Buffer as Buffer3 } from "node:buffer";
570
+ function storageAdministrationInputInvalid() {
571
+ return new RuntimeDiagnosticError({
572
+ code: "RUNTIME_LOCAL_FILES_INPUT_INVALID",
573
+ stage: "request",
574
+ capability: "storage",
575
+ servingStarted: "unchanged",
576
+ dataImpact: "none",
577
+ retryable: false,
578
+ retryPrecondition: "Use a current flat object ID, bounded page/selection and valid filename, MIME type and visibility. Before retrying a containing Files action, inspect any earlier effects through Files and the selected storage state.",
579
+ nextAction: "Use the opaque object ID returned by the selected storage adapter, then refresh Files and correct the rejected Files input. This Files sub-operation changed no file; inspect any earlier effects from the containing Files or bulk action before a deliberate retry. Do not blindly replay the whole action."
580
+ });
581
+ }
582
+ function storageAdministrationReadLimit(limit) {
583
+ return new RuntimeDiagnosticError({
584
+ code: "RUNTIME_STORAGE_READ_LIMIT_EXCEEDED",
585
+ stage: "request",
586
+ capability: "storage",
587
+ servingStarted: "unchanged",
588
+ dataImpact: "none",
589
+ retryable: false,
590
+ retryPrecondition: `Choose an object within the selected ${limit}-byte read limit or verify trusted storage configuration first.`,
591
+ nextAction: "Refresh Files and choose a smaller object. This read was bounded; no file or current serving state changed."
592
+ });
593
+ }
594
+ function storageAdministrationMetadataInvalid() {
595
+ return new RuntimeDiagnosticError({
596
+ code: "RUNTIME_STORAGE_METADATA_INVALID",
597
+ stage: "request",
598
+ capability: "storage",
599
+ servingStarted: "unchanged",
600
+ dataImpact: "none",
601
+ retryable: false,
602
+ retryPrecondition: "Inspect the selected storage object's actual metadata through its trusted owner before another action.",
603
+ nextAction: "Refresh Files after verifying the selected storage owner and object metadata. No metadata was rewritten or file changed by this read."
604
+ });
605
+ }
606
+ function assertAdministrationStorageId(id) {
607
+ if (!isValidStorageObjectId(id))
608
+ throw storageAdministrationInputInvalid();
609
+ }
610
+ function assertAdministrationVisibility(value) {
611
+ if (value !== "private" && value !== "public")
612
+ throw storageAdministrationInputInvalid();
613
+ }
614
+ function assertAdministrationUpload(input) {
615
+ assertAdministrationVisibility(input.visibility);
616
+ if (typeof input.name !== "string" || !input.name.trim() || input.name.length > 1024 || /[\x00-\x1f]/u.test(input.name) || typeof input.type !== "string" || !input.type || input.type.length > 256 || /[\x00-\x1f]/u.test(input.type))
617
+ throw storageAdministrationInputInvalid();
618
+ }
619
+ function administrationMetadata(file, createdAt, source) {
620
+ try {
621
+ assertAdministrationStorageId(file.id);
622
+ assertStorageMetadataProjection(file);
623
+ } catch {
624
+ throw storageAdministrationMetadataInvalid();
625
+ }
626
+ if (!Number.isSafeInteger(file.size) || file.size < 0)
627
+ throw storageAdministrationMetadataInvalid();
628
+ const date = createdAt === void 0 ? void 0 : createdAt instanceof Date ? createdAt : new Date(createdAt);
629
+ if (date && !Number.isFinite(date.getTime()))
630
+ throw storageAdministrationMetadataInvalid();
631
+ return Object.freeze({
632
+ id: file.id,
633
+ name: file.name,
634
+ type: file.type,
635
+ size: file.size,
636
+ visibility: file.visibility,
637
+ ...date ? { createdAt: date.toISOString() } : {},
638
+ ...source === "dashboard" || source === "cli" || source === "api" ? { source } : {}
639
+ });
640
+ }
641
+ function assertStorageMetadataProjection(file) {
642
+ if (typeof file.name !== "string" || typeof file.type !== "string" || file.visibility !== "private" && file.visibility !== "public" || file.name.length > filesystemMetadataMaxSerializedBytes || file.type.length > filesystemMetadataMaxSerializedBytes || Buffer3.byteLength(JSON.stringify({ name: file.name, type: file.type }), "utf8") > filesystemMetadataMaxSerializedBytes)
643
+ throw storageAdministrationMetadataInvalid();
644
+ }
645
+ async function storageAdministrationWrite(operation) {
646
+ try {
647
+ return await operation();
648
+ } catch (error) {
649
+ const typed = runtimeDiagnostic(error);
650
+ if (typed?.code === "RUNTIME_STORAGE_METADATA_UPDATE_LIMIT_EXCEEDED" && typed.dataImpact === "none")
651
+ throw error;
652
+ throw new RuntimeDiagnosticError({
653
+ ...typed ?? {
654
+ code: "RUNTIME_STORAGE_PROVIDER_UNAVAILABLE",
655
+ stage: "request",
656
+ capability: "storage"
657
+ },
658
+ servingStarted: "unchanged",
659
+ dataImpact: "unknown",
660
+ retryable: false,
661
+ retryPrecondition: "Explicitly inspect the current selected files and visibility before a deliberate new action.",
662
+ nextAction: "Refresh Files and inspect the intended objects. Storage may have changed; no rollback or automatic replay is claimed."
663
+ });
664
+ }
665
+ }
666
+
667
+ export {
668
+ ProcedureRpcHandler,
669
+ snapshotRuntimeUploadLimitsInput,
670
+ resolveRuntimeUploadLimits,
671
+ assertRuntimeMultipartFiles,
672
+ filesystemMetadataSuffix,
673
+ filesystemMetadataMaxSerializedBytes,
674
+ filesystemLegacyMetadataSuffix,
675
+ filesystemRootOwnerFilename,
676
+ filesystemReadGrantKeyFilename,
677
+ filesystemRootInternalDirectories,
678
+ isValidStorageObjectId,
679
+ storageAdministrationInputInvalid,
680
+ storageAdministrationReadLimit,
681
+ storageAdministrationMetadataInvalid,
682
+ assertAdministrationStorageId,
683
+ assertAdministrationVisibility,
684
+ assertAdministrationUpload,
685
+ administrationMetadata,
686
+ storageAdministrationWrite,
687
+ isAzureObjectAbsent,
688
+ isAzureObjectHeadAbsent,
689
+ azureObjectNotFound,
690
+ azureMetadataInvalid,
691
+ azureStorageCall,
692
+ captureAzureStorageNamespace,
693
+ azureNamespaceResolver,
694
+ captureAzureNamespaceOption
695
+ };