@shapio/local 0.5.9 → 0.5.11
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/{advisoryLocks-ajVNBhfa.js → advisoryLocks-DGbxw3_E.js} +13 -13
- package/dist/advisoryLocks-DGbxw3_E.js.map +1 -0
- package/dist/errors-nQvt9bs7.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{migrator-CO5sXosL.js → migrator-BfVtncOo.js} +269 -148
- package/dist/migrator-BfVtncOo.js.map +1 -0
- package/package.json +4 -4
- package/dist/advisoryLocks-ajVNBhfa.js.map +0 -1
- package/dist/migrator-CO5sXosL.js.map +0 -1
|
@@ -2065,7 +2065,7 @@ const REFUSES_UPDATES = /* @__PURE__ */ new Set(["content_revisions", "schema_re
|
|
|
2065
2065
|
const targetOf = (conflict) => conflict.columns?.map((column) => column.column.name);
|
|
2066
2066
|
/**
|
|
2067
2067
|
* `ON CONFLICT … DO UPDATE` as `ON DUPLICATE KEY UPDATE`, and `ON CONFLICT … DO NOTHING` without RETURNING
|
|
2068
|
-
* as `ON DUPLICATE KEY UPDATE <key> = <key>` (a no-op), when MySQL's any-key
|
|
2068
|
+
* as `ON DUPLICATE KEY UPDATE <key> = <key>` (a no-op), when MySQL's any-key behavior equals the target's
|
|
2069
2069
|
* (`duplicateKeyMatchesTarget`). Any other conflict clause (another unique key could fire, a `WHERE` on the
|
|
2070
2070
|
* update, RETURNING) is left for the compiler's plan: each row inserted under a savepoint, and a duplicate
|
|
2071
2071
|
* on the target either skipped or turned into an UPDATE of the row it found.
|
|
@@ -2271,7 +2271,7 @@ const insertPlan = (node, compile) => {
|
|
|
2271
2271
|
/**
|
|
2272
2272
|
* Subquery shapes MySQL rejects, rewritten (ADR 0001, "MySQL"): `IN (… LIMIT n)` (error 1235) and a subquery
|
|
2273
2273
|
* reading the table an UPDATE, DELETE or INSERT writes (error 1093) read a derived table instead, which MySQL
|
|
2274
|
-
*
|
|
2274
|
+
* materializes first; PostgreSQL's `UPDATE … FROM` becomes a multi-table UPDATE.
|
|
2275
2275
|
*/
|
|
2276
2276
|
/** The alias of a derived table wrapped around a subquery. */
|
|
2277
2277
|
const DERIVED_ALIAS = "shapio_derived";
|
|
@@ -2281,7 +2281,7 @@ const tableNameOf$1 = (node) => node && TableNode.is(node) ? node.table.identifi
|
|
|
2281
2281
|
* reads `table`, the target of the enclosing UPDATE, DELETE or INSERT (error 1093).
|
|
2282
2282
|
*/
|
|
2283
2283
|
const needsDerivedTable = (node, table) => node.limit !== void 0 || table !== void 0 && ((node.from?.froms ?? []).some((item) => tableNameOf$1(AliasNode.is(item) ? item.node : item) === table) || (node.joins ?? []).some((join) => tableNameOf$1(AliasNode.is(join.table) ? join.table.node : join.table) === table));
|
|
2284
|
-
/** `(select * from (<subquery>) as shapio_derived)`: MySQL
|
|
2284
|
+
/** `(select * from (<subquery>) as shapio_derived)`: MySQL materializes it first. */
|
|
2285
2285
|
const derived = (node) => Object.freeze({
|
|
2286
2286
|
...SelectQueryNode.createFrom([AliasNode.create(node, IdentifierNode.create(DERIVED_ALIAS))]),
|
|
2287
2287
|
selections: [SelectionNode.create(SelectAllNode.create())]
|
|
@@ -2311,7 +2311,7 @@ var DerivedTableWrapper = class extends OperationNodeTransformer {
|
|
|
2311
2311
|
const wrapSubqueries = (where, table) => where ? new DerivedTableWrapper(table).transformNode(where) : where;
|
|
2312
2312
|
/**
|
|
2313
2313
|
* An INSERT whose VALUES read the target table in a scalar subquery (`coalesce(max(position) + 1, 0)`):
|
|
2314
|
-
* MySQL rejects that (error 1093) unless the subquery reads a derived table, which it
|
|
2314
|
+
* MySQL rejects that (error 1093) unless the subquery reads a derived table, which it materializes first.
|
|
2315
2315
|
*/
|
|
2316
2316
|
const withDerivedValueSubqueries = (node) => {
|
|
2317
2317
|
const table = node.into?.table.identifier.name;
|
|
@@ -2488,7 +2488,7 @@ var ShapioMysqlQueryCompiler = class ShapioMysqlQueryCompiler extends MysqlQuery
|
|
|
2488
2488
|
//#endregion
|
|
2489
2489
|
//#region ../../apps/api/src/db/notifyHub.ts
|
|
2490
2490
|
/**
|
|
2491
|
-
* In-process notification delivery (ADR 0002 notes notifications are an
|
|
2491
|
+
* In-process notification delivery (ADR 0002 notes notifications are an optimization; consumers also check
|
|
2492
2492
|
* a durable version): an event bus per database. Every handle on the same database in this process shares
|
|
2493
2493
|
* one bus, so two app instances in one test process still hear each other.
|
|
2494
2494
|
* - SQLite: the only delivery (SQLite deployments are single-process).
|
|
@@ -2770,7 +2770,7 @@ var MysqlDriver = class {
|
|
|
2770
2770
|
this.#pool = pool;
|
|
2771
2771
|
}
|
|
2772
2772
|
#pooled() {
|
|
2773
|
-
if (!this.#pool) throw new Error("The MySQL driver is not
|
|
2773
|
+
if (!this.#pool) throw new Error("The MySQL driver is not initialized");
|
|
2774
2774
|
return this.#pool;
|
|
2775
2775
|
}
|
|
2776
2776
|
/**
|
|
@@ -2914,7 +2914,7 @@ const ISO_TIMESTAMP = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/;
|
|
|
2914
2914
|
*/
|
|
2915
2915
|
const timestampText = (value) => typeof value === "string" && ISO_TIMESTAMP.test(value) ? toDatetimeText(value) : value;
|
|
2916
2916
|
const isTimestampColumn = (table, column) => table !== void 0 && (tableInfo(table)?.timestamps ?? []).includes(column);
|
|
2917
|
-
/** A value node (or primitive list) bound to a timestamp column, with ISO text
|
|
2917
|
+
/** A value node (or primitive list) bound to a timestamp column, with ISO text normalized. */
|
|
2918
2918
|
const timestampValue = (node) => {
|
|
2919
2919
|
if (ValueNode.is(node)) {
|
|
2920
2920
|
const value = timestampText(node.value);
|
|
@@ -2923,7 +2923,7 @@ const timestampValue = (node) => {
|
|
|
2923
2923
|
if (PrimitiveValueListNode.is(node)) return PrimitiveValueListNode.create(node.values.map(timestampText));
|
|
2924
2924
|
return node;
|
|
2925
2925
|
};
|
|
2926
|
-
/** Insert rows with ISO text for timestamp columns
|
|
2926
|
+
/** Insert rows with ISO text for timestamp columns normalized. */
|
|
2927
2927
|
const withTimestampValues = (node) => {
|
|
2928
2928
|
const table = node.into?.table.identifier.name;
|
|
2929
2929
|
const positions = (node.columns?.map((column) => column.column.name) ?? []).flatMap((column, index) => isTimestampColumn(table, column) ? [index] : []);
|
|
@@ -3042,7 +3042,7 @@ const decodeRow = (row, markers) => {
|
|
|
3042
3042
|
* Adapts Kysely queries written for PostgreSQL to MySQL (dialect boundary, ADR 0001, "MySQL"). Rewrites that
|
|
3043
3043
|
* stay one statement happen here; statements MySQL cannot run as one (`RETURNING`, most `ON CONFLICT`) are
|
|
3044
3044
|
* planned by the compiler (`plans.ts`). This plugin:
|
|
3045
|
-
* - fills the columns PostgreSQL defaults that MySQL cannot, and
|
|
3045
|
+
* - fills the columns PostgreSQL defaults that MySQL cannot, and normalizes ISO text bound to timestamp
|
|
3046
3046
|
* columns (`insertValues.ts`);
|
|
3047
3047
|
* - spells casts MySQL's way (`text` → `char`, `bigint`/`integer` → `signed`) and maps row locks MySQL lacks;
|
|
3048
3048
|
* - keeps PostgreSQL's NULL placement in ORDER BY (`nullOrdering.ts`);
|
|
@@ -3704,7 +3704,7 @@ const indexExpressionSql = (index) => index.columns.map((column) => index.nullab
|
|
|
3704
3704
|
const nullsNotDistinctIndexFor = (table, columns) => NULLS_NOT_DISTINCT_INDEXES.find((index) => index.table === table && index.columns.length === columns.length && index.columns.every((column) => columns.includes(column)));
|
|
3705
3705
|
//#endregion
|
|
3706
3706
|
//#region ../../apps/api/src/db/sqlite/plugin.ts
|
|
3707
|
-
/** Row-lock modifiers PostgreSQL needs and SQLite rejects; its write transactions are already
|
|
3707
|
+
/** Row-lock modifiers PostgreSQL needs and SQLite rejects; its write transactions are already serialized. */
|
|
3708
3708
|
const ROW_LOCKS = /* @__PURE__ */ new Set([
|
|
3709
3709
|
"ForUpdate",
|
|
3710
3710
|
"ForNoKeyUpdate",
|
|
@@ -3888,7 +3888,7 @@ const OPTIMIZE = {
|
|
|
3888
3888
|
};
|
|
3889
3889
|
/**
|
|
3890
3890
|
* A Kysely driver over Node's built-in `node:sqlite` (no native dependency). One writer connection runs
|
|
3891
|
-
* every write,
|
|
3891
|
+
* every write, serialized by an in-process lock (`writeLock.ts`, `BEGIN IMMEDIATE`); reader connections
|
|
3892
3892
|
* serve read-only transactions and autocommit reads concurrently (WAL). An in-memory database has the
|
|
3893
3893
|
* writer only, and every statement takes the lock.
|
|
3894
3894
|
*/
|
|
@@ -4117,7 +4117,7 @@ var SqliteSession = class {
|
|
|
4117
4117
|
//#region ../../apps/api/src/db/sqlite/index.ts
|
|
4118
4118
|
/**
|
|
4119
4119
|
* SQLite runs DDL inside transactions, so each migration commits or rolls back whole. The driver handles
|
|
4120
|
-
* concurrency itself (one writer, several readers), so Kysely must not
|
|
4120
|
+
* concurrency itself (one writer, several readers), so Kysely must not serialize connections on top.
|
|
4121
4121
|
*/
|
|
4122
4122
|
var ShapioSqliteAdapter = class extends SqliteAdapter {
|
|
4123
4123
|
get supportsTransactionalDdl() {
|
|
@@ -4192,4 +4192,4 @@ const lockKeyFromId = (id) => createHash("sha256").update(id).digest().readInt32
|
|
|
4192
4192
|
//#endregion
|
|
4193
4193
|
export { mysqlDriverOf as a, assertNotNested as c, toDatetimeText as d, AppError as f, createMysqlDb as i, withConnectionScope as l, createSqliteDb as n, DEFAULT_POOL_ACQUIRE_TIMEOUT_MS as o, sqliteDriverOf as r, pgAcquireError as s, lockKeyFromId as t, toStoredTimestamp as u };
|
|
4194
4194
|
|
|
4195
|
-
//# sourceMappingURL=advisoryLocks-
|
|
4195
|
+
//# sourceMappingURL=advisoryLocks-DGbxw3_E.js.map
|