@portqueue/core 1.0.0 → 1.0.2
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/README.md +5 -5
- package/dist/conformance/index.cjs +1 -1
- package/dist/conformance/index.mjs +1 -1
- package/dist/constants/storage.constants.d.ts +2 -2
- package/dist/drivers/driver-context.d.ts +1 -1
- package/dist/drivers/driver.interface.d.ts +1 -1
- package/dist/drivers/mysql/index.cjs +3 -3
- package/dist/drivers/mysql/index.cjs.map +1 -1
- package/dist/drivers/mysql/index.mjs +3 -3
- package/dist/drivers/mysql/index.mjs.map +1 -1
- package/dist/drivers/mysql/mysql-driver.d.ts +1 -1
- package/dist/drivers/oracle/index.cjs +3 -3
- package/dist/drivers/oracle/index.cjs.map +1 -1
- package/dist/drivers/oracle/index.mjs +3 -3
- package/dist/drivers/oracle/index.mjs.map +1 -1
- package/dist/drivers/oracle/oracle-driver.d.ts +1 -1
- package/dist/drivers/pglite/index.cjs +7 -7
- package/dist/drivers/pglite/index.cjs.map +1 -1
- package/dist/drivers/pglite/index.mjs +6 -6
- package/dist/drivers/pglite/index.mjs.map +1 -1
- package/dist/drivers/pglite/migrations.d.ts +2 -2
- package/dist/drivers/pglite/pglite-driver.d.ts +7 -7
- package/dist/drivers/postgresql/index.cjs +5 -0
- package/dist/drivers/postgresql/index.d.ts +2 -0
- package/dist/drivers/postgresql/index.mjs +5 -0
- package/dist/drivers/{postgres → postgresql}/migrations.d.ts +5 -5
- package/dist/drivers/{postgres/postgres-driver.d.ts → postgresql/postgresql-driver.d.ts} +7 -7
- package/dist/drivers/shared/base-driver.d.ts +4 -4
- package/dist/drivers/shared/migration-runner.service.d.ts +1 -1
- package/dist/drivers/sqlite/index.cjs +2 -2
- package/dist/drivers/sqlite/index.cjs.map +1 -1
- package/dist/drivers/sqlite/index.mjs +2 -2
- package/dist/drivers/sqlite/index.mjs.map +1 -1
- package/dist/drivers/table-names.d.ts +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{migration-CWBCpwFH.cjs → migration-CoTjpgBl.cjs} +7 -7
- package/dist/migration-CoTjpgBl.cjs.map +1 -0
- package/dist/{migration-CQsAizIw.js → migration-D73ANkYV.js} +7 -7
- package/dist/migration-D73ANkYV.js.map +1 -0
- package/dist/options/enums.d.ts +1 -1
- package/dist/{postgres-driver-eWlY7pVg.js → postgresql-driver-BUHuyRYj.js} +14 -14
- package/dist/postgresql-driver-BUHuyRYj.js.map +1 -0
- package/dist/{postgres-driver-F9-TIi38.cjs → postgresql-driver-CIk94XCq.cjs} +14 -14
- package/dist/postgresql-driver-CIk94XCq.cjs.map +1 -0
- package/dist/{storage.constants-CIkf7BAJ.cjs → storage.constants-B5oQjxp5.cjs} +2 -2
- package/dist/storage.constants-B5oQjxp5.cjs.map +1 -0
- package/dist/{storage.constants-BDS_q-_N.js → storage.constants-DwSzjjMZ.js} +2 -2
- package/dist/storage.constants-DwSzjjMZ.js.map +1 -0
- package/dist/tx/index.cjs +8 -8
- package/dist/tx/index.cjs.map +1 -1
- package/dist/tx/index.mjs +8 -8
- package/dist/tx/index.mjs.map +1 -1
- package/package.json +6 -5
- package/dist/drivers/postgres/index.cjs +0 -5
- package/dist/drivers/postgres/index.d.ts +0 -2
- package/dist/drivers/postgres/index.mjs +0 -5
- package/dist/migration-CQsAizIw.js.map +0 -1
- package/dist/migration-CWBCpwFH.cjs.map +0 -1
- package/dist/postgres-driver-F9-TIi38.cjs.map +0 -1
- package/dist/postgres-driver-eWlY7pVg.js.map +0 -1
- package/dist/storage.constants-BDS_q-_N.js.map +0 -1
- package/dist/storage.constants-CIkf7BAJ.cjs.map +0 -1
- /package/dist/drivers/{postgres → postgresql}/index.cjs.map +0 -0
- /package/dist/drivers/{postgres → postgresql}/index.mjs.map +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/drivers/pglite/migrations.ts","../../../src/drivers/pglite/pglite-driver.ts"],"sourcesContent":["import type { FlavourMigration } from '../shared/migration';\n// --- Compatible with Postgres: reused verbatim ---\n// PGLite is Postgres compiled to WASM, so every version below emits byte-for-byte the DDL the\n// Postgres flavour emits. Rather than keep a second copy in sync by hand, the statement builders\n// are imported from the Postgres flavour and referenced here.\nimport { v1 as postgresV1 } from '../postgres/migrations';\n\n/**\n * Predefined PGLite DDL, version by version. Authored by hand for this engine; not generated at\n * runtime.\n *\n * `PGLITE_MIGRATIONS` is PGLite's own array — the runner only ever reads this one — but each entry\n * points at the Postgres statement builder because the two dialects are identical, keys, partial\n * indexes and `CREATE SCHEMA IF NOT EXISTS` included. There is a single version so far; a future\n * change appends `{ version: 2, ... }` rather than editing v1, which is a frozen record of what has\n * already been applied.\n *\n * --- Custom to PGLite ---\n * Nothing yet. When a version needs to diverge (e.g. dropping a clause the WASM build rejects),\n * author a local `v<n>(names: MigrationNames): string[]` here (`MigrationNames` comes from\n * `../shared/migration`) and swap it into the array for that version only; every other version\n * keeps reusing Postgres. Spell its column names as raw string literals, never the `*Column` enums\n * — renaming an enum member must never retroactively rewrite a past migration's DDL.\n */\n\nexport const PGLITE_MIGRATIONS: FlavourMigration[] = [{ version: 1, statements: postgresV1 }];\n","import { DatabaseEngine } from '../../options/enums';\nimport { capabilities, DriverCapability, type DriverCapabilitySet } from '../driver-capabilities';\nimport {\n DriverConnectionError,\n MissingPeerDependencyError,\n UnsupportedCapabilityError,\n} from '../../errors/errors';\nimport { toMigrationSteps } from '../shared/migration';\nimport { PGLITE_MIGRATIONS } from './migrations';\nimport type { Driver, DriverProbe, MigrationStep, Subscription } from '../driver.interface';\n// --- Compatible with Postgres: the whole SQL surface is inherited ---\n// PGLite is Postgres compiled to WASM and speaks the same wire protocol and dialect, so every\n// query method (jobs, queues, schedules, instances, claiming, retention, paging, the tx handle)\n// comes from `PostgresDriver` unchanged. `RawResult`/`Session` are its own connection-level types,\n// imported so the overrides below stay signature-compatible.\nimport { PostgresDriver, type RawResult, type Session } from '../postgres/postgres-driver';\n\n/**\n * Options for {@link PgliteDriver} — entirely custom to PGLite: there is no host, port, user or\n * pool, only an optional on-disk directory. `schema`/`tablePrefix`/`namespace` mean exactly what\n * they mean for Postgres and are forwarded to the base driver's `DriverContext`.\n */\nexport interface PGliteDriverOptions {\n /** Data directory for a file-backed DB; omit for in-memory. */\n dataDir?: string;\n /** DB schema for all objects. Created by the migration and used to qualify every table name. */\n schema?: string;\n /** Prefix for all created tables (default 'pq_'). */\n tablePrefix?: string;\n /** Logical prefix for pub/sub channels when multiple PortQueues share one DB. */\n namespace?: string;\n}\n\n// --- Custom to PGLite: the client shape ---\n// The `@electric-sql/pglite` client is nothing like `pg` — one in-process instance instead of a\n// pool, a callback-style `transaction()` instead of BEGIN/COMMIT on a checked-out connection, and\n// `affectedRows` instead of `rowCount`.\nexport interface PGliteQueryable {\n query(\n sql: string,\n params?: readonly unknown[],\n ): Promise<{ rows: Array<Record<string, unknown>>; affectedRows?: number }>;\n}\nexport interface PGliteInstance extends PGliteQueryable {\n transaction<T>(fn: (tx: PGliteQueryable) => Promise<T>): Promise<T>;\n close(): Promise<void>;\n}\n\n/**\n * PGLite driver — Postgres compiled to WASM, running in-process. Primarily for embedded/edge use\n * and tests.\n *\n * Because PGLite is byte-for-byte PG-wire compatible, this class **extends `PostgresDriver`** and\n * inherits its entire SQL surface: `$1`-style placeholders, SKIP LOCKED claiming, RETURNING\n * everywhere, the keys and indexes its migration creates, no relational JOIN (relationships resolve\n * by name/key lookups), and the in-code enforcement of idempotency/singleton dedup. A change to a\n * query in `PostgresDriver` therefore changes PGLite too; anything that must differ is overridden\n * here.\n *\n * What is custom to PGLite and overridden below:\n * - `engine`/`capabilities`/`migrations` — its own identity, capability set and migration array.\n * - `connect`/`disconnect` — boots one in-process WASM instance from `@electric-sql/pglite`\n * (an optional peer) instead of opening a `pg.Pool`.\n * - `execute`/`transaction` — talks to that instance and uses its callback-style `transaction()`.\n * - `probe` — no `SHOW server_version` round-trip; the version is the fixed string `'pglite'`.\n * - `notify`/`subscribe` — LISTEN/NOTIFY is off: PGLite is in-process with no shared bus, so the\n * interval poller is the backstop.\n * - `tryAdvisoryLock`/`releaseAdvisoryLock` — inert, since a single in-process DB has nothing to\n * coordinate with.\n */\nexport class PgliteDriver extends PostgresDriver implements Driver {\n override readonly engine: DatabaseEngine = DatabaseEngine.PGLITE;\n /** Same as Postgres minus LISTEN/NOTIFY and advisory locks — neither is meaningful in-process. */\n override readonly capabilities: DriverCapabilitySet = capabilities({\n [DriverCapability.SKIP_LOCKED]: true,\n [DriverCapability.RETURNING]: true,\n [DriverCapability.TRANSACTIONS]: true,\n });\n override readonly migrations: MigrationStep[] = toMigrationSteps(PGLITE_MIGRATIONS);\n\n private db: PGliteInstance | null = null;\n private readonly dataDir: string | undefined;\n\n constructor(options: PGliteDriverOptions = {}) {\n // Forward only the naming options; PGLite has no connection string, pool or pg config.\n super({\n ...(options.tablePrefix !== undefined ? { tablePrefix: options.tablePrefix } : {}),\n ...(options.schema !== undefined ? { schema: options.schema } : {}),\n ...(options.namespace !== undefined ? { namespace: options.namespace } : {}),\n });\n this.dataDir = options.dataDir;\n }\n\n // --- Connection management (custom to PGLite) ---\n override async connect(): Promise<void> {\n let mod: { PGlite: new (dataDir?: string) => PGliteInstance };\n try {\n mod = (await import('@electric-sql/pglite')) as unknown as {\n PGlite: new (dataDir?: string) => PGliteInstance;\n };\n } catch {\n throw new MissingPeerDependencyError('@electric-sql/pglite', 'PGLite');\n }\n try {\n this.db = this.dataDir ? new mod.PGlite(this.dataDir) : new mod.PGlite();\n // Force the WASM instance to finish booting with a trivial query.\n await this.db.query('SELECT 1');\n } catch (err) {\n throw new DriverConnectionError('Failed to initialize PGLite.', err);\n }\n }\n\n override async disconnect(): Promise<void> {\n await this.db?.close();\n this.db = null;\n }\n\n protected override async execute(\n sql: string,\n params: readonly unknown[],\n session?: Session,\n ): Promise<RawResult> {\n const target = (session as PGliteQueryable | undefined) ?? this.db;\n if (!target) throw new DriverConnectionError('PGLite driver is not connected.');\n const res = await target.query(sql, params);\n // PGLite reports mutations as `affectedRows`, not `rowCount`.\n return { rows: res.rows ?? [], rowCount: res.affectedRows ?? res.rows?.length ?? 0 };\n }\n\n protected override async transaction<T>(fn: (session: Session) => Promise<T>): Promise<T> {\n if (!this.db) throw new DriverConnectionError('PGLite driver is not connected.');\n // The client owns BEGIN/COMMIT/ROLLBACK — no connection to check out and release.\n return this.db.transaction((tx) => fn(tx));\n }\n\n // --- Probe (custom to PGLite: no server to ask for a version) ---\n override async probe(): Promise<DriverProbe> {\n return { serverVersion: 'pglite', verifiedCapabilities: this.enabledCapabilities() };\n }\n\n // --- Pub/sub (custom to PGLite: LISTEN/NOTIFY disabled — an interval poll is the backstop) ---\n // No-op: PGLite runs in-process without a shared LISTEN/NOTIFY bus; the poller drives progress.\n override async notify(_options: { channel: string; payload: string }): Promise<void> {}\n\n override async subscribe(_options: {\n channel: string;\n onNotification: (payload: string) => void;\n }): Promise<Subscription> {\n throw new UnsupportedCapabilityError(\n DriverCapability.LISTEN_NOTIFY,\n 'PGLite has no shared notification bus; rely on interval polling instead.',\n );\n }\n\n // --- Advisory locks (custom to PGLite: inert) ---\n // A single in-process DB has no second process to coordinate with, so the migration runner takes\n // no lock — it skips these entirely because ADVISORY_LOCK is off in `capabilities`. They stay\n // declared, and inert, so Postgres' pool-backed implementations can never be inherited.\n override async tryAdvisoryLock(_options: { key: string }): Promise<boolean> {\n return false;\n }\n\n override async releaseAdvisoryLock(_options: { key: string }): Promise<void> {}\n}\n"],"names":["postgresV1","PostgresDriver","DatabaseEngine","capabilities","DriverCapability","toMigrationSteps","MissingPeerDependencyError","DriverConnectionError","UnsupportedCapabilityError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,oBAAwC,CAAC,EAAE,SAAS,GAAG,YAAYA,eAAAA,IAAY;AC6CrF,MAAM,qBAAqBC,eAAAA,eAAiC;AAAA,EAC/C,SAAyBC,kBAAAA,eAAe;AAAA;AAAA,EAExC,eAAoCC,kBAAAA,aAAa;AAAA,IACjE,CAACC,kBAAAA,iBAAiB,WAAW,GAAG;AAAA,IAChC,CAACA,kBAAAA,iBAAiB,SAAS,GAAG;AAAA,IAC9B,CAACA,kBAAAA,iBAAiB,YAAY,GAAG;AAAA,EAAA,CAClC;AAAA,EACiB,aAA8BC,UAAAA,iBAAiB,iBAAiB;AAAA,EAE1E,KAA4B;AAAA,EACnB;AAAA,EAEjB,YAAY,UAA+B,IAAI;AAE7C,UAAM;AAAA,MACJ,GAAI,QAAQ,gBAAgB,SAAY,EAAE,aAAa,QAAQ,YAAA,IAAgB,CAAA;AAAA,MAC/E,GAAI,QAAQ,WAAW,SAAY,EAAE,QAAQ,QAAQ,OAAA,IAAW,CAAA;AAAA,MAChE,GAAI,QAAQ,cAAc,SAAY,EAAE,WAAW,QAAQ,cAAc,CAAA;AAAA,IAAC,CAC3E;AACD,SAAK,UAAU,QAAQ;AAAA,EACzB;AAAA;AAAA,EAGA,MAAe,UAAyB;AACtC,QAAI;AACJ,QAAI;AACF,YAAO,MAAM,OAAO,sBAAsB;AAAA,IAG5C,QAAQ;AACN,YAAM,IAAIC,UAAAA,2BAA2B,wBAAwB,QAAQ;AAAA,IACvE;AACA,QAAI;AACF,WAAK,KAAK,KAAK,UAAU,IAAI,IAAI,OAAO,KAAK,OAAO,IAAI,IAAI,IAAI,OAAA;AAEhE,YAAM,KAAK,GAAG,MAAM,UAAU;AAAA,IAChC,SAAS,KAAK;AACZ,YAAM,IAAIC,UAAAA,sBAAsB,gCAAgC,GAAG;AAAA,IACrE;AAAA,EACF;AAAA,EAEA,MAAe,aAA4B;AACzC,UAAM,KAAK,IAAI,MAAA;AACf,SAAK,KAAK;AAAA,EACZ;AAAA,EAEA,MAAyB,QACvB,KACA,QACA,SACoB;AACpB,UAAM,SAAU,WAA2C,KAAK;AAChE,QAAI,CAAC,OAAQ,OAAM,IAAIA,UAAAA,sBAAsB,iCAAiC;AAC9E,UAAM,MAAM,MAAM,OAAO,MAAM,KAAK,MAAM;AAE1C,WAAO,EAAE,MAAM,IAAI,QAAQ,CAAA,GAAI,UAAU,IAAI,gBAAgB,IAAI,MAAM,UAAU,EAAA;AAAA,EACnF;AAAA,EAEA,MAAyB,YAAe,IAAkD;AACxF,QAAI,CAAC,KAAK,GAAI,OAAM,IAAIA,UAAAA,sBAAsB,iCAAiC;AAE/E,WAAO,KAAK,GAAG,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;AAAA,EAC3C;AAAA;AAAA,EAGA,MAAe,QAA8B;AAC3C,WAAO,EAAE,eAAe,UAAU,sBAAsB,KAAK,sBAAoB;AAAA,EACnF;AAAA;AAAA;AAAA,EAIA,MAAe,OAAO,UAA+D;AAAA,EAAC;AAAA,EAEtF,MAAe,UAAU,UAGC;AACxB,UAAM,IAAIC,UAAAA;AAAAA,MACRJ,kBAAAA,iBAAiB;AAAA,MACjB;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAe,gBAAgB,UAA6C;AAC1E,WAAO;AAAA,EACT;AAAA,EAEA,MAAe,oBAAoB,UAA0C;AAAA,EAAC;AAChF;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/drivers/pglite/migrations.ts","../../../src/drivers/pglite/pglite-driver.ts"],"sourcesContent":["import type { FlavourMigration } from '../shared/migration';\n// --- Compatible with PostgreSQL: reused verbatim ---\n// PGLite is PostgreSQL compiled to WASM, so every version below emits byte-for-byte the DDL the\n// PostgreSQL flavour emits. Rather than keep a second copy in sync by hand, the statement builders\n// are imported from the PostgreSQL flavour and referenced here.\nimport { v1 as postgresqlV1 } from '../postgresql/migrations';\n\n/**\n * Predefined PGLite DDL, version by version. Authored by hand for this engine; not generated at\n * runtime.\n *\n * `PGLITE_MIGRATIONS` is PGLite's own array — the runner only ever reads this one — but each entry\n * points at the PostgreSQL statement builder because the two dialects are identical, keys, partial\n * indexes and `CREATE SCHEMA IF NOT EXISTS` included. There is a single version so far; a future\n * change appends `{ version: 2, ... }` rather than editing v1, which is a frozen record of what has\n * already been applied.\n *\n * --- Custom to PGLite ---\n * Nothing yet. When a version needs to diverge (e.g. dropping a clause the WASM build rejects),\n * author a local `v<n>(names: MigrationNames): string[]` here (`MigrationNames` comes from\n * `../shared/migration`) and swap it into the array for that version only; every other version\n * keeps reusing PostgreSQL. Spell its column names as raw string literals, never the `*Column` enums\n * — renaming an enum member must never retroactively rewrite a past migration's DDL.\n */\n\nexport const PGLITE_MIGRATIONS: FlavourMigration[] = [{ version: 1, statements: postgresqlV1 }];\n","import { DatabaseEngine } from '../../options/enums';\nimport { capabilities, DriverCapability, type DriverCapabilitySet } from '../driver-capabilities';\nimport {\n DriverConnectionError,\n MissingPeerDependencyError,\n UnsupportedCapabilityError,\n} from '../../errors/errors';\nimport { toMigrationSteps } from '../shared/migration';\nimport { PGLITE_MIGRATIONS } from './migrations';\nimport type { Driver, DriverProbe, MigrationStep, Subscription } from '../driver.interface';\n// --- Compatible with PostgreSQL: the whole SQL surface is inherited ---\n// PGLite is PostgreSQL compiled to WASM and speaks the same wire protocol and dialect, so every\n// query method (jobs, queues, schedules, instances, claiming, retention, paging, the tx handle)\n// comes from `PostgresqlDriver` unchanged. `RawResult`/`Session` are its own connection-level types,\n// imported so the overrides below stay signature-compatible.\nimport { PostgresqlDriver, type RawResult, type Session } from '../postgresql/postgresql-driver';\n\n/**\n * Options for {@link PgliteDriver} — entirely custom to PGLite: there is no host, port, user or\n * pool, only an optional on-disk directory. `schema`/`tablePrefix`/`namespace` mean exactly what\n * they mean for PostgreSQL and are forwarded to the base driver's `DriverContext`.\n */\nexport interface PGliteDriverOptions {\n /** Data directory for a file-backed DB; omit for in-memory. */\n dataDir?: string;\n /** DB schema for all objects. Created by the migration and used to qualify every table name. */\n schema?: string;\n /** Prefix for all created tables (default 'pq_'). */\n tablePrefix?: string;\n /** Logical prefix for pub/sub channels when multiple PortQueues share one DB. */\n namespace?: string;\n}\n\n// --- Custom to PGLite: the client shape ---\n// The `@electric-sql/pglite` client is nothing like `pg` — one in-process instance instead of a\n// pool, a callback-style `transaction()` instead of BEGIN/COMMIT on a checked-out connection, and\n// `affectedRows` instead of `rowCount`.\nexport interface PGliteQueryable {\n query(\n sql: string,\n params?: readonly unknown[],\n ): Promise<{ rows: Array<Record<string, unknown>>; affectedRows?: number }>;\n}\nexport interface PGliteInstance extends PGliteQueryable {\n transaction<T>(fn: (tx: PGliteQueryable) => Promise<T>): Promise<T>;\n close(): Promise<void>;\n}\n\n/**\n * PGLite driver — PostgreSQL compiled to WASM, running in-process. Primarily for embedded/edge use\n * and tests.\n *\n * Because PGLite is byte-for-byte PG-wire compatible, this class **extends `PostgresqlDriver`** and\n * inherits its entire SQL surface: `$1`-style placeholders, SKIP LOCKED claiming, RETURNING\n * everywhere, the keys and indexes its migration creates, no relational JOIN (relationships resolve\n * by name/key lookups), and the in-code enforcement of idempotency/singleton dedup. A change to a\n * query in `PostgresqlDriver` therefore changes PGLite too; anything that must differ is overridden\n * here.\n *\n * What is custom to PGLite and overridden below:\n * - `engine`/`capabilities`/`migrations` — its own identity, capability set and migration array.\n * - `connect`/`disconnect` — boots one in-process WASM instance from `@electric-sql/pglite`\n * (an optional peer) instead of opening a `pg.Pool`.\n * - `execute`/`transaction` — talks to that instance and uses its callback-style `transaction()`.\n * - `probe` — no `SHOW server_version` round-trip; the version is the fixed string `'pglite'`.\n * - `notify`/`subscribe` — LISTEN/NOTIFY is off: PGLite is in-process with no shared bus, so the\n * interval poller is the backstop.\n * - `tryAdvisoryLock`/`releaseAdvisoryLock` — inert, since a single in-process DB has nothing to\n * coordinate with.\n */\nexport class PgliteDriver extends PostgresqlDriver implements Driver {\n override readonly engine: DatabaseEngine = DatabaseEngine.PGLITE;\n /** Same as PostgreSQL minus LISTEN/NOTIFY and advisory locks — neither is meaningful in-process. */\n override readonly capabilities: DriverCapabilitySet = capabilities({\n [DriverCapability.SKIP_LOCKED]: true,\n [DriverCapability.RETURNING]: true,\n [DriverCapability.TRANSACTIONS]: true,\n });\n override readonly migrations: MigrationStep[] = toMigrationSteps(PGLITE_MIGRATIONS);\n\n private db: PGliteInstance | null = null;\n private readonly dataDir: string | undefined;\n\n constructor(options: PGliteDriverOptions = {}) {\n // Forward only the naming options; PGLite has no connection string, pool or pg config.\n super({\n ...(options.tablePrefix !== undefined ? { tablePrefix: options.tablePrefix } : {}),\n ...(options.schema !== undefined ? { schema: options.schema } : {}),\n ...(options.namespace !== undefined ? { namespace: options.namespace } : {}),\n });\n this.dataDir = options.dataDir;\n }\n\n // --- Connection management (custom to PGLite) ---\n override async connect(): Promise<void> {\n let mod: { PGlite: new (dataDir?: string) => PGliteInstance };\n try {\n mod = (await import('@electric-sql/pglite')) as unknown as {\n PGlite: new (dataDir?: string) => PGliteInstance;\n };\n } catch {\n throw new MissingPeerDependencyError('@electric-sql/pglite', 'PGLite');\n }\n try {\n this.db = this.dataDir ? new mod.PGlite(this.dataDir) : new mod.PGlite();\n // Force the WASM instance to finish booting with a trivial query.\n await this.db.query('SELECT 1');\n } catch (err) {\n throw new DriverConnectionError('Failed to initialize PGLite.', err);\n }\n }\n\n override async disconnect(): Promise<void> {\n await this.db?.close();\n this.db = null;\n }\n\n protected override async execute(\n sql: string,\n params: readonly unknown[],\n session?: Session,\n ): Promise<RawResult> {\n const target = (session as PGliteQueryable | undefined) ?? this.db;\n if (!target) throw new DriverConnectionError('PGLite driver is not connected.');\n const res = await target.query(sql, params);\n // PGLite reports mutations as `affectedRows`, not `rowCount`.\n return { rows: res.rows ?? [], rowCount: res.affectedRows ?? res.rows?.length ?? 0 };\n }\n\n protected override async transaction<T>(fn: (session: Session) => Promise<T>): Promise<T> {\n if (!this.db) throw new DriverConnectionError('PGLite driver is not connected.');\n // The client owns BEGIN/COMMIT/ROLLBACK — no connection to check out and release.\n return this.db.transaction((tx) => fn(tx));\n }\n\n // --- Probe (custom to PGLite: no server to ask for a version) ---\n override async probe(): Promise<DriverProbe> {\n return { serverVersion: 'pglite', verifiedCapabilities: this.enabledCapabilities() };\n }\n\n // --- Pub/sub (custom to PGLite: LISTEN/NOTIFY disabled — an interval poll is the backstop) ---\n // No-op: PGLite runs in-process without a shared LISTEN/NOTIFY bus; the poller drives progress.\n override async notify(_options: { channel: string; payload: string }): Promise<void> {}\n\n override async subscribe(_options: {\n channel: string;\n onNotification: (payload: string) => void;\n }): Promise<Subscription> {\n throw new UnsupportedCapabilityError(\n DriverCapability.LISTEN_NOTIFY,\n 'PGLite has no shared notification bus; rely on interval polling instead.',\n );\n }\n\n // --- Advisory locks (custom to PGLite: inert) ---\n // A single in-process DB has no second process to coordinate with, so the migration runner takes\n // no lock — it skips these entirely because ADVISORY_LOCK is off in `capabilities`. They stay\n // declared, and inert, so PostgreSQL' pool-backed implementations can never be inherited.\n override async tryAdvisoryLock(_options: { key: string }): Promise<boolean> {\n return false;\n }\n\n override async releaseAdvisoryLock(_options: { key: string }): Promise<void> {}\n}\n"],"names":["postgresqlV1","PostgresqlDriver","DatabaseEngine","capabilities","DriverCapability","toMigrationSteps","MissingPeerDependencyError","DriverConnectionError","UnsupportedCapabilityError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,oBAAwC,CAAC,EAAE,SAAS,GAAG,YAAYA,iBAAAA,IAAc;AC6CvF,MAAM,qBAAqBC,iBAAAA,iBAAmC;AAAA,EACjD,SAAyBC,kBAAAA,eAAe;AAAA;AAAA,EAExC,eAAoCC,kBAAAA,aAAa;AAAA,IACjE,CAACC,kBAAAA,iBAAiB,WAAW,GAAG;AAAA,IAChC,CAACA,kBAAAA,iBAAiB,SAAS,GAAG;AAAA,IAC9B,CAACA,kBAAAA,iBAAiB,YAAY,GAAG;AAAA,EAAA,CAClC;AAAA,EACiB,aAA8BC,UAAAA,iBAAiB,iBAAiB;AAAA,EAE1E,KAA4B;AAAA,EACnB;AAAA,EAEjB,YAAY,UAA+B,IAAI;AAE7C,UAAM;AAAA,MACJ,GAAI,QAAQ,gBAAgB,SAAY,EAAE,aAAa,QAAQ,YAAA,IAAgB,CAAA;AAAA,MAC/E,GAAI,QAAQ,WAAW,SAAY,EAAE,QAAQ,QAAQ,OAAA,IAAW,CAAA;AAAA,MAChE,GAAI,QAAQ,cAAc,SAAY,EAAE,WAAW,QAAQ,cAAc,CAAA;AAAA,IAAC,CAC3E;AACD,SAAK,UAAU,QAAQ;AAAA,EACzB;AAAA;AAAA,EAGA,MAAe,UAAyB;AACtC,QAAI;AACJ,QAAI;AACF,YAAO,MAAM,OAAO,sBAAsB;AAAA,IAG5C,QAAQ;AACN,YAAM,IAAIC,UAAAA,2BAA2B,wBAAwB,QAAQ;AAAA,IACvE;AACA,QAAI;AACF,WAAK,KAAK,KAAK,UAAU,IAAI,IAAI,OAAO,KAAK,OAAO,IAAI,IAAI,IAAI,OAAA;AAEhE,YAAM,KAAK,GAAG,MAAM,UAAU;AAAA,IAChC,SAAS,KAAK;AACZ,YAAM,IAAIC,UAAAA,sBAAsB,gCAAgC,GAAG;AAAA,IACrE;AAAA,EACF;AAAA,EAEA,MAAe,aAA4B;AACzC,UAAM,KAAK,IAAI,MAAA;AACf,SAAK,KAAK;AAAA,EACZ;AAAA,EAEA,MAAyB,QACvB,KACA,QACA,SACoB;AACpB,UAAM,SAAU,WAA2C,KAAK;AAChE,QAAI,CAAC,OAAQ,OAAM,IAAIA,UAAAA,sBAAsB,iCAAiC;AAC9E,UAAM,MAAM,MAAM,OAAO,MAAM,KAAK,MAAM;AAE1C,WAAO,EAAE,MAAM,IAAI,QAAQ,CAAA,GAAI,UAAU,IAAI,gBAAgB,IAAI,MAAM,UAAU,EAAA;AAAA,EACnF;AAAA,EAEA,MAAyB,YAAe,IAAkD;AACxF,QAAI,CAAC,KAAK,GAAI,OAAM,IAAIA,UAAAA,sBAAsB,iCAAiC;AAE/E,WAAO,KAAK,GAAG,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;AAAA,EAC3C;AAAA;AAAA,EAGA,MAAe,QAA8B;AAC3C,WAAO,EAAE,eAAe,UAAU,sBAAsB,KAAK,sBAAoB;AAAA,EACnF;AAAA;AAAA;AAAA,EAIA,MAAe,OAAO,UAA+D;AAAA,EAAC;AAAA,EAEtF,MAAe,UAAU,UAGC;AACxB,UAAM,IAAIC,UAAAA;AAAAA,MACRJ,kBAAAA,iBAAiB;AAAA,MACjB;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAe,gBAAgB,UAA6C;AAC1E,WAAO;AAAA,EACT;AAAA,EAEA,MAAe,oBAAoB,UAA0C;AAAA,EAAC;AAChF;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as DatabaseEngine, c as capabilities, D as DriverCapability } from "../../storage.constants-
|
|
2
|
-
import { t as toMigrationSteps, M as MissingPeerDependencyError, D as DriverConnectionError, U as UnsupportedCapabilityError } from "../../migration-
|
|
3
|
-
import { v as v1, P as
|
|
1
|
+
import { a as DatabaseEngine, c as capabilities, D as DriverCapability } from "../../storage.constants-DwSzjjMZ.js";
|
|
2
|
+
import { t as toMigrationSteps, M as MissingPeerDependencyError, D as DriverConnectionError, U as UnsupportedCapabilityError } from "../../migration-D73ANkYV.js";
|
|
3
|
+
import { v as v1, P as PostgresqlDriver } from "../../postgresql-driver-BUHuyRYj.js";
|
|
4
4
|
const PGLITE_MIGRATIONS = [{ version: 1, statements: v1 }];
|
|
5
|
-
class PgliteDriver extends
|
|
5
|
+
class PgliteDriver extends PostgresqlDriver {
|
|
6
6
|
engine = DatabaseEngine.PGLITE;
|
|
7
|
-
/** Same as
|
|
7
|
+
/** Same as PostgreSQL minus LISTEN/NOTIFY and advisory locks — neither is meaningful in-process. */
|
|
8
8
|
capabilities = capabilities({
|
|
9
9
|
[DriverCapability.SKIP_LOCKED]: true,
|
|
10
10
|
[DriverCapability.RETURNING]: true,
|
|
@@ -67,7 +67,7 @@ class PgliteDriver extends PostgresDriver {
|
|
|
67
67
|
// --- Advisory locks (custom to PGLite: inert) ---
|
|
68
68
|
// A single in-process DB has no second process to coordinate with, so the migration runner takes
|
|
69
69
|
// no lock — it skips these entirely because ADVISORY_LOCK is off in `capabilities`. They stay
|
|
70
|
-
// declared, and inert, so
|
|
70
|
+
// declared, and inert, so PostgreSQL' pool-backed implementations can never be inherited.
|
|
71
71
|
async tryAdvisoryLock(_options) {
|
|
72
72
|
return false;
|
|
73
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/drivers/pglite/migrations.ts","../../../src/drivers/pglite/pglite-driver.ts"],"sourcesContent":["import type { FlavourMigration } from '../shared/migration';\n// --- Compatible with Postgres: reused verbatim ---\n// PGLite is Postgres compiled to WASM, so every version below emits byte-for-byte the DDL the\n// Postgres flavour emits. Rather than keep a second copy in sync by hand, the statement builders\n// are imported from the Postgres flavour and referenced here.\nimport { v1 as postgresV1 } from '../postgres/migrations';\n\n/**\n * Predefined PGLite DDL, version by version. Authored by hand for this engine; not generated at\n * runtime.\n *\n * `PGLITE_MIGRATIONS` is PGLite's own array — the runner only ever reads this one — but each entry\n * points at the Postgres statement builder because the two dialects are identical, keys, partial\n * indexes and `CREATE SCHEMA IF NOT EXISTS` included. There is a single version so far; a future\n * change appends `{ version: 2, ... }` rather than editing v1, which is a frozen record of what has\n * already been applied.\n *\n * --- Custom to PGLite ---\n * Nothing yet. When a version needs to diverge (e.g. dropping a clause the WASM build rejects),\n * author a local `v<n>(names: MigrationNames): string[]` here (`MigrationNames` comes from\n * `../shared/migration`) and swap it into the array for that version only; every other version\n * keeps reusing Postgres. Spell its column names as raw string literals, never the `*Column` enums\n * — renaming an enum member must never retroactively rewrite a past migration's DDL.\n */\n\nexport const PGLITE_MIGRATIONS: FlavourMigration[] = [{ version: 1, statements: postgresV1 }];\n","import { DatabaseEngine } from '../../options/enums';\nimport { capabilities, DriverCapability, type DriverCapabilitySet } from '../driver-capabilities';\nimport {\n DriverConnectionError,\n MissingPeerDependencyError,\n UnsupportedCapabilityError,\n} from '../../errors/errors';\nimport { toMigrationSteps } from '../shared/migration';\nimport { PGLITE_MIGRATIONS } from './migrations';\nimport type { Driver, DriverProbe, MigrationStep, Subscription } from '../driver.interface';\n// --- Compatible with Postgres: the whole SQL surface is inherited ---\n// PGLite is Postgres compiled to WASM and speaks the same wire protocol and dialect, so every\n// query method (jobs, queues, schedules, instances, claiming, retention, paging, the tx handle)\n// comes from `PostgresDriver` unchanged. `RawResult`/`Session` are its own connection-level types,\n// imported so the overrides below stay signature-compatible.\nimport { PostgresDriver, type RawResult, type Session } from '../postgres/postgres-driver';\n\n/**\n * Options for {@link PgliteDriver} — entirely custom to PGLite: there is no host, port, user or\n * pool, only an optional on-disk directory. `schema`/`tablePrefix`/`namespace` mean exactly what\n * they mean for Postgres and are forwarded to the base driver's `DriverContext`.\n */\nexport interface PGliteDriverOptions {\n /** Data directory for a file-backed DB; omit for in-memory. */\n dataDir?: string;\n /** DB schema for all objects. Created by the migration and used to qualify every table name. */\n schema?: string;\n /** Prefix for all created tables (default 'pq_'). */\n tablePrefix?: string;\n /** Logical prefix for pub/sub channels when multiple PortQueues share one DB. */\n namespace?: string;\n}\n\n// --- Custom to PGLite: the client shape ---\n// The `@electric-sql/pglite` client is nothing like `pg` — one in-process instance instead of a\n// pool, a callback-style `transaction()` instead of BEGIN/COMMIT on a checked-out connection, and\n// `affectedRows` instead of `rowCount`.\nexport interface PGliteQueryable {\n query(\n sql: string,\n params?: readonly unknown[],\n ): Promise<{ rows: Array<Record<string, unknown>>; affectedRows?: number }>;\n}\nexport interface PGliteInstance extends PGliteQueryable {\n transaction<T>(fn: (tx: PGliteQueryable) => Promise<T>): Promise<T>;\n close(): Promise<void>;\n}\n\n/**\n * PGLite driver — Postgres compiled to WASM, running in-process. Primarily for embedded/edge use\n * and tests.\n *\n * Because PGLite is byte-for-byte PG-wire compatible, this class **extends `PostgresDriver`** and\n * inherits its entire SQL surface: `$1`-style placeholders, SKIP LOCKED claiming, RETURNING\n * everywhere, the keys and indexes its migration creates, no relational JOIN (relationships resolve\n * by name/key lookups), and the in-code enforcement of idempotency/singleton dedup. A change to a\n * query in `PostgresDriver` therefore changes PGLite too; anything that must differ is overridden\n * here.\n *\n * What is custom to PGLite and overridden below:\n * - `engine`/`capabilities`/`migrations` — its own identity, capability set and migration array.\n * - `connect`/`disconnect` — boots one in-process WASM instance from `@electric-sql/pglite`\n * (an optional peer) instead of opening a `pg.Pool`.\n * - `execute`/`transaction` — talks to that instance and uses its callback-style `transaction()`.\n * - `probe` — no `SHOW server_version` round-trip; the version is the fixed string `'pglite'`.\n * - `notify`/`subscribe` — LISTEN/NOTIFY is off: PGLite is in-process with no shared bus, so the\n * interval poller is the backstop.\n * - `tryAdvisoryLock`/`releaseAdvisoryLock` — inert, since a single in-process DB has nothing to\n * coordinate with.\n */\nexport class PgliteDriver extends PostgresDriver implements Driver {\n override readonly engine: DatabaseEngine = DatabaseEngine.PGLITE;\n /** Same as Postgres minus LISTEN/NOTIFY and advisory locks — neither is meaningful in-process. */\n override readonly capabilities: DriverCapabilitySet = capabilities({\n [DriverCapability.SKIP_LOCKED]: true,\n [DriverCapability.RETURNING]: true,\n [DriverCapability.TRANSACTIONS]: true,\n });\n override readonly migrations: MigrationStep[] = toMigrationSteps(PGLITE_MIGRATIONS);\n\n private db: PGliteInstance | null = null;\n private readonly dataDir: string | undefined;\n\n constructor(options: PGliteDriverOptions = {}) {\n // Forward only the naming options; PGLite has no connection string, pool or pg config.\n super({\n ...(options.tablePrefix !== undefined ? { tablePrefix: options.tablePrefix } : {}),\n ...(options.schema !== undefined ? { schema: options.schema } : {}),\n ...(options.namespace !== undefined ? { namespace: options.namespace } : {}),\n });\n this.dataDir = options.dataDir;\n }\n\n // --- Connection management (custom to PGLite) ---\n override async connect(): Promise<void> {\n let mod: { PGlite: new (dataDir?: string) => PGliteInstance };\n try {\n mod = (await import('@electric-sql/pglite')) as unknown as {\n PGlite: new (dataDir?: string) => PGliteInstance;\n };\n } catch {\n throw new MissingPeerDependencyError('@electric-sql/pglite', 'PGLite');\n }\n try {\n this.db = this.dataDir ? new mod.PGlite(this.dataDir) : new mod.PGlite();\n // Force the WASM instance to finish booting with a trivial query.\n await this.db.query('SELECT 1');\n } catch (err) {\n throw new DriverConnectionError('Failed to initialize PGLite.', err);\n }\n }\n\n override async disconnect(): Promise<void> {\n await this.db?.close();\n this.db = null;\n }\n\n protected override async execute(\n sql: string,\n params: readonly unknown[],\n session?: Session,\n ): Promise<RawResult> {\n const target = (session as PGliteQueryable | undefined) ?? this.db;\n if (!target) throw new DriverConnectionError('PGLite driver is not connected.');\n const res = await target.query(sql, params);\n // PGLite reports mutations as `affectedRows`, not `rowCount`.\n return { rows: res.rows ?? [], rowCount: res.affectedRows ?? res.rows?.length ?? 0 };\n }\n\n protected override async transaction<T>(fn: (session: Session) => Promise<T>): Promise<T> {\n if (!this.db) throw new DriverConnectionError('PGLite driver is not connected.');\n // The client owns BEGIN/COMMIT/ROLLBACK — no connection to check out and release.\n return this.db.transaction((tx) => fn(tx));\n }\n\n // --- Probe (custom to PGLite: no server to ask for a version) ---\n override async probe(): Promise<DriverProbe> {\n return { serverVersion: 'pglite', verifiedCapabilities: this.enabledCapabilities() };\n }\n\n // --- Pub/sub (custom to PGLite: LISTEN/NOTIFY disabled — an interval poll is the backstop) ---\n // No-op: PGLite runs in-process without a shared LISTEN/NOTIFY bus; the poller drives progress.\n override async notify(_options: { channel: string; payload: string }): Promise<void> {}\n\n override async subscribe(_options: {\n channel: string;\n onNotification: (payload: string) => void;\n }): Promise<Subscription> {\n throw new UnsupportedCapabilityError(\n DriverCapability.LISTEN_NOTIFY,\n 'PGLite has no shared notification bus; rely on interval polling instead.',\n );\n }\n\n // --- Advisory locks (custom to PGLite: inert) ---\n // A single in-process DB has no second process to coordinate with, so the migration runner takes\n // no lock — it skips these entirely because ADVISORY_LOCK is off in `capabilities`. They stay\n // declared, and inert, so Postgres' pool-backed implementations can never be inherited.\n override async tryAdvisoryLock(_options: { key: string }): Promise<boolean> {\n return false;\n }\n\n override async releaseAdvisoryLock(_options: { key: string }): Promise<void> {}\n}\n"],"names":["postgresV1"],"mappings":";;;AAyBO,MAAM,oBAAwC,CAAC,EAAE,SAAS,GAAG,YAAYA,IAAY;AC6CrF,MAAM,qBAAqB,eAAiC;AAAA,EAC/C,SAAyB,eAAe;AAAA;AAAA,EAExC,eAAoC,aAAa;AAAA,IACjE,CAAC,iBAAiB,WAAW,GAAG;AAAA,IAChC,CAAC,iBAAiB,SAAS,GAAG;AAAA,IAC9B,CAAC,iBAAiB,YAAY,GAAG;AAAA,EAAA,CAClC;AAAA,EACiB,aAA8B,iBAAiB,iBAAiB;AAAA,EAE1E,KAA4B;AAAA,EACnB;AAAA,EAEjB,YAAY,UAA+B,IAAI;AAE7C,UAAM;AAAA,MACJ,GAAI,QAAQ,gBAAgB,SAAY,EAAE,aAAa,QAAQ,YAAA,IAAgB,CAAA;AAAA,MAC/E,GAAI,QAAQ,WAAW,SAAY,EAAE,QAAQ,QAAQ,OAAA,IAAW,CAAA;AAAA,MAChE,GAAI,QAAQ,cAAc,SAAY,EAAE,WAAW,QAAQ,cAAc,CAAA;AAAA,IAAC,CAC3E;AACD,SAAK,UAAU,QAAQ;AAAA,EACzB;AAAA;AAAA,EAGA,MAAe,UAAyB;AACtC,QAAI;AACJ,QAAI;AACF,YAAO,MAAM,OAAO,sBAAsB;AAAA,IAG5C,QAAQ;AACN,YAAM,IAAI,2BAA2B,wBAAwB,QAAQ;AAAA,IACvE;AACA,QAAI;AACF,WAAK,KAAK,KAAK,UAAU,IAAI,IAAI,OAAO,KAAK,OAAO,IAAI,IAAI,IAAI,OAAA;AAEhE,YAAM,KAAK,GAAG,MAAM,UAAU;AAAA,IAChC,SAAS,KAAK;AACZ,YAAM,IAAI,sBAAsB,gCAAgC,GAAG;AAAA,IACrE;AAAA,EACF;AAAA,EAEA,MAAe,aAA4B;AACzC,UAAM,KAAK,IAAI,MAAA;AACf,SAAK,KAAK;AAAA,EACZ;AAAA,EAEA,MAAyB,QACvB,KACA,QACA,SACoB;AACpB,UAAM,SAAU,WAA2C,KAAK;AAChE,QAAI,CAAC,OAAQ,OAAM,IAAI,sBAAsB,iCAAiC;AAC9E,UAAM,MAAM,MAAM,OAAO,MAAM,KAAK,MAAM;AAE1C,WAAO,EAAE,MAAM,IAAI,QAAQ,CAAA,GAAI,UAAU,IAAI,gBAAgB,IAAI,MAAM,UAAU,EAAA;AAAA,EACnF;AAAA,EAEA,MAAyB,YAAe,IAAkD;AACxF,QAAI,CAAC,KAAK,GAAI,OAAM,IAAI,sBAAsB,iCAAiC;AAE/E,WAAO,KAAK,GAAG,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;AAAA,EAC3C;AAAA;AAAA,EAGA,MAAe,QAA8B;AAC3C,WAAO,EAAE,eAAe,UAAU,sBAAsB,KAAK,sBAAoB;AAAA,EACnF;AAAA;AAAA;AAAA,EAIA,MAAe,OAAO,UAA+D;AAAA,EAAC;AAAA,EAEtF,MAAe,UAAU,UAGC;AACxB,UAAM,IAAI;AAAA,MACR,iBAAiB;AAAA,MACjB;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAe,gBAAgB,UAA6C;AAC1E,WAAO;AAAA,EACT;AAAA,EAEA,MAAe,oBAAoB,UAA0C;AAAA,EAAC;AAChF;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/drivers/pglite/migrations.ts","../../../src/drivers/pglite/pglite-driver.ts"],"sourcesContent":["import type { FlavourMigration } from '../shared/migration';\n// --- Compatible with PostgreSQL: reused verbatim ---\n// PGLite is PostgreSQL compiled to WASM, so every version below emits byte-for-byte the DDL the\n// PostgreSQL flavour emits. Rather than keep a second copy in sync by hand, the statement builders\n// are imported from the PostgreSQL flavour and referenced here.\nimport { v1 as postgresqlV1 } from '../postgresql/migrations';\n\n/**\n * Predefined PGLite DDL, version by version. Authored by hand for this engine; not generated at\n * runtime.\n *\n * `PGLITE_MIGRATIONS` is PGLite's own array — the runner only ever reads this one — but each entry\n * points at the PostgreSQL statement builder because the two dialects are identical, keys, partial\n * indexes and `CREATE SCHEMA IF NOT EXISTS` included. There is a single version so far; a future\n * change appends `{ version: 2, ... }` rather than editing v1, which is a frozen record of what has\n * already been applied.\n *\n * --- Custom to PGLite ---\n * Nothing yet. When a version needs to diverge (e.g. dropping a clause the WASM build rejects),\n * author a local `v<n>(names: MigrationNames): string[]` here (`MigrationNames` comes from\n * `../shared/migration`) and swap it into the array for that version only; every other version\n * keeps reusing PostgreSQL. Spell its column names as raw string literals, never the `*Column` enums\n * — renaming an enum member must never retroactively rewrite a past migration's DDL.\n */\n\nexport const PGLITE_MIGRATIONS: FlavourMigration[] = [{ version: 1, statements: postgresqlV1 }];\n","import { DatabaseEngine } from '../../options/enums';\nimport { capabilities, DriverCapability, type DriverCapabilitySet } from '../driver-capabilities';\nimport {\n DriverConnectionError,\n MissingPeerDependencyError,\n UnsupportedCapabilityError,\n} from '../../errors/errors';\nimport { toMigrationSteps } from '../shared/migration';\nimport { PGLITE_MIGRATIONS } from './migrations';\nimport type { Driver, DriverProbe, MigrationStep, Subscription } from '../driver.interface';\n// --- Compatible with PostgreSQL: the whole SQL surface is inherited ---\n// PGLite is PostgreSQL compiled to WASM and speaks the same wire protocol and dialect, so every\n// query method (jobs, queues, schedules, instances, claiming, retention, paging, the tx handle)\n// comes from `PostgresqlDriver` unchanged. `RawResult`/`Session` are its own connection-level types,\n// imported so the overrides below stay signature-compatible.\nimport { PostgresqlDriver, type RawResult, type Session } from '../postgresql/postgresql-driver';\n\n/**\n * Options for {@link PgliteDriver} — entirely custom to PGLite: there is no host, port, user or\n * pool, only an optional on-disk directory. `schema`/`tablePrefix`/`namespace` mean exactly what\n * they mean for PostgreSQL and are forwarded to the base driver's `DriverContext`.\n */\nexport interface PGliteDriverOptions {\n /** Data directory for a file-backed DB; omit for in-memory. */\n dataDir?: string;\n /** DB schema for all objects. Created by the migration and used to qualify every table name. */\n schema?: string;\n /** Prefix for all created tables (default 'pq_'). */\n tablePrefix?: string;\n /** Logical prefix for pub/sub channels when multiple PortQueues share one DB. */\n namespace?: string;\n}\n\n// --- Custom to PGLite: the client shape ---\n// The `@electric-sql/pglite` client is nothing like `pg` — one in-process instance instead of a\n// pool, a callback-style `transaction()` instead of BEGIN/COMMIT on a checked-out connection, and\n// `affectedRows` instead of `rowCount`.\nexport interface PGliteQueryable {\n query(\n sql: string,\n params?: readonly unknown[],\n ): Promise<{ rows: Array<Record<string, unknown>>; affectedRows?: number }>;\n}\nexport interface PGliteInstance extends PGliteQueryable {\n transaction<T>(fn: (tx: PGliteQueryable) => Promise<T>): Promise<T>;\n close(): Promise<void>;\n}\n\n/**\n * PGLite driver — PostgreSQL compiled to WASM, running in-process. Primarily for embedded/edge use\n * and tests.\n *\n * Because PGLite is byte-for-byte PG-wire compatible, this class **extends `PostgresqlDriver`** and\n * inherits its entire SQL surface: `$1`-style placeholders, SKIP LOCKED claiming, RETURNING\n * everywhere, the keys and indexes its migration creates, no relational JOIN (relationships resolve\n * by name/key lookups), and the in-code enforcement of idempotency/singleton dedup. A change to a\n * query in `PostgresqlDriver` therefore changes PGLite too; anything that must differ is overridden\n * here.\n *\n * What is custom to PGLite and overridden below:\n * - `engine`/`capabilities`/`migrations` — its own identity, capability set and migration array.\n * - `connect`/`disconnect` — boots one in-process WASM instance from `@electric-sql/pglite`\n * (an optional peer) instead of opening a `pg.Pool`.\n * - `execute`/`transaction` — talks to that instance and uses its callback-style `transaction()`.\n * - `probe` — no `SHOW server_version` round-trip; the version is the fixed string `'pglite'`.\n * - `notify`/`subscribe` — LISTEN/NOTIFY is off: PGLite is in-process with no shared bus, so the\n * interval poller is the backstop.\n * - `tryAdvisoryLock`/`releaseAdvisoryLock` — inert, since a single in-process DB has nothing to\n * coordinate with.\n */\nexport class PgliteDriver extends PostgresqlDriver implements Driver {\n override readonly engine: DatabaseEngine = DatabaseEngine.PGLITE;\n /** Same as PostgreSQL minus LISTEN/NOTIFY and advisory locks — neither is meaningful in-process. */\n override readonly capabilities: DriverCapabilitySet = capabilities({\n [DriverCapability.SKIP_LOCKED]: true,\n [DriverCapability.RETURNING]: true,\n [DriverCapability.TRANSACTIONS]: true,\n });\n override readonly migrations: MigrationStep[] = toMigrationSteps(PGLITE_MIGRATIONS);\n\n private db: PGliteInstance | null = null;\n private readonly dataDir: string | undefined;\n\n constructor(options: PGliteDriverOptions = {}) {\n // Forward only the naming options; PGLite has no connection string, pool or pg config.\n super({\n ...(options.tablePrefix !== undefined ? { tablePrefix: options.tablePrefix } : {}),\n ...(options.schema !== undefined ? { schema: options.schema } : {}),\n ...(options.namespace !== undefined ? { namespace: options.namespace } : {}),\n });\n this.dataDir = options.dataDir;\n }\n\n // --- Connection management (custom to PGLite) ---\n override async connect(): Promise<void> {\n let mod: { PGlite: new (dataDir?: string) => PGliteInstance };\n try {\n mod = (await import('@electric-sql/pglite')) as unknown as {\n PGlite: new (dataDir?: string) => PGliteInstance;\n };\n } catch {\n throw new MissingPeerDependencyError('@electric-sql/pglite', 'PGLite');\n }\n try {\n this.db = this.dataDir ? new mod.PGlite(this.dataDir) : new mod.PGlite();\n // Force the WASM instance to finish booting with a trivial query.\n await this.db.query('SELECT 1');\n } catch (err) {\n throw new DriverConnectionError('Failed to initialize PGLite.', err);\n }\n }\n\n override async disconnect(): Promise<void> {\n await this.db?.close();\n this.db = null;\n }\n\n protected override async execute(\n sql: string,\n params: readonly unknown[],\n session?: Session,\n ): Promise<RawResult> {\n const target = (session as PGliteQueryable | undefined) ?? this.db;\n if (!target) throw new DriverConnectionError('PGLite driver is not connected.');\n const res = await target.query(sql, params);\n // PGLite reports mutations as `affectedRows`, not `rowCount`.\n return { rows: res.rows ?? [], rowCount: res.affectedRows ?? res.rows?.length ?? 0 };\n }\n\n protected override async transaction<T>(fn: (session: Session) => Promise<T>): Promise<T> {\n if (!this.db) throw new DriverConnectionError('PGLite driver is not connected.');\n // The client owns BEGIN/COMMIT/ROLLBACK — no connection to check out and release.\n return this.db.transaction((tx) => fn(tx));\n }\n\n // --- Probe (custom to PGLite: no server to ask for a version) ---\n override async probe(): Promise<DriverProbe> {\n return { serverVersion: 'pglite', verifiedCapabilities: this.enabledCapabilities() };\n }\n\n // --- Pub/sub (custom to PGLite: LISTEN/NOTIFY disabled — an interval poll is the backstop) ---\n // No-op: PGLite runs in-process without a shared LISTEN/NOTIFY bus; the poller drives progress.\n override async notify(_options: { channel: string; payload: string }): Promise<void> {}\n\n override async subscribe(_options: {\n channel: string;\n onNotification: (payload: string) => void;\n }): Promise<Subscription> {\n throw new UnsupportedCapabilityError(\n DriverCapability.LISTEN_NOTIFY,\n 'PGLite has no shared notification bus; rely on interval polling instead.',\n );\n }\n\n // --- Advisory locks (custom to PGLite: inert) ---\n // A single in-process DB has no second process to coordinate with, so the migration runner takes\n // no lock — it skips these entirely because ADVISORY_LOCK is off in `capabilities`. They stay\n // declared, and inert, so PostgreSQL' pool-backed implementations can never be inherited.\n override async tryAdvisoryLock(_options: { key: string }): Promise<boolean> {\n return false;\n }\n\n override async releaseAdvisoryLock(_options: { key: string }): Promise<void> {}\n}\n"],"names":["postgresqlV1"],"mappings":";;;AAyBO,MAAM,oBAAwC,CAAC,EAAE,SAAS,GAAG,YAAYA,IAAc;AC6CvF,MAAM,qBAAqB,iBAAmC;AAAA,EACjD,SAAyB,eAAe;AAAA;AAAA,EAExC,eAAoC,aAAa;AAAA,IACjE,CAAC,iBAAiB,WAAW,GAAG;AAAA,IAChC,CAAC,iBAAiB,SAAS,GAAG;AAAA,IAC9B,CAAC,iBAAiB,YAAY,GAAG;AAAA,EAAA,CAClC;AAAA,EACiB,aAA8B,iBAAiB,iBAAiB;AAAA,EAE1E,KAA4B;AAAA,EACnB;AAAA,EAEjB,YAAY,UAA+B,IAAI;AAE7C,UAAM;AAAA,MACJ,GAAI,QAAQ,gBAAgB,SAAY,EAAE,aAAa,QAAQ,YAAA,IAAgB,CAAA;AAAA,MAC/E,GAAI,QAAQ,WAAW,SAAY,EAAE,QAAQ,QAAQ,OAAA,IAAW,CAAA;AAAA,MAChE,GAAI,QAAQ,cAAc,SAAY,EAAE,WAAW,QAAQ,cAAc,CAAA;AAAA,IAAC,CAC3E;AACD,SAAK,UAAU,QAAQ;AAAA,EACzB;AAAA;AAAA,EAGA,MAAe,UAAyB;AACtC,QAAI;AACJ,QAAI;AACF,YAAO,MAAM,OAAO,sBAAsB;AAAA,IAG5C,QAAQ;AACN,YAAM,IAAI,2BAA2B,wBAAwB,QAAQ;AAAA,IACvE;AACA,QAAI;AACF,WAAK,KAAK,KAAK,UAAU,IAAI,IAAI,OAAO,KAAK,OAAO,IAAI,IAAI,IAAI,OAAA;AAEhE,YAAM,KAAK,GAAG,MAAM,UAAU;AAAA,IAChC,SAAS,KAAK;AACZ,YAAM,IAAI,sBAAsB,gCAAgC,GAAG;AAAA,IACrE;AAAA,EACF;AAAA,EAEA,MAAe,aAA4B;AACzC,UAAM,KAAK,IAAI,MAAA;AACf,SAAK,KAAK;AAAA,EACZ;AAAA,EAEA,MAAyB,QACvB,KACA,QACA,SACoB;AACpB,UAAM,SAAU,WAA2C,KAAK;AAChE,QAAI,CAAC,OAAQ,OAAM,IAAI,sBAAsB,iCAAiC;AAC9E,UAAM,MAAM,MAAM,OAAO,MAAM,KAAK,MAAM;AAE1C,WAAO,EAAE,MAAM,IAAI,QAAQ,CAAA,GAAI,UAAU,IAAI,gBAAgB,IAAI,MAAM,UAAU,EAAA;AAAA,EACnF;AAAA,EAEA,MAAyB,YAAe,IAAkD;AACxF,QAAI,CAAC,KAAK,GAAI,OAAM,IAAI,sBAAsB,iCAAiC;AAE/E,WAAO,KAAK,GAAG,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;AAAA,EAC3C;AAAA;AAAA,EAGA,MAAe,QAA8B;AAC3C,WAAO,EAAE,eAAe,UAAU,sBAAsB,KAAK,sBAAoB;AAAA,EACnF;AAAA;AAAA;AAAA,EAIA,MAAe,OAAO,UAA+D;AAAA,EAAC;AAAA,EAEtF,MAAe,UAAU,UAGC;AACxB,UAAM,IAAI;AAAA,MACR,iBAAiB;AAAA,MACjB;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAe,gBAAgB,UAA6C;AAC1E,WAAO;AAAA,EACT;AAAA,EAEA,MAAe,oBAAoB,UAA0C;AAAA,EAAC;AAChF;"}
|
|
@@ -4,7 +4,7 @@ import { FlavourMigration } from '../shared/migration';
|
|
|
4
4
|
* runtime.
|
|
5
5
|
*
|
|
6
6
|
* `PGLITE_MIGRATIONS` is PGLite's own array — the runner only ever reads this one — but each entry
|
|
7
|
-
* points at the
|
|
7
|
+
* points at the PostgreSQL statement builder because the two dialects are identical, keys, partial
|
|
8
8
|
* indexes and `CREATE SCHEMA IF NOT EXISTS` included. There is a single version so far; a future
|
|
9
9
|
* change appends `{ version: 2, ... }` rather than editing v1, which is a frozen record of what has
|
|
10
10
|
* already been applied.
|
|
@@ -13,7 +13,7 @@ import { FlavourMigration } from '../shared/migration';
|
|
|
13
13
|
* Nothing yet. When a version needs to diverge (e.g. dropping a clause the WASM build rejects),
|
|
14
14
|
* author a local `v<n>(names: MigrationNames): string[]` here (`MigrationNames` comes from
|
|
15
15
|
* `../shared/migration`) and swap it into the array for that version only; every other version
|
|
16
|
-
* keeps reusing
|
|
16
|
+
* keeps reusing PostgreSQL. Spell its column names as raw string literals, never the `*Column` enums
|
|
17
17
|
* — renaming an enum member must never retroactively rewrite a past migration's DDL.
|
|
18
18
|
*/
|
|
19
19
|
export declare const PGLITE_MIGRATIONS: FlavourMigration[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DatabaseEngine } from '../../options/enums';
|
|
2
2
|
import { DriverCapabilitySet } from '../driver-capabilities';
|
|
3
3
|
import { Driver, DriverProbe, MigrationStep, Subscription } from '../driver.interface';
|
|
4
|
-
import {
|
|
4
|
+
import { PostgresqlDriver, RawResult, Session } from '../postgresql/postgresql-driver';
|
|
5
5
|
/**
|
|
6
6
|
* Options for {@link PgliteDriver} — entirely custom to PGLite: there is no host, port, user or
|
|
7
7
|
* pool, only an optional on-disk directory. `schema`/`tablePrefix`/`namespace` mean exactly what
|
|
8
|
-
* they mean for
|
|
8
|
+
* they mean for PostgreSQL and are forwarded to the base driver's `DriverContext`.
|
|
9
9
|
*/
|
|
10
10
|
export interface PGliteDriverOptions {
|
|
11
11
|
/** Data directory for a file-backed DB; omit for in-memory. */
|
|
@@ -28,14 +28,14 @@ export interface PGliteInstance extends PGliteQueryable {
|
|
|
28
28
|
close(): Promise<void>;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* PGLite driver —
|
|
31
|
+
* PGLite driver — PostgreSQL compiled to WASM, running in-process. Primarily for embedded/edge use
|
|
32
32
|
* and tests.
|
|
33
33
|
*
|
|
34
|
-
* Because PGLite is byte-for-byte PG-wire compatible, this class **extends `
|
|
34
|
+
* Because PGLite is byte-for-byte PG-wire compatible, this class **extends `PostgresqlDriver`** and
|
|
35
35
|
* inherits its entire SQL surface: `$1`-style placeholders, SKIP LOCKED claiming, RETURNING
|
|
36
36
|
* everywhere, the keys and indexes its migration creates, no relational JOIN (relationships resolve
|
|
37
37
|
* by name/key lookups), and the in-code enforcement of idempotency/singleton dedup. A change to a
|
|
38
|
-
* query in `
|
|
38
|
+
* query in `PostgresqlDriver` therefore changes PGLite too; anything that must differ is overridden
|
|
39
39
|
* here.
|
|
40
40
|
*
|
|
41
41
|
* What is custom to PGLite and overridden below:
|
|
@@ -49,9 +49,9 @@ export interface PGliteInstance extends PGliteQueryable {
|
|
|
49
49
|
* - `tryAdvisoryLock`/`releaseAdvisoryLock` — inert, since a single in-process DB has nothing to
|
|
50
50
|
* coordinate with.
|
|
51
51
|
*/
|
|
52
|
-
export declare class PgliteDriver extends
|
|
52
|
+
export declare class PgliteDriver extends PostgresqlDriver implements Driver {
|
|
53
53
|
readonly engine: DatabaseEngine;
|
|
54
|
-
/** Same as
|
|
54
|
+
/** Same as PostgreSQL minus LISTEN/NOTIFY and advisory locks — neither is meaningful in-process. */
|
|
55
55
|
readonly capabilities: DriverCapabilitySet;
|
|
56
56
|
readonly migrations: MigrationStep[];
|
|
57
57
|
private db;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { FlavourMigration, MigrationNames } from '../shared/migration';
|
|
2
2
|
/**
|
|
3
|
-
* Predefined
|
|
3
|
+
* Predefined PostgreSQL DDL, version by version. Authored by hand for this engine; not generated at
|
|
4
4
|
* runtime. There is a single version so far — the base schema — but the array is the extension
|
|
5
5
|
* point: a future change appends `{ version: 2, ... }` with its own statement builder rather than
|
|
6
6
|
* editing `v1`, which is a frozen record of what has already been applied.
|
|
7
7
|
*
|
|
8
|
-
* The statement builders are exported because PGLite is
|
|
8
|
+
* The statement builders are exported because PGLite is PostgreSQL compiled to WASM and reuses them
|
|
9
9
|
* verbatim (see `../pglite/migrations.ts`) — every other engine authors its own copy under its own
|
|
10
|
-
* folder, so a change here reaches
|
|
10
|
+
* folder, so a change here reaches PostgreSQL and PGLite and no one else.
|
|
11
11
|
*
|
|
12
|
-
* **Keys and indexes.**
|
|
12
|
+
* **Keys and indexes.** PostgreSQL is a capable engine, so the schema uses them: a primary key per
|
|
13
13
|
* table (which is also what makes `INSERT … ON CONFLICT DO NOTHING` a legal get-or-create for the
|
|
14
14
|
* queue and instance rows), plus one index per hot access path — the claim query, the two
|
|
15
15
|
* maintenance sweeps, the retention sweep, both dedup lookups, the newest-first job page and the
|
|
@@ -19,4 +19,4 @@ import { FlavourMigration, MigrationNames } from '../shared/migration';
|
|
|
19
19
|
*/
|
|
20
20
|
/** Version 1 — the full base schema, its keys and its indexes. */
|
|
21
21
|
export declare function v1(names: MigrationNames): string[];
|
|
22
|
-
export declare const
|
|
22
|
+
export declare const POSTGRESQL_MIGRATIONS: FlavourMigration[];
|
|
@@ -6,7 +6,7 @@ import { Driver, DriverProbe, InstanceListFilter, JobListFilter, JobRef, Migrati
|
|
|
6
6
|
import { InsertedJobRow, InstanceMetrics, InstanceRow, JobRecord, NewJobRecord, NewScheduleRow, QueueRow, ScheduleRow } from '../../jobs/job-record';
|
|
7
7
|
import { QueueOptions } from '../../options/queue-options';
|
|
8
8
|
import { TransactionHandle } from '../../tx/transaction-handle';
|
|
9
|
-
export interface
|
|
9
|
+
export interface PostgresqlDriverOptions {
|
|
10
10
|
connectionString?: string;
|
|
11
11
|
/** An existing `pg.Pool` to share with the app. */
|
|
12
12
|
pool?: unknown;
|
|
@@ -24,7 +24,7 @@ export interface PostgresDriverOptions {
|
|
|
24
24
|
}
|
|
25
25
|
export type { RawResult, Session };
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* PostgreSQL driver — the full-feature reference driver and the sole owner of the PG-wire SQL
|
|
28
28
|
* surface: `$1`-style placeholders, LISTEN/NOTIFY on a dedicated connection, advisory locks for
|
|
29
29
|
* leader-only tasks, SKIP LOCKED claiming, RETURNING everywhere, real keys and indexes. No method
|
|
30
30
|
* emits a relational JOIN — relationships resolve by name/key lookups — and idempotency/singleton
|
|
@@ -32,15 +32,15 @@ export type { RawResult, Session };
|
|
|
32
32
|
* could not honour one. The `pg` package is an optional peer, imported lazily inside `connect()`.
|
|
33
33
|
*
|
|
34
34
|
* Row mapping, value conversion, insert value lists and the affinity scan arithmetic come from
|
|
35
|
-
* {@link BaseDriver} — mechanism, not SQL. Every statement string in this file is
|
|
35
|
+
* {@link BaseDriver} — mechanism, not SQL. Every statement string in this file is PostgreSQL'.
|
|
36
36
|
*
|
|
37
37
|
* PG-wire subclassing: `PgliteDriver` extends this class and overrides only the connection
|
|
38
38
|
* mechanism (`connect`/`disconnect`/`execute`/`transaction`/`probe`) plus the features PGLite
|
|
39
39
|
* lacks. Every query method below is therefore shared with PGLite — treat a change here as a
|
|
40
|
-
* change to both engines, and if a tweak is genuinely
|
|
40
|
+
* change to both engines, and if a tweak is genuinely PostgreSQL-only, override it in `PgliteDriver`
|
|
41
41
|
* rather than branching on the engine here. No other engine shares this code.
|
|
42
42
|
*/
|
|
43
|
-
export declare class
|
|
43
|
+
export declare class PostgresqlDriver extends BaseDriver implements Driver {
|
|
44
44
|
readonly engine: DatabaseEngine;
|
|
45
45
|
readonly capabilities: DriverCapabilitySet;
|
|
46
46
|
readonly migrations: MigrationStep[];
|
|
@@ -53,14 +53,14 @@ export declare class PostgresDriver extends BaseDriver implements Driver {
|
|
|
53
53
|
private readonly lockClients;
|
|
54
54
|
private readonly listeners;
|
|
55
55
|
private readonly options;
|
|
56
|
-
constructor(options?:
|
|
56
|
+
constructor(options?: PostgresqlDriverOptions);
|
|
57
57
|
connect(): Promise<void>;
|
|
58
58
|
disconnect(): Promise<void>;
|
|
59
59
|
/** Run one statement. `protected` so a PG-wire subclass can swap in its own client. */
|
|
60
60
|
protected execute(sql: string, params: readonly unknown[], session?: Session): Promise<RawResult>;
|
|
61
61
|
/** Wrap `fn` in a transaction. `protected` so a PG-wire subclass can swap in its own client. */
|
|
62
62
|
protected transaction<T>(fn: (session: Session) => Promise<T>): Promise<T>;
|
|
63
|
-
/**
|
|
63
|
+
/** PostgreSQL uses `$1`-style positional placeholders. */
|
|
64
64
|
protected ph(index0: number): string;
|
|
65
65
|
/**
|
|
66
66
|
* The trailing `LIMIT`/`OFFSET` for a list read, appending each bound value to `params`.
|
|
@@ -50,7 +50,7 @@ export declare abstract class BaseDriver {
|
|
|
50
50
|
/**
|
|
51
51
|
* The most bound parameters this engine accepts in one statement. The default is a floor that
|
|
52
52
|
* every supported engine clears: SQLite's `SQLITE_MAX_VARIABLE_NUMBER` (32766 on a modern build),
|
|
53
|
-
*
|
|
53
|
+
* PostgreSQL' 16-bit parameter index (65535) and MySQL's `max_prepared_stmt_count` are all above it.
|
|
54
54
|
* A driver whose engine is tighter — Oracle's `INSERT ALL` — lowers it.
|
|
55
55
|
*/
|
|
56
56
|
protected readonly maxBindParams: number;
|
|
@@ -109,7 +109,7 @@ export declare abstract class BaseDriver {
|
|
|
109
109
|
* Split a batch so no single statement exceeds this engine's bound-parameter limit.
|
|
110
110
|
*
|
|
111
111
|
* A multi-row insert binds every column of every row, so a batch of a thousand jobs is tens of
|
|
112
|
-
* thousands of parameters — past SQLite's `SQLITE_MAX_VARIABLE_NUMBER` and
|
|
112
|
+
* thousands of parameters — past SQLite's `SQLITE_MAX_VARIABLE_NUMBER` and PostgreSQL' 16-bit
|
|
113
113
|
* parameter index. The caller loops over the chunks; each is still one round trip, so a large
|
|
114
114
|
* batch costs `ceil(rows / chunk)` statements instead of `rows`.
|
|
115
115
|
*/
|
|
@@ -123,7 +123,7 @@ export declare abstract class BaseDriver {
|
|
|
123
123
|
* tightest engine's `IN` limit, so a public batch is always one chunk; this is what keeps an
|
|
124
124
|
* internal caller (or a driver with a lower ceiling) from emitting a statement the engine rejects —
|
|
125
125
|
* `removeJobs` with 1001 ids used to raise ORA-01795 on Oracle and to blow past the parameter
|
|
126
|
-
* index on
|
|
126
|
+
* index on PostgreSQL and SQLite at a few tens of thousands.
|
|
127
127
|
*/
|
|
128
128
|
protected chunkIds<T>(keys: readonly T[]): T[][];
|
|
129
129
|
/**
|
|
@@ -150,7 +150,7 @@ export declare abstract class BaseDriver {
|
|
|
150
150
|
* declared by the query's own `ESCAPE '!'` — so a user typing `100%` searches for that text rather
|
|
151
151
|
* than matching everything. Still a bound parameter: nothing here is interpolated into SQL.
|
|
152
152
|
*
|
|
153
|
-
* The term is lower-cased for the engines whose query site lower-cases the column too;
|
|
153
|
+
* The term is lower-cased for the engines whose query site lower-cases the column too; PostgreSQL and
|
|
154
154
|
* PGLite use `ILIKE`, where the case folding is the operator's job and this is already inert.
|
|
155
155
|
*
|
|
156
156
|
* **A free-text search is a scan, and no index is declared for one.** The pattern has a leading
|
|
@@ -18,7 +18,7 @@ import { Clock } from '../../util/clock';
|
|
|
18
18
|
* contiguous prefix, and there is no way to reach "v1 and v3 applied, v2 not" — the state in which
|
|
19
19
|
* a maximum would read as complete while a version was missing.
|
|
20
20
|
*
|
|
21
|
-
* **Concurrency.** Where the engine has a named lock (
|
|
21
|
+
* **Concurrency.** Where the engine has a named lock (PostgreSQL' `pg_try_advisory_lock`, MySQL's
|
|
22
22
|
* `GET_LOCK`) one instance migrates and the rest wait for the version to land. Where it does not
|
|
23
23
|
* (Oracle, SQLite, PGLite) every instance proceeds, which is safe only because each engine's DDL is
|
|
24
24
|
* written to be idempotent — `IF NOT EXISTS`, `MERGE`, PL/SQL-guarded `CREATE INDEX` — and because
|
|
@@ -22,8 +22,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
24
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
|
-
const storage_constants = require("../../storage.constants-
|
|
26
|
-
const migration = require("../../migration-
|
|
25
|
+
const storage_constants = require("../../storage.constants-B5oQjxp5.cjs");
|
|
26
|
+
const migration = require("../../migration-CoTjpgBl.cjs");
|
|
27
27
|
function v1(names) {
|
|
28
28
|
const t = names.name;
|
|
29
29
|
const idx = names.derived;
|