@prisma-next/core-control-plane 0.1.0-dev.14 → 0.1.0-dev.15
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/exports/result.d.ts +47 -0
- package/dist/exports/result.js +17 -0
- package/dist/exports/result.js.map +1 -0
- package/dist/exports/types.d.ts +37 -2
- package/package.json +7 -3
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Result type for representing success or failure outcomes.
|
|
3
|
+
*
|
|
4
|
+
* This is the standard way to return "expected failures" as values rather than
|
|
5
|
+
* throwing exceptions. See docs/Error Handling.md for the full taxonomy.
|
|
6
|
+
*
|
|
7
|
+
* Naming rationale:
|
|
8
|
+
* - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator
|
|
9
|
+
* - `NotOk` avoids collision with domain types like "Failure" or "Error"
|
|
10
|
+
* - `failure` property distinguishes from JS Error semantics
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Represents a successful result containing a value.
|
|
14
|
+
*/
|
|
15
|
+
interface Ok<T> {
|
|
16
|
+
readonly ok: true;
|
|
17
|
+
readonly value: T;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents an unsuccessful result containing failure details.
|
|
21
|
+
*/
|
|
22
|
+
interface NotOk<F> {
|
|
23
|
+
readonly ok: false;
|
|
24
|
+
readonly failure: F;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A discriminated union representing either success (Ok) or failure (NotOk).
|
|
28
|
+
*
|
|
29
|
+
* @typeParam T - The success value type
|
|
30
|
+
* @typeParam F - The failure details type
|
|
31
|
+
*/
|
|
32
|
+
type Result<T, F> = Ok<T> | NotOk<F>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a successful result.
|
|
35
|
+
*/
|
|
36
|
+
declare function ok<T>(value: T): Ok<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates an unsuccessful result.
|
|
39
|
+
*/
|
|
40
|
+
declare function notOk<F>(failure: F): NotOk<F>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a successful void result.
|
|
43
|
+
* Use this for validation checks that don't produce a value.
|
|
44
|
+
*/
|
|
45
|
+
declare function okVoid(): Ok<void>;
|
|
46
|
+
|
|
47
|
+
export { type NotOk, type Ok, type Result, notOk, ok, okVoid };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/result.ts
|
|
2
|
+
function ok(value) {
|
|
3
|
+
return Object.freeze({ ok: true, value });
|
|
4
|
+
}
|
|
5
|
+
function notOk(failure) {
|
|
6
|
+
return Object.freeze({ ok: false, failure });
|
|
7
|
+
}
|
|
8
|
+
var OK_VOID = Object.freeze({ ok: true, value: void 0 });
|
|
9
|
+
function okVoid() {
|
|
10
|
+
return OK_VOID;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
notOk,
|
|
14
|
+
ok,
|
|
15
|
+
okVoid
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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\n/**\n * Represents a successful result containing a value.\n */\nexport interface Ok<T> {\n readonly ok: true;\n readonly value: T;\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}\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 * Creates a successful result.\n */\nexport function ok<T>(value: T): Ok<T> {\n return Object.freeze({ ok: true, value });\n}\n\n/**\n * Creates an unsuccessful result.\n */\nexport function notOk<F>(failure: F): NotOk<F> {\n return Object.freeze({ ok: false, 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> = Object.freeze({ ok: true, value: 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":";AAuCO,SAAS,GAAM,OAAiB;AACrC,SAAO,OAAO,OAAO,EAAE,IAAI,MAAM,MAAM,CAAC;AAC1C;AAKO,SAAS,MAAS,SAAsB;AAC7C,SAAO,OAAO,OAAO,EAAE,IAAI,OAAO,QAAQ,CAAC;AAC7C;AAMA,IAAM,UAAoB,OAAO,OAAO,EAAE,IAAI,MAAM,OAAO,OAAU,CAAC;AAM/D,SAAS,SAAmB;AACjC,SAAO;AACT;","names":[]}
|
package/dist/exports/types.d.ts
CHANGED
|
@@ -56,6 +56,41 @@ interface ControlExtensionInstance<TFamilyId extends string = string, TTargetId
|
|
|
56
56
|
readonly familyId: TFamilyId;
|
|
57
57
|
readonly targetId: TTargetId;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Operation context for propagating metadata through control-plane operation call chains.
|
|
61
|
+
* Inspired by OpenTelemetry's Context and Sentry's Scope patterns.
|
|
62
|
+
*
|
|
63
|
+
* This context carries informational metadata (like file paths) that can be used for
|
|
64
|
+
* error reporting, logging, and debugging, but is not required for structural correctness.
|
|
65
|
+
* It allows subsystems to propagate context without coupling to file I/O concerns.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const context: OperationContext = {
|
|
70
|
+
* contractPath: './contract.json',
|
|
71
|
+
* configPath: './prisma-next.config.ts',
|
|
72
|
+
* };
|
|
73
|
+
*
|
|
74
|
+
* await runner.execute({ plan, driver, destinationContract: contract, context });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
interface OperationContext {
|
|
78
|
+
/**
|
|
79
|
+
* Path to the contract file (if applicable).
|
|
80
|
+
* Used for error reporting and metadata, not for file I/O.
|
|
81
|
+
*/
|
|
82
|
+
readonly contractPath?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Path to the configuration file (if applicable).
|
|
85
|
+
* Used for error reporting and metadata, not for file I/O.
|
|
86
|
+
*/
|
|
87
|
+
readonly configPath?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Additional metadata that can be propagated through the call chain.
|
|
90
|
+
* Extensible for future needs without breaking changes.
|
|
91
|
+
*/
|
|
92
|
+
readonly meta?: Readonly<Record<string, unknown>>;
|
|
93
|
+
}
|
|
59
94
|
/**
|
|
60
95
|
* Descriptor for a control-plane family (e.g., SQL).
|
|
61
96
|
* Provides the family hook and factory method.
|
|
@@ -298,7 +333,7 @@ interface VerifyDatabaseSchemaResult {
|
|
|
298
333
|
};
|
|
299
334
|
readonly meta?: {
|
|
300
335
|
readonly configPath?: string;
|
|
301
|
-
readonly contractPath
|
|
336
|
+
readonly contractPath?: string;
|
|
302
337
|
readonly strict: boolean;
|
|
303
338
|
};
|
|
304
339
|
readonly timings: {
|
|
@@ -368,4 +403,4 @@ interface SignDatabaseResult {
|
|
|
368
403
|
};
|
|
369
404
|
}
|
|
370
405
|
|
|
371
|
-
export type { ControlAdapterDescriptor, ControlAdapterInstance, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlExtensionInstance, ControlFamilyDescriptor, ControlFamilyInstance, ControlTargetDescriptor, ControlTargetInstance, EmitContractResult, FamilyInstance, IntrospectSchemaResult, SchemaIssue, SchemaVerificationNode, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult };
|
|
406
|
+
export type { ControlAdapterDescriptor, ControlAdapterInstance, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlExtensionInstance, ControlFamilyDescriptor, ControlFamilyInstance, ControlTargetDescriptor, ControlTargetInstance, EmitContractResult, FamilyInstance, IntrospectSchemaResult, OperationContext, SchemaIssue, SchemaVerificationNode, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult };
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/core-control-plane",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Control plane domain actions, config types, validation, and error factories for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"arktype": "^2.1.26",
|
|
9
9
|
"prettier": "^3.3.3",
|
|
10
|
-
"@prisma-next/contract": "0.1.0-dev.
|
|
11
|
-
"@prisma-next/operations": "0.1.0-dev.
|
|
10
|
+
"@prisma-next/contract": "0.1.0-dev.15",
|
|
11
|
+
"@prisma-next/operations": "0.1.0-dev.15"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"tsup": "^8.3.0",
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
"./schema-view": {
|
|
44
44
|
"types": "./dist/exports/schema-view.d.ts",
|
|
45
45
|
"import": "./dist/exports/schema-view.js"
|
|
46
|
+
},
|
|
47
|
+
"./result": {
|
|
48
|
+
"types": "./dist/exports/result.d.ts",
|
|
49
|
+
"import": "./dist/exports/result.js"
|
|
46
50
|
}
|
|
47
51
|
},
|
|
48
52
|
"scripts": {
|