@prisma-next/sql-runtime 0.1.0-dev.15 → 0.1.0-dev.17
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/accelerate-EEKAFGN3-SHR4XFVV.js +137863 -0
- package/dist/accelerate-EEKAFGN3-SHR4XFVV.js.map +1 -0
- package/dist/amcheck-24VY6X5V.js +13 -0
- package/dist/amcheck-24VY6X5V.js.map +1 -0
- package/dist/bloom-VS74NLHT.js +13 -0
- package/dist/bloom-VS74NLHT.js.map +1 -0
- package/dist/btree_gin-WBC4EAAI.js +13 -0
- package/dist/btree_gin-WBC4EAAI.js.map +1 -0
- package/dist/btree_gist-UNC6QD3M.js +13 -0
- package/dist/btree_gist-UNC6QD3M.js.map +1 -0
- package/dist/chunk-3KTOEDFX.js +49 -0
- package/dist/chunk-3KTOEDFX.js.map +1 -0
- package/dist/chunk-47DZBRQC.js +1280 -0
- package/dist/chunk-47DZBRQC.js.map +1 -0
- package/dist/chunk-52N6AFZM.js +133 -0
- package/dist/chunk-52N6AFZM.js.map +1 -0
- package/dist/chunk-7D4SUZUM.js +38 -0
- package/dist/chunk-7D4SUZUM.js.map +1 -0
- package/dist/chunk-7UNP42HJ.js +455 -0
- package/dist/chunk-7UNP42HJ.js.map +1 -0
- package/dist/chunk-ECWIHLAT.js +37 -0
- package/dist/chunk-ECWIHLAT.js.map +1 -0
- package/dist/chunk-EI626SDC.js +105 -0
- package/dist/chunk-EI626SDC.js.map +1 -0
- package/dist/chunk-UKKOYUGL.js +578 -0
- package/dist/chunk-UKKOYUGL.js.map +1 -0
- package/dist/chunk-XPLNMXQV.js +1537 -0
- package/dist/chunk-XPLNMXQV.js.map +1 -0
- package/dist/citext-T7MXGUY7.js +13 -0
- package/dist/citext-T7MXGUY7.js.map +1 -0
- package/dist/client-5FENX6AW.js +299 -0
- package/dist/client-5FENX6AW.js.map +1 -0
- package/dist/cube-TFDQBZCI.js +13 -0
- package/dist/cube-TFDQBZCI.js.map +1 -0
- package/dist/dict_int-AEUOPGWP.js +13 -0
- package/dist/dict_int-AEUOPGWP.js.map +1 -0
- package/dist/dict_xsyn-DAAYX3FL.js +13 -0
- package/dist/dict_xsyn-DAAYX3FL.js.map +1 -0
- package/dist/dist-LBVX6BJW.js +189 -0
- package/dist/dist-LBVX6BJW.js.map +1 -0
- package/dist/dist-LCVVJCGI.js +570 -0
- package/dist/dist-LCVVJCGI.js.map +1 -0
- package/dist/dist-WLKUVDN2.js +5127 -0
- package/dist/dist-WLKUVDN2.js.map +1 -0
- package/dist/earthdistance-KIGTF4LE.js +13 -0
- package/dist/earthdistance-KIGTF4LE.js.map +1 -0
- package/dist/file_fdw-5N55UP6I.js +13 -0
- package/dist/file_fdw-5N55UP6I.js.map +1 -0
- package/dist/fuzzystrmatch-KN3YWBFP.js +13 -0
- package/dist/fuzzystrmatch-KN3YWBFP.js.map +1 -0
- package/dist/hstore-YX726NKN.js +13 -0
- package/dist/hstore-YX726NKN.js.map +1 -0
- package/dist/http-exception-FZY2H4OF.js +8 -0
- package/dist/http-exception-FZY2H4OF.js.map +1 -0
- package/dist/index.d.ts +7 -59
- package/dist/index.js +15 -439
- package/dist/index.js.map +1 -1
- package/dist/intarray-NKVXNO2D.js +13 -0
- package/dist/intarray-NKVXNO2D.js.map +1 -0
- package/dist/isn-FTEMJGEV.js +13 -0
- package/dist/isn-FTEMJGEV.js.map +1 -0
- package/dist/lo-DB7L4NGI.js +13 -0
- package/dist/lo-DB7L4NGI.js.map +1 -0
- package/dist/logger-WQ7SHNDD.js +68 -0
- package/dist/logger-WQ7SHNDD.js.map +1 -0
- package/dist/ltree-Z32TZT6W.js +13 -0
- package/dist/ltree-Z32TZT6W.js.map +1 -0
- package/dist/nodefs-NM46ACH7.js +31 -0
- package/dist/nodefs-NM46ACH7.js.map +1 -0
- package/dist/opfs-ahp-NJO33LVZ.js +332 -0
- package/dist/opfs-ahp-NJO33LVZ.js.map +1 -0
- package/dist/pageinspect-YP3IZR4X.js +13 -0
- package/dist/pageinspect-YP3IZR4X.js.map +1 -0
- package/dist/pg_buffercache-7TD5J2FB.js +13 -0
- package/dist/pg_buffercache-7TD5J2FB.js.map +1 -0
- package/dist/pg_dump-SG4KYBUB.js +2492 -0
- package/dist/pg_dump-SG4KYBUB.js.map +1 -0
- package/dist/pg_freespacemap-DZDNCPZK.js +13 -0
- package/dist/pg_freespacemap-DZDNCPZK.js.map +1 -0
- package/dist/pg_surgery-J2MUEWEP.js +13 -0
- package/dist/pg_surgery-J2MUEWEP.js.map +1 -0
- package/dist/pg_trgm-7VNQOYS6.js +13 -0
- package/dist/pg_trgm-7VNQOYS6.js.map +1 -0
- package/dist/pg_visibility-TTSIPHFL.js +13 -0
- package/dist/pg_visibility-TTSIPHFL.js.map +1 -0
- package/dist/pg_walinspect-KPFHSHRJ.js +13 -0
- package/dist/pg_walinspect-KPFHSHRJ.js.map +1 -0
- package/dist/proxy-signals-GUDAMDHV.js +39 -0
- package/dist/proxy-signals-GUDAMDHV.js.map +1 -0
- package/dist/seg-IYVDLE4O.js +13 -0
- package/dist/seg-IYVDLE4O.js.map +1 -0
- package/dist/sql-runtime-qPimiOqJ.d.ts +63 -0
- package/dist/tablefunc-EF4RCS7S.js +13 -0
- package/dist/tablefunc-EF4RCS7S.js.map +1 -0
- package/dist/tcn-3VT5BQYW.js +13 -0
- package/dist/tcn-3VT5BQYW.js.map +1 -0
- package/dist/test/utils.d.ts +60 -0
- package/dist/test/utils.js +24604 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/tiny-CW6F4GX6.js +10 -0
- package/dist/tiny-CW6F4GX6.js.map +1 -0
- package/dist/tsm_system_rows-ES7KNUQH.js +13 -0
- package/dist/tsm_system_rows-ES7KNUQH.js.map +1 -0
- package/dist/tsm_system_time-76WEIMBG.js +13 -0
- package/dist/tsm_system_time-76WEIMBG.js.map +1 -0
- package/dist/unaccent-7RYF3R64.js +13 -0
- package/dist/unaccent-7RYF3R64.js.map +1 -0
- package/dist/utility-Q5A254LJ-J4HTKZPT.js +347 -0
- package/dist/utility-Q5A254LJ-J4HTKZPT.js.map +1 -0
- package/dist/uuid_ossp-4ETE4FPE.js +13 -0
- package/dist/uuid_ossp-4ETE4FPE.js.map +1 -0
- package/dist/vector-74GPNV7V.js +13 -0
- package/dist/vector-74GPNV7V.js.map +1 -0
- package/package.json +9 -9
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
u
|
|
3
|
+
} from "./chunk-3KTOEDFX.js";
|
|
4
|
+
import "./chunk-7D4SUZUM.js";
|
|
5
|
+
|
|
6
|
+
// ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/earthdistance.js
|
|
7
|
+
u();
|
|
8
|
+
var t = async (n, s) => ({ bundlePath: new URL("../earthdistance.tar.gz", import.meta.url) });
|
|
9
|
+
var r = { name: "earthdistance", setup: t };
|
|
10
|
+
export {
|
|
11
|
+
r as earthdistance
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=earthdistance-KIGTF4LE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/earthdistance.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/earthdistance.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const earthdistance = {\n name: 'earthdistance',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,2BAAA,YAAsC,GAAA,EAAA;AAF9D,IAE8D,IAAA,EAAA,MAC5D,iBAIM,OAAA,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
u
|
|
3
|
+
} from "./chunk-3KTOEDFX.js";
|
|
4
|
+
import "./chunk-7D4SUZUM.js";
|
|
5
|
+
|
|
6
|
+
// ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/file_fdw.js
|
|
7
|
+
u();
|
|
8
|
+
var t = async (n, s) => ({ bundlePath: new URL("../file_fdw.tar.gz", import.meta.url) });
|
|
9
|
+
var a = { name: "file_fdw", setup: t };
|
|
10
|
+
export {
|
|
11
|
+
a as file_fdw
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=file_fdw-5N55UP6I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/file_fdw.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/file_fdw.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const file_fdw = {\n name: 'file_fdw',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,sBAAA,YAAiC,GAAA,EAAA;AAFzD,IAEyD,IAAA,EAAA,MACvD,YAIM,OAAA,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
u
|
|
3
|
+
} from "./chunk-3KTOEDFX.js";
|
|
4
|
+
import "./chunk-7D4SUZUM.js";
|
|
5
|
+
|
|
6
|
+
// ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/fuzzystrmatch.js
|
|
7
|
+
u();
|
|
8
|
+
var e = async (s, n) => ({ bundlePath: new URL("../fuzzystrmatch.tar.gz", import.meta.url) });
|
|
9
|
+
var i = { name: "fuzzystrmatch", setup: e };
|
|
10
|
+
export {
|
|
11
|
+
i as fuzzystrmatch
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=fuzzystrmatch-KN3YWBFP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/fuzzystrmatch.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/fuzzystrmatch.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const fuzzystrmatch = {\n name: 'fuzzystrmatch',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,2BAAA,YAAsC,GAAA,EAAA;AAF9D,IAE8D,IAAA,EAAA,MAC5D,iBAIM,OAAA,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
u
|
|
3
|
+
} from "./chunk-3KTOEDFX.js";
|
|
4
|
+
import "./chunk-7D4SUZUM.js";
|
|
5
|
+
|
|
6
|
+
// ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/hstore.js
|
|
7
|
+
u();
|
|
8
|
+
var t = async (s, n) => ({ bundlePath: new URL("../hstore.tar.gz", import.meta.url) });
|
|
9
|
+
var o = { name: "hstore", setup: t };
|
|
10
|
+
export {
|
|
11
|
+
o as hstore
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=hstore-YX726NKN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/hstore.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/hstore.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const hstore = {\n name: 'hstore',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,oBAAA,YAA+B,GAAA,EAAA;AAFvD,IAEuD,IAAA,EAAA,MACrD,UAIA,OAAM,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
import { MarkerStatement, AsyncIterableResult, RuntimeTelemetryEvent, RuntimeVerifyOptions, Plugin, Log } from '@prisma-next/runtime-executor';
|
|
2
1
|
export { AfterExecuteResult, BudgetsOptions, LintsOptions, Log, Plugin, PluginContext, RuntimeTelemetryEvent, RuntimeVerifyOptions, TelemetryOutcome, budgets, lints } from '@prisma-next/runtime-executor';
|
|
3
2
|
import { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
4
|
-
import { CodecRegistry
|
|
3
|
+
import { CodecRegistry } from '@prisma-next/sql-relational-core/ast';
|
|
5
4
|
import { ExecutionPlan } from '@prisma-next/contract/types';
|
|
6
5
|
import { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import
|
|
6
|
+
import { R as RuntimeContext } from './sql-runtime-qPimiOqJ.js';
|
|
7
|
+
export { E as Extension, b as Runtime, d as RuntimeOptions, S as SqlStatement, f as createRuntime, c as createRuntimeContext, e as ensureSchemaStatement, a as ensureTableStatement, r as readContractMarker, w as writeContractMarker } from './sql-runtime-qPimiOqJ.js';
|
|
8
|
+
import '@prisma-next/operations';
|
|
9
|
+
import '@prisma-next/sql-operations';
|
|
10
|
+
import '@prisma-next/sql-relational-core/query-lane-context';
|
|
10
11
|
|
|
11
12
|
declare function extractCodecIds(contract: SqlContract<SqlStorage>): Set<string>;
|
|
12
13
|
declare function validateContractCodecMappings(registry: CodecRegistry, contract: SqlContract<SqlStorage>): void;
|
|
13
14
|
declare function validateCodecRegistryCompleteness(registry: CodecRegistry, contract: SqlContract<SqlStorage>): void;
|
|
14
15
|
|
|
15
|
-
interface RuntimeContext<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> extends QueryLaneContext<TContract> {
|
|
16
|
-
readonly adapter: Adapter<QueryAst, TContract, LoweredStatement> | Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;
|
|
17
|
-
}
|
|
18
|
-
interface Extension {
|
|
19
|
-
codecs?(): CodecRegistry;
|
|
20
|
-
operations?(): ReadonlyArray<SqlOperationSignature>;
|
|
21
|
-
}
|
|
22
|
-
interface CreateRuntimeContextOptions<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> {
|
|
23
|
-
readonly contract: TContract;
|
|
24
|
-
readonly adapter: Adapter<QueryAst, TContract, LoweredStatement> | Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;
|
|
25
|
-
readonly extensions?: ReadonlyArray<Extension>;
|
|
26
|
-
}
|
|
27
|
-
declare function createRuntimeContext<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>>(options: CreateRuntimeContextOptions<TContract>): RuntimeContext<TContract>;
|
|
28
|
-
|
|
29
16
|
/**
|
|
30
17
|
* Lowers a SQL query plan to an executable Plan by calling the adapter's lower method.
|
|
31
18
|
*
|
|
@@ -38,43 +25,4 @@ declare function createRuntimeContext<TContract extends SqlContract<SqlStorage>
|
|
|
38
25
|
*/
|
|
39
26
|
declare function lowerSqlPlan<Row>(context: RuntimeContext, queryPlan: SqlQueryPlan<Row>): ExecutionPlan<Row>;
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
readonly sql: string;
|
|
43
|
-
readonly params: readonly unknown[];
|
|
44
|
-
}
|
|
45
|
-
interface WriteMarkerInput {
|
|
46
|
-
readonly coreHash: string;
|
|
47
|
-
readonly profileHash: string;
|
|
48
|
-
readonly contractJson?: unknown;
|
|
49
|
-
readonly canonicalVersion?: number;
|
|
50
|
-
readonly appTag?: string;
|
|
51
|
-
readonly meta?: Record<string, unknown>;
|
|
52
|
-
}
|
|
53
|
-
declare const ensureSchemaStatement: SqlStatement;
|
|
54
|
-
declare const ensureTableStatement: SqlStatement;
|
|
55
|
-
declare function readContractMarker(): MarkerStatement;
|
|
56
|
-
interface WriteContractMarkerStatements {
|
|
57
|
-
readonly insert: SqlStatement;
|
|
58
|
-
readonly update: SqlStatement;
|
|
59
|
-
}
|
|
60
|
-
declare function writeContractMarker(input: WriteMarkerInput): WriteContractMarkerStatements;
|
|
61
|
-
|
|
62
|
-
interface RuntimeOptions<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> {
|
|
63
|
-
readonly adapter: Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>;
|
|
64
|
-
readonly driver: SqlDriver;
|
|
65
|
-
readonly verify: RuntimeVerifyOptions;
|
|
66
|
-
readonly context: RuntimeContext<TContract>;
|
|
67
|
-
readonly plugins?: readonly Plugin<TContract, Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>, SqlDriver>[];
|
|
68
|
-
readonly mode?: 'strict' | 'permissive';
|
|
69
|
-
readonly log?: Log;
|
|
70
|
-
}
|
|
71
|
-
interface Runtime {
|
|
72
|
-
execute<Row = Record<string, unknown>>(plan: ExecutionPlan<Row> | SqlQueryPlan<Row>): AsyncIterableResult<Row>;
|
|
73
|
-
telemetry(): RuntimeTelemetryEvent | null;
|
|
74
|
-
close(): Promise<void>;
|
|
75
|
-
operations(): OperationRegistry;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
declare function createRuntime<TContract extends SqlContract<SqlStorage>>(options: RuntimeOptions<TContract>): Runtime;
|
|
79
|
-
|
|
80
|
-
export { type Extension, type Runtime, type RuntimeContext, type RuntimeOptions, type SqlStatement, createRuntime, createRuntimeContext, ensureSchemaStatement, ensureTableStatement, extractCodecIds, lowerSqlPlan, readContractMarker, validateCodecRegistryCompleteness, validateContractCodecMappings, writeContractMarker };
|
|
28
|
+
export { RuntimeContext, extractCodecIds, lowerSqlPlan, validateCodecRegistryCompleteness, validateContractCodecMappings };
|
package/dist/index.js
CHANGED
|
@@ -1,442 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function extractCodecIdsFromColumns(contract) {
|
|
17
|
-
const codecIds = /* @__PURE__ */ new Map();
|
|
18
|
-
for (const [tableName, table] of Object.entries(contract.storage.tables)) {
|
|
19
|
-
for (const [columnName, column] of Object.entries(table.columns)) {
|
|
20
|
-
const codecId = column.codecId;
|
|
21
|
-
const key = `${tableName}.${columnName}`;
|
|
22
|
-
codecIds.set(key, codecId);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return codecIds;
|
|
26
|
-
}
|
|
27
|
-
function validateContractCodecMappings(registry, contract) {
|
|
28
|
-
const codecIds = extractCodecIdsFromColumns(contract);
|
|
29
|
-
const invalidCodecs = [];
|
|
30
|
-
for (const [key, codecId] of codecIds.entries()) {
|
|
31
|
-
if (!registry.has(codecId)) {
|
|
32
|
-
const parts = key.split(".");
|
|
33
|
-
const table = parts[0] ?? "";
|
|
34
|
-
const column = parts[1] ?? "";
|
|
35
|
-
invalidCodecs.push({ table, column, codecId });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (invalidCodecs.length > 0) {
|
|
39
|
-
const details = {
|
|
40
|
-
contractTarget: contract.target,
|
|
41
|
-
invalidCodecs
|
|
42
|
-
};
|
|
43
|
-
throw runtimeError(
|
|
44
|
-
"RUNTIME.CODEC_MISSING",
|
|
45
|
-
`Missing codec implementations for column codecIds: ${invalidCodecs.map((c) => `${c.table}.${c.column} (${c.codecId})`).join(", ")}`,
|
|
46
|
-
details
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function validateCodecRegistryCompleteness(registry, contract) {
|
|
51
|
-
validateContractCodecMappings(registry, contract);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// src/lower-sql-plan.ts
|
|
55
|
-
function lowerSqlPlan(context, queryPlan) {
|
|
56
|
-
const lowered = context.adapter.lower(queryPlan.ast, {
|
|
57
|
-
contract: context.contract,
|
|
58
|
-
params: queryPlan.params
|
|
59
|
-
});
|
|
60
|
-
const body = lowered.body;
|
|
61
|
-
return Object.freeze({
|
|
62
|
-
sql: body.sql,
|
|
63
|
-
params: body.params ?? queryPlan.params,
|
|
64
|
-
ast: queryPlan.ast,
|
|
65
|
-
meta: queryPlan.meta
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// src/sql-context.ts
|
|
70
|
-
import { createOperationRegistry } from "@prisma-next/operations";
|
|
71
|
-
import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
|
|
72
|
-
function createRuntimeContext(options) {
|
|
73
|
-
const { contract, adapter, extensions } = options;
|
|
74
|
-
const codecRegistry = createCodecRegistry();
|
|
75
|
-
const operationRegistry = createOperationRegistry();
|
|
76
|
-
const allExtensions = [
|
|
77
|
-
{
|
|
78
|
-
codecs: () => adapter.profile.codecs()
|
|
79
|
-
},
|
|
80
|
-
...extensions ?? []
|
|
81
|
-
];
|
|
82
|
-
for (const extension of allExtensions) {
|
|
83
|
-
const extensionCodecs = extension.codecs?.();
|
|
84
|
-
if (extensionCodecs) {
|
|
85
|
-
for (const codec of extensionCodecs.values()) {
|
|
86
|
-
codecRegistry.register(codec);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const extensionOperations = extension.operations?.();
|
|
90
|
-
if (extensionOperations) {
|
|
91
|
-
for (const operation of extensionOperations) {
|
|
92
|
-
operationRegistry.register(operation);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
contract,
|
|
98
|
-
adapter,
|
|
99
|
-
operations: operationRegistry,
|
|
100
|
-
codecs: codecRegistry
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// src/sql-marker.ts
|
|
105
|
-
var ensureSchemaStatement = {
|
|
106
|
-
sql: "create schema if not exists prisma_contract",
|
|
107
|
-
params: []
|
|
108
|
-
};
|
|
109
|
-
var ensureTableStatement = {
|
|
110
|
-
sql: `create table if not exists prisma_contract.marker (
|
|
111
|
-
id smallint primary key default 1,
|
|
112
|
-
core_hash text not null,
|
|
113
|
-
profile_hash text not null,
|
|
114
|
-
contract_json jsonb,
|
|
115
|
-
canonical_version int,
|
|
116
|
-
updated_at timestamptz not null default now(),
|
|
117
|
-
app_tag text,
|
|
118
|
-
meta jsonb not null default '{}'
|
|
119
|
-
)`,
|
|
120
|
-
params: []
|
|
121
|
-
};
|
|
122
|
-
function readContractMarker() {
|
|
123
|
-
return {
|
|
124
|
-
sql: `select
|
|
125
|
-
core_hash,
|
|
126
|
-
profile_hash,
|
|
127
|
-
contract_json,
|
|
128
|
-
canonical_version,
|
|
129
|
-
updated_at,
|
|
130
|
-
app_tag,
|
|
131
|
-
meta
|
|
132
|
-
from prisma_contract.marker
|
|
133
|
-
where id = $1`,
|
|
134
|
-
params: [1]
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function writeContractMarker(input) {
|
|
138
|
-
const baseParams = [
|
|
139
|
-
1,
|
|
140
|
-
input.coreHash,
|
|
141
|
-
input.profileHash,
|
|
142
|
-
input.contractJson ?? null,
|
|
143
|
-
input.canonicalVersion ?? null,
|
|
144
|
-
input.appTag ?? null,
|
|
145
|
-
JSON.stringify(input.meta ?? {})
|
|
146
|
-
];
|
|
147
|
-
const insert = {
|
|
148
|
-
sql: `insert into prisma_contract.marker (
|
|
149
|
-
id,
|
|
150
|
-
core_hash,
|
|
151
|
-
profile_hash,
|
|
152
|
-
contract_json,
|
|
153
|
-
canonical_version,
|
|
154
|
-
updated_at,
|
|
155
|
-
app_tag,
|
|
156
|
-
meta
|
|
157
|
-
) values (
|
|
158
|
-
$1,
|
|
159
|
-
$2,
|
|
160
|
-
$3,
|
|
161
|
-
$4::jsonb,
|
|
162
|
-
$5,
|
|
163
|
-
now(),
|
|
164
|
-
$6,
|
|
165
|
-
$7::jsonb
|
|
166
|
-
)`,
|
|
167
|
-
params: baseParams
|
|
168
|
-
};
|
|
169
|
-
const update = {
|
|
170
|
-
sql: `update prisma_contract.marker set
|
|
171
|
-
core_hash = $2,
|
|
172
|
-
profile_hash = $3,
|
|
173
|
-
contract_json = $4::jsonb,
|
|
174
|
-
canonical_version = $5,
|
|
175
|
-
updated_at = now(),
|
|
176
|
-
app_tag = $6,
|
|
177
|
-
meta = $7::jsonb
|
|
178
|
-
where id = $1`,
|
|
179
|
-
params: baseParams
|
|
180
|
-
};
|
|
181
|
-
return { insert, update };
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// src/sql-runtime.ts
|
|
185
|
-
import { AsyncIterableResult, createRuntimeCore } from "@prisma-next/runtime-executor";
|
|
186
|
-
|
|
187
|
-
// src/codecs/decoding.ts
|
|
188
|
-
function resolveRowCodec(alias, plan, registry) {
|
|
189
|
-
const planCodecId = plan.meta.annotations?.codecs?.[alias];
|
|
190
|
-
if (planCodecId) {
|
|
191
|
-
const codec = registry.get(planCodecId);
|
|
192
|
-
if (codec) {
|
|
193
|
-
return codec;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (plan.meta.projectionTypes) {
|
|
197
|
-
const typeId = plan.meta.projectionTypes[alias];
|
|
198
|
-
if (typeId) {
|
|
199
|
-
const codec = registry.get(typeId);
|
|
200
|
-
if (codec) {
|
|
201
|
-
return codec;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
function decodeRow(row, plan, registry) {
|
|
208
|
-
const decoded = {};
|
|
209
|
-
let aliases;
|
|
210
|
-
const projection = plan.meta.projection;
|
|
211
|
-
if (projection && !Array.isArray(projection)) {
|
|
212
|
-
aliases = Object.keys(projection);
|
|
213
|
-
} else if (projection && Array.isArray(projection)) {
|
|
214
|
-
aliases = projection;
|
|
215
|
-
} else {
|
|
216
|
-
aliases = Object.keys(row);
|
|
217
|
-
}
|
|
218
|
-
for (const alias of aliases) {
|
|
219
|
-
const wireValue = row[alias];
|
|
220
|
-
const projection2 = plan.meta.projection;
|
|
221
|
-
const projectionValue = projection2 && typeof projection2 === "object" && !Array.isArray(projection2) ? projection2[alias] : void 0;
|
|
222
|
-
if (typeof projectionValue === "string" && projectionValue.startsWith("include:")) {
|
|
223
|
-
if (wireValue === null || wireValue === void 0) {
|
|
224
|
-
decoded[alias] = [];
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
try {
|
|
228
|
-
let parsed;
|
|
229
|
-
if (typeof wireValue === "string") {
|
|
230
|
-
parsed = JSON.parse(wireValue);
|
|
231
|
-
} else if (Array.isArray(wireValue)) {
|
|
232
|
-
parsed = wireValue;
|
|
233
|
-
} else {
|
|
234
|
-
parsed = JSON.parse(String(wireValue));
|
|
235
|
-
}
|
|
236
|
-
if (!Array.isArray(parsed)) {
|
|
237
|
-
throw new Error(`Expected array for include alias '${alias}', got ${typeof parsed}`);
|
|
238
|
-
}
|
|
239
|
-
decoded[alias] = parsed;
|
|
240
|
-
} catch (error) {
|
|
241
|
-
const decodeError = new Error(
|
|
242
|
-
`Failed to parse JSON array for include alias '${alias}': ${error instanceof Error ? error.message : String(error)}`
|
|
243
|
-
);
|
|
244
|
-
decodeError.code = "RUNTIME.DECODE_FAILED";
|
|
245
|
-
decodeError.category = "RUNTIME";
|
|
246
|
-
decodeError.severity = "error";
|
|
247
|
-
decodeError.details = {
|
|
248
|
-
alias,
|
|
249
|
-
wirePreview: typeof wireValue === "string" && wireValue.length > 100 ? `${wireValue.substring(0, 100)}...` : String(wireValue).substring(0, 100)
|
|
250
|
-
};
|
|
251
|
-
throw decodeError;
|
|
252
|
-
}
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
if (wireValue === null || wireValue === void 0) {
|
|
256
|
-
decoded[alias] = wireValue;
|
|
257
|
-
continue;
|
|
258
|
-
}
|
|
259
|
-
const codec = resolveRowCodec(alias, plan, registry);
|
|
260
|
-
if (!codec) {
|
|
261
|
-
decoded[alias] = wireValue;
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
try {
|
|
265
|
-
decoded[alias] = codec.decode(wireValue);
|
|
266
|
-
} catch (error) {
|
|
267
|
-
const decodeError = new Error(
|
|
268
|
-
`Failed to decode row alias '${alias}' with codec '${codec.id}': ${error instanceof Error ? error.message : String(error)}`
|
|
269
|
-
);
|
|
270
|
-
decodeError.code = "RUNTIME.DECODE_FAILED";
|
|
271
|
-
decodeError.category = "RUNTIME";
|
|
272
|
-
decodeError.severity = "error";
|
|
273
|
-
decodeError.details = {
|
|
274
|
-
alias,
|
|
275
|
-
codec: codec.id,
|
|
276
|
-
wirePreview: typeof wireValue === "string" && wireValue.length > 100 ? `${wireValue.substring(0, 100)}...` : String(wireValue).substring(0, 100)
|
|
277
|
-
};
|
|
278
|
-
throw decodeError;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return decoded;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// src/codecs/encoding.ts
|
|
285
|
-
function resolveParamCodec(paramDescriptor, plan, registry) {
|
|
286
|
-
const paramName = paramDescriptor.name ?? `param_${paramDescriptor.index ?? 0}`;
|
|
287
|
-
const planCodecId = plan.meta.annotations?.codecs?.[paramName];
|
|
288
|
-
if (planCodecId) {
|
|
289
|
-
const codec = registry.get(planCodecId);
|
|
290
|
-
if (codec) {
|
|
291
|
-
return codec;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
if (paramDescriptor.codecId) {
|
|
295
|
-
const codec = registry.get(paramDescriptor.codecId);
|
|
296
|
-
if (codec) {
|
|
297
|
-
return codec;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
function encodeParam(value, paramDescriptor, plan, registry) {
|
|
303
|
-
if (value === null || value === void 0) {
|
|
304
|
-
return null;
|
|
305
|
-
}
|
|
306
|
-
const codec = resolveParamCodec(paramDescriptor, plan, registry);
|
|
307
|
-
if (!codec) {
|
|
308
|
-
return value;
|
|
309
|
-
}
|
|
310
|
-
if (codec.encode) {
|
|
311
|
-
try {
|
|
312
|
-
return codec.encode(value);
|
|
313
|
-
} catch (error) {
|
|
314
|
-
throw new Error(
|
|
315
|
-
`Failed to encode parameter ${paramDescriptor.name ?? paramDescriptor.index}: ${error instanceof Error ? error.message : String(error)}`
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return value;
|
|
320
|
-
}
|
|
321
|
-
function encodeParams(plan, registry) {
|
|
322
|
-
if (plan.params.length === 0) {
|
|
323
|
-
return plan.params;
|
|
324
|
-
}
|
|
325
|
-
const encoded = [];
|
|
326
|
-
for (let i = 0; i < plan.params.length; i++) {
|
|
327
|
-
const paramValue = plan.params[i];
|
|
328
|
-
const paramDescriptor = plan.meta.paramDescriptors[i];
|
|
329
|
-
if (paramDescriptor) {
|
|
330
|
-
encoded.push(encodeParam(paramValue, paramDescriptor, plan, registry));
|
|
331
|
-
} else {
|
|
332
|
-
encoded.push(paramValue);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return Object.freeze(encoded);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// src/sql-family-adapter.ts
|
|
339
|
-
import { runtimeError as runtimeError2 } from "@prisma-next/runtime-executor";
|
|
340
|
-
var SqlMarkerReader = class {
|
|
341
|
-
readMarkerStatement() {
|
|
342
|
-
return readContractMarker();
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
var SqlFamilyAdapter = class {
|
|
346
|
-
contract;
|
|
347
|
-
markerReader;
|
|
348
|
-
constructor(contract) {
|
|
349
|
-
this.contract = contract;
|
|
350
|
-
this.markerReader = new SqlMarkerReader();
|
|
351
|
-
}
|
|
352
|
-
validatePlan(plan, contract) {
|
|
353
|
-
if (plan.meta.target !== contract.target) {
|
|
354
|
-
throw runtimeError2("PLAN.TARGET_MISMATCH", "Plan target does not match runtime target", {
|
|
355
|
-
planTarget: plan.meta.target,
|
|
356
|
-
runtimeTarget: contract.target
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
if (plan.meta.coreHash !== contract.coreHash) {
|
|
360
|
-
throw runtimeError2("PLAN.HASH_MISMATCH", "Plan core hash does not match runtime contract", {
|
|
361
|
-
planCoreHash: plan.meta.coreHash,
|
|
362
|
-
runtimeCoreHash: contract.coreHash
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
// src/sql-runtime.ts
|
|
369
|
-
var SqlRuntimeImpl = class {
|
|
370
|
-
core;
|
|
371
|
-
contract;
|
|
372
|
-
context;
|
|
373
|
-
codecRegistry;
|
|
374
|
-
codecRegistryValidated;
|
|
375
|
-
constructor(options) {
|
|
376
|
-
const { context, driver, verify, plugins, mode, log } = options;
|
|
377
|
-
this.contract = context.contract;
|
|
378
|
-
this.context = context;
|
|
379
|
-
this.codecRegistry = context.codecs;
|
|
380
|
-
this.codecRegistryValidated = false;
|
|
381
|
-
const familyAdapter = new SqlFamilyAdapter(context.contract);
|
|
382
|
-
const coreOptions = {
|
|
383
|
-
familyAdapter,
|
|
384
|
-
driver,
|
|
385
|
-
verify,
|
|
386
|
-
plugins,
|
|
387
|
-
...mode !== void 0 ? { mode } : {},
|
|
388
|
-
...log !== void 0 ? { log } : {},
|
|
389
|
-
operationRegistry: context.operations
|
|
390
|
-
};
|
|
391
|
-
this.core = createRuntimeCore(coreOptions);
|
|
392
|
-
if (verify.mode === "startup") {
|
|
393
|
-
validateCodecRegistryCompleteness(this.codecRegistry, context.contract);
|
|
394
|
-
this.codecRegistryValidated = true;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
ensureCodecRegistryValidated(contract) {
|
|
398
|
-
if (!this.codecRegistryValidated) {
|
|
399
|
-
validateCodecRegistryCompleteness(this.codecRegistry, contract);
|
|
400
|
-
this.codecRegistryValidated = true;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
execute(plan) {
|
|
404
|
-
this.ensureCodecRegistryValidated(this.contract);
|
|
405
|
-
const isSqlQueryPlan = (p) => {
|
|
406
|
-
return "ast" in p && !("sql" in p);
|
|
407
|
-
};
|
|
408
|
-
const executablePlan = isSqlQueryPlan(plan) ? lowerSqlPlan(this.context, plan) : plan;
|
|
409
|
-
const iterator = async function* (self) {
|
|
410
|
-
const encodedParams = encodeParams(executablePlan, self.codecRegistry);
|
|
411
|
-
const planWithEncodedParams = {
|
|
412
|
-
...executablePlan,
|
|
413
|
-
params: encodedParams
|
|
414
|
-
};
|
|
415
|
-
const coreIterator = self.core.execute(planWithEncodedParams);
|
|
416
|
-
for await (const rawRow of coreIterator) {
|
|
417
|
-
const decodedRow = decodeRow(
|
|
418
|
-
rawRow,
|
|
419
|
-
executablePlan,
|
|
420
|
-
self.codecRegistry
|
|
421
|
-
);
|
|
422
|
-
yield decodedRow;
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
return new AsyncIterableResult(iterator(this));
|
|
426
|
-
}
|
|
427
|
-
telemetry() {
|
|
428
|
-
return this.core.telemetry();
|
|
429
|
-
}
|
|
430
|
-
operations() {
|
|
431
|
-
return this.core.operations();
|
|
432
|
-
}
|
|
433
|
-
close() {
|
|
434
|
-
return this.core.close();
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
function createRuntime(options) {
|
|
438
|
-
return new SqlRuntimeImpl(options);
|
|
439
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
budgets,
|
|
3
|
+
createRuntime,
|
|
4
|
+
createRuntimeContext,
|
|
5
|
+
ensureSchemaStatement,
|
|
6
|
+
ensureTableStatement,
|
|
7
|
+
extractCodecIds,
|
|
8
|
+
lints,
|
|
9
|
+
lowerSqlPlan,
|
|
10
|
+
readContractMarker,
|
|
11
|
+
validateCodecRegistryCompleteness,
|
|
12
|
+
validateContractCodecMappings,
|
|
13
|
+
writeContractMarker
|
|
14
|
+
} from "./chunk-7UNP42HJ.js";
|
|
15
|
+
import "./chunk-7D4SUZUM.js";
|
|
440
16
|
export {
|
|
441
17
|
budgets,
|
|
442
18
|
createRuntime,
|