@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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { dependency, hydrateSecrets, hydrateSync, number, provisionNeed, resource, service, string } from "@prisma/composer";
|
|
2
2
|
import { blindCast } from "@prisma/composer/casts";
|
|
3
|
-
import { RPC_PEER_KEY } from "@prisma/composer/service-rpc";
|
|
4
3
|
import { type } from "arktype";
|
|
4
|
+
import { RPC_PEER_KEY } from "@prisma/composer/service-rpc";
|
|
5
5
|
import node from "@prisma/composer/node";
|
|
6
|
-
|
|
6
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-CJiOhF2d.mjs
|
|
7
7
|
/**
|
|
8
8
|
* Walks a node's own params, then each dependency input's connection params —
|
|
9
9
|
* the same enumeration order `configOf` uses, but carrying the raw
|
|
@@ -191,6 +191,35 @@ function stashProviderParams(entries, address) {
|
|
|
191
191
|
process.env[configKey("", d)] = encode("service", value);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
+
/** The framework-resolved origin row: COMPOSER_<addr>_ORIGIN. Written per
|
|
195
|
+
* compute service at serialize — the service's own provisioned endpoint URL,
|
|
196
|
+
* riding the reserved-provider-param machinery (`origin-key.ts`'s
|
|
197
|
+
* `ORIGIN_PARAM`); never a declared param, never in config(). A harness with
|
|
198
|
+
* no deploy behind it supplies it by setting `COMPOSER_ORIGIN` to the
|
|
199
|
+
* JSON-encoded origin URL — exactly how the existing entrypoint tests supply
|
|
200
|
+
* their other `COMPOSER_*` rows. */
|
|
201
|
+
const ORIGIN_KEY_NAME = "ORIGIN";
|
|
202
|
+
/**
|
|
203
|
+
* Reads this service's origin back out of the address-free stash
|
|
204
|
+
* `stashProviderParams` wrote for the ORIGIN entry. `COMPOSER_ORIGIN` unset is
|
|
205
|
+
* a loud failure — a deployed environment always writes it, so an unset row
|
|
206
|
+
* means either a local harness that hasn't supplied it or a boot() called
|
|
207
|
+
* before run().
|
|
208
|
+
*/
|
|
209
|
+
function readOrigin() {
|
|
210
|
+
const d = {
|
|
211
|
+
owner: "service",
|
|
212
|
+
name: ORIGIN_KEY_NAME,
|
|
213
|
+
param: {
|
|
214
|
+
schema: type("string"),
|
|
215
|
+
optional: true
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const key = configKey("", d);
|
|
219
|
+
const value = coerce(process.env[key], d, key);
|
|
220
|
+
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).");
|
|
221
|
+
return blindCast(value);
|
|
222
|
+
}
|
|
194
223
|
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
195
224
|
function standardValidateSync(schema, value) {
|
|
196
225
|
const result = schema["~standard"].validate(value);
|
|
@@ -199,7 +228,41 @@ function standardValidateSync(schema, value) {
|
|
|
199
228
|
return result.value;
|
|
200
229
|
}
|
|
201
230
|
//#endregion
|
|
202
|
-
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-
|
|
231
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-C1wSO3cx.mjs
|
|
232
|
+
/**
|
|
233
|
+
* The service's own origin as a reserved provider param (ADR-0031): the ONE
|
|
234
|
+
* brand and the ONE entry — shared by control.ts (which registers the
|
|
235
|
+
* deploy-side value function that resolves the provisioned service's
|
|
236
|
+
* `endpointDomain` — see its `selfOriginValue`) and compute.ts (which
|
|
237
|
+
* validates and stashes the row at boot through the generic
|
|
238
|
+
* `stashProviderParams` loop), so writer and reader cannot drift.
|
|
239
|
+
*
|
|
240
|
+
* Unlike the key-minting brands (`service-keys.ts`, `streams-keys.ts`) this
|
|
241
|
+
* brand has no provisioner and no consumer edges: the value derives from the
|
|
242
|
+
* service's OWN provisioned attributes, so control.ts registers it as a
|
|
243
|
+
* service-derived provider param (`descriptors/shared.ts`'s
|
|
244
|
+
* `ServiceProviderParam`) and the descriptor writes it for EVERY compute
|
|
245
|
+
* service, exposing or not.
|
|
246
|
+
*
|
|
247
|
+
* This module is reachable from the RUNTIME/authoring side — it must never
|
|
248
|
+
* import `@internal/lowering` or `effect`, or those tokens leak into a user
|
|
249
|
+
* service's bundle (the deploy-side value function lives in control.ts, the
|
|
250
|
+
* control-plane-only entry).
|
|
251
|
+
*/
|
|
252
|
+
/** ADR-0031's brand for the service's own origin — control.ts registers the deploy-side value function under this. */
|
|
253
|
+
const SELF_ORIGIN = Symbol.for("prisma:self-origin");
|
|
254
|
+
/**
|
|
255
|
+
* The reserved provider param for the origin row: the var name is `ORIGIN`,
|
|
256
|
+
* derived through `configKey` at both ends (`configKey(address, …)` at
|
|
257
|
+
* deploy, `configKey('', …)` — `COMPOSER_ORIGIN` — at boot, where
|
|
258
|
+
* `readOrigin` reads it back). `brand` is `SELF_ORIGIN` — control.ts looks
|
|
259
|
+
* its deploy-side value function up by this field.
|
|
260
|
+
*/
|
|
261
|
+
const ORIGIN_PARAM = {
|
|
262
|
+
name: ORIGIN_KEY_NAME,
|
|
263
|
+
schema: type("string"),
|
|
264
|
+
brand: SELF_ORIGIN
|
|
265
|
+
};
|
|
203
266
|
/**
|
|
204
267
|
* RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —
|
|
205
268
|
* name + schema + brand — for the accepted-keys set a provider stores, shared
|
|
@@ -252,8 +315,33 @@ configKey("", {
|
|
|
252
315
|
owner: "service",
|
|
253
316
|
name: STREAMS_API_KEY_PARAM.name
|
|
254
317
|
});
|
|
255
|
-
|
|
256
|
-
|
|
318
|
+
/**
|
|
319
|
+
* The list of provider-side reserved params the boot path validates and
|
|
320
|
+
* stashes (ADR-0031): every brand's `{name, schema, brand}` declaration,
|
|
321
|
+
* collected from that brand's own module (`service-keys.ts`,
|
|
322
|
+
* `streams-keys.ts`, `origin-key.ts`) so `compute.ts` names no brand itself.
|
|
323
|
+
*
|
|
324
|
+
* This list exists separately from `control.ts`'s deploy-side registry
|
|
325
|
+
* (`PROVIDER_PARAMS`) because `control.ts` is deploy-only code — it imports
|
|
326
|
+
* `@internal/lowering` and `effect` to mint values — and a booted service
|
|
327
|
+
* must never import it. This module is reachable from a user service's
|
|
328
|
+
* bundle through `compute.ts`, so it must never import `@internal/lowering`,
|
|
329
|
+
* `effect`, `alchemy`, or `control.ts`.
|
|
330
|
+
*
|
|
331
|
+
* This is the single source of which reserved provider params exist:
|
|
332
|
+
* control.ts builds `PROVIDER_PARAMS` by mapping over this list and looking
|
|
333
|
+
* up each entry's deploy-side value function (edge-derived `value(refs)` or
|
|
334
|
+
* service-derived `valueForService(provisioned, address)`) by its `brand`,
|
|
335
|
+
* throwing at module load if one is missing. Adding a brand means adding its
|
|
336
|
+
* entry here, plus its deploy-side value function in control.ts — a brand
|
|
337
|
+
* registered for deploy but absent here is no longer expressible, because
|
|
338
|
+
* deploy no longer names its own param set independently.
|
|
339
|
+
*/
|
|
340
|
+
const RESERVED_PROVIDER_PARAMS = [
|
|
341
|
+
RPC_ACCEPTED_KEYS_PARAM,
|
|
342
|
+
STREAMS_API_KEY_PARAM,
|
|
343
|
+
ORIGIN_PARAM
|
|
344
|
+
];
|
|
257
345
|
Object.freeze({
|
|
258
346
|
kind: "s3",
|
|
259
347
|
__cmp: {
|
|
@@ -270,7 +358,7 @@ const reservedParams = { port: number({ default: 3e3 }) };
|
|
|
270
358
|
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
271
359
|
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
272
360
|
* one fails at authoring, the same way a colliding dependency name does.
|
|
273
|
-
*
|
|
361
|
+
*
|
|
274
362
|
* · run(address, boot) — the process controller: deserialize the platform
|
|
275
363
|
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
276
364
|
* typed Config, re-emit it under address-free process-local stash keys,
|
|
@@ -278,23 +366,69 @@ const reservedParams = { port: number({ default: 3e3 }) };
|
|
|
278
366
|
* · load() / config() — called from inside the app's entry: read the stash;
|
|
279
367
|
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
280
368
|
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
369
|
+
* · origin() — this service's platform-assigned public origin, read from the
|
|
370
|
+
* stash `run()` populates; memoized per process.
|
|
281
371
|
*
|
|
282
|
-
*
|
|
372
|
+
* The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
283
373
|
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
284
374
|
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
285
|
-
* deploy time; nodes are pure data.
|
|
375
|
+
* deploy time; nodes are pure data until run() or load() is called.
|
|
286
376
|
*/
|
|
377
|
+
var ComputeService = class {
|
|
378
|
+
#resolved;
|
|
379
|
+
#loadedDeps;
|
|
380
|
+
#loadedParams;
|
|
381
|
+
#loadedSecrets;
|
|
382
|
+
#origin;
|
|
383
|
+
constructor(node) {
|
|
384
|
+
Object.assign(this, node);
|
|
385
|
+
}
|
|
386
|
+
#processConfig() {
|
|
387
|
+
if (this.#resolved === void 0) this.#resolved = deserialize(this, "");
|
|
388
|
+
return this.#resolved;
|
|
389
|
+
}
|
|
390
|
+
async run(address, boot) {
|
|
391
|
+
const config = deserialize(this, address);
|
|
392
|
+
stash(this, config);
|
|
393
|
+
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
394
|
+
stashSecrets(this, address);
|
|
395
|
+
const port = config.service["port"];
|
|
396
|
+
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
397
|
+
return boot();
|
|
398
|
+
}
|
|
399
|
+
load() {
|
|
400
|
+
if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
|
|
401
|
+
return this.#loadedDeps;
|
|
402
|
+
}
|
|
403
|
+
config() {
|
|
404
|
+
if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
|
|
405
|
+
return this.#loadedParams;
|
|
406
|
+
}
|
|
407
|
+
secrets() {
|
|
408
|
+
if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
|
|
409
|
+
return this.#loadedSecrets;
|
|
410
|
+
}
|
|
411
|
+
/** This service's platform-assigned public origin — read from the stash
|
|
412
|
+
* run() populates and memoized per process. Throws if called before run()
|
|
413
|
+
* has stashed it (readOrigin's pinned message). */
|
|
414
|
+
origin() {
|
|
415
|
+
this.#origin ??= readOrigin();
|
|
416
|
+
return this.#origin;
|
|
417
|
+
}
|
|
418
|
+
};
|
|
287
419
|
const compute = (def) => {
|
|
288
420
|
const userParams = def.params ?? blindCast({});
|
|
289
421
|
for (const reserved of Object.keys(reservedParams)) {
|
|
290
422
|
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
291
423
|
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
292
424
|
}
|
|
425
|
+
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.`);
|
|
426
|
+
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.`);
|
|
293
427
|
const params = blindCast({
|
|
294
428
|
...userParams,
|
|
295
429
|
...reservedParams
|
|
296
430
|
});
|
|
297
|
-
const
|
|
431
|
+
const instance = new ComputeService(service({
|
|
298
432
|
name: def.name,
|
|
299
433
|
extension: "@prisma/composer-prisma-cloud",
|
|
300
434
|
type: "compute",
|
|
@@ -303,40 +437,9 @@ const compute = (def) => {
|
|
|
303
437
|
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
304
438
|
build: def.build,
|
|
305
439
|
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
let loadedParams;
|
|
310
|
-
let loadedSecrets;
|
|
311
|
-
function processConfig() {
|
|
312
|
-
if (resolved === void 0) resolved = deserialize(node, "");
|
|
313
|
-
return resolved;
|
|
314
|
-
}
|
|
315
|
-
const runnable = {
|
|
316
|
-
...node,
|
|
317
|
-
async run(address, boot) {
|
|
318
|
-
const config = deserialize(node, address);
|
|
319
|
-
stash(node, config);
|
|
320
|
-
stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
|
|
321
|
-
stashSecrets(node, address);
|
|
322
|
-
const port = config.service["port"];
|
|
323
|
-
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
324
|
-
return boot();
|
|
325
|
-
},
|
|
326
|
-
load() {
|
|
327
|
-
if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
|
|
328
|
-
return loadedDeps;
|
|
329
|
-
},
|
|
330
|
-
config() {
|
|
331
|
-
if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
|
|
332
|
-
return loadedParams;
|
|
333
|
-
},
|
|
334
|
-
secrets() {
|
|
335
|
-
if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
|
|
336
|
-
return loadedSecrets;
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
return Object.freeze(blindCast(runnable));
|
|
440
|
+
}));
|
|
441
|
+
Object.freeze(instance);
|
|
442
|
+
return instance;
|
|
340
443
|
};
|
|
341
444
|
/**
|
|
342
445
|
* The contract a Postgres provides — and the contract its consumers require.
|
|
@@ -407,13 +510,21 @@ function s3Credentials(opts) {
|
|
|
407
510
|
* return type is compute's exactly (including the reserved `port` param). The
|
|
408
511
|
* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
|
|
409
512
|
* param, and `expose: { store: s3Contract }`.
|
|
513
|
+
*
|
|
514
|
+
* `compute()`'s result is a `ComputeService` instance — its run/load/config/
|
|
515
|
+
* secrets/origin methods live on the class prototype, not as the instance's
|
|
516
|
+
* own properties, so a plain object spread (`{ ...node }`) would silently
|
|
517
|
+
* drop them. Building a fresh `ComputeService` from the same data fields
|
|
518
|
+
* (which `{ ...node }` DOES copy — they're the node's own enumerable
|
|
519
|
+
* properties) with `type` overridden keeps every method intact.
|
|
410
520
|
*/
|
|
411
521
|
function s3StoreService(def) {
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
...node,
|
|
522
|
+
const instance = new ComputeService({
|
|
523
|
+
...compute(def),
|
|
415
524
|
type: "s3-store"
|
|
416
|
-
})
|
|
525
|
+
});
|
|
526
|
+
Object.freeze(instance);
|
|
527
|
+
return instance;
|
|
417
528
|
}
|
|
418
529
|
//#endregion
|
|
419
530
|
//#region ../../1-prisma-cloud/2-shared-modules/storage/dist/storage-service-DSaZsAC4.mjs
|