@prisma-next/utils 0.12.0 → 0.13.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array-equal.d.mts.map +1 -1
- package/dist/assertions.d.mts +1 -1
- package/dist/assertions.d.mts.map +1 -1
- package/dist/assertions.mjs +1 -1
- package/dist/assertions.mjs.map +1 -1
- package/dist/canonical-stringify.mjs.map +1 -1
- package/dist/{casts-D2-X_DNw.mjs → casts-DpaahrlC.mjs} +1 -1
- package/dist/{casts-D2-X_DNw.mjs.map → casts-DpaahrlC.mjs.map} +1 -1
- package/dist/casts.d.mts.map +1 -1
- package/dist/casts.mjs +1 -1
- package/dist/{defined-BnXRnErx.mjs → defined-BB-H4E45.mjs} +1 -1
- package/dist/{defined-BnXRnErx.mjs.map → defined-BB-H4E45.mjs.map} +1 -1
- package/dist/defined.d.mts.map +1 -1
- package/dist/defined.mjs +1 -1
- package/dist/hash-content.mjs.map +1 -1
- package/dist/json.d.mts +1 -1
- package/dist/redact-db-url.mjs +1 -1
- package/dist/result.d.mts.map +1 -1
- package/dist/result.mjs +1 -1
- package/dist/simplify-deep.d.mts +1 -1
- package/package.json +5 -5
- package/src/assertions.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-equal.d.mts","names":[],"sources":["../src/array-equal.ts"],"mappings":";;AAgBA;;;;;;;;;;AAAgE;;;;;iBAAhD,YAAA,
|
|
1
|
+
{"version":3,"file":"array-equal.d.mts","names":[],"sources":["../src/array-equal.ts"],"mappings":";;AAgBA;;;;;;;;;;AAAgE;;;;;iBAAhD,YAAA,IAAgB,CAAA,WAAY,CAAA,IAAK,CAAA,WAAY,CAAC"}
|
package/dist/assertions.d.mts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* const table = storage.namespaces[namespaceId].
|
|
10
|
+
* const table = storage.namespaces[namespaceId].entries.table[tableName];
|
|
11
11
|
* assertDefined(table, `Table "${tableName}" not found`);
|
|
12
12
|
* // table is now narrowed to non-nullable
|
|
13
13
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.mts","names":[],"sources":["../src/assertions.ts"],"mappings":";;AAaA;;;;;;;;;;;AAAkG;iBAAlF,aAAA,
|
|
1
|
+
{"version":3,"file":"assertions.d.mts","names":[],"sources":["../src/assertions.ts"],"mappings":";;AAaA;;;;;;;;;;;AAAkG;iBAAlF,aAAA,IAAiB,KAAA,EAAO,CAAA,qBAAsB,OAAA,mBAA0B,KAAA,IAAS,CAAC;;;;;;;;AAiBjB;;;;iBAAjE,SAAA,CAAU,SAAA,WAAoB,OAAA,mBAA0B,SAAA"}
|
package/dist/assertions.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* const table = storage.namespaces[namespaceId].
|
|
10
|
+
* const table = storage.namespaces[namespaceId].entries.table[tableName];
|
|
11
11
|
* assertDefined(table, `Table "${tableName}" not found`);
|
|
12
12
|
* // table is now narrowed to non-nullable
|
|
13
13
|
* ```
|
package/dist/assertions.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.mjs","names":[],"sources":["../src/assertions.ts"],"sourcesContent":["/**\n * Asserts that a value is defined (not null or undefined).\n * Use for invariants where the value should always exist at runtime.\n *\n * @throws Error if value is null or undefined\n *\n * @example\n * ```typescript\n * const table = storage.namespaces[namespaceId].
|
|
1
|
+
{"version":3,"file":"assertions.mjs","names":[],"sources":["../src/assertions.ts"],"sourcesContent":["/**\n * Asserts that a value is defined (not null or undefined).\n * Use for invariants where the value should always exist at runtime.\n *\n * @throws Error if value is null or undefined\n *\n * @example\n * ```typescript\n * const table = storage.namespaces[namespaceId].entries.table[tableName];\n * assertDefined(table, `Table \"${tableName}\" not found`);\n * // table is now narrowed to non-nullable\n * ```\n */\nexport function assertDefined<T>(value: T | null | undefined, message: string): asserts value is T {\n if (value === null || value === undefined) {\n throw new Error(message);\n }\n}\n\n/**\n * Asserts that a condition is true.\n * Use for invariants that should always hold at runtime.\n *\n * @throws Error if condition is false\n *\n * @example\n * ```typescript\n * invariant(columns.length > 0, 'Primary key must have at least one column');\n * ```\n */\nexport function invariant(condition: boolean, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,SAAgB,cAAiB,OAA6B,SAAqC;CACjG,IAAI,UAAU,QAAQ,UAAU,KAAA,GAC9B,MAAM,IAAI,MAAM,OAAO;AAE3B;;;;;;;;;;;;AAaA,SAAgB,UAAU,WAAoB,SAAoC;CAChF,IAAI,CAAC,WACH,MAAM,IAAI,MAAM,OAAO;AAE3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonical-stringify.mjs","names":[],"sources":["../src/canonical-stringify.ts"],"sourcesContent":["/**\n * Produces a deterministic, JSON-like string representation of a value.\n *\n * Designed for use as a stable identity / cache key. Two values that are\n * structurally equivalent — regardless of object key insertion order —\n * produce the same string. Two values that differ in any meaningful way\n * (including types that JSON would conflate, like `BigInt(1)` vs `1`)\n * produce different strings.\n *\n * Supported inputs:\n * - `null`, `undefined` (distinguishable: `null` → `\"null\"`, `undefined` → `\"undefined\"`)\n * - `boolean`, `string`, `number` (including `NaN`, `Infinity`, `-Infinity`)\n * - `bigint` (suffixed with `n` to disambiguate from `number`)\n * - `Date` (tagged + ISO string)\n * - `Buffer` / `Uint8Array` (tagged + hex-encoded as `Bytes(<hex>)`)\n * - Other `ArrayBuffer` views — `Int8Array`, `Uint16Array`, `Float64Array`,\n * `DataView`, etc. (tagged with the constructor name + hex-encoded over\n * the underlying bytes, e.g. `Uint16Array(<hex>)`). Note that the bytes\n * are read in host byte order, so callers that need cross-platform\n * stability for multi-byte typed arrays should normalize endianness\n * before passing the value in.\n * - Arrays (order-preserving)\n * - Plain objects (key-sorted) — only objects whose prototype is\n * `Object.prototype` or `null`. Non-plain objects (`Map`, `Set`,\n * `RegExp`, class instances, etc.) are rejected so they cannot silently\n * collapse to `{}` and collide with each other.\n *\n * Throws on `function`, `symbol`, circular references, non-plain objects,\n * and objects with symbol-keyed properties (which `Object.keys` would\n * silently drop). Callers that need to canonicalize any of these must\n * convert them to a supported representation first.\n *\n * The output format is intentionally not JSON: the type tags and BigInt\n * suffix mean it cannot be round-tripped via `JSON.parse`. The goal is\n * keying, not serialization.\n *\n * @example\n * ```typescript\n * canonicalStringify({ a: 1, b: 2 }) === canonicalStringify({ b: 2, a: 1 })\n * // → true\n *\n * canonicalStringify(1n) !== canonicalStringify(1)\n * // → true\n * ```\n */\nexport function canonicalStringify(value: unknown): string {\n return write(value, new Set());\n}\n\nfunction write(value: unknown, seen: Set<object>): string {\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n\n switch (typeof value) {\n case 'boolean':\n return value ? 'true' : 'false';\n case 'number':\n return writeNumber(value);\n case 'bigint':\n return `${value.toString()}n`;\n case 'string':\n return JSON.stringify(value);\n case 'function':\n throw new TypeError('canonicalStringify: functions are not supported');\n case 'symbol':\n throw new TypeError('canonicalStringify: symbols are not supported');\n }\n\n // From here, value is a non-null object.\n const obj = value as object;\n\n // Leaf object types are handled before touching `seen`: they can never\n // contain back-references, so cycle tracking is wasted work for them.\n if (value instanceof Date) {\n return `Date(${value.toISOString()})`;\n }\n\n // `Buffer` is a `Uint8Array` subclass; this branch covers both, and\n // emits the legacy `Bytes(<hex>)` tag so a `Buffer` and a same-content\n // `Uint8Array` digest identically.\n if (value instanceof Uint8Array) {\n return `Bytes(${bytesToHex(value)})`;\n }\n\n // Any other `ArrayBuffer` view — typed arrays (`Int8Array`,\n // `Uint16Array`, `Float64Array`, …) and `DataView`. Without this\n // branch they would fall through to the plain-object writer and\n // canonicalize as `{\"0\":1,\"1\":2,...}`, which would silently collide\n // with a same-keyed plain object. Tagging by constructor name keeps\n // distinct view families distinct.\n if (ArrayBuffer.isView(value)) {\n const tag = value.constructor.name;\n const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n return `${tag}(${bytesToHex(bytes)})`;\n }\n\n if (seen.has(obj)) {\n throw new TypeError('canonicalStringify: circular reference detected');\n }\n seen.add(obj);\n try {\n if (Array.isArray(value)) {\n const parts = value.map((item) => write(item, seen));\n return `[${parts.join(',')}]`;\n }\n\n return writePlainObject(obj as Record<string, unknown>, seen);\n } finally {\n seen.delete(obj);\n }\n}\n\nfunction writeNumber(value: number): string {\n if (Number.isNaN(value)) return 'NaN';\n if (value === Number.POSITIVE_INFINITY) return 'Infinity';\n if (value === Number.NEGATIVE_INFINITY) return '-Infinity';\n // Distinguish `+0` from `-0` so they hash differently.\n if (value === 0 && 1 / value === Number.NEGATIVE_INFINITY) return '-0';\n return String(value);\n}\n\nfunction writePlainObject(obj: Record<string, unknown>, seen: Set<object>): string {\n // Only true plain objects are accepted here. Without this guard, anything\n // that fell through the type-tagged branches above (`Map`, `Set`,\n // `RegExp`, class instances, …) would canonicalize to `{}` because\n // `Object.keys` returns no enumerable string keys for them — silently\n // colliding with each other and with the literal `{}`.\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) {\n const tag = proto?.constructor?.name ?? 'unknown';\n throw new TypeError(`canonicalStringify: non-plain objects are not supported (got ${tag})`);\n }\n\n // `Object.keys` ignores symbol-keyed properties, so they would be\n // silently dropped from the canonical form. Force callers to handle\n // them explicitly instead of producing a key that omits real data.\n if (Object.getOwnPropertySymbols(obj).length > 0) {\n throw new TypeError(\n 'canonicalStringify: objects with symbol-keyed properties are not supported',\n );\n }\n\n const keys = Object.keys(obj).sort();\n const parts: string[] = [];\n for (const key of keys) {\n parts.push(`${JSON.stringify(key)}:${write(obj[key], seen)}`);\n }\n return `{${parts.join(',')}}`;\n}\n\nfunction bytesToHex(bytes: Uint8Array): string {\n let out = '';\n for (let i = 0; i < bytes.length; i++) {\n const byte = bytes[i] as number;\n out += byte.toString(16).padStart(2, '0');\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,mBAAmB,OAAwB;CACzD,OAAO,MAAM,uBAAO,IAAI,IAAI,CAAC;AAC/B;AAEA,SAAS,MAAM,OAAgB,MAA2B;CACxD,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,UAAU,KAAA,GAAW,OAAO;CAEhC,QAAQ,OAAO,OAAf;EACE,KAAK,WACH,OAAO,QAAQ,SAAS;EAC1B,KAAK,UACH,OAAO,YAAY,KAAK;EAC1B,KAAK,UACH,OAAO,GAAG,MAAM,SAAS,EAAE;EAC7B,KAAK,UACH,OAAO,KAAK,UAAU,KAAK;EAC7B,KAAK,YACH,MAAM,IAAI,UAAU,iDAAiD;EACvE,KAAK,UACH,MAAM,IAAI,UAAU,+CAA+C;CACvE;CAGA,MAAM,MAAM;CAIZ,IAAI,iBAAiB,MACnB,OAAO,QAAQ,MAAM,YAAY,EAAE;CAMrC,IAAI,iBAAiB,YACnB,OAAO,SAAS,WAAW,KAAK,EAAE;CASpC,IAAI,YAAY,OAAO,KAAK,GAG1B,OAAO,GAFK,MAAM,YAAY,KAEhB,GAAG,WAAW,IADV,WAAW,MAAM,QAAQ,MAAM,YAAY,MAAM,UACnC,CAAC,EAAE;CAGrC,IAAI,KAAK,IAAI,GAAG,GACd,MAAM,IAAI,UAAU,iDAAiD;CAEvE,KAAK,IAAI,GAAG;CACZ,IAAI;EACF,IAAI,MAAM,QAAQ,KAAK,GAErB,OAAO,IADO,MAAM,KAAK,SAAS,MAAM,MAAM,IAAI,CACnC,
|
|
1
|
+
{"version":3,"file":"canonical-stringify.mjs","names":[],"sources":["../src/canonical-stringify.ts"],"sourcesContent":["/**\n * Produces a deterministic, JSON-like string representation of a value.\n *\n * Designed for use as a stable identity / cache key. Two values that are\n * structurally equivalent — regardless of object key insertion order —\n * produce the same string. Two values that differ in any meaningful way\n * (including types that JSON would conflate, like `BigInt(1)` vs `1`)\n * produce different strings.\n *\n * Supported inputs:\n * - `null`, `undefined` (distinguishable: `null` → `\"null\"`, `undefined` → `\"undefined\"`)\n * - `boolean`, `string`, `number` (including `NaN`, `Infinity`, `-Infinity`)\n * - `bigint` (suffixed with `n` to disambiguate from `number`)\n * - `Date` (tagged + ISO string)\n * - `Buffer` / `Uint8Array` (tagged + hex-encoded as `Bytes(<hex>)`)\n * - Other `ArrayBuffer` views — `Int8Array`, `Uint16Array`, `Float64Array`,\n * `DataView`, etc. (tagged with the constructor name + hex-encoded over\n * the underlying bytes, e.g. `Uint16Array(<hex>)`). Note that the bytes\n * are read in host byte order, so callers that need cross-platform\n * stability for multi-byte typed arrays should normalize endianness\n * before passing the value in.\n * - Arrays (order-preserving)\n * - Plain objects (key-sorted) — only objects whose prototype is\n * `Object.prototype` or `null`. Non-plain objects (`Map`, `Set`,\n * `RegExp`, class instances, etc.) are rejected so they cannot silently\n * collapse to `{}` and collide with each other.\n *\n * Throws on `function`, `symbol`, circular references, non-plain objects,\n * and objects with symbol-keyed properties (which `Object.keys` would\n * silently drop). Callers that need to canonicalize any of these must\n * convert them to a supported representation first.\n *\n * The output format is intentionally not JSON: the type tags and BigInt\n * suffix mean it cannot be round-tripped via `JSON.parse`. The goal is\n * keying, not serialization.\n *\n * @example\n * ```typescript\n * canonicalStringify({ a: 1, b: 2 }) === canonicalStringify({ b: 2, a: 1 })\n * // → true\n *\n * canonicalStringify(1n) !== canonicalStringify(1)\n * // → true\n * ```\n */\nexport function canonicalStringify(value: unknown): string {\n return write(value, new Set());\n}\n\nfunction write(value: unknown, seen: Set<object>): string {\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n\n switch (typeof value) {\n case 'boolean':\n return value ? 'true' : 'false';\n case 'number':\n return writeNumber(value);\n case 'bigint':\n return `${value.toString()}n`;\n case 'string':\n return JSON.stringify(value);\n case 'function':\n throw new TypeError('canonicalStringify: functions are not supported');\n case 'symbol':\n throw new TypeError('canonicalStringify: symbols are not supported');\n }\n\n // From here, value is a non-null object.\n const obj = value as object;\n\n // Leaf object types are handled before touching `seen`: they can never\n // contain back-references, so cycle tracking is wasted work for them.\n if (value instanceof Date) {\n return `Date(${value.toISOString()})`;\n }\n\n // `Buffer` is a `Uint8Array` subclass; this branch covers both, and\n // emits the legacy `Bytes(<hex>)` tag so a `Buffer` and a same-content\n // `Uint8Array` digest identically.\n if (value instanceof Uint8Array) {\n return `Bytes(${bytesToHex(value)})`;\n }\n\n // Any other `ArrayBuffer` view — typed arrays (`Int8Array`,\n // `Uint16Array`, `Float64Array`, …) and `DataView`. Without this\n // branch they would fall through to the plain-object writer and\n // canonicalize as `{\"0\":1,\"1\":2,...}`, which would silently collide\n // with a same-keyed plain object. Tagging by constructor name keeps\n // distinct view families distinct.\n if (ArrayBuffer.isView(value)) {\n const tag = value.constructor.name;\n const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n return `${tag}(${bytesToHex(bytes)})`;\n }\n\n if (seen.has(obj)) {\n throw new TypeError('canonicalStringify: circular reference detected');\n }\n seen.add(obj);\n try {\n if (Array.isArray(value)) {\n const parts = value.map((item) => write(item, seen));\n return `[${parts.join(',')}]`;\n }\n\n return writePlainObject(obj as Record<string, unknown>, seen);\n } finally {\n seen.delete(obj);\n }\n}\n\nfunction writeNumber(value: number): string {\n if (Number.isNaN(value)) return 'NaN';\n if (value === Number.POSITIVE_INFINITY) return 'Infinity';\n if (value === Number.NEGATIVE_INFINITY) return '-Infinity';\n // Distinguish `+0` from `-0` so they hash differently.\n if (value === 0 && 1 / value === Number.NEGATIVE_INFINITY) return '-0';\n return String(value);\n}\n\nfunction writePlainObject(obj: Record<string, unknown>, seen: Set<object>): string {\n // Only true plain objects are accepted here. Without this guard, anything\n // that fell through the type-tagged branches above (`Map`, `Set`,\n // `RegExp`, class instances, …) would canonicalize to `{}` because\n // `Object.keys` returns no enumerable string keys for them — silently\n // colliding with each other and with the literal `{}`.\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) {\n const tag = proto?.constructor?.name ?? 'unknown';\n throw new TypeError(`canonicalStringify: non-plain objects are not supported (got ${tag})`);\n }\n\n // `Object.keys` ignores symbol-keyed properties, so they would be\n // silently dropped from the canonical form. Force callers to handle\n // them explicitly instead of producing a key that omits real data.\n if (Object.getOwnPropertySymbols(obj).length > 0) {\n throw new TypeError(\n 'canonicalStringify: objects with symbol-keyed properties are not supported',\n );\n }\n\n const keys = Object.keys(obj).sort();\n const parts: string[] = [];\n for (const key of keys) {\n parts.push(`${JSON.stringify(key)}:${write(obj[key], seen)}`);\n }\n return `{${parts.join(',')}}`;\n}\n\nfunction bytesToHex(bytes: Uint8Array): string {\n let out = '';\n for (let i = 0; i < bytes.length; i++) {\n const byte = bytes[i] as number;\n out += byte.toString(16).padStart(2, '0');\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,mBAAmB,OAAwB;CACzD,OAAO,MAAM,uBAAO,IAAI,IAAI,CAAC;AAC/B;AAEA,SAAS,MAAM,OAAgB,MAA2B;CACxD,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,UAAU,KAAA,GAAW,OAAO;CAEhC,QAAQ,OAAO,OAAf;EACE,KAAK,WACH,OAAO,QAAQ,SAAS;EAC1B,KAAK,UACH,OAAO,YAAY,KAAK;EAC1B,KAAK,UACH,OAAO,GAAG,MAAM,SAAS,EAAE;EAC7B,KAAK,UACH,OAAO,KAAK,UAAU,KAAK;EAC7B,KAAK,YACH,MAAM,IAAI,UAAU,iDAAiD;EACvE,KAAK,UACH,MAAM,IAAI,UAAU,+CAA+C;CACvE;CAGA,MAAM,MAAM;CAIZ,IAAI,iBAAiB,MACnB,OAAO,QAAQ,MAAM,YAAY,EAAE;CAMrC,IAAI,iBAAiB,YACnB,OAAO,SAAS,WAAW,KAAK,EAAE;CASpC,IAAI,YAAY,OAAO,KAAK,GAG1B,OAAO,GAFK,MAAM,YAAY,KAEhB,GAAG,WAAW,IADV,WAAW,MAAM,QAAQ,MAAM,YAAY,MAAM,UACnC,CAAC,EAAE;CAGrC,IAAI,KAAK,IAAI,GAAG,GACd,MAAM,IAAI,UAAU,iDAAiD;CAEvE,KAAK,IAAI,GAAG;CACZ,IAAI;EACF,IAAI,MAAM,QAAQ,KAAK,GAErB,OAAO,IADO,MAAM,KAAK,SAAS,MAAM,MAAM,IAAI,CACnC,CAAC,CAAC,KAAK,GAAG,EAAE;EAG7B,OAAO,iBAAiB,KAAgC,IAAI;CAC9D,UAAU;EACR,KAAK,OAAO,GAAG;CACjB;AACF;AAEA,SAAS,YAAY,OAAuB;CAC1C,IAAI,OAAO,MAAM,KAAK,GAAG,OAAO;CAChC,IAAI,UAAU,OAAO,mBAAmB,OAAO;CAC/C,IAAI,UAAU,OAAO,mBAAmB,OAAO;CAE/C,IAAI,UAAU,KAAK,IAAI,UAAU,OAAO,mBAAmB,OAAO;CAClE,OAAO,OAAO,KAAK;AACrB;AAEA,SAAS,iBAAiB,KAA8B,MAA2B;CAMjF,MAAM,QAAQ,OAAO,eAAe,GAAG;CACvC,IAAI,UAAU,OAAO,aAAa,UAAU,MAAM;EAChD,MAAM,MAAM,OAAO,aAAa,QAAQ;EACxC,MAAM,IAAI,UAAU,gEAAgE,IAAI,EAAE;CAC5F;CAKA,IAAI,OAAO,sBAAsB,GAAG,CAAC,CAAC,SAAS,GAC7C,MAAM,IAAI,UACR,4EACF;CAGF,MAAM,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,KAAK;CACnC,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,OAAO,MAChB,MAAM,KAAK,GAAG,KAAK,UAAU,GAAG,EAAE,GAAG,MAAM,IAAI,MAAM,IAAI,GAAG;CAE9D,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE;AAC7B;AAEA,SAAS,WAAW,OAA2B;CAC7C,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM;EACnB,OAAO,KAAK,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;CAC1C;CACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"casts-
|
|
1
|
+
{"version":3,"file":"casts-DpaahrlC.mjs","names":["x"],"sources":["../src/casts.ts"],"sourcesContent":["/**\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 */\nexport function blindCast<TargetType, _Reason extends string>(input: unknown): TargetType {\n // biome-ignore lint/suspicious/noExplicitAny: this helper is the single canonical escape hatch for type-unsafe casts in the codebase; the `any` is hyper-local, the unsafety is made explicit at every call site via the call's own `Reason` literal, and the reviewer evaluates whether that justification holds\n const x: any = input;\n return x;\n}\n\n/**\n * Type-checked, runtime pass-through alternative to a bare `as Type` cast.\n *\n * Use `castAs` when the value already satisfies the target type but you want to make\n * the type assertion explicit at the call site — for example, when an inferred type is\n * wider than the type you want to publish, or when a literal object should be tagged\n * with its nominal interface. Unlike {@link blindCast}, the compiler still checks that\n * the value is assignable to the target type, so this helper cannot smuggle in an\n * unsafe assertion.\n *\n * `castAs` exists alongside `blindCast` so authors pick the right name at the call\n * site: a `castAs` is type-checked and benign; a `blindCast` is the unsafe escape\n * hatch. The split makes review faster — readers know which casts to scrutinize and\n * which are pure annotations.\n *\n * @example\n * ```typescript\n * interface FancyObject {\n * key: string;\n * keyTwo: {\n * subKey: string;\n * subKeyTwo: number;\n * };\n * }\n *\n * const typedObject = castAs<FancyObject>({\n * key: 'Chookede',\n * keyTwo: {\n * subKey: 'Choookeeeee',\n * subKeyTwo: 2,\n * },\n * });\n * ```\n *\n * @typeParam Type - The type to constrain and tag the value with. The value must be assignable to `Type`.\n */\nexport function castAs<Type>(value: Type): Type {\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,UAA8C,OAA4B;CAGxF,OAAOA;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,OAAa,OAAmB;CAC9C,OAAO;AACT"}
|
package/dist/casts.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"casts.d.mts","names":[],"sources":["../src/casts.ts"],"mappings":";;AAmCA;;;;;;;;;AAAyF;AA0CzF;;;;;;;;;AAA+C;;;;;;;;;;;;;;;iBA1C/B,SAAA,
|
|
1
|
+
{"version":3,"file":"casts.d.mts","names":[],"sources":["../src/casts.ts"],"mappings":";;AAmCA;;;;;;;;;AAAyF;AA0CzF;;;;;;;;;AAA+C;;;;;;;;;;;;;;;iBA1C/B,SAAA,qCAA8C,KAAA,YAAiB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0CzE,MAAA,OAAa,KAAA,EAAO,IAAA,GAAO,IAAI"}
|
package/dist/casts.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as castAs, t as blindCast } from "./casts-
|
|
1
|
+
import { n as castAs, t as blindCast } from "./casts-DpaahrlC.mjs";
|
|
2
2
|
export { blindCast, castAs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defined-
|
|
1
|
+
{"version":3,"file":"defined-BB-H4E45.mjs","names":[],"sources":["../src/defined.ts"],"sourcesContent":["/**\n * Returns an object with the key/value if value is defined, otherwise an empty object.\n *\n * Use with spread to conditionally include optional properties while satisfying\n * exactOptionalPropertyTypes. This is explicit about which properties are optional\n * and won't inadvertently strip other undefined values.\n *\n * @example\n * ```typescript\n * // Instead of:\n * const obj = {\n * required: 'value',\n * ...(optional ? { optional } : {}),\n * };\n *\n * // Use:\n * const obj = {\n * required: 'value',\n * ...ifDefined('optional', optional),\n * };\n * ```\n */\nexport function ifDefined<K extends string, V>(\n key: K,\n value: V | undefined,\n): Record<never, never> | { [P in K]: V } {\n return value !== undefined ? ({ [key]: value } as { [P in K]: V }) : {};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,UACd,KACA,OACwC;CACxC,OAAO,UAAU,KAAA,IAAa,GAAG,MAAM,MAAM,IAAwB,CAAC;AACxE"}
|
package/dist/defined.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defined.d.mts","names":[],"sources":["../src/defined.ts"],"mappings":";;AAsBA;;;;;;;;;;;;;;;;;;;;;iBAAgB,SAAA,
|
|
1
|
+
{"version":3,"file":"defined.d.mts","names":[],"sources":["../src/defined.ts"],"mappings":";;AAsBA;;;;;;;;;;;;;;;;;;;;;iBAAgB,SAAA,sBACd,GAAA,EAAK,CAAA,EACL,KAAA,EAAO,CAAA,eACN,MAAA,yBAA+B,CAAA,GAAI,CAAA"}
|
package/dist/defined.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ifDefined } from "./defined-
|
|
1
|
+
import { t as ifDefined } from "./defined-BB-H4E45.mjs";
|
|
2
2
|
export { ifDefined };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-content.mjs","names":[],"sources":["../src/hash-content.ts"],"sourcesContent":["/**\n * Hashes a canonical-string representation of an execution into a bounded,\n * opaque cache-key digest.\n *\n * Designed for use as the final step of `RuntimeMiddlewareContext.contentHash`\n * implementations: family runtimes compose a canonical string from\n * `meta.storageHash`, the rendered statement (or wire command), and\n * canonicalized parameters via `canonicalStringify`, then pipe the result\n * through this helper.\n *\n * Why hash the canonical string instead of using it directly as a `Map` key:\n *\n * 1. **Bounded memory.** A raw canonical key includes concrete parameter\n * values, so a query bound to a 10 MB JSON column or binary blob produces\n * a 10 MB cache key. With `maxEntries = 1000`, that scales to gigabytes\n * of cache keys alone. SHA-512 pins per-key cost at a fixed digest\n * length regardless of input size.\n *\n * 2. **Sensitive-data isolation.** The canonical string contains parameter\n * values verbatim. Cache keys flow into debug logs, Redis `KEYS`/`MONITOR`\n * output, persistence dumps, monitoring tools, and any user-supplied\n * `CacheStore` implementation. Hashing prevents PII / credentials /\n * tokens that appear in query parameters from showing up in any of those\n * surfaces.\n *\n * Algorithm choice — SHA-512 (`SHA-512` via the WebCrypto API):\n *\n * - **Portability.** WebCrypto (`globalThis.crypto.subtle`) is available in\n * every modern JavaScript runtime — Node, Deno, Bun, browsers, edge\n * workers — without importing a Node-specific module. This keeps the\n * helper usable in non-Node hosts where `node:crypto` is not available.\n * - **Collision space.** 512 bits of output makes accidental collisions\n * astronomically improbable — far beyond what a cache needs, but the\n * incremental cost over 256-bit output is negligible and the headroom\n * is free.\n * - **No additional dependency.** SHA-512 is part of the WebCrypto standard\n * set of digest algorithms; no third-party package needed.\n *\n * The function is `async` because the WebCrypto digest API is async by\n * design. Callers must await the result.\n *\n * Output format: `sha512:HEXDIGEST` (128-char hex with the algorithm tag\n * prefix). Self-describing so a future migration to a different hash\n * produces visibly distinct keys, and consistent with the\n * `sha256:HEXDIGEST` shape already used by `meta.storageHash`.\n *\n * @example\n * ```typescript\n * const canonical = `${exec.meta.storageHash}|${exec.sql}|${canonicalStringify(exec.params)}`;\n * return await hashContent(canonical);\n * // → 'sha512:8f3...e1c' (always 135 chars: 'sha512:' + 128 hex chars)\n * ```\n */\nexport async function hashContent(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-512', bytes);\n const hex = Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');\n return `sha512:${hex}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,eAAsB,YAAY,OAAgC;CAChE,MAAM,QAAQ,IAAI,YAAY,
|
|
1
|
+
{"version":3,"file":"hash-content.mjs","names":[],"sources":["../src/hash-content.ts"],"sourcesContent":["/**\n * Hashes a canonical-string representation of an execution into a bounded,\n * opaque cache-key digest.\n *\n * Designed for use as the final step of `RuntimeMiddlewareContext.contentHash`\n * implementations: family runtimes compose a canonical string from\n * `meta.storageHash`, the rendered statement (or wire command), and\n * canonicalized parameters via `canonicalStringify`, then pipe the result\n * through this helper.\n *\n * Why hash the canonical string instead of using it directly as a `Map` key:\n *\n * 1. **Bounded memory.** A raw canonical key includes concrete parameter\n * values, so a query bound to a 10 MB JSON column or binary blob produces\n * a 10 MB cache key. With `maxEntries = 1000`, that scales to gigabytes\n * of cache keys alone. SHA-512 pins per-key cost at a fixed digest\n * length regardless of input size.\n *\n * 2. **Sensitive-data isolation.** The canonical string contains parameter\n * values verbatim. Cache keys flow into debug logs, Redis `KEYS`/`MONITOR`\n * output, persistence dumps, monitoring tools, and any user-supplied\n * `CacheStore` implementation. Hashing prevents PII / credentials /\n * tokens that appear in query parameters from showing up in any of those\n * surfaces.\n *\n * Algorithm choice — SHA-512 (`SHA-512` via the WebCrypto API):\n *\n * - **Portability.** WebCrypto (`globalThis.crypto.subtle`) is available in\n * every modern JavaScript runtime — Node, Deno, Bun, browsers, edge\n * workers — without importing a Node-specific module. This keeps the\n * helper usable in non-Node hosts where `node:crypto` is not available.\n * - **Collision space.** 512 bits of output makes accidental collisions\n * astronomically improbable — far beyond what a cache needs, but the\n * incremental cost over 256-bit output is negligible and the headroom\n * is free.\n * - **No additional dependency.** SHA-512 is part of the WebCrypto standard\n * set of digest algorithms; no third-party package needed.\n *\n * The function is `async` because the WebCrypto digest API is async by\n * design. Callers must await the result.\n *\n * Output format: `sha512:HEXDIGEST` (128-char hex with the algorithm tag\n * prefix). Self-describing so a future migration to a different hash\n * produces visibly distinct keys, and consistent with the\n * `sha256:HEXDIGEST` shape already used by `meta.storageHash`.\n *\n * @example\n * ```typescript\n * const canonical = `${exec.meta.storageHash}|${exec.sql}|${canonicalStringify(exec.params)}`;\n * return await hashContent(canonical);\n * // → 'sha512:8f3...e1c' (always 135 chars: 'sha512:' + 128 hex chars)\n * ```\n */\nexport async function hashContent(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-512', bytes);\n const hex = Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');\n return `sha512:${hex}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,eAAsB,YAAY,OAAgC;CAChE,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CAC5C,MAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK;CAE1D,OAAO,UADK,MAAM,KAAK,IAAI,WAAW,MAAM,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EACzE;AACrB"}
|
package/dist/json.d.mts
CHANGED
|
@@ -21,5 +21,5 @@ type JsonObject = {
|
|
|
21
21
|
};
|
|
22
22
|
type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
23
23
|
//#endregion
|
|
24
|
-
export {
|
|
24
|
+
export type { JsonArray, JsonObject, JsonPrimitive, JsonValue };
|
|
25
25
|
//# sourceMappingURL=json.d.mts.map
|
package/dist/redact-db-url.mjs
CHANGED
package/dist/result.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.mts","names":[],"sources":["../src/result.ts"],"mappings":";;AAiBA;;;;;;;;;;;;AAIa;UAJI,EAAA;EAAA,SACN,EAAA;EAAA,SACA,KAAA,EAAO,CAAA;EAChB,QAAA,IAAY,CAAC;EACb,WAAA;AAAA;;;;UAMe,KAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA,EAAS,CAAA;EAClB,QAAA;EACA,WAAA,IAAe,CAAC;AAAA;;;;;;;KASN,MAAA,SAAe,EAAA,CAAG,CAAA,IAAK,KAAA,CAAM,CAAA;;;;iBAkFzB,EAAA,
|
|
1
|
+
{"version":3,"file":"result.d.mts","names":[],"sources":["../src/result.ts"],"mappings":";;AAiBA;;;;;;;;;;;;AAIa;UAJI,EAAA;EAAA,SACN,EAAA;EAAA,SACA,KAAA,EAAO,CAAA;EAChB,QAAA,IAAY,CAAC;EACb,WAAA;AAAA;;;;UAMe,KAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA,EAAS,CAAA;EAClB,QAAA;EACA,WAAA,IAAe,CAAC;AAAA;;;;;;;KASN,MAAA,SAAe,EAAA,CAAG,CAAA,IAAK,KAAA,CAAM,CAAA;;;;iBAkFzB,EAAA,IAAM,KAAA,EAAO,CAAA,GAAI,EAAA,CAAG,CAAA;;;;iBAOpB,KAAA,IAAS,OAAA,EAAS,CAAA,GAAI,KAAA,CAAM,CAAA;AAP5C;;;;AAAA,iBAqBgB,MAAA,IAAU,EAAE"}
|
package/dist/result.mjs
CHANGED
package/dist/simplify-deep.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/simplify-deep.d.ts
|
|
2
2
|
type SimplifyDeep<T> = T extends readonly (infer Element)[] ? T extends unknown[] ? SimplifyDeep<Element>[] : readonly SimplifyDeep<Element>[] : T extends string | number | boolean | bigint | symbol | Date | RegExp | Uint8Array | ((...args: never[]) => unknown) ? T : T extends object ? { [K in keyof T]: SimplifyDeep<T[K]> } : T;
|
|
3
3
|
//#endregion
|
|
4
|
-
export {
|
|
4
|
+
export type { SimplifyDeep };
|
|
5
5
|
//# sourceMappingURL=simplify-deep.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0-dev.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "Shared utility functions for Prisma Next",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@prisma-next/tsconfig": "0.
|
|
10
|
-
"@prisma-next/tsdown": "0.
|
|
11
|
-
"tsdown": "0.22.
|
|
9
|
+
"@prisma-next/tsconfig": "0.13.0-dev.2",
|
|
10
|
+
"@prisma-next/tsdown": "0.13.0-dev.2",
|
|
11
|
+
"tsdown": "0.22.1",
|
|
12
12
|
"typescript": "5.9.3",
|
|
13
|
-
"vitest": "4.1.
|
|
13
|
+
"vitest": "4.1.8"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"typescript": ">=5.9"
|
package/src/assertions.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* const table = storage.namespaces[namespaceId].
|
|
9
|
+
* const table = storage.namespaces[namespaceId].entries.table[tableName];
|
|
10
10
|
* assertDefined(table, `Table "${tableName}" not found`);
|
|
11
11
|
* // table is now narrowed to non-nullable
|
|
12
12
|
* ```
|