@prisma-next/utils 0.1.0-pr.65.1 → 0.1.0-pr.65.11

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.
@@ -0,0 +1,9 @@
1
+ // src/defined.ts
2
+ function ifDefined(key, value) {
3
+ return value !== void 0 ? { [key]: value } : {};
4
+ }
5
+
6
+ export {
7
+ ifDefined
8
+ };
9
+ //# sourceMappingURL=chunk-ZDWVVJU6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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":";AAsBO,SAAS,UACd,KACA,OACwC;AACxC,SAAO,UAAU,SAAa,EAAE,CAAC,GAAG,GAAG,MAAM,IAAwB,CAAC;AACxE;","names":[]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Checks if two arrays are equal using Object.is() for element comparison.
3
+ * Arrays are considered equal if they have the same length and each element
4
+ * at corresponding indices is equal according to Object.is().
5
+ *
6
+ * @param a - First array to compare
7
+ * @param b - Second array to compare
8
+ * @returns true if arrays are equal, false otherwise
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * isArrayEqual(['a', 'b'], ['a', 'b']); // true
13
+ * isArrayEqual(['a'], ['a', 'b']); // false
14
+ * isArrayEqual([0], [-0]); // false (Object.is distinguishes +0 and -0)
15
+ * ```
16
+ */
17
+ declare function isArrayEqual<T>(a: readonly T[], b: readonly T[]): boolean;
18
+
19
+ export { isArrayEqual };
@@ -0,0 +1,16 @@
1
+ // src/array-equal.ts
2
+ function isArrayEqual(a, b) {
3
+ if (a.length !== b.length) {
4
+ return false;
5
+ }
6
+ for (let i = 0; i < a.length; i++) {
7
+ if (!Object.is(a[i], b[i])) {
8
+ return false;
9
+ }
10
+ }
11
+ return true;
12
+ }
13
+ export {
14
+ isArrayEqual
15
+ };
16
+ //# sourceMappingURL=array-equal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/array-equal.ts"],"sourcesContent":["/**\n * Checks if two arrays are equal using Object.is() for element comparison.\n * Arrays are considered equal if they have the same length and each element\n * at corresponding indices is equal according to Object.is().\n *\n * @param a - First array to compare\n * @param b - Second array to compare\n * @returns true if arrays are equal, false otherwise\n *\n * @example\n * ```typescript\n * isArrayEqual(['a', 'b'], ['a', 'b']); // true\n * isArrayEqual(['a'], ['a', 'b']); // false\n * isArrayEqual([0], [-0]); // false (Object.is distinguishes +0 and -0)\n * ```\n */\nexport function isArrayEqual<T>(a: readonly T[], b: readonly T[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (!Object.is(a[i], b[i])) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":";AAgBO,SAAS,aAAgB,GAAiB,GAA0B;AACzE,MAAI,EAAE,WAAW,EAAE,QAAQ;AACzB,WAAO;AAAA,EACT;AACA,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AACjC,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG;AAC1B,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,7 +1,6 @@
1
- // src/defined.ts
2
- function ifDefined(key, value) {
3
- return value !== void 0 ? { [key]: value } : {};
4
- }
1
+ import {
2
+ ifDefined
3
+ } from "../chunk-ZDWVVJU6.js";
5
4
  export {
6
5
  ifDefined
7
6
  };
