🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@prisma-next/utils

Package Overview
Dependencies
Maintainers
4
Versions
1012
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/utils - npm Package Compare versions

Comparing version
0.16.0-dev.30
to
0.16.0-dev.31
+1
-1
dist/result.d.mts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"result.d.mts","names":[],"sources":["../src/result.ts"],"mappings":";;;;;;;;;;;;;;;UAiBiB,GAAG;WACT;WACA,OAAO;EAChB,YAAY;EACZ;;;;;UAMe,MAAM;WACZ;WACA,SAAS;EAClB;EACA,eAAe;;;;;;;;KASL,OAAO,GAAG,KAAK,GAAG,KAAK,MAAM;;;;iBAkFzB,GAAG,GAAG,OAAO,IAAI,GAAG;;;;iBAOpB,MAAM,GAAG,SAAS,IAAI,MAAM;;;;;iBAc5B,UAAU"}
{"version":3,"file":"result.d.mts","names":[],"sources":["../src/result.ts"],"mappings":";;;;;;;;;;;;;;;UAkBiB,GAAG;WACT;WACA,OAAO;EAChB,YAAY;EACZ;;;;;UAMe,MAAM;WACZ;WACA,SAAS;EAClB;EACA,eAAe;;;;;;;;KASL,OAAO,GAAG,KAAK,GAAG,KAAK,MAAM;;;;iBAkFzB,GAAG,GAAG,OAAO,IAAI,GAAG;;;;iBAOpB,MAAM,GAAG,SAAS,IAAI,MAAM;;;;;iBAc5B,UAAU"}

@@ -0,1 +1,2 @@

import { t as InternalError } from "./internal-error-BIc-ehme.mjs";
import { t as blindCast } from "./casts-DpaahrlC.mjs";

@@ -28,7 +29,7 @@ //#region src/result.ts

get value() {
if (!this.ok) throw new Error("Cannot access value on NotOk result");
if (!this.ok) throw new InternalError("Cannot access value on NotOk result");
return this._value;
}
get failure() {
if (this.ok) throw new Error("Cannot access failure on Ok result");
if (this.ok) throw new InternalError("Cannot access failure on Ok result");
return this._failure;

@@ -53,3 +54,3 @@ }

assertOk() {
if (!this.ok) throw new Error("Expected Ok result but got NotOk");
if (!this.ok) throw new InternalError("Expected Ok result but got NotOk");
return this.value;

@@ -62,3 +63,3 @@ }

