cloudrop 0.0.0 → 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/CHANGELOG.md +56 -0
- package/LICENSE +21 -0
- package/README.md +98 -3
- package/dist/adapters/drizzle.d.ts +204 -0
- package/dist/adapters/drizzle.js +216 -0
- package/dist/adapters/drizzle.js.map +1 -0
- package/dist/adapters/prisma.d.ts +81 -0
- package/dist/adapters/prisma.js +32 -0
- package/dist/adapters/prisma.js.map +1 -0
- package/dist/adapters/sql.d.ts +98 -0
- package/dist/adapters/sql.js +70 -0
- package/dist/adapters/sql.js.map +1 -0
- package/dist/client-Dj6ON4MN.d.ts +214 -0
- package/dist/client-Y1zUEbCj.js +1561 -0
- package/dist/client-Y1zUEbCj.js.map +1 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.js +3 -0
- package/dist/d1-BY2c5bcL.js +16 -0
- package/dist/d1-BY2c5bcL.js.map +1 -0
- package/dist/errors-CUxMmFAe.js +40 -0
- package/dist/errors-CUxMmFAe.js.map +1 -0
- package/dist/executor-CEA7WV2W.d.ts +27 -0
- package/dist/index.d.ts +421 -0
- package/dist/index.js +3007 -0
- package/dist/index.js.map +1 -0
- package/dist/input-DTC476_I.js +13 -0
- package/dist/input-DTC476_I.js.map +1 -0
- package/dist/next.d.ts +9 -0
- package/dist/next.js +14 -0
- package/dist/next.js.map +1 -0
- package/dist/node.d.ts +32 -0
- package/dist/node.js +100 -0
- package/dist/node.js.map +1 -0
- package/dist/part-size-CvMoobfC.js +9 -0
- package/dist/part-size-CvMoobfC.js.map +1 -0
- package/dist/react.d.ts +123 -0
- package/dist/react.js +355 -0
- package/dist/react.js.map +1 -0
- package/dist/route-CspI1Ypt.js +72 -0
- package/dist/route-CspI1Ypt.js.map +1 -0
- package/dist/store-BfCJejGh.d.ts +382 -0
- package/dist/tables-DZnw2sPK.d.ts +11 -0
- package/dist/transactional-DnvnGsVH.js +672 -0
- package/dist/transactional-DnvnGsVH.js.map +1 -0
- package/dist/types-BZUOaz_B.js +5 -0
- package/dist/types-BZUOaz_B.js.map +1 -0
- package/dist/types-BrAx3dA4.d.ts +185 -0
- package/package.json +108 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactional-DnvnGsVH.js","names":["INSERT_COLUMNS"],"sources":["../src/store/sql/executor.ts","../src/store/sql/bind.ts","../src/store/sql/records.ts","../src/store/sql/outcomes.ts","../src/store/sql/postgres.ts","../src/store/sql/reads.ts","../src/store/sql/sqlite.ts","../src/store/sql/tables.ts","../src/store/sql/store.ts","../src/adapters/transactional.ts"],"sourcesContent":["// The seam between the SQL core and a database driver (spec M5 §7, M5-T11). An executor runs SQL text with positional\n// parameters and hands rows back as plain objects; the core builds every statement and decodes every value, so an\n// executor is a few lines over its driver (`cloudrop/adapters/sql` ships four).\n\n/** One row as the driver returns it, keyed by column name. */\nexport type SqlRow = Record<string, unknown>;\n\n/** One statement with its parameters: `$1::type` placeholders on Postgres, `?` on SQLite. */\nexport interface SqlStatement {\n sql: string;\n params: readonly unknown[];\n}\n\nexport type SqlDialect = \"postgres\" | \"sqlite\";\n\n/** What the store needs from a database. `TTx` is the handle `onComplete` receives as `tx` in transaction mode. */\nexport interface SqlExecutor<TTx = never> {\n dialect: SqlDialect;\n /** Runs one statement and answers its rows (none for a write without `RETURNING`). */\n query(sql: string, params: readonly unknown[]): Promise<SqlRow[]>;\n /**\n * Runs the statements in order and atomically: every one commits, or the batch throws and none does. It need not be\n * interactive (D1's `batch()` is enough). Answers each statement's rows, in order.\n */\n batch(statements: readonly SqlStatement[]): Promise<SqlRow[][]>;\n /**\n * Runs `run` in one interactive transaction, committing when it resolves and rolling back when it throws. Only\n * executors whose database can hold one (Postgres) have it; the store then offers `transaction` too.\n */\n transaction?<T>(run: (executor: Omit<SqlExecutor<TTx>, \"transaction\">, tx: TTx) => Promise<T>): Promise<T>;\n}\n\n/** An executor that can hold a transaction (node-postgres, postgres.js): its store gets `transaction` and `route`. */\nexport type TransactionalSqlExecutor<TTx> = SqlExecutor<TTx> & Required<Pick<SqlExecutor<TTx>, \"transaction\">>;\n\n/**\n * An executor whose `batch` runs its statements one after another through `query`: for a connection already inside\n * a transaction, where a failed statement aborts the transaction, so nothing of the batch can commit alone.\n */\nexport function sequential(dialect: SqlDialect, query: SqlExecutor[\"query\"]): Omit<SqlExecutor<never>, \"transaction\"> {\n return {\n dialect,\n query,\n async batch(statements) {\n const results: SqlRow[][] = [];\n for (const { sql, params } of statements) results.push(await query(sql, params));\n return results;\n },\n };\n}\n\n/** Runs one built statement. */\nexport function runStatement(\n executor: Pick<SqlExecutor<unknown>, \"query\">,\n statement: SqlStatement,\n): Promise<SqlRow[]> {\n return executor.query(statement.sql, statement.params);\n}\n\n/**\n * True when the error carries this Postgres SQLSTATE: node-postgres and postgres.js set it as `code`, and a wrapper\n * (Drizzle's query error) keeps the driver's error as `cause`, so the chain is followed a few levels.\n * Prisma 7 answers `P2010` and keeps its driver adapter's error under `meta.driverAdapterError`; that error's `cause`\n * holds the SQLSTATE as `originalCode`, and as `code` only for the errors the adapter does not name (measured, 7.10.1:\n * 55P03 has both, 23505 becomes kind \"UniqueConstraintViolation\" with `originalCode` alone).\n */\nfunction hasCode(error: unknown, sqlState: string): boolean {\n let current: unknown = error;\n for (let depth = 0; depth < 5 && typeof current === \"object\" && current !== null; depth++) {\n const { code, originalCode, cause, meta } = current as {\n code?: unknown;\n originalCode?: unknown;\n cause?: unknown;\n meta?: { driverAdapterError?: unknown };\n };\n if (code === sqlState || originalCode === sqlState) return true;\n current = cause ?? meta?.driverAdapterError;\n }\n return false;\n}\n\n/** Postgres's `lock_not_available`, raised when `lock_timeout` runs out. */\nexport const isLockTimeout = (error: unknown): boolean => hasCode(error, \"55P03\");\n\n/** Postgres's `unique_violation`. */\nexport const isUniqueViolation = (error: unknown): boolean => hasCode(error, \"23505\");\n","// Builds one statement's parameter list while its SQL is written, so placeholders and values cannot drift apart.\n// Postgres gets explicit casts on every placeholder: drivers that send typed parameters (Prisma sends a string as text)\n// would otherwise fail on `timestamptz = text`, and casts let one statement serve every driver. SQLite keeps times as\n// integer milliseconds, so no driver converts a Date its own way.\n\nimport type { SqlDialect, SqlStatement } from \"./executor.ts\";\n\nexport interface Binder {\n text(value: string | null): string;\n bigint(value: number | null): string;\n integer(value: number): string;\n time(value: Date | null): string;\n /** Postgres only: a JSON document read with `json_to_recordset`. */\n json(value: string): string;\n /** The statement with every value bound so far, in placeholder order. */\n statement(sql: string): SqlStatement;\n}\n\n/** A fresh parameter list. Template literals evaluate left to right, so `?` placeholders take values in order. */\nexport function binder(dialect: SqlDialect): Binder {\n const params: unknown[] = [];\n const bind = (value: unknown, type: string): string => {\n params.push(value);\n return dialect === \"postgres\" ? `$${params.length}::${type}` : \"?\";\n };\n return {\n text: (value) => bind(value, \"text\"),\n bigint: (value) => bind(value, \"bigint\"),\n integer: (value) => bind(value, \"integer\"),\n time: (value) =>\n dialect === \"postgres\"\n ? bind(value?.toISOString() ?? null, \"timestamptz\")\n : bind(value?.getTime() ?? null, \"bigint\"),\n // Bound as text, then cast: postgres.js JSON-encodes a string bound to a json parameter a second time.\n json: (value) => `${bind(value, \"text\")}::json`,\n statement: (sql) => ({ sql, params }),\n };\n}\n","// Turns driver rows into the store's types. Drivers disagree on numbers and times (spec review I9): node-postgres and\n// postgres.js return int8 and numeric sums as decimal text, Prisma returns BigInt and Decimal, node:sqlite and D1\n// return numbers; Postgres times arrive as Dates, SQLite times are the integer milliseconds the core wrote.\n\nimport type { FileRecord, FileStatus, OwnerUsage } from \"../../server/store.ts\";\nimport type { SqlRow } from \"./executor.ts\";\n\n/** Every column of the files table, in the order of spec §3. */\nexport const FILE_COLUMNS: readonly string[] = [\n \"id\",\n \"route\",\n \"key\",\n \"owner\",\n \"status\",\n \"name\",\n \"type\",\n \"size\",\n \"upload_id\",\n \"metadata\",\n \"result\",\n \"claim\",\n \"claimed_at\",\n \"expires_at\",\n \"created_at\",\n \"updated_at\",\n \"completed_at\",\n \"ended_at\",\n \"cleaned_at\",\n \"request_key\",\n];\n\n/** The files columns a `FileRecord` is read from: every column except `claim`, `updated_at` and `request_key`. */\nexport const RECORD_COLUMNS: string = FILE_COLUMNS.filter(\n (column) => column !== \"claim\" && column !== \"updated_at\" && column !== \"request_key\",\n).join(\", \");\n\nfunction describe(value: unknown): string {\n return typeof value === \"string\" ? JSON.stringify(value) : `${typeof value} ${String(value)}`;\n}\n\n/**\n * A whole number within 2^53 from a number, a decimal string, a bigint or a decimal-like object (Prisma's Decimal\n * prints as its digits). Throws on fractions and larger values rather than round: a byte count must stay exact.\n */\nexport function toSafeInteger(value: unknown, column: string): number {\n const digits = typeof value === \"bigint\" || (typeof value === \"object\" && value !== null) ? String(value) : value;\n const number = typeof digits === \"string\" && /^-?\\d+$/.test(digits) ? Number(digits) : digits;\n if (typeof number === \"number\" && Number.isSafeInteger(number)) return number;\n throw new Error(`The database returned ${describe(value)} for ${column}; expected a whole number up to 2^53.`);\n}\n\n/** A time from a Date, an ISO string or milliseconds since the epoch. */\nexport function toDate(value: unknown, column: string): Date {\n const ms =\n value instanceof Date\n ? value.getTime()\n : typeof value === \"string\" && !/^-?\\d+$/.test(value)\n ? Date.parse(value)\n : toSafeInteger(value, column);\n if (Number.isNaN(ms)) throw new Error(`The database returned ${describe(value)} for ${column}; expected a time.`);\n return new Date(ms);\n}\n\nconst text = (row: SqlRow, column: string): string => {\n const value = row[column];\n if (typeof value === \"string\") return value;\n throw new Error(`The database returned ${describe(value)} for ${column}; expected text.`);\n};\nconst optionalText = (row: SqlRow, column: string): string | null => (row[column] == null ? null : text(row, column));\nconst optionalDate = (row: SqlRow, column: string): Date | null =>\n row[column] == null ? null : toDate(row[column], column);\n\nexport function toRecord(row: SqlRow): FileRecord {\n return {\n id: text(row, \"id\"),\n route: text(row, \"route\"),\n key: text(row, \"key\"),\n name: text(row, \"name\"),\n type: text(row, \"type\"),\n size: toSafeInteger(row.size, \"size\"),\n metadata: optionalText(row, \"metadata\"),\n owner: optionalText(row, \"owner\"),\n // Only the store writes this column, always one of the FileStatus values.\n status: text(row, \"status\") as FileStatus,\n uploadId: optionalText(row, \"upload_id\"),\n result: optionalText(row, \"result\"),\n expiresAt: toDate(row.expires_at, \"expires_at\"),\n createdAt: toDate(row.created_at, \"created_at\"),\n claimedAt: optionalDate(row, \"claimed_at\"),\n completedAt: optionalDate(row, \"completed_at\"),\n endedAt: optionalDate(row, \"ended_at\"),\n cleanedAt: optionalDate(row, \"cleaned_at\"),\n };\n}\n\nexport function toUsage(row: SqlRow | undefined): OwnerUsage {\n if (!row) return { reservedBytes: 0, activeBytes: 0, files: 0 };\n return {\n reservedBytes: toSafeInteger(row.reserved_bytes, \"reserved_bytes\"),\n activeBytes: toSafeInteger(row.active_bytes, \"active_bytes\"),\n files: toSafeInteger(row.files, \"files\"),\n };\n}\n\n/** A `stale` cursor: the last row's time in milliseconds and its id, so the next page starts strictly after both. */\nexport function encodeCursor(time: Date, id: string): string {\n return `${time.getTime()}:${id}`;\n}\n\nexport function decodeCursor(cursor: string): { time: Date; id: string } {\n const match = /^(\\d+):(.*)$/s.exec(cursor);\n if (!match?.[1] || match[2] === undefined) {\n throw new Error(\"This sweep cursor was not made by the store. Start the sweep again with cursor null.\");\n }\n return { time: new Date(Number(match[1])), id: match[2] };\n}\n","// What both dialects share once their statements have run: reading a claim's outcome or a transition from the row, and\n// the usage change each status gives back when a row leaves it.\n\nimport type { ClaimOutcome, FileStatus, Transition } from \"../../server/store.ts\";\nimport type { SqlRow } from \"./executor.ts\";\nimport { toRecord } from \"./records.ts\";\n\n/** `row` is the file as the claim statement found it, read in the same unit. */\nexport function claimOutcome(claimed: boolean, row: SqlRow | undefined): ClaimOutcome {\n if (claimed) return { kind: \"claimed\" };\n if (!row) return { kind: \"missing\" };\n const record = toRecord(row);\n if (record.status === \"completed\") return { kind: \"completed\", record };\n // A pending row the update did not take was claimed by a concurrent call after this statement's snapshot: Postgres\n // re-reads a row it waited for before updating it, while the snapshot still shows the row as it was.\n if (record.status === \"pending\" || record.status === \"completing\") return { kind: \"busy\" };\n return { kind: \"ended\", record };\n}\n\nexport function transition(changed: boolean, row: SqlRow | undefined): Transition {\n if (changed && row) return { changed: true, record: toRecord(row) };\n return { changed: false, record: row ? toRecord(row) : null };\n}\n\n/**\n * The `SET` list that takes a row of `size` bytes off its owner's counters as it leaves `from`, or null when `from`\n * holds no bytes (an ended status), in which case the usage row is not written at all.\n */\nexport function releaseFrom(from: FileStatus, size: string): string | null {\n if (from === \"pending\" || from === \"completing\") return `reserved_bytes = reserved_bytes - ${size}`;\n if (from === \"completed\") return `active_bytes = active_bytes - ${size}, files = files - 1`;\n return null;\n}\n\n/** The columns reconcile recounts, as one aggregate over the owner's files rows. */\nexport const RECOUNT = {\n reserved: \"coalesce(sum(CASE WHEN status IN ('pending', 'completing') THEN size END), 0)\",\n active: \"coalesce(sum(CASE WHEN status = 'completed' THEN size END), 0)\",\n files: \"count(CASE WHEN status = 'completed' THEN 1 END)\",\n};\n","// The Postgres statements of the methods that write both tables or must decide in one step. Each is one statement:\n// data-modifying CTEs run with the statement, so the files change and its usage change commit together, and a guarded\n// UPDATE that waited for a row lock re-reads the row before it applies (READ COMMITTED), which is what makes a claim\n// exclusive. reconcile alone is a batch: the usage row made to exist and locked first, so the recount takes a snapshot\n// after it.\n\nimport type { FileStatus, NewFile } from \"../../server/store.ts\";\nimport { type Binder, binder } from \"./bind.ts\";\nimport { isUniqueViolation, runStatement } from \"./executor.ts\";\nimport { claimOutcome, RECOUNT, releaseFrom, transition } from \"./outcomes.ts\";\nimport type { SqlContext, StoreMethods } from \"./reads.ts\";\nimport { RECORD_COLUMNS, toSafeInteger } from \"./records.ts\";\n\ntype GuardedWrites = Pick<StoreMethods, \"reserve\" | \"claim\" | \"complete\" | \"end\" | \"revoke\" | \"reconcile\">;\n\nconst INPUT_COLUMNS = \"ord integer, id text, route text, key text, name text, type text, size bigint, metadata text\";\nconst INSERT_COLUMNS =\n \"id, route, key, owner, status, name, type, size, metadata, expires_at, created_at, updated_at, request_key\";\n\n/** The accepted files as one JSON parameter, numbered from 1 in the order the quota checks them. */\nconst inputJson = (files: readonly NewFile[]): string =>\n JSON.stringify(\n files.map(({ id, route, key, name, type, size, metadata }, index) => ({\n ord: index + 1,\n id,\n route,\n key,\n name,\n type,\n size,\n metadata,\n })),\n );\n\n/**\n * A retry of a request whose answer was lost ends that attempt's pending rows in the reserve's statement: the CTE that\n * does it, and the bytes it frees. Every CTE reads one snapshot, so the counters read beside it still hold those bytes\n * and the freed sum is taken off them. `key` and `who` are bound placeholders (`who` may be `NULL`). No key: no CTE,\n * nothing freed.\n */\nfunction superseding(files: string, key: string | null, who: string, at: string) {\n if (key === null) return { cte: \"\", freed: \"0\" };\n const cte = `, superseded AS (\n UPDATE ${files} SET status = 'aborted', ended_at = ${at}, updated_at = ${at}\n WHERE request_key = ${key} AND owner IS NOT DISTINCT FROM ${who}\n AND route IN (SELECT route FROM input) AND status = 'pending'\n RETURNING size\n )`;\n return { cte, freed: \"(SELECT coalesce(sum(size), 0) FROM superseded)\" };\n}\n\nexport function postgresWrites({ executor, tables }: SqlContext): GuardedWrites {\n const { files, usage } = tables;\n\n /**\n * Files and usage of one guarded transition, then the row: changed, or unchanged as found. `from` is the status the\n * update requires.\n */\n async function transitionRow(update: string, set: string | null, id: string, from: FileStatus, b: Binder) {\n const counted = set\n ? `, counted AS (UPDATE ${usage} SET ${set} FROM changed WHERE ${usage}.owner = changed.owner)`\n : \"\";\n const sql = `WITH changed AS (${update} RETURNING ${RECORD_COLUMNS})${counted}\n SELECT true AS changed, ${RECORD_COLUMNS} FROM changed\n UNION ALL\n SELECT false, ${RECORD_COLUMNS} FROM ${files} WHERE id = ${b.text(id)} AND NOT EXISTS (SELECT 1 FROM changed)`;\n const [row] = await runStatement(executor, b.statement(sql));\n const found = transition(row?.changed === true, row);\n // Unchanged, yet the row still shows the status the update wanted: the update waited for another transaction's\n // lock and found the row changed, while this statement's snapshot still holds it as it was. Read it as it is now.\n if (found.changed || found.record?.status !== from) return found;\n const again = binder(\"postgres\");\n const [current] = await runStatement(\n executor,\n again.statement(`SELECT ${RECORD_COLUMNS} FROM ${files} WHERE id = ${again.text(id)}`),\n );\n return transition(false, current);\n }\n\n return {\n async reserve({ owner, limit, expiresAt, requestKey, files: accepted }, now) {\n if (accepted.length === 0) return [];\n const b = binder(\"postgres\");\n const [input, expires, at, key] = [\n b.json(inputJson(accepted)),\n b.time(expiresAt),\n b.time(now),\n b.text(requestKey),\n ];\n const who = owner === null ? \"NULL\" : b.text(owner);\n const { cte, freed } = superseding(files, requestKey === null ? null : key, who, at);\n const head = `input AS (SELECT * FROM json_to_recordset(${input}) AS input(${INPUT_COLUMNS}))${cte}`;\n const values = `input.id, input.route, input.key, ${who}, 'pending', input.name, input.type, input.size,\n input.metadata, ${expires}, ${at}, ${at}, ${key}`;\n if (owner === null) {\n await runStatement(\n executor,\n b.statement(`WITH ${head} INSERT INTO ${files} (${INSERT_COLUMNS}) SELECT ${values} FROM input`),\n );\n return accepted.map(() => \"reserved\" as const);\n }\n const fits = limit === null ? \"true\" : `decided.used + input.size <= ${b.bigint(limit)}`;\n // Without a limit, a first reserve racing another for the same new owner adds to the row the other created. With\n // one it cannot: its quota decisions assumed no row, so the insert fails on the unique owner and is run again.\n const onConflict =\n limit === null\n ? `ON CONFLICT (owner) DO UPDATE SET reserved_bytes = ${usage}.reserved_bytes + EXCLUDED.reserved_bytes,\n updated_at = EXCLUDED.updated_at`\n : \"\";\n // The usage row is locked before any decision, so concurrent reserves of one owner queue and each sees the\n // counters the previous one committed. `decided` walks the files in order, adding each that fits.\n // Lock order: file rows, then the usage row, as in every other writer (end, complete, revoke). The freed sum sits\n // in `locked`'s projection, which the scan computes before FOR UPDATE locks the row, so `superseded` waits for a\n // row another transaction holds before this statement takes the usage row; the other order deadlocks (40P01).\n // With no usage row the owner has no reserved bytes to free.\n const sql = `WITH RECURSIVE ${head},\n locked AS (\n SELECT reserved_bytes + active_bytes - ${freed} AS used FROM ${usage} WHERE owner = ${who} FOR UPDATE\n ),\n decided (ord, used, reserved) AS (\n SELECT 0, coalesce((SELECT used FROM locked), 0), false\n UNION ALL\n SELECT input.ord, decided.used + CASE WHEN ${fits} THEN input.size ELSE 0 END, ${fits}\n FROM decided JOIN input ON input.ord = decided.ord + 1\n ),\n inserted AS (\n INSERT INTO ${files} (${INSERT_COLUMNS})\n SELECT ${values} FROM input JOIN decided ON decided.ord = input.ord WHERE decided.reserved\n RETURNING size\n ),\n total AS (SELECT coalesce(sum(size), 0) AS bytes, count(*) AS reserved, ${freed} AS freed FROM inserted),\n counted AS (\n UPDATE ${usage} SET reserved_bytes = reserved_bytes + total.bytes - total.freed, updated_at = ${at}\n FROM total WHERE owner = ${who} AND (total.reserved > 0 OR total.freed > 0)\n ),\n created AS (\n INSERT INTO ${usage} (owner, reserved_bytes, active_bytes, files, updated_at)\n SELECT ${who}, total.bytes, 0, 0, ${at} FROM total\n WHERE total.reserved > 0 AND NOT EXISTS (SELECT 1 FROM locked)\n ${onConflict}\n )\n SELECT reserved FROM decided WHERE ord > 0 ORDER BY ord`;\n const statement = b.statement(sql);\n const rows = await runStatement(executor, statement).catch((error: unknown) => {\n // A first reserve of this owner raced ours and created the usage row after our snapshot (see onConflict). The\n // failed statement rolled back whole; run again, it takes a new snapshot and its FOR UPDATE locks that row. A\n // duplicate file id fails the same way again and is thrown.\n if (limit === null || !isUniqueViolation(error)) throw error;\n return runStatement(executor, statement);\n });\n return rows.map((row) => (row.reserved === true ? \"reserved\" : \"over-quota\"));\n },\n\n async claim(id, claim, now, leaseMs) {\n const b = binder(\"postgres\");\n const [key, at] = [b.text(id), b.time(now)];\n const sql = `WITH claimed AS (\n UPDATE ${files} SET status = 'completing', claim = ${b.text(claim)}, claimed_at = ${at}, updated_at = ${at}\n WHERE id = ${key} AND (status = 'pending'\n OR (status = 'completing' AND claimed_at < ${b.time(new Date(now.getTime() - leaseMs))}))\n RETURNING id\n )\n SELECT EXISTS (SELECT 1 FROM claimed) AS claimed, ${RECORD_COLUMNS} FROM ${files} WHERE id = ${key}`;\n const [row] = await runStatement(executor, b.statement(sql));\n return claimOutcome(row?.claimed === true, row);\n },\n\n async complete(id, claim, result, now) {\n const b = binder(\"postgres\");\n const at = b.time(now);\n const update = `UPDATE ${files} SET status = 'completed', result = ${b.text(result)}, completed_at = ${at},\n updated_at = ${at} WHERE id = ${b.text(id)} AND status = 'completing' AND claim = ${b.text(claim)}`;\n const set = `reserved_bytes = reserved_bytes - changed.size, active_bytes = active_bytes + changed.size,\n files = files + 1, updated_at = ${at}`;\n return transitionRow(update, set, id, \"completing\", b);\n },\n\n async end(id, from, to, now, options) {\n const b = binder(\"postgres\");\n const at = b.time(now);\n const cleaned = options?.cleaned ? `, cleaned_at = ${at}` : \"\";\n const update = `UPDATE ${files} SET status = ${b.text(to)}, ended_at = ${at}, updated_at = ${at}${cleaned}\n WHERE id = ${b.text(id)} AND status = ${b.text(from)}`;\n const released = releaseFrom(from, \"changed.size\");\n return transitionRow(update, released && `${released}, updated_at = ${at}`, id, from, b);\n },\n\n async revoke(owner, now) {\n const b = binder(\"postgres\");\n const [who, at] = [b.text(owner), b.time(now)];\n const sql = `WITH revoked AS (\n UPDATE ${files} SET status = 'aborted', ended_at = ${at}, updated_at = ${at}\n WHERE owner = ${who} AND status = 'pending' RETURNING size\n ),\n counted AS (\n UPDATE ${usage} SET reserved_bytes = reserved_bytes - (SELECT sum(size) FROM revoked), updated_at = ${at}\n WHERE owner = ${who} AND EXISTS (SELECT 1 FROM revoked)\n )\n SELECT count(*) AS revoked FROM revoked`;\n const [row] = await runStatement(executor, b.statement(sql));\n return toSafeInteger(row?.revoked, \"revoked\");\n },\n\n async reconcile(owner) {\n /** A statement whose one parameter is the owner. */\n const forOwner = (sql: (who: string) => string) => {\n const b = binder(\"postgres\");\n return b.statement(sql(b.text(owner)));\n };\n // One transaction. The usage row is made to exist first (a zero row marked -infinity, which nobody else sees\n // before the commit), then locked, so every reserve of this owner either committed before the recount or waits\n // behind it: in READ COMMITTED the recount takes its snapshot after the lock. An upsert recount would compute its\n // values before waiting for a reserve that inserted the row meanwhile, and drop that reserve's bytes. The marked\n // row is removed again when the recount left it at zeros: an owner counted as all zeros gets no row.\n const [, , changed] = await executor.batch([\n forOwner(\n (who) => `INSERT INTO ${usage} (owner, reserved_bytes, active_bytes, files, updated_at)\n VALUES (${who}, 0, 0, 0, '-infinity') ON CONFLICT (owner) DO NOTHING`,\n ),\n forOwner((who) => `SELECT 1 FROM ${usage} WHERE owner = ${who} FOR UPDATE`),\n forOwner(\n (who) => `UPDATE ${usage} SET reserved_bytes = counted.reserved, active_bytes = counted.active,\n files = counted.files, updated_at = now()\n FROM (SELECT ${RECOUNT.reserved} AS reserved, ${RECOUNT.active} AS active, ${RECOUNT.files} AS files\n FROM ${files} WHERE owner = ${who}) AS counted\n WHERE ${usage}.owner = ${who} AND (${usage}.reserved_bytes, ${usage}.active_bytes, ${usage}.files)\n IS DISTINCT FROM (counted.reserved, counted.active, counted.files)\n RETURNING ${usage}.owner`,\n ),\n forOwner((who) => `DELETE FROM ${usage} WHERE owner = ${who} AND updated_at = '-infinity'`),\n ]);\n return (changed?.length ?? 0) > 0;\n },\n };\n}\n","// The store methods that are one statement on both dialects: they touch one table, so the only differences are the\n// placeholders (the binder's) and the collation of keyset comparisons.\n\nimport type { CloudropStore, FileRecord } from \"../../server/store.ts\";\nimport { binder } from \"./bind.ts\";\nimport { runStatement, type SqlDialect, type SqlExecutor, type SqlStatement } from \"./executor.ts\";\nimport { decodeCursor, encodeCursor, RECORD_COLUMNS, toRecord, toUsage } from \"./records.ts\";\nimport type { QuotedTables } from \"./tables.ts\";\n\n/** What every statement builder needs: where to run, in which dialect, over which tables. */\nexport interface SqlContext {\n executor: Omit<SqlExecutor<unknown>, \"transaction\">;\n dialect: SqlDialect;\n tables: QuotedTables;\n}\n\nexport type StoreMethods = Omit<CloudropStore<never>, \"transaction\">;\n\ntype SingleStatementMethods = Pick<\n StoreMethods,\n \"attach\" | \"get\" | \"release\" | \"cleaned\" | \"usage\" | \"stale\" | \"owners\"\n>;\n\nconst CLEANUP_STATUSES = \"'aborted', 'rejected', 'failed', 'expired', 'deleted'\";\n\n/** A keyset page: `limit + 1` rows were asked for, so a row beyond the page means another page follows. */\nfunction page<T>(rows: T[], limit: number, cursorOf: (last: T) => string) {\n const kept = rows.slice(0, limit);\n const last = kept.at(-1);\n return { kept, cursor: rows.length > limit && last !== undefined ? cursorOf(last) : null };\n}\n\nexport function singleStatementMethods({ executor, dialect, tables }: SqlContext): SingleStatementMethods {\n const { files, usage } = tables;\n // Byte order on Postgres, whatever the database's collation, so ids and owners page in the same order everywhere;\n // SQLite's default collation already compares bytes.\n const byteOrder = (expression: string) => (dialect === \"postgres\" ? `${expression} COLLATE \"C\"` : expression);\n const run = (statement: SqlStatement) => runStatement(executor, statement);\n\n return {\n async attach(id, uploadId, now) {\n const b = binder(dialect);\n const sql = `UPDATE ${files} SET upload_id = ${b.text(uploadId)}, updated_at = ${b.time(now)}\n WHERE id = ${b.text(id)} AND status = 'pending' AND (upload_id IS NULL OR upload_id = ${b.text(uploadId)})\n RETURNING id`;\n return (await run(b.statement(sql))).length > 0;\n },\n\n async get(id) {\n const b = binder(dialect);\n const [row] = await run(b.statement(`SELECT ${RECORD_COLUMNS} FROM ${files} WHERE id = ${b.text(id)}`));\n return row ? toRecord(row) : null;\n },\n\n async release(id, claim, now) {\n const b = binder(dialect);\n const sql = `UPDATE ${files} SET status = 'pending', claim = NULL, claimed_at = NULL, updated_at = ${b.time(now)}\n WHERE id = ${b.text(id)} AND status = 'completing' AND claim = ${b.text(claim)} RETURNING id`;\n return (await run(b.statement(sql))).length > 0;\n },\n\n async cleaned(id, now) {\n const b = binder(dialect);\n const sql = `UPDATE ${files} SET cleaned_at = ${b.time(now)}, updated_at = ${b.time(now)}\n WHERE id = ${b.text(id)} AND cleaned_at IS NULL`;\n await run(b.statement(sql));\n },\n\n async usage(owner) {\n const b = binder(dialect);\n const sql = `SELECT reserved_bytes, active_bytes, files FROM ${usage} WHERE owner = ${b.text(owner)}`;\n return toUsage((await run(b.statement(sql)))[0]);\n },\n\n async stale({ kind, before, claimedBefore, limit, cursor }) {\n const b = binder(dialect);\n const time = kind === \"expire\" ? \"expires_at\" : \"ended_at\";\n const work =\n kind === \"expire\"\n ? `expires_at < ${b.time(before)}\n AND (status = 'pending' OR (status = 'completing' AND claimed_at < ${b.time(claimedBefore)}))`\n : `status IN (${CLEANUP_STATUSES}) AND cleaned_at IS NULL AND ended_at < ${b.time(before)}`;\n const start = cursor === null ? null : decodeCursor(cursor);\n const after = start ? `AND (${time}, ${byteOrder(\"id\")}) > (${b.time(start.time)}, ${b.text(start.id)})` : \"\";\n const sql = `SELECT ${RECORD_COLUMNS} FROM ${files} WHERE ${work} ${after}\n ORDER BY ${time}, ${byteOrder(\"id\")} LIMIT ${b.integer(limit + 1)}`;\n const records = (await run(b.statement(sql))).map(toRecord);\n const timeOf = (record: FileRecord) => (kind === \"expire\" ? record.expiresAt : (record.endedAt ?? new Date(0)));\n const { kept, cursor: next } = page(records, limit, (last) => encodeCursor(timeOf(last), last.id));\n return { records: kept, cursor: next };\n },\n\n async owners(cursor, limit) {\n const b = binder(dialect);\n const after = cursor === null ? \"\" : `WHERE ${byteOrder(\"owner\")} > ${b.text(cursor)}`;\n const sql = `SELECT owner FROM ${usage} ${after} ORDER BY ${byteOrder(\"owner\")} LIMIT ${b.integer(limit + 1)}`;\n const owners = (await run(b.statement(sql))).map((row) => String(row.owner));\n const { kept, cursor: next } = page(owners, limit, (last) => last);\n return { owners: kept, cursor: next };\n },\n };\n}\n","// The SQLite statements of the methods that write both tables or must decide in one step. SQLite has no writing CTEs,\n// so each method is one atomic batch (D1's `batch()`, `BEGIN IMMEDIATE … COMMIT` on node:sqlite) whose statements each\n// check their own condition and never read the previous one's row count, which D1 does not report reliably. Where a\n// usage change depends on a files change, the usage statement runs first, guarded on the files row's state before the\n// change: both statements then test the same unchanged condition, so they apply together or not at all, and a replay\n// with the same claim cannot count twice.\n\nimport type { NewFile } from \"../../server/store.ts\";\nimport { type Binder, binder } from \"./bind.ts\";\nimport { runStatement, type SqlStatement } from \"./executor.ts\";\nimport { claimOutcome, RECOUNT, releaseFrom, transition } from \"./outcomes.ts\";\nimport type { SqlContext, StoreMethods } from \"./reads.ts\";\nimport { RECORD_COLUMNS } from \"./records.ts\";\n\ntype GuardedWrites = Pick<StoreMethods, \"reserve\" | \"claim\" | \"complete\" | \"end\" | \"revoke\" | \"reconcile\">;\n\nconst INSERT_COLUMNS =\n \"id, route, key, owner, status, name, type, size, metadata, expires_at, created_at, updated_at, request_key\";\n\n/** The database's clock in integer milliseconds, as reconcile is given no time. Valid on every SQLite version. */\nconst NOW_MS = \"CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER)\";\n\nexport function sqliteWrites({ executor, tables }: SqlContext): GuardedWrites {\n const { files, usage } = tables;\n const select = (id: string) => {\n const b = binder(\"sqlite\");\n return b.statement(`SELECT ${RECORD_COLUMNS} FROM ${files} WHERE id = ${b.text(id)}`);\n };\n\n /** Runs `[usage change?, files update, select]` and reads the transition from the last two. */\n async function transitionBatch(counted: SqlStatement | null, update: SqlStatement, id: string) {\n const statements = [{ sql: `${update.sql} RETURNING id`, params: update.params }, select(id)];\n const [updated, found] = (await executor.batch(counted ? [counted, ...statements] : statements)).slice(-2);\n return transition((updated?.length ?? 0) > 0, found?.[0]);\n }\n\n /** The usage `UPDATE` (or none, for `set` null) for the owner of file `id` while it is in `from`; f is that row. */\n function usageFor(set: string | null, id: string, from: string, now: Date, guard?: (b: Binder) => string) {\n if (set === null) return null;\n const b = binder(\"sqlite\");\n return b.statement(`UPDATE ${usage} SET ${set}, updated_at = ${b.time(now)} FROM ${files} AS f\n WHERE f.id = ${b.text(id)} AND f.status = ${b.text(from)} ${guard?.(b) ?? \"\"} AND ${usage}.owner = f.owner`);\n }\n\n /**\n * A retry of a request whose answer was lost: the statements that end that attempt's pending rows and release their\n * bytes, the usage first while the rows are still pending, so the quota checks after them count without those bytes.\n */\n function supersede(key: string, owner: string | null, accepted: readonly NewFile[], now: Date): SqlStatement[] {\n const routes = [...new Set(accepted.map((file) => file.route))];\n const superseded = (b: Binder) =>\n // `IS` is SQLite's null-safe equality: a null owner matches only null.\n `request_key = ${b.text(key)} AND owner IS ${b.text(owner)}\n AND route IN (${routes.map((route) => b.text(route)).join(\", \")}) AND status = 'pending'`;\n const b = binder(\"sqlite\");\n const end = b.statement(`UPDATE ${files} SET status = 'aborted', ended_at = ${b.time(now)},\n updated_at = ${b.time(now)} WHERE ${superseded(b)}`);\n if (owner === null) return [end];\n const counter = binder(\"sqlite\");\n const rows = (c: Binder) => `FROM ${files} WHERE ${superseded(c)}`;\n const count = counter.statement(`UPDATE ${usage}\n SET reserved_bytes = reserved_bytes - (SELECT sum(size) ${rows(counter)}), updated_at = ${counter.time(now)}\n WHERE owner = ${counter.text(owner)} AND EXISTS (SELECT 1 ${rows(counter)})`);\n return [count, end];\n }\n\n return {\n async reserve({ owner, limit, expiresAt, requestKey, files: accepted }, now) {\n // The quota check reads the usage row as the earlier files of this batch left it; the same check guards the usage\n // write, which runs before anything else changes that row, so the two always agree.\n const fits = (b: Binder, file: NewFile) =>\n owner === null || limit === null\n ? \"1\"\n : `coalesce((SELECT reserved_bytes + active_bytes FROM ${usage} WHERE owner = ${b.text(owner)}), 0)\n + ${b.bigint(file.size)} <= ${b.bigint(limit)}`;\n const statements = accepted.flatMap((file) => {\n const row = binder(\"sqlite\");\n const insert = row.statement(`INSERT INTO ${files} (${INSERT_COLUMNS})\n SELECT ${row.text(file.id)}, ${row.text(file.route)}, ${row.text(file.key)}, ${row.text(owner)}, 'pending',\n ${row.text(file.name)}, ${row.text(file.type)}, ${row.bigint(file.size)}, ${row.text(file.metadata)},\n ${row.time(expiresAt)}, ${row.time(now)}, ${row.time(now)}, ${row.text(requestKey)}\n WHERE ${fits(row, file)} RETURNING id`);\n if (owner === null) return [insert];\n const counter = binder(\"sqlite\");\n // SQLite needs the WHERE before an upsert's ON CONFLICT, so the bare `1` stays when there is no limit.\n const count = counter.statement(`INSERT INTO ${usage} (owner, reserved_bytes, active_bytes, files, updated_at)\n SELECT ${counter.text(owner)}, ${counter.bigint(file.size)}, 0, 0, ${counter.time(now)}\n WHERE ${fits(counter, file)}\n ON CONFLICT (owner) DO UPDATE SET reserved_bytes = reserved_bytes + excluded.reserved_bytes,\n updated_at = excluded.updated_at`);\n return [insert, count];\n });\n if (statements.length === 0) return [];\n const superseded = requestKey === null ? [] : supersede(requestKey, owner, accepted, now);\n const results = (await executor.batch([...superseded, ...statements])).slice(superseded.length);\n const step = owner === null ? 1 : 2;\n return accepted.map((_, index) => ((results[index * step]?.length ?? 0) > 0 ? \"reserved\" : \"over-quota\"));\n },\n\n async claim(id, claim, now, leaseMs) {\n const b = binder(\"sqlite\");\n const update = b.statement(`UPDATE ${files}\n SET status = 'completing', claim = ${b.text(claim)}, claimed_at = ${b.time(now)}, updated_at = ${b.time(now)}\n WHERE id = ${b.text(id)} AND (status = 'pending'\n OR (status = 'completing' AND claimed_at < ${b.time(new Date(now.getTime() - leaseMs))}))\n RETURNING id`);\n const [claimed, found] = await executor.batch([update, select(id)]);\n return claimOutcome((claimed?.length ?? 0) > 0, found?.[0]);\n },\n\n async complete(id, claim, result, now) {\n const counted = usageFor(\n \"reserved_bytes = reserved_bytes - f.size, active_bytes = active_bytes + f.size, files = files + 1\",\n id,\n \"completing\",\n now,\n (b) => `AND f.claim = ${b.text(claim)}`,\n );\n const b = binder(\"sqlite\");\n const update = b.statement(`UPDATE ${files} SET status = 'completed', result = ${b.text(result)},\n completed_at = ${b.time(now)}, updated_at = ${b.time(now)}\n WHERE id = ${b.text(id)} AND status = 'completing' AND claim = ${b.text(claim)}`);\n return transitionBatch(counted, update, id);\n },\n\n async end(id, from, to, now, options) {\n const counted = usageFor(releaseFrom(from, \"f.size\"), id, from, now);\n const b = binder(\"sqlite\");\n // Bound inline: `?` placeholders take their values in the order the template evaluates them.\n const update = b.statement(`UPDATE ${files}\n SET status = ${b.text(to)}${options?.cleaned ? `, cleaned_at = ${b.time(now)}` : \"\"}, ended_at = ${b.time(now)},\n updated_at = ${b.time(now)} WHERE id = ${b.text(id)} AND status = ${b.text(from)}`);\n return transitionBatch(counted, update, id);\n },\n\n async revoke(owner, now) {\n const counter = binder(\"sqlite\");\n const pending = (b: Binder) => `FROM ${files} WHERE owner = ${b.text(owner)} AND status = 'pending'`;\n const count = counter.statement(`UPDATE ${usage}\n SET reserved_bytes = reserved_bytes - (SELECT sum(size) ${pending(counter)}), updated_at = ${counter.time(now)}\n WHERE owner = ${counter.text(owner)} AND EXISTS (SELECT 1 ${pending(counter)})`);\n const b = binder(\"sqlite\");\n const revoke = b.statement(`UPDATE ${files} SET status = 'aborted', ended_at = ${b.time(now)},\n updated_at = ${b.time(now)} WHERE owner = ${b.text(owner)} AND status = 'pending' RETURNING id`);\n const [, revoked] = await executor.batch([count, revoke]);\n return revoked?.length ?? 0;\n },\n\n async reconcile(owner) {\n // One statement, and SQLite runs one writer at a time, so nothing can change the rows between count and write.\n // An owner without a row whose rows count nothing gets none: a missing row already counts as zeros.\n const b = binder(\"sqlite\");\n const sql = `INSERT INTO ${usage} (owner, reserved_bytes, active_bytes, files, updated_at)\n SELECT ${b.text(owner)}, ${RECOUNT.reserved}, ${RECOUNT.active}, ${RECOUNT.files}, ${NOW_MS}\n FROM ${files} WHERE owner = ${b.text(owner)}\n HAVING ${RECOUNT.reserved} + ${RECOUNT.active} + ${RECOUNT.files} > 0\n OR EXISTS (SELECT 1 FROM ${usage} WHERE owner = ${b.text(owner)})\n ON CONFLICT (owner) DO UPDATE SET reserved_bytes = excluded.reserved_bytes,\n active_bytes = excluded.active_bytes, files = excluded.files, updated_at = excluded.updated_at\n WHERE reserved_bytes <> excluded.reserved_bytes OR active_bytes <> excluded.active_bytes\n OR files <> excluded.files\n RETURNING owner`;\n return (await runStatement(executor, b.statement(sql))).length > 0;\n },\n };\n}\n","// The store's two tables: names validated and quoted once at construction, and a lazy check that every column the\n// core reads exists, so a schema mistake fails with a message naming the table and the column instead of a driver error\n// on the first upload.\n\nimport { CloudropError, configError } from \"../../errors.ts\";\nimport type { SqlDialect, SqlExecutor } from \"./executor.ts\";\nimport { FILE_COLUMNS } from \"./records.ts\";\n\n/** The table names a store is built with (spec §3); columns are fixed. */\nexport interface StoreTables {\n files?: string;\n usage?: string;\n /**\n * Postgres only: the schema both tables live in, such as `\"app\"`. Without it the statements name the tables alone,\n * and the connection's search path finds them.\n */\n schema?: string;\n}\n\n/** The names with their defaults, validated. */\nexport interface TableNames {\n files: string;\n usage: string;\n schema?: string;\n}\n\n/** Both tables as SQL names: quoted, and qualified with the schema when there is one. */\nexport interface QuotedTables {\n files: string;\n usage: string;\n}\n\ntype Reader = Pick<SqlExecutor<unknown>, \"query\">;\n\nconst NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nconst NO_SQLITE_SCHEMA = \"SQLite has no schemas: remove schema from { tables }.\";\n\nconst USAGE_COLUMNS = [\"owner\", \"reserved_bytes\", \"active_bytes\", \"files\", \"updated_at\"];\n\n/** Fills in the default names and validates every name: they are the only text the core puts into SQL unbound. */\nexport function tableNames(tables: StoreTables = {}, dialect: SqlDialect): TableNames {\n const { schema } = tables;\n if (schema !== undefined && dialect === \"sqlite\") throw configError(NO_SQLITE_SCHEMA);\n const names = { files: tables.files ?? \"cloudrop_files\", usage: tables.usage ?? \"cloudrop_usage\" };\n const checked = schema === undefined ? names : { ...names, schema };\n for (const [option, name] of Object.entries(checked)) {\n if (typeof name !== \"string\" || !NAME.test(name)) {\n const what = option === \"schema\" ? \"schema\" : `${option} table`;\n throw configError(\n `The ${what} name ${JSON.stringify(name)} is not allowed. Use letters, digits and \"_\", not starting with a digit: { tables: { ${option}: \"...\" } }.`,\n );\n }\n }\n return checked;\n}\n\n/** The names as SQL: quoted, and prefixed with the quoted schema when there is one. */\nexport function quoteTables({ files, usage, schema }: TableNames): QuotedTables {\n const prefix = schema === undefined ? \"\" : `\"${schema}\".`;\n return { files: `${prefix}\"${files}\"`, usage: `${prefix}\"${usage}\"` };\n}\n\n/** Answers whether the statement runs; any failure counts as no. */\nasync function runs(executor: Reader, sql: string): Promise<boolean> {\n try {\n await executor.query(sql, []);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * The first problem with one table: the table itself, or its first missing column in the order of spec §3. Only called\n * after the whole-table read failed, so the probes run on the error path alone.\n */\nasync function findMissing(executor: Reader, table: string, columns: readonly string[]): Promise<string | null> {\n if (!(await runs(executor, `SELECT 1 FROM ${table} WHERE 1 = 0`))) return `The table ${table} does not exist.`;\n for (const column of columns) {\n if (!(await runs(executor, `SELECT ${column} FROM ${table} WHERE 1 = 0`))) {\n return `The table ${table} has no column \"${column}\".`;\n }\n }\n return null;\n}\n\n/**\n * Reads every column of both tables without reading a row. When that fails and the database answers a bare `SELECT 1`,\n * the schema is at fault: throws `INVALID_CONFIG` naming the table (qualified, when it has a schema) and its first\n * missing column. Any other failure (the database is down) is rethrown as it is.\n */\nexport async function checkSchema(executor: Reader, quoted: QuotedTables): Promise<void> {\n const tables: [string, readonly string[]][] = [\n [quoted.files, FILE_COLUMNS],\n [quoted.usage, USAGE_COLUMNS],\n ];\n for (const [table, columns] of tables) {\n try {\n await executor.query(`SELECT ${columns.join(\", \")} FROM ${table} WHERE 1 = 0`, []);\n } catch (error) {\n const missing = (await runs(executor, \"SELECT 1\")) ? await findMissing(executor, table, columns) : null;\n if (missing === null) throw error;\n throw new CloudropError(\n \"INVALID_CONFIG\",\n `${missing} Create the store's tables as the cloudrop docs show, or pass their names in { tables }.`,\n { cause: error },\n );\n }\n }\n}\n","// The SQL core's entry: a CloudropStore over any SqlExecutor, for Postgres or SQLite. Every adapter\n// (`cloudrop/adapters/sql`, Drizzle, Prisma) builds an executor and calls this; none writes SQL of its own.\n\nimport { configError } from \"../../errors.ts\";\nimport type { CloudropStore } from \"../../server/store.ts\";\nimport { isLockTimeout, type SqlExecutor } from \"./executor.ts\";\nimport { postgresWrites } from \"./postgres.ts\";\nimport { type SqlContext, type StoreMethods, singleStatementMethods } from \"./reads.ts\";\nimport { sqliteWrites } from \"./sqlite.ts\";\nimport { checkSchema, quoteTables, type StoreTables, tableNames } from \"./tables.ts\";\n\nexport interface SqlStoreOptions {\n /**\n * The two tables' names, defaults `cloudrop_files` and `cloudrop_usage`, and on Postgres their schema; letters,\n * digits and `_`.\n */\n tables?: StoreTables;\n /**\n * Postgres only, with an executor that has `transaction()`. On: each completion's claim, `onComplete` and record\n * share one transaction, and the store gets `route` for routes whose `onComplete` receives it as `tx`; a completion\n * holds a connection and the row lock while `onComplete` runs. Off (the default): a completion holds its file with\n * a lease and no connection.\n */\n transaction?: boolean;\n}\n\nconst NEEDS_POSTGRES =\n \"transaction: true needs Postgres. SQLite has one writer at a time, so a transaction held open while onComplete runs would stall every other upload; leave the option out and completions use a lease.\";\nconst NEEDS_TRANSACTION =\n \"transaction: true needs an executor with transaction(), such as pgExecutor or postgresJsExecutor. Add one to your executor, or leave the option out and completions use a lease.\";\n\n/** Postgres waits at most this long for a row lock inside a transaction; a claim that waits longer is `busy`. */\nconst LOCK_TIMEOUT = \"2s\";\n\nfunction methodsOver(context: SqlContext): StoreMethods {\n const writes = context.dialect === \"postgres\" ? postgresWrites(context) : sqliteWrites(context);\n return { ...singleStatementMethods(context), ...writes };\n}\n\n/** The same methods, each waiting for `ready` first. */\nfunction afterCheck(methods: StoreMethods, ready: () => Promise<void>): StoreMethods {\n const checked: Record<string, (...args: never[]) => Promise<unknown>> = {};\n for (const [name, method] of Object.entries(methods) as [string, (...args: never[]) => Promise<unknown>][]) {\n checked[name] = async (...args) => {\n await ready();\n return method(...args);\n };\n }\n // Every key of `methods` was copied with its own signature, only deferred.\n return checked as unknown as StoreMethods;\n}\n\n/**\n * A store over SQL tables. Each method is one atomic unit (one statement on Postgres, one batch on SQLite). The schema\n * is checked once, on the first call, and a missing table or column fails that call with `INVALID_CONFIG`. With\n * `transaction: true` the store has `transaction` too, from the executor's: inside it a claim waits at most 2 seconds for\n * Postgres's row lock, so an overlapping `/complete` answers `busy` instead of waiting for `onComplete` to finish; the\n * app's own statements through `tx` keep the lock timeout their session had. Postgres must run at its default\n * isolation, READ COMMITTED: claims, quota and reconcile rely on its re-reading of a row they waited for.\n */\nexport function sqlStore<TTx = never>(executor: SqlExecutor<TTx>, options: SqlStoreOptions = {}): CloudropStore<TTx> {\n const { dialect } = executor;\n if (dialect !== \"postgres\" && dialect !== \"sqlite\") {\n throw configError(\n `The executor's dialect ${JSON.stringify(dialect)} is not supported. Use \"postgres\" or \"sqlite\".`,\n );\n }\n const tables = quoteTables(tableNames(options.tables, dialect));\n let schema: Promise<void> | undefined;\n const ready = () => {\n // A failed check is not kept, so a fixed schema (or a database back up) is picked up by the next call.\n schema ??= checkSchema(executor, tables).catch((error: unknown) => {\n schema = undefined;\n throw error;\n });\n return schema;\n };\n const store: CloudropStore<TTx> = afterCheck(methodsOver({ executor, dialect, tables }), ready);\n if (!options.transaction) return store;\n if (dialect !== \"postgres\") throw configError(NEEDS_POSTGRES);\n if (!executor.transaction) throw configError(NEEDS_TRANSACTION);\n const transaction = executor.transaction.bind(executor);\n return {\n ...store,\n async transaction<T>(run: (tx: TTx, store: StoreMethods) => Promise<T>): Promise<T> {\n await ready();\n let timedOut = false;\n let answer: { value: T } | undefined;\n try {\n return await transaction<T>(async (inner, tx) => {\n const methods = methodsOver({ executor: inner, dialect, tables });\n // The cap covers the claim alone: onComplete's own statements through tx then run at whatever lock timeout\n // the session had, restored exactly (a session-level SET included, which DEFAULT would drop). Another\n // /complete holding the row lock past the cap makes the row busy, not broken. The CTE is materialized so the\n // saved value is read before set_config changes it.\n const capLockWait = async (): Promise<string | undefined> => {\n if (dialect !== \"postgres\") return undefined;\n const [row] = await inner.query(\n `WITH before AS MATERIALIZED (SELECT current_setting('lock_timeout') AS saved)\n SELECT saved, set_config('lock_timeout', '${LOCK_TIMEOUT}', true) FROM before`,\n [],\n );\n return String(row?.saved);\n };\n const claim: StoreMethods[\"claim\"] = async (...args) => {\n const saved = await capLockWait();\n let outcome: Awaited<ReturnType<StoreMethods[\"claim\"]>>;\n try {\n outcome = await methods.claim(...args);\n } catch (error) {\n if (!isLockTimeout(error)) throw error;\n timedOut = true;\n return { kind: \"busy\" };\n }\n if (saved !== undefined) await inner.query(\"SELECT set_config('lock_timeout', $1::text, true)\", [saved]);\n return outcome;\n };\n const value = await run(tx, { ...methods, claim });\n answer = { value };\n return value;\n });\n } catch (error) {\n // postgres.js fails a transaction in which any statement failed, even the claim answered as busy above. That\n // transaction rolled back with nothing written, which is what node-postgres does silently, so run's answer\n // stands.\n if (timedOut && answer && isLockTimeout(error)) return answer.value;\n throw error;\n }\n },\n };\n}\n","// What every adapter does to a store built with `transaction: true`: give it `route`, for the routes whose onComplete\n// receives the store's transaction as `tx`.\n\nimport { routeFor } from \"../server/route.ts\";\nimport type { CloudropStore, TransactionalStore } from \"../server/store.ts\";\n\n/** The store with `route`; `transaction` is the store's own, so the caller checks it is there. */\nexport function withRoute<TTx>(store: CloudropStore<TTx>): TransactionalStore<TTx> {\n // routeFor brands each route with this very object, the one the app passes to createCloudrop.\n return Object.assign(store, { route: routeFor<{ tx: TTx }>(store) }) as TransactionalStore<TTx>;\n}\n"],"mappings":";;;AAuCA,SAAgB,WAAW,SAAqB,OAAsE;CACpH,OAAO;EACL;EACA;EACA,MAAM,MAAM,YAAY;GACtB,MAAM,UAAsB,CAAC;GAC7B,KAAK,MAAM,EAAE,KAAK,YAAY,YAAY,QAAQ,KAAK,MAAM,MAAM,KAAK,MAAM,CAAC;GAC/E,OAAO;EACT;CACF;AACF;AAGA,SAAgB,aACd,UACA,WACmB;CACnB,OAAO,SAAS,MAAM,UAAU,KAAK,UAAU,MAAM;AACvD;AASA,SAAS,QAAQ,OAAgB,UAA2B;CAC1D,IAAI,UAAmB;CACvB,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,OAAO,YAAY,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
|
|
1
|
+
{"version":3,"file":"types-BZUOaz_B.js","names":[],"sources":["../src/protocol/types.ts"],"sourcesContent":["// The upload protocol (spec §5): the only module the client and the server share. Types and constants only, so the\n// client bundle never pulls in server code.\n\nimport type { CloudropErrorCode } from \"../errors.ts\";\n\n/** The four JSON endpoints, each at `<basePath>/<endpoint>`, all `POST`. */\nexport type Endpoint = \"upload\" | \"sign\" | \"complete\" | \"abort\";\n\n/** The largest request body any endpoint reads, in bytes (spec §7.3). */\nexport const MAX_BODY_BYTES: number = 65_536;\n/** The most part URLs one `/upload` file or one `/sign` call returns (spec §5.2). */\nexport const PARTS_PER_SIGN: number = 20;\n/** The longest file name accepted, in Unicode code points (spec §7.3). */\nexport const MAX_NAME_LENGTH: number = 255;\n\n/** What the client knows about a file before it uploads it. `type` may be \"\" (the browser does not know it). */\nexport interface FileDescriptor {\n name: string;\n size: number;\n type: string;\n}\n\nexport interface UploadRequest {\n route: string;\n files: FileDescriptor[];\n metadata?: unknown;\n /**\n * 16 to 128 characters of `[A-Za-z0-9_-]`, new for each ask and the same on every retry of it. With a store, a\n * retry supersedes the rows its earlier attempt reserved, whose answer the client never had. Never reuse a key for a\n * new ask: a request with a key ends the pending uploads of earlier requests with the same key, route and owner. On\n * a route without `owner`, or when it answers null, the key does nothing.\n */\n idempotencyKey?: string;\n}\n\n/**\n * A presigned `PUT`. Send exactly `headers`, no more: every header is signed, and R2 rejects an unsigned\n * `x-amz-meta-*` header. Never set Content-Length: its value is signed, and the platform derives it from the body.\n */\nexport interface SignedRequest {\n url: string;\n headers: Record<string, string>;\n /** ISO 8601. Renew through `/sign` before it passes. */\n expiresAt: string;\n}\n\nexport interface SignedPart extends SignedRequest {\n partNumber: number;\n}\n\ninterface TicketFields {\n id: string;\n key: string;\n /** Present it to `/sign`, `/complete` and `/abort`. */\n token: string;\n /** ISO 8601: when the token, and with it the chance to resume, expires. */\n expiresAt: string;\n}\n\nexport interface SingleTicket extends TicketFields {\n kind: \"single\";\n put: SignedRequest;\n}\n\nexport interface MultipartTicket extends TicketFields {\n kind: \"multipart\";\n /** Every part except the last has exactly this many bytes. */\n partSize: number;\n partCount: number;\n /** URLs for the first parts, at most PARTS_PER_SIGN; ask `/sign` for the rest. */\n parts: SignedPart[];\n}\n\n/** A file the server refused (size, type, or a storage failure); the request's other files go on. */\nexport interface RejectedFile {\n kind: \"rejected\";\n error: ErrorBody;\n}\n\nexport type FileTicket = SingleTicket | MultipartTicket | RejectedFile;\n\n/** One ticket per requested file, in request order. */\nexport interface UploadResponse {\n files: FileTicket[];\n}\n\n/** `parts` is required for a multipart upload and must be absent for a single PUT. */\nexport interface SignRequest {\n token: string;\n parts?: number[];\n}\n\nexport type SignResponse = { put: SignedRequest } | { parts: SignedPart[] };\n\nexport interface CompleteRequest {\n token: string;\n}\n\nexport interface UploadedFile {\n /** Stable across retries and copies; stored as `x-amz-meta-cloudrop-id`. */\n id: string;\n key: string;\n name: string;\n size: number;\n type: string;\n /** The public URL on a public route, otherwise null (use `api.getUrl`). */\n url: string | null;\n}\n\nexport interface CompleteResponse<TResult = unknown> {\n file: UploadedFile;\n /** What the route's `onComplete` returned, or null without one. */\n data: TResult;\n}\n\nexport interface AbortRequest {\n token: string;\n /**\n * Without a store's row, never delete an object that landed, even while the token is valid: only an unfinished\n * multipart upload is aborted. With a row it changes nothing: a pending row proves no completion committed, and a\n * completed one is kept anyway. The client's discard() sends it, for an upload a /complete may have finished.\n */\n keep?: boolean;\n}\n\nexport interface AbortResponse {\n id: string;\n}\n\nexport interface ErrorBody {\n code: CloudropErrorCode;\n message: string;\n retryable: boolean;\n /** PARTS_MISSING only: the part numbers to upload again. */\n parts?: number[];\n}\n\n/** Every non-2xx response has this body. */\nexport interface ErrorResponse {\n error: ErrorBody;\n}\n\n/**\n * Approximately what a value becomes after JSON.stringify and JSON.parse, for JSON-shaped data such as an authorize\n * result or schema output: a `toJSON` value (a Date) becomes its JSON form, and function, symbol and undefined\n * properties vanish. It does not model every JavaScript object: in arrays JSON turns undefined and functions into\n * null, a `T | undefined` property is typed as present though JSON may drop it, and a Map, a Set or a class instance is\n * typed by its own fields while JSON keeps only own enumerable properties (a Map becomes `{}`). Return plain data.\n */\nexport type Jsonified<T> = unknown extends T\n ? unknown\n : T extends { toJSON(): infer J }\n ? Jsonified<J>\n : T extends string | number | boolean | null\n ? T\n : T extends undefined | symbol | bigint | ((...args: never[]) => unknown)\n ? never\n : T extends readonly (infer E)[]\n ? Jsonified<E>[]\n : T extends object\n ? {\n [K in keyof T as K extends string | number\n ? Jsonified<T[K]> extends never\n ? never\n : K\n : never]: Jsonified<T[K]>;\n }\n : never;\n\n/** The types the client reads from a route. */\nexport interface RouteTypes {\n metadata: unknown;\n result: unknown;\n}\n\n/** Implemented by the server's `Cloudrop`. The client reads it through `import type` only. */\nexport interface InferableCloudrop<TRoutes extends Record<string, RouteTypes> = Record<string, RouteTypes>> {\n /** Type-only: never set at runtime. */\n readonly \"~routes\"?: TRoutes;\n}\n\ntype RoutesOf<TCloudrop> = TCloudrop extends InferableCloudrop<infer TRoutes> ? TRoutes : never;\n\nexport type RouteName<TCloudrop> = keyof RoutesOf<TCloudrop> & string;\n\n/** The metadata a client sends to the route: the schema's input type, or undefined for a route without a schema. */\nexport type RouteMetadata<TCloudrop, TName extends RouteName<TCloudrop>> = RoutesOf<TCloudrop>[TName][\"metadata\"];\n\n/** What `/complete` returns as `data` for the route: the JSON form of its `onComplete` result. */\nexport type RouteResult<TCloudrop, TName extends RouteName<TCloudrop>> = RoutesOf<TCloudrop>[TName][\"result\"];\n\n/** What both framework adapters accept: anything with a Web `Request` handler, such as `Cloudrop`. */\nexport interface RequestHandler {\n handler(request: Request): Promise<Response>;\n}\n"],"mappings":";AASA,MAAa,iBAAyB"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
type CloudropErrorCode = "INVALID_INPUT" | "INVALID_CONFIG" | "STORAGE_UNREACHABLE" | "STORAGE_DENIED" | "STORAGE_ERROR" | "RATE_LIMITED" | "NOT_FOUND" | "ALREADY_EXISTS" | "NO_SUCH_UPLOAD" | "INVALID_PART" | "CHECKSUM_MISMATCH" | "UNAUTHORIZED" | "FORBIDDEN" | "ORIGIN_NOT_ALLOWED" | "METHOD_NOT_ALLOWED" | "UNSUPPORTED_MEDIA_TYPE" | "BODY_TOO_LARGE" | "UNKNOWN_ROUTE" | "INVALID_METADATA" | "TOO_MANY_FILES" | "FILE_TOO_LARGE" | "FILE_TYPE_NOT_ALLOWED" | "QUOTA_EXCEEDED" | "INVALID_TOKEN" | "UPLOAD_EXPIRED" | "NOT_UPLOADED" | "PARTS_MISSING" | "VERIFICATION_FAILED" | "SERVER_ERROR" | "UPLOAD_REJECTED" | "ABORTED" | "NETWORK_ERROR" | "UPLOAD_IN_USE";
|
|
2
|
+
interface CloudropErrorOptions {
|
|
3
|
+
retryable?: boolean;
|
|
4
|
+
status?: number;
|
|
5
|
+
storageCode?: string;
|
|
6
|
+
/** PARTS_MISSING: the part numbers to upload again. */
|
|
7
|
+
parts?: readonly number[];
|
|
8
|
+
/** The file of a job this error belongs to. */
|
|
9
|
+
file?: {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
cause?: unknown;
|
|
14
|
+
}
|
|
15
|
+
declare class CloudropError extends Error {
|
|
16
|
+
readonly code: CloudropErrorCode;
|
|
17
|
+
readonly retryable: boolean;
|
|
18
|
+
/** The HTTP status the storage service answered, for logs. The handler's own answer takes its status from `code`. */
|
|
19
|
+
readonly status: number | undefined;
|
|
20
|
+
/** The storage service's own error code, for logs. Never shown to end users. */
|
|
21
|
+
readonly storageCode: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* PARTS_MISSING only: the part numbers the client must upload again before it retries `/complete`. The one field
|
|
24
|
+
* besides `code`, `message` and `retryable` that reaches the client. Undefined for every other code.
|
|
25
|
+
*/
|
|
26
|
+
readonly parts: readonly number[] | undefined;
|
|
27
|
+
/** The file of a job this error belongs to; undefined for an error of the whole job or of the server. */
|
|
28
|
+
readonly file: {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
constructor(code: CloudropErrorCode, message: string, options?: CloudropErrorOptions);
|
|
33
|
+
}
|
|
34
|
+
type Result<T> = {
|
|
35
|
+
data: T;
|
|
36
|
+
error: null;
|
|
37
|
+
} | {
|
|
38
|
+
data: null;
|
|
39
|
+
error: CloudropError;
|
|
40
|
+
};
|
|
41
|
+
/** The four JSON endpoints, each at `<basePath>/<endpoint>`, all `POST`. */
|
|
42
|
+
type Endpoint = "upload" | "sign" | "complete" | "abort";
|
|
43
|
+
/** What the client knows about a file before it uploads it. `type` may be "" (the browser does not know it). */
|
|
44
|
+
interface FileDescriptor {
|
|
45
|
+
name: string;
|
|
46
|
+
size: number;
|
|
47
|
+
type: string;
|
|
48
|
+
}
|
|
49
|
+
interface UploadRequest {
|
|
50
|
+
route: string;
|
|
51
|
+
files: FileDescriptor[];
|
|
52
|
+
metadata?: unknown;
|
|
53
|
+
/**
|
|
54
|
+
* 16 to 128 characters of `[A-Za-z0-9_-]`, new for each ask and the same on every retry of it. With a store, a
|
|
55
|
+
* retry supersedes the rows its earlier attempt reserved, whose answer the client never had. Never reuse a key for a
|
|
56
|
+
* new ask: a request with a key ends the pending uploads of earlier requests with the same key, route and owner. On
|
|
57
|
+
* a route without `owner`, or when it answers null, the key does nothing.
|
|
58
|
+
*/
|
|
59
|
+
idempotencyKey?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A presigned `PUT`. Send exactly `headers`, no more: every header is signed, and R2 rejects an unsigned
|
|
63
|
+
* `x-amz-meta-*` header. Never set Content-Length: its value is signed, and the platform derives it from the body.
|
|
64
|
+
*/
|
|
65
|
+
interface SignedRequest {
|
|
66
|
+
url: string;
|
|
67
|
+
headers: Record<string, string>;
|
|
68
|
+
/** ISO 8601. Renew through `/sign` before it passes. */
|
|
69
|
+
expiresAt: string;
|
|
70
|
+
}
|
|
71
|
+
interface SignedPart extends SignedRequest {
|
|
72
|
+
partNumber: number;
|
|
73
|
+
}
|
|
74
|
+
interface TicketFields {
|
|
75
|
+
id: string;
|
|
76
|
+
key: string;
|
|
77
|
+
/** Present it to `/sign`, `/complete` and `/abort`. */
|
|
78
|
+
token: string;
|
|
79
|
+
/** ISO 8601: when the token, and with it the chance to resume, expires. */
|
|
80
|
+
expiresAt: string;
|
|
81
|
+
}
|
|
82
|
+
interface SingleTicket extends TicketFields {
|
|
83
|
+
kind: "single";
|
|
84
|
+
put: SignedRequest;
|
|
85
|
+
}
|
|
86
|
+
interface MultipartTicket extends TicketFields {
|
|
87
|
+
kind: "multipart";
|
|
88
|
+
/** Every part except the last has exactly this many bytes. */
|
|
89
|
+
partSize: number;
|
|
90
|
+
partCount: number;
|
|
91
|
+
/** URLs for the first parts, at most PARTS_PER_SIGN; ask `/sign` for the rest. */
|
|
92
|
+
parts: SignedPart[];
|
|
93
|
+
}
|
|
94
|
+
/** A file the server refused (size, type, or a storage failure); the request's other files go on. */
|
|
95
|
+
interface RejectedFile {
|
|
96
|
+
kind: "rejected";
|
|
97
|
+
error: ErrorBody;
|
|
98
|
+
}
|
|
99
|
+
type FileTicket = SingleTicket | MultipartTicket | RejectedFile;
|
|
100
|
+
/** One ticket per requested file, in request order. */
|
|
101
|
+
interface UploadResponse {
|
|
102
|
+
files: FileTicket[];
|
|
103
|
+
}
|
|
104
|
+
/** `parts` is required for a multipart upload and must be absent for a single PUT. */
|
|
105
|
+
interface SignRequest {
|
|
106
|
+
token: string;
|
|
107
|
+
parts?: number[];
|
|
108
|
+
}
|
|
109
|
+
type SignResponse = {
|
|
110
|
+
put: SignedRequest;
|
|
111
|
+
} | {
|
|
112
|
+
parts: SignedPart[];
|
|
113
|
+
};
|
|
114
|
+
interface CompleteRequest {
|
|
115
|
+
token: string;
|
|
116
|
+
}
|
|
117
|
+
interface UploadedFile {
|
|
118
|
+
/** Stable across retries and copies; stored as `x-amz-meta-cloudrop-id`. */
|
|
119
|
+
id: string;
|
|
120
|
+
key: string;
|
|
121
|
+
name: string;
|
|
122
|
+
size: number;
|
|
123
|
+
type: string;
|
|
124
|
+
/** The public URL on a public route, otherwise null (use `api.getUrl`). */
|
|
125
|
+
url: string | null;
|
|
126
|
+
}
|
|
127
|
+
interface CompleteResponse<TResult = unknown> {
|
|
128
|
+
file: UploadedFile;
|
|
129
|
+
/** What the route's `onComplete` returned, or null without one. */
|
|
130
|
+
data: TResult;
|
|
131
|
+
}
|
|
132
|
+
interface AbortRequest {
|
|
133
|
+
token: string;
|
|
134
|
+
/**
|
|
135
|
+
* Without a store's row, never delete an object that landed, even while the token is valid: only an unfinished
|
|
136
|
+
* multipart upload is aborted. With a row it changes nothing: a pending row proves no completion committed, and a
|
|
137
|
+
* completed one is kept anyway. The client's discard() sends it, for an upload a /complete may have finished.
|
|
138
|
+
*/
|
|
139
|
+
keep?: boolean;
|
|
140
|
+
}
|
|
141
|
+
interface AbortResponse {
|
|
142
|
+
id: string;
|
|
143
|
+
}
|
|
144
|
+
interface ErrorBody {
|
|
145
|
+
code: CloudropErrorCode;
|
|
146
|
+
message: string;
|
|
147
|
+
retryable: boolean;
|
|
148
|
+
/** PARTS_MISSING only: the part numbers to upload again. */
|
|
149
|
+
parts?: number[];
|
|
150
|
+
}
|
|
151
|
+
/** Every non-2xx response has this body. */
|
|
152
|
+
interface ErrorResponse {
|
|
153
|
+
error: ErrorBody;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Approximately what a value becomes after JSON.stringify and JSON.parse, for JSON-shaped data such as an authorize
|
|
157
|
+
* result or schema output: a `toJSON` value (a Date) becomes its JSON form, and function, symbol and undefined
|
|
158
|
+
* properties vanish. It does not model every JavaScript object: in arrays JSON turns undefined and functions into
|
|
159
|
+
* null, a `T | undefined` property is typed as present though JSON may drop it, and a Map, a Set or a class instance is
|
|
160
|
+
* typed by its own fields while JSON keeps only own enumerable properties (a Map becomes `{}`). Return plain data.
|
|
161
|
+
*/
|
|
162
|
+
type Jsonified<T> = unknown extends T ? unknown : T extends {
|
|
163
|
+
toJSON(): infer J;
|
|
164
|
+
} ? Jsonified<J> : T extends string | number | boolean | null ? T : T extends undefined | symbol | bigint | ((...args: never[]) => unknown) ? never : T extends readonly (infer E)[] ? Jsonified<E>[] : T extends object ? { [K in keyof T as K extends string | number ? Jsonified<T[K]> extends never ? never : K : never]: Jsonified<T[K]>; } : never;
|
|
165
|
+
/** The types the client reads from a route. */
|
|
166
|
+
interface RouteTypes {
|
|
167
|
+
metadata: unknown;
|
|
168
|
+
result: unknown;
|
|
169
|
+
}
|
|
170
|
+
/** Implemented by the server's `Cloudrop`. The client reads it through `import type` only. */
|
|
171
|
+
interface InferableCloudrop<TRoutes extends Record<string, RouteTypes> = Record<string, RouteTypes>> {
|
|
172
|
+
/** Type-only: never set at runtime. */
|
|
173
|
+
readonly "~routes"?: TRoutes;
|
|
174
|
+
}
|
|
175
|
+
type RoutesOf<TCloudrop> = TCloudrop extends InferableCloudrop<infer TRoutes> ? TRoutes : never;
|
|
176
|
+
type RouteName<TCloudrop> = keyof RoutesOf<TCloudrop> & string;
|
|
177
|
+
/** The metadata a client sends to the route: the schema's input type, or undefined for a route without a schema. */
|
|
178
|
+
type RouteMetadata<TCloudrop, TName extends RouteName<TCloudrop>> = RoutesOf<TCloudrop>[TName]["metadata"];
|
|
179
|
+
/** What `/complete` returns as `data` for the route: the JSON form of its `onComplete` result. */
|
|
180
|
+
type RouteResult<TCloudrop, TName extends RouteName<TCloudrop>> = RoutesOf<TCloudrop>[TName]["result"];
|
|
181
|
+
/** What both framework adapters accept: anything with a Web `Request` handler, such as `Cloudrop`. */
|
|
182
|
+
interface RequestHandler {
|
|
183
|
+
handler(request: Request): Promise<Response>;
|
|
184
|
+
}
|
|
185
|
+
export { UploadRequest as C, CloudropErrorCode as D, CloudropError as E, CloudropErrorOptions as O, SingleTicket as S, UploadedFile as T, RouteResult as _, Endpoint as a, SignedPart as b, FileDescriptor as c, Jsonified as d, MultipartTicket as f, RouteName as g, RouteMetadata as h, CompleteResponse as i, Result as k, FileTicket as l, RequestHandler as m, AbortResponse as n, ErrorBody as o, RejectedFile as p, CompleteRequest as r, ErrorResponse as s, AbortRequest as t, InferableCloudrop as u, SignRequest as v, UploadResponse as w, SignedRequest as x, SignResponse as y };
|
package/package.json
CHANGED
|
@@ -1,8 +1,112 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudrop",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Fast, resumable, direct-to-bucket file uploads for Cloudflare R2 and S3-compatible storage.
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fast, resumable, direct-to-bucket file uploads for Cloudflare R2 and S3-compatible storage.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/vcode-sh/cloudrop.git",
|
|
9
|
+
"directory": "packages/cloudrop"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/vcode-sh/cloudrop#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/vcode-sh/cloudrop/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"CHANGELOG.md"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=24"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./next": {
|
|
33
|
+
"types": "./dist/next.d.ts",
|
|
34
|
+
"default": "./dist/next.js"
|
|
35
|
+
},
|
|
36
|
+
"./node": {
|
|
37
|
+
"types": "./dist/node.d.ts",
|
|
38
|
+
"default": "./dist/node.js"
|
|
39
|
+
},
|
|
40
|
+
"./client": {
|
|
41
|
+
"types": "./dist/client.d.ts",
|
|
42
|
+
"default": "./dist/client.js"
|
|
43
|
+
},
|
|
44
|
+
"./react": {
|
|
45
|
+
"types": "./dist/react.d.ts",
|
|
46
|
+
"default": "./dist/react.js"
|
|
47
|
+
},
|
|
48
|
+
"./adapters/sql": {
|
|
49
|
+
"types": "./dist/adapters/sql.d.ts",
|
|
50
|
+
"default": "./dist/adapters/sql.js"
|
|
51
|
+
},
|
|
52
|
+
"./adapters/drizzle": {
|
|
53
|
+
"types": "./dist/adapters/drizzle.d.ts",
|
|
54
|
+
"default": "./dist/adapters/drizzle.js"
|
|
55
|
+
},
|
|
56
|
+
"./adapters/prisma": {
|
|
57
|
+
"types": "./dist/adapters/prisma.d.ts",
|
|
58
|
+
"default": "./dist/adapters/prisma.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsdown",
|
|
63
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
64
|
+
"test": "vitest run --project unit",
|
|
65
|
+
"package:check": "../../scripts/check-package.sh"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"drizzle-orm": ">=0.45.0 <1 || >=1.0.0-rc.5 <2",
|
|
69
|
+
"react": ">=18"
|
|
70
|
+
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"drizzle-orm": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"react": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
81
|
+
"@cloudflare/workers-types": "5.20261113.1",
|
|
82
|
+
"@libsql/client": "^0.18.0",
|
|
83
|
+
"@prisma/adapter-better-sqlite3": "^7.10.1",
|
|
84
|
+
"@prisma/adapter-pg": "^7.10.1",
|
|
85
|
+
"@prisma/client": "^7.10.1",
|
|
86
|
+
"@size-limit/esbuild": "^14.3.0",
|
|
87
|
+
"@size-limit/file": "^14.3.0",
|
|
88
|
+
"@testing-library/dom": "^10.4.2",
|
|
89
|
+
"@testing-library/react": "^16.3.3",
|
|
90
|
+
"@types/better-sqlite3": "^9.6.0",
|
|
91
|
+
"@types/node": "^24",
|
|
92
|
+
"@types/pg": "^8.23.1",
|
|
93
|
+
"@types/react": "^19.3.0",
|
|
94
|
+
"@types/react-dom": "^19.3.0",
|
|
95
|
+
"aws4fetch": "^1.0.20",
|
|
96
|
+
"better-sqlite3": "^12.11.1",
|
|
97
|
+
"drizzle-orm": "1.0.0-rc.5",
|
|
98
|
+
"fast-check": "^4.10.2",
|
|
99
|
+
"happy-dom": "^21.0.4",
|
|
100
|
+
"pg": "^8.23.1",
|
|
101
|
+
"postgres": "^4.0.0",
|
|
102
|
+
"prisma": "^7.10.1",
|
|
103
|
+
"publint": "^0.3.25",
|
|
104
|
+
"react": "^19.3.1",
|
|
105
|
+
"react-dom": "^19.3.1",
|
|
106
|
+
"size-limit": "^14.3.0",
|
|
107
|
+
"tsdown": "^0.23.7",
|
|
108
|
+
"typescript": "^7.0.2",
|
|
109
|
+
"vitest": "^5.1.0",
|
|
110
|
+
"wrangler": "^4.162.0"
|
|
111
|
+
}
|
|
8
112
|
}
|