@prisma-next/utils 0.4.0-dev.9 → 0.5.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{defined-BSROFTyI.mjs → defined-CV9lG7rM.mjs} +1 -1
- package/dist/{defined-BSROFTyI.mjs.map → defined-CV9lG7rM.mjs.map} +1 -1
- package/dist/defined.mjs +1 -1
- package/dist/redact-db-url.mjs +1 -1
- package/dist/simplify-deep.d.mts +5 -0
- package/dist/simplify-deep.d.mts.map +1 -0
- package/dist/simplify-deep.mjs +1 -0
- package/package.json +2 -1
- package/src/exports/simplify-deep.ts +1 -0
- package/src/simplify-deep.ts +18 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defined-
|
|
1
|
+
{"version":3,"file":"defined-CV9lG7rM.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;AACxC,QAAO,UAAU,SAAa,GAAG,MAAM,OAAO,GAAuB,EAAE"}
|
package/dist/defined.mjs
CHANGED
package/dist/redact-db-url.mjs
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/simplify-deep.d.ts
|
|
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
|
+
//#endregion
|
|
4
|
+
export { type SimplifyDeep };
|
|
5
|
+
//# sourceMappingURL=simplify-deep.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simplify-deep.d.mts","names":[],"sources":["../src/simplify-deep.ts"],"sourcesContent":[],"mappings":";KAAY,kBAAkB,uCAC1B,sBACE,aAAa,sBACJ,aAAa,aACxB,wDAMM,OACA,SACA,+CAEJ,IACA,2BAfM,MAgBU,CAhBV,GAgBc,YAhBF,CAgBe,CAhBf,CAgBiB,CAhBjB,CAAA,CAAA,EAAM,GAiBtB,CAjBsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-dev.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Shared utility functions for Prisma Next",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"./defined": "./dist/defined.mjs",
|
|
26
26
|
"./redact-db-url": "./dist/redact-db-url.mjs",
|
|
27
27
|
"./result": "./dist/result.mjs",
|
|
28
|
+
"./simplify-deep": "./dist/simplify-deep.mjs",
|
|
28
29
|
"./package.json": "./package.json"
|
|
29
30
|
},
|
|
30
31
|
"repository": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { SimplifyDeep } from '../simplify-deep';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type SimplifyDeep<T> = T extends readonly (infer Element)[]
|
|
2
|
+
? T extends unknown[]
|
|
3
|
+
? SimplifyDeep<Element>[]
|
|
4
|
+
: readonly SimplifyDeep<Element>[]
|
|
5
|
+
: T extends
|
|
6
|
+
| string
|
|
7
|
+
| number
|
|
8
|
+
| boolean
|
|
9
|
+
| bigint
|
|
10
|
+
| symbol
|
|
11
|
+
| Date
|
|
12
|
+
| RegExp
|
|
13
|
+
| Uint8Array
|
|
14
|
+
| ((...args: never[]) => unknown)
|
|
15
|
+
? T
|
|
16
|
+
: T extends object
|
|
17
|
+
? { [K in keyof T]: SimplifyDeep<T[K]> }
|
|
18
|
+
: T;
|