openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
28 lines (27 loc) • 1.4 kB
JavaScript
import { b as extractSqliteTableSchema } from "./sqlite-schema-facts-BVf0E_0z.mjs";
import { r as createSqliteSchemaEnsurer } from "./openclaw-agent-session-transcript-archive-schema-D-prUhTC.mjs";
import { t as OPENCLAW_STATE_SCHEMA_SQL } from "./openclaw-state-schema-Cr2v_hbj.mjs";
import { l as runOpenClawStateWriteTransaction, r as openOpenClawStateDatabase } from "./openclaw-state-db-DJZ7EKoI.mjs";
//#region src/state/openclaw-state-feature-schema.ts
/** Prepare canonical DDL without opening a database; each feature keeps its own handle cache. */
function createOpenClawStateSchemaEnsurer(params) {
const schema = extractSqliteTableSchema(OPENCLAW_STATE_SCHEMA_SQL, params.table, {
endMarker: params.endMarker ?? "\n) STRICT;\n",
errorMessage: `Canonical state schema markers are missing for ${params.table}`
});
const ensure = createSqliteSchemaEnsurer(() => schema, {
tables: [params.table, ...params.additionalTables ?? []],
indexes: params.indexes
});
const ensuredDatabases = /* @__PURE__ */ new WeakSet();
return (options = {}) => {
const database = openOpenClawStateDatabase(options);
if (ensuredDatabases.has(database.db)) return;
runOpenClawStateWriteTransaction(({ db }) => {
ensure(db);
}, options, { operationLabel: params.operationLabel });
ensuredDatabases.add(database.db);
};
}
//#endregion
export { createOpenClawStateSchemaEnsurer as t };