prisma-ltree 0.0.1 → 0.1.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 +194 -3
- package/dist/codec-types-mZn-cIh9.d.mts +73 -0
- package/dist/codec-types-mZn-cIh9.d.mts.map +1 -0
- package/dist/codec-types.d.mts +2 -0
- package/dist/codec-types.mjs +1 -0
- package/dist/column-types.d.mts +8 -0
- package/dist/column-types.d.mts.map +1 -0
- package/dist/column-types.mjs +18 -0
- package/dist/column-types.mjs.map +1 -0
- package/dist/contract-space-constants-Da9EC668.mjs +15 -0
- package/dist/contract-space-constants-Da9EC668.mjs.map +1 -0
- package/dist/control.d.mts +7 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +139 -0
- package/dist/control.mjs.map +1 -0
- package/dist/descriptor-meta-B84muAZG.mjs +345 -0
- package/dist/descriptor-meta-B84muAZG.mjs.map +1 -0
- package/dist/operation-types-CP6jqHAZ.d.mts +184 -0
- package/dist/operation-types-CP6jqHAZ.d.mts.map +1 -0
- package/dist/operation-types.d.mts +2 -0
- package/dist/operation-types.mjs +1 -0
- package/dist/pack.d.mts +73 -0
- package/dist/pack.d.mts.map +1 -0
- package/dist/pack.mjs +2 -0
- package/dist/runtime.d.mts +11 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +22 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +80 -11
- package/src/contract.d.ts +115 -0
- package/src/contract.json +61 -0
- package/src/contract.ts +27 -0
- package/src/core/authoring.ts +22 -0
- package/src/core/codecs.ts +178 -0
- package/src/core/constants.ts +7 -0
- package/src/core/contract-space-constants.ts +14 -0
- package/src/core/descriptor-meta.ts +346 -0
- package/src/core/registry.ts +6 -0
- package/src/exports/codec-types.ts +1 -0
- package/src/exports/column-types.ts +17 -0
- package/src/exports/control.ts +55 -0
- package/src/exports/operation-types.ts +1 -0
- package/src/exports/pack.ts +1 -0
- package/src/exports/runtime.ts +27 -0
- package/src/types/codec-types.ts +7 -0
- package/src/types/operation-types.ts +156 -0
- package/index.js +0 -3
package/README.md
CHANGED
|
@@ -1,9 +1,200 @@
|
|
|
1
1
|
# prisma-ltree
|
|
2
2
|
|
|
3
|
-
Prisma extension for PostgreSQL
|
|
3
|
+
A [Prisma Next](https://github.com/prisma/prisma) extension pack for PostgreSQL's
|
|
4
|
+
[`ltree`](https://www.postgresql.org/docs/current/ltree.html) hierarchical-tree data type.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Model category trees, org charts, taxonomies, and filesystem-like paths in Postgres and query
|
|
7
|
+
them with type-safe, prisma-native operators — ancestor/descendant checks, `lquery`/`ltxtquery`
|
|
8
|
+
pattern matching, path manipulation, and lowest-common-ancestor computation — without dropping to
|
|
9
|
+
raw SQL.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **`ltree` and `ltree[]` columns** — `ltree()` / `ltreeArray()` column helpers
|
|
14
|
+
- **Hierarchy operators** — ancestor and descendant checks
|
|
15
|
+
- **Pattern matching** — `lquery`, `lquery[]`, and `ltxtquery`
|
|
16
|
+
- **Scalar functions** — depth, subpaths, label index, lowest common ancestor
|
|
17
|
+
- **Concatenation & conversion** — path building and `ltree` ↔ `text` conversion
|
|
18
|
+
- **Array first-match** — find the first matching path in an `ltree[]` column
|
|
19
|
+
- **Baseline migration** — installs the Postgres extension via
|
|
20
|
+
`CREATE EXTENSION IF NOT EXISTS ltree` when the pack is composed
|
|
21
|
+
|
|
22
|
+
See the [feature support matrix](https://github.com/slovakian/prisma-ltree/blob/main/docs/feature-support.md)
|
|
23
|
+
for what is supported, planned, or out of scope.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm add prisma-ltree
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Requires Node `>=24` and `@prisma-next/*@0.14.0` (exact pin — see
|
|
32
|
+
[versioning & compatibility](https://github.com/slovakian/prisma-ltree/blob/main/docs/prisma-next/versioning-and-compatibility.md)).
|
|
33
|
+
|
|
34
|
+
### Agent skills (optional)
|
|
35
|
+
|
|
36
|
+
Agent skills for adoption and query patterns ship in the repo under
|
|
37
|
+
[`skills/`](https://github.com/slovakian/prisma-ltree/tree/main/skills):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pnpm dlx skills add slovakian/prisma-ltree --all
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Database setup
|
|
44
|
+
|
|
45
|
+
The extension ships an on-disk baseline migration that installs `ltree` when the pack is composed
|
|
46
|
+
into an application. `prisma-next db init` / `db update` apply it automatically. The equivalent
|
|
47
|
+
manual DDL is:
|
|
48
|
+
|
|
49
|
+
```sql
|
|
50
|
+
CREATE EXTENSION IF NOT EXISTS ltree;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
Add the pack to your `prisma-next.config.ts`:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { defineConfig } from "@prisma-next/cli/config-types";
|
|
59
|
+
import postgresAdapter from "@prisma-next/adapter-postgres/control";
|
|
60
|
+
import sql from "@prisma-next/family-sql/control";
|
|
61
|
+
import postgres from "@prisma-next/target-postgres/control";
|
|
62
|
+
import ltree from "prisma-ltree/control";
|
|
63
|
+
|
|
64
|
+
export default defineConfig({
|
|
65
|
+
family: sql,
|
|
66
|
+
target: postgres,
|
|
67
|
+
adapter: postgresAdapter,
|
|
68
|
+
extensionPacks: [ltree],
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
### Contract definition
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { int4Column, textColumn } from "@prisma-next/adapter-postgres/column-types";
|
|
78
|
+
import sqlFamily from "@prisma-next/family-sql/pack";
|
|
79
|
+
import { defineContract, field, model } from "@prisma-next/sql-contract-ts/contract-builder";
|
|
80
|
+
import { ltree } from "prisma-ltree/column-types";
|
|
81
|
+
import ltreePack from "prisma-ltree/pack";
|
|
82
|
+
import postgres from "@prisma-next/target-postgres/pack";
|
|
83
|
+
|
|
84
|
+
export const contract = defineContract({
|
|
85
|
+
family: sqlFamily,
|
|
86
|
+
target: postgres,
|
|
87
|
+
extensionPacks: { ltree: ltreePack },
|
|
88
|
+
models: {
|
|
89
|
+
Category: model("Category", {
|
|
90
|
+
fields: {
|
|
91
|
+
id: field.column(int4Column).id(),
|
|
92
|
+
name: field.column(textColumn),
|
|
93
|
+
path: field.column(ltree()),
|
|
94
|
+
},
|
|
95
|
+
}).sql({ table: "category" }),
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Runtime setup
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { instantiateExecutionStack } from "@prisma-next/framework-components/execution";
|
|
104
|
+
import { createExecutionContext, createSqlExecutionStack } from "@prisma-next/sql-runtime";
|
|
105
|
+
import postgresAdapter from "@prisma-next/adapter-postgres/runtime";
|
|
106
|
+
import postgresTarget from "@prisma-next/target-postgres/runtime";
|
|
107
|
+
import ltree from "prisma-ltree/runtime";
|
|
108
|
+
|
|
109
|
+
const stack = createSqlExecutionStack({
|
|
110
|
+
target: postgresTarget,
|
|
111
|
+
adapter: postgresAdapter,
|
|
112
|
+
extensionPacks: [ltree],
|
|
113
|
+
});
|
|
114
|
+
const context = createExecutionContext({ contract, stack });
|
|
115
|
+
const stackInstance = instantiateExecutionStack(stack);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Query usage
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { sql, tables } from "../prisma/query";
|
|
122
|
+
import { param } from "@prisma-next/sql-query/param";
|
|
123
|
+
|
|
124
|
+
// Find every descendant of "Top.Science"
|
|
125
|
+
const plan = sql
|
|
126
|
+
.from(tables.category)
|
|
127
|
+
.select({
|
|
128
|
+
id: tables.category.columns.id,
|
|
129
|
+
depth: tables.category.columns.path.nlevel(),
|
|
130
|
+
})
|
|
131
|
+
.where(tables.category.columns.path.isDescendantOf(param("prefix")))
|
|
132
|
+
.build({ params: { prefix: "Top.Science" } });
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Operations
|
|
136
|
+
|
|
137
|
+
### Hierarchy (→ boolean)
|
|
138
|
+
|
|
139
|
+
| Method | SQL |
|
|
140
|
+
| -------------------------- | ---------------- |
|
|
141
|
+
| `path.isAncestorOf(rhs)` | `ltree @> ltree` |
|
|
142
|
+
| `path.isDescendantOf(rhs)` | `ltree <@ ltree` |
|
|
143
|
+
|
|
144
|
+
### Pattern matching (→ boolean)
|
|
145
|
+
|
|
146
|
+
| Method | SQL | Arg |
|
|
147
|
+
| ----------------------------------- | ------------------- | ---------- |
|
|
148
|
+
| `path.matchesLquery(pattern)` | `ltree ~ lquery` | `string` |
|
|
149
|
+
| `path.matchesLqueryArray(patterns)` | `ltree ? lquery[]` | `string[]` |
|
|
150
|
+
| `path.matchesLtxtquery(query)` | `ltree @ ltxtquery` | `string` |
|
|
151
|
+
|
|
152
|
+
### Scalar functions
|
|
153
|
+
|
|
154
|
+
| Method | SQL | Returns |
|
|
155
|
+
| ---------------------------- | ----------------------------- | ------- |
|
|
156
|
+
| `path.nlevel()` | `nlevel(ltree)` | `int` |
|
|
157
|
+
| `path.subltree(start, end)` | `subltree(ltree, start, end)` | `ltree` |
|
|
158
|
+
| `path.subpath(offset, len?)` | `subpath(ltree, offset, len)` | `ltree` |
|
|
159
|
+
| `path.indexOf(other, off?)` | `index(ltree, ltree, off)` | `int` |
|
|
160
|
+
| `path.lca(other, ...rest)` | `lca(ltree, ltree, ...)` | `ltree` |
|
|
161
|
+
|
|
162
|
+
`lca` requires **≥2 paths** and returns the proper (strictly shorter) lowest common ancestor.
|
|
163
|
+
|
|
164
|
+
### Concatenation (→ ltree) & conversion
|
|
165
|
+
|
|
166
|
+
| Method | SQL | Returns |
|
|
167
|
+
| ------------------------- | ------------------- | ------- |
|
|
168
|
+
| `path.concat(rhs)` | `ltree \|\| ltree` | `ltree` |
|
|
169
|
+
| `path.concatText(label)` | `ltree \|\| text` | `ltree` |
|
|
170
|
+
| `path.prependText(label)` | `text \|\| ltree` | `ltree` |
|
|
171
|
+
| `path.toText()` | `ltree2text(ltree)` | `text` |
|
|
172
|
+
| `text.toLtree()` | `text2ltree(text)` | `ltree` |
|
|
173
|
+
|
|
174
|
+
`prependText` keeps the ltree column as the receiver even though it is the right SQL operand.
|
|
175
|
+
`toLtree` is called on a text column.
|
|
176
|
+
|
|
177
|
+
### Array first-match (→ ltree, receiver `ltree[]`)
|
|
178
|
+
|
|
179
|
+
| Method | SQL |
|
|
180
|
+
| ---------------------------------- | ---------------------- |
|
|
181
|
+
| `paths.firstAncestorOf(rhs)` | `ltree[] ?@> ltree` |
|
|
182
|
+
| `paths.firstDescendantOf(rhs)` | `ltree[] ?<@ ltree` |
|
|
183
|
+
| `paths.firstMatchLquery(pattern)` | `ltree[] ?~ lquery` |
|
|
184
|
+
| `paths.firstMatchLtxtquery(query)` | `ltree[] ?@ ltxtquery` |
|
|
185
|
+
|
|
186
|
+
Use `ltreeArray()` for `ltree[]` columns that expose these methods.
|
|
187
|
+
|
|
188
|
+
## Types
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import type { CodecTypes, Ltree, LtreeArray } from "prisma-ltree/codec-types";
|
|
192
|
+
import type { QueryOperationTypes } from "prisma-ltree/operation-types";
|
|
193
|
+
|
|
194
|
+
// CodecTypes['pg/ltree@1']['output'] = string
|
|
195
|
+
// CodecTypes['pg/ltree-array@1']['output'] = readonly string[]
|
|
196
|
+
```
|
|
6
197
|
|
|
7
198
|
## License
|
|
8
199
|
|
|
9
|
-
|
|
200
|
+
Apache-2.0
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CodecCallContext, CodecDescriptorImpl, CodecImpl, CodecInstanceContext } from "@prisma-next/framework-components/codec";
|
|
2
|
+
import { JsonValue } from "@prisma-next/contract/types";
|
|
3
|
+
import { ExtractCodecTypes } from "@prisma-next/sql-relational-core/ast";
|
|
4
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
|
+
|
|
6
|
+
//#region src/core/constants.d.ts
|
|
7
|
+
declare const LTREE_CODEC_ID: "pg/ltree@1";
|
|
8
|
+
declare const LTREE_ARRAY_CODEC_ID: "pg/ltree-array@1";
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/core/codecs.d.ts
|
|
11
|
+
declare class LtreeCodec extends CodecImpl<typeof LTREE_CODEC_ID, readonly ["equality", "order"], string, string> {
|
|
12
|
+
encode(value: string, _ctx: CodecCallContext): Promise<string>;
|
|
13
|
+
decode(wire: string, _ctx: CodecCallContext): Promise<string>;
|
|
14
|
+
encodeJson(value: string): JsonValue;
|
|
15
|
+
decodeJson(json: JsonValue): string;
|
|
16
|
+
}
|
|
17
|
+
declare class LtreeDescriptor extends CodecDescriptorImpl<void> {
|
|
18
|
+
readonly codecId: "pg/ltree@1";
|
|
19
|
+
readonly traits: readonly ["equality", "order"];
|
|
20
|
+
readonly targetTypes: readonly ["ltree"];
|
|
21
|
+
readonly meta: {
|
|
22
|
+
readonly db: {
|
|
23
|
+
readonly sql: {
|
|
24
|
+
readonly postgres: {
|
|
25
|
+
readonly nativeType: "ltree";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
readonly paramsSchema: StandardSchemaV1<void>;
|
|
31
|
+
renderOutputType(): string;
|
|
32
|
+
factory(): (ctx: CodecInstanceContext) => LtreeCodec;
|
|
33
|
+
}
|
|
34
|
+
declare class LtreeArrayCodec extends CodecImpl<typeof LTREE_ARRAY_CODEC_ID, readonly ["equality"], readonly string[], readonly string[]> {
|
|
35
|
+
encode(value: readonly string[], _ctx: CodecCallContext): Promise<readonly string[]>;
|
|
36
|
+
decode(wire: readonly string[], _ctx: CodecCallContext): Promise<readonly string[]>;
|
|
37
|
+
encodeJson(value: readonly string[]): JsonValue;
|
|
38
|
+
decodeJson(json: JsonValue): readonly string[];
|
|
39
|
+
}
|
|
40
|
+
declare class LtreeArrayDescriptor extends CodecDescriptorImpl<void> {
|
|
41
|
+
readonly codecId: "pg/ltree-array@1";
|
|
42
|
+
readonly traits: readonly ["equality"];
|
|
43
|
+
readonly targetTypes: readonly ["ltree[]"];
|
|
44
|
+
readonly meta: {
|
|
45
|
+
readonly db: {
|
|
46
|
+
readonly sql: {
|
|
47
|
+
readonly postgres: {
|
|
48
|
+
readonly nativeType: "ltree[]";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly paramsSchema: StandardSchemaV1<void>;
|
|
54
|
+
renderOutputType(): string;
|
|
55
|
+
factory(): (ctx: CodecInstanceContext) => LtreeArrayCodec;
|
|
56
|
+
}
|
|
57
|
+
declare const codecDescriptorMap: {
|
|
58
|
+
readonly ltree: LtreeDescriptor;
|
|
59
|
+
readonly ltreeArray: LtreeArrayDescriptor;
|
|
60
|
+
};
|
|
61
|
+
type CodecTypes$1 = ExtractCodecTypes<typeof codecDescriptorMap>;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/types/codec-types.d.ts
|
|
64
|
+
type Ltree = string & {
|
|
65
|
+
readonly __ltree?: undefined;
|
|
66
|
+
};
|
|
67
|
+
type LtreeArray = readonly string[] & {
|
|
68
|
+
readonly __ltreeArray?: undefined;
|
|
69
|
+
};
|
|
70
|
+
type CodecTypes = CodecTypes$1;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { Ltree as n, LtreeArray as r, CodecTypes as t };
|
|
73
|
+
//# sourceMappingURL=codec-types-mZn-cIh9.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-types-mZn-cIh9.d.mts","names":[],"sources":["../src/core/constants.ts","../src/core/codecs.ts","../src/types/codec-types.ts"],"mappings":";;;;;;cAAa,cAAA;AAAA,cAEA,oBAAA;;;cCkDA,UAAA,SAAmB,SAAA,QACvB,cAAA;EAKD,MAAA,CAAO,KAAA,UAAe,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAK/C,MAAA,CAAO,IAAA,UAAc,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAIpD,UAAA,CAAW,KAAA,WAAgB,SAAA;EAK3B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAQN,eAAA,SAAwB,mBAAA;EAAA,SACjB,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,IAAA;IAAA;eANO,GAAA;QAAA,SAAO,QAAA;UAAA,SAAY,UAAA;QAAA;MAAA;IAAA;EAAA;EAAA,SAO1B,YAAA,EAAc,gBAAA;EACvB,gBAAA;EAGA,OAAA,KAAY,GAAA,EAAK,oBAAA,KAAyB,UAAA;AAAA;AAAA,cAkBxC,eAAA,SAAwB,SAAA,QAC5B,oBAAA;EAKD,MAAA,CAAO,KAAA,qBAA0B,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAO1D,MAAA,CAAO,IAAA,qBAAyB,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAI/D,UAAA,CAAW,KAAA,sBAA2B,SAAA;EAOtC,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAWN,oBAAA,SAA6B,mBAAA;EAAA,SACtB,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,IAAA;IAAA;eA1CZ,GAAA;QAAA,SAAO,QAAA;UAAA,SAAY,UAAA;QAAA;MAAA;IAAA;EAAA;EAAA,SA2CP,YAAA,EAAc,gBAAA;EACvB,gBAAA;EAGA,OAAA,KAAY,GAAA,EAAK,oBAAA,KAAyB,eAAA;AAAA;AAAA,cAmB/C,kBAAA;EAAA,SACJ,KAAA,EAAK,eAAA;EAAA,SACL,UAAA,EAAU,oBAAA;AAAA;AAAA,KAGA,YAAA,GAAa,iBAAiB,QAAQ,kBAAA;;;KC7KtC,KAAA;EAAA,SAA4B,OAAO;AAAA;AAAA,KAEnC,UAAA;EAAA,SAA4C,YAAY;AAAA;AAAA,KAExD,UAAA,GAAa,YAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnTypeDescriptor } from "@prisma-next/framework-components/codec";
|
|
2
|
+
|
|
3
|
+
//#region src/exports/column-types.d.ts
|
|
4
|
+
declare function ltree(): ColumnTypeDescriptor;
|
|
5
|
+
declare function ltreeArray(): ColumnTypeDescriptor;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { ltree, ltreeArray };
|
|
8
|
+
//# sourceMappingURL=column-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-types.d.mts","names":[],"sources":["../src/exports/column-types.ts"],"mappings":";;;iBAIgB,KAAA,IAAS,oBAAoB;AAAA,iBAO7B,UAAA,IAAc,oBAAoB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { a as LTREE_ARRAY_CODEC_ID, o as LTREE_CODEC_ID, r as LTREE_NATIVE_TYPE, t as LTREE_ARRAY_NATIVE_TYPE } from "./contract-space-constants-Da9EC668.mjs";
|
|
2
|
+
//#region src/exports/column-types.ts
|
|
3
|
+
function ltree() {
|
|
4
|
+
return {
|
|
5
|
+
codecId: LTREE_CODEC_ID,
|
|
6
|
+
nativeType: LTREE_NATIVE_TYPE
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function ltreeArray() {
|
|
10
|
+
return {
|
|
11
|
+
codecId: LTREE_ARRAY_CODEC_ID,
|
|
12
|
+
nativeType: LTREE_ARRAY_NATIVE_TYPE
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ltree, ltreeArray };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=column-types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-types.mjs","names":[],"sources":["../src/exports/column-types.ts"],"sourcesContent":["import type { ColumnTypeDescriptor } from \"@prisma-next/framework-components/codec\";\nimport { LTREE_ARRAY_CODEC_ID, LTREE_CODEC_ID } from \"../core/constants\";\nimport { LTREE_ARRAY_NATIVE_TYPE, LTREE_NATIVE_TYPE } from \"../core/contract-space-constants\";\n\nexport function ltree(): ColumnTypeDescriptor {\n return {\n codecId: LTREE_CODEC_ID,\n nativeType: LTREE_NATIVE_TYPE,\n } as const;\n}\n\nexport function ltreeArray(): ColumnTypeDescriptor {\n return {\n codecId: LTREE_ARRAY_CODEC_ID,\n nativeType: LTREE_ARRAY_NATIVE_TYPE,\n } as const;\n}\n"],"mappings":";;AAIA,SAAgB,QAA8B;CAC5C,OAAO;EACL,SAAS;EACT,YAAY;CACd;AACF;AAEA,SAAgB,aAAmC;CACjD,OAAO;EACL,SAAS;EACT,YAAY;CACd;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/core/constants.ts
|
|
2
|
+
const LTREE_CODEC_ID = "pg/ltree@1";
|
|
3
|
+
const LTREE_ARRAY_CODEC_ID = "pg/ltree-array@1";
|
|
4
|
+
const LTREE_MAX_LABEL_LENGTH = 1e3;
|
|
5
|
+
const LTREE_MAX_LABELS = 65535;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/core/contract-space-constants.ts
|
|
8
|
+
const LTREE_SPACE_ID = "ltree";
|
|
9
|
+
const LTREE_NATIVE_TYPE = "ltree";
|
|
10
|
+
const LTREE_ARRAY_NATIVE_TYPE = "ltree[]";
|
|
11
|
+
const LTREE_BASELINE_MIGRATION_NAME = "20260619T2142_install_ltree";
|
|
12
|
+
//#endregion
|
|
13
|
+
export { LTREE_ARRAY_CODEC_ID as a, LTREE_MAX_LABEL_LENGTH as c, LTREE_SPACE_ID as i, LTREE_BASELINE_MIGRATION_NAME as n, LTREE_CODEC_ID as o, LTREE_NATIVE_TYPE as r, LTREE_MAX_LABELS as s, LTREE_ARRAY_NATIVE_TYPE as t };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=contract-space-constants-Da9EC668.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-space-constants-Da9EC668.mjs","names":[],"sources":["../src/core/constants.ts","../src/core/contract-space-constants.ts"],"sourcesContent":["export const LTREE_CODEC_ID = \"pg/ltree@1\" as const;\n\nexport const LTREE_ARRAY_CODEC_ID = \"pg/ltree-array@1\" as const;\n\nexport const LTREE_MAX_LABEL_LENGTH = 1000;\n\nexport const LTREE_MAX_LABELS = 65535;\n","export const LTREE_SPACE_ID = \"ltree\" as const;\n\nexport const LTREE_NATIVE_TYPE = \"ltree\" as const;\n\nexport const LTREE_ARRAY_NATIVE_TYPE = \"ltree[]\" as const;\n\n/** Contract storage.types key — must be a valid identifier for contract emit. */\nexport const LTREE_ARRAY_STORAGE_TYPE = \"ltreeArray\" as const;\n\nexport const LTREE_BASELINE_MIGRATION_NAME = \"20260619T2142_install_ltree\" as const;\n\nexport const LTREE_INVARIANTS = {\n installLtree: \"ltree:install-ltree-v1\",\n} as const;\n"],"mappings":";AAAA,MAAa,iBAAiB;AAE9B,MAAa,uBAAuB;AAEpC,MAAa,yBAAyB;AAEtC,MAAa,mBAAmB;;;ACNhC,MAAa,iBAAiB;AAE9B,MAAa,oBAAoB;AAEjC,MAAa,0BAA0B;AAKvC,MAAa,gCAAgC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SqlControlExtensionDescriptor } from "@prisma-next/family-sql/control";
|
|
2
|
+
|
|
3
|
+
//#region src/exports/control.d.ts
|
|
4
|
+
declare const ltreeExtensionDescriptor: SqlControlExtensionDescriptor<"postgres">;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { ltreeExtensionDescriptor as default, ltreeExtensionDescriptor };
|
|
7
|
+
//# sourceMappingURL=control.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"mappings":";;;cAgCM,wBAAA,EAA0B,6BAA6B"}
|
package/dist/control.mjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { a as LTREE_ARRAY_CODEC_ID, i as LTREE_SPACE_ID, n as LTREE_BASELINE_MIGRATION_NAME, o as LTREE_CODEC_ID } from "./contract-space-constants-Da9EC668.mjs";
|
|
2
|
+
import { n as ltreeQueryOperations, t as ltreePackMeta } from "./descriptor-meta-B84muAZG.mjs";
|
|
3
|
+
import { contractSpaceFromJson } from "@prisma-next/migration-tools/spaces";
|
|
4
|
+
//#region migrations/app/20260619T2142_install_ltree/migration.json
|
|
5
|
+
var migration_default = {
|
|
6
|
+
from: null,
|
|
7
|
+
to: "sha256:81cc0a29674d926c9089886b1941ba66d6ce26ec5644fc8a0b7c92a5e9e9876e",
|
|
8
|
+
providedInvariants: ["ltree:install-ltree-v1"],
|
|
9
|
+
createdAt: "2026-06-19T21:42:51.612Z",
|
|
10
|
+
migrationHash: "sha256:12135607df23ecea31aaf9e402703096cfcb236abf9e48a6797de2e74208700a"
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region migrations/app/20260619T2142_install_ltree/ops.json
|
|
14
|
+
var ops_default = [{
|
|
15
|
+
"id": "ltree.install-ltree-extension",
|
|
16
|
+
"label": "Enable extension \"ltree\"",
|
|
17
|
+
"operationClass": "additive",
|
|
18
|
+
"invariantId": "ltree:install-ltree-v1",
|
|
19
|
+
"target": {
|
|
20
|
+
"id": "postgres",
|
|
21
|
+
"details": {
|
|
22
|
+
"schema": "public",
|
|
23
|
+
"objectType": "dependency",
|
|
24
|
+
"name": "ltree"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"precheck": [{
|
|
28
|
+
"description": "verify extension \"ltree\" is not already enabled",
|
|
29
|
+
"sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_extension\" WHERE \"extname\" = $1) AS \"result\"",
|
|
30
|
+
"params": ["ltree"]
|
|
31
|
+
}],
|
|
32
|
+
"execute": [{
|
|
33
|
+
"description": "create extension \"ltree\"",
|
|
34
|
+
"sql": "CREATE EXTENSION IF NOT EXISTS ltree"
|
|
35
|
+
}],
|
|
36
|
+
"postcheck": [{
|
|
37
|
+
"description": "confirm extension \"ltree\" is enabled",
|
|
38
|
+
"sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_extension\" WHERE \"extname\" = $1) AS \"result\"",
|
|
39
|
+
"params": ["ltree"]
|
|
40
|
+
}]
|
|
41
|
+
}];
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region migrations/app/refs/head.json
|
|
44
|
+
var head_default = {
|
|
45
|
+
hash: "sha256:81cc0a29674d926c9089886b1941ba66d6ce26ec5644fc8a0b7c92a5e9e9876e",
|
|
46
|
+
invariants: ["ltree:install-ltree-v1"]
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/contract.json
|
|
50
|
+
var contract_default = {
|
|
51
|
+
schemaVersion: "1",
|
|
52
|
+
targetFamily: "sql",
|
|
53
|
+
target: "postgres",
|
|
54
|
+
profileHash: "sha256:9c8aa3114e84ed3b7ea2bd57526d9c2e1bf7c5292be694e9d3801f566fda7ccb",
|
|
55
|
+
roots: {},
|
|
56
|
+
domain: { "namespaces": { "public": { "models": {} } } },
|
|
57
|
+
storage: {
|
|
58
|
+
"namespaces": { "public": {
|
|
59
|
+
"entries": { "table": {} },
|
|
60
|
+
"id": "public",
|
|
61
|
+
"kind": "postgres-schema"
|
|
62
|
+
} },
|
|
63
|
+
"storageHash": "sha256:81cc0a29674d926c9089886b1941ba66d6ce26ec5644fc8a0b7c92a5e9e9876e",
|
|
64
|
+
"types": {
|
|
65
|
+
"ltree": {
|
|
66
|
+
"codecId": "pg/ltree@1",
|
|
67
|
+
"kind": "codec-instance",
|
|
68
|
+
"nativeType": "ltree"
|
|
69
|
+
},
|
|
70
|
+
"ltreeArray": {
|
|
71
|
+
"codecId": "pg/ltree-array@1",
|
|
72
|
+
"kind": "codec-instance",
|
|
73
|
+
"nativeType": "ltree[]"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
capabilities: {
|
|
78
|
+
"postgres": {
|
|
79
|
+
"distinctOn": true,
|
|
80
|
+
"jsonAgg": true,
|
|
81
|
+
"lateral": true,
|
|
82
|
+
"limit": true,
|
|
83
|
+
"orderBy": true,
|
|
84
|
+
"returning": true
|
|
85
|
+
},
|
|
86
|
+
"sql": {
|
|
87
|
+
"defaultInInsert": true,
|
|
88
|
+
"enums": true,
|
|
89
|
+
"lateral": true,
|
|
90
|
+
"returning": true
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
extensionPacks: {},
|
|
94
|
+
meta: {},
|
|
95
|
+
_generated: {
|
|
96
|
+
"warning": "⚠️ GENERATED FILE - DO NOT EDIT",
|
|
97
|
+
"message": "This file is automatically generated by \"prisma-next contract emit\".",
|
|
98
|
+
"regenerate": "To regenerate, run: prisma-next contract emit"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/exports/control.ts
|
|
103
|
+
const ltreeControlPlaneHooks = {
|
|
104
|
+
expandNativeType: ({ nativeType }) => nativeType,
|
|
105
|
+
resolveIdentityValue: () => null
|
|
106
|
+
};
|
|
107
|
+
const ltreeContractSpace = contractSpaceFromJson({
|
|
108
|
+
contractJson: contract_default,
|
|
109
|
+
migrations: [{
|
|
110
|
+
dirName: LTREE_BASELINE_MIGRATION_NAME,
|
|
111
|
+
metadata: migration_default,
|
|
112
|
+
ops: ops_default
|
|
113
|
+
}],
|
|
114
|
+
headRef: head_default
|
|
115
|
+
});
|
|
116
|
+
const ltreeExtensionDescriptor = {
|
|
117
|
+
...ltreePackMeta,
|
|
118
|
+
id: LTREE_SPACE_ID,
|
|
119
|
+
contractSpace: ltreeContractSpace,
|
|
120
|
+
types: {
|
|
121
|
+
...ltreePackMeta.types,
|
|
122
|
+
codecTypes: {
|
|
123
|
+
...ltreePackMeta.types.codecTypes,
|
|
124
|
+
controlPlaneHooks: {
|
|
125
|
+
[LTREE_CODEC_ID]: ltreeControlPlaneHooks,
|
|
126
|
+
[LTREE_ARRAY_CODEC_ID]: ltreeControlPlaneHooks
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
queryOperations: () => ltreeQueryOperations(),
|
|
131
|
+
create: () => ({
|
|
132
|
+
familyId: "sql",
|
|
133
|
+
targetId: "postgres"
|
|
134
|
+
})
|
|
135
|
+
};
|
|
136
|
+
//#endregion
|
|
137
|
+
export { ltreeExtensionDescriptor as default, ltreeExtensionDescriptor };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=control.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.mjs","names":["baselineMetadata","baselineOps"],"sources":["../migrations/app/20260619T2142_install_ltree/migration.json","../migrations/app/20260619T2142_install_ltree/ops.json","../migrations/app/refs/head.json","../src/contract.json","../src/exports/control.ts"],"sourcesContent":["","","","","import type { Contract } from \"@prisma-next/contract/types\";\nimport type {\n CodecControlHooks,\n SqlControlExtensionDescriptor,\n} from \"@prisma-next/family-sql/control\";\nimport { contractSpaceFromJson } from \"@prisma-next/migration-tools/spaces\";\nimport type { SqlStorage } from \"@prisma-next/sql-contract/types\";\nimport baselineMetadata from \"../../migrations/app/20260619T2142_install_ltree/migration.json\" with { type: \"json\" };\nimport baselineOps from \"../../migrations/app/20260619T2142_install_ltree/ops.json\" with { type: \"json\" };\nimport headRef from \"../../migrations/app/refs/head.json\" with { type: \"json\" };\nimport contractJson from \"../contract.json\" with { type: \"json\" };\nimport { LTREE_ARRAY_CODEC_ID, LTREE_CODEC_ID } from \"../core/constants\";\nimport { LTREE_SPACE_ID, LTREE_BASELINE_MIGRATION_NAME } from \"../core/contract-space-constants\";\nimport { ltreePackMeta, ltreeQueryOperations } from \"../core/descriptor-meta\";\n\nconst ltreeControlPlaneHooks: CodecControlHooks = {\n expandNativeType: ({ nativeType }) => nativeType,\n resolveIdentityValue: () => null,\n};\n\nconst ltreeContractSpace = contractSpaceFromJson<Contract<SqlStorage>>({\n contractJson,\n migrations: [\n {\n dirName: LTREE_BASELINE_MIGRATION_NAME,\n metadata: baselineMetadata,\n ops: baselineOps,\n },\n ],\n headRef,\n});\n\nconst ltreeExtensionDescriptor: SqlControlExtensionDescriptor<\"postgres\"> = {\n ...ltreePackMeta,\n id: LTREE_SPACE_ID,\n contractSpace: ltreeContractSpace,\n types: {\n ...ltreePackMeta.types,\n codecTypes: {\n ...ltreePackMeta.types.codecTypes,\n controlPlaneHooks: {\n [LTREE_CODEC_ID]: ltreeControlPlaneHooks,\n [LTREE_ARRAY_CODEC_ID]: ltreeControlPlaneHooks,\n },\n },\n },\n queryOperations: () => ltreeQueryOperations(),\n create: () => ({\n familyId: \"sql\" as const,\n targetId: \"postgres\" as const,\n }),\n};\n\nexport { ltreeExtensionDescriptor };\nexport default ltreeExtensionDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIeA,MAAM,yBAA4C;CAChD,mBAAmB,EAAE,iBAAiB;CACtC,4BAA4B;AAC9B;AAEA,MAAM,qBAAqB,sBAA4C;CACrE,cAAA;CACA,YAAY,CACV;EACE,SAAS;EACT,UAAUA;EACV,KAAKC;CACP,CACF;CACA,SAAA;AACF,CAAC;AAED,MAAM,2BAAsE;CAC1E,GAAG;CACH,IAAI;CACJ,eAAe;CACf,OAAO;EACL,GAAG,cAAc;EACjB,YAAY;GACV,GAAG,cAAc,MAAM;GACvB,mBAAmB;KAChB,iBAAiB;KACjB,uBAAuB;GAC1B;EACF;CACF;CACA,uBAAuB,qBAAqB;CAC5C,eAAe;EACb,UAAU;EACV,UAAU;CACZ;AACF"}
|