@prisma-next/utils 0.13.0-dev.31 → 0.13.0-dev.33

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.
@@ -1,3 +1,4 @@
1
+ import { t as blindCast } from "./casts-DpaahrlC.mjs";
1
2
  //#region src/defined.ts
2
3
  /**
3
4
  * Returns an object with the key/value if value is defined, otherwise an empty object.
@@ -22,9 +23,9 @@
22
23
  * ```
23
24
  */
24
25
  function ifDefined(key, value) {
25
- return value !== void 0 ? { [key]: value } : {};
26
+ return value !== void 0 ? blindCast({ [key]: value }) : {};
26
27
  }
27
28
  //#endregion
28
29
  export { ifDefined as t };
29
30
 
30
- //# sourceMappingURL=defined-BB-H4E45.mjs.map
31
+ //# sourceMappingURL=defined-BQWA85QH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defined-BQWA85QH.mjs","names":[],"sources":["../src/defined.ts"],"sourcesContent":["import { blindCast } from './casts';\n\n/**\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\n ? blindCast<{ [P in K]: V }, 'computed key K; value is defined'>({ [key]: value })\n : {};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,UACd,KACA,OACwC;CACxC,OAAO,UAAU,KAAA,IACb,UAA+D,GAAG,MAAM,MAAM,CAAC,IAC/E,CAAC;AACP"}
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"defined.d.mts","names":[],"sources":["../src/defined.ts"],"mappings":";;AAwBA;;;;;;;;;;;;;;;;;;;;;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-BB-H4E45.mjs";
1
+ import { t as ifDefined } from "./defined-BQWA85QH.mjs";
2
2
  export { ifDefined };
@@ -1,4 +1,4 @@
1
- import { t as ifDefined } from "./defined-BB-H4E45.mjs";
1
+ import { t as ifDefined } from "./defined-BQWA85QH.mjs";
2
2
  //#region src/redact-db-url.ts
3
3
  /**
4
4
  * Redacts a database connection URL to a minimal metadata object.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@prisma-next/utils",
3
- "version": "0.13.0-dev.31",
3
+ "version": "0.13.0-dev.33",
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.13.0-dev.31",
10
- "@prisma-next/tsdown": "0.13.0-dev.31",
9
+ "@prisma-next/tsconfig": "0.13.0-dev.33",
10
+ "@prisma-next/tsdown": "0.13.0-dev.33",
11
11
  "tsdown": "0.22.1",
12
12
  "typescript": "5.9.3",
13
13
  "vitest": "4.1.8"
package/src/defined.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { blindCast } from './casts';
2
+
1
3
  /**
2
4
  * Returns an object with the key/value if value is defined, otherwise an empty object.
3
5
  *
@@ -24,5 +26,7 @@ export function ifDefined<K extends string, V>(
24
26
  key: K,
25
27
  value: V | undefined,
26
28
  ): Record<never, never> | { [P in K]: V } {
27
- return value !== undefined ? ({ [key]: value } as { [P in K]: V }) : {};
29
+ return value !== undefined
30
+ ? blindCast<{ [P in K]: V }, 'computed key K; value is defined'>({ [key]: value })
31
+ : {};
28
32
  }
@@ -1 +0,0 @@
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"}