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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"mappings":";;cAiSM,iBAAA;EAAA,SACJ,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,YAAA;IAAA,SACE,QAAA;MAAA,SACE,YAAA;IAAA;EAAA;EAAA,SAGJ,SAAA;IAAA,SACE,IAAA;MAAA;;;;;;;;;;;;;;;;;;WAEF,KAAA;IAAA,SACE,UAAA;MAAA,SACE,gBAAA,oDAAgB,eAAA;MAAA,SAChB,MAAA;QAAA,SACE,OAAA;QAAA,SACA,KAAA;QAAA,SACA,KAAA;MAAA;MAAA,SAEF,WAAA;QAAA,SAEI,OAAA;QAAA,SACA,KAAA;QAAA,SACA,KAAA;MAAA;IAAA;IAAA,SAIN,mBAAA;MAAA,SACE,MAAA;QAAA,SACE,OAAA;QAAA,SACA,KAAA;QAAA,SACA,KAAA;MAAA;IAAA;IAAA,SAGJ,OAAA;MAAA,SAEI,MAAA;MAAA,SACA,QAAA;MAAA,SACA,QAAA;MAAA,SACA,UAAA;IAAA;MAAA,SAGA,MAAA;MAAA,SACA,QAAA;MAAA,SACA,QAAA;MAAA,SACA,UAAA;IAAA;EAAA;AAAA;AAAA,cAMK,aAAA,SAAsB,iBAAA;EAAA,SACxB,YAAA,GAAe,UAAU;AAAA"}
|
package/dist/pack.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SqlRuntimeExtensionDescriptor } from "@prisma-next/sql-runtime";
|
|
2
|
+
import { CodecDescriptorRegistry } from "@prisma-next/sql-relational-core/query-lane-context";
|
|
3
|
+
|
|
4
|
+
//#region src/core/registry.d.ts
|
|
5
|
+
declare const ltreeCodecRegistry: CodecDescriptorRegistry;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/exports/runtime.d.ts
|
|
8
|
+
declare const ltreeRuntimeDescriptor: SqlRuntimeExtensionDescriptor<"postgres">;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ltreeRuntimeDescriptor as default, ltreeCodecRegistry };
|
|
11
|
+
//# sourceMappingURL=runtime.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/registry.ts","../src/exports/runtime.ts"],"mappings":";;;;cAIa,kBAAA,EAAoB,uBACe;;;cCD1C,sBAAA,EAAwB,6BAA6B"}
|
package/dist/runtime.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { n as ltreeQueryOperations, r as ltreeCodecRegistry, t as ltreePackMeta } from "./descriptor-meta-B84muAZG.mjs";
|
|
2
|
+
//#region src/exports/runtime.ts
|
|
3
|
+
const ltreeRuntimeDescriptor = {
|
|
4
|
+
kind: "extension",
|
|
5
|
+
id: ltreePackMeta.id,
|
|
6
|
+
version: ltreePackMeta.version,
|
|
7
|
+
familyId: "sql",
|
|
8
|
+
targetId: "postgres",
|
|
9
|
+
types: { codecTypes: { codecDescriptors: Array.from(ltreeCodecRegistry.values()) } },
|
|
10
|
+
codecs: () => Array.from(ltreeCodecRegistry.values()),
|
|
11
|
+
queryOperations: () => ltreeQueryOperations(),
|
|
12
|
+
create() {
|
|
13
|
+
return {
|
|
14
|
+
familyId: "sql",
|
|
15
|
+
targetId: "postgres"
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ltreeRuntimeDescriptor as default, ltreeCodecRegistry };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=runtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { SqlRuntimeExtensionDescriptor } from \"@prisma-next/sql-runtime\";\nimport { ltreePackMeta, ltreeQueryOperations } from \"../core/descriptor-meta\";\nimport { ltreeCodecRegistry } from \"../core/registry\";\n\nconst ltreeRuntimeDescriptor: SqlRuntimeExtensionDescriptor<\"postgres\"> = {\n kind: \"extension\" as const,\n id: ltreePackMeta.id,\n version: ltreePackMeta.version,\n familyId: \"sql\" as const,\n targetId: \"postgres\" as const,\n types: {\n codecTypes: {\n codecDescriptors: Array.from(ltreeCodecRegistry.values()),\n },\n },\n codecs: () => Array.from(ltreeCodecRegistry.values()),\n queryOperations: () => ltreeQueryOperations(),\n create() {\n return {\n familyId: \"sql\" as const,\n targetId: \"postgres\" as const,\n };\n },\n};\n\nexport { ltreeCodecRegistry };\nexport default ltreeRuntimeDescriptor;\n"],"mappings":";;AAIA,MAAM,yBAAoE;CACxE,MAAM;CACN,IAAI,cAAc;CAClB,SAAS,cAAc;CACvB,UAAU;CACV,UAAU;CACV,OAAO,EACL,YAAY,EACV,kBAAkB,MAAM,KAAK,mBAAmB,OAAO,CAAC,EAC1D,EACF;CACA,cAAc,MAAM,KAAK,mBAAmB,OAAO,CAAC;CACpD,uBAAuB,qBAAqB;CAC5C,SAAS;EACP,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-ltree",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Prisma extension for PostgreSQL ltree
|
|
5
|
-
"license": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Prisma Next extension pack for PostgreSQL's ltree hierarchical tree data type.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/slovakian/prisma-ltree.git",
|
|
9
|
+
"directory": "packages/extension-ltree"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"src"
|
|
14
|
+
],
|
|
6
15
|
"type": "module",
|
|
7
|
-
"
|
|
16
|
+
"sideEffects": false,
|
|
8
17
|
"exports": {
|
|
9
|
-
"
|
|
18
|
+
"./codec-types": "./dist/codec-types.mjs",
|
|
19
|
+
"./column-types": "./dist/column-types.mjs",
|
|
20
|
+
"./control": "./dist/control.mjs",
|
|
21
|
+
"./operation-types": "./dist/operation-types.mjs",
|
|
22
|
+
"./pack": "./dist/pack.mjs",
|
|
23
|
+
"./runtime": "./dist/runtime.mjs",
|
|
10
24
|
"./package.json": "./package.json"
|
|
11
25
|
},
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@prisma-next/contract": "0.14.0",
|
|
31
|
+
"@prisma-next/contract-authoring": "0.14.0",
|
|
32
|
+
"@prisma-next/family-sql": "0.14.0",
|
|
33
|
+
"@prisma-next/framework-components": "0.14.0",
|
|
34
|
+
"@prisma-next/migration-tools": "0.14.0",
|
|
35
|
+
"@prisma-next/sql-contract": "0.14.0",
|
|
36
|
+
"@prisma-next/sql-operations": "0.14.0",
|
|
37
|
+
"@prisma-next/sql-relational-core": "0.14.0",
|
|
38
|
+
"@prisma-next/sql-runtime": "0.14.0",
|
|
39
|
+
"@prisma-next/sql-schema-ir": "0.14.0",
|
|
40
|
+
"@standard-schema/spec": "^1.1.0",
|
|
41
|
+
"arktype": "^2.2.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@electric-sql/pglite": "^0.5.3",
|
|
45
|
+
"@prisma-next/adapter-postgres": "0.14.0",
|
|
46
|
+
"@prisma-next/cli": "0.14.0",
|
|
47
|
+
"@prisma-next/extension-author-tools": "0.14.0",
|
|
48
|
+
"@prisma-next/operations": "0.14.0",
|
|
49
|
+
"@prisma-next/postgres": "0.14.0",
|
|
50
|
+
"@prisma-next/sql-contract-ts": "0.14.0",
|
|
51
|
+
"@prisma-next/target-postgres": "0.14.0",
|
|
52
|
+
"@types/node": "^24",
|
|
53
|
+
"@typescript/native-preview": "7.0.0-dev.20260509.2",
|
|
54
|
+
"@vitest/coverage-v8": "4.1.8",
|
|
55
|
+
"typescript": "^5",
|
|
56
|
+
"vite-plus": "0.1.24"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@prisma-next/adapter-postgres": "0.14.0",
|
|
60
|
+
"typescript": ">=5.9"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@prisma-next/adapter-postgres": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"typescript": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
16
70
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
71
|
+
"node": ">=24"
|
|
72
|
+
},
|
|
73
|
+
"prismaNext": {
|
|
74
|
+
"family": "sql",
|
|
75
|
+
"dialects": [
|
|
76
|
+
"postgres"
|
|
77
|
+
],
|
|
78
|
+
"type": "extension-pack"
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"build": "vp pack",
|
|
82
|
+
"dev": "vp pack --watch",
|
|
83
|
+
"test": "vp test",
|
|
84
|
+
"check": "vp check",
|
|
85
|
+
"build:contract-space": "prisma-next contract emit",
|
|
86
|
+
"check-pins": "prisma-next-check-pins"
|
|
18
87
|
}
|
|
19
|
-
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// ⚠️ GENERATED FILE - DO NOT EDIT
|
|
2
|
+
// This file is automatically generated by 'prisma-next contract emit'.
|
|
3
|
+
// To regenerate, run: prisma-next contract emit
|
|
4
|
+
import type { QueryOperationTypes as PgAdapterQueryOps } from '@prisma-next/adapter-postgres/operation-types';
|
|
5
|
+
import type {
|
|
6
|
+
Bit,
|
|
7
|
+
Char,
|
|
8
|
+
CodecTypes as PgTypes,
|
|
9
|
+
Interval,
|
|
10
|
+
JsonValue,
|
|
11
|
+
Numeric,
|
|
12
|
+
Time,
|
|
13
|
+
Timestamp,
|
|
14
|
+
Timestamptz,
|
|
15
|
+
Timetz,
|
|
16
|
+
VarBit,
|
|
17
|
+
Varchar,
|
|
18
|
+
} from '@prisma-next/target-postgres/codec-types';
|
|
19
|
+
|
|
20
|
+
import type {
|
|
21
|
+
ContractWithTypeMaps,
|
|
22
|
+
TypeMaps as TypeMapsType,
|
|
23
|
+
} from '@prisma-next/sql-contract/types';
|
|
24
|
+
import type {
|
|
25
|
+
Contract as ContractType,
|
|
26
|
+
ExecutionHashBase,
|
|
27
|
+
NamespaceId,
|
|
28
|
+
ProfileHashBase,
|
|
29
|
+
StorageHashBase,
|
|
30
|
+
} from '@prisma-next/contract/types';
|
|
31
|
+
|
|
32
|
+
export type StorageHash =
|
|
33
|
+
StorageHashBase<'sha256:81cc0a29674d926c9089886b1941ba66d6ce26ec5644fc8a0b7c92a5e9e9876e'>;
|
|
34
|
+
export type ExecutionHash = ExecutionHashBase<string>;
|
|
35
|
+
export type ProfileHash =
|
|
36
|
+
ProfileHashBase<'sha256:9c8aa3114e84ed3b7ea2bd57526d9c2e1bf7c5292be694e9d3801f566fda7ccb'>;
|
|
37
|
+
|
|
38
|
+
export type CodecTypes = PgTypes;
|
|
39
|
+
export type LaneCodecTypes = CodecTypes;
|
|
40
|
+
export type QueryOperationTypes = PgAdapterQueryOps<CodecTypes>;
|
|
41
|
+
type DefaultLiteralValue<CodecId extends string, _Encoded> = CodecId extends keyof CodecTypes
|
|
42
|
+
? CodecTypes[CodecId]['output']
|
|
43
|
+
: _Encoded;
|
|
44
|
+
|
|
45
|
+
export type FieldOutputTypes = { readonly public: Record<string, never> };
|
|
46
|
+
export type FieldInputTypes = { readonly public: Record<string, never> };
|
|
47
|
+
export type TypeMaps = TypeMapsType<
|
|
48
|
+
CodecTypes,
|
|
49
|
+
QueryOperationTypes,
|
|
50
|
+
FieldOutputTypes,
|
|
51
|
+
FieldInputTypes
|
|
52
|
+
>;
|
|
53
|
+
|
|
54
|
+
type ContractBase = Omit<
|
|
55
|
+
ContractType<{
|
|
56
|
+
readonly namespaces: {
|
|
57
|
+
readonly public: {
|
|
58
|
+
readonly id: 'public';
|
|
59
|
+
readonly kind: 'postgres-schema';
|
|
60
|
+
readonly entries: { readonly table: {} };
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
readonly types: {
|
|
64
|
+
readonly ltree: {
|
|
65
|
+
readonly kind: 'codec-instance';
|
|
66
|
+
readonly codecId: 'pg/ltree@1';
|
|
67
|
+
readonly nativeType: 'ltree';
|
|
68
|
+
readonly typeParams: Record<string, never>;
|
|
69
|
+
};
|
|
70
|
+
readonly ltreeArray: {
|
|
71
|
+
readonly kind: 'codec-instance';
|
|
72
|
+
readonly codecId: 'pg/ltree-array@1';
|
|
73
|
+
readonly nativeType: 'ltree[]';
|
|
74
|
+
readonly typeParams: Record<string, never>;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
readonly storageHash: StorageHash;
|
|
78
|
+
}>,
|
|
79
|
+
'roots' | 'domain'
|
|
80
|
+
> & {
|
|
81
|
+
readonly target: 'postgres';
|
|
82
|
+
readonly targetFamily: 'sql';
|
|
83
|
+
readonly roots: Record<string, never>;
|
|
84
|
+
readonly domain: {
|
|
85
|
+
readonly namespaces: {
|
|
86
|
+
readonly public: {
|
|
87
|
+
readonly models: Record<string, never>;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
readonly capabilities: {
|
|
92
|
+
readonly postgres: {
|
|
93
|
+
readonly distinctOn: true;
|
|
94
|
+
readonly jsonAgg: true;
|
|
95
|
+
readonly lateral: true;
|
|
96
|
+
readonly limit: true;
|
|
97
|
+
readonly orderBy: true;
|
|
98
|
+
readonly returning: true;
|
|
99
|
+
};
|
|
100
|
+
readonly sql: {
|
|
101
|
+
readonly defaultInInsert: true;
|
|
102
|
+
readonly enums: true;
|
|
103
|
+
readonly lateral: true;
|
|
104
|
+
readonly returning: true;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
readonly extensionPacks: {};
|
|
108
|
+
readonly meta: {};
|
|
109
|
+
|
|
110
|
+
readonly profileHash: ProfileHash;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type Contract = ContractWithTypeMaps<ContractBase, TypeMaps>;
|
|
114
|
+
|
|
115
|
+
export type Namespaces = Contract['storage']['namespaces'];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1",
|
|
3
|
+
"targetFamily": "sql",
|
|
4
|
+
"target": "postgres",
|
|
5
|
+
"profileHash": "sha256:9c8aa3114e84ed3b7ea2bd57526d9c2e1bf7c5292be694e9d3801f566fda7ccb",
|
|
6
|
+
"roots": {},
|
|
7
|
+
"domain": {
|
|
8
|
+
"namespaces": {
|
|
9
|
+
"public": {
|
|
10
|
+
"models": {}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"storage": {
|
|
15
|
+
"namespaces": {
|
|
16
|
+
"public": {
|
|
17
|
+
"entries": {
|
|
18
|
+
"table": {}
|
|
19
|
+
},
|
|
20
|
+
"id": "public",
|
|
21
|
+
"kind": "postgres-schema"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"storageHash": "sha256:81cc0a29674d926c9089886b1941ba66d6ce26ec5644fc8a0b7c92a5e9e9876e",
|
|
25
|
+
"types": {
|
|
26
|
+
"ltree": {
|
|
27
|
+
"codecId": "pg/ltree@1",
|
|
28
|
+
"kind": "codec-instance",
|
|
29
|
+
"nativeType": "ltree"
|
|
30
|
+
},
|
|
31
|
+
"ltreeArray": {
|
|
32
|
+
"codecId": "pg/ltree-array@1",
|
|
33
|
+
"kind": "codec-instance",
|
|
34
|
+
"nativeType": "ltree[]"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"capabilities": {
|
|
39
|
+
"postgres": {
|
|
40
|
+
"distinctOn": true,
|
|
41
|
+
"jsonAgg": true,
|
|
42
|
+
"lateral": true,
|
|
43
|
+
"limit": true,
|
|
44
|
+
"orderBy": true,
|
|
45
|
+
"returning": true
|
|
46
|
+
},
|
|
47
|
+
"sql": {
|
|
48
|
+
"defaultInInsert": true,
|
|
49
|
+
"enums": true,
|
|
50
|
+
"lateral": true,
|
|
51
|
+
"returning": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"extensionPacks": {},
|
|
55
|
+
"meta": {},
|
|
56
|
+
"_generated": {
|
|
57
|
+
"warning": "⚠️ GENERATED FILE - DO NOT EDIT",
|
|
58
|
+
"message": "This file is automatically generated by \"prisma-next contract emit\".",
|
|
59
|
+
"regenerate": "To regenerate, run: prisma-next contract emit"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/contract.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineContract } from "@prisma-next/postgres/contract-builder";
|
|
2
|
+
import { LTREE_ARRAY_CODEC_ID, LTREE_CODEC_ID } from "./core/constants";
|
|
3
|
+
import {
|
|
4
|
+
LTREE_ARRAY_STORAGE_TYPE,
|
|
5
|
+
LTREE_ARRAY_NATIVE_TYPE,
|
|
6
|
+
LTREE_NATIVE_TYPE,
|
|
7
|
+
} from "./core/contract-space-constants";
|
|
8
|
+
|
|
9
|
+
export const contract = defineContract({}, () => ({
|
|
10
|
+
types: {
|
|
11
|
+
[LTREE_NATIVE_TYPE]: {
|
|
12
|
+
kind: "codec-instance",
|
|
13
|
+
codecId: LTREE_CODEC_ID,
|
|
14
|
+
nativeType: LTREE_NATIVE_TYPE,
|
|
15
|
+
typeParams: {},
|
|
16
|
+
},
|
|
17
|
+
[LTREE_ARRAY_STORAGE_TYPE]: {
|
|
18
|
+
kind: "codec-instance",
|
|
19
|
+
codecId: LTREE_ARRAY_CODEC_ID,
|
|
20
|
+
nativeType: LTREE_ARRAY_NATIVE_TYPE,
|
|
21
|
+
typeParams: {},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
models: {},
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
export default contract;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AuthoringTypeNamespace } from "@prisma-next/framework-components/authoring";
|
|
2
|
+
import { LTREE_ARRAY_CODEC_ID, LTREE_CODEC_ID } from "./constants";
|
|
3
|
+
import { LTREE_ARRAY_NATIVE_TYPE, LTREE_NATIVE_TYPE } from "./contract-space-constants";
|
|
4
|
+
|
|
5
|
+
export const ltreeAuthoringTypes = {
|
|
6
|
+
ltree: {
|
|
7
|
+
Ltree: {
|
|
8
|
+
kind: "typeConstructor",
|
|
9
|
+
output: {
|
|
10
|
+
codecId: LTREE_CODEC_ID,
|
|
11
|
+
nativeType: LTREE_NATIVE_TYPE,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
LtreeArray: {
|
|
15
|
+
kind: "typeConstructor",
|
|
16
|
+
output: {
|
|
17
|
+
codecId: LTREE_ARRAY_CODEC_ID,
|
|
18
|
+
nativeType: LTREE_ARRAY_NATIVE_TYPE,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
} as const satisfies AuthoringTypeNamespace;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { JsonValue } from "@prisma-next/contract/types";
|
|
2
|
+
import {
|
|
3
|
+
type AnyCodecDescriptor,
|
|
4
|
+
type CodecCallContext,
|
|
5
|
+
CodecDescriptorImpl,
|
|
6
|
+
CodecImpl,
|
|
7
|
+
type CodecInstanceContext,
|
|
8
|
+
type ColumnHelperFor,
|
|
9
|
+
type ColumnHelperForStrict,
|
|
10
|
+
column,
|
|
11
|
+
voidParamsSchema,
|
|
12
|
+
} from "@prisma-next/framework-components/codec";
|
|
13
|
+
import type { ExtractCodecTypes } from "@prisma-next/sql-relational-core/ast";
|
|
14
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
15
|
+
import {
|
|
16
|
+
LTREE_ARRAY_CODEC_ID,
|
|
17
|
+
LTREE_CODEC_ID,
|
|
18
|
+
LTREE_MAX_LABEL_LENGTH,
|
|
19
|
+
LTREE_MAX_LABELS,
|
|
20
|
+
} from "./constants";
|
|
21
|
+
import { LTREE_ARRAY_NATIVE_TYPE, LTREE_NATIVE_TYPE } from "./contract-space-constants";
|
|
22
|
+
|
|
23
|
+
const LABEL_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
24
|
+
|
|
25
|
+
export function assertValidLtree(value: unknown): asserts value is string {
|
|
26
|
+
if (typeof value !== "string") {
|
|
27
|
+
throw new Error("ltree value must be a string");
|
|
28
|
+
}
|
|
29
|
+
if (value.length === 0) {
|
|
30
|
+
throw new Error("ltree value must not be empty");
|
|
31
|
+
}
|
|
32
|
+
const labels = value.split(".");
|
|
33
|
+
if (labels.length > LTREE_MAX_LABELS) {
|
|
34
|
+
throw new Error(`ltree path exceeds max labels: got ${labels.length}, max ${LTREE_MAX_LABELS}`);
|
|
35
|
+
}
|
|
36
|
+
for (const label of labels) {
|
|
37
|
+
if (label.length === 0) {
|
|
38
|
+
throw new Error(`ltree label must not be empty in path "${value}"`);
|
|
39
|
+
}
|
|
40
|
+
if (label.length > LTREE_MAX_LABEL_LENGTH) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`ltree label exceeds max length: got ${label.length}, max ${LTREE_MAX_LABEL_LENGTH}`,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (!LABEL_PATTERN.test(label)) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`ltree label "${label}" contains invalid characters; allowed: alphanumeric, underscore, hyphen`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class LtreeCodec extends CodecImpl<
|
|
54
|
+
typeof LTREE_CODEC_ID,
|
|
55
|
+
readonly ["equality", "order"],
|
|
56
|
+
string,
|
|
57
|
+
string
|
|
58
|
+
> {
|
|
59
|
+
async encode(value: string, _ctx: CodecCallContext): Promise<string> {
|
|
60
|
+
assertValidLtree(value);
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async decode(wire: string, _ctx: CodecCallContext): Promise<string> {
|
|
65
|
+
return wire;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
encodeJson(value: string): JsonValue {
|
|
69
|
+
assertValidLtree(value);
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
decodeJson(json: JsonValue): string {
|
|
74
|
+
assertValidLtree(json);
|
|
75
|
+
return json;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const LTREE_META = { db: { sql: { postgres: { nativeType: LTREE_NATIVE_TYPE } } } } as const;
|
|
80
|
+
|
|
81
|
+
export class LtreeDescriptor extends CodecDescriptorImpl<void> {
|
|
82
|
+
override readonly codecId = LTREE_CODEC_ID;
|
|
83
|
+
override readonly traits = ["equality", "order"] as const;
|
|
84
|
+
override readonly targetTypes = [LTREE_NATIVE_TYPE] as const;
|
|
85
|
+
override readonly meta = LTREE_META;
|
|
86
|
+
override readonly paramsSchema: StandardSchemaV1<void> = voidParamsSchema;
|
|
87
|
+
override renderOutputType(): string {
|
|
88
|
+
return "string";
|
|
89
|
+
}
|
|
90
|
+
override factory(): (ctx: CodecInstanceContext) => LtreeCodec {
|
|
91
|
+
const shared = new LtreeCodec(this);
|
|
92
|
+
return () => shared;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const ltreeDescriptor = new LtreeDescriptor();
|
|
97
|
+
|
|
98
|
+
export const ltree = () =>
|
|
99
|
+
column(ltreeDescriptor.factory(), ltreeDescriptor.codecId, undefined, LTREE_NATIVE_TYPE);
|
|
100
|
+
|
|
101
|
+
ltree satisfies ColumnHelperFor<LtreeDescriptor>;
|
|
102
|
+
ltree satisfies ColumnHelperForStrict<LtreeDescriptor>;
|
|
103
|
+
|
|
104
|
+
const LTREE_ARRAY_META = {
|
|
105
|
+
db: { sql: { postgres: { nativeType: LTREE_ARRAY_NATIVE_TYPE } } },
|
|
106
|
+
} as const;
|
|
107
|
+
|
|
108
|
+
export class LtreeArrayCodec extends CodecImpl<
|
|
109
|
+
typeof LTREE_ARRAY_CODEC_ID,
|
|
110
|
+
readonly ["equality"],
|
|
111
|
+
readonly string[],
|
|
112
|
+
readonly string[]
|
|
113
|
+
> {
|
|
114
|
+
async encode(value: readonly string[], _ctx: CodecCallContext): Promise<readonly string[]> {
|
|
115
|
+
for (const entry of value) {
|
|
116
|
+
assertValidLtree(entry);
|
|
117
|
+
}
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async decode(wire: readonly string[], _ctx: CodecCallContext): Promise<readonly string[]> {
|
|
122
|
+
return wire;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
encodeJson(value: readonly string[]): JsonValue {
|
|
126
|
+
for (const entry of value) {
|
|
127
|
+
assertValidLtree(entry);
|
|
128
|
+
}
|
|
129
|
+
return [...value];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
decodeJson(json: JsonValue): readonly string[] {
|
|
133
|
+
if (!Array.isArray(json)) {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
return json.map((entry) => {
|
|
137
|
+
assertValidLtree(entry);
|
|
138
|
+
return String(entry);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export class LtreeArrayDescriptor extends CodecDescriptorImpl<void> {
|
|
144
|
+
override readonly codecId = LTREE_ARRAY_CODEC_ID;
|
|
145
|
+
override readonly traits = ["equality"] as const;
|
|
146
|
+
override readonly targetTypes = [LTREE_ARRAY_NATIVE_TYPE] as const;
|
|
147
|
+
override readonly meta = LTREE_ARRAY_META;
|
|
148
|
+
override readonly paramsSchema: StandardSchemaV1<void> = voidParamsSchema;
|
|
149
|
+
override renderOutputType(): string {
|
|
150
|
+
return "readonly string[]";
|
|
151
|
+
}
|
|
152
|
+
override factory(): (ctx: CodecInstanceContext) => LtreeArrayCodec {
|
|
153
|
+
const shared = new LtreeArrayCodec(this);
|
|
154
|
+
return () => shared;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const ltreeArrayDescriptor = new LtreeArrayDescriptor();
|
|
159
|
+
|
|
160
|
+
export const ltreeArray = () =>
|
|
161
|
+
column(
|
|
162
|
+
ltreeArrayDescriptor.factory(),
|
|
163
|
+
ltreeArrayDescriptor.codecId,
|
|
164
|
+
undefined,
|
|
165
|
+
LTREE_ARRAY_NATIVE_TYPE,
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
ltreeArray satisfies ColumnHelperFor<LtreeArrayDescriptor>;
|
|
169
|
+
ltreeArray satisfies ColumnHelperForStrict<LtreeArrayDescriptor>;
|
|
170
|
+
|
|
171
|
+
const codecDescriptorMap = {
|
|
172
|
+
ltree: ltreeDescriptor,
|
|
173
|
+
ltreeArray: ltreeArrayDescriptor,
|
|
174
|
+
} as const;
|
|
175
|
+
|
|
176
|
+
export type CodecTypes = ExtractCodecTypes<typeof codecDescriptorMap>;
|
|
177
|
+
|
|
178
|
+
export const codecDescriptors: readonly AnyCodecDescriptor[] = Object.values(codecDescriptorMap);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const LTREE_SPACE_ID = "ltree" as const;
|
|
2
|
+
|
|
3
|
+
export const LTREE_NATIVE_TYPE = "ltree" as const;
|
|
4
|
+
|
|
5
|
+
export const LTREE_ARRAY_NATIVE_TYPE = "ltree[]" as const;
|
|
6
|
+
|
|
7
|
+
/** Contract storage.types key — must be a valid identifier for contract emit. */
|
|
8
|
+
export const LTREE_ARRAY_STORAGE_TYPE = "ltreeArray" as const;
|
|
9
|
+
|
|
10
|
+
export const LTREE_BASELINE_MIGRATION_NAME = "20260619T2142_install_ltree" as const;
|
|
11
|
+
|
|
12
|
+
export const LTREE_INVARIANTS = {
|
|
13
|
+
installLtree: "ltree:install-ltree-v1",
|
|
14
|
+
} as const;
|