assertNotOk() {
if (this.ok) throw new Error("Expected NotOk result but got Ok");
if (this.ok) throw new InternalError("Expected NotOk result but got Ok");
return this.failure;

@@ -65,0 +66,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"result.mjs","names":[],"sources":["../src/result.ts"],"sourcesContent":["/**\n * Generic Result type for representing success or failure outcomes.\n *\n * This is the standard way to return \"expected failures\" as values rather than\n * throwing exceptions. See docs/Error Handling.md for the full taxonomy.\n *\n * Naming rationale:\n * - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator\n * - `NotOk` avoids collision with domain types like \"Failure\" or \"Error\"\n * - `failure` property distinguishes from JS Error semantics\n */\n\nimport { blindCast } from './casts';\n\n/**\n * Represents a successful result containing a value.\n */\nexport interface Ok<T> {\n readonly ok: true;\n readonly value: T;\n assertOk(): T;\n assertNotOk(): never;\n}\n\n/**\n * Represents an unsuccessful result containing failure details.\n */\nexport interface NotOk<F> {\n readonly ok: false;\n readonly failure: F;\n assertOk(): never;\n assertNotOk(): F;\n}\n\n/**\n * A discriminated union representing either success (Ok) or failure (NotOk).\n *\n * @typeParam T - The success value type\n * @typeParam F - The failure details type\n */\nexport type Result<T, F> = Ok<T> | NotOk<F>;\n\n/**\n * Result class that implements both Ok and NotOk variants.\n */\nclass ResultImpl<T, F> {\n readonly ok: boolean;\n private readonly _value?: T;\n private readonly _failure?: F;\n\n private constructor(ok: boolean, valueOrFailure: T | F) {\n this.ok = ok;\n if (ok) {\n this._value = valueOrFailure as T;\n } else {\n this._failure = valueOrFailure as F;\n }\n Object.freeze(this);\n }\n\n get value(): T {\n if (!this.ok) {\n throw new Error('Cannot access value on NotOk result');\n }\n // biome-ignore lint/style/noNonNullAssertion: must be present if ok is true\n return this._value!;\n }\n\n get failure(): F {\n if (this.ok) {\n throw new Error('Cannot access failure on Ok result');\n }\n // biome-ignore lint/style/noNonNullAssertion: must be present if ok is false\n return this._failure!;\n }\n\n /**\n * Creates a successful result.\n */\n static ok<T, F = never>(value: T): Ok<T> {\n return blindCast<\n Ok<T>,\n 'ResultImpl is the single implementation of the Result discriminated union; TypeScript cannot express discriminated return types for a single class. ok=true guarantees this is an Ok<T> at runtime.'\n >(new ResultImpl<T, F>(true, value));\n }\n\n /**\n * Creates an unsuccessful result.\n */\n static notOk<T = never, F = unknown>(failure: F): NotOk<F> {\n return blindCast<\n NotOk<F>,\n 'ResultImpl is the single implementation of the Result discriminated union; TypeScript cannot express discriminated return types for a single class. ok=false guarantees this is a NotOk<F> at runtime.'\n >(new ResultImpl<T, F>(false, failure));\n }\n\n /**\n * Asserts that this result is Ok and returns the value.\n * Throws if the result is NotOk.\n */\n assertOk(this: Result<T, F>): T {\n if (!this.ok) {\n throw new Error('Expected Ok result but got NotOk');\n }\n return this.value;\n }\n\n /**\n * Asserts that this result is NotOk and returns the failure.\n * Throws if the result is Ok.\n */\n assertNotOk(this: Result<T, F>): F {\n if (this.ok) {\n throw new Error('Expected NotOk result but got Ok');\n }\n return this.failure;\n }\n}\n\n/**\n * Creates a successful result.\n */\nexport function ok<T>(value: T): Ok<T> {\n return ResultImpl.ok(value);\n}\n\n/**\n * Creates an unsuccessful result.\n */\nexport function notOk<F>(failure: F): NotOk<F> {\n return ResultImpl.notOk(failure);\n}\n\n/**\n * Singleton for void success results.\n * Use this for validation checks that don't produce a value.\n */\nconst OK_VOID: Ok<void> = ResultImpl.ok<void>(undefined);\n\n/**\n * Returns a successful void result.\n * Use this for validation checks that don't produce a value.\n */\nexport function okVoid(): Ok<void> {\n return OK_VOID;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6CA,IAAM,aAAN,MAAM,WAAiB;CACrB;CACA;CACA;CAEA,YAAoB,IAAa,gBAAuB;EACtD,KAAK,KAAK;EACV,IAAI,IACF,KAAK,SAAS;OAEd,KAAK,WAAW;EAElB,OAAO,OAAO,IAAI;CACpB;CAEA,IAAI,QAAW;EACb,IAAI,CAAC,KAAK,IACR,MAAM,IAAI,MAAM,qCAAqC;EAGvD,OAAO,KAAK;CACd;CAEA,IAAI,UAAa;EACf,IAAI,KAAK,IACP,MAAM,IAAI,MAAM,oCAAoC;EAGtD,OAAO,KAAK;CACd;;;;CAKA,OAAO,GAAiB,OAAiB;EACvC,OAAO,UAGL,IAAI,WAAiB,MAAM,KAAK,CAAC;CACrC;;;;CAKA,OAAO,MAA8B,SAAsB;EACzD,OAAO,UAGL,IAAI,WAAiB,OAAO,OAAO,CAAC;CACxC;;;;;CAMA,WAAgC;EAC9B,IAAI,CAAC,KAAK,IACR,MAAM,IAAI,MAAM,kCAAkC;EAEpD,OAAO,KAAK;CACd;;;;;CAMA,cAAmC;EACjC,IAAI,KAAK,IACP,MAAM,IAAI,MAAM,kCAAkC;EAEpD,OAAO,KAAK;CACd;AACF;;;;AAKA,SAAgB,GAAM,OAAiB;CACrC,OAAO,WAAW,GAAG,KAAK;AAC5B;;;;AAKA,SAAgB,MAAS,SAAsB;CAC7C,OAAO,WAAW,MAAM,OAAO;AACjC;;;;;AAMA,MAAM,UAAoB,WAAW,GAAS,KAAA,CAAS;;;;;AAMvD,SAAgB,SAAmB;CACjC,OAAO;AACT"}
{"version":3,"file":"result.mjs","names":[],"sources":["../src/result.ts"],"sourcesContent":["/**\n * Generic Result type for representing success or failure outcomes.\n *\n * This is the standard way to return \"expected failures\" as values rather than\n * throwing exceptions. See docs/Error Handling.md for the full taxonomy.\n *\n * Naming rationale:\n * - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator\n * - `NotOk` avoids collision with domain types like \"Failure\" or \"Error\"\n * - `failure` property distinguishes from JS Error semantics\n */\n\nimport { blindCast } from './casts';\nimport { InternalError } from './internal-error';\n\n/**\n * Represents a successful result containing a value.\n */\nexport interface Ok<T> {\n readonly ok: true;\n readonly value: T;\n assertOk(): T;\n assertNotOk(): never;\n}\n\n/**\n * Represents an unsuccessful result containing failure details.\n */\nexport interface NotOk<F> {\n readonly ok: false;\n readonly failure: F;\n assertOk(): never;\n assertNotOk(): F;\n}\n\n/**\n * A discriminated union representing either success (Ok) or failure (NotOk).\n *\n * @typeParam T - The success value type\n * @typeParam F - The failure details type\n */\nexport type Result<T, F> = Ok<T> | NotOk<F>;\n\n/**\n * Result class that implements both Ok and NotOk variants.\n */\nclass ResultImpl<T, F> {\n readonly ok: boolean;\n private readonly _value?: T;\n private readonly _failure?: F;\n\n private constructor(ok: boolean, valueOrFailure: T | F) {\n this.ok = ok;\n if (ok) {\n this._value = valueOrFailure as T;\n } else {\n this._failure = valueOrFailure as F;\n }\n Object.freeze(this);\n }\n\n get value(): T {\n if (!this.ok) {\n throw new InternalError('Cannot access value on NotOk result');\n }\n // biome-ignore lint/style/noNonNullAssertion: must be present if ok is true\n return this._value!;\n }\n\n get failure(): F {\n if (this.ok) {\n throw new InternalError('Cannot access failure on Ok result');\n }\n // biome-ignore lint/style/noNonNullAssertion: must be present if ok is false\n return this._failure!;\n }\n\n /**\n * Creates a successful result.\n */\n static ok<T, F = never>(value: T): Ok<T> {\n return blindCast<\n Ok<T>,\n 'ResultImpl is the single implementation of the Result discriminated union; TypeScript cannot express discriminated return types for a single class. ok=true guarantees this is an Ok<T> at runtime.'\n >(new ResultImpl<T, F>(true, value));\n }\n\n /**\n * Creates an unsuccessful result.\n */\n static notOk<T = never, F = unknown>(failure: F): NotOk<F> {\n return blindCast<\n NotOk<F>,\n 'ResultImpl is the single implementation of the Result discriminated union; TypeScript cannot express discriminated return types for a single class. ok=false guarantees this is a NotOk<F> at runtime.'\n >(new ResultImpl<T, F>(false, failure));\n }\n\n /**\n * Asserts that this result is Ok and returns the value.\n * Throws if the result is NotOk.\n */\n assertOk(this: Result<T, F>): T {\n if (!this.ok) {\n throw new InternalError('Expected Ok result but got NotOk');\n }\n return this.value;\n }\n\n /**\n * Asserts that this result is NotOk and returns the failure.\n * Throws if the result is Ok.\n */\n assertNotOk(this: Result<T, F>): F {\n if (this.ok) {\n throw new InternalError('Expected NotOk result but got Ok');\n }\n return this.failure;\n }\n}\n\n/**\n * Creates a successful result.\n */\nexport function ok<T>(value: T): Ok<T> {\n return ResultImpl.ok(value);\n}\n\n/**\n * Creates an unsuccessful result.\n */\nexport function notOk<F>(failure: F): NotOk<F> {\n return ResultImpl.notOk(failure);\n}\n\n/**\n * Singleton for void success results.\n * Use this for validation checks that don't produce a value.\n */\nconst OK_VOID: Ok<void> = ResultImpl.ok<void>(undefined);\n\n/**\n * Returns a successful void result.\n * Use this for validation checks that don't produce a value.\n */\nexport function okVoid(): Ok<void> {\n return OK_VOID;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA8CA,IAAM,aAAN,MAAM,WAAiB;CACrB;CACA;CACA;CAEA,YAAoB,IAAa,gBAAuB;EACtD,KAAK,KAAK;EACV,IAAI,IACF,KAAK,SAAS;OAEd,KAAK,WAAW;EAElB,OAAO,OAAO,IAAI;CACpB;CAEA,IAAI,QAAW;EACb,IAAI,CAAC,KAAK,IACR,MAAM,IAAI,cAAc,qCAAqC;EAG/D,OAAO,KAAK;CACd;CAEA,IAAI,UAAa;EACf,IAAI,KAAK,IACP,MAAM,IAAI,cAAc,oCAAoC;EAG9D,OAAO,KAAK;CACd;;;;CAKA,OAAO,GAAiB,OAAiB;EACvC,OAAO,UAGL,IAAI,WAAiB,MAAM,KAAK,CAAC;CACrC;;;;CAKA,OAAO,MAA8B,SAAsB;EACzD,OAAO,UAGL,IAAI,WAAiB,OAAO,OAAO,CAAC;CACxC;;;;;CAMA,WAAgC;EAC9B,IAAI,CAAC,KAAK,IACR,MAAM,IAAI,cAAc,kCAAkC;EAE5D,OAAO,KAAK;CACd;;;;;CAMA,cAAmC;EACjC,IAAI,KAAK,IACP,MAAM,IAAI,cAAc,kCAAkC;EAE5D,OAAO,KAAK;CACd;AACF;;;;AAKA,SAAgB,GAAM,OAAiB;CACrC,OAAO,WAAW,GAAG,KAAK;AAC5B;;;;AAKA,SAAgB,MAAS,SAAsB;CAC7C,OAAO,WAAW,MAAM,OAAO;AACjC;;;;;AAMA,MAAM,UAAoB,WAAW,GAAS,KAAA,CAAS;;;;;AAMvD,SAAgB,SAAmB;CACjC,OAAO;AACT"}
{
"name": "@prisma-next/utils",
"version": "0.16.0-dev.30",
"version": "0.16.0-dev.31",
"license": "Apache-2.0",

@@ -9,4 +9,4 @@ "type": "module",

"devDependencies": {
"@prisma-next/tsconfig": "0.16.0-dev.30",
"@prisma-next/tsdown": "0.16.0-dev.30",
"@prisma-next/tsconfig": "0.16.0-dev.31",
"@prisma-next/tsdown": "0.16.0-dev.31",
"tsdown": "0.22.8",

@@ -13,0 +13,0 @@ "typescript": "5.9.3",

@@ -14,2 +14,3 @@ /**

import { blindCast } from './casts';
import { InternalError } from './internal-error';

@@ -64,3 +65,3 @@ /**

if (!this.ok) {
throw new Error('Cannot access value on NotOk result');
throw new InternalError('Cannot access value on NotOk result');
}

@@ -73,3 +74,3 @@ // biome-ignore lint/style/noNonNullAssertion: must be present if ok is true

if (this.ok) {
throw new Error('Cannot access failure on Ok result');
throw new InternalError('Cannot access failure on Ok result');
}

@@ -106,3 +107,3 @@ // biome-ignore lint/style/noNonNullAssertion: must be present if ok is false

if (!this.ok) {
throw new Error('Expected Ok result but got NotOk');
throw new InternalError('Expected Ok result but got NotOk');
}

@@ -118,3 +119,3 @@ return this.value;

if (this.ok) {
throw new Error('Expected NotOk result but got Ok');
throw new InternalError('Expected NotOk result but got Ok');
}

@@ -121,0 +122,0 @@ return this.failure;