@@ -1 +1 @@
1
- {"version":3,"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":";AAsBO,SAAS,UACd,KACA,OACwC;AACxC,SAAO,UAAU,SAAa,EAAE,CAAC,GAAG,GAAG,MAAM,IAAwB,CAAC;AACxE;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Minimal metadata extracted from a database URL for logging or error output.
3
+ * Sensitive fields (password, full URL) are never returned.
4
+ */
5
+ interface RedactedDatabaseUrl {
6
+ readonly host?: string;
7
+ readonly port?: string;
8
+ readonly database?: string;
9
+ readonly username?: string;
10
+ }
11
+ /**
12
+ * Redacts a database connection URL to a minimal metadata object.
13
+ *
14
+ * Parsing errors are ignored and result in an empty object so callers never
15
+ * leak raw URLs when the input is malformed.
16
+ */
17
+ declare function redactDatabaseUrl(url: string): RedactedDatabaseUrl;
18
+
19
+ export { type RedactedDatabaseUrl, redactDatabaseUrl };
@@ -0,0 +1,23 @@
1
+ import {
2
+ ifDefined
3
+ } from "../chunk-ZDWVVJU6.js";
4
+
5
+ // src/redact-db-url.ts
6
+ function redactDatabaseUrl(url) {
7
+ try {
8
+ const parsed = new URL(url);
9
+ const database = parsed.pathname?.replace(/^\//, "") || void 0;
10
+ return {
11
+ ...ifDefined("host", parsed.hostname || void 0),
12
+ ...ifDefined("port", parsed.port || void 0),
13
+ ...ifDefined("database", database),
14
+ ...ifDefined("username", parsed.username || void 0)
15
+ };
16
+ } catch {
17
+ return {};
18
+ }
19
+ }
20
+ export {
21
+ redactDatabaseUrl
22
+ };
23
+ //# sourceMappingURL=redact-db-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/redact-db-url.ts"],"sourcesContent":["import { ifDefined } from './defined';\n\n/**\n * Minimal metadata extracted from a database URL for logging or error output.\n * Sensitive fields (password, full URL) are never returned.\n */\nexport interface RedactedDatabaseUrl {\n readonly host?: string;\n readonly port?: string;\n readonly database?: string;\n readonly username?: string;\n}\n\n/**\n * Redacts a database connection URL to a minimal metadata object.\n *\n * Parsing errors are ignored and result in an empty object so callers never\n * leak raw URLs when the input is malformed.\n */\nexport function redactDatabaseUrl(url: string): RedactedDatabaseUrl {\n try {\n const parsed = new URL(url);\n const database = parsed.pathname?.replace(/^\\//, '') || undefined;\n return {\n ...ifDefined('host', parsed.hostname || undefined),\n ...ifDefined('port', parsed.port || undefined),\n ...ifDefined('database', database),\n ...ifDefined('username', parsed.username || undefined),\n };\n } catch {\n // Ignore parsing errors; return empty metadata\n return {};\n }\n}\n"],"mappings":";;;;;AAmBO,SAAS,kBAAkB,KAAkC;AAClE,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,GAAG;AAC1B,UAAM,WAAW,OAAO,UAAU,QAAQ,OAAO,EAAE,KAAK;AACxD,WAAO;AAAA,MACL,GAAG,UAAU,QAAQ,OAAO,YAAY,MAAS;AAAA,MACjD,GAAG,UAAU,QAAQ,OAAO,QAAQ,MAAS;AAAA,MAC7C,GAAG,UAAU,YAAY,QAAQ;AAAA,MACjC,GAAG,UAAU,YAAY,OAAO,YAAY,MAAS;AAAA,IACvD;AAAA,EACF,QAAQ;AAEN,WAAO,CAAC;AAAA,EACV;AACF;","names":[]}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@prisma-next/utils",
3
- "version": "0.1.0-pr.65.1",
3
+ "version": "0.1.0-pr.65.11",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "Shared utility functions for Prisma Next",
7
7
  "devDependencies": {
8
- "@vitest/coverage-v8": "^2.1.1",
8
+ "@vitest/coverage-v8": "^4.0.0",
9
9
  "tsup": "^8.3.0",
10
10
  "typescript": "^5.9.3",
11
11
  "vite-tsconfig-paths": "^5.1.4",
@@ -15,6 +15,10 @@
15
15
  "dist"
16
16
  ],
17
17
  "exports": {
18
+ "./array-equal": {
19
+ "types": "./dist/exports/array-equal.d.ts",
20
+ "import": "./dist/exports/array-equal.js"
21
+ },
18
22
  "./defined": {
19
23
  "types": "./dist/exports/defined.d.ts",
20
24
  "import": "./dist/exports/defined.js"
@@ -22,6 +26,10 @@
22
26
  "./result": {
23
27
  "types": "./dist/exports/result.d.ts",
24
28
  "import": "./dist/exports/result.js"
29
+ },
30
+ "./redact-db-url": {
31
+ "types": "./dist/exports/redact-db-url.d.ts",
32
+ "import": "./dist/exports/redact-db-url.js"
25
33
  }
26
34
  },
27
35
  "scripts": {