@prisma-next/sql-orm-lane 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 +84 -0
- package/dist/chunk-JOTSRS66.js +1707 -0
- package/dist/chunk-JOTSRS66.js.map +1 -0
- package/dist/exports/orm.d.ts +5 -0
- package/dist/exports/orm.js +7 -0
- package/dist/exports/orm.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/orm-C_3ipYf3.d.ts +150 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @prisma-next/sql-orm-lane
|
|
2
|
+
|
|
3
|
+
ORM builder, include compilation, and relation filters for Prisma Next.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides the ORM query builder that compiles model-based queries to SQL lane primitives. It is part of the SQL lanes ring and depends on `@prisma-next/sql-relational-core` for schema access.
|
|
8
|
+
|
|
9
|
+
## Responsibilities
|
|
10
|
+
|
|
11
|
+
- **ORM query builder**: Model-based query builder (`orm()`)
|
|
12
|
+
- **Include compilation**: ORM includes compile to SQL lane primitives like `includeMany`
|
|
13
|
+
- **Relation filters**: Filter queries by related model properties (`some`, `none`, `every`)
|
|
14
|
+
- **Model accessors**: Type-safe access to models and their columns/relations
|
|
15
|
+
|
|
16
|
+
## Dependencies
|
|
17
|
+
|
|
18
|
+
- `@prisma-next/contract` - Contract types and plan metadata
|
|
19
|
+
- `@prisma-next/plan` - Plan helpers and error utilities
|
|
20
|
+
- `@prisma-next/runtime` - Runtime context for adapter access
|
|
21
|
+
- `@prisma-next/sql-relational-core` - Schema and column builders
|
|
22
|
+
- `@prisma-next/sql-target` - SQL contract types and AST definitions
|
|
23
|
+
|
|
24
|
+
## Exports
|
|
25
|
+
|
|
26
|
+
- `.` - Main package export (exports `orm` and related types)
|
|
27
|
+
- `./orm` - ORM builder entry point (`orm()`, `OrmRegistry`, `OrmModelBuilder`, etc.)
|
|
28
|
+
|
|
29
|
+
## Architecture
|
|
30
|
+
|
|
31
|
+
This package compiles ORM queries to SQL lane primitives (AST nodes). Dialect-specific lowering to SQL strings happens in adapters (per ADR 015 and ADR 016).
|
|
32
|
+
|
|
33
|
+
The ORM builder:
|
|
34
|
+
1. Takes model-based queries (e.g., `orm().user().where(...).include(...)`)
|
|
35
|
+
2. Compiles them to SQL lane primitives (e.g., `sql().from(...).where(...).includeMany(...)`)
|
|
36
|
+
3. Returns plans that can be executed by the runtime
|
|
37
|
+
|
|
38
|
+
### Package Structure
|
|
39
|
+
|
|
40
|
+
The package is organized into modular components following a domain-driven structure:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
src/
|
|
44
|
+
├── orm/ # Core ORM builder and state management
|
|
45
|
+
│ ├── builder.ts # Main OrmModelBuilderImpl facade
|
|
46
|
+
│ ├── context.ts # OrmContext and factory
|
|
47
|
+
│ ├── state.ts # Immutable state shapes
|
|
48
|
+
│ └── capabilities.ts # Runtime capability checks
|
|
49
|
+
├── selection/ # Query selection building
|
|
50
|
+
│ ├── predicates.ts # WHERE clause building
|
|
51
|
+
│ ├── ordering.ts # ORDER BY clause building
|
|
52
|
+
│ ├── pagination.ts # LIMIT/OFFSET handling
|
|
53
|
+
│ ├── projection.ts # SELECT projection flattening
|
|
54
|
+
│ ├── join.ts # JOIN ON expression building
|
|
55
|
+
│ └── select-builder.ts # Main SELECT AST assembly
|
|
56
|
+
├── relations/ # Relation handling
|
|
57
|
+
│ └── include-plan.ts # Include AST and EXISTS subquery building
|
|
58
|
+
├── mutations/ # Write operations
|
|
59
|
+
│ ├── insert-builder.ts # INSERT plan building
|
|
60
|
+
│ ├── update-builder.ts # UPDATE plan building
|
|
61
|
+
│ └── delete-builder.ts # DELETE plan building
|
|
62
|
+
├── plan/ # Plan assembly and metadata
|
|
63
|
+
│ ├── plan-assembly.ts # PlanMeta building and Plan creation
|
|
64
|
+
│ ├── lowering.ts # Lane-specific pre-lowering (placeholder)
|
|
65
|
+
│ └── result-typing.ts # Type-level helpers (placeholder)
|
|
66
|
+
├── utils/ # Shared utilities
|
|
67
|
+
│ ├── ast.ts # AST factory wrappers
|
|
68
|
+
│ ├── errors.ts # Centralized error constructors
|
|
69
|
+
│ └── guards.ts # Type guards and helpers
|
|
70
|
+
└── types/ # Internal type exports
|
|
71
|
+
└── internal.ts # Re-exported internal types
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Design Principles:**
|
|
75
|
+
- **Modular**: Each module has a single, well-defined responsibility
|
|
76
|
+
- **Pure helpers**: Utility functions are side-effect free
|
|
77
|
+
- **Centralized errors**: All error messages come from `utils/errors.ts`
|
|
78
|
+
- **Type-safe**: Proper generic types throughout, avoiding `any`
|
|
79
|
+
- **Immutable state**: Builder state is immutable, methods return new instances
|
|
80
|
+
|
|
81
|
+
## Related Packages
|
|
82
|
+
|
|
83
|
+
- `@prisma-next/sql-relational-core` - Provides schema and column builders used by this package
|
|
84
|
+
- `@prisma-next/sql-target` - Defines SQL contract types and AST structures
|