@prisma/composer-prisma-cloud 0.1.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.
- package/LICENSE +201 -0
- package/dist/control.d.mts +56 -0
- package/dist/control.mjs +1814 -0
- package/dist/control.mjs.map +1 -0
- package/dist/cron/index.d.mts +96 -0
- package/dist/cron/index.mjs +356 -0
- package/dist/cron/index.mjs.map +1 -0
- package/dist/cron/scheduler-entrypoint.mjs +7713 -0
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -0
- package/dist/cron/scheduler-service.mjs +282 -0
- package/dist/cron/scheduler-service.mjs.map +1 -0
- package/dist/index.d.mts +168 -0
- package/dist/index.mjs +179 -0
- package/dist/index.mjs.map +1 -0
- package/dist/prisma-next-COrwlg3N.mjs +176 -0
- package/dist/prisma-next-COrwlg3N.mjs.map +1 -0
- package/dist/prisma-next.d.mts +72 -0
- package/dist/prisma-next.mjs +2 -0
- package/dist/serializer-C2CsA7xm-29Eg2Tjl.mjs +207 -0
- package/dist/serializer-C2CsA7xm-29Eg2Tjl.mjs.map +1 -0
- package/dist/storage/index.d.mts +67 -0
- package/dist/storage/index.mjs +374 -0
- package/dist/storage/index.mjs.map +1 -0
- package/dist/storage/storage-entrypoint.mjs +1138 -0
- package/dist/storage/storage-entrypoint.mjs.map +1 -0
- package/dist/storage/storage-service.mjs +340 -0
- package/dist/storage/storage-service.mjs.map +1 -0
- package/dist/storage/testing.d.mts +82 -0
- package/dist/storage/testing.mjs +531 -0
- package/dist/storage/testing.mjs.map +1 -0
- package/dist/testing.d.mts +26 -0
- package/dist/testing.mjs +32 -0
- package/dist/testing.mjs.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-entrypoint.mjs","names":["#value"],"sources":["../../../../1-prisma-cloud/2-shared-modules/storage/dist/storage-entrypoint.mjs"],"sourcesContent":["import { createHash, createHmac, timingSafeEqual } from \"node:crypto\";\nimport { SQL } from \"bun\";\n//#region ../../1-extensions/target/dist/pg-connection.mjs\n/** Connection resilience helpers for Prisma Postgres cold-starts (FT-5226); no heavy imports (no `effect`/`alchemy`/`pg`), so the deploy lowerings, the pnPostgres runtime client, and bun-runnable services (the storage store, via the pure `@internal/prisma-cloud/connection` subpath) all share one implementation. */\n/** Network-level socket failures node-postgres surfaces as `err.code`. */\nconst TRANSIENT_CODES = /* @__PURE__ */ new Set([\n\t\"ECONNREFUSED\",\n\t\"ECONNRESET\",\n\t\"ETIMEDOUT\",\n\t\"EPIPE\",\n\t\"ENOTFOUND\",\n\t\"EAI_AGAIN\"\n]);\n/** Connection-establishment failure messages (no useful `err.code`). */\nconst TRANSIENT_MESSAGE_FRAGMENTS = [\n\t\"upstream database\",\n\t\"connection terminated\",\n\t\"connection refused\",\n\t\"terminating connection\",\n\t\"server closed the connection\",\n\t\"connection timeout\",\n\t\"timeout expired\"\n];\n/** Whether an error is a transient connection failure worth retrying, as opposed to a real query error that must surface at once. */\nfunction isTransientConnectionError(error) {\n\tif (typeof error !== \"object\" || error === null) return false;\n\tconst code = \"code\" in error && typeof error.code === \"string\" ? error.code : void 0;\n\tif (code !== void 0 && TRANSIENT_CODES.has(code)) return true;\n\tconst message = \"message\" in error && typeof error.message === \"string\" ? error.message.toLowerCase() : \"\";\n\treturn TRANSIENT_MESSAGE_FRAGMENTS.some((fragment) => message.includes(fragment));\n}\n/**\n* Retries an operation past a transient connection failure, bounded (default\n* ~1 min). `shouldRetry` decides what's transient — defaults to retrying\n* everything; the runtime client passes {@link isTransientConnectionError}.\n*/\nasync function withConnectionRetry(operation, opts = {}) {\n\tconst attempts = opts.attempts ?? 12;\n\tconst delayMs = opts.delayMs ?? 5e3;\n\tconst sleep = opts.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));\n\tconst shouldRetry = opts.shouldRetry ?? (() => true);\n\tlet lastError;\n\tfor (let attempt = 1; attempt <= attempts; attempt++) try {\n\t\treturn await operation();\n\t} catch (error) {\n\t\tif (!shouldRetry(error)) throw error;\n\t\tlastError = error;\n\t\tif (attempt < attempts) await sleep(delayMs);\n\t}\n\tthrow lastError;\n}\n/** Retries acquiring a connection past a transient cold-start; {@link withConnectionRetry} with {@link isTransientConnectionError} fixed as the predicate. */\nfunction retryTransientConnect(acquire, opts = {}) {\n\treturn withConnectionRetry(acquire, {\n\t\t...opts,\n\t\tshouldRetry: isTransientConnectionError\n\t});\n}\n//#endregion\n//#region src/pg-store.ts\n/**\n* The `ObjectStore` over Postgres `bytea` (spec § 3): one `objects` table,\n* single-row-per-object. Ranged reads use SQL `substring` so a range request\n* never detoasts the whole object. The schema is applied idempotently at init\n* behind a bounded connection retry — the first connect to a freshly\n* provisioned Postgres is rejected while the upstream is cold (FT-5226).\n*\n* Runtime engine code (`bun` SQL + `node:crypto`); NOT re-exported from the\n* authoring barrel.\n*/\nconst DEFAULT_MAX_KEYS$1 = 1e3;\nfunction etagOf(bytes) {\n\treturn `\"${createHash(\"sha256\").update(bytes).digest(\"hex\")}\"`;\n}\n/** bytea comes back as a Node Buffer (a Uint8Array). Fail closed on anything else rather than returning wrong bytes. */\nfunction toBytes(value) {\n\tif (value instanceof Uint8Array) return value;\n\tthrow new TypeError(`expected bytea to decode as Uint8Array, got ${typeof value}`);\n}\n/** One row → GetResult (both the whole-object and ranged queries alias the payload as `bytes`; `size` is the bigint total). */\nfunction toGetResult(row) {\n\treturn {\n\t\tbytes: toBytes(row.bytes),\n\t\tetag: row.etag,\n\t\tcontentType: row.content_type,\n\t\tsize: Number(row.size)\n\t};\n}\nvar PgObjectStore = class {\n\tsql;\n\tconstructor(sql) {\n\t\tthis.sql = sql;\n\t}\n\tasync put(bucket, key, bytes, opts = {}) {\n\t\tconst etag = etagOf(bytes);\n\t\tconst contentType = opts.contentType ?? \"application/octet-stream\";\n\t\tawait this.sql`\n insert into objects (bucket, key, bytes, size, etag, content_type)\n values (${bucket}, ${key}, ${bytes}, ${bytes.byteLength}, ${etag}, ${contentType})\n on conflict (bucket, key) do update set\n bytes = excluded.bytes, size = excluded.size,\n etag = excluded.etag, content_type = excluded.content_type`;\n\t\treturn { etag };\n\t}\n\tasync get(bucket, key, opts = {}) {\n\t\tconst range = opts.range;\n\t\tif (range) {\n\t\t\tconst from = range.start + 1;\n\t\t\tconst row = (range.end === void 0 ? await this.sql`select substring(bytes from ${from}) as bytes, size, etag, content_type\n from objects where bucket = ${bucket} and key = ${key}` : await this.sql`select substring(bytes from ${from} for ${range.end - range.start + 1}) as bytes,\n size, etag, content_type\n from objects where bucket = ${bucket} and key = ${key}`)[0];\n\t\t\treturn row === void 0 ? null : toGetResult(row);\n\t\t}\n\t\tconst row = (await this.sql`select bytes, size, etag, content_type\n from objects where bucket = ${bucket} and key = ${key}`)[0];\n\t\treturn row === void 0 ? null : toGetResult(row);\n\t}\n\tasync head(bucket, key) {\n\t\tconst row = (await this.sql`select size, etag, content_type\n from objects where bucket = ${bucket} and key = ${key}`)[0];\n\t\tif (row === void 0) return null;\n\t\treturn {\n\t\t\tetag: row.etag,\n\t\t\tsize: Number(row.size),\n\t\t\tcontentType: row.content_type\n\t\t};\n\t}\n\tasync delete(bucket, key) {\n\t\tawait this.sql`delete from objects where bucket = ${bucket} and key = ${key}`;\n\t}\n\tasync list(bucket, opts = {}) {\n\t\tconst prefix = opts.prefix ?? \"\";\n\t\tconst maxKeys = opts.maxKeys ?? DEFAULT_MAX_KEYS$1;\n\t\tconst token = opts.continuationToken;\n\t\tconst limit = maxKeys + 1;\n\t\tconst keys = (token === void 0 ? await this.sql`select key from objects\n where bucket = ${bucket} and starts_with(key, ${prefix})\n order by key limit ${limit}` : await this.sql`select key from objects\n where bucket = ${bucket} and starts_with(key, ${prefix}) and key > ${token}\n order by key limit ${limit}`).map((r) => r.key);\n\t\tconst isTruncated = keys.length > maxKeys;\n\t\tconst page = isTruncated ? keys.slice(0, maxKeys) : keys;\n\t\tconst last = page.at(-1);\n\t\treturn {\n\t\t\tkeys: page,\n\t\t\tisTruncated,\n\t\t\t...isTruncated && last !== void 0 ? { nextContinuationToken: last } : {}\n\t\t};\n\t}\n};\n/**\n* Connect (FT-5219 posture: `max: 1`, short `idleTimeout`), apply the schema\n* idempotently behind the cold-start retry, and return the store.\n*/\nasync function createPgStore(url) {\n\tconst sql = new SQL({\n\t\turl,\n\t\tmax: 1,\n\t\tidleTimeout: 10\n\t});\n\tawait retryTransientConnect(() => sql`\n create table if not exists objects (\n bucket text not null,\n key text not null,\n bytes bytea not null,\n size bigint not null,\n etag text not null,\n content_type text not null,\n created_at timestamptz not null default now(),\n primary key (bucket, key)\n )`);\n\treturn new PgObjectStore(sql);\n}\n//#endregion\n//#region src/sigv4.ts\n/**\n* AWS SigV4 verification for the S3 wire protocol (spec § 2 auth). The payload\n* hash comes from the client — `x-amz-content-sha256` (a real hash or\n* `UNSIGNED-PAYLOAD`) for header auth, `UNSIGNED-PAYLOAD` for presign — and is\n* never re-hashed; the verifier trusts what was signed, like a real S3 endpoint.\n* Runtime engine code (`node:crypto`); not re-exported from the authoring barrel.\n*/\nconst ALGORITHM = \"AWS4-HMAC-SHA256\";\nconst UNSIGNED_PAYLOAD = \"UNSIGNED-PAYLOAD\";\nfunction sha256Hex(data) {\n\treturn createHash(\"sha256\").update(data).digest(\"hex\");\n}\nfunction hmac(key, data) {\n\treturn createHmac(\"sha256\", key).update(data).digest();\n}\n/** AWS canonical URI encoding: every byte except the unreserved set is %XX. */\nfunction awsUriEncode(value) {\n\treturn encodeURIComponent(value).replace(/[!'()*]/g, (ch) => `%${ch.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%7E/g, \"~\");\n}\nfunction parseCredential(credential) {\n\tconst parts = credential.split(\"/\");\n\tif (parts.length !== 5 || parts[4] !== \"aws4_request\") return null;\n\tconst [accessKeyId, date, region, service] = parts;\n\tif (!accessKeyId || !date || !region || !service) return null;\n\treturn {\n\t\taccessKeyId,\n\t\tdate,\n\t\tregion,\n\t\tservice\n\t};\n}\nfunction signingKey(secret, scope) {\n\treturn hmac(hmac(hmac(hmac(`AWS4${secret}`, scope.date), scope.region), scope.service), \"aws4_request\");\n}\nfunction canonicalHeaders(url, req, signedHeaders) {\n\treturn signedHeaders.map((name) => {\n\t\treturn `${name}:${(name === \"host\" ? url.host : req.headers.get(name) ?? \"\").trim().replace(/\\s+/g, \" \")}\\n`;\n\t}).join(\"\");\n}\nfunction canonicalQuery(url, exclude) {\n\tconst entries = [];\n\tfor (const [key, value] of url.searchParams.entries()) {\n\t\tif (exclude !== void 0 && key === exclude) continue;\n\t\tentries.push([awsUriEncode(key), awsUriEncode(value)]);\n\t}\n\tconst cmp = (a, b) => a < b ? -1 : a > b ? 1 : 0;\n\tentries.sort(([ak, av], [bk, bv]) => cmp(ak, bk) || cmp(av, bv));\n\treturn entries.map(([k, v]) => `${k}=${v}`).join(\"&\");\n}\nfunction stringToSign(amzDate, scope, canonicalRequest) {\n\tconst scopeString = `${scope.date}/${scope.region}/${scope.service}/aws4_request`;\n\treturn [\n\t\tALGORITHM,\n\t\tamzDate,\n\t\tscopeString,\n\t\tsha256Hex(canonicalRequest)\n\t].join(\"\\n\");\n}\nfunction signatureMatches(expected, provided) {\n\tconst a = Buffer.from(expected, \"hex\");\n\tconst b = Buffer.from(provided, \"hex\");\n\treturn a.length === b.length && a.length > 0 && timingSafeEqual(a, b);\n}\n/** `YYYYMMDDTHHMMSSZ` → epoch ms, or null when malformed. */\nfunction parseAmzDate(amzDate) {\n\tconst match = /^(\\d{4})(\\d{2})(\\d{2})T(\\d{2})(\\d{2})(\\d{2})Z$/.exec(amzDate);\n\tif (!match) return null;\n\tconst [, y, mo, d, h, mi, s] = match;\n\treturn Date.UTC(Number(y), Number(mo) - 1, Number(d), Number(h), Number(mi), Number(s));\n}\nfunction parseAuthorizationHeader(header) {\n\tif (!header.startsWith(`${ALGORITHM} `)) return null;\n\tconst rest = header.slice(17);\n\tconst fields = /* @__PURE__ */ new Map();\n\tfor (const part of rest.split(\",\")) {\n\t\tconst eq = part.indexOf(\"=\");\n\t\tif (eq === -1) continue;\n\t\tfields.set(part.slice(0, eq).trim(), part.slice(eq + 1).trim());\n\t}\n\tconst credential = fields.get(\"Credential\");\n\tconst signedHeaders = fields.get(\"SignedHeaders\");\n\tconst signature = fields.get(\"Signature\");\n\tif (!credential || !signedHeaders || !signature) return null;\n\treturn {\n\t\tcredential,\n\t\tsignedHeaders: signedHeaders.split(\";\"),\n\t\tsignature\n\t};\n}\n/** The one signing core both auth forms share: check the access key, rebuild the canonical request, derive the key, compare in constant time. */\nfunction verifySignature(req, url, credentials, params) {\n\tif (params.scope.accessKeyId !== credentials.accessKeyId) return {\n\t\tok: false,\n\t\treason: \"unknown access key\"\n\t};\n\tconst canonicalRequest = [\n\t\treq.method,\n\t\turl.pathname,\n\t\tcanonicalQuery(url, params.excludeQuery),\n\t\tcanonicalHeaders(url, req, params.signedHeaders),\n\t\tparams.signedHeaders.join(\";\"),\n\t\tparams.payloadHash\n\t].join(\"\\n\");\n\treturn signatureMatches(hmac(signingKey(credentials.secretAccessKey, params.scope), stringToSign(params.amzDate, params.scope, canonicalRequest)).toString(\"hex\"), params.signature) ? { ok: true } : {\n\t\tok: false,\n\t\treason: \"signature mismatch\"\n\t};\n}\nfunction verifyHeader(req, url, credentials) {\n\tconst auth = parseAuthorizationHeader(req.headers.get(\"authorization\") ?? \"\");\n\tif (!auth) return {\n\t\tok: false,\n\t\treason: \"malformed Authorization header\"\n\t};\n\tconst scope = parseCredential(auth.credential);\n\tif (!scope) return {\n\t\tok: false,\n\t\treason: \"malformed credential scope\"\n\t};\n\tconst amzDate = req.headers.get(\"x-amz-date\");\n\tif (!amzDate) return {\n\t\tok: false,\n\t\treason: \"missing x-amz-date\"\n\t};\n\tconst payloadHash = req.headers.get(\"x-amz-content-sha256\");\n\tif (!payloadHash) return {\n\t\tok: false,\n\t\treason: \"missing x-amz-content-sha256\"\n\t};\n\treturn verifySignature(req, url, credentials, {\n\t\tscope,\n\t\tamzDate,\n\t\tsignedHeaders: auth.signedHeaders,\n\t\tpayloadHash,\n\t\tsignature: auth.signature\n\t});\n}\nfunction verifyPresigned(req, url, credentials, now) {\n\tconst q = url.searchParams;\n\tif (q.get(\"X-Amz-Algorithm\") !== ALGORITHM) return {\n\t\tok: false,\n\t\treason: \"unsupported presign algorithm\"\n\t};\n\tconst credentialRaw = q.get(\"X-Amz-Credential\");\n\tconst amzDate = q.get(\"X-Amz-Date\");\n\tconst expiresRaw = q.get(\"X-Amz-Expires\");\n\tconst signedHeadersRaw = q.get(\"X-Amz-SignedHeaders\");\n\tconst signature = q.get(\"X-Amz-Signature\");\n\tif (!credentialRaw || !amzDate || !expiresRaw || !signedHeadersRaw || !signature) return {\n\t\tok: false,\n\t\treason: \"incomplete presign parameters\"\n\t};\n\tconst scope = parseCredential(credentialRaw);\n\tif (!scope) return {\n\t\tok: false,\n\t\treason: \"malformed credential scope\"\n\t};\n\tconst signedAt = parseAmzDate(amzDate);\n\tconst expires = Number(expiresRaw);\n\tif (signedAt === null || !Number.isFinite(expires)) return {\n\t\tok: false,\n\t\treason: \"malformed presign date\"\n\t};\n\tif (now.getTime() > signedAt + expires * 1e3) return {\n\t\tok: false,\n\t\treason: \"presign expired\"\n\t};\n\treturn verifySignature(req, url, credentials, {\n\t\tscope,\n\t\tamzDate,\n\t\tsignedHeaders: signedHeadersRaw.split(\";\"),\n\t\tpayloadHash: UNSIGNED_PAYLOAD,\n\t\tsignature,\n\t\texcludeQuery: \"X-Amz-Signature\"\n\t});\n}\n/**\n* Verify a request's SigV4 signature against a single credential pair. Picks\n* the presigned form when `X-Amz-Signature` is present, otherwise the\n* `Authorization`-header form. `now` is injectable for deterministic\n* expiry tests.\n*/\nfunction verifyRequest(req, credentials, now = /* @__PURE__ */ new Date()) {\n\tconst url = new URL(req.url);\n\tif (url.searchParams.has(\"X-Amz-Signature\")) return verifyPresigned(req, url, credentials, now);\n\tif (req.headers.has(\"authorization\")) return verifyHeader(req, url, credentials);\n\treturn {\n\t\tok: false,\n\t\treason: \"unsigned request\"\n\t};\n}\n//#endregion\n//#region src/handler.ts\nconst DEFAULT_CONTENT_TYPE = \"application/octet-stream\";\n/** Path-style: `/{bucket}/{key…}`. Each segment is percent-decoded. */\nfunction parseTarget(url) {\n\tconst segments = url.pathname.split(\"/\").filter((s) => s.length > 0);\n\tif (segments.length === 0) return null;\n\tconst [bucket, ...keyParts] = segments;\n\treturn {\n\t\tbucket: decodeURIComponent(bucket ?? \"\"),\n\t\tkey: keyParts.map(decodeURIComponent).join(\"/\")\n\t};\n}\n/** `bytes=a-b` (inclusive) or `bytes=a-` (open-ended). Null when absent/malformed. */\nfunction parseRange(header) {\n\tif (!header) return null;\n\tconst match = /^bytes=(\\d+)-(\\d*)$/.exec(header.trim());\n\tif (!match) return null;\n\tconst start = Number(match[1]);\n\treturn match[2] ? {\n\t\tstart,\n\t\tend: Number(match[2])\n\t} : { start };\n}\nfunction xmlEscape(value) {\n\treturn value.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\"/g, \""\").replace(/'/g, \"'\");\n}\nfunction listXml(bucket, prefix, maxKeys, result) {\n\tconst contents = result.keys.map((k) => `<Contents><Key>${xmlEscape(k)}</Key></Contents>`).join(\"\");\n\tconst next = result.isTruncated && result.nextContinuationToken !== void 0 ? `<NextContinuationToken>${xmlEscape(result.nextContinuationToken)}</NextContinuationToken>` : \"\";\n\treturn `<?xml version=\"1.0\" encoding=\"UTF-8\"?><ListBucketResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><Name>${xmlEscape(bucket)}</Name><Prefix>${xmlEscape(prefix)}</Prefix><KeyCount>${result.keys.length}</KeyCount><MaxKeys>${maxKeys}</MaxKeys><IsTruncated>${result.isTruncated}</IsTruncated>` + contents + next + \"</ListBucketResult>\";\n}\nconst DEFAULT_MAX_KEYS = 1e3;\nasync function handleList(store, bucket, url) {\n\tconst prefix = url.searchParams.get(\"prefix\") ?? \"\";\n\tconst continuationToken = url.searchParams.get(\"continuation-token\");\n\tconst maxKeysRaw = url.searchParams.get(\"max-keys\");\n\tconst maxKeys = maxKeysRaw !== null && Number.isFinite(Number(maxKeysRaw)) ? Number(maxKeysRaw) : DEFAULT_MAX_KEYS;\n\tconst result = await store.list(bucket, {\n\t\tprefix,\n\t\tmaxKeys,\n\t\t...continuationToken !== null ? { continuationToken } : {}\n\t});\n\treturn new Response(listXml(bucket, prefix, maxKeys, result), {\n\t\tstatus: 200,\n\t\theaders: { \"content-type\": \"application/xml\" }\n\t});\n}\n/** aws-chunked / flexible-checksum PUTs frame the body as chunks + a trailer (signalled by `x-amz-content-sha256: STREAMING-…` or `content-encoding: aws-chunked`); the seed signature still verifies, so reject them (501) rather than store the raw framing as the object bytes. Decoding is out of scope. */\nfunction isStreamingPut(req) {\n\tconst contentSha = req.headers.get(\"x-amz-content-sha256\") ?? \"\";\n\tconst contentEncoding = req.headers.get(\"content-encoding\") ?? \"\";\n\treturn contentSha.startsWith(\"STREAMING-\") || contentEncoding.split(\",\").some((e) => e.trim() === \"aws-chunked\");\n}\nasync function handlePut(store, t, req) {\n\tif (isStreamingPut(req)) return new Response(\"aws-chunked / flexible checksums not supported; set requestChecksumCalculation: 'WHEN_REQUIRED'\", { status: 501 });\n\tconst body = new Uint8Array(await req.arrayBuffer());\n\tconst contentType = req.headers.get(\"content-type\") ?? DEFAULT_CONTENT_TYPE;\n\tconst { etag } = await store.put(t.bucket, t.key, body, { contentType });\n\treturn new Response(null, {\n\t\tstatus: 200,\n\t\theaders: { etag }\n\t});\n}\n/** The etag/content-type/content-length/accept-ranges headers GET and HEAD share — `contentLength` is the slice length for GET, the total object size for HEAD. */\nfunction metaHeaders(meta) {\n\treturn new Headers({\n\t\tetag: meta.etag,\n\t\t\"content-type\": meta.contentType,\n\t\t\"content-length\": String(meta.contentLength),\n\t\t\"accept-ranges\": \"bytes\"\n\t});\n}\nasync function handleGet(store, t, req) {\n\tconst range = parseRange(req.headers.get(\"range\"));\n\tconst object = await store.get(t.bucket, t.key, range ? { range } : void 0);\n\tif (!object) return new Response(null, { status: 404 });\n\tconst headers = metaHeaders({\n\t\tetag: object.etag,\n\t\tcontentType: object.contentType,\n\t\tcontentLength: object.bytes.byteLength\n\t});\n\tif (!range) return new Response(object.bytes, {\n\t\tstatus: 200,\n\t\theaders\n\t});\n\tif (range.start >= object.size && object.size > 0) return new Response(null, {\n\t\tstatus: 416,\n\t\theaders: { \"content-range\": `bytes */${object.size}` }\n\t});\n\tconst end = range.end === void 0 ? object.size - 1 : Math.min(range.end, object.size - 1);\n\theaders.set(\"content-range\", `bytes ${range.start}-${end}/${object.size}`);\n\treturn new Response(object.bytes, {\n\t\tstatus: 206,\n\t\theaders\n\t});\n}\nasync function handleHead(store, t) {\n\tconst meta = await store.head(t.bucket, t.key);\n\tif (!meta) return new Response(null, { status: 404 });\n\treturn new Response(null, {\n\t\tstatus: 200,\n\t\theaders: metaHeaders({\n\t\t\tetag: meta.etag,\n\t\t\tcontentType: meta.contentType,\n\t\t\tcontentLength: meta.size\n\t\t})\n\t});\n}\nasync function handleDelete(store, t) {\n\tawait store.delete(t.bucket, t.key);\n\treturn new Response(null, { status: 204 });\n}\nfunction createS3Handler(opts) {\n\tconst { store, credentials } = opts;\n\treturn async (req) => {\n\t\tif (!verifyRequest(req, credentials).ok) return new Response(null, { status: 403 });\n\t\tconst url = new URL(req.url);\n\t\tconst target = parseTarget(url);\n\t\tif (!target) return new Response(null, { status: 400 });\n\t\tif (req.method === \"GET\" && url.searchParams.get(\"list-type\") === \"2\" && target.key === \"\") return handleList(store, target.bucket, url);\n\t\tif (target.key === \"\") return new Response(null, { status: 400 });\n\t\tswitch (req.method) {\n\t\t\tcase \"PUT\": return handlePut(store, target, req);\n\t\t\tcase \"GET\": return handleGet(store, target, req);\n\t\t\tcase \"HEAD\": return handleHead(store, target);\n\t\t\tcase \"DELETE\": return handleDelete(store, target);\n\t\t\tdefault: return new Response(null, { status: 405 });\n\t\t}\n\t};\n}\n//#endregion\n//#region src/storage-server.ts\n/**\n* Boots the S3 wire protocol on `Bun.serve` — the D2 handler over any\n* `ObjectStore`. Binds all interfaces (Compute routes external HTTP to the VM,\n* so a loopback-only listener would be unreachable). Installs the FT-5219\n* process guards so an idle Bun.SQL connection close surfaces as a logged\n* error instead of crash-looping the process on scale-to-zero.\n*\n* Runtime engine code; NOT re-exported from the authoring barrel. The D4\n* entrypoint reads deps via `load()` and calls this.\n*/\nlet guardsInstalled = false;\n/** FT-5219: keep the process alive when Bun.SQL surfaces an idle-close as an unawaited async error. Installed once. */\nfunction installProcessGuards() {\n\tif (guardsInstalled) return;\n\tguardsInstalled = true;\n\tprocess.on(\"uncaughtException\", (err) => console.error(\"uncaughtException\", err));\n\tprocess.on(\"unhandledRejection\", (err) => console.error(\"unhandledRejection\", err));\n}\nfunction startStorageServer(opts) {\n\tinstallProcessGuards();\n\tconst handler = createS3Handler({\n\t\tstore: opts.store,\n\t\tcredentials: opts.credentials\n\t});\n\tconst hostname = opts.hostname ?? \"0.0.0.0\";\n\tconst server = Bun.serve({\n\t\tport: opts.port,\n\t\thostname,\n\t\tfetch: (req) => handler(req)\n\t});\n\treturn {\n\t\turl: `http://${hostname === \"0.0.0.0\" ? \"127.0.0.1\" : hostname}:${server.port}`,\n\t\tstop: () => server.stop(true)\n\t};\n}\n//#endregion\n//#region ../../../0-framework/0-foundation/foundation/dist/casts.mjs\n/**\n* **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**\n*\n* Before reaching for `blindCast`, **rewrite the surrounding code so the cast becomes\n* unnecessary**: tighten an input type, add a runtime check that narrows via a type\n* predicate, restructure a generic so the compiler can see the relationship you're\n* asserting, or use {@link castAs} when the value already satisfies the target type.\n* Only when no rewrite is feasible does `blindCast` become the right answer — and at\n* that point, the `Reason` literal you supply must articulate the compromise in\n* language a reviewer can evaluate.\n*\n* The reviewer **will** validate the `Reason`. If it doesn't hold up under scrutiny,\n* that is not a signal to soften the reason; it is a signal to go back and solve the\n* underlying type-system problem properly. An unconvincing justification is rework,\n* not a free pass.\n*\n* `blindCast` is the auditable form of `as Foo` / `as unknown as Foo`: it bypasses\n* the compiler's checks (the input type is `unknown`, the output type is whatever the\n* caller asks for), but it forces the unsafety to be named at the call site instead of\n* smuggled in via a bare `as`. The `Reason` type parameter exists only at compile\n* time — it is not present in the emitted JavaScript — but it is grep-able and\n* visible to future readers.\n*\n* @example\n* ```typescript\n* const stringValue = blindCast<\n* string,\n* \"JSON.parse returns `unknown`; this field is documented to be a string in the API contract\"\n* >(parsed[key]);\n* ```\n*\n* @typeParam TargetType - The type the caller is asserting the input has.\n* @typeParam _Reason - A string literal describing why bypassing the type system is necessary here.\n* Only meaningful at compile time. The reviewer evaluates whether it justifies the unsafety.\n*/\nfunction blindCast(input) {\n\treturn input;\n}\n//#endregion\n//#region ../../../0-framework/1-core/core/dist/graph-BYdCQKya.mjs\n/**\n* Core model: node types and the factories that construct them, plain frozen\n* data objects. A node's `extension` + `type` form its deploy-time registry key (ADR-0017).\n*/\nconst NODE = Symbol.for(\"prisma:node\");\nfunction requireType(type, factory) {\n\tif (typeof type !== \"string\" || type.length === 0) throw new Error(`${factory}() requires a non-empty node type.`);\n}\nfunction requireName(name, factory) {\n\tif (typeof name !== \"string\" || name.length === 0) throw new Error(`${factory}() requires a non-empty name.`);\n}\nfunction requireExtension(extension, factory) {\n\tif (typeof extension !== \"string\" || extension.length === 0) throw new Error(`${factory}() requires a non-empty extension (the authoring extension's package name).`);\n}\n/**\n* Config keys join address/input/param names with \"_\" and uppercase — an\n* underscore inside a name would collide with that separator (e.g. param\n* \"db_url\" vs input \"db\"'s param \"url\" both hitting env key \"DB_URL\").\n*/\nfunction requireNoUnderscoreName(name, kind, factory) {\n\tif (name.includes(\"_\")) throw new Error(`${factory}() ${kind} name \"${name}\" may not contain \"_\" — config keys join names with \"_\" as the separator (e.g. an input \"db\"'s param \"url\" becomes env key \"DB_URL\"), so an underscore inside a name would collide with that separator.`);\n}\nfunction requireNoUnderscoreNames(names, kind, factory) {\n\tfor (const name of names) requireNoUnderscoreName(name, kind, factory);\n}\nfunction freezeParams(params) {\n\tconst frozen = {};\n\tfor (const [name, param] of Object.entries(params)) frozen[name] = Object.freeze({ ...param });\n\treturn Object.freeze(frozen);\n}\nfunction freezeSecrets(secrets) {\n\tconst frozen = {};\n\tfor (const [name, need] of Object.entries(secrets)) frozen[name] = Object.freeze({ ...need });\n\treturn blindCast(Object.freeze(frozen));\n}\n/** A frozen shallow copy that keeps the caller's declared type. */\nfunction frozenShallowCopy(obj) {\n\treturn blindCast(Object.freeze({ ...obj }));\n}\n/**\n* Seals a node instance after its constructor has assigned all fields — the\n* last statement of a concrete node class's constructor. A free function, not\n* a base-class method, so an instance stays structurally a plain frozen node.\n*/\nfunction freezeNode(node) {\n\tObject.freeze(node);\n\treturn node;\n}\n/**\n* Everything `resource()` establishes, minus the freeze — an extension\n* whose resource node carries extra fields extends this, assigns them, and\n* calls `freezeNode(this)` as its constructor's last statement.\n*/\nvar ResourceNodeBase = class {\n\t[NODE] = true;\n\tkind = \"resource\";\n\tname;\n\textension;\n\ttype;\n\tprovides;\n\tconstructor(def) {\n\t\trequireName(def.name, \"resource\");\n\t\trequireExtension(def.extension, \"resource\");\n\t\tconst provides = def.provides;\n\t\tif (typeof provides !== \"object\" || provides === null || typeof provides.kind !== \"string\" || provides.kind.length === 0 || typeof provides.satisfies !== \"function\") throw new Error(\"resource() requires `provides` — the Contract this resource offers (a non-empty `kind` plus its `satisfies()`).\");\n\t\tthis.name = def.name;\n\t\tthis.extension = def.extension;\n\t\tthis.type = provides.kind;\n\t\tthis.provides = provides;\n\t}\n};\n/** The core leaf: exactly the base, frozen. */\nvar FrozenResourceNode = class extends ResourceNodeBase {\n\tconstructor(def) {\n\t\tsuper(def);\n\t\tfreezeNode(this);\n\t}\n};\n/**\n* Constructs a branded, frozen Resource node — an identity plus the Contract\n* it provides; the routing `type` is the contract's `kind`. Pure — nothing\n* is provisioned until a module provisions it.\n*/\nfunction resource(def) {\n\treturn new FrozenResourceNode(def);\n}\n/**\n* Constructs a branded, frozen Service node — declarations only (inputs,\n* params, build adapter, and the ports it exposes). Pure; carries no runtime behavior.\n*/\nfunction service$1(def) {\n\trequireName(def.name, \"service\");\n\trequireExtension(def.extension, \"service\");\n\trequireType(def.type, \"service\");\n\trequireNoUnderscoreNames(Object.keys(def.inputs), \"input\", \"service\");\n\trequireNoUnderscoreNames(Object.keys(def.params), \"param\", \"service\");\n\trequireNoUnderscoreNames(Object.keys(def.secrets ?? {}), \"secret\", \"service\");\n\tfor (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 (COMPOSE_<addr>_${slot.toUpperCase()}); rename one.`);\n\treturn Object.freeze({\n\t\t[NODE]: true,\n\t\tkind: \"service\",\n\t\tname: def.name,\n\t\textension: def.extension,\n\t\ttype: def.type,\n\t\tinputs: frozenShallowCopy(def.inputs),\n\t\tparams: freezeParams(def.params),\n\t\tsecretSlots: freezeSecrets(def.secrets ?? blindCast({})),\n\t\tbuild: Object.freeze({ ...def.build }),\n\t\texpose: def.expose !== void 0 ? frozenShallowCopy(def.expose) : void 0\n\t});\n}\n/**\n* Constructs a branded, frozen DependencyEnd. `required` (if given) is the\n* contract Load compares a wired ref against via `satisfies()`; an unnamed\n* end's diagnostic `name` falls back to its `type`.\n*/\nfunction dependency(def) {\n\trequireType(def.type, \"dependency\");\n\trequireNoUnderscoreNames(Object.keys(def.connection.params), \"param\", \"dependency\");\n\tconst connection = Object.freeze({\n\t\tparams: freezeParams(def.connection.params),\n\t\thydrate: def.connection.hydrate\n\t});\n\treturn Object.freeze({\n\t\t[NODE]: true,\n\t\tkind: \"dependency\",\n\t\tname: def.name !== void 0 && def.name.length > 0 ? def.name : def.type,\n\t\ttype: def.type,\n\t\tconnection,\n\t\trequired: def.required\n\t});\n}\n//#endregion\n//#region ../../../0-framework/0-foundation/foundation/dist/secret.mjs\n/**\n* A value wrapper that redacts everywhere except the one explicit reader,\n* `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a\n* sink must remember to check: `String(box)`, template interpolation,\n* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so\n* a secret can't leak through an accidental log or serialization.\n*\n* Shape matches the platform's own `secrecy` type (pdp-control-plane). The class\n* is nominal enough on its own — no phantom brand.\n*/\nconst REDACTED = \"[REDACTED]\";\nvar SecretBox = class {\n\t#value;\n\tconstructor(value) {\n\t\tthis.#value = value;\n\t}\n\t/** The sole explicit door to the wrapped value. */\n\texpose() {\n\t\treturn this.#value;\n\t}\n\ttoString() {\n\t\treturn REDACTED;\n\t}\n\ttoJSON() {\n\t\treturn REDACTED;\n\t}\n\tvalueOf() {\n\t\treturn REDACTED;\n\t}\n\t[Symbol.toPrimitive]() {\n\t\treturn REDACTED;\n\t}\n\t[Symbol.for(\"nodejs.util.inspect.custom\")]() {\n\t\treturn REDACTED;\n\t}\n};\n//#endregion\n//#region ../../../0-framework/1-core/core/dist/index.mjs\nfunction scalarSchema(name, check) {\n\treturn { \"~standard\": {\n\t\tversion: 1,\n\t\tvendor: \"@prisma/composer\",\n\t\tvalidate: (value) => check(value) ? { value } : { issues: [{ message: `expected ${name}, got ${typeof value}` }] }\n\t} };\n}\nconst stringSchema = scalarSchema(\"string\", (v) => typeof v === \"string\");\nconst numberSchema = scalarSchema(\"number\", (v) => typeof v === \"number\" && Number.isFinite(v));\nfunction withFacets(schema, opts) {\n\treturn {\n\t\tschema,\n\t\t...opts.optional !== void 0 ? { optional: opts.optional } : {},\n\t\t...opts.default !== void 0 ? { default: opts.default } : {}\n\t};\n}\n/** A string-valued param. */\nfunction string(opts = {}) {\n\treturn withFacets(stringSchema, opts);\n}\n/** A number-valued param. */\nfunction number(opts = {}) {\n\treturn withFacets(numberSchema, opts);\n}\n/**\n* Synchronous hydrate — what the node's `load()` uses so\n* `const { db } = service.load()` reads without `await`. Requires every\n* connection.hydrate to return synchronously; a Promise return is a loud error\n* naming the input (an async client factory must use the async `hydrate` path).\n*/\nfunction hydrateSync(root, config) {\n\tconst deps = {};\n\tfor (const [name, inputNode] of Object.entries(root.inputs)) {\n\t\tconst values = config.inputs[name] ?? {};\n\t\tconst client = inputNode.connection.hydrate(values);\n\t\tif (client instanceof Promise) throw new Error(`Connection hydrate for input \"${name}\" returned a Promise; load() requires a synchronous client factory.`);\n\t\tdeps[name] = client;\n\t}\n\treturn deps;\n}\n/**\n* Wraps each of a service's resolved secret values in a redacting `SecretBox`\n* — what the node's `secrets()` accessor returns (ADR-0021, sibling to\n* `load()`/`config()`). The RESOLUTION of a secret's value (the boot\n* double-lookup that reads the platform var the pointer names) is the target\n* pack's job; core is handed the already-resolved strings and only boxes them,\n* so a secret is redacted by TYPE from here on. A declared slot missing from\n* `values` is a target contract violation, named loudly.\n*/\nfunction hydrateSecrets(root, values) {\n\tconst boxed = {};\n\tfor (const slot of Object.keys(root.secretSlots)) {\n\t\tconst value = values[slot];\n\t\tif (value === void 0) throw new Error(`secret slot \"${slot}\" has no resolved value — the target must resolve every declared secret before hydrateSecrets().`);\n\t\tboxed[slot] = new SecretBox(value);\n\t}\n\treturn blindCast(boxed);\n}\n//#endregion\n//#region ../../../0-framework/2-authoring/node/dist/index.mjs\nconst nodeBuild = (opts) => ({\n\textension: \"@prisma/composer/node\",\n\ttype: \"node\",\n\tmodule: opts.module,\n\tentry: opts.entry\n});\n/**\n* Walks a node's own params, then each dependency input's connection params —\n* the same enumeration order `configOf` uses, but carrying the raw\n* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data\n* projection.\n*/\nfunction paramEntries(node) {\n\tconst entries = [];\n\tfor (const [input, value] of Object.entries(node.inputs)) {\n\t\tif (typeof value !== \"object\" || value === null) continue;\n\t\tconst params = blindCast(value).connection.params;\n\t\tfor (const [name, param] of Object.entries(params)) entries.push({\n\t\t\towner: { input },\n\t\t\tname,\n\t\t\tparam\n\t\t});\n\t}\n\tfor (const [name, param] of Object.entries(node.params)) entries.push({\n\t\towner: \"service\",\n\t\tname,\n\t\tparam\n\t});\n\treturn entries;\n}\nconst configKey = (address, d) => {\n\tconst segments = address.split(\".\").filter((s) => s.length > 0);\n\tconst owner = d.owner === \"service\" ? [] : [d.owner.input];\n\treturn [\n\t\t\"COMPOSE\",\n\t\t...segments,\n\t\t...owner,\n\t\td.name\n\t].join(\"_\").toUpperCase();\n};\n/**\n* Typed value → its stored string. Service-own literals are JSON-encoded; a\n* dependency-input value is a provisioning ref at deploy (and a resolved\n* string at boot) and passes through untouched — LANDMINE: JSON-encoding it\n* would break the ordering edge Alchemy resolves through it.\n*/\nfunction encode(owner, value) {\n\treturn owner === \"service\" ? JSON.stringify(value) : blindCast(value);\n}\n/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */\nfunction decode(owner, raw) {\n\treturn owner === \"service\" ? JSON.parse(raw) : raw;\n}\nfunction coerce(raw, d, key) {\n\tif (!(raw !== void 0 && raw !== \"\")) {\n\t\tif (d.param.default !== void 0) return d.param.default;\n\t\tif (d.param.optional === true) return void 0;\n\t\tthrow new Error(`missing required config param \"${d.name}\" (env ${key})`);\n\t}\n\ttry {\n\t\treturn standardValidateSync(d.param.schema, decode(d.owner, raw));\n\t} catch (cause) {\n\t\tconst message = cause instanceof Error ? cause.message : String(cause);\n\t\tthrow new Error(`invalid value for config param \"${d.name}\" (env ${key}): ${message}`);\n\t}\n}\n/**\n* Boot: read each declared param from env by its key, reverse the param's own\n* serialization (missing/invalid fails loudly), assemble the typed Config.\n* Secrets ride a separate channel (deserializeSecrets), not this one.\n*/\nconst deserialize = (node, address) => {\n\tconst service = {};\n\tconst inputs = {};\n\tfor (const d of paramEntries(node)) {\n\t\tconst key = configKey(address, d);\n\t\tconst value = coerce(process.env[key], d, key);\n\t\tif (d.owner === \"service\") service[d.name] = value;\n\t\telse {\n\t\t\tlet bucket = inputs[d.owner.input];\n\t\t\tif (bucket === void 0) {\n\t\t\t\tbucket = {};\n\t\t\t\tinputs[d.owner.input] = bucket;\n\t\t\t}\n\t\t\tbucket[d.name] = value;\n\t\t}\n\t}\n\treturn {\n\t\tservice,\n\t\tinputs\n\t};\n};\n/**\n* run()'s setup step: write the resolved config to the environment under\n* address-free keys (configKey(\"\", d) + each serialize suffix), which load()\n* reads back with no address. Uses env, not a module variable, because a\n* framework may fork worker processes that inherit env but not memory.\n* Writes only these keys; nothing else is touched.\n*/\nconst stash = (node, config) => {\n\tfor (const d of paramEntries(node)) {\n\t\tconst value = d.owner === \"service\" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];\n\t\tif (value === void 0) continue;\n\t\tprocess.env[configKey(\"\", d)] = encode(d.owner, value);\n\t}\n};\n/** The pointer-row key for a secret slot: COMPOSE_<addr>_<slot> (secrets are service-level). */\nconst secretKey = (address, slot) => configKey(address, {\n\towner: \"service\",\n\tname: slot\n});\n/**\n* Boot: resolve every secret slot to its value by double-lookup — read the\n* pointer key (the platform NAME), then read that platform var. A missing\n* pointer or a missing/empty platform value is a loud failure naming both keys.\n* Returns a plain Record for core's `hydrateSecrets` to box.\n*/\nconst deserializeSecrets = (node, address) => {\n\tconst values = {};\n\tfor (const slot of Object.keys(node.secretSlots)) {\n\t\tconst key = secretKey(address, slot);\n\t\tconst name = process.env[key];\n\t\tif (name === void 0 || name === \"\") throw new Error(`missing secret pointer for slot \"${slot}\" (env ${key}) — the deploy did not write it.`);\n\t\tconst value = process.env[name];\n\t\tif (value === void 0 || value === \"\") throw new Error(`secret \"${slot}\" is not provisioned (env ${key} → ${name}): the platform var \"${name}\" is unset or empty.`);\n\t\tvalues[slot] = value;\n\t}\n\treturn values;\n};\n/**\n* run()'s setup step for secrets: re-emit each slot's pointer NAME under its\n* address-free key, so the address-free `deserializeSecrets` double-looks-up\n* identically. Never the value — the value stays only in the platform var.\n*/\nconst stashSecrets = (node, address) => {\n\tfor (const slot of Object.keys(node.secretSlots)) {\n\t\tconst name = process.env[secretKey(address, slot)];\n\t\tif (name === void 0) continue;\n\t\tprocess.env[secretKey(\"\", slot)] = name;\n\t}\n};\n/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */\nfunction standardValidateSync(schema, value) {\n\tconst result = schema[\"~standard\"].validate(value);\n\tif (result instanceof Promise) throw new Error(\"config param schema validation must be synchronous — async Standard Schema validators are not supported for config params\");\n\tif (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join(\"; \")}`);\n\treturn result.value;\n}\n//#endregion\n//#region ../../1-extensions/target/dist/index.mjs\nconst reservedParams = { port: number({ default: 3e3 }) };\n/**\n* A Prisma Compute service — declarations only (deps + params + build + the\n* ports it exposes), no descriptor. `params` merges with the reserved\n* `ReservedParams` (`port`); a user param whose name collides with a reserved\n* one fails at authoring, the same way a colliding dependency name does.\n* Returns the extension's runnable/loadable node:\n* · run(address, boot) — the process controller: deserialize the platform\n* environment (keyed off `address`, the extension's ONE env read) into a\n* typed Config, re-emit it under address-free process-local stash keys,\n* then call boot() to start the app's entry.\n* · load() / config() — called from inside the app's entry: read the stash;\n* load() hydrates + memoizes the deps, config() returns the typed params.\n* Separate accessors so a dep and a param never share a namespace (ADR-0021).\n*\n* `service()`'s underlying node carries `extension: '@prisma/composer-prisma-cloud'` —\n* the control-plane registry key `prisma-composer deploy` resolves through the\n* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at\n* deploy time; nodes are pure data.\n*/\nconst compute = (def) => {\n\tconst userParams = def.params ?? blindCast({});\n\tfor (const reserved of Object.keys(reservedParams)) {\n\t\tif (reserved in def.deps) throw new Error(`compute(): dependency \"${reserved}\" collides with the reserved service param of the same name — rename the dependency.`);\n\t\tif (reserved in userParams) throw new Error(`compute(): param \"${reserved}\" collides with the reserved service param of the same name — rename the param.`);\n\t}\n\tconst params = blindCast({\n\t\t...userParams,\n\t\t...reservedParams\n\t});\n\tconst node = service$1({\n\t\tname: def.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\ttype: \"compute\",\n\t\tinputs: def.deps,\n\t\tparams,\n\t\t...def.secrets !== void 0 ? { secrets: def.secrets } : {},\n\t\tbuild: def.build,\n\t\t...def.expose !== void 0 ? { expose: def.expose } : {}\n\t});\n\tlet resolved;\n\tlet loadedDeps;\n\tlet loadedParams;\n\tlet loadedSecrets;\n\tfunction processConfig() {\n\t\tif (resolved === void 0) resolved = deserialize(node, \"\");\n\t\treturn resolved;\n\t}\n\tconst runnable = {\n\t\t...node,\n\t\tasync run(address, boot) {\n\t\t\tconst config = deserialize(node, address);\n\t\t\tstash(node, config);\n\t\t\tstashSecrets(node, address);\n\t\t\tconst port = config.service[\"port\"];\n\t\t\tif (typeof port === \"number\") process.env[\"PORT\"] = String(port);\n\t\t\treturn boot();\n\t\t},\n\t\tload() {\n\t\t\tif (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));\n\t\t\treturn loadedDeps;\n\t\t},\n\t\tconfig() {\n\t\t\tif (loadedParams === void 0) loadedParams = blindCast(processConfig().service);\n\t\t\treturn loadedParams;\n\t\t},\n\t\tsecrets() {\n\t\t\tif (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, \"\")));\n\t\t\treturn loadedSecrets;\n\t\t}\n\t};\n\treturn Object.freeze(blindCast(runnable));\n};\n/**\n* The contract a Postgres provides — and the contract its consumers require.\n* `satisfies` compares KIND, not identity: an extension module can be duplicated\n* across a workspace (same rationale as the Symbol.for node brand), and every\n* duplicate's contract must still satisfy. `__cmp` is the connection config a\n* postgres offers; core never inspects it.\n*/\nconst postgresContract = Object.freeze({\n\tkind: \"postgres\",\n\t__cmp: { url: \"\" },\n\tsatisfies: (required) => required.kind === \"postgres\"\n});\nfunction postgres(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: postgresContract\n\t});\n\treturn dependency({\n\t\ttype: \"postgres\",\n\t\tconnection: {\n\t\t\tparams: { url: string() },\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: postgresContract\n\t});\n}\n/**\n* The contract the `s3-credentials` resource provides — a minted SigV4 key\n* pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is\n* the config the resource offers, which core never inspects.\n*/\nconst credentialsContract = Object.freeze({\n\tkind: \"credentials\",\n\t__cmp: {\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"credentials\"\n});\nfunction s3Credentials(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: credentialsContract\n\t});\n\treturn dependency({\n\t\ttype: \"credentials\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\taccessKeyId: string(),\n\t\t\t\tsecretAccessKey: string()\n\t\t\t},\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: credentialsContract\n\t});\n}\n/**\n* The storage service authoring factory — a `compute` service routed to the\n* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s\n* runnable (run/load/config, deps, params, build, expose) with the routing\n* `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the\n* serializer keys off the deployment address and each param's owner/name, and\n* `load`/`config` off deps/params), so only the deploy-time descriptor lookup\n* sees the override and routes to the extended-output lowering (§ 5). The\n* return type is compute's exactly (including the reserved `port` param). The\n* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`\n* param, and `expose: { store: s3Contract }`.\n*/\nfunction s3StoreService(def) {\n\tconst node = compute(def);\n\treturn Object.freeze(blindCast({\n\t\t...node,\n\t\ttype: \"s3-store\"\n\t}));\n}\n//#endregion\n//#region src/contract.ts\nconst s3Contract = Object.freeze({\n\tkind: \"s3\",\n\t__cmp: {\n\t\turl: \"\",\n\t\tbucket: \"\",\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"s3\"\n});\n//#endregion\n//#region src/storage-service.ts\n/**\n* The storage service node (like cron's `scheduler.ts` + `scheduler-service.ts`\n* combined): `storageService` builds the `s3-store` service — a Postgres `db`\n* dependency, a minted `credentials` dependency, a `bucket` param, and the\n* `store` port exposing `s3Contract`. The deploy bootstrap runs the\n* default-exported bare node (`main.run(address, boot)`); the real bucket comes\n* from serialized config at runtime, so the default's `bucket` is only a\n* placeholder — exactly like `scheduler-service.ts` default-exports\n* `cronScheduler({ jobs: [] })`.\n*/\nfunction storageService(opts) {\n\treturn s3StoreService({\n\t\tname: \"storage\",\n\t\tdeps: {\n\t\t\tdb: postgres(),\n\t\t\tcredentials: s3Credentials()\n\t\t},\n\t\tparams: { bucket: string({ default: opts.bucket }) },\n\t\tbuild: nodeBuild({\n\t\t\tmodule: new URL(\"./storage-service.mjs\", import.meta.url).href,\n\t\t\tentry: \"./storage-entrypoint.mjs\"\n\t\t}),\n\t\texpose: { store: s3Contract }\n\t});\n}\nstorageService({ bucket: \"storage\" });\n//#endregion\n//#region src/storage-entrypoint.ts\nconst service = storageService({ bucket: \"storage\" });\nconst { db, credentials } = service.load();\nconst { bucket, port } = service.config();\nstartStorageServer({\n\tstore: await createPgStore(db.url),\n\tcredentials,\n\tbucket,\n\tport\n});\n//#endregion\nexport {};\n\n//# sourceMappingURL=storage-entrypoint.mjs.map"],"mappings":";;;;;AAKA,MAAM,kCAAkC,IAAI,IAAI;CAC/C;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAED,MAAM,8BAA8B;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,SAAS,2BAA2B,OAAO;CAC1C,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,OAAO,UAAU,SAAS,OAAO,MAAM,SAAS,WAAW,MAAM,OAAO,KAAK;CACnF,IAAI,SAAS,KAAK,KAAK,gBAAgB,IAAI,IAAI,GAAG,OAAO;CACzD,MAAM,UAAU,aAAa,SAAS,OAAO,MAAM,YAAY,WAAW,MAAM,QAAQ,YAAY,IAAI;CACxG,OAAO,4B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;CACA;CACA;AACD,CAAC"}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { dependency, hydrateSecrets, hydrateSync, number, resource, service, string } from "@prisma/composer";
|
|
2
|
+
import { blindCast } from "@prisma/composer/casts";
|
|
3
|
+
import node from "@prisma/composer/node";
|
|
4
|
+
blindCast(Symbol.for("prisma:prisma-cloud-secret-source"));
|
|
5
|
+
/**
|
|
6
|
+
* Walks a node's own params, then each dependency input's connection params —
|
|
7
|
+
* the same enumeration order `configOf` uses, but carrying the raw
|
|
8
|
+
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
9
|
+
* projection.
|
|
10
|
+
*/
|
|
11
|
+
function paramEntries(node) {
|
|
12
|
+
const entries = [];
|
|
13
|
+
for (const [input, value] of Object.entries(node.inputs)) {
|
|
14
|
+
if (typeof value !== "object" || value === null) continue;
|
|
15
|
+
const params = blindCast(value).connection.params;
|
|
16
|
+
for (const [name, param] of Object.entries(params)) entries.push({
|
|
17
|
+
owner: { input },
|
|
18
|
+
name,
|
|
19
|
+
param
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
23
|
+
owner: "service",
|
|
24
|
+
name,
|
|
25
|
+
param
|
|
26
|
+
});
|
|
27
|
+
return entries;
|
|
28
|
+
}
|
|
29
|
+
const configKey = (address, d) => {
|
|
30
|
+
const segments = address.split(".").filter((s) => s.length > 0);
|
|
31
|
+
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
32
|
+
return [
|
|
33
|
+
"COMPOSE",
|
|
34
|
+
...segments,
|
|
35
|
+
...owner,
|
|
36
|
+
d.name
|
|
37
|
+
].join("_").toUpperCase();
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
41
|
+
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
42
|
+
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
43
|
+
* would break the ordering edge Alchemy resolves through it.
|
|
44
|
+
*/
|
|
45
|
+
function encode(owner, value) {
|
|
46
|
+
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
47
|
+
}
|
|
48
|
+
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
49
|
+
function decode(owner, raw) {
|
|
50
|
+
return owner === "service" ? JSON.parse(raw) : raw;
|
|
51
|
+
}
|
|
52
|
+
function coerce(raw, d, key) {
|
|
53
|
+
if (!(raw !== void 0 && raw !== "")) {
|
|
54
|
+
if (d.param.default !== void 0) return d.param.default;
|
|
55
|
+
if (d.param.optional === true) return void 0;
|
|
56
|
+
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
60
|
+
} catch (cause) {
|
|
61
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
62
|
+
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Boot: read each declared param from env by its key, reverse the param's own
|
|
67
|
+
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
68
|
+
* Secrets ride a separate channel (deserializeSecrets), not this one.
|
|
69
|
+
*/
|
|
70
|
+
const deserialize = (node, address) => {
|
|
71
|
+
const service = {};
|
|
72
|
+
const inputs = {};
|
|
73
|
+
for (const d of paramEntries(node)) {
|
|
74
|
+
const key = configKey(address, d);
|
|
75
|
+
const value = coerce(process.env[key], d, key);
|
|
76
|
+
if (d.owner === "service") service[d.name] = value;
|
|
77
|
+
else {
|
|
78
|
+
let bucket = inputs[d.owner.input];
|
|
79
|
+
if (bucket === void 0) {
|
|
80
|
+
bucket = {};
|
|
81
|
+
inputs[d.owner.input] = bucket;
|
|
82
|
+
}
|
|
83
|
+
bucket[d.name] = value;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
service,
|
|
88
|
+
inputs
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* run()'s setup step: write the resolved config to the environment under
|
|
93
|
+
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
94
|
+
* reads back with no address. Uses env, not a module variable, because a
|
|
95
|
+
* framework may fork worker processes that inherit env but not memory.
|
|
96
|
+
* Writes only these keys; nothing else is touched.
|
|
97
|
+
*/
|
|
98
|
+
const stash = (node, config) => {
|
|
99
|
+
for (const d of paramEntries(node)) {
|
|
100
|
+
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
101
|
+
if (value === void 0) continue;
|
|
102
|
+
process.env[configKey("", d)] = encode(d.owner, value);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
/** The pointer-row key for a secret slot: COMPOSE_<addr>_<slot> (secrets are service-level). */
|
|
106
|
+
const secretKey = (address, slot) => configKey(address, {
|
|
107
|
+
owner: "service",
|
|
108
|
+
name: slot
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* Boot: resolve every secret slot to its value by double-lookup — read the
|
|
112
|
+
* pointer key (the platform NAME), then read that platform var. A missing
|
|
113
|
+
* pointer or a missing/empty platform value is a loud failure naming both keys.
|
|
114
|
+
* Returns a plain Record for core's `hydrateSecrets` to box.
|
|
115
|
+
*/
|
|
116
|
+
const deserializeSecrets = (node, address) => {
|
|
117
|
+
const values = {};
|
|
118
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
119
|
+
const key = secretKey(address, slot);
|
|
120
|
+
const name = process.env[key];
|
|
121
|
+
if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
|
|
122
|
+
const value = process.env[name];
|
|
123
|
+
if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
124
|
+
values[slot] = value;
|
|
125
|
+
}
|
|
126
|
+
return values;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* run()'s setup step for secrets: re-emit each slot's pointer NAME under its
|
|
130
|
+
* address-free key, so the address-free `deserializeSecrets` double-looks-up
|
|
131
|
+
* identically. Never the value — the value stays only in the platform var.
|
|
132
|
+
*/
|
|
133
|
+
const stashSecrets = (node, address) => {
|
|
134
|
+
for (const slot of Object.keys(node.secretSlots)) {
|
|
135
|
+
const name = process.env[secretKey(address, slot)];
|
|
136
|
+
if (name === void 0) continue;
|
|
137
|
+
process.env[secretKey("", slot)] = name;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
141
|
+
function standardValidateSync(schema, value) {
|
|
142
|
+
const result = schema["~standard"].validate(value);
|
|
143
|
+
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
144
|
+
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
145
|
+
return result.value;
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/index.mjs
|
|
149
|
+
const reservedParams = { port: number({ default: 3e3 }) };
|
|
150
|
+
/**
|
|
151
|
+
* A Prisma Compute service — declarations only (deps + params + build + the
|
|
152
|
+
* ports it exposes), no descriptor. `params` merges with the reserved
|
|
153
|
+
* `ReservedParams` (`port`); a user param whose name collides with a reserved
|
|
154
|
+
* one fails at authoring, the same way a colliding dependency name does.
|
|
155
|
+
* Returns the extension's runnable/loadable node:
|
|
156
|
+
* · run(address, boot) — the process controller: deserialize the platform
|
|
157
|
+
* environment (keyed off `address`, the extension's ONE env read) into a
|
|
158
|
+
* typed Config, re-emit it under address-free process-local stash keys,
|
|
159
|
+
* then call boot() to start the app's entry.
|
|
160
|
+
* · load() / config() — called from inside the app's entry: read the stash;
|
|
161
|
+
* load() hydrates + memoizes the deps, config() returns the typed params.
|
|
162
|
+
* Separate accessors so a dep and a param never share a namespace (ADR-0021).
|
|
163
|
+
*
|
|
164
|
+
* `service()`'s underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
|
|
165
|
+
* the control-plane registry key `prisma-composer deploy` resolves through the
|
|
166
|
+
* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
|
|
167
|
+
* deploy time; nodes are pure data.
|
|
168
|
+
*/
|
|
169
|
+
const compute = (def) => {
|
|
170
|
+
const userParams = def.params ?? blindCast({});
|
|
171
|
+
for (const reserved of Object.keys(reservedParams)) {
|
|
172
|
+
if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
|
|
173
|
+
if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
|
|
174
|
+
}
|
|
175
|
+
const params = blindCast({
|
|
176
|
+
...userParams,
|
|
177
|
+
...reservedParams
|
|
178
|
+
});
|
|
179
|
+
const node = service({
|
|
180
|
+
name: def.name,
|
|
181
|
+
extension: "@prisma/composer-prisma-cloud",
|
|
182
|
+
type: "compute",
|
|
183
|
+
inputs: def.deps,
|
|
184
|
+
params,
|
|
185
|
+
...def.secrets !== void 0 ? { secrets: def.secrets } : {},
|
|
186
|
+
build: def.build,
|
|
187
|
+
...def.expose !== void 0 ? { expose: def.expose } : {}
|
|
188
|
+
});
|
|
189
|
+
let resolved;
|
|
190
|
+
let loadedDeps;
|
|
191
|
+
let loadedParams;
|
|
192
|
+
let loadedSecrets;
|
|
193
|
+
function processConfig() {
|
|
194
|
+
if (resolved === void 0) resolved = deserialize(node, "");
|
|
195
|
+
return resolved;
|
|
196
|
+
}
|
|
197
|
+
const runnable = {
|
|
198
|
+
...node,
|
|
199
|
+
async run(address, boot) {
|
|
200
|
+
const config = deserialize(node, address);
|
|
201
|
+
stash(node, config);
|
|
202
|
+
stashSecrets(node, address);
|
|
203
|
+
const port = config.service["port"];
|
|
204
|
+
if (typeof port === "number") process.env["PORT"] = String(port);
|
|
205
|
+
return boot();
|
|
206
|
+
},
|
|
207
|
+
load() {
|
|
208
|
+
if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
|
|
209
|
+
return loadedDeps;
|
|
210
|
+
},
|
|
211
|
+
config() {
|
|
212
|
+
if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
|
|
213
|
+
return loadedParams;
|
|
214
|
+
},
|
|
215
|
+
secrets() {
|
|
216
|
+
if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
|
|
217
|
+
return loadedSecrets;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
return Object.freeze(blindCast(runnable));
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* The contract a Postgres provides — and the contract its consumers require.
|
|
224
|
+
* `satisfies` compares KIND, not identity: an extension module can be duplicated
|
|
225
|
+
* across a workspace (same rationale as the Symbol.for node brand), and every
|
|
226
|
+
* duplicate's contract must still satisfy. `__cmp` is the connection config a
|
|
227
|
+
* postgres offers; core never inspects it.
|
|
228
|
+
*/
|
|
229
|
+
const postgresContract = Object.freeze({
|
|
230
|
+
kind: "postgres",
|
|
231
|
+
__cmp: { url: "" },
|
|
232
|
+
satisfies: (required) => required.kind === "postgres"
|
|
233
|
+
});
|
|
234
|
+
function postgres(opts) {
|
|
235
|
+
if (opts?.name !== void 0) return resource({
|
|
236
|
+
name: opts.name,
|
|
237
|
+
extension: "@prisma/composer-prisma-cloud",
|
|
238
|
+
provides: postgresContract
|
|
239
|
+
});
|
|
240
|
+
return dependency({
|
|
241
|
+
type: "postgres",
|
|
242
|
+
connection: {
|
|
243
|
+
params: { url: string() },
|
|
244
|
+
hydrate: (v) => v
|
|
245
|
+
},
|
|
246
|
+
required: postgresContract
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The contract the `s3-credentials` resource provides — a minted SigV4 key
|
|
251
|
+
* pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is
|
|
252
|
+
* the config the resource offers, which core never inspects.
|
|
253
|
+
*/
|
|
254
|
+
const credentialsContract = Object.freeze({
|
|
255
|
+
kind: "credentials",
|
|
256
|
+
__cmp: {
|
|
257
|
+
accessKeyId: "",
|
|
258
|
+
secretAccessKey: ""
|
|
259
|
+
},
|
|
260
|
+
satisfies: (required) => required.kind === "credentials"
|
|
261
|
+
});
|
|
262
|
+
function s3Credentials(opts) {
|
|
263
|
+
if (opts?.name !== void 0) return resource({
|
|
264
|
+
name: opts.name,
|
|
265
|
+
extension: "@prisma/composer-prisma-cloud",
|
|
266
|
+
provides: credentialsContract
|
|
267
|
+
});
|
|
268
|
+
return dependency({
|
|
269
|
+
type: "credentials",
|
|
270
|
+
connection: {
|
|
271
|
+
params: {
|
|
272
|
+
accessKeyId: string(),
|
|
273
|
+
secretAccessKey: string()
|
|
274
|
+
},
|
|
275
|
+
hydrate: (v) => v
|
|
276
|
+
},
|
|
277
|
+
required: credentialsContract
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The storage service authoring factory — a `compute` service routed to the
|
|
282
|
+
* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s
|
|
283
|
+
* runnable (run/load/config, deps, params, build, expose) with the routing
|
|
284
|
+
* `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the
|
|
285
|
+
* serializer keys off the deployment address and each param's owner/name, and
|
|
286
|
+
* `load`/`config` off deps/params), so only the deploy-time descriptor lookup
|
|
287
|
+
* sees the override and routes to the extended-output lowering (§ 5). The
|
|
288
|
+
* return type is compute's exactly (including the reserved `port` param). The
|
|
289
|
+
* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
|
|
290
|
+
* param, and `expose: { store: s3Contract }`.
|
|
291
|
+
*/
|
|
292
|
+
function s3StoreService(def) {
|
|
293
|
+
const node = compute(def);
|
|
294
|
+
return Object.freeze(blindCast({
|
|
295
|
+
...node,
|
|
296
|
+
type: "s3-store"
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region ../../1-prisma-cloud/2-shared-modules/storage/dist/storage-service-DSaZsAC4.mjs
|
|
301
|
+
const s3Contract = Object.freeze({
|
|
302
|
+
kind: "s3",
|
|
303
|
+
__cmp: {
|
|
304
|
+
url: "",
|
|
305
|
+
bucket: "",
|
|
306
|
+
accessKeyId: "",
|
|
307
|
+
secretAccessKey: ""
|
|
308
|
+
},
|
|
309
|
+
satisfies: (required) => required.kind === "s3"
|
|
310
|
+
});
|
|
311
|
+
/**
|
|
312
|
+
* The storage service node (like cron's `scheduler.ts` + `scheduler-service.ts`
|
|
313
|
+
* combined): `storageService` builds the `s3-store` service — a Postgres `db`
|
|
314
|
+
* dependency, a minted `credentials` dependency, a `bucket` param, and the
|
|
315
|
+
* `store` port exposing `s3Contract`. The deploy bootstrap runs the
|
|
316
|
+
* default-exported bare node (`main.run(address, boot)`); the real bucket comes
|
|
317
|
+
* from serialized config at runtime, so the default's `bucket` is only a
|
|
318
|
+
* placeholder — exactly like `scheduler-service.ts` default-exports
|
|
319
|
+
* `cronScheduler({ jobs: [] })`.
|
|
320
|
+
*/
|
|
321
|
+
function storageService(opts) {
|
|
322
|
+
return s3StoreService({
|
|
323
|
+
name: "storage",
|
|
324
|
+
deps: {
|
|
325
|
+
db: postgres(),
|
|
326
|
+
credentials: s3Credentials()
|
|
327
|
+
},
|
|
328
|
+
params: { bucket: string({ default: opts.bucket }) },
|
|
329
|
+
build: node({
|
|
330
|
+
module: new URL("./storage-service.mjs", import.meta.url).href,
|
|
331
|
+
entry: "./storage-entrypoint.mjs"
|
|
332
|
+
}),
|
|
333
|
+
expose: { store: s3Contract }
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
var storage_service_default = storageService({ bucket: "storage" });
|
|
337
|
+
//#endregion
|
|
338
|
+
export { storage_service_default as default, storageService };
|
|
339
|
+
|
|
340
|
+
//# sourceMappingURL=storage-service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-service.mjs","names":[],"sources":["../../../../1-prisma-cloud/1-extensions/target/dist/serializer-C2CsA7xm.mjs","../../../../1-prisma-cloud/1-extensions/target/dist/index.mjs","../../../../1-prisma-cloud/2-shared-modules/storage/dist/storage-service-DSaZsAC4.mjs"],"sourcesContent":["import { secretSource } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\n//#region src/secret.ts\n/**\n* Brands the payload `envSecret` builds. Core's `secretSource()` is a public\n* SPI, so a user could bypass `envSecret` and bind a raw `secretSource('x')`;\n* the brand lets `secretName` reject such a source (or another target's) with a\n* clear error instead of reading an absent `.name`.\n*/\nconst PRISMA_CLOUD_SECRET_SOURCE = blindCast(Symbol.for(\"prisma:prisma-cloud-secret-source\"));\nconst RESERVED_SECRET_PREFIX = \"COMPOSE_\";\nconst POISONED_SECRET_NAMES = /* @__PURE__ */ new Set([\"DATABASE_URL\", \"DATABASE_URL_POOLED\"]);\n/**\n* Binds a secret slot to a named Prisma Cloud platform env var (ADR-0029). The\n* value is provisioned out-of-band; only the name is carried. The name may not\n* use the framework's reserved `COMPOSE_` prefix or the poisoned\n* `DATABASE_URL(_POOLED)` keys.\n*/\nfunction envSecret(name) {\n\tif (typeof name !== \"string\" || name.length === 0) throw new Error(\"envSecret() requires a non-empty platform env-var name, e.g. envSecret('STRIPE_SECRET_KEY').\");\n\tif (name.startsWith(RESERVED_SECRET_PREFIX)) throw new Error(`envSecret name \"${name}\" may not start with \"${RESERVED_SECRET_PREFIX}\" — that prefix is reserved for the framework's own generated config keys.`);\n\tif (POISONED_SECRET_NAMES.has(name)) throw new Error(`envSecret name \"${name}\" is reserved — ${[...POISONED_SECRET_NAMES].join(\" and \")} are poisoned at project provision and cannot back a secret.`);\n\treturn secretSource({\n\t\t[PRISMA_CLOUD_SECRET_SOURCE]: true,\n\t\tname\n\t});\n}\n/** True only for a payload that `envSecret` built — i.e. one carrying the brand. */\nfunction isEnvSecretPayload(payload) {\n\treturn typeof payload === \"object\" && payload !== null && blindCast(payload)[PRISMA_CLOUD_SECRET_SOURCE] === true;\n}\n/**\n* Reads the Prisma Cloud env-var name back out of a secret binding's opaque\n* source. A source not built by `envSecret` (a raw `secretSource(...)` or\n* another target's source) carries no name — reject it here. `secretName` runs\n* in preflight before any provisioning, so a foreign source fails early and\n* clearly rather than producing a broken deploy with an undefined name.\n*/\nfunction secretName(binding) {\n\tconst payload = binding.source.payload;\n\tif (!isEnvSecretPayload(payload)) throw new Error(`secret slot \"${binding.slot}\" of service \"${binding.serviceAddress}\" is bound to a source not created by envSecret() — bind secrets with envSecret('NAME') from @prisma/composer-prisma-cloud.`);\n\treturn payload.name;\n}\n//#endregion\n//#region src/serializer.ts\n/**\n* Walks a node's own params, then each dependency input's connection params —\n* the same enumeration order `configOf` uses, but carrying the raw\n* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data\n* projection.\n*/\nfunction paramEntries(node) {\n\tconst entries = [];\n\tfor (const [input, value] of Object.entries(node.inputs)) {\n\t\tif (typeof value !== \"object\" || value === null) continue;\n\t\tconst params = blindCast(value).connection.params;\n\t\tfor (const [name, param] of Object.entries(params)) entries.push({\n\t\t\towner: { input },\n\t\t\tname,\n\t\t\tparam\n\t\t});\n\t}\n\tfor (const [name, param] of Object.entries(node.params)) entries.push({\n\t\towner: \"service\",\n\t\tname,\n\t\tparam\n\t});\n\treturn entries;\n}\nconst configKey = (address, d) => {\n\tconst segments = address.split(\".\").filter((s) => s.length > 0);\n\tconst owner = d.owner === \"service\" ? [] : [d.owner.input];\n\treturn [\n\t\t\"COMPOSE\",\n\t\t...segments,\n\t\t...owner,\n\t\td.name\n\t].join(\"_\").toUpperCase();\n};\n/**\n* Typed value → its stored string. Service-own literals are JSON-encoded; a\n* dependency-input value is a provisioning ref at deploy (and a resolved\n* string at boot) and passes through untouched — LANDMINE: JSON-encoding it\n* would break the ordering edge Alchemy resolves through it.\n*/\nfunction encode(owner, value) {\n\treturn owner === \"service\" ? JSON.stringify(value) : blindCast(value);\n}\n/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */\nfunction decode(owner, raw) {\n\treturn owner === \"service\" ? JSON.parse(raw) : raw;\n}\nfunction coerce(raw, d, key) {\n\tif (!(raw !== void 0 && raw !== \"\")) {\n\t\tif (d.param.default !== void 0) return d.param.default;\n\t\tif (d.param.optional === true) return void 0;\n\t\tthrow new Error(`missing required config param \"${d.name}\" (env ${key})`);\n\t}\n\ttry {\n\t\treturn standardValidateSync(d.param.schema, decode(d.owner, raw));\n\t} catch (cause) {\n\t\tconst message = cause instanceof Error ? cause.message : String(cause);\n\t\tthrow new Error(`invalid value for config param \"${d.name}\" (env ${key}): ${message}`);\n\t}\n}\n/**\n* Boot: read each declared param from env by its key, reverse the param's own\n* serialization (missing/invalid fails loudly), assemble the typed Config.\n* Secrets ride a separate channel (deserializeSecrets), not this one.\n*/\nconst deserialize = (node, address) => {\n\tconst service = {};\n\tconst inputs = {};\n\tfor (const d of paramEntries(node)) {\n\t\tconst key = configKey(address, d);\n\t\tconst value = coerce(process.env[key], d, key);\n\t\tif (d.owner === \"service\") service[d.name] = value;\n\t\telse {\n\t\t\tlet bucket = inputs[d.owner.input];\n\t\t\tif (bucket === void 0) {\n\t\t\t\tbucket = {};\n\t\t\t\tinputs[d.owner.input] = bucket;\n\t\t\t}\n\t\t\tbucket[d.name] = value;\n\t\t}\n\t}\n\treturn {\n\t\tservice,\n\t\tinputs\n\t};\n};\n/**\n* run()'s setup step: write the resolved config to the environment under\n* address-free keys (configKey(\"\", d) + each serialize suffix), which load()\n* reads back with no address. Uses env, not a module variable, because a\n* framework may fork worker processes that inherit env but not memory.\n* Writes only these keys; nothing else is touched.\n*/\nconst stash = (node, config) => {\n\tfor (const d of paramEntries(node)) {\n\t\tconst value = d.owner === \"service\" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];\n\t\tif (value === void 0) continue;\n\t\tprocess.env[configKey(\"\", d)] = encode(d.owner, value);\n\t}\n};\n/** The pointer-row key for a secret slot: COMPOSE_<addr>_<slot> (secrets are service-level). */\nconst secretKey = (address, slot) => configKey(address, {\n\towner: \"service\",\n\tname: slot\n});\n/**\n* Deploy: the pointer rows for a node's secret slots — each slot's key mapped to\n* the platform NAME the root bound it to (looked up in `graph.secrets`). Never a\n* value. A declared slot with no binding is a Load-invariant violation (Load\n* binds every slot), surfaced loudly here rather than written as a blank row.\n*/\nfunction secretPointerRows(node, address, bindings) {\n\tconst rows = [];\n\tfor (const slot of Object.keys(node.secretSlots)) {\n\t\tconst binding = bindings.find((b) => b.serviceAddress === address && b.slot === slot);\n\t\tif (binding === void 0) throw new Error(`secret slot \"${slot}\" of \"${address}\" has no bound platform name — Load should have bound it (ADR-0029).`);\n\t\trows.push({\n\t\t\tkey: secretKey(address, slot),\n\t\t\tname: secretName(binding)\n\t\t});\n\t}\n\treturn rows;\n}\n/**\n* Boot: resolve every secret slot to its value by double-lookup — read the\n* pointer key (the platform NAME), then read that platform var. A missing\n* pointer or a missing/empty platform value is a loud failure naming both keys.\n* Returns a plain Record for core's `hydrateSecrets` to box.\n*/\nconst deserializeSecrets = (node, address) => {\n\tconst values = {};\n\tfor (const slot of Object.keys(node.secretSlots)) {\n\t\tconst key = secretKey(address, slot);\n\t\tconst name = process.env[key];\n\t\tif (name === void 0 || name === \"\") throw new Error(`missing secret pointer for slot \"${slot}\" (env ${key}) — the deploy did not write it.`);\n\t\tconst value = process.env[name];\n\t\tif (value === void 0 || value === \"\") throw new Error(`secret \"${slot}\" is not provisioned (env ${key} → ${name}): the platform var \"${name}\" is unset or empty.`);\n\t\tvalues[slot] = value;\n\t}\n\treturn values;\n};\n/**\n* run()'s setup step for secrets: re-emit each slot's pointer NAME under its\n* address-free key, so the address-free `deserializeSecrets` double-looks-up\n* identically. Never the value — the value stays only in the platform var.\n*/\nconst stashSecrets = (node, address) => {\n\tfor (const slot of Object.keys(node.secretSlots)) {\n\t\tconst name = process.env[secretKey(address, slot)];\n\t\tif (name === void 0) continue;\n\t\tprocess.env[secretKey(\"\", slot)] = name;\n\t}\n};\n/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */\nfunction standardValidateSync(schema, value) {\n\tconst result = schema[\"~standard\"].validate(value);\n\tif (result instanceof Promise) throw new Error(\"config param schema validation must be synchronous — async Standard Schema validators are not supported for config params\");\n\tif (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join(\"; \")}`);\n\treturn result.value;\n}\n//#endregion\nexport { paramEntries as a, stashSecrets as c, encode as i, envSecret as l, deserialize as n, secretPointerRows as o, deserializeSecrets as r, stash as s, configKey as t, secretName as u };\n\n//# sourceMappingURL=serializer-C2CsA7xm.mjs.map","import { c as stashSecrets, l as envSecret, n as deserialize, r as deserializeSecrets, s as stash, t as configKey, u as secretName } from \"./serializer-C2CsA7xm.mjs\";\nimport { dependency, hydrateSecrets, hydrateSync, number, resource, service, string } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\n//#region src/compute.ts\nconst reservedParams = { port: number({ default: 3e3 }) };\n/**\n* A Prisma Compute service — declarations only (deps + params + build + the\n* ports it exposes), no descriptor. `params` merges with the reserved\n* `ReservedParams` (`port`); a user param whose name collides with a reserved\n* one fails at authoring, the same way a colliding dependency name does.\n* Returns the extension's runnable/loadable node:\n* · run(address, boot) — the process controller: deserialize the platform\n* environment (keyed off `address`, the extension's ONE env read) into a\n* typed Config, re-emit it under address-free process-local stash keys,\n* then call boot() to start the app's entry.\n* · load() / config() — called from inside the app's entry: read the stash;\n* load() hydrates + memoizes the deps, config() returns the typed params.\n* Separate accessors so a dep and a param never share a namespace (ADR-0021).\n*\n* `service()`'s underlying node carries `extension: '@prisma/composer-prisma-cloud'` —\n* the control-plane registry key `prisma-composer deploy` resolves through the\n* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at\n* deploy time; nodes are pure data.\n*/\nconst compute = (def) => {\n\tconst userParams = def.params ?? blindCast({});\n\tfor (const reserved of Object.keys(reservedParams)) {\n\t\tif (reserved in def.deps) throw new Error(`compute(): dependency \"${reserved}\" collides with the reserved service param of the same name — rename the dependency.`);\n\t\tif (reserved in userParams) throw new Error(`compute(): param \"${reserved}\" collides with the reserved service param of the same name — rename the param.`);\n\t}\n\tconst params = blindCast({\n\t\t...userParams,\n\t\t...reservedParams\n\t});\n\tconst node = service({\n\t\tname: def.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\ttype: \"compute\",\n\t\tinputs: def.deps,\n\t\tparams,\n\t\t...def.secrets !== void 0 ? { secrets: def.secrets } : {},\n\t\tbuild: def.build,\n\t\t...def.expose !== void 0 ? { expose: def.expose } : {}\n\t});\n\tlet resolved;\n\tlet loadedDeps;\n\tlet loadedParams;\n\tlet loadedSecrets;\n\tfunction processConfig() {\n\t\tif (resolved === void 0) resolved = deserialize(node, \"\");\n\t\treturn resolved;\n\t}\n\tconst runnable = {\n\t\t...node,\n\t\tasync run(address, boot) {\n\t\t\tconst config = deserialize(node, address);\n\t\t\tstash(node, config);\n\t\t\tstashSecrets(node, address);\n\t\t\tconst port = config.service[\"port\"];\n\t\t\tif (typeof port === \"number\") process.env[\"PORT\"] = String(port);\n\t\t\treturn boot();\n\t\t},\n\t\tload() {\n\t\t\tif (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));\n\t\t\treturn loadedDeps;\n\t\t},\n\t\tconfig() {\n\t\t\tif (loadedParams === void 0) loadedParams = blindCast(processConfig().service);\n\t\t\treturn loadedParams;\n\t\t},\n\t\tsecrets() {\n\t\t\tif (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, \"\")));\n\t\t\treturn loadedSecrets;\n\t\t}\n\t};\n\treturn Object.freeze(blindCast(runnable));\n};\n//#endregion\n//#region src/http.ts\nconst defaultHttpClient = (cfg) => ({\n\turl: cfg.url,\n\tfetch: (path, init) => fetch(new URL(path, cfg.url), init)\n});\n/**\n* A service-to-service dependency. Its binding (what `load()` returns) is a\n* derived HttpClient — a thin URL-anchored fetch wrapper (fetch is standard\n* across runtimes — no driver, no runtime coupling). http() is a\n* protocol-owned kind: the framework owns the transport, so the client is\n* kind-canonical and derived from the contract, with no user client in the\n* declaration (ADR-0015). The typed generated client arrives with the\n* interface primitive (a later extension point).\n*/\nconst http = (opts) => dependency({\n\tname: opts.name,\n\ttype: \"http\",\n\tconnection: {\n\t\tparams: { url: string() },\n\t\thydrate: (v) => defaultHttpClient({ url: v.url })\n\t}\n});\n//#endregion\n//#region src/postgres.ts\n/**\n* The contract a Postgres provides — and the contract its consumers require.\n* `satisfies` compares KIND, not identity: an extension module can be duplicated\n* across a workspace (same rationale as the Symbol.for node brand), and every\n* duplicate's contract must still satisfy. `__cmp` is the connection config a\n* postgres offers; core never inspects it.\n*/\nconst postgresContract = Object.freeze({\n\tkind: \"postgres\",\n\t__cmp: { url: \"\" },\n\tsatisfies: (required) => required.kind === \"postgres\"\n});\nfunction postgres(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: postgresContract\n\t});\n\treturn dependency({\n\t\ttype: \"postgres\",\n\t\tconnection: {\n\t\t\tparams: { url: string() },\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: postgresContract\n\t});\n}\n//#endregion\n//#region src/s3-credentials.ts\n/**\n* The contract the `s3-credentials` resource provides — a minted SigV4 key\n* pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is\n* the config the resource offers, which core never inspects.\n*/\nconst credentialsContract = Object.freeze({\n\tkind: \"credentials\",\n\t__cmp: {\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"credentials\"\n});\nfunction s3Credentials(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: credentialsContract\n\t});\n\treturn dependency({\n\t\ttype: \"credentials\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\taccessKeyId: string(),\n\t\t\t\tsecretAccessKey: string()\n\t\t\t},\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: credentialsContract\n\t});\n}\n//#endregion\n//#region src/s3-store.ts\n/**\n* The storage service authoring factory — a `compute` service routed to the\n* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s\n* runnable (run/load/config, deps, params, build, expose) with the routing\n* `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the\n* serializer keys off the deployment address and each param's owner/name, and\n* `load`/`config` off deps/params), so only the deploy-time descriptor lookup\n* sees the override and routes to the extended-output lowering (§ 5). The\n* return type is compute's exactly (including the reserved `port` param). The\n* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`\n* param, and `expose: { store: s3Contract }`.\n*/\nfunction s3StoreService(def) {\n\tconst node = compute(def);\n\treturn Object.freeze(blindCast({\n\t\t...node,\n\t\ttype: \"s3-store\"\n\t}));\n}\n//#endregion\nexport { compute, configKey, credentialsContract, envSecret, http, postgres, postgresContract, s3Credentials, s3StoreService, secretName };\n\n//# sourceMappingURL=index.mjs.map","import { dependency, string } from \"@internal/core\";\nimport { postgres, s3Credentials, s3StoreService } from \"@internal/prisma-cloud\";\nimport node from \"@internal/node\";\n//#region src/contract.ts\nconst s3Contract = Object.freeze({\n\tkind: \"s3\",\n\t__cmp: {\n\t\turl: \"\",\n\t\tbucket: \"\",\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"s3\"\n});\n/**\n* A consumer's dependency on an S3-compatible store. No `region` in the\n* binding — the server accepts whatever region string the client signed.\n*/\nfunction s3() {\n\treturn dependency({\n\t\ttype: \"s3\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\turl: string(),\n\t\t\t\tbucket: string(),\n\t\t\t\taccessKeyId: string(),\n\t\t\t\tsecretAccessKey: string()\n\t\t\t},\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: s3Contract\n\t});\n}\n//#endregion\n//#region src/storage-service.ts\n/**\n* The storage service node (like cron's `scheduler.ts` + `scheduler-service.ts`\n* combined): `storageService` builds the `s3-store` service — a Postgres `db`\n* dependency, a minted `credentials` dependency, a `bucket` param, and the\n* `store` port exposing `s3Contract`. The deploy bootstrap runs the\n* default-exported bare node (`main.run(address, boot)`); the real bucket comes\n* from serialized config at runtime, so the default's `bucket` is only a\n* placeholder — exactly like `scheduler-service.ts` default-exports\n* `cronScheduler({ jobs: [] })`.\n*/\nfunction storageService(opts) {\n\treturn s3StoreService({\n\t\tname: \"storage\",\n\t\tdeps: {\n\t\t\tdb: postgres(),\n\t\t\tcredentials: s3Credentials()\n\t\t},\n\t\tparams: { bucket: string({ default: opts.bucket }) },\n\t\tbuild: node({\n\t\t\tmodule: new URL(\"./storage-service.mjs\", import.meta.url).href,\n\t\t\tentry: \"./storage-entrypoint.mjs\"\n\t\t}),\n\t\texpose: { store: s3Contract }\n\t});\n}\nvar storage_service_default = storageService({ bucket: \"storage\" });\n//#endregion\nexport { s3Contract as i, storage_service_default as n, s3 as r, storageService as t };\n\n//# sourceMappingURL=storage-service-DSaZsAC4.mjs.map"],"mappings":";;;AASmC,UAAU,OAAO,IAAI,mCAAmC,CAAC;;;;;;;AA0C5F,SAAS,aAAa,MAAM;CAC3B,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,MAAM,GAAG;EACzD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EACjD,MAAM,SAAS,UAAU,KAAK,CAAC,CAAC,WAAW;EAC3C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,MAAM,GAAG,QAAQ,KAAK;GAChE,OAAO,EAAE,MAAM;GACf;GACA;EACD,CAAC;CACF;CACA,KAAK,MAAM,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KAAK,GAAG,OAAO,SAAS;EAC1C,MAAM,KAAK;EACX,WAAW;EACX,UAAU;CACX,CAAC;CACD,OAAO,WAAW;EACjB,MAAM;EACN,YAAY;GACX,QAAQ;IACP,aAAa,OAAO;IACpB,iBAAiB,OAAO;GACzB;GACA,UAAU,MAAM;EACjB;EACA,UAAU;CACX,CAAC;AACF;;;;;;;;;;;;;AAeA,SAAS,eAAe,KAAK;CAC5B,MAAM,OAAO,QAAQ,GAAG;CACxB,OAAO,OAAO,OAAO,UAAU;EAC9B,GAAG;EACH,MAAM;CACP,CAAC,CAAC;AACH;;;AClLA,MAAM,aAAa,OAAO,OAAO;CAChC,MAAM;CACN,OAAO;EACN,KAAK;EACL,QAAQ;EACR,aAAa;EACb,iBAAiB;CAClB;CACA,YAAY,aAAa,SAAS,SAAS;AAC5C,CAAC;;;;;;;;;;;AAgCD,SAAS,eAAe,MAAM;CAC7B,OAAO,eAAe;EACrB,MAAM;EACN,MAAM;GACL,IAAI,SAAS;GACb,aAAa,cAAc;EAC5B;EACA,QAAQ,EAAE,QAAQ,OAAO,EAAE,SAAS,KAAK,OAAO,CAAC,EAAE;EACnD,OAAO,KAAK;GACX,QAAQ,IAAI,IAAI,yBAAyB,OAAO,KAAK,GAAG,CAAC,CAAC;GAC1D,OAAO;EACR,CAAC;EACD,QAAQ,EAAE,OAAO,WAAW;CAC7B,CAAC;AACF;AACA,IAAI,0BAA0B,eAAe,EAAE,QAAQ,UAAU,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//#region ../../1-prisma-cloud/2-shared-modules/storage/dist/testing.d.mts
|
|
2
|
+
//#region src/store.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The minimal object store the protocol handler drives — the seam between the
|
|
5
|
+
* wire protocol (D2) and its backing (the Postgres bytea store, D3). Buckets
|
|
6
|
+
* are namespaces: any bucket name is accepted and simply scopes keys. The
|
|
7
|
+
* store owns the ETag (quoted SHA-256 hex of the object bytes).
|
|
8
|
+
*/
|
|
9
|
+
interface PutResult {
|
|
10
|
+
readonly etag: string;
|
|
11
|
+
}
|
|
12
|
+
interface GetRange {
|
|
13
|
+
readonly start: number;
|
|
14
|
+
/** Inclusive end; omitted means "to the end of the object". */
|
|
15
|
+
readonly end?: number;
|
|
16
|
+
}
|
|
17
|
+
interface GetResult {
|
|
18
|
+
/** The requested slice — the whole object when no range was given. */
|
|
19
|
+
readonly bytes: Uint8Array;
|
|
20
|
+
readonly etag: string;
|
|
21
|
+
readonly contentType: string;
|
|
22
|
+
/** TOTAL object size, for `Content-Range` — not the slice length. */
|
|
23
|
+
readonly size: number;
|
|
24
|
+
}
|
|
25
|
+
interface HeadResult {
|
|
26
|
+
readonly etag: string;
|
|
27
|
+
readonly size: number;
|
|
28
|
+
readonly contentType: string;
|
|
29
|
+
}
|
|
30
|
+
interface ListOptions {
|
|
31
|
+
readonly prefix?: string;
|
|
32
|
+
readonly continuationToken?: string;
|
|
33
|
+
readonly maxKeys?: number;
|
|
34
|
+
}
|
|
35
|
+
interface ListResult {
|
|
36
|
+
readonly keys: readonly string[];
|
|
37
|
+
readonly nextContinuationToken?: string;
|
|
38
|
+
readonly isTruncated: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface ObjectStore {
|
|
41
|
+
put(bucket: string, key: string, bytes: Uint8Array, opts?: {
|
|
42
|
+
contentType?: string;
|
|
43
|
+
}): Promise<PutResult>;
|
|
44
|
+
/** `null` when the key is missing. */
|
|
45
|
+
get(bucket: string, key: string, opts?: {
|
|
46
|
+
range?: GetRange;
|
|
47
|
+
}): Promise<GetResult | null>;
|
|
48
|
+
/** `null` when the key is missing. */
|
|
49
|
+
head(bucket: string, key: string): Promise<HeadResult | null>;
|
|
50
|
+
/** Idempotent — deleting a missing key is not an error. */
|
|
51
|
+
delete(bucket: string, key: string): Promise<void>;
|
|
52
|
+
list(bucket: string, opts?: ListOptions): Promise<ListResult>;
|
|
53
|
+
} //#endregion
|
|
54
|
+
//#region src/pg-store.d.ts
|
|
55
|
+
/**
|
|
56
|
+
* Connect (FT-5219 posture: `max: 1`, short `idleTimeout`), apply the schema
|
|
57
|
+
* idempotently behind the cold-start retry, and return the store.
|
|
58
|
+
*/
|
|
59
|
+
declare function createPgStore(url: string): Promise<ObjectStore>; //#endregion
|
|
60
|
+
//#region src/sigv4.d.ts
|
|
61
|
+
interface Credentials {
|
|
62
|
+
readonly accessKeyId: string;
|
|
63
|
+
readonly secretAccessKey: string;
|
|
64
|
+
} //#endregion
|
|
65
|
+
//#region src/storage-server.d.ts
|
|
66
|
+
interface StorageServer {
|
|
67
|
+
/** The externally reachable base URL of the running server. */
|
|
68
|
+
readonly url: string;
|
|
69
|
+
stop(): void;
|
|
70
|
+
}
|
|
71
|
+
interface StorageServerOptions {
|
|
72
|
+
readonly store: ObjectStore;
|
|
73
|
+
readonly credentials: Credentials;
|
|
74
|
+
/** The module's canonical bucket — surfaced to consumers; the wire namespaces by the path bucket. */
|
|
75
|
+
readonly bucket: string;
|
|
76
|
+
readonly port: number;
|
|
77
|
+
readonly hostname?: string;
|
|
78
|
+
}
|
|
79
|
+
declare function startStorageServer(opts: StorageServerOptions): StorageServer; //#endregion
|
|
80
|
+
//#endregion
|
|
81
|
+
export { type StorageServer, type StorageServerOptions, createPgStore, startStorageServer };
|
|
82
|
+
//# sourceMappingURL=testing.d.mts.map
|