@nicia-ai/typegraph 0.26.0 → 0.28.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/postgres/index.cjs +99 -57
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +4 -4
- package/dist/backend/postgres/index.d.ts +4 -4
- package/dist/backend/postgres/index.js +47 -5
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +13 -13
- package/dist/backend/sqlite/index.d.cts +5 -5
- package/dist/backend/sqlite/index.d.ts +5 -5
- package/dist/backend/sqlite/index.js +3 -3
- package/dist/backend/sqlite/libsql.cjs +6 -6
- package/dist/backend/sqlite/libsql.d.cts +2 -2
- package/dist/backend/sqlite/libsql.d.ts +2 -2
- package/dist/backend/sqlite/libsql.js +3 -3
- package/dist/backend/sqlite/local.cjs +7 -7
- package/dist/backend/sqlite/local.d.cts +2 -2
- package/dist/backend/sqlite/local.d.ts +2 -2
- package/dist/backend/sqlite/local.js +3 -3
- package/dist/{chunk-TVUARC7S.cjs → chunk-2E4VTD2E.cjs} +50 -22
- package/dist/chunk-2E4VTD2E.cjs.map +1 -0
- package/dist/{chunk-RVT2N4RF.cjs → chunk-33K3ZYFG.cjs} +46 -46
- package/dist/{chunk-RVT2N4RF.cjs.map → chunk-33K3ZYFG.cjs.map} +1 -1
- package/dist/{chunk-RF5EUQWS.js → chunk-DFHLG75V.js} +50 -22
- package/dist/chunk-DFHLG75V.js.map +1 -0
- package/dist/{chunk-DN4RUDF3.cjs → chunk-LYRUNG6E.cjs} +2 -2
- package/dist/chunk-LYRUNG6E.cjs.map +1 -0
- package/dist/{chunk-ENXJLDRK.js → chunk-PCHTTG42.js} +2 -2
- package/dist/chunk-PCHTTG42.js.map +1 -0
- package/dist/{chunk-DDVA4QBA.js → chunk-UKG7XHZ3.js} +4 -4
- package/dist/{chunk-DDVA4QBA.js.map → chunk-UKG7XHZ3.js.map} +1 -1
- package/dist/{chunk-3W6AIFT2.js → chunk-X53YKGHR.js} +74 -8
- package/dist/chunk-X53YKGHR.js.map +1 -0
- package/dist/{chunk-4TJI44WP.cjs → chunk-ZGEMI7MJ.cjs} +75 -7
- package/dist/chunk-ZGEMI7MJ.cjs.map +1 -0
- package/dist/{ddl-9kw8UADK.d.ts → ddl-0Ooc2dpL.d.ts} +2 -2
- package/dist/{ddl-Cw82BPM4.d.cts → ddl-Dza3kDrI.d.cts} +2 -2
- package/dist/index.cjs +100 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +40 -7
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/interchange/index.d.cts +3 -3
- package/dist/interchange/index.d.ts +3 -3
- package/dist/{manager-Aqzmztkb.d.cts → manager-c1MGaVVR.d.cts} +35 -11
- package/dist/{manager-C3LxzPcX.d.ts → manager-ehLTTNq0.d.ts} +35 -11
- package/dist/profiler/index.d.cts +5 -5
- package/dist/profiler/index.d.ts +5 -5
- package/dist/schema/index.cjs +28 -24
- package/dist/schema/index.d.cts +4 -4
- package/dist/schema/index.d.ts +4 -4
- package/dist/schema/index.js +2 -2
- package/dist/{sqlite-GKvcDPVn.d.ts → sqlite-BxZUPbyD.d.ts} +1 -1
- package/dist/{sqlite-BvSEbybu.d.cts → sqlite-mvpXjEeB.d.cts} +1 -1
- package/dist/{store-DbQLsSor.d.cts → store-D7YEMg2v.d.cts} +69 -3
- package/dist/{store-CiS_AGNH.d.ts → store-Ufc1Eoey.d.ts} +69 -3
- package/dist/{types-Cars4JZ1.d.ts → types-B-sJJ4GQ.d.ts} +1 -1
- package/dist/{types-DZPBXZOK.d.cts → types-CMQymcwk.d.cts} +11 -0
- package/dist/{types-Dzkr0Eqi.d.ts → types-CQ7xXJMP.d.ts} +11 -0
- package/dist/{types-CF7nDH3q.d.cts → types-CmUA9sal.d.cts} +1 -1
- package/dist/{where-BmtjfWuS.d.cts → where-5zf15aFZ.d.cts} +1 -1
- package/dist/{where-kk1Zz2En.d.ts → where-CtrLu1Zf.d.ts} +1 -1
- package/package.json +8 -8
- package/dist/chunk-3W6AIFT2.js.map +0 -1
- package/dist/chunk-4TJI44WP.cjs.map +0 -1
- package/dist/chunk-DN4RUDF3.cjs.map +0 -1
- package/dist/chunk-ENXJLDRK.js.map +0 -1
- package/dist/chunk-RF5EUQWS.js.map +0 -1
- package/dist/chunk-TVUARC7S.cjs.map +0 -1
|
@@ -2362,10 +2362,7 @@ function parseSerializedSchema(json) {
|
|
|
2362
2362
|
}
|
|
2363
2363
|
async function loadActiveSchemaWithBootstrap(backend, graphId) {
|
|
2364
2364
|
try {
|
|
2365
|
-
|
|
2366
|
-
const ensureRuntime = backend.ensureRuntimeContributions ? backend.ensureRuntimeContributions(graphId) : backend.ensureFulltextTable?.(graphId);
|
|
2367
|
-
await ensureRuntime;
|
|
2368
|
-
return row;
|
|
2365
|
+
return await backend.getActiveSchema(graphId);
|
|
2369
2366
|
} catch (error) {
|
|
2370
2367
|
if (backend.bootstrapTables && chunkIUIWCFG3_cjs.isMissingTableError(error)) {
|
|
2371
2368
|
await backend.bootstrapTables();
|
|
@@ -2379,11 +2376,17 @@ async function loadAndMergeGraphExtensionDocument(backend, graph) {
|
|
|
2379
2376
|
if (activeRow === void 0) {
|
|
2380
2377
|
return { graph, activeRow: void 0, storedSchema: void 0 };
|
|
2381
2378
|
}
|
|
2379
|
+
const { graph: merged, storedSchema } = mergeStoredGraphExtension(
|
|
2380
|
+
graph,
|
|
2381
|
+
activeRow
|
|
2382
|
+
);
|
|
2383
|
+
return { graph: merged, activeRow, storedSchema };
|
|
2384
|
+
}
|
|
2385
|
+
function mergeStoredGraphExtension(graph, activeRow) {
|
|
2382
2386
|
const storedSchema = parseSerializedSchema(activeRow.schema_doc);
|
|
2383
2387
|
const merged = storedSchema.extension === void 0 ? graph : mergeGraphExtension(graph, storedSchema.extension);
|
|
2384
2388
|
return {
|
|
2385
2389
|
graph: applyDeprecatedKinds(merged, storedSchema.deprecatedKinds),
|
|
2386
|
-
activeRow,
|
|
2387
2390
|
storedSchema
|
|
2388
2391
|
};
|
|
2389
2392
|
}
|
|
@@ -2466,6 +2469,69 @@ async function ensureSchema(backend, graph, options) {
|
|
|
2466
2469
|
}
|
|
2467
2470
|
return { status: "breaking", diff, actions };
|
|
2468
2471
|
}
|
|
2472
|
+
async function loadAndVerifyGraph(backend, graph) {
|
|
2473
|
+
const activeRow = await readActiveSchemaPure(backend, graph.id);
|
|
2474
|
+
const { graph: merged, storedSchema } = mergeStoredGraphExtension(
|
|
2475
|
+
graph,
|
|
2476
|
+
activeRow
|
|
2477
|
+
);
|
|
2478
|
+
const storedHash = activeRow.schema_hash;
|
|
2479
|
+
const currentHash = await getSchemaHash(merged, activeRow.version + 1);
|
|
2480
|
+
if (storedHash !== currentHash) {
|
|
2481
|
+
const currentSchema = serializeSchema(merged, activeRow.version + 1);
|
|
2482
|
+
const diff = computeSchemaDiff(storedSchema, currentSchema);
|
|
2483
|
+
if (diff.hasChanges) {
|
|
2484
|
+
throw schemaBehindError(merged.id, activeRow.version, diff);
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
await backend.assertRuntimeContributionsInitialized?.(merged.id);
|
|
2488
|
+
return {
|
|
2489
|
+
graph: merged,
|
|
2490
|
+
activeRow,
|
|
2491
|
+
result: { status: "unchanged", version: activeRow.version }
|
|
2492
|
+
};
|
|
2493
|
+
}
|
|
2494
|
+
function schemaBehindError(graphId, fromVersion, diff) {
|
|
2495
|
+
const actions = getMigrationActions(diff);
|
|
2496
|
+
const qualifier = isBackwardsCompatible(diff) ? "safe auto-migration" : "breaking change";
|
|
2497
|
+
return new chunkYEDQLNVE_cjs.MigrationError(
|
|
2498
|
+
`Schema verification failed for graph "${graphId}": ${diff.summary} (${qualifier}). ${actions.length} migration action(s) needed. The least-privilege runtime cannot migrate \u2014 run createStoreWithSchema(graph, adminBackend) under a privileged role (after any generated migration SQL, if you manage DDL externally) before attaching with createStore() / createVerifiedStore().`,
|
|
2499
|
+
{
|
|
2500
|
+
graphId,
|
|
2501
|
+
fromVersion,
|
|
2502
|
+
toVersion: fromVersion + 1
|
|
2503
|
+
}
|
|
2504
|
+
);
|
|
2505
|
+
}
|
|
2506
|
+
async function assertSchemaCurrent(backend, graph) {
|
|
2507
|
+
const { result } = await loadAndVerifyGraph(backend, graph);
|
|
2508
|
+
return result;
|
|
2509
|
+
}
|
|
2510
|
+
async function readActiveSchemaPure(backend, graphId) {
|
|
2511
|
+
let activeRow;
|
|
2512
|
+
try {
|
|
2513
|
+
activeRow = await backend.getActiveSchema(graphId);
|
|
2514
|
+
} catch (error) {
|
|
2515
|
+
if (chunkIUIWCFG3_cjs.isMissingTableError(error)) {
|
|
2516
|
+
throw schemaNotInitializedError(graphId, error);
|
|
2517
|
+
}
|
|
2518
|
+
throw error;
|
|
2519
|
+
}
|
|
2520
|
+
if (activeRow === void 0) {
|
|
2521
|
+
throw schemaNotInitializedError(graphId);
|
|
2522
|
+
}
|
|
2523
|
+
return activeRow;
|
|
2524
|
+
}
|
|
2525
|
+
function schemaNotInitializedError(graphId, cause) {
|
|
2526
|
+
return new chunkYEDQLNVE_cjs.ConfigurationError(
|
|
2527
|
+
`Cannot verify graph "${graphId}": no schema has been initialized. Run createStoreWithSchema(graph, adminBackend) once under a privileged role (which commits the schema_versions row and materializes contribution markers) before attaching with createStore() / createVerifiedStore(). Generated migration SQL creates the tables but does not initialize the schema row.`,
|
|
2528
|
+
{ graphId },
|
|
2529
|
+
{
|
|
2530
|
+
cause,
|
|
2531
|
+
suggestion: "Run createStoreWithSchema(graph, adminBackend) once under a privileged role. If you manage DDL externally with drizzle-kit / generatePostgresMigrationSQL / generateSqliteMigrationSQL, apply that first, then still run createStoreWithSchema to commit the schema row and contribution markers."
|
|
2532
|
+
}
|
|
2533
|
+
);
|
|
2534
|
+
}
|
|
2469
2535
|
async function initializeSchema(backend, graph) {
|
|
2470
2536
|
const schema = serializeSchema(graph, 1);
|
|
2471
2537
|
const hash = await computeSchemaHash(schema);
|
|
@@ -2603,6 +2669,7 @@ function createValidationError(message, issues, context) {
|
|
|
2603
2669
|
exports.KindRegistry = KindRegistry;
|
|
2604
2670
|
exports.META_EDGE_BRAND = META_EDGE_BRAND;
|
|
2605
2671
|
exports.applyDeprecatedKinds = applyDeprecatedKinds;
|
|
2672
|
+
exports.assertSchemaCurrent = assertSchemaCurrent;
|
|
2606
2673
|
exports.broader = broader;
|
|
2607
2674
|
exports.buildGraphExtensionOntologyKeySet = buildGraphExtensionOntologyKeySet;
|
|
2608
2675
|
exports.commitNewSchemaVersion = commitNewSchemaVersion;
|
|
@@ -2634,6 +2701,7 @@ exports.isMetaEdge = isMetaEdge;
|
|
|
2634
2701
|
exports.isSchemaInitialized = isSchemaInitialized;
|
|
2635
2702
|
exports.loadActiveSchemaWithBootstrap = loadActiveSchemaWithBootstrap;
|
|
2636
2703
|
exports.loadAndMergeGraphExtensionDocument = loadAndMergeGraphExtensionDocument;
|
|
2704
|
+
exports.loadAndVerifyGraph = loadAndVerifyGraph;
|
|
2637
2705
|
exports.mergeGraphExtension = mergeGraphExtension;
|
|
2638
2706
|
exports.migrateSchema = migrateSchema;
|
|
2639
2707
|
exports.narrower = narrower;
|
|
@@ -2649,5 +2717,5 @@ exports.validateEdgeProps = validateEdgeProps;
|
|
|
2649
2717
|
exports.validateNodeProps = validateNodeProps;
|
|
2650
2718
|
exports.validateProps = validateProps;
|
|
2651
2719
|
exports.wrapZodError = wrapZodError;
|
|
2652
|
-
//# sourceMappingURL=chunk-
|
|
2653
|
-
//# sourceMappingURL=chunk-
|
|
2720
|
+
//# sourceMappingURL=chunk-ZGEMI7MJ.cjs.map
|
|
2721
|
+
//# sourceMappingURL=chunk-ZGEMI7MJ.cjs.map
|