@nicia-ai/typegraph 0.38.0 → 0.40.0
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/backend/drizzle/indexes.cjs +8 -10
- package/dist/backend/drizzle/indexes.d.cts +2 -2
- package/dist/backend/drizzle/indexes.d.ts +2 -2
- package/dist/backend/drizzle/indexes.js +4 -6
- package/dist/backend/index.cjs +60 -39
- package/dist/backend/index.d.cts +60 -1
- package/dist/backend/index.d.ts +60 -1
- package/dist/backend/index.js +12 -3
- package/dist/backend/postgres/index.cjs +25 -27
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +12 -14
- package/dist/backend/postgres/pglite-store.cjs +26 -27
- package/dist/backend/postgres/pglite-store.cjs.map +1 -1
- package/dist/backend/postgres/pglite-store.d.cts +6 -5
- package/dist/backend/postgres/pglite-store.d.ts +6 -5
- package/dist/backend/postgres/pglite-store.js +22 -23
- package/dist/backend/postgres/pglite-store.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +14 -16
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +13 -15
- package/dist/backend/sqlite/index.cjs +26 -28
- package/dist/backend/sqlite/index.d.cts +6 -6
- package/dist/backend/sqlite/index.d.ts +6 -6
- package/dist/backend/sqlite/index.js +10 -12
- package/dist/backend/sqlite/libsql.cjs +16 -18
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +15 -17
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local-store.cjs +27 -28
- package/dist/backend/sqlite/local-store.cjs.map +1 -1
- package/dist/backend/sqlite/local-store.d.cts +6 -5
- package/dist/backend/sqlite/local-store.d.ts +6 -5
- package/dist/backend/sqlite/local-store.js +23 -24
- package/dist/backend/sqlite/local-store.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +15 -17
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +13 -15
- package/dist/{chunk-U4JDJKPD.js → chunk-2I3DNNBU.js} +4 -4
- package/dist/{chunk-U4JDJKPD.js.map → chunk-2I3DNNBU.js.map} +1 -1
- package/dist/{chunk-NPWACFQJ.cjs → chunk-2J5NMMVR.cjs} +43 -43
- package/dist/{chunk-NPWACFQJ.cjs.map → chunk-2J5NMMVR.cjs.map} +1 -1
- package/dist/{chunk-NU23DUSJ.cjs → chunk-2X73QTIC.cjs} +12 -13
- package/dist/chunk-2X73QTIC.cjs.map +1 -0
- package/dist/{chunk-A2FGSWMQ.js → chunk-3BL3JFHL.js} +202 -52
- package/dist/chunk-3BL3JFHL.js.map +1 -0
- package/dist/chunk-3SHAUJRB.js +79 -0
- package/dist/chunk-3SHAUJRB.js.map +1 -0
- package/dist/{chunk-UPXDVI3T.js → chunk-53BSOG3O.js} +8 -7
- package/dist/chunk-53BSOG3O.js.map +1 -0
- package/dist/chunk-5J4VNCUD.js +856 -0
- package/dist/chunk-5J4VNCUD.js.map +1 -0
- package/dist/chunk-5YBDB7UG.cjs +12 -0
- package/dist/{chunk-FMNUSGZ4.cjs.map → chunk-5YBDB7UG.cjs.map} +1 -1
- package/dist/{chunk-6XDBRDZE.js → chunk-6N7QBIWN.js} +7 -3
- package/dist/chunk-6N7QBIWN.js.map +1 -0
- package/dist/{chunk-EZH7FNUS.js → chunk-6QP4QXBR.js} +3 -3
- package/dist/{chunk-EZH7FNUS.js.map → chunk-6QP4QXBR.js.map} +1 -1
- package/dist/{chunk-E6TXEISH.cjs → chunk-7UTUKH4E.cjs} +4 -4
- package/dist/{chunk-E6TXEISH.cjs.map → chunk-7UTUKH4E.cjs.map} +1 -1
- package/dist/chunk-7WLEQIHA.cjs +605 -0
- package/dist/chunk-7WLEQIHA.cjs.map +1 -0
- package/dist/{chunk-BQITNFQJ.js → chunk-AQVDAKXH.js} +3 -3
- package/dist/{chunk-BQITNFQJ.js.map → chunk-AQVDAKXH.js.map} +1 -1
- package/dist/{chunk-X6CNEA32.js → chunk-BUZWMDNL.js} +5 -5
- package/dist/{chunk-X6CNEA32.js.map → chunk-BUZWMDNL.js.map} +1 -1
- package/dist/{chunk-7M3NACL3.cjs → chunk-CKFBZ4LV.cjs} +4 -4
- package/dist/{chunk-7M3NACL3.cjs.map → chunk-CKFBZ4LV.cjs.map} +1 -1
- package/dist/{chunk-VBH7ZXSZ.js → chunk-CU3LPYNB.js} +5 -5
- package/dist/{chunk-VBH7ZXSZ.js.map → chunk-CU3LPYNB.js.map} +1 -1
- package/dist/{chunk-YJDSPA5E.js → chunk-EFZ4S22A.js} +11 -10
- package/dist/chunk-EFZ4S22A.js.map +1 -0
- package/dist/chunk-ELA3V6UN.js +601 -0
- package/dist/chunk-ELA3V6UN.js.map +1 -0
- package/dist/{chunk-2SL7OGPR.cjs → chunk-H6I36MGT.cjs} +1037 -887
- package/dist/chunk-H6I36MGT.cjs.map +1 -0
- package/dist/chunk-HAQVISUF.cjs +1098 -0
- package/dist/chunk-HAQVISUF.cjs.map +1 -0
- package/dist/{chunk-O5H62ZWJ.cjs → chunk-HP6LWBLB.cjs} +14 -2
- package/dist/chunk-HP6LWBLB.cjs.map +1 -0
- package/dist/{chunk-BKAKAVRW.cjs → chunk-HQRZEYYB.cjs} +44 -44
- package/dist/{chunk-BKAKAVRW.cjs.map → chunk-HQRZEYYB.cjs.map} +1 -1
- package/dist/{chunk-XD6X7O5R.js → chunk-I5CRUPKO.js} +9 -10
- package/dist/{chunk-XD6X7O5R.js.map → chunk-I5CRUPKO.js.map} +1 -1
- package/dist/{chunk-RQPRCEIO.js → chunk-JHK6NPFV.js} +218 -306
- package/dist/chunk-JHK6NPFV.js.map +1 -0
- package/dist/chunk-JZYMOHHM.cjs +226 -0
- package/dist/chunk-JZYMOHHM.cjs.map +1 -0
- package/dist/{chunk-CQC6VBAF.cjs → chunk-K4FB2RMO.cjs} +10 -10
- package/dist/{chunk-CQC6VBAF.cjs.map → chunk-K4FB2RMO.cjs.map} +1 -1
- package/dist/{chunk-ERZ4QPQX.js → chunk-K6CD6W5J.js} +5 -5
- package/dist/{chunk-ERZ4QPQX.js.map → chunk-K6CD6W5J.js.map} +1 -1
- package/dist/{chunk-LZ3TVJY4.cjs → chunk-KHNKYSGP.cjs} +34 -34
- package/dist/{chunk-LZ3TVJY4.cjs.map → chunk-KHNKYSGP.cjs.map} +1 -1
- package/dist/{chunk-CWX77JB4.cjs → chunk-KLR77R5A.cjs} +13 -13
- package/dist/{chunk-CWX77JB4.cjs.map → chunk-KLR77R5A.cjs.map} +1 -1
- package/dist/{chunk-AOL64O4Z.js → chunk-L3DDZUZP.js} +3 -3
- package/dist/{chunk-AOL64O4Z.js.map → chunk-L3DDZUZP.js.map} +1 -1
- package/dist/{chunk-PZHC5GCD.js → chunk-L5ET7FYQ.js} +3 -3
- package/dist/{chunk-PZHC5GCD.js.map → chunk-L5ET7FYQ.js.map} +1 -1
- package/dist/{chunk-B63IFHXR.cjs → chunk-LFFVD5ZR.cjs} +41 -41
- package/dist/{chunk-B63IFHXR.cjs.map → chunk-LFFVD5ZR.cjs.map} +1 -1
- package/dist/chunk-LL5D5T5W.cjs +157 -0
- package/dist/chunk-LL5D5T5W.cjs.map +1 -0
- package/dist/{chunk-GUUWKPTK.cjs → chunk-LLE25NRD.cjs} +7 -7
- package/dist/{chunk-GUUWKPTK.cjs.map → chunk-LLE25NRD.cjs.map} +1 -1
- package/dist/chunk-LLHMAHG4.cjs +886 -0
- package/dist/chunk-LLHMAHG4.cjs.map +1 -0
- package/dist/{chunk-ZHX4KEM7.cjs → chunk-M2RPZS7J.cjs} +10 -10
- package/dist/{chunk-ZHX4KEM7.cjs.map → chunk-M2RPZS7J.cjs.map} +1 -1
- package/dist/chunk-MNURF4RF.cjs +85 -0
- package/dist/chunk-MNURF4RF.cjs.map +1 -0
- package/dist/chunk-QOHTVDHU.js +144 -0
- package/dist/chunk-QOHTVDHU.js.map +1 -0
- package/dist/{chunk-7VLCN3JB.cjs → chunk-QXKVUJLI.cjs} +113 -112
- package/dist/chunk-QXKVUJLI.cjs.map +1 -0
- package/dist/{chunk-GNPGGLAE.cjs → chunk-QYDUCWD2.cjs} +4 -4
- package/dist/{chunk-GNPGGLAE.cjs.map → chunk-QYDUCWD2.cjs.map} +1 -1
- package/dist/{chunk-TE5ZA4VX.js → chunk-QZYGZVUI.js} +45 -41
- package/dist/chunk-QZYGZVUI.js.map +1 -0
- package/dist/{chunk-YLINFV7Z.cjs → chunk-SAMJLDGG.cjs} +114 -110
- package/dist/chunk-SAMJLDGG.cjs.map +1 -0
- package/dist/{chunk-DOVMTPKE.cjs → chunk-SE422RES.cjs} +27 -27
- package/dist/{chunk-DOVMTPKE.cjs.map → chunk-SE422RES.cjs.map} +1 -1
- package/dist/{chunk-NWYCOFEZ.cjs → chunk-UCHW2MGP.cjs} +332 -433
- package/dist/chunk-UCHW2MGP.cjs.map +1 -0
- package/dist/{chunk-XFY73JWD.cjs → chunk-UDS5DZNY.cjs} +498 -1098
- package/dist/chunk-UDS5DZNY.cjs.map +1 -0
- package/dist/{chunk-KFLXWVUJ.js → chunk-UUIBACKJ.js} +14 -3
- package/dist/chunk-UUIBACKJ.js.map +1 -0
- package/dist/{chunk-VDYA2HMS.js → chunk-VWEFXG73.js} +3 -3
- package/dist/{chunk-VDYA2HMS.js.map → chunk-VWEFXG73.js.map} +1 -1
- package/dist/{chunk-G32AO634.js → chunk-W66YCXWT.js} +464 -1048
- package/dist/chunk-W66YCXWT.js.map +1 -0
- package/dist/{chunk-E6YZRKMM.js → chunk-XMEYZYGE.js} +6 -6
- package/dist/{chunk-E6YZRKMM.js.map → chunk-XMEYZYGE.js.map} +1 -1
- package/dist/{chunk-G3CSQLLT.js → chunk-Y5UC3IXF.js} +461 -6
- package/dist/chunk-Y5UC3IXF.js.map +1 -0
- package/dist/{chunk-SDHV2MWU.js → chunk-YGX4PMG6.js} +5 -5
- package/dist/{chunk-SDHV2MWU.js.map → chunk-YGX4PMG6.js.map} +1 -1
- package/dist/{chunk-KCLZHYPU.cjs → chunk-YIX3BEBR.cjs} +86 -85
- package/dist/chunk-YIX3BEBR.cjs.map +1 -0
- package/dist/{chunk-X6RDQ5NB.cjs → chunk-YX3H63VV.cjs} +8 -2
- package/dist/chunk-YX3H63VV.cjs.map +1 -0
- package/dist/chunk-YYLMXERH.js +211 -0
- package/dist/chunk-YYLMXERH.js.map +1 -0
- package/dist/{chunk-6G5CQ6JX.js → chunk-ZE7E46IZ.js} +5 -5
- package/dist/{chunk-6G5CQ6JX.js.map → chunk-ZE7E46IZ.js.map} +1 -1
- package/dist/{chunk-Z2PPIVOO.js → chunk-ZVME6OSV.js} +5 -5
- package/dist/{chunk-Z2PPIVOO.js.map → chunk-ZVME6OSV.js.map} +1 -1
- package/dist/core/index.cjs +15 -3
- package/dist/core/index.d.cts +4 -3
- package/dist/core/index.d.ts +4 -3
- package/dist/core/index.js +2 -2
- package/dist/{ddl-Dx3Z0_WC.d.ts → ddl-BLEzHw6j.d.ts} +3 -3
- package/dist/{ddl-J6sDyABg.d.cts → ddl-KnCdF_le.d.cts} +3 -3
- package/dist/{define-graph-CzEvA_8F.d.cts → define-graph-Cv3CFwKm.d.cts} +1 -1
- package/dist/{define-graph-DRo9xpYN.d.ts → define-graph-DQnj3fNH.d.ts} +1 -1
- package/dist/graph-merge/index.cjs +40 -43
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +15 -9
- package/dist/graph-merge/index.d.ts +15 -9
- package/dist/graph-merge/index.js +19 -22
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/index.cjs +143 -119
- package/dist/index.d.cts +12 -10
- package/dist/index.d.ts +12 -10
- package/dist/index.js +23 -23
- package/dist/indexes/index.cjs +12 -14
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +5 -7
- package/dist/interchange/index.cjs +29 -30
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +6 -5
- package/dist/interchange/index.d.ts +6 -5
- package/dist/interchange/index.js +10 -11
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-CASfhmzV.d.ts → manager-DjE6Mhag.d.ts} +2 -2
- package/dist/{manager-nCEJiYBb.d.cts → manager-mqee5MVB.d.cts} +2 -2
- package/dist/{postgres-DMgIKQU-.d.cts → postgres-Bm4DyFQU.d.cts} +100 -49
- package/dist/{postgres-Cl1ZAN1G.d.ts → postgres-DtaVALOZ.d.ts} +100 -49
- package/dist/profiler/index.d.cts +8 -7
- package/dist/profiler/index.d.ts +8 -7
- package/dist/provenance/index.cjs +20 -20
- package/dist/provenance/index.d.cts +6 -5
- package/dist/provenance/index.d.ts +6 -5
- package/dist/provenance/index.js +7 -7
- package/dist/schema/index.cjs +26 -28
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +5 -5
- package/dist/schema/index.d.ts +5 -5
- package/dist/schema/index.js +7 -9
- package/dist/schema/index.js.map +1 -1
- package/dist/{temporal-DqtOEo_B.d.ts → searchable-BxlJQVFw.d.cts} +3 -58
- package/dist/{temporal-BC_NQV5Y.d.cts → searchable-ChJ29MCd.d.ts} +3 -58
- package/dist/{sqlite-BDkW39aa.d.cts → sqlite-DT6tTHOG.d.cts} +124 -97
- package/dist/{sqlite-CYfhvESj.d.ts → sqlite-m9Izphk_.d.ts} +124 -97
- package/dist/{store-view-BoHqdHjB.d.cts → store-view-C-buB8Q8.d.cts} +46 -31
- package/dist/{store-view-Ctq-3OHy.d.ts → store-view-CagdeyNn.d.ts} +46 -31
- package/dist/temporal-CyFsSPe8.d.ts +73 -0
- package/dist/temporal-Dn_JADWY.d.cts +73 -0
- package/dist/{types-CUevi_D1.d.ts → types-CYdXzZef.d.ts} +1 -1
- package/dist/{types-COq3-vMC.d.cts → types-CqSfMRW3.d.cts} +1 -1
- package/dist/{where-C92TXCzT.d.cts → where-C3-HRgUq.d.cts} +1 -1
- package/dist/{where-BdE_cYtx.d.ts → where-sQL4u5h-.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-2SL7OGPR.cjs.map +0 -1
- package/dist/chunk-6XDBRDZE.js.map +0 -1
- package/dist/chunk-7VLCN3JB.cjs.map +0 -1
- package/dist/chunk-A2FGSWMQ.js.map +0 -1
- package/dist/chunk-DDCIXXOO.js +0 -9
- package/dist/chunk-DDCIXXOO.js.map +0 -1
- package/dist/chunk-DDCYVIVV.cjs +0 -44
- package/dist/chunk-DDCYVIVV.cjs.map +0 -1
- package/dist/chunk-EOJFGECD.cjs +0 -284
- package/dist/chunk-EOJFGECD.cjs.map +0 -1
- package/dist/chunk-FMNUSGZ4.cjs +0 -12
- package/dist/chunk-G32AO634.js.map +0 -1
- package/dist/chunk-G3CSQLLT.js.map +0 -1
- package/dist/chunk-I6FX7AAG.js +0 -39
- package/dist/chunk-I6FX7AAG.js.map +0 -1
- package/dist/chunk-J6IJARLG.js +0 -94
- package/dist/chunk-J6IJARLG.js.map +0 -1
- package/dist/chunk-KCLZHYPU.cjs.map +0 -1
- package/dist/chunk-KFLXWVUJ.js.map +0 -1
- package/dist/chunk-MTNEGGM2.js +0 -273
- package/dist/chunk-MTNEGGM2.js.map +0 -1
- package/dist/chunk-NU23DUSJ.cjs.map +0 -1
- package/dist/chunk-NWYCOFEZ.cjs.map +0 -1
- package/dist/chunk-O5H62ZWJ.cjs.map +0 -1
- package/dist/chunk-RQPRCEIO.js.map +0 -1
- package/dist/chunk-SVUKGWSN.cjs +0 -102
- package/dist/chunk-SVUKGWSN.cjs.map +0 -1
- package/dist/chunk-TE5ZA4VX.js.map +0 -1
- package/dist/chunk-UH2USOMG.cjs +0 -627
- package/dist/chunk-UH2USOMG.cjs.map +0 -1
- package/dist/chunk-UPXDVI3T.js.map +0 -1
- package/dist/chunk-X6RDQ5NB.cjs.map +0 -1
- package/dist/chunk-XFY73JWD.cjs.map +0 -1
- package/dist/chunk-Y7M44XEK.js +0 -462
- package/dist/chunk-Y7M44XEK.js.map +0 -1
- package/dist/chunk-YJDSPA5E.js.map +0 -1
- package/dist/chunk-YLINFV7Z.cjs.map +0 -1
- package/dist/chunk-Z5QHVL5U.cjs +0 -12
- package/dist/chunk-Z5QHVL5U.cjs.map +0 -1
- package/dist/chunk-ZKZAIX42.cjs +0 -479
- package/dist/chunk-ZKZAIX42.cjs.map +0 -1
- package/dist/{index-CrFL_ENI.d.cts → types-C5pZeKTl.d.cts} +1 -1
- package/dist/{index-Bq7vSPHy.d.ts → types-D8szWDUo.d.ts} +1 -1
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
import { buildPostgresSystemIndexBuilders, buildPostgresNodeIndexBuilders, buildPostgresEdgeIndexBuilders, buildSqliteSystemIndexBuilders, buildSqliteNodeIndexBuilders, buildSqliteEdgeIndexBuilders } from './chunk-ZVME6OSV.js';
|
|
2
|
+
import { assertNoSystemIndexNameCollision } from './chunk-AQVDAKXH.js';
|
|
3
|
+
import { tsvectorStrategy, fts5Strategy, BASE_CONTRIBUTION_OWNER } from './chunk-Y5UC3IXF.js';
|
|
4
|
+
import { sql, is } from 'drizzle-orm';
|
|
5
|
+
import { customType, pgTable, timestamp, integer, jsonb, text, primaryKey, bigint, index, boolean, uniqueIndex, getTableConfig as getTableConfig$1, PgTable } from 'drizzle-orm/pg-core';
|
|
6
|
+
import { sqliteTable, text as text$1, integer as integer$1, primaryKey as primaryKey$1, index as index$1, uniqueIndex as uniqueIndex$1, getTableConfig, SQLiteTable } from 'drizzle-orm/sqlite-core';
|
|
7
|
+
|
|
8
|
+
var regconfig = customType({
|
|
9
|
+
dataType: () => "regconfig"
|
|
10
|
+
});
|
|
11
|
+
var tsvector = customType({
|
|
12
|
+
dataType: () => "tsvector"
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// src/backend/drizzle/schema/postgres.ts
|
|
16
|
+
var DEFAULT_TABLE_NAMES = {
|
|
17
|
+
nodes: "typegraph_nodes",
|
|
18
|
+
edges: "typegraph_edges",
|
|
19
|
+
recordedNodes: "typegraph_recorded_nodes",
|
|
20
|
+
recordedEdges: "typegraph_recorded_edges",
|
|
21
|
+
recordedClock: "typegraph_recorded_clock",
|
|
22
|
+
revisionOrigins: "typegraph_revision_origins",
|
|
23
|
+
uniques: "typegraph_node_uniques",
|
|
24
|
+
schemaVersions: "typegraph_schema_versions",
|
|
25
|
+
fulltext: "typegraph_node_fulltext",
|
|
26
|
+
indexMaterializations: "typegraph_index_materializations",
|
|
27
|
+
contributionMaterializations: "typegraph_contribution_materializations",
|
|
28
|
+
kindRemovals: "typegraph_kind_removals",
|
|
29
|
+
reconciliationMarkers: "typegraph_reconciliation_markers"
|
|
30
|
+
};
|
|
31
|
+
function createPostgresTables(names = {}, options = {}) {
|
|
32
|
+
const n = { ...DEFAULT_TABLE_NAMES, ...names };
|
|
33
|
+
const indexes = options.indexes ?? [];
|
|
34
|
+
assertNoSystemIndexNameCollision(indexes, n);
|
|
35
|
+
const nodes3 = pgTable(
|
|
36
|
+
n.nodes,
|
|
37
|
+
{
|
|
38
|
+
graphId: text("graph_id").notNull(),
|
|
39
|
+
kind: text("kind").notNull(),
|
|
40
|
+
id: text("id").notNull(),
|
|
41
|
+
props: jsonb("props").notNull(),
|
|
42
|
+
version: integer("version").notNull().default(1),
|
|
43
|
+
validFrom: timestamp("valid_from", { withTimezone: true }),
|
|
44
|
+
validTo: timestamp("valid_to", { withTimezone: true }),
|
|
45
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
46
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
47
|
+
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
48
|
+
},
|
|
49
|
+
(t) => [
|
|
50
|
+
primaryKey({ columns: [t.graphId, t.kind, t.id] }),
|
|
51
|
+
// System indexes come from SYSTEM_INDEX_DECLARATIONS (single source
|
|
52
|
+
// for both dialects + the runtime materializer).
|
|
53
|
+
...buildPostgresSystemIndexBuilders("nodes", n.nodes, t),
|
|
54
|
+
...buildPostgresNodeIndexBuilders(t, indexes)
|
|
55
|
+
]
|
|
56
|
+
);
|
|
57
|
+
const edges3 = pgTable(
|
|
58
|
+
n.edges,
|
|
59
|
+
{
|
|
60
|
+
graphId: text("graph_id").notNull(),
|
|
61
|
+
id: text("id").notNull(),
|
|
62
|
+
kind: text("kind").notNull(),
|
|
63
|
+
fromKind: text("from_kind").notNull(),
|
|
64
|
+
fromId: text("from_id").notNull(),
|
|
65
|
+
toKind: text("to_kind").notNull(),
|
|
66
|
+
toId: text("to_id").notNull(),
|
|
67
|
+
props: jsonb("props").notNull(),
|
|
68
|
+
validFrom: timestamp("valid_from", { withTimezone: true }),
|
|
69
|
+
validTo: timestamp("valid_to", { withTimezone: true }),
|
|
70
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
71
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
72
|
+
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
73
|
+
},
|
|
74
|
+
(t) => [
|
|
75
|
+
primaryKey({ columns: [t.graphId, t.id] }),
|
|
76
|
+
...buildPostgresSystemIndexBuilders("edges", n.edges, t),
|
|
77
|
+
...buildPostgresEdgeIndexBuilders(t, indexes)
|
|
78
|
+
]
|
|
79
|
+
);
|
|
80
|
+
const recordedNodes3 = pgTable(
|
|
81
|
+
n.recordedNodes,
|
|
82
|
+
{
|
|
83
|
+
historyId: text("history_id").notNull(),
|
|
84
|
+
graphId: text("graph_id").notNull(),
|
|
85
|
+
kind: text("kind").notNull(),
|
|
86
|
+
id: text("id").notNull(),
|
|
87
|
+
props: jsonb("props").notNull(),
|
|
88
|
+
version: integer("version").notNull(),
|
|
89
|
+
validFrom: timestamp("valid_from", { withTimezone: true }),
|
|
90
|
+
validTo: timestamp("valid_to", { withTimezone: true }),
|
|
91
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
92
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
93
|
+
deletedAt: timestamp("deleted_at", { withTimezone: true }),
|
|
94
|
+
recordedFrom: bigint("recorded_from", { mode: "number" }).notNull(),
|
|
95
|
+
recordedTo: bigint("recorded_to", { mode: "number" }).notNull(),
|
|
96
|
+
op: text("op").notNull(),
|
|
97
|
+
schemaVersion: integer("schema_version"),
|
|
98
|
+
txId: text("tx_id"),
|
|
99
|
+
meta: jsonb("meta")
|
|
100
|
+
},
|
|
101
|
+
(t) => [
|
|
102
|
+
primaryKey({ columns: [t.historyId] }),
|
|
103
|
+
...buildPostgresSystemIndexBuilders("recordedNodes", n.recordedNodes, t)
|
|
104
|
+
]
|
|
105
|
+
);
|
|
106
|
+
const recordedEdges3 = pgTable(
|
|
107
|
+
n.recordedEdges,
|
|
108
|
+
{
|
|
109
|
+
historyId: text("history_id").notNull(),
|
|
110
|
+
graphId: text("graph_id").notNull(),
|
|
111
|
+
id: text("id").notNull(),
|
|
112
|
+
kind: text("kind").notNull(),
|
|
113
|
+
fromKind: text("from_kind").notNull(),
|
|
114
|
+
fromId: text("from_id").notNull(),
|
|
115
|
+
toKind: text("to_kind").notNull(),
|
|
116
|
+
toId: text("to_id").notNull(),
|
|
117
|
+
props: jsonb("props").notNull(),
|
|
118
|
+
validFrom: timestamp("valid_from", { withTimezone: true }),
|
|
119
|
+
validTo: timestamp("valid_to", { withTimezone: true }),
|
|
120
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
121
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
122
|
+
deletedAt: timestamp("deleted_at", { withTimezone: true }),
|
|
123
|
+
recordedFrom: bigint("recorded_from", { mode: "number" }).notNull(),
|
|
124
|
+
recordedTo: bigint("recorded_to", { mode: "number" }).notNull(),
|
|
125
|
+
op: text("op").notNull(),
|
|
126
|
+
schemaVersion: integer("schema_version"),
|
|
127
|
+
txId: text("tx_id"),
|
|
128
|
+
meta: jsonb("meta")
|
|
129
|
+
},
|
|
130
|
+
(t) => [
|
|
131
|
+
primaryKey({ columns: [t.historyId] }),
|
|
132
|
+
...buildPostgresSystemIndexBuilders("recordedEdges", n.recordedEdges, t)
|
|
133
|
+
]
|
|
134
|
+
);
|
|
135
|
+
const recordedClock3 = pgTable(
|
|
136
|
+
n.recordedClock,
|
|
137
|
+
{
|
|
138
|
+
graphId: text("graph_id").notNull(),
|
|
139
|
+
revision: bigint("revision", { mode: "number" }).notNull(),
|
|
140
|
+
recordedAt: timestamp("recorded_at", { withTimezone: true }).notNull()
|
|
141
|
+
},
|
|
142
|
+
(t) => [primaryKey({ columns: [t.graphId] })]
|
|
143
|
+
);
|
|
144
|
+
const revisionOrigins = pgTable(
|
|
145
|
+
n.revisionOrigins,
|
|
146
|
+
{
|
|
147
|
+
graphId: text("graph_id").notNull(),
|
|
148
|
+
origin: text("origin").notNull()
|
|
149
|
+
},
|
|
150
|
+
(t) => [primaryKey({ columns: [t.graphId] })]
|
|
151
|
+
);
|
|
152
|
+
const uniques3 = pgTable(
|
|
153
|
+
n.uniques,
|
|
154
|
+
{
|
|
155
|
+
graphId: text("graph_id").notNull(),
|
|
156
|
+
nodeKind: text("node_kind").notNull(),
|
|
157
|
+
constraintName: text("constraint_name").notNull(),
|
|
158
|
+
key: text("key").notNull(),
|
|
159
|
+
nodeId: text("node_id").notNull(),
|
|
160
|
+
concreteKind: text("concrete_kind").notNull(),
|
|
161
|
+
deletedAt: timestamp("deleted_at", { withTimezone: true })
|
|
162
|
+
},
|
|
163
|
+
(t) => [
|
|
164
|
+
primaryKey({
|
|
165
|
+
columns: [t.graphId, t.nodeKind, t.constraintName, t.key]
|
|
166
|
+
}),
|
|
167
|
+
index(`${n.uniques}_node_idx`).on(t.graphId, t.concreteKind, t.nodeId)
|
|
168
|
+
]
|
|
169
|
+
);
|
|
170
|
+
const schemaVersions3 = pgTable(
|
|
171
|
+
n.schemaVersions,
|
|
172
|
+
{
|
|
173
|
+
graphId: text("graph_id").notNull(),
|
|
174
|
+
version: integer("version").notNull(),
|
|
175
|
+
schemaHash: text("schema_hash").notNull(),
|
|
176
|
+
schemaDoc: jsonb("schema_doc").notNull(),
|
|
177
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
178
|
+
isActive: boolean("is_active").notNull().default(false)
|
|
179
|
+
},
|
|
180
|
+
(t) => [
|
|
181
|
+
primaryKey({ columns: [t.graphId, t.version] }),
|
|
182
|
+
index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
|
|
183
|
+
// Partial unique index enforcing the "at most one active version
|
|
184
|
+
// per graph" invariant at the storage layer. Defense in depth
|
|
185
|
+
// against buggy backend implementations or out-of-band writes.
|
|
186
|
+
// Forces the deactivate-then-activate ordering used by
|
|
187
|
+
// `commitSchemaVersion` and `setActiveVersion`.
|
|
188
|
+
uniqueIndex(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(sql`${t.isActive} = TRUE`)
|
|
189
|
+
]
|
|
190
|
+
);
|
|
191
|
+
const indexMaterializations = pgTable(
|
|
192
|
+
n.indexMaterializations,
|
|
193
|
+
{
|
|
194
|
+
indexName: text("index_name").notNull(),
|
|
195
|
+
graphId: text("graph_id").notNull(),
|
|
196
|
+
entity: text("entity").notNull(),
|
|
197
|
+
kind: text("kind").notNull(),
|
|
198
|
+
signature: text("signature").notNull(),
|
|
199
|
+
schemaVersion: integer("schema_version").notNull(),
|
|
200
|
+
materializedAt: timestamp("materialized_at", { withTimezone: true }),
|
|
201
|
+
lastAttemptedAt: timestamp("last_attempted_at", {
|
|
202
|
+
withTimezone: true
|
|
203
|
+
}).notNull(),
|
|
204
|
+
lastError: text("last_error"),
|
|
205
|
+
// Cross-caller build claim: while `building_since` is fresh (within
|
|
206
|
+
// the lease), exactly one materializer owns this index's CREATE
|
|
207
|
+
// INDEX CONCURRENTLY. Serializes same-index CIC across processes —
|
|
208
|
+
// two concurrent expression-index CICs deadlock each other (no
|
|
209
|
+
// safe-snapshot exemption). NULL when no build is in flight.
|
|
210
|
+
buildingSince: timestamp("building_since", { withTimezone: true }),
|
|
211
|
+
claimToken: text("claim_token")
|
|
212
|
+
},
|
|
213
|
+
(t) => [primaryKey({ columns: [t.indexName] })]
|
|
214
|
+
);
|
|
215
|
+
const kindRemovals = pgTable(
|
|
216
|
+
n.kindRemovals,
|
|
217
|
+
{
|
|
218
|
+
graphId: text("graph_id").notNull(),
|
|
219
|
+
kindName: text("kind_name").notNull(),
|
|
220
|
+
entity: text("entity").notNull(),
|
|
221
|
+
schemaVersion: integer("schema_version").notNull(),
|
|
222
|
+
removedAt: timestamp("removed_at", { withTimezone: true }),
|
|
223
|
+
lastAttemptedAt: timestamp("last_attempted_at", {
|
|
224
|
+
withTimezone: true
|
|
225
|
+
}).notNull(),
|
|
226
|
+
lastError: text("last_error")
|
|
227
|
+
},
|
|
228
|
+
(t) => [
|
|
229
|
+
primaryKey({
|
|
230
|
+
columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
);
|
|
234
|
+
const reconciliationMarkers = pgTable(
|
|
235
|
+
n.reconciliationMarkers,
|
|
236
|
+
{
|
|
237
|
+
graphId: text("graph_id").notNull(),
|
|
238
|
+
reconciledToVersion: integer("reconciled_to_version").notNull()
|
|
239
|
+
},
|
|
240
|
+
(t) => [primaryKey({ columns: [t.graphId] })]
|
|
241
|
+
);
|
|
242
|
+
const contributionMaterializations = pgTable(
|
|
243
|
+
n.contributionMaterializations,
|
|
244
|
+
{
|
|
245
|
+
graphId: text("graph_id").notNull(),
|
|
246
|
+
logicalName: text("logical_name").notNull(),
|
|
247
|
+
owner: text("owner").notNull(),
|
|
248
|
+
tableName: text("table_name").notNull(),
|
|
249
|
+
signature: text("signature").notNull(),
|
|
250
|
+
materializedAt: timestamp("materialized_at", { withTimezone: true }),
|
|
251
|
+
lastAttemptedAt: timestamp("last_attempted_at", {
|
|
252
|
+
withTimezone: true
|
|
253
|
+
}).notNull(),
|
|
254
|
+
lastError: text("last_error")
|
|
255
|
+
},
|
|
256
|
+
(t) => [
|
|
257
|
+
primaryKey({
|
|
258
|
+
columns: [t.graphId, t.logicalName, t.owner, t.tableName]
|
|
259
|
+
})
|
|
260
|
+
]
|
|
261
|
+
);
|
|
262
|
+
const fulltext2 = pgTable(
|
|
263
|
+
n.fulltext,
|
|
264
|
+
{
|
|
265
|
+
graphId: text("graph_id").notNull(),
|
|
266
|
+
nodeKind: text("node_kind").notNull(),
|
|
267
|
+
nodeId: text("node_id").notNull(),
|
|
268
|
+
content: text("content").notNull(),
|
|
269
|
+
language: regconfig("language").notNull(),
|
|
270
|
+
tsv: tsvector("tsv").generatedAlwaysAs(sql`to_tsvector("language", "content")`).notNull(),
|
|
271
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
272
|
+
},
|
|
273
|
+
(t) => [
|
|
274
|
+
primaryKey({ columns: [t.graphId, t.nodeKind, t.nodeId] }),
|
|
275
|
+
index(`${n.fulltext}_tsv_idx`).using("gin", t.tsv),
|
|
276
|
+
index(`${n.fulltext}_kind_idx`).on(t.graphId, t.nodeKind)
|
|
277
|
+
]
|
|
278
|
+
);
|
|
279
|
+
return {
|
|
280
|
+
nodes: nodes3,
|
|
281
|
+
edges: edges3,
|
|
282
|
+
recordedNodes: recordedNodes3,
|
|
283
|
+
recordedEdges: recordedEdges3,
|
|
284
|
+
recordedClock: recordedClock3,
|
|
285
|
+
revisionOrigins,
|
|
286
|
+
uniques: uniques3,
|
|
287
|
+
schemaVersions: schemaVersions3,
|
|
288
|
+
indexMaterializations,
|
|
289
|
+
contributionMaterializations,
|
|
290
|
+
kindRemovals,
|
|
291
|
+
reconciliationMarkers,
|
|
292
|
+
fulltext: fulltext2,
|
|
293
|
+
fulltextTableName: n.fulltext
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
var tables = createPostgresTables();
|
|
297
|
+
var {
|
|
298
|
+
nodes,
|
|
299
|
+
edges,
|
|
300
|
+
recordedNodes,
|
|
301
|
+
recordedEdges,
|
|
302
|
+
recordedClock,
|
|
303
|
+
uniques,
|
|
304
|
+
schemaVersions,
|
|
305
|
+
fulltext
|
|
306
|
+
} = tables;
|
|
307
|
+
var LEGACY_EMBEDDINGS_TABLE_NAME = "typegraph_node_embeddings";
|
|
308
|
+
var DEFAULT_TABLE_NAMES2 = {
|
|
309
|
+
nodes: "typegraph_nodes",
|
|
310
|
+
edges: "typegraph_edges",
|
|
311
|
+
recordedNodes: "typegraph_recorded_nodes",
|
|
312
|
+
recordedEdges: "typegraph_recorded_edges",
|
|
313
|
+
recordedClock: "typegraph_recorded_clock",
|
|
314
|
+
revisionOrigins: "typegraph_revision_origins",
|
|
315
|
+
uniques: "typegraph_node_uniques",
|
|
316
|
+
schemaVersions: "typegraph_schema_versions",
|
|
317
|
+
fulltext: "typegraph_node_fulltext",
|
|
318
|
+
indexMaterializations: "typegraph_index_materializations",
|
|
319
|
+
contributionMaterializations: "typegraph_contribution_materializations",
|
|
320
|
+
kindRemovals: "typegraph_kind_removals",
|
|
321
|
+
reconciliationMarkers: "typegraph_reconciliation_markers"
|
|
322
|
+
};
|
|
323
|
+
function createSqliteTables(names = {}, options = {}) {
|
|
324
|
+
const n = { ...DEFAULT_TABLE_NAMES2, ...names };
|
|
325
|
+
const indexes = options.indexes ?? [];
|
|
326
|
+
assertNoSystemIndexNameCollision(indexes, n);
|
|
327
|
+
const nodes3 = sqliteTable(
|
|
328
|
+
n.nodes,
|
|
329
|
+
{
|
|
330
|
+
graphId: text$1("graph_id").notNull(),
|
|
331
|
+
kind: text$1("kind").notNull(),
|
|
332
|
+
id: text$1("id").notNull(),
|
|
333
|
+
props: text$1("props").notNull(),
|
|
334
|
+
version: integer$1("version").notNull().default(1),
|
|
335
|
+
validFrom: text$1("valid_from"),
|
|
336
|
+
validTo: text$1("valid_to"),
|
|
337
|
+
createdAt: text$1("created_at").notNull(),
|
|
338
|
+
updatedAt: text$1("updated_at").notNull(),
|
|
339
|
+
deletedAt: text$1("deleted_at")
|
|
340
|
+
},
|
|
341
|
+
(t) => [
|
|
342
|
+
primaryKey$1({ columns: [t.graphId, t.kind, t.id] }),
|
|
343
|
+
// System indexes come from SYSTEM_INDEX_DECLARATIONS (single source
|
|
344
|
+
// for both dialects + the runtime materializer).
|
|
345
|
+
...buildSqliteSystemIndexBuilders("nodes", n.nodes, t),
|
|
346
|
+
...buildSqliteNodeIndexBuilders(t, indexes)
|
|
347
|
+
]
|
|
348
|
+
);
|
|
349
|
+
const edges3 = sqliteTable(
|
|
350
|
+
n.edges,
|
|
351
|
+
{
|
|
352
|
+
graphId: text$1("graph_id").notNull(),
|
|
353
|
+
id: text$1("id").notNull(),
|
|
354
|
+
kind: text$1("kind").notNull(),
|
|
355
|
+
fromKind: text$1("from_kind").notNull(),
|
|
356
|
+
fromId: text$1("from_id").notNull(),
|
|
357
|
+
toKind: text$1("to_kind").notNull(),
|
|
358
|
+
toId: text$1("to_id").notNull(),
|
|
359
|
+
props: text$1("props").notNull(),
|
|
360
|
+
validFrom: text$1("valid_from"),
|
|
361
|
+
validTo: text$1("valid_to"),
|
|
362
|
+
createdAt: text$1("created_at").notNull(),
|
|
363
|
+
updatedAt: text$1("updated_at").notNull(),
|
|
364
|
+
deletedAt: text$1("deleted_at")
|
|
365
|
+
},
|
|
366
|
+
(t) => [
|
|
367
|
+
primaryKey$1({ columns: [t.graphId, t.id] }),
|
|
368
|
+
...buildSqliteSystemIndexBuilders("edges", n.edges, t),
|
|
369
|
+
...buildSqliteEdgeIndexBuilders(t, indexes)
|
|
370
|
+
]
|
|
371
|
+
);
|
|
372
|
+
const recordedNodes3 = sqliteTable(
|
|
373
|
+
n.recordedNodes,
|
|
374
|
+
{
|
|
375
|
+
historyId: text$1("history_id").notNull(),
|
|
376
|
+
graphId: text$1("graph_id").notNull(),
|
|
377
|
+
kind: text$1("kind").notNull(),
|
|
378
|
+
id: text$1("id").notNull(),
|
|
379
|
+
props: text$1("props").notNull(),
|
|
380
|
+
version: integer$1("version").notNull(),
|
|
381
|
+
validFrom: text$1("valid_from"),
|
|
382
|
+
validTo: text$1("valid_to"),
|
|
383
|
+
createdAt: text$1("created_at").notNull(),
|
|
384
|
+
updatedAt: text$1("updated_at").notNull(),
|
|
385
|
+
deletedAt: text$1("deleted_at"),
|
|
386
|
+
recordedFrom: integer$1("recorded_from").notNull(),
|
|
387
|
+
recordedTo: integer$1("recorded_to").notNull(),
|
|
388
|
+
op: text$1("op").notNull(),
|
|
389
|
+
schemaVersion: integer$1("schema_version"),
|
|
390
|
+
txId: text$1("tx_id"),
|
|
391
|
+
meta: text$1("meta")
|
|
392
|
+
},
|
|
393
|
+
(t) => [
|
|
394
|
+
primaryKey$1({ columns: [t.historyId] }),
|
|
395
|
+
...buildSqliteSystemIndexBuilders("recordedNodes", n.recordedNodes, t)
|
|
396
|
+
]
|
|
397
|
+
);
|
|
398
|
+
const recordedEdges3 = sqliteTable(
|
|
399
|
+
n.recordedEdges,
|
|
400
|
+
{
|
|
401
|
+
historyId: text$1("history_id").notNull(),
|
|
402
|
+
graphId: text$1("graph_id").notNull(),
|
|
403
|
+
id: text$1("id").notNull(),
|
|
404
|
+
kind: text$1("kind").notNull(),
|
|
405
|
+
fromKind: text$1("from_kind").notNull(),
|
|
406
|
+
fromId: text$1("from_id").notNull(),
|
|
407
|
+
toKind: text$1("to_kind").notNull(),
|
|
408
|
+
toId: text$1("to_id").notNull(),
|
|
409
|
+
props: text$1("props").notNull(),
|
|
410
|
+
validFrom: text$1("valid_from"),
|
|
411
|
+
validTo: text$1("valid_to"),
|
|
412
|
+
createdAt: text$1("created_at").notNull(),
|
|
413
|
+
updatedAt: text$1("updated_at").notNull(),
|
|
414
|
+
deletedAt: text$1("deleted_at"),
|
|
415
|
+
recordedFrom: integer$1("recorded_from").notNull(),
|
|
416
|
+
recordedTo: integer$1("recorded_to").notNull(),
|
|
417
|
+
op: text$1("op").notNull(),
|
|
418
|
+
schemaVersion: integer$1("schema_version"),
|
|
419
|
+
txId: text$1("tx_id"),
|
|
420
|
+
meta: text$1("meta")
|
|
421
|
+
},
|
|
422
|
+
(t) => [
|
|
423
|
+
primaryKey$1({ columns: [t.historyId] }),
|
|
424
|
+
...buildSqliteSystemIndexBuilders("recordedEdges", n.recordedEdges, t)
|
|
425
|
+
]
|
|
426
|
+
);
|
|
427
|
+
const recordedClock3 = sqliteTable(
|
|
428
|
+
n.recordedClock,
|
|
429
|
+
{
|
|
430
|
+
graphId: text$1("graph_id").notNull(),
|
|
431
|
+
revision: integer$1("revision").notNull(),
|
|
432
|
+
recordedAt: text$1("recorded_at").notNull()
|
|
433
|
+
},
|
|
434
|
+
(t) => [primaryKey$1({ columns: [t.graphId] })]
|
|
435
|
+
);
|
|
436
|
+
const revisionOrigins = sqliteTable(
|
|
437
|
+
n.revisionOrigins,
|
|
438
|
+
{
|
|
439
|
+
graphId: text$1("graph_id").notNull(),
|
|
440
|
+
origin: text$1("origin").notNull()
|
|
441
|
+
},
|
|
442
|
+
(t) => [primaryKey$1({ columns: [t.graphId] })]
|
|
443
|
+
);
|
|
444
|
+
const uniques3 = sqliteTable(
|
|
445
|
+
n.uniques,
|
|
446
|
+
{
|
|
447
|
+
graphId: text$1("graph_id").notNull(),
|
|
448
|
+
nodeKind: text$1("node_kind").notNull(),
|
|
449
|
+
constraintName: text$1("constraint_name").notNull(),
|
|
450
|
+
key: text$1("key").notNull(),
|
|
451
|
+
nodeId: text$1("node_id").notNull(),
|
|
452
|
+
concreteKind: text$1("concrete_kind").notNull(),
|
|
453
|
+
deletedAt: text$1("deleted_at")
|
|
454
|
+
},
|
|
455
|
+
(t) => [
|
|
456
|
+
primaryKey$1({
|
|
457
|
+
columns: [t.graphId, t.nodeKind, t.constraintName, t.key]
|
|
458
|
+
}),
|
|
459
|
+
index$1(`${n.uniques}_node_idx`).on(t.graphId, t.concreteKind, t.nodeId)
|
|
460
|
+
]
|
|
461
|
+
);
|
|
462
|
+
const schemaVersions3 = sqliteTable(
|
|
463
|
+
n.schemaVersions,
|
|
464
|
+
{
|
|
465
|
+
graphId: text$1("graph_id").notNull(),
|
|
466
|
+
version: integer$1("version").notNull(),
|
|
467
|
+
schemaHash: text$1("schema_hash").notNull(),
|
|
468
|
+
schemaDoc: text$1("schema_doc").notNull(),
|
|
469
|
+
createdAt: text$1("created_at").notNull(),
|
|
470
|
+
isActive: integer$1("is_active", { mode: "boolean" }).notNull().default(false)
|
|
471
|
+
},
|
|
472
|
+
(t) => [
|
|
473
|
+
primaryKey$1({ columns: [t.graphId, t.version] }),
|
|
474
|
+
index$1(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
|
|
475
|
+
// Partial unique index enforcing the "at most one active version
|
|
476
|
+
// per graph" invariant at the storage layer. Defense in depth
|
|
477
|
+
// against buggy backend implementations or out-of-band writes.
|
|
478
|
+
// Forces the deactivate-then-activate ordering used by
|
|
479
|
+
// `commitSchemaVersion` and `setActiveVersion`.
|
|
480
|
+
uniqueIndex$1(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(sql`${t.isActive} = 1`)
|
|
481
|
+
]
|
|
482
|
+
);
|
|
483
|
+
const indexMaterializations = sqliteTable(
|
|
484
|
+
n.indexMaterializations,
|
|
485
|
+
{
|
|
486
|
+
indexName: text$1("index_name").notNull(),
|
|
487
|
+
graphId: text$1("graph_id").notNull(),
|
|
488
|
+
entity: text$1("entity").notNull(),
|
|
489
|
+
kind: text$1("kind").notNull(),
|
|
490
|
+
signature: text$1("signature").notNull(),
|
|
491
|
+
schemaVersion: integer$1("schema_version").notNull(),
|
|
492
|
+
materializedAt: text$1("materialized_at"),
|
|
493
|
+
lastAttemptedAt: text$1("last_attempted_at").notNull(),
|
|
494
|
+
lastError: text$1("last_error")
|
|
495
|
+
},
|
|
496
|
+
(t) => [primaryKey$1({ columns: [t.indexName] })]
|
|
497
|
+
);
|
|
498
|
+
const kindRemovals = sqliteTable(
|
|
499
|
+
n.kindRemovals,
|
|
500
|
+
{
|
|
501
|
+
graphId: text$1("graph_id").notNull(),
|
|
502
|
+
kindName: text$1("kind_name").notNull(),
|
|
503
|
+
entity: text$1("entity").notNull(),
|
|
504
|
+
schemaVersion: integer$1("schema_version").notNull(),
|
|
505
|
+
removedAt: text$1("removed_at"),
|
|
506
|
+
lastAttemptedAt: text$1("last_attempted_at").notNull(),
|
|
507
|
+
lastError: text$1("last_error")
|
|
508
|
+
},
|
|
509
|
+
(t) => [
|
|
510
|
+
primaryKey$1({
|
|
511
|
+
columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
|
|
512
|
+
})
|
|
513
|
+
]
|
|
514
|
+
);
|
|
515
|
+
const reconciliationMarkers = sqliteTable(
|
|
516
|
+
n.reconciliationMarkers,
|
|
517
|
+
{
|
|
518
|
+
graphId: text$1("graph_id").notNull(),
|
|
519
|
+
reconciledToVersion: integer$1("reconciled_to_version").notNull()
|
|
520
|
+
},
|
|
521
|
+
(t) => [primaryKey$1({ columns: [t.graphId] })]
|
|
522
|
+
);
|
|
523
|
+
const contributionMaterializations = sqliteTable(
|
|
524
|
+
n.contributionMaterializations,
|
|
525
|
+
{
|
|
526
|
+
graphId: text$1("graph_id").notNull(),
|
|
527
|
+
logicalName: text$1("logical_name").notNull(),
|
|
528
|
+
owner: text$1("owner").notNull(),
|
|
529
|
+
tableName: text$1("table_name").notNull(),
|
|
530
|
+
signature: text$1("signature").notNull(),
|
|
531
|
+
materializedAt: text$1("materialized_at"),
|
|
532
|
+
lastAttemptedAt: text$1("last_attempted_at").notNull(),
|
|
533
|
+
lastError: text$1("last_error")
|
|
534
|
+
},
|
|
535
|
+
(t) => [
|
|
536
|
+
primaryKey$1({
|
|
537
|
+
columns: [t.graphId, t.logicalName, t.owner, t.tableName]
|
|
538
|
+
})
|
|
539
|
+
]
|
|
540
|
+
);
|
|
541
|
+
return {
|
|
542
|
+
nodes: nodes3,
|
|
543
|
+
edges: edges3,
|
|
544
|
+
recordedNodes: recordedNodes3,
|
|
545
|
+
recordedEdges: recordedEdges3,
|
|
546
|
+
recordedClock: recordedClock3,
|
|
547
|
+
revisionOrigins,
|
|
548
|
+
uniques: uniques3,
|
|
549
|
+
schemaVersions: schemaVersions3,
|
|
550
|
+
indexMaterializations,
|
|
551
|
+
contributionMaterializations,
|
|
552
|
+
kindRemovals,
|
|
553
|
+
reconciliationMarkers,
|
|
554
|
+
/**
|
|
555
|
+
* The fulltext storage is a FTS5 virtual table which Drizzle cannot
|
|
556
|
+
* represent. DDL is emitted as raw SQL and operations query it via
|
|
557
|
+
* `sql.raw()`.
|
|
558
|
+
*/
|
|
559
|
+
fulltextTableName: n.fulltext
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
var tables2 = createSqliteTables();
|
|
563
|
+
var {
|
|
564
|
+
nodes: nodes2,
|
|
565
|
+
edges: edges2,
|
|
566
|
+
recordedNodes: recordedNodes2,
|
|
567
|
+
recordedEdges: recordedEdges2,
|
|
568
|
+
recordedClock: recordedClock2,
|
|
569
|
+
uniques: uniques2,
|
|
570
|
+
schemaVersions: schemaVersions2
|
|
571
|
+
} = tables2;
|
|
572
|
+
function getSqliteColumnType(column) {
|
|
573
|
+
switch (column.columnType) {
|
|
574
|
+
case "SQLiteText": {
|
|
575
|
+
return "TEXT";
|
|
576
|
+
}
|
|
577
|
+
case "SQLiteInteger": {
|
|
578
|
+
return "INTEGER";
|
|
579
|
+
}
|
|
580
|
+
case "SQLiteReal": {
|
|
581
|
+
return "REAL";
|
|
582
|
+
}
|
|
583
|
+
case "SQLiteBlob": {
|
|
584
|
+
return "BLOB";
|
|
585
|
+
}
|
|
586
|
+
default: {
|
|
587
|
+
return "TEXT";
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
function formatDefaultValue(value) {
|
|
592
|
+
if (value === null) return "NULL";
|
|
593
|
+
if (typeof value === "string") return `'${value}'`;
|
|
594
|
+
if (typeof value === "number") return String(value);
|
|
595
|
+
if (typeof value === "boolean") return value ? "1" : "0";
|
|
596
|
+
return JSON.stringify(value);
|
|
597
|
+
}
|
|
598
|
+
function generateSqliteCreateTableSQL(table) {
|
|
599
|
+
const config = getTableConfig(table);
|
|
600
|
+
const columnDefs = [];
|
|
601
|
+
for (const column of config.columns) {
|
|
602
|
+
const parts = [
|
|
603
|
+
`"${column.name}"`,
|
|
604
|
+
getSqliteColumnType(column)
|
|
605
|
+
];
|
|
606
|
+
if (column.notNull) {
|
|
607
|
+
parts.push("NOT NULL");
|
|
608
|
+
}
|
|
609
|
+
if (column.hasDefault && column.default !== void 0) {
|
|
610
|
+
parts.push(`DEFAULT ${formatDefaultValue(column.default)}`);
|
|
611
|
+
}
|
|
612
|
+
columnDefs.push(parts.join(" "));
|
|
613
|
+
}
|
|
614
|
+
const pk = config.primaryKeys[0];
|
|
615
|
+
if (pk) {
|
|
616
|
+
const pkColumns = pk.columns.map((c) => `"${c.name}"`).join(", ");
|
|
617
|
+
columnDefs.push(`PRIMARY KEY (${pkColumns})`);
|
|
618
|
+
}
|
|
619
|
+
return `CREATE TABLE IF NOT EXISTS "${config.name}" (
|
|
620
|
+
${columnDefs.join(",\n ")}
|
|
621
|
+
);`;
|
|
622
|
+
}
|
|
623
|
+
function renderIndexColumn(col) {
|
|
624
|
+
if (col && typeof col === "object" && "name" in col) {
|
|
625
|
+
return `"${col.name}"`;
|
|
626
|
+
}
|
|
627
|
+
const sql3 = tryInlineSql(col);
|
|
628
|
+
if (sql3 !== void 0) {
|
|
629
|
+
return sql3;
|
|
630
|
+
}
|
|
631
|
+
return "unknown";
|
|
632
|
+
}
|
|
633
|
+
function tryInlineSql(value) {
|
|
634
|
+
if (value && typeof value === "object" && "getSQL" in value) {
|
|
635
|
+
const maybe = value;
|
|
636
|
+
if (typeof maybe.getSQL === "function") {
|
|
637
|
+
return inlineSql(maybe.getSQL());
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
return inlineSql(value);
|
|
641
|
+
}
|
|
642
|
+
function flattenSqlChunk(chunk) {
|
|
643
|
+
if (typeof chunk === "string") {
|
|
644
|
+
return chunk;
|
|
645
|
+
}
|
|
646
|
+
if (typeof chunk === "object" && chunk !== null) {
|
|
647
|
+
if ("name" in chunk && typeof chunk.name === "string") {
|
|
648
|
+
return `"${chunk.name}"`;
|
|
649
|
+
}
|
|
650
|
+
if ("value" in chunk) {
|
|
651
|
+
const value = chunk.value;
|
|
652
|
+
if (typeof value === "string") {
|
|
653
|
+
return value;
|
|
654
|
+
}
|
|
655
|
+
if (Array.isArray(value)) {
|
|
656
|
+
return value.map((part) => flattenSqlChunk(part)).join("");
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if ("queryChunks" in chunk && Array.isArray(chunk.queryChunks)) {
|
|
660
|
+
return chunk.queryChunks.map((part) => flattenSqlChunk(part)).join("");
|
|
661
|
+
}
|
|
662
|
+
if ("getSQL" in chunk) {
|
|
663
|
+
const maybe = chunk;
|
|
664
|
+
if (typeof maybe.getSQL === "function") {
|
|
665
|
+
return flattenSqlChunk(maybe.getSQL());
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
throw new Error(`Unable to inline SQL chunk: ${String(chunk)}`);
|
|
670
|
+
}
|
|
671
|
+
function inlineSql(value) {
|
|
672
|
+
try {
|
|
673
|
+
return flattenSqlChunk(value);
|
|
674
|
+
} catch {
|
|
675
|
+
return void 0;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function inlineSqlOrThrow(value, context) {
|
|
679
|
+
const inlined = inlineSql(value);
|
|
680
|
+
if (inlined === void 0) {
|
|
681
|
+
throw new Error(`Unable to inline SQL for ${context}`);
|
|
682
|
+
}
|
|
683
|
+
return inlined;
|
|
684
|
+
}
|
|
685
|
+
function generateSqliteCreateIndexSQL(table) {
|
|
686
|
+
const config = getTableConfig(table);
|
|
687
|
+
const statements = [];
|
|
688
|
+
for (const index3 of config.indexes) {
|
|
689
|
+
const indexConfig = index3.config;
|
|
690
|
+
const columns = indexConfig.columns.map((c) => renderIndexColumn(c)).join(", ");
|
|
691
|
+
const unique = indexConfig.unique ? "UNIQUE " : "";
|
|
692
|
+
const where = indexConfig.where ? ` WHERE ${inlineSqlOrThrow(indexConfig.where, `SQLite index "${indexConfig.name}" WHERE clause`)}` : "";
|
|
693
|
+
statements.push(
|
|
694
|
+
`CREATE ${unique}INDEX IF NOT EXISTS "${indexConfig.name}" ON "${config.name}" (${columns})${where};`
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
return statements;
|
|
698
|
+
}
|
|
699
|
+
function isSqliteTable(value) {
|
|
700
|
+
return is(value, SQLiteTable);
|
|
701
|
+
}
|
|
702
|
+
function runtimeStrategyContributions(fulltextStrategy, fulltextTableName) {
|
|
703
|
+
return fulltextStrategy.ownedTables(fulltextTableName).filter((contribution) => contribution.runtimeEnsure);
|
|
704
|
+
}
|
|
705
|
+
function sqliteContributions(tables3 = tables2, fulltextStrategy = fts5Strategy) {
|
|
706
|
+
const contributions = [];
|
|
707
|
+
for (const [key, table] of Object.entries(tables3)) {
|
|
708
|
+
if (!isSqliteTable(table)) continue;
|
|
709
|
+
contributions.push({
|
|
710
|
+
logicalName: key,
|
|
711
|
+
owner: BASE_CONTRIBUTION_OWNER,
|
|
712
|
+
tableName: getTableConfig(table).name,
|
|
713
|
+
createDdl: [
|
|
714
|
+
generateSqliteCreateTableSQL(table),
|
|
715
|
+
...generateSqliteCreateIndexSQL(table)
|
|
716
|
+
],
|
|
717
|
+
runtimeEnsure: false
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
for (const declared of fulltextStrategy.ownedTables(
|
|
721
|
+
tables3.fulltextTableName
|
|
722
|
+
)) {
|
|
723
|
+
contributions.push(declared);
|
|
724
|
+
}
|
|
725
|
+
return contributions;
|
|
726
|
+
}
|
|
727
|
+
function generateSqliteDDL(tables3 = tables2, fulltextStrategy = fts5Strategy) {
|
|
728
|
+
return sqliteContributions(tables3, fulltextStrategy).flatMap(
|
|
729
|
+
(contribution) => [...contribution.createDdl]
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = fts5Strategy) {
|
|
733
|
+
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
734
|
+
}
|
|
735
|
+
function getPgColumnType(column) {
|
|
736
|
+
switch (column.columnType) {
|
|
737
|
+
case "PgText": {
|
|
738
|
+
return "TEXT";
|
|
739
|
+
}
|
|
740
|
+
case "PgInteger": {
|
|
741
|
+
return "INTEGER";
|
|
742
|
+
}
|
|
743
|
+
case "PgBigInt53":
|
|
744
|
+
case "PgBigInt64": {
|
|
745
|
+
return "BIGINT";
|
|
746
|
+
}
|
|
747
|
+
case "PgBoolean": {
|
|
748
|
+
return "BOOLEAN";
|
|
749
|
+
}
|
|
750
|
+
case "PgJsonb": {
|
|
751
|
+
return "JSONB";
|
|
752
|
+
}
|
|
753
|
+
case "PgTimestamp": {
|
|
754
|
+
return column.config?.withTimezone ? "TIMESTAMPTZ" : "TIMESTAMP";
|
|
755
|
+
}
|
|
756
|
+
case "PgReal": {
|
|
757
|
+
return "REAL";
|
|
758
|
+
}
|
|
759
|
+
case "PgDoublePrecision": {
|
|
760
|
+
return "DOUBLE PRECISION";
|
|
761
|
+
}
|
|
762
|
+
case "PgCustomColumn": {
|
|
763
|
+
const dataType = column.getSQLType?.();
|
|
764
|
+
return dataType ?? "TEXT";
|
|
765
|
+
}
|
|
766
|
+
default: {
|
|
767
|
+
return "TEXT";
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
function formatPgDefaultValue(value) {
|
|
772
|
+
if (value === null) return "NULL";
|
|
773
|
+
if (typeof value === "string") return `'${value}'`;
|
|
774
|
+
if (typeof value === "number") return String(value);
|
|
775
|
+
if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
|
|
776
|
+
return JSON.stringify(value);
|
|
777
|
+
}
|
|
778
|
+
function generatePgCreateTableSQL(table) {
|
|
779
|
+
const config = getTableConfig$1(table);
|
|
780
|
+
const columnDefs = [];
|
|
781
|
+
for (const column of config.columns) {
|
|
782
|
+
const parts = [`"${column.name}"`, getPgColumnType(column)];
|
|
783
|
+
if (column.notNull) {
|
|
784
|
+
parts.push("NOT NULL");
|
|
785
|
+
}
|
|
786
|
+
if (column.hasDefault && column.default !== void 0) {
|
|
787
|
+
parts.push(`DEFAULT ${formatPgDefaultValue(column.default)}`);
|
|
788
|
+
}
|
|
789
|
+
columnDefs.push(parts.join(" "));
|
|
790
|
+
}
|
|
791
|
+
const pk = config.primaryKeys[0];
|
|
792
|
+
if (pk) {
|
|
793
|
+
const pkColumns = pk.columns.map((c) => `"${c.name}"`).join(", ");
|
|
794
|
+
columnDefs.push(`PRIMARY KEY (${pkColumns})`);
|
|
795
|
+
}
|
|
796
|
+
return `CREATE TABLE IF NOT EXISTS "${config.name}" (
|
|
797
|
+
${columnDefs.join(",\n ")}
|
|
798
|
+
);`;
|
|
799
|
+
}
|
|
800
|
+
function generatePgCreateIndexSQL(table) {
|
|
801
|
+
const config = getTableConfig$1(table);
|
|
802
|
+
const statements = [];
|
|
803
|
+
for (const index3 of config.indexes) {
|
|
804
|
+
const indexConfig = index3.config;
|
|
805
|
+
const columns = indexConfig.columns.map((c) => renderIndexColumn(c)).join(", ");
|
|
806
|
+
const unique = indexConfig.unique ? "UNIQUE " : "";
|
|
807
|
+
const method = indexConfig.method && indexConfig.method !== "btree" ? ` USING ${indexConfig.method}` : "";
|
|
808
|
+
const where = indexConfig.where ? ` WHERE ${inlineSqlOrThrow(indexConfig.where, `PostgreSQL index "${indexConfig.name}" WHERE clause`)}` : "";
|
|
809
|
+
statements.push(
|
|
810
|
+
`CREATE ${unique}INDEX IF NOT EXISTS "${indexConfig.name}" ON "${config.name}"${method} (${columns})${where};`
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
return statements;
|
|
814
|
+
}
|
|
815
|
+
function isPgTable(value) {
|
|
816
|
+
return is(value, PgTable);
|
|
817
|
+
}
|
|
818
|
+
function postgresContributions(tables3 = tables, fulltextStrategy = tsvectorStrategy) {
|
|
819
|
+
const contributions = [];
|
|
820
|
+
for (const [key, table] of Object.entries(tables3)) {
|
|
821
|
+
if (!isPgTable(table)) continue;
|
|
822
|
+
if (table === tables3.fulltext) continue;
|
|
823
|
+
contributions.push({
|
|
824
|
+
logicalName: key,
|
|
825
|
+
owner: BASE_CONTRIBUTION_OWNER,
|
|
826
|
+
tableName: getTableConfig$1(table).name,
|
|
827
|
+
createDdl: [
|
|
828
|
+
generatePgCreateTableSQL(table),
|
|
829
|
+
...generatePgCreateIndexSQL(table)
|
|
830
|
+
],
|
|
831
|
+
runtimeEnsure: false
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
for (const declared of fulltextStrategy.ownedTables(
|
|
835
|
+
tables3.fulltextTableName
|
|
836
|
+
)) {
|
|
837
|
+
contributions.push(declared);
|
|
838
|
+
}
|
|
839
|
+
return contributions;
|
|
840
|
+
}
|
|
841
|
+
function generatePostgresDDL(tables3 = tables, fulltextStrategy = tsvectorStrategy) {
|
|
842
|
+
return postgresContributions(tables3, fulltextStrategy).flatMap(
|
|
843
|
+
(contribution) => [...contribution.createDdl]
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = tsvectorStrategy) {
|
|
847
|
+
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
848
|
+
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
849
|
+
return `${extensionSql}
|
|
850
|
+
|
|
851
|
+
${ddlSql}`;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
export { LEGACY_EMBEDDINGS_TABLE_NAME, createPostgresTables, createSqliteTables, edges, edges2, fulltext, generatePgCreateTableSQL, generatePostgresDDL, generatePostgresMigrationSQL, generateSqliteCreateTableSQL, generateSqliteDDL, generateSqliteMigrationSQL, nodes, nodes2, postgresContributions, recordedClock, recordedClock2, recordedEdges, recordedEdges2, recordedNodes, recordedNodes2, runtimeStrategyContributions, schemaVersions, schemaVersions2, sqliteContributions, tables, tables2, uniques, uniques2 };
|
|
855
|
+
//# sourceMappingURL=chunk-5J4VNCUD.js.map
|
|
856
|
+
//# sourceMappingURL=chunk-5J4VNCUD.js.map
|