@prisma-next/plan 0.0.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/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # @prisma-next/plan
2
+
3
+ Plan helpers, diagnostics, and shared errors for Prisma Next.
4
+
5
+ ## Overview
6
+
7
+ This package is part of the **core ring** and provides target-agnostic plan error helpers and error types. These utilities are used across all target families (SQL, document, etc.) for consistent error handling during plan construction and validation.
8
+
9
+ ## Purpose
10
+
11
+ Provide shared plan error utilities that can be used by any target family without depending on target-specific types or implementations.
12
+
13
+ ## Responsibilities
14
+
15
+ - **Plan Error Helpers**: Functions for creating standardized plan errors (`planInvalid`, `planUnsupported`)
16
+ - **Error Types**: TypeScript types for plan errors (`RuntimeError`)
17
+
18
+ **Non-goals:**
19
+ - Target-specific error handling (handled by target packages)
20
+ - Runtime error handling (handled by runtime package)
21
+ - Contract validation errors (handled by contract/emitter packages)
22
+
23
+ ## Architecture
24
+
25
+ ```mermaid
26
+ flowchart TD
27
+ subgraph "Core Ring"
28
+ PLAN["@prisma-next/plan"]
29
+ end
30
+
31
+ subgraph "Consumers"
32
+ SQL[SQL Lanes]
33
+ DOC[Document Lanes]
34
+ RUNTIME[Runtime]
35
+ end
36
+
37
+ PLAN --> SQL
38
+ PLAN --> DOC
39
+ PLAN --> RUNTIME
40
+ ```
41
+
42
+ ## Components
43
+
44
+ ### Error Helpers (`errors.ts`)
45
+
46
+ - **`planInvalid(message, details?, hints?, docs?)`**: Creates a `RuntimeError` with code `PLAN.INVALID` for invalid plan operations
47
+ - **`planUnsupported(message, details?, hints?, docs?)`**: Creates a `RuntimeError` with code `PLAN.UNSUPPORTED` for unsupported plan operations
48
+
49
+ ### Error Types (`types.ts`)
50
+
51
+ - **`RuntimeError`**: Interface for plan errors with standardized fields:
52
+ - `code`: Error code (e.g., `PLAN.INVALID`, `PLAN.UNSUPPORTED`)
53
+ - `category`: Always `'PLAN'` for plan errors
54
+ - `severity`: Always `'error'`
55
+ - `message`: Human-readable error message
56
+ - `details`: Optional structured details
57
+ - `hints`: Optional array of hints
58
+ - `docs`: Optional array of documentation links
59
+
60
+ ## Dependencies
61
+
62
+ This package has **no dependencies** - it's part of the innermost core ring and provides foundational error utilities.
63
+
64
+ ## Package Structure
65
+
66
+ This package follows the standard `exports/` directory pattern:
67
+
68
+ - `src/exports/errors.ts` - Re-exports error helpers (`planInvalid`, `planUnsupported`)
69
+ - `src/exports/types.ts` - Re-exports error types (`RuntimeError`)
70
+ - `src/index.ts` - Main entry point that re-exports from `exports/`
71
+
72
+ This enables subpath imports like `@prisma-next/plan/errors` and `@prisma-next/plan/types` if needed in the future.
73
+
74
+ ## Package Location
75
+
76
+ This package is part of the **framework domain**, **core layer**, **shared plane**:
77
+ - **Domain**: framework (target-agnostic)
78
+ - **Layer**: core
79
+ - **Plane**: shared
80
+ - **Path**: `packages/framework/core-plan`
81
+
82
+ ## Related Subsystems
83
+
84
+ - **[Query Lanes](../../../../docs/architecture%20docs/subsystems/3.%20Query%20Lanes.md)**: Uses plan errors during query construction
85
+ - **[Runtime & Plugin Framework](../../../../docs/architecture%20docs/subsystems/4.%20Runtime%20&%20Plugin%20Framework.md)**: Uses plan errors for validation
86
+
87
+ ## Related ADRs
88
+
89
+ - [ADR 140 - Package Layering & Target-Family Namespacing](../../../../docs/architecture%20docs/adrs/ADR%20140%20-%20Package%20Layering%20&%20Target-Family%20Namespacing.md)
90
+ - [ADR 068 - Error mapping to RuntimeError](../../../../docs/architecture%20docs/adrs/ADR%20068%20-%20Error%20mapping%20to%20RuntimeError.md)
91
+ - [ADR 027 - Error Envelope Stable Codes](../../../../docs/architecture%20docs/adrs/ADR%20027%20-%20Error%20Envelope%20Stable%20Codes.md)
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-G4WYE6TI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,37 @@
1
+ // src/errors.ts
2
+ function planInvalid(message, details, hints, docs) {
3
+ const error = new Error(message);
4
+ Object.defineProperty(error, "name", {
5
+ value: "RuntimeError",
6
+ configurable: true
7
+ });
8
+ return Object.assign(error, {
9
+ code: "PLAN.INVALID",
10
+ category: "PLAN",
11
+ severity: "error",
12
+ details,
13
+ hints,
14
+ docs
15
+ });
16
+ }
17
+ function planUnsupported(message, details, hints, docs) {
18
+ const error = new Error(message);
19
+ Object.defineProperty(error, "name", {
20
+ value: "RuntimeError",
21
+ configurable: true
22
+ });
23
+ return Object.assign(error, {
24
+ code: "PLAN.UNSUPPORTED",
25
+ category: "PLAN",
26
+ severity: "error",
27
+ details,
28
+ hints,
29
+ docs
30
+ });
31
+ }
32
+
33
+ export {
34
+ planInvalid,
35
+ planUnsupported
36
+ };
37
+ //# sourceMappingURL=chunk-JG6QOQIV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import type { RuntimeError } from './types';\n\nexport function planInvalid(\n message: string,\n details?: Record<string, unknown>,\n hints?: readonly string[],\n docs?: readonly string[],\n): RuntimeError {\n const error = new Error(message) as RuntimeError;\n\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n\n return Object.assign(error, {\n code: 'PLAN.INVALID',\n category: 'PLAN' as const,\n severity: 'error' as const,\n details,\n hints,\n docs,\n });\n}\n\nexport function planUnsupported(\n message: string,\n details?: Record<string, unknown>,\n hints?: readonly string[],\n docs?: readonly string[],\n): RuntimeError {\n const error = new Error(message) as RuntimeError;\n\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n\n return Object.assign(error, {\n code: 'PLAN.UNSUPPORTED',\n category: 'PLAN' as const,\n severity: 'error' as const,\n details,\n hints,\n docs,\n });\n}\n"],"mappings":";AAEO,SAAS,YACd,SACA,SACA,OACA,MACc;AACd,QAAM,QAAQ,IAAI,MAAM,OAAO;AAE/B,SAAO,eAAe,OAAO,QAAQ;AAAA,IACnC,OAAO;AAAA,IACP,cAAc;AAAA,EAChB,CAAC;AAED,SAAO,OAAO,OAAO,OAAO;AAAA,IAC1B,MAAM;AAAA,IACN,UAAU;AAAA,IACV,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,SAAS,gBACd,SACA,SACA,OACA,MACc;AACd,QAAM,QAAQ,IAAI,MAAM,OAAO;AAE/B,SAAO,eAAe,OAAO,QAAQ;AAAA,IACnC,OAAO;AAAA,IACP,cAAc;AAAA,EAChB,CAAC;AAED,SAAO,OAAO,OAAO,OAAO;AAAA,IAC1B,MAAM;AAAA,IACN,UAAU;AAAA,IACV,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { RuntimeError } from './types.js';
2
+
3
+ declare function planInvalid(message: string, details?: Record<string, unknown>, hints?: readonly string[], docs?: readonly string[]): RuntimeError;
4
+ declare function planUnsupported(message: string, details?: Record<string, unknown>, hints?: readonly string[], docs?: readonly string[]): RuntimeError;
5
+
6
+ export { planInvalid, planUnsupported };
@@ -0,0 +1,9 @@
1
+ import {
2
+ planInvalid,
3
+ planUnsupported
4
+ } from "../chunk-JG6QOQIV.js";
5
+ export {
6
+ planInvalid,
7
+ planUnsupported
8
+ };
9
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,11 @@
1
+ interface RuntimeError extends Error {
2
+ readonly code: string;
3
+ readonly category: 'PLAN';
4
+ readonly severity: 'error';
5
+ readonly message: string;
6
+ readonly details?: Record<string, unknown>;
7
+ readonly hints?: readonly string[];
8
+ readonly docs?: readonly string[];
9
+ }
10
+
11
+ export type { RuntimeError };
@@ -0,0 +1,2 @@
1
+ import "../chunk-G4WYE6TI.js";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ export { planInvalid, planUnsupported } from './exports/errors.js';
2
+ export { RuntimeError } from './exports/types.js';
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ planInvalid,
3
+ planUnsupported
4
+ } from "./chunk-JG6QOQIV.js";
5
+ import "./chunk-G4WYE6TI.js";
6
+ export {
7
+ planInvalid,
8
+ planUnsupported
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@prisma-next/plan",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "description": "Plan helpers, diagnostics, and shared errors for Prisma Next",
7
+ "devDependencies": {
8
+ "tsup": "^8.3.0",
9
+ "typescript": "^5.9.3",
10
+ "vitest": "^2.1.1"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ },
20
+ "./errors": {
21
+ "types": "./dist/exports/errors.d.ts",
22
+ "import": "./dist/exports/errors.js"
23
+ },
24
+ "./types": {
25
+ "types": "./dist/exports/types.d.ts",
26
+ "import": "./dist/exports/types.js"
27
+ }
28
+ },
29
+ "scripts": {
30
+ "build": "tsup --config tsup.config.ts",
31
+ "test": "vitest run",
32
+ "test:coverage": "vitest run --coverage",
33
+ "typecheck": "tsc --project tsconfig.json --noEmit",
34
+ "lint": "biome check . --config-path ../../../biome.json --error-on-warnings",
35
+ "clean": "node ../../../scripts/clean.mjs"
36
+ }
37
+ }