openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
31 lines (30 loc) • 1.19 kB
JavaScript
import { t as isPromiseLike } from "./promise-like-aMoWEh5w.mjs";
//#region src/shared/listeners.ts
/** Notifies every registered listener while isolating individual listener failures. */
function notifyListeners(e, t, n) {
for (const r of e) try {
r(t);
} catch (e) {
n?.(e);
}
}
/** Registers a listener in a Set and returns an idempotent unsubscribe handle. */
function registerListener(e, t) {
e.add(t);
return () => e.delete(t);
}
//#endregion
//#region src/infra/sql-connection.ts
function assertSyncTransactionResult(e) {
if (isPromiseLike(e)) throw new Error("SQLite write transactions must be synchronous; Promise returns are not supported.");
}
const postgresConnectionBrand = Symbol.for("openclaw.postgres-sync-connection");
function isPostgresSqlConnection(e) {
return postgresConnectionBrand in e && e[postgresConnectionBrand] === true;
}
/** Publications and receipts must key on the store anchor for every engine. */
function sqlPublicationAnchor(e) {
return isPostgresSqlConnection(e) ? e.anchor : e;
}
//#endregion
export { registerListener as a, notifyListeners as i, isPostgresSqlConnection as n, sqlPublicationAnchor as r, assertSyncTransactionResult as t };