@prisma/composer-prisma-cloud 0.2.0 → 0.3.0-dev.1
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/dist/buckets-main.mjs +795 -0
- package/dist/buckets-main.mjs.map +1 -0
- package/dist/compute-main.mjs +559 -0
- package/dist/compute-main.mjs.map +1 -0
- package/dist/control.d.mts +34 -5
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +98 -1280
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.d.mts +54 -4
- package/dist/cron/index.d.mts.map +1 -0
- package/dist/cron/index.mjs +145 -42
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +637 -529
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +145 -42
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/email/email-entrypoint.mjs +19738 -0
- package/dist/email/email-entrypoint.mjs.map +1 -0
- package/dist/email/email-service.mjs +565 -0
- package/dist/email/email-service.mjs.map +1 -0
- package/dist/email/index.d.mts +282 -0
- package/dist/email/index.d.mts.map +1 -0
- package/dist/email/index.mjs +652 -0
- package/dist/email/index.mjs.map +1 -0
- package/dist/email/testing.d.mts +22 -0
- package/dist/email/testing.d.mts.map +1 -0
- package/dist/email/testing.mjs +1321 -0
- package/dist/email/testing.mjs.map +1 -0
- package/dist/get-port-BYnpbW5H.mjs +111 -0
- package/dist/get-port-BYnpbW5H.mjs.map +1 -0
- package/dist/index.d.mts +37 -6
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +70 -45
- package/dist/index.mjs.map +1 -1
- package/dist/local-target.d.mts +12 -0
- package/dist/local-target.d.mts.map +1 -0
- package/dist/local-target.mjs +6185 -0
- package/dist/local-target.mjs.map +1 -0
- package/dist/param-BTzY0ne5-CW6ojZ3E.mjs +66 -0
- package/dist/param-BTzY0ne5-CW6ojZ3E.mjs.map +1 -0
- package/dist/pg-connection-CadPZuEK-CF3FsSQu.mjs +79 -0
- package/dist/pg-connection-CadPZuEK-CF3FsSQu.mjs.map +1 -0
- package/dist/postgres-main.mjs +602 -0
- package/dist/postgres-main.mjs.map +1 -0
- package/dist/preflight-names-BPL-qsZF-BfoRgbgb.mjs +1252 -0
- package/dist/preflight-names-BPL-qsZF-BfoRgbgb.mjs.map +1 -0
- package/dist/{prisma-next-DlU01kXJ-2sP5mQb6.mjs → prisma-next-BvBwGCIt-DssgnctU.mjs} +21 -80
- package/dist/prisma-next-BvBwGCIt-DssgnctU.mjs.map +1 -0
- package/dist/prisma-next.d.mts +14 -5
- package/dist/prisma-next.d.mts.map +1 -0
- package/dist/prisma-next.mjs +1 -1
- package/dist/provisioned-edges-C1wSO3cx-YC5C19f9.mjs +151 -0
- package/dist/provisioned-edges-C1wSO3cx-YC5C19f9.mjs.map +1 -0
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs +47 -0
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs.map +1 -0
- package/dist/segments-NpKN-46R-C_LQ2urs.mjs +1454 -0
- package/dist/segments-NpKN-46R-C_LQ2urs.mjs.map +1 -0
- package/dist/{serializer-CX4VYdf_-KKGoAxfx.mjs → serializer-CJiOhF2d-DJUjQj1i.mjs} +34 -44
- package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs.map +1 -0
- package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts.map +1 -0
- package/dist/storage/index.d.mts +52 -5
- package/dist/storage/index.d.mts.map +1 -0
- package/dist/storage/index.mjs +158 -47
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +370 -271
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +158 -47
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/storage/testing.d.mts +7 -6
- package/dist/storage/testing.d.mts.map +1 -0
- package/dist/storage/testing.mjs +4 -21
- package/dist/storage/testing.mjs.map +1 -1
- package/dist/streams/index.d.mts +56 -84
- package/dist/streams/index.d.mts.map +1 -0
- package/dist/streams/index.mjs +158 -47
- package/dist/streams/index.mjs.map +1 -1
- package/dist/streams/streams-entrypoint.mjs +366 -250
- package/dist/streams/streams-entrypoint.mjs.map +1 -1
- package/dist/streams/streams-service.mjs +158 -47
- package/dist/streams/streams-service.mjs.map +1 -1
- package/dist/streams/testing.d.mts.map +1 -0
- package/dist/testing.d.mts.map +1 -0
- package/dist/testing.mjs +1 -1
- package/dist/testing.mjs.map +1 -1
- package/package.json +34 -20
- package/src/exports/control.ts +1 -0
- package/src/exports/cron.ts +1 -0
- package/src/exports/email-testing.ts +1 -0
- package/src/exports/email.ts +1 -0
- package/src/exports/index.ts +1 -0
- package/src/exports/local-target.ts +1 -0
- package/src/exports/prisma-next.ts +1 -0
- package/src/exports/storage-testing.ts +1 -0
- package/src/exports/storage.ts +1 -0
- package/src/exports/streams-testing.ts +1 -0
- package/src/exports/streams.ts +1 -0
- package/src/exports/testing.ts +1 -0
- package/dist/prisma-next-DlU01kXJ-2sP5mQb6.mjs.map +0 -1
- package/dist/provisioned-edges-DIQAR4q4-Bn9op-JG.mjs +0 -151
- package/dist/provisioned-edges-DIQAR4q4-Bn9op-JG.mjs.map +0 -1
- package/dist/serializer-CX4VYdf_-KKGoAxfx.mjs.map +0 -1
|
@@ -61,15 +61,19 @@ function requireExtension(extension, factory) {
|
|
|
61
61
|
if (typeof extension !== "string" || extension.length === 0) throw new Error(`${factory}() requires a non-empty extension (the authoring extension's package name).`);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
64
|
+
* Core's grammar for every name that becomes a config-key segment —
|
|
65
|
+
* addresses, input/param/secret names: ASCII letters and digits only.
|
|
66
|
+
* Conservative by design so any target medium — POSIX env-var keys
|
|
67
|
+
* included — can uppercase and "_"-join segments without escaping.
|
|
67
68
|
*/
|
|
68
|
-
function
|
|
69
|
-
|
|
69
|
+
function isConfigKeySegment(name) {
|
|
70
|
+
return /^[A-Za-z0-9]+$/.test(name);
|
|
70
71
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
72
|
+
function requireConfigKeySegmentName(name, kind, factory) {
|
|
73
|
+
if (!isConfigKeySegment(name)) throw new Error(`${factory}() ${kind} name "${name}" must contain only ASCII letters and digits ([A-Za-z0-9]) — declared names derive deterministic config keys, uppercased and joined with "_" (an input "db"'s param "url" becomes config key "DB_URL"), so an underscore inside a name collides with that separator and any other character has no place in a config key. "${name}" would put "${name.toUpperCase()}" inside the derived key.`);
|
|
74
|
+
}
|
|
75
|
+
function requireConfigKeySegmentNames(names, kind, factory) {
|
|
76
|
+
for (const name of names) requireConfigKeySegmentName(name, kind, factory);
|
|
73
77
|
}
|
|
74
78
|
function freezeParams(params) {
|
|
75
79
|
const frozen = {};
|
|
@@ -93,9 +97,9 @@ function service$1(def) {
|
|
|
93
97
|
requireName(def.name, "service");
|
|
94
98
|
requireExtension(def.extension, "service");
|
|
95
99
|
requireType(def.type, "service");
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
requireConfigKeySegmentNames(Object.keys(def.inputs), "input", "service");
|
|
101
|
+
requireConfigKeySegmentNames(Object.keys(def.params), "param", "service");
|
|
102
|
+
requireConfigKeySegmentNames(Object.keys(def.secrets ?? {}), "secret", "service");
|
|
99
103
|
for (const slot of Object.keys(def.secrets ?? {})) if (Object.hasOwn(def.params, slot)) throw new Error(`service() secret slot "${slot}" collides with a param of the same name — a secret slot and a service param derive the same config key (COMPOSER_<addr>_${slot.toUpperCase()}); rename one.`);
|
|
100
104
|
return Object.freeze({
|
|
101
105
|
[NODE]: true,
|
|
@@ -117,7 +121,7 @@ function service$1(def) {
|
|
|
117
121
|
*/
|
|
118
122
|
function dependency(def) {
|
|
119
123
|
requireType(def.type, "dependency");
|
|
120
|
-
|
|
124
|
+
requireConfigKeySegmentNames(Object.keys(def.connection.params), "param", "dependency");
|
|
121
125
|
const connection = Object.freeze({
|
|
122
126
|
params: freezeParams(def.connection.params),
|
|
123
127
|
hydrate: def.connection.hydrate
|
|
@@ -237,432 +241,129 @@ const nodeBuild = (opts) => ({
|
|
|
237
241
|
entry: opts.entry,
|
|
238
242
|
...opts.dir === void 0 ? {} : { dir: opts.dir }
|
|
239
243
|
});
|
|
244
|
+
const liftArray = (data) => Array.isArray(data) ? data : [data];
|
|
240
245
|
/**
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
246
|
+
* Splits an array into two arrays based on the result of a predicate
|
|
247
|
+
*
|
|
248
|
+
* @param predicate - The guard function used to determine which items to include.
|
|
249
|
+
* @returns A tuple containing two arrays:
|
|
250
|
+
* - the first includes items for which `predicate` returns true
|
|
251
|
+
* - the second includes items for which `predicate` returns false
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* const list = [1, "2", "3", 4, 5];
|
|
255
|
+
* const [numbers, strings] = spliterate(list, (x) => typeof x === "number");
|
|
256
|
+
* // Type: number[]
|
|
257
|
+
* // Output: [1, 4, 5]
|
|
258
|
+
* console.log(evens);
|
|
259
|
+
* // Type: string[]
|
|
260
|
+
* // Output: ["2", "3"]
|
|
261
|
+
* console.log(odds);
|
|
245
262
|
*/
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
for (const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
for (const [name, param] of Object.entries(params)) entries.push({
|
|
252
|
-
owner: { input },
|
|
253
|
-
name,
|
|
254
|
-
param
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
258
|
-
owner: "service",
|
|
259
|
-
name,
|
|
260
|
-
param
|
|
261
|
-
});
|
|
262
|
-
return entries;
|
|
263
|
-
}
|
|
264
|
-
const configKey = (address, d) => {
|
|
265
|
-
const segments = address.split(".").filter((s) => s.length > 0);
|
|
266
|
-
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
267
|
-
return [
|
|
268
|
-
"COMPOSER",
|
|
269
|
-
...segments,
|
|
270
|
-
...owner,
|
|
271
|
-
d.name
|
|
272
|
-
].join("_").toUpperCase();
|
|
263
|
+
const spliterate = (arr, predicate) => {
|
|
264
|
+
const result = [[], []];
|
|
265
|
+
for (const item of arr) if (predicate(item)) result[0].push(item);
|
|
266
|
+
else result[1].push(item);
|
|
267
|
+
return result;
|
|
273
268
|
};
|
|
269
|
+
const ReadonlyArray = Array;
|
|
270
|
+
const includes = (array, element) => array.includes(element);
|
|
271
|
+
const range = (length, offset = 0) => [...new Array(length)].map((_, i) => i + offset);
|
|
274
272
|
/**
|
|
275
|
-
*
|
|
276
|
-
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
277
|
-
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
278
|
-
* would break the ordering edge Alchemy resolves through it.
|
|
273
|
+
* Adds a value or array to an array, returning the concatenated result
|
|
279
274
|
*/
|
|
280
|
-
|
|
281
|
-
return
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
289
|
-
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
290
|
-
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
291
|
-
const decodeParamPointer = (raw) => raw.slice(24);
|
|
292
|
-
function coerce(raw, d, key) {
|
|
293
|
-
if (!(raw !== void 0 && raw !== "")) {
|
|
294
|
-
if (d.param.default !== void 0) return d.param.default;
|
|
295
|
-
if (d.param.optional === true) return void 0;
|
|
296
|
-
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
297
|
-
}
|
|
298
|
-
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
299
|
-
try {
|
|
300
|
-
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
301
|
-
} catch (cause) {
|
|
302
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
303
|
-
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
275
|
+
const append = (to, value, opts) => {
|
|
276
|
+
if (to === void 0) return value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
277
|
+
if (opts?.prepend) if (Array.isArray(value)) to.unshift(...value);
|
|
278
|
+
else to.unshift(value);
|
|
279
|
+
else if (Array.isArray(value)) to.push(...value);
|
|
280
|
+
else to.push(value);
|
|
281
|
+
return to;
|
|
282
|
+
};
|
|
306
283
|
/**
|
|
307
|
-
*
|
|
308
|
-
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
309
|
-
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
310
|
-
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
311
|
-
* not special-cased here — it reaches the schema like any other value, so it
|
|
312
|
-
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
313
|
-
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
284
|
+
* Concatenates an element or list with a readonly list
|
|
314
285
|
*/
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return standardValidateSync(d.param.schema, value);
|
|
321
|
-
} catch (cause) {
|
|
322
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
323
|
-
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
286
|
+
const conflatenate = (to, elementOrList) => {
|
|
287
|
+
if (elementOrList === void 0 || elementOrList === null) return to ?? [];
|
|
288
|
+
if (to === void 0 || to === null) return liftArray(elementOrList);
|
|
289
|
+
return to.concat(elementOrList);
|
|
290
|
+
};
|
|
326
291
|
/**
|
|
327
|
-
*
|
|
328
|
-
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
329
|
-
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
292
|
+
* Concatenates a variadic list of elements or lists with a readonly list
|
|
330
293
|
*/
|
|
331
|
-
const
|
|
332
|
-
const service = {};
|
|
333
|
-
const inputs = {};
|
|
334
|
-
for (const d of paramEntries(node)) {
|
|
335
|
-
const key = configKey(address, d);
|
|
336
|
-
const value = coerce(process.env[key], d, key);
|
|
337
|
-
if (d.owner === "service") service[d.name] = value;
|
|
338
|
-
else {
|
|
339
|
-
let bucket = inputs[d.owner.input];
|
|
340
|
-
if (bucket === void 0) {
|
|
341
|
-
bucket = {};
|
|
342
|
-
inputs[d.owner.input] = bucket;
|
|
343
|
-
}
|
|
344
|
-
bucket[d.name] = value;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return {
|
|
348
|
-
service,
|
|
349
|
-
inputs
|
|
350
|
-
};
|
|
351
|
-
};
|
|
294
|
+
const conflatenateAll = (...elementsOrLists) => elementsOrLists.reduce(conflatenate, []);
|
|
352
295
|
/**
|
|
353
|
-
*
|
|
354
|
-
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
355
|
-
* reads back with no address. Uses env, not a module variable, because a
|
|
356
|
-
* framework may fork worker processes that inherit env but not memory.
|
|
357
|
-
* Writes only these keys; nothing else is touched.
|
|
296
|
+
* Appends a value or concatenates an array to an array if it is not already included, returning the array
|
|
358
297
|
*/
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
298
|
+
const appendUnique = (to, value, opts) => {
|
|
299
|
+
if (to === void 0) return Array.isArray(value) ? value : [value];
|
|
300
|
+
const isEqual = opts?.isEqual ?? ((l, r) => l === r);
|
|
301
|
+
for (const v of liftArray(value)) if (!to.some((existing) => isEqual(existing, v))) to.push(v);
|
|
302
|
+
return to;
|
|
365
303
|
};
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
});
|
|
304
|
+
const groupBy = (array, discriminant) => array.reduce((result, item) => {
|
|
305
|
+
const key = item[discriminant];
|
|
306
|
+
result[key] = append(result[key], item);
|
|
307
|
+
return result;
|
|
308
|
+
}, {});
|
|
309
|
+
const arrayEquals = (l, r, opts) => l.length === r.length && l.every(opts?.isEqual ? (lItem, i) => opts.isEqual(lItem, r[i]) : (lItem, i) => lItem === r[i]);
|
|
310
|
+
const hasDomain = (data, kind) => domainOf(data) === kind;
|
|
311
|
+
const domainOf = (data) => {
|
|
312
|
+
const builtinType = typeof data;
|
|
313
|
+
return builtinType === "object" ? data === null ? "null" : "object" : builtinType === "function" ? "object" : builtinType;
|
|
314
|
+
};
|
|
315
|
+
/** Each domain's completion for the phrase "must be _____" */
|
|
316
|
+
const domainDescriptions = {
|
|
317
|
+
boolean: "boolean",
|
|
318
|
+
null: "null",
|
|
319
|
+
undefined: "undefined",
|
|
320
|
+
bigint: "a bigint",
|
|
321
|
+
number: "a number",
|
|
322
|
+
object: "an object",
|
|
323
|
+
string: "a string",
|
|
324
|
+
symbol: "a symbol"
|
|
325
|
+
};
|
|
326
|
+
const jsTypeOfDescriptions = {
|
|
327
|
+
...domainDescriptions,
|
|
328
|
+
function: "a function"
|
|
329
|
+
};
|
|
330
|
+
var InternalArktypeError = class extends Error {};
|
|
331
|
+
const throwInternalError = (message) => throwError(message, InternalArktypeError);
|
|
332
|
+
const throwError = (message, ctor = Error) => {
|
|
333
|
+
throw new ctor(message);
|
|
334
|
+
};
|
|
335
|
+
var ParseError = class extends Error {
|
|
336
|
+
name = "ParseError";
|
|
337
|
+
};
|
|
338
|
+
const throwParseError = (message) => throwError(message, ParseError);
|
|
371
339
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
375
|
-
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
340
|
+
* TypeScript won't suggest strings beginning with a space as properties.
|
|
341
|
+
* Useful for symbol-like string properties.
|
|
376
342
|
*/
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
343
|
+
const noSuggest = (s) => ` ${s}`;
|
|
344
|
+
const flatMorph = (o, flatMapEntry) => {
|
|
345
|
+
const result = {};
|
|
346
|
+
const inputIsArray = Array.isArray(o);
|
|
347
|
+
let outputShouldBeArray = false;
|
|
348
|
+
for (const [i, entry] of Object.entries(o).entries()) {
|
|
349
|
+
const mapped = inputIsArray ? flatMapEntry(i, entry[1]) : flatMapEntry(...entry, i);
|
|
350
|
+
outputShouldBeArray ||= typeof mapped[0] === "number";
|
|
351
|
+
const flattenedEntries = Array.isArray(mapped[0]) || mapped.length === 0 ? mapped : [mapped];
|
|
352
|
+
for (const [k, v] of flattenedEntries) if (typeof k === "object") result[k.group] = append(result[k.group], v);
|
|
353
|
+
else result[k] = v;
|
|
386
354
|
}
|
|
387
|
-
return values;
|
|
355
|
+
return outputShouldBeArray ? Object.values(result) : result;
|
|
388
356
|
};
|
|
389
357
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* identically. Never the value — the value stays only in the platform var.
|
|
358
|
+
* Object.entries wrapper providing narrowed types for objects with known sets
|
|
359
|
+
* of keys, e.g. those defined internally as configs
|
|
393
360
|
*/
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
};
|
|
401
|
-
/**
|
|
402
|
-
* Boot: for each reserved provider param, read its address-scoped row through
|
|
403
|
-
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
404
|
-
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
405
|
-
* declaration space. A param is declared optional here unconditionally: an
|
|
406
|
-
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
407
|
-
* registered value for this deploy), never a boot failure, so nothing is
|
|
408
|
-
* stashed and the runtime reader that owns this slot falls back to its own
|
|
409
|
-
* pass-through behavior.
|
|
410
|
-
*/
|
|
411
|
-
function stashProviderParams(entries, address) {
|
|
412
|
-
for (const entry of entries) {
|
|
413
|
-
const d = {
|
|
414
|
-
owner: "service",
|
|
415
|
-
name: entry.name,
|
|
416
|
-
param: {
|
|
417
|
-
schema: entry.schema,
|
|
418
|
-
optional: true
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
const key = configKey(address, d);
|
|
422
|
-
const value = coerce(process.env[key], d, key);
|
|
423
|
-
if (value === void 0) continue;
|
|
424
|
-
process.env[configKey("", d)] = encode("service", value);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
428
|
-
function standardValidateSync(schema, value) {
|
|
429
|
-
const result = schema["~standard"].validate(value);
|
|
430
|
-
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
431
|
-
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
432
|
-
return result.value;
|
|
433
|
-
}
|
|
434
|
-
/** Bounded jittered backoff for retrying a dropped call. `maxRetries` is retries after the first attempt. */
|
|
435
|
-
const RETRY = {
|
|
436
|
-
initialDelayMs: 250,
|
|
437
|
-
multiplier: 2,
|
|
438
|
-
maxDelayMs: 5e3,
|
|
439
|
-
maxRetries: 5
|
|
440
|
-
};
|
|
441
|
-
const IDEMPOTENCY_KEY_HEADER$1 = "Idempotency-Key";
|
|
442
|
-
function sleep(ms) {
|
|
443
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
444
|
-
}
|
|
445
|
-
/** Whether a non-OK response is safe to retry: 429 or any 5xx, never another 4xx. */
|
|
446
|
-
function isRetryableStatus(status) {
|
|
447
|
-
return status === 429 || status >= 500;
|
|
448
|
-
}
|
|
449
|
-
/** The server's `{ error }` body, if the response has one — undefined otherwise. */
|
|
450
|
-
async function errorDetail(res) {
|
|
451
|
-
try {
|
|
452
|
-
const body = await res.json();
|
|
453
|
-
return typeof body === "object" && body !== null && "error" in body ? String(body.error) : void 0;
|
|
454
|
-
} catch {
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
/** `<base>/rpc/<method>`, preserving a base URL's own path (e.g. a mount point). */
|
|
459
|
-
function methodUrl(base, method) {
|
|
460
|
-
const normalizedBase = base.endsWith("/") ? base : `${base}/`;
|
|
461
|
-
return new URL(`rpc/${method}`, normalizedBase).toString();
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Sends one call over `send`, retrying a thrown error, 429, or 5xx with
|
|
465
|
-
* full-jitter backoff. `buildRequest` runs per attempt but carries the same
|
|
466
|
-
* idempotency key each time — only the transport call repeats, not the key.
|
|
467
|
-
*/
|
|
468
|
-
async function callWithRetry(send, buildRequest, method) {
|
|
469
|
-
let delay = RETRY.initialDelayMs;
|
|
470
|
-
let retries = 0;
|
|
471
|
-
for (;;) {
|
|
472
|
-
let res;
|
|
473
|
-
try {
|
|
474
|
-
res = await send(buildRequest());
|
|
475
|
-
} catch (err) {
|
|
476
|
-
if (retries >= RETRY.maxRetries) throw err;
|
|
477
|
-
retries += 1;
|
|
478
|
-
await sleep(Math.random() * delay);
|
|
479
|
-
delay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);
|
|
480
|
-
continue;
|
|
481
|
-
}
|
|
482
|
-
if (res.ok) return res.json();
|
|
483
|
-
if (!isRetryableStatus(res.status) || retries >= RETRY.maxRetries) {
|
|
484
|
-
const detail = await errorDetail(res);
|
|
485
|
-
throw new Error(`RPC call "${method}" failed: ${res.status} ${res.statusText}` + (detail !== void 0 ? ` — ${detail}` : ""));
|
|
486
|
-
}
|
|
487
|
-
retries += 1;
|
|
488
|
-
await sleep(Math.random() * delay);
|
|
489
|
-
delay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
function makeClient(contract, url, opts) {
|
|
493
|
-
const send = opts?.fetch ?? fetch;
|
|
494
|
-
const baseHeaders = { "content-type": "application/json" };
|
|
495
|
-
if (opts?.serviceKey !== void 0) baseHeaders["Authorization"] = `Bearer ${opts.serviceKey}`;
|
|
496
|
-
const client = {};
|
|
497
|
-
for (const method of Object.keys(contract.__cmp)) client[method] = async (input) => {
|
|
498
|
-
const idempotencyKey = crypto.randomUUID();
|
|
499
|
-
const body = JSON.stringify(input);
|
|
500
|
-
return callWithRetry(send, () => new Request(methodUrl(url, method), {
|
|
501
|
-
method: "POST",
|
|
502
|
-
headers: {
|
|
503
|
-
...baseHeaders,
|
|
504
|
-
[IDEMPOTENCY_KEY_HEADER$1]: idempotencyKey
|
|
505
|
-
},
|
|
506
|
-
body
|
|
507
|
-
}), method);
|
|
508
|
-
};
|
|
509
|
-
return blindCast(client);
|
|
510
|
-
}
|
|
511
|
-
function contract(fns) {
|
|
512
|
-
const value = {
|
|
513
|
-
kind: "rpc",
|
|
514
|
-
__cmp: fns,
|
|
515
|
-
satisfies: (required) => value === required
|
|
516
|
-
};
|
|
517
|
-
return Object.freeze(value);
|
|
518
|
-
}
|
|
519
|
-
/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
|
|
520
|
-
const RPC_PEER_KEY = Symbol.for("prisma:rpc/per-binding-key");
|
|
521
|
-
/** The provisioning need `rpc()`'s `serviceKey` param declares (ADR-0030): a shared, unguessable value the target mints per consumer edge. */
|
|
522
|
-
const perBindingToken = () => provisionNeed(RPC_PEER_KEY);
|
|
523
|
-
function rpc(arg) {
|
|
524
|
-
if (!isRpcContract(arg)) return arg;
|
|
525
|
-
return dependency({
|
|
526
|
-
type: "rpc",
|
|
527
|
-
connection: {
|
|
528
|
-
params: {
|
|
529
|
-
url: string$1(),
|
|
530
|
-
serviceKey: string$1({
|
|
531
|
-
optional: true,
|
|
532
|
-
provision: perBindingToken()
|
|
533
|
-
})
|
|
534
|
-
},
|
|
535
|
-
hydrate: ({ url, serviceKey }) => makeClient(arg, url, { serviceKey })
|
|
536
|
-
},
|
|
537
|
-
required: arg
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
function isRpcContract(value) {
|
|
541
|
-
return typeof value === "object" && value !== null && "kind" in value && value.kind === "rpc" && "__cmp" in value && "satisfies" in value;
|
|
542
|
-
}
|
|
543
|
-
const liftArray = (data) => Array.isArray(data) ? data : [data];
|
|
544
|
-
/**
|
|
545
|
-
* Splits an array into two arrays based on the result of a predicate
|
|
546
|
-
*
|
|
547
|
-
* @param predicate - The guard function used to determine which items to include.
|
|
548
|
-
* @returns A tuple containing two arrays:
|
|
549
|
-
* - the first includes items for which `predicate` returns true
|
|
550
|
-
* - the second includes items for which `predicate` returns false
|
|
551
|
-
*
|
|
552
|
-
* @example
|
|
553
|
-
* const list = [1, "2", "3", 4, 5];
|
|
554
|
-
* const [numbers, strings] = spliterate(list, (x) => typeof x === "number");
|
|
555
|
-
* // Type: number[]
|
|
556
|
-
* // Output: [1, 4, 5]
|
|
557
|
-
* console.log(evens);
|
|
558
|
-
* // Type: string[]
|
|
559
|
-
* // Output: ["2", "3"]
|
|
560
|
-
* console.log(odds);
|
|
561
|
-
*/
|
|
562
|
-
const spliterate = (arr, predicate) => {
|
|
563
|
-
const result = [[], []];
|
|
564
|
-
for (const item of arr) if (predicate(item)) result[0].push(item);
|
|
565
|
-
else result[1].push(item);
|
|
566
|
-
return result;
|
|
567
|
-
};
|
|
568
|
-
const ReadonlyArray = Array;
|
|
569
|
-
const includes = (array, element) => array.includes(element);
|
|
570
|
-
const range = (length, offset = 0) => [...new Array(length)].map((_, i) => i + offset);
|
|
571
|
-
/**
|
|
572
|
-
* Adds a value or array to an array, returning the concatenated result
|
|
573
|
-
*/
|
|
574
|
-
const append = (to, value, opts) => {
|
|
575
|
-
if (to === void 0) return value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
576
|
-
if (opts?.prepend) if (Array.isArray(value)) to.unshift(...value);
|
|
577
|
-
else to.unshift(value);
|
|
578
|
-
else if (Array.isArray(value)) to.push(...value);
|
|
579
|
-
else to.push(value);
|
|
580
|
-
return to;
|
|
581
|
-
};
|
|
582
|
-
/**
|
|
583
|
-
* Concatenates an element or list with a readonly list
|
|
584
|
-
*/
|
|
585
|
-
const conflatenate = (to, elementOrList) => {
|
|
586
|
-
if (elementOrList === void 0 || elementOrList === null) return to ?? [];
|
|
587
|
-
if (to === void 0 || to === null) return liftArray(elementOrList);
|
|
588
|
-
return to.concat(elementOrList);
|
|
589
|
-
};
|
|
590
|
-
/**
|
|
591
|
-
* Concatenates a variadic list of elements or lists with a readonly list
|
|
592
|
-
*/
|
|
593
|
-
const conflatenateAll = (...elementsOrLists) => elementsOrLists.reduce(conflatenate, []);
|
|
594
|
-
/**
|
|
595
|
-
* Appends a value or concatenates an array to an array if it is not already included, returning the array
|
|
596
|
-
*/
|
|
597
|
-
const appendUnique = (to, value, opts) => {
|
|
598
|
-
if (to === void 0) return Array.isArray(value) ? value : [value];
|
|
599
|
-
const isEqual = opts?.isEqual ?? ((l, r) => l === r);
|
|
600
|
-
for (const v of liftArray(value)) if (!to.some((existing) => isEqual(existing, v))) to.push(v);
|
|
601
|
-
return to;
|
|
602
|
-
};
|
|
603
|
-
const groupBy = (array, discriminant) => array.reduce((result, item) => {
|
|
604
|
-
const key = item[discriminant];
|
|
605
|
-
result[key] = append(result[key], item);
|
|
606
|
-
return result;
|
|
607
|
-
}, {});
|
|
608
|
-
const arrayEquals = (l, r, opts) => l.length === r.length && l.every(opts?.isEqual ? (lItem, i) => opts.isEqual(lItem, r[i]) : (lItem, i) => lItem === r[i]);
|
|
609
|
-
const hasDomain = (data, kind) => domainOf(data) === kind;
|
|
610
|
-
const domainOf = (data) => {
|
|
611
|
-
const builtinType = typeof data;
|
|
612
|
-
return builtinType === "object" ? data === null ? "null" : "object" : builtinType === "function" ? "object" : builtinType;
|
|
613
|
-
};
|
|
614
|
-
/** Each domain's completion for the phrase "must be _____" */
|
|
615
|
-
const domainDescriptions = {
|
|
616
|
-
boolean: "boolean",
|
|
617
|
-
null: "null",
|
|
618
|
-
undefined: "undefined",
|
|
619
|
-
bigint: "a bigint",
|
|
620
|
-
number: "a number",
|
|
621
|
-
object: "an object",
|
|
622
|
-
string: "a string",
|
|
623
|
-
symbol: "a symbol"
|
|
624
|
-
};
|
|
625
|
-
const jsTypeOfDescriptions = {
|
|
626
|
-
...domainDescriptions,
|
|
627
|
-
function: "a function"
|
|
628
|
-
};
|
|
629
|
-
var InternalArktypeError = class extends Error {};
|
|
630
|
-
const throwInternalError = (message) => throwError(message, InternalArktypeError);
|
|
631
|
-
const throwError = (message, ctor = Error) => {
|
|
632
|
-
throw new ctor(message);
|
|
633
|
-
};
|
|
634
|
-
var ParseError = class extends Error {
|
|
635
|
-
name = "ParseError";
|
|
636
|
-
};
|
|
637
|
-
const throwParseError = (message) => throwError(message, ParseError);
|
|
638
|
-
/**
|
|
639
|
-
* TypeScript won't suggest strings beginning with a space as properties.
|
|
640
|
-
* Useful for symbol-like string properties.
|
|
641
|
-
*/
|
|
642
|
-
const noSuggest = (s) => ` ${s}`;
|
|
643
|
-
const flatMorph = (o, flatMapEntry) => {
|
|
644
|
-
const result = {};
|
|
645
|
-
const inputIsArray = Array.isArray(o);
|
|
646
|
-
let outputShouldBeArray = false;
|
|
647
|
-
for (const [i, entry] of Object.entries(o).entries()) {
|
|
648
|
-
const mapped = inputIsArray ? flatMapEntry(i, entry[1]) : flatMapEntry(...entry, i);
|
|
649
|
-
outputShouldBeArray ||= typeof mapped[0] === "number";
|
|
650
|
-
const flattenedEntries = Array.isArray(mapped[0]) || mapped.length === 0 ? mapped : [mapped];
|
|
651
|
-
for (const [k, v] of flattenedEntries) if (typeof k === "object") result[k.group] = append(result[k.group], v);
|
|
652
|
-
else result[k] = v;
|
|
653
|
-
}
|
|
654
|
-
return outputShouldBeArray ? Object.values(result) : result;
|
|
655
|
-
};
|
|
656
|
-
/**
|
|
657
|
-
* Object.entries wrapper providing narrowed types for objects with known sets
|
|
658
|
-
* of keys, e.g. those defined internally as configs
|
|
659
|
-
*/
|
|
660
|
-
const entriesOf = Object.entries;
|
|
661
|
-
const isKeyOf = (k, o) => k in o;
|
|
662
|
-
const hasKey = (o, k) => k in o;
|
|
663
|
-
var DynamicBase = class {
|
|
664
|
-
constructor(properties) {
|
|
665
|
-
Object.assign(this, properties);
|
|
361
|
+
const entriesOf = Object.entries;
|
|
362
|
+
const isKeyOf = (k, o) => k in o;
|
|
363
|
+
const hasKey = (o, k) => k in o;
|
|
364
|
+
var DynamicBase = class {
|
|
365
|
+
constructor(properties) {
|
|
366
|
+
Object.assign(this, properties);
|
|
666
367
|
}
|
|
667
368
|
};
|
|
668
369
|
const NoopBase = class {};
|
|
@@ -7583,81 +7284,447 @@ const Record = genericNode(["K", intrinsic.key], "V")((args) => ({
|
|
|
7583
7284
|
signature: args.K,
|
|
7584
7285
|
value: args.V
|
|
7585
7286
|
}
|
|
7586
|
-
}), RecordHkt);
|
|
7587
|
-
var PickHkt = class extends Hkt {
|
|
7588
|
-
description = "pick a set of properties from an object like `Pick(User, \"name | age\")`";
|
|
7589
|
-
};
|
|
7590
|
-
const Pick = genericNode(["T", intrinsic.object], ["K", intrinsic.key])((args) => args.T.pick(args.K), PickHkt);
|
|
7591
|
-
var OmitHkt = class extends Hkt {
|
|
7592
|
-
description = "omit a set of properties from an object like `Omit(User, \"age\")`";
|
|
7593
|
-
};
|
|
7594
|
-
const Omit = genericNode(["T", intrinsic.object], ["K", intrinsic.key])((args) => args.T.omit(args.K), OmitHkt);
|
|
7595
|
-
var PartialHkt = class extends Hkt {
|
|
7596
|
-
description = "make all named properties of an object optional like `Partial(User)`";
|
|
7597
|
-
};
|
|
7598
|
-
const Partial = genericNode(["T", intrinsic.object])((args) => args.T.partial(), PartialHkt);
|
|
7599
|
-
var RequiredHkt = class extends Hkt {
|
|
7600
|
-
description = "make all named properties of an object required like `Required(User)`";
|
|
7287
|
+
}), RecordHkt);
|
|
7288
|
+
var PickHkt = class extends Hkt {
|
|
7289
|
+
description = "pick a set of properties from an object like `Pick(User, \"name | age\")`";
|
|
7290
|
+
};
|
|
7291
|
+
const Pick = genericNode(["T", intrinsic.object], ["K", intrinsic.key])((args) => args.T.pick(args.K), PickHkt);
|
|
7292
|
+
var OmitHkt = class extends Hkt {
|
|
7293
|
+
description = "omit a set of properties from an object like `Omit(User, \"age\")`";
|
|
7294
|
+
};
|
|
7295
|
+
const Omit = genericNode(["T", intrinsic.object], ["K", intrinsic.key])((args) => args.T.omit(args.K), OmitHkt);
|
|
7296
|
+
var PartialHkt = class extends Hkt {
|
|
7297
|
+
description = "make all named properties of an object optional like `Partial(User)`";
|
|
7298
|
+
};
|
|
7299
|
+
const Partial = genericNode(["T", intrinsic.object])((args) => args.T.partial(), PartialHkt);
|
|
7300
|
+
var RequiredHkt = class extends Hkt {
|
|
7301
|
+
description = "make all named properties of an object required like `Required(User)`";
|
|
7302
|
+
};
|
|
7303
|
+
const Required = genericNode(["T", intrinsic.object])((args) => args.T.required(), RequiredHkt);
|
|
7304
|
+
var ExcludeHkt = class extends Hkt {
|
|
7305
|
+
description = "exclude branches of a union like `Exclude(\"boolean\", \"true\")`";
|
|
7306
|
+
};
|
|
7307
|
+
const Exclude = genericNode("T", "U")((args) => args.T.exclude(args.U), ExcludeHkt);
|
|
7308
|
+
var ExtractHkt = class extends Hkt {
|
|
7309
|
+
description = "extract branches of a union like `Extract(\"0 | false | 1\", \"number\")`";
|
|
7310
|
+
};
|
|
7311
|
+
const Extract = genericNode("T", "U")((args) => args.T.extract(args.U), ExtractHkt);
|
|
7312
|
+
const arkTsGenerics = Scope.module({
|
|
7313
|
+
Exclude,
|
|
7314
|
+
Extract,
|
|
7315
|
+
Omit,
|
|
7316
|
+
Partial,
|
|
7317
|
+
Pick,
|
|
7318
|
+
Record,
|
|
7319
|
+
Required
|
|
7320
|
+
});
|
|
7321
|
+
const ark = scope({
|
|
7322
|
+
...arkTsKeywords,
|
|
7323
|
+
...arkTsGenerics,
|
|
7324
|
+
...arkPrototypes,
|
|
7325
|
+
...arkBuiltins,
|
|
7326
|
+
string,
|
|
7327
|
+
number,
|
|
7328
|
+
object,
|
|
7329
|
+
unknown
|
|
7330
|
+
}, {
|
|
7331
|
+
prereducedAliases: true,
|
|
7332
|
+
name: "ark"
|
|
7333
|
+
});
|
|
7334
|
+
const keywords = ark.export();
|
|
7335
|
+
Object.assign($arkTypeRegistry.ambient, keywords);
|
|
7336
|
+
$arkTypeRegistry.typeAttachments = {
|
|
7337
|
+
string: keywords.string.root,
|
|
7338
|
+
number: keywords.number.root,
|
|
7339
|
+
bigint: keywords.bigint,
|
|
7340
|
+
boolean: keywords.boolean,
|
|
7341
|
+
symbol: keywords.symbol,
|
|
7342
|
+
undefined: keywords.undefined,
|
|
7343
|
+
null: keywords.null,
|
|
7344
|
+
object: keywords.object.root,
|
|
7345
|
+
unknown: keywords.unknown.root,
|
|
7346
|
+
false: keywords.false,
|
|
7347
|
+
true: keywords.true,
|
|
7348
|
+
never: keywords.never,
|
|
7349
|
+
arrayIndex: keywords.Array.index,
|
|
7350
|
+
Key: keywords.Key,
|
|
7351
|
+
Record: keywords.Record,
|
|
7352
|
+
Array: keywords.Array.root,
|
|
7353
|
+
Date: keywords.Date
|
|
7354
|
+
};
|
|
7355
|
+
const type = Object.assign(ark.type, $arkTypeRegistry.typeAttachments);
|
|
7356
|
+
ark.match;
|
|
7357
|
+
ark.fn;
|
|
7358
|
+
ark.generic;
|
|
7359
|
+
ark.schema;
|
|
7360
|
+
ark.define;
|
|
7361
|
+
ark.declare;
|
|
7362
|
+
/**
|
|
7363
|
+
* Walks a node's own params, then each dependency input's connection params —
|
|
7364
|
+
* the same enumeration order `configOf` uses, but carrying the raw
|
|
7365
|
+
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
7366
|
+
* projection.
|
|
7367
|
+
*/
|
|
7368
|
+
function paramEntries(node) {
|
|
7369
|
+
const entries = [];
|
|
7370
|
+
for (const [input, value] of Object.entries(node.inputs)) {
|
|
7371
|
+
if (typeof value !== "object" || value === null) continue;
|
|
7372
|
+
const params = blindCast(value).connection.params;
|
|
7373
|
+
for (const [name, param] of Object.entries(params)) entries.push({
|
|
7374
|
+
owner: { input },
|
|
7375
|
+
name,
|
|
7376
|
+
param
|
|
7377
|
+
});
|
|
7378
|
+
}
|
|
7379
|
+
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
7380
|
+
owner: "service",
|
|
7381
|
+
name,
|
|
7382
|
+
param
|
|
7383
|
+
});
|
|
7384
|
+
return entries;
|
|
7385
|
+
}
|
|
7386
|
+
const configKey = (address, d) => {
|
|
7387
|
+
const segments = address.split(".").filter((s) => s.length > 0);
|
|
7388
|
+
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
7389
|
+
return [
|
|
7390
|
+
"COMPOSER",
|
|
7391
|
+
...segments,
|
|
7392
|
+
...owner,
|
|
7393
|
+
d.name
|
|
7394
|
+
].join("_").toUpperCase();
|
|
7395
|
+
};
|
|
7396
|
+
/**
|
|
7397
|
+
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
7398
|
+
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
7399
|
+
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
7400
|
+
* would break the ordering edge Alchemy resolves through it.
|
|
7401
|
+
*/
|
|
7402
|
+
function encode(owner, value) {
|
|
7403
|
+
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
7404
|
+
}
|
|
7405
|
+
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
7406
|
+
function decode(owner, raw) {
|
|
7407
|
+
return owner === "service" ? JSON.parse(raw) : raw;
|
|
7408
|
+
}
|
|
7409
|
+
const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
|
|
7410
|
+
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
7411
|
+
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
7412
|
+
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
7413
|
+
const decodeParamPointer = (raw) => raw.slice(24);
|
|
7414
|
+
function coerce(raw, d, key) {
|
|
7415
|
+
if (!(raw !== void 0 && raw !== "")) {
|
|
7416
|
+
if (d.param.default !== void 0) return d.param.default;
|
|
7417
|
+
if (d.param.optional === true) return void 0;
|
|
7418
|
+
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
7419
|
+
}
|
|
7420
|
+
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
7421
|
+
try {
|
|
7422
|
+
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
7423
|
+
} catch (cause) {
|
|
7424
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7425
|
+
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
7426
|
+
}
|
|
7427
|
+
}
|
|
7428
|
+
/**
|
|
7429
|
+
* Boot resolution for an env-sourced param: double-lookup (pointer → platform
|
|
7430
|
+
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
7431
|
+
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
7432
|
+
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
7433
|
+
* not special-cased here — it reaches the schema like any other value, so it
|
|
7434
|
+
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
7435
|
+
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
7436
|
+
*/
|
|
7437
|
+
function coerceEnvSourcedParam(raw, d, key) {
|
|
7438
|
+
const platformVar = decodeParamPointer(raw);
|
|
7439
|
+
const value = process.env[platformVar];
|
|
7440
|
+
if (value === void 0) throw new Error(`env-sourced config param "${d.name}" (env ${key} → ${platformVar}) is unset: the platform variable "${platformVar}" was not injected — the deploy did not provision it.`);
|
|
7441
|
+
try {
|
|
7442
|
+
return standardValidateSync(d.param.schema, value);
|
|
7443
|
+
} catch (cause) {
|
|
7444
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
7445
|
+
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
7446
|
+
}
|
|
7447
|
+
}
|
|
7448
|
+
/**
|
|
7449
|
+
* Boot: read each declared param from env by its key, reverse the param's own
|
|
7450
|
+
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
7451
|
+
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
7452
|
+
*/
|
|
7453
|
+
const deserialize = (node, address) => {
|
|
7454
|
+
const service = {};
|
|
7455
|
+
const inputs = {};
|
|
7456
|
+
for (const d of paramEntries(node)) {
|
|
7457
|
+
const key = configKey(address, d);
|
|
7458
|
+
const value = coerce(process.env[key], d, key);
|
|
7459
|
+
if (d.owner === "service") service[d.name] = value;
|
|
7460
|
+
else {
|
|
7461
|
+
let bucket = inputs[d.owner.input];
|
|
7462
|
+
if (bucket === void 0) {
|
|
7463
|
+
bucket = {};
|
|
7464
|
+
inputs[d.owner.input] = bucket;
|
|
7465
|
+
}
|
|
7466
|
+
bucket[d.name] = value;
|
|
7467
|
+
}
|
|
7468
|
+
}
|
|
7469
|
+
return {
|
|
7470
|
+
service,
|
|
7471
|
+
inputs
|
|
7472
|
+
};
|
|
7473
|
+
};
|
|
7474
|
+
/**
|
|
7475
|
+
* run()'s setup step: write the resolved config to the environment under
|
|
7476
|
+
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
7477
|
+
* reads back with no address. Uses env, not a module variable, because a
|
|
7478
|
+
* framework may fork worker processes that inherit env but not memory.
|
|
7479
|
+
* Writes only these keys; nothing else is touched.
|
|
7480
|
+
*/
|
|
7481
|
+
const stash = (node, config) => {
|
|
7482
|
+
for (const d of paramEntries(node)) {
|
|
7483
|
+
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
7484
|
+
if (value === void 0) continue;
|
|
7485
|
+
process.env[configKey("", d)] = encode(d.owner, value);
|
|
7486
|
+
}
|
|
7487
|
+
};
|
|
7488
|
+
/** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
|
|
7489
|
+
const secretKey = (address, slot) => configKey(address, {
|
|
7490
|
+
owner: "service",
|
|
7491
|
+
name: slot
|
|
7492
|
+
});
|
|
7493
|
+
/**
|
|
7494
|
+
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
7495
|
+
* pointer key (the platform NAME), then read that platform var. A missing
|
|
7496
|
+
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
7497
|
+
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
7498
|
+
*/
|
|
7499
|
+
const deserializeSecrets = (node, address) => {
|
|
7500
|
+
const values = {};
|
|
7501
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
7502
|
+
const key = secretKey(address, slot);
|
|
7503
|
+
const name = process.env[key];
|
|
7504
|
+
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
7505
|
+
const value = process.env[name];
|
|
7506
|
+
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
7507
|
+
values[slot] = value;
|
|
7508
|
+
}
|
|
7509
|
+
return values;
|
|
7601
7510
|
};
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7511
|
+
/**
|
|
7512
|
+
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
7513
|
+
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
7514
|
+
* identically. Never the value — the value stays only in the platform var.
|
|
7515
|
+
*/
|
|
7516
|
+
const stashSecrets = (node, address) => {
|
|
7517
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
7518
|
+
const name = process.env[secretKey(address, slot)];
|
|
7519
|
+
if (name === void 0) continue;
|
|
7520
|
+
process.env[secretKey("", slot)] = name;
|
|
7521
|
+
}
|
|
7605
7522
|
};
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7523
|
+
/**
|
|
7524
|
+
* Boot: for each reserved provider param, read its address-scoped row through
|
|
7525
|
+
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
7526
|
+
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
7527
|
+
* declaration space. A param is declared optional here unconditionally: an
|
|
7528
|
+
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
7529
|
+
* registered value for this deploy), never a boot failure, so nothing is
|
|
7530
|
+
* stashed and the runtime reader that owns this slot falls back to its own
|
|
7531
|
+
* pass-through behavior.
|
|
7532
|
+
*/
|
|
7533
|
+
function stashProviderParams(entries, address) {
|
|
7534
|
+
for (const entry of entries) {
|
|
7535
|
+
const d = {
|
|
7536
|
+
owner: "service",
|
|
7537
|
+
name: entry.name,
|
|
7538
|
+
param: {
|
|
7539
|
+
schema: entry.schema,
|
|
7540
|
+
optional: true
|
|
7541
|
+
}
|
|
7542
|
+
};
|
|
7543
|
+
const key = configKey(address, d);
|
|
7544
|
+
const value = coerce(process.env[key], d, key);
|
|
7545
|
+
if (value === void 0) continue;
|
|
7546
|
+
process.env[configKey("", d)] = encode("service", value);
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7549
|
+
/** The framework-resolved origin row: COMPOSER_<addr>_ORIGIN. Written per
|
|
7550
|
+
* compute service at serialize — the service's own provisioned endpoint URL,
|
|
7551
|
+
* riding the reserved-provider-param machinery (`origin-key.ts`'s
|
|
7552
|
+
* `ORIGIN_PARAM`); never a declared param, never in config(). A harness with
|
|
7553
|
+
* no deploy behind it supplies it by setting `COMPOSER_ORIGIN` to the
|
|
7554
|
+
* JSON-encoded origin URL — exactly how the existing entrypoint tests supply
|
|
7555
|
+
* their other `COMPOSER_*` rows. */
|
|
7556
|
+
const ORIGIN_KEY_NAME = "ORIGIN";
|
|
7557
|
+
/**
|
|
7558
|
+
* Reads this service's origin back out of the address-free stash
|
|
7559
|
+
* `stashProviderParams` wrote for the ORIGIN entry. `COMPOSER_ORIGIN` unset is
|
|
7560
|
+
* a loud failure — a deployed environment always writes it, so an unset row
|
|
7561
|
+
* means either a local harness that hasn't supplied it or a boot() called
|
|
7562
|
+
* before run().
|
|
7563
|
+
*/
|
|
7564
|
+
function readOrigin() {
|
|
7565
|
+
const d = {
|
|
7566
|
+
owner: "service",
|
|
7567
|
+
name: ORIGIN_KEY_NAME,
|
|
7568
|
+
param: {
|
|
7569
|
+
schema: type("string"),
|
|
7570
|
+
optional: true
|
|
7571
|
+
}
|
|
7572
|
+
};
|
|
7573
|
+
const key = configKey("", d);
|
|
7574
|
+
const value = coerce(process.env[key], d, key);
|
|
7575
|
+
if (value === void 0) throw new Error("this service's origin is not available (env COMPOSER_ORIGIN is unset) — a deployed environment writes it automatically; a local harness must supply it like any other config value (set COMPOSER_ORIGIN to the JSON-encoded origin URL).");
|
|
7576
|
+
return blindCast(value);
|
|
7577
|
+
}
|
|
7578
|
+
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
7579
|
+
function standardValidateSync(schema, value) {
|
|
7580
|
+
const result = schema["~standard"].validate(value);
|
|
7581
|
+
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
7582
|
+
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
7583
|
+
return result.value;
|
|
7584
|
+
}
|
|
7585
|
+
/** Bounded jittered backoff for retrying a dropped call. `maxRetries` is retries after the first attempt. */
|
|
7586
|
+
const RETRY = {
|
|
7587
|
+
initialDelayMs: 250,
|
|
7588
|
+
multiplier: 2,
|
|
7589
|
+
maxDelayMs: 5e3,
|
|
7590
|
+
maxRetries: 5
|
|
7609
7591
|
};
|
|
7610
|
-
const
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7592
|
+
const IDEMPOTENCY_KEY_HEADER$1 = "Idempotency-Key";
|
|
7593
|
+
function sleep(ms) {
|
|
7594
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7595
|
+
}
|
|
7596
|
+
/** Whether a non-OK response is safe to retry: 429 or any 5xx, never another 4xx. */
|
|
7597
|
+
function isRetryableStatus(status) {
|
|
7598
|
+
return status === 429 || status >= 500;
|
|
7599
|
+
}
|
|
7600
|
+
/** The server's `{ error }` body, if the response has one — undefined otherwise. */
|
|
7601
|
+
async function errorDetail(res) {
|
|
7602
|
+
try {
|
|
7603
|
+
const body = await res.json();
|
|
7604
|
+
return typeof body === "object" && body !== null && "error" in body ? String(body.error) : void 0;
|
|
7605
|
+
} catch {
|
|
7606
|
+
return;
|
|
7607
|
+
}
|
|
7608
|
+
}
|
|
7609
|
+
/** `<base>/rpc/<method>`, preserving a base URL's own path (e.g. a mount point). */
|
|
7610
|
+
function methodUrl(base, method) {
|
|
7611
|
+
const normalizedBase = base.endsWith("/") ? base : `${base}/`;
|
|
7612
|
+
return new URL(`rpc/${method}`, normalizedBase).toString();
|
|
7613
|
+
}
|
|
7614
|
+
/**
|
|
7615
|
+
* Sends one call over `send`, retrying a thrown error, 429, or 5xx with
|
|
7616
|
+
* full-jitter backoff. `buildRequest` runs per attempt but carries the same
|
|
7617
|
+
* idempotency key each time — only the transport call repeats, not the key.
|
|
7618
|
+
*/
|
|
7619
|
+
async function callWithRetry(send, buildRequest, method) {
|
|
7620
|
+
let delay = RETRY.initialDelayMs;
|
|
7621
|
+
let retries = 0;
|
|
7622
|
+
for (;;) {
|
|
7623
|
+
let res;
|
|
7624
|
+
try {
|
|
7625
|
+
res = await send(buildRequest());
|
|
7626
|
+
} catch (err) {
|
|
7627
|
+
if (retries >= RETRY.maxRetries) throw err;
|
|
7628
|
+
retries += 1;
|
|
7629
|
+
await sleep(Math.random() * delay);
|
|
7630
|
+
delay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);
|
|
7631
|
+
continue;
|
|
7632
|
+
}
|
|
7633
|
+
if (res.ok) return res.json();
|
|
7634
|
+
if (!isRetryableStatus(res.status) || retries >= RETRY.maxRetries) {
|
|
7635
|
+
const detail = await errorDetail(res);
|
|
7636
|
+
throw new Error(`RPC call "${method}" failed: ${res.status} ${res.statusText}` + (detail !== void 0 ? ` — ${detail}` : ""));
|
|
7637
|
+
}
|
|
7638
|
+
retries += 1;
|
|
7639
|
+
await sleep(Math.random() * delay);
|
|
7640
|
+
delay = Math.min(delay * RETRY.multiplier, RETRY.maxDelayMs);
|
|
7641
|
+
}
|
|
7642
|
+
}
|
|
7643
|
+
function makeClient(contract, url, opts) {
|
|
7644
|
+
const send = opts?.fetch ?? fetch;
|
|
7645
|
+
const baseHeaders = { "content-type": "application/json" };
|
|
7646
|
+
if (opts?.serviceKey !== void 0) baseHeaders["Authorization"] = `Bearer ${opts.serviceKey}`;
|
|
7647
|
+
const client = {};
|
|
7648
|
+
for (const method of Object.keys(contract.__cmp)) client[method] = async (input) => {
|
|
7649
|
+
const idempotencyKey = crypto.randomUUID();
|
|
7650
|
+
const body = JSON.stringify(input);
|
|
7651
|
+
return callWithRetry(send, () => new Request(methodUrl(url, method), {
|
|
7652
|
+
method: "POST",
|
|
7653
|
+
headers: {
|
|
7654
|
+
...baseHeaders,
|
|
7655
|
+
[IDEMPOTENCY_KEY_HEADER$1]: idempotencyKey
|
|
7656
|
+
},
|
|
7657
|
+
body
|
|
7658
|
+
}), method);
|
|
7659
|
+
};
|
|
7660
|
+
return blindCast(client);
|
|
7661
|
+
}
|
|
7662
|
+
function contract(fns) {
|
|
7663
|
+
const value = {
|
|
7664
|
+
kind: "rpc",
|
|
7665
|
+
__cmp: fns,
|
|
7666
|
+
satisfies: (required) => value === required
|
|
7667
|
+
};
|
|
7668
|
+
return Object.freeze(value);
|
|
7669
|
+
}
|
|
7670
|
+
/** ADR-0031's need brand for RPC's per-binding service key — the target registers a provisioner under this. */
|
|
7671
|
+
const RPC_PEER_KEY = Symbol.for("prisma:rpc/per-binding-key");
|
|
7672
|
+
/** The provisioning need `rpc()`'s `serviceKey` param declares (ADR-0030): a shared, unguessable value the target mints per consumer edge. */
|
|
7673
|
+
const perBindingToken = () => provisionNeed(RPC_PEER_KEY);
|
|
7674
|
+
function rpc(arg) {
|
|
7675
|
+
if (!isRpcContract(arg)) return arg;
|
|
7676
|
+
return dependency({
|
|
7677
|
+
type: "rpc",
|
|
7678
|
+
connection: {
|
|
7679
|
+
params: {
|
|
7680
|
+
url: string$1(),
|
|
7681
|
+
serviceKey: string$1({
|
|
7682
|
+
optional: true,
|
|
7683
|
+
provision: perBindingToken()
|
|
7684
|
+
})
|
|
7685
|
+
},
|
|
7686
|
+
hydrate: ({ url, serviceKey }) => makeClient(arg, url, { serviceKey })
|
|
7687
|
+
},
|
|
7688
|
+
required: arg
|
|
7689
|
+
});
|
|
7690
|
+
}
|
|
7691
|
+
function isRpcContract(value) {
|
|
7692
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "rpc" && "__cmp" in value && "satisfies" in value;
|
|
7693
|
+
}
|
|
7694
|
+
/**
|
|
7695
|
+
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
7696
|
+
* brand and the ONE entry — shared by control.ts (which registers the
|
|
7697
|
+
* deploy-side value function that resolves the provisioned service's
|
|
7698
|
+
* `endpointDomain` — see its `selfOriginValue`) and compute.ts (which
|
|
7699
|
+
* validates and stashes the row at boot through the generic
|
|
7700
|
+
* `stashProviderParams` loop), so writer and reader cannot drift.
|
|
7701
|
+
*
|
|
7702
|
+
* Unlike the key-minting brands (`service-keys.ts`, `streams-keys.ts`) this
|
|
7703
|
+
* brand has no provisioner and no consumer edges: the value derives from the
|
|
7704
|
+
* service's OWN provisioned attributes, so control.ts registers it as a
|
|
7705
|
+
* service-derived provider param (`descriptors/shared.ts`'s
|
|
7706
|
+
* `ServiceProviderParam`) and the descriptor writes it for EVERY compute
|
|
7707
|
+
* service, exposing or not.
|
|
7708
|
+
*
|
|
7709
|
+
* This module is reachable from the RUNTIME/authoring side — it must never
|
|
7710
|
+
* import `@internal/lowering` or `effect`, or those tokens leak into a user
|
|
7711
|
+
* service's bundle (the deploy-side value function lives in control.ts, the
|
|
7712
|
+
* control-plane-only entry).
|
|
7713
|
+
*/
|
|
7714
|
+
/** ADR-0031's brand for the service's own origin — control.ts registers the deploy-side value function under this. */
|
|
7715
|
+
const SELF_ORIGIN = Symbol.for("prisma:self-origin");
|
|
7716
|
+
/**
|
|
7717
|
+
* The reserved provider param for the origin row: the var name is `ORIGIN`,
|
|
7718
|
+
* derived through `configKey` at both ends (`configKey(address, …)` at
|
|
7719
|
+
* deploy, `configKey('', …)` — `COMPOSER_ORIGIN` — at boot, where
|
|
7720
|
+
* `readOrigin` reads it back). `brand` is `SELF_ORIGIN` — control.ts looks
|
|
7721
|
+
* its deploy-side value function up by this field.
|
|
7722
|
+
*/
|
|
7723
|
+
const ORIGIN_PARAM = {
|
|
7724
|
+
name: ORIGIN_KEY_NAME,
|
|
7725
|
+
schema: type("string"),
|
|
7726
|
+
brand: SELF_ORIGIN
|
|
7653
7727
|
};
|
|
7654
|
-
const type = Object.assign(ark.type, $arkTypeRegistry.typeAttachments);
|
|
7655
|
-
ark.match;
|
|
7656
|
-
ark.fn;
|
|
7657
|
-
ark.generic;
|
|
7658
|
-
ark.schema;
|
|
7659
|
-
ark.define;
|
|
7660
|
-
ark.declare;
|
|
7661
7728
|
/**
|
|
7662
7729
|
* RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —
|
|
7663
7730
|
* name + schema + brand — for the accepted-keys set a provider stores, shared
|
|
@@ -7702,7 +7769,33 @@ configKey("", {
|
|
|
7702
7769
|
owner: "service",
|
|
7703
7770
|
name: STREAMS_API_KEY_PARAM.name
|
|
7704
7771
|
});
|
|
7705
|
-
|
|
7772
|
+
/**
|
|
7773
|
+
* The list of provider-side reserved params the boot path validates and
|
|
7774
|
+
* stashes (ADR-0031): every brand's `{name, schema, brand}` declaration,
|
|
7775
|
+
* collected from that brand's own module (`service-keys.ts`,
|
|
7776
|
+
* `streams-keys.ts`, `origin-key.ts`) so `compute.ts` names no brand itself.
|
|
7777
|
+
*
|
|
7778
|
+
* This list exists separately from `control.ts`'s deploy-side registry
|
|
7779
|
+
* (`PROVIDER_PARAMS`) because `control.ts` is deploy-only code — it imports
|
|
7780
|
+
* `@internal/lowering` and `effect` to mint values — and a booted service
|
|
7781
|
+
* must never import it. This module is reachable from a user service's
|
|
7782
|
+
* bundle through `compute.ts`, so it must never import `@internal/lowering`,
|
|
7783
|
+
* `effect`, `alchemy`, or `control.ts`.
|
|
7784
|
+
*
|
|
7785
|
+
* This is the single source of which reserved provider params exist:
|
|
7786
|
+
* control.ts builds `PROVIDER_PARAMS` by mapping over this list and looking
|
|
7787
|
+
* up each entry's deploy-side value function (edge-derived `value(refs)` or
|
|
7788
|
+
* service-derived `valueForService(provisioned, address)`) by its `brand`,
|
|
7789
|
+
* throwing at module load if one is missing. Adding a brand means adding its
|
|
7790
|
+
* entry here, plus its deploy-side value function in control.ts — a brand
|
|
7791
|
+
* registered for deploy but absent here is no longer expressible, because
|
|
7792
|
+
* deploy no longer names its own param set independently.
|
|
7793
|
+
*/
|
|
7794
|
+
const RESERVED_PROVIDER_PARAMS = [
|
|
7795
|
+
RPC_ACCEPTED_KEYS_PARAM,
|
|
7796
|
+
STREAMS_API_KEY_PARAM,
|
|
7797
|
+
ORIGIN_PARAM
|
|
7798
|
+
];
|
|
7706
7799
|
Object.freeze({
|
|
7707
7800
|
kind: "s3",
|
|
7708
7801
|
__cmp: {
|
|
@@ -7719,7 +7812,7 @@ const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
|
7719
7812
|
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
7720
7813
|
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
7721
7814
|
* one fails at authoring, the same way a colliding dependency name does.
|
|
7722
|
-
*
|
|
7815
|
+
*
|
|
7723
7816
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
7724
7817
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
7725
7818
|
* typed Config, re-emit it under address-free process-local stash keys,
|
|
@@ -7727,23 +7820,69 @@ const reservedParams = { port: number$1({ default: 3e3 }) };
|
|
|
7727
7820
|
* · load() / config() — called from inside the app's entry: read the stash;
|
|
7728
7821
|
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
7729
7822
|
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
7823
|
+
* · origin() — this service's platform-assigned public origin, read from the
|
|
7824
|
+
* stash `run()` populates; memoized per process.
|
|
7730
7825
|
*
|
|
7731
|
-
*
|
|
7826
|
+
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
7732
7827
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
7733
7828
|
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
7734
|
-
* deploy time; nodes are pure data.
|
|
7829
|
+
* deploy time; nodes are pure data until run() or load() is called.
|
|
7735
7830
|
*/
|
|
7831
|
+
var ComputeService = class {
|
|
7832
|
+
#resolved;
|
|
7833
|
+
#loadedDeps;
|
|
7834
|
+
#loadedParams;
|
|
7835
|
+
#loadedSecrets;
|
|
7836
|
+
#origin;
|
|
7837
|
+
constructor(node) {
|
|
7838
|
+
Object.assign(this, node);
|
|
7839
|
+
}
|
|
7840
|
+
#processConfig() {
|
|
7841
|
+
if (this.#resolved === void 0) this.#resolved = deserialize(this, "");
|
|
7842
|
+
return this.#resolved;
|
|
7843
|
+
}
|
|
7844
|
+
async run(address, boot) {
|
|
7845
|
+
const config = deserialize(this, address);
|
|
7846
|
+
stash(this, config);
|
|
7847
|
+
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
7848
|
+
stashSecrets(this, address);
|
|
7849
|
+
const port = config.service["port"];
|
|
7850
|
+
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
7851
|
+
return boot();
|
|
7852
|
+
}
|
|
7853
|
+
load() {
|
|
7854
|
+
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
7855
|
+
return this.#loadedDeps;
|
|
7856
|
+
}
|
|
7857
|
+
config() {
|
|
7858
|
+
if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
|
|
7859
|
+
return this.#loadedParams;
|
|
7860
|
+
}
|
|
7861
|
+
secrets() {
|
|
7862
|
+
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
7863
|
+
return this.#loadedSecrets;
|
|
7864
|
+
}
|
|
7865
|
+
/** This service's platform-assigned public origin — read from the stash
|
|
7866
|
+
* run() populates and memoized per process. Throws if called before run()
|
|
7867
|
+
* has stashed it (readOrigin's pinned message). */
|
|
7868
|
+
origin() {
|
|
7869
|
+
this.#origin ??= readOrigin();
|
|
7870
|
+
return this.#origin;
|
|
7871
|
+
}
|
|
7872
|
+
};
|
|
7736
7873
|
const compute = (def) => {
|
|
7737
7874
|
const userParams = def.params ?? blindCast({});
|
|
7738
7875
|
for (const reserved of Object.keys(reservedParams)) {
|
|
7739
7876
|
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
7740
7877
|
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
7741
7878
|
}
|
|
7879
|
+
for (const name of Object.keys(userParams)) if (name.toUpperCase() === "ORIGIN") throw new Error(`compute(): param "${name}" collides with the framework-written origin row — rename the param.`);
|
|
7880
|
+
for (const name of Object.keys(def.secrets ?? {})) if (name.toUpperCase() === "ORIGIN") throw new Error(`compute(): secret "${name}" collides with the framework-written origin row — rename the secret.`);
|
|
7742
7881
|
const params = blindCast({
|
|
7743
7882
|
...userParams,
|
|
7744
7883
|
...reservedParams
|
|
7745
7884
|
});
|
|
7746
|
-
const
|
|
7885
|
+
const instance = new ComputeService(service$1({
|
|
7747
7886
|
name: def.name,
|
|
7748
7887
|
extension: "@prisma/composer-prisma-cloud",
|
|
7749
7888
|
type: "compute",
|
|
@@ -7752,40 +7891,9 @@ const compute = (def) => {
|
|
|
7752
7891
|
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
7753
7892
|
build: def.build,
|
|
7754
7893
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
7755
|
-
});
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
let loadedParams;
|
|
7759
|
-
let loadedSecrets;
|
|
7760
|
-
function processConfig() {
|
|
7761
|
-
if (resolved === void 0) resolved = deserialize(node, "");
|
|
7762
|
-
return resolved;
|
|
7763
|
-
}
|
|
7764
|
-
const runnable = {
|
|
7765
|
-
...node,
|
|
7766
|
-
async run(address, boot) {
|
|
7767
|
-
const config = deserialize(node, address);
|
|
7768
|
-
stash(node, config);
|
|
7769
|
-
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
7770
|
-
stashSecrets(node, address);
|
|
7771
|
-
const port = config.service["port"];
|
|
7772
|
-
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
7773
|
-
return boot();
|
|
7774
|
-
},
|
|
7775
|
-
load() {
|
|
7776
|
-
if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
|
|
7777
|
-
return loadedDeps;
|
|
7778
|
-
},
|
|
7779
|
-
config() {
|
|
7780
|
-
if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
|
|
7781
|
-
return loadedParams;
|
|
7782
|
-
},
|
|
7783
|
-
secrets() {
|
|
7784
|
-
if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
|
|
7785
|
-
return loadedSecrets;
|
|
7786
|
-
}
|
|
7787
|
-
};
|
|
7788
|
-
return Object.freeze(blindCast(runnable));
|
|
7894
|
+
}));
|
|
7895
|
+
Object.freeze(instance);
|
|
7896
|
+
return instance;
|
|
7789
7897
|
};
|
|
7790
7898
|
Object.freeze({
|
|
7791
7899
|
kind: "postgres",
|