@hot-updater/vercel 1.1.13 → 1.1.15

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.
@@ -2118,9 +2118,17 @@ const pruneStatements = (dialect, table, tablePrefix, limit) => {
2118
2118
  const order = retentionOrder(table).columns.map(quote);
2119
2119
  const list = (alias, direction = "") => order.map((column) => `${alias}.${column}${direction}`).join(", ");
2120
2120
  const oldest = (before) => `SELECT ${list("i")} FROM ${name} i WHERE i.${at} <= ${before()} ORDER BY ${list("i", " ASC")} LIMIT ${limit}`;
2121
- const doomed = (alias, before) => `${alias}.${at} <= ${before()} AND (${list(alias)}) <= (SELECT ${list("b")} FROM (${oldest(before)}) b ORDER BY ${list("b", " DESC")} LIMIT 1)`;
2121
+ const doomed = (alias, before) => `(${list(alias)}) <= (SELECT ${list("b")} FROM (${oldest(before)}) b ORDER BY ${list("b", " DESC")} LIMIT 1) AND ${alias}.${at} <= ${before()}`;
2122
2122
  const entries = table.indexes.filter((index) => isMultiIndex(table, index)).map((index) => quote(`${tablePrefix}${table.name}__${index.name}`));
2123
2123
  const keyOf = (left, right) => table.key.map((column) => `${left}.${quote(column)} = ${right}.${quote(column)}`).join(" AND ");
2124
+ if (dialect === "sqlite") return [...table.indexes.filter((index) => isMultiIndex(table, index)).map((index) => {
2125
+ const columns = [...index.eq, ...indexOrderColumns(table, index)];
2126
+ const multi = columns.filter((column) => findPhysicalColumn(table, column).multi);
2127
+ const values = columns.map((column) => multi.includes(column) ? `j${multi.indexOf(column)}.${quote("value")}` : `b.${quote(column)}`);
2128
+ const each = multi.map((column, at) => `, json_each(b.${quote(column)}) j${at}`);
2129
+ const into = quote(`${tablePrefix}${table.name}__${index.name}`);
2130
+ return (before) => `DELETE FROM ${into} WHERE (${columns.map(quote).join(", ")}) IN (SELECT ${values.join(", ")} FROM ${name} b${each.join("")} WHERE ${doomed("b", before)})`;
2131
+ }), (before) => `DELETE FROM ${name} WHERE ${doomed(name, before)}`];
2124
2132
  if (dialect === "mysql") return [...entries.map((index) => (before) => `DELETE e FROM ${index} e JOIN (${oldest(before)}) d ON ${keyOf("e", "d")}`), (before) => `DELETE FROM ${name} WHERE ${at} <= ${before()} ORDER BY ${order.join(", ")} LIMIT ${limit}`];
2125
2133
  return [...entries.map((index) => (before) => `DELETE FROM ${index} WHERE EXISTS (SELECT * FROM ${name} b WHERE ${keyOf("b", index)} AND ${doomed("b", before)})`), (before) => `DELETE FROM ${name} WHERE ${doomed(name, before)}`];
2126
2134
  };
@@ -4186,19 +4194,19 @@ const createSqlAdapter = ({ executor, tablePrefix = "", maxOps = 1e3, maxParams
4186
4194
  const where = (bind, key, v) => `${keyMatch(bind, table, key)}${v === void 0 ? "" : ` AND ${version} = ${bind(v)}`}${when ? ` AND ${when(bind)}` : ""}`;
4187
4195
  const insert = (bind, into, columns, values) => `INSERT INTO ${into} (${columns.map(quote).join(", ")}) ${when ? `SELECT ${values.join(", ")} WHERE ${when(bind)}` : `VALUES (${values.join(", ")})`}`;
4188
4196
  const insertRow = (bind, row) => insert(bind, name, table.columns.map((column) => column.name), table.columns.map((column) => bind(row[column.name], column)));
4189
- const entries = (key, row, changed) => table.indexes.flatMap((index) => {
4197
+ const entries = (key, row, changed, stale = true) => table.indexes.flatMap((index) => {
4190
4198
  const columns = [...index.eq, ...indexOrderColumns(table, index)];
4191
4199
  if (!isMultiIndex(table, index) || changed && !columns.some((column) => changed.includes(column))) return [];
4192
4200
  const into = tableOf(table, index);
4193
4201
  const found = row ? indexEntries(table, index, row) : [];
4194
4202
  const order = found.length > 0 ? indexOrderTuple(table, index, row) : [];
4195
- return [sql((bind) => `DELETE FROM ${into} WHERE ${where(bind, key)}`), ...found.map((eq) => sql((bind) => {
4203
+ return [...stale ? [sql((bind) => `DELETE FROM ${into} WHERE ${where(bind, key)}`)] : [], ...found.map((eq) => sql((bind) => {
4196
4204
  const values = [...eq, ...order].map((value) => bind(value));
4197
4205
  return insert(bind, into, columns, values);
4198
4206
  }))];
4199
4207
  });
4200
4208
  switch (op.type) {
4201
- case "insert": return [sql((bind) => insertRow(bind, op.row)), ...entries(rowKey(table, op.row), op.row)];
4209
+ case "insert": return [sql((bind) => insertRow(bind, op.row)), ...entries(rowKey(table, op.row), op.row, void 0, false)];
4202
4210
  case "patch": return [sql((bind) => {
4203
4211
  const set = Object.entries(op.set).map(([column, value]) => `${quote(column)} = ${bind(value, findPhysicalColumn(table, column))}`);
4204
4212
  return `UPDATE ${name} SET ${[...set, `${version} = ${version} + 1`].join(", ")} WHERE ${where(bind, op.key, op.guard.v)}`;
@@ -17558,7 +17566,7 @@ const postgres = (config) => {
17558
17566
  };
17559
17567
  //#endregion
17560
17568
  //#region ../../packages/server/dist/version.mjs
17561
- const HOT_UPDATER_SERVER_VERSION = "1.1.13";
17569
+ const HOT_UPDATER_SERVER_VERSION = "1.1.15";
17562
17570
  //#endregion
17563
17571
  //#region ../../packages/server/dist/handlerVersionRoutes.mjs
17564
17572
  const createVersionRouteHandlers = (plugins = []) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/vercel",
3
3
  "type": "module",
4
- "version": "1.1.13",
4
+ "version": "1.1.15",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -41,11 +41,11 @@
41
41
  "@vercel/cli-auth": "0.3.10",
42
42
  "@vercel/cli-config": "0.3.1",
43
43
  "pg": "8.13.1",
44
- "@hot-updater/cli-tools": "1.1.13",
45
- "@hot-updater/postgres": "1.1.13",
46
- "@hot-updater/server": "1.1.13",
47
- "@hot-updater/protocol": "1.1.13",
48
- "@hot-updater/plugin-core": "1.1.13"
44
+ "@hot-updater/plugin-core": "1.1.15",
45
+ "@hot-updater/cli-tools": "1.1.15",
46
+ "@hot-updater/postgres": "1.1.15",
47
+ "@hot-updater/protocol": "1.1.15",
48
+ "@hot-updater/server": "1.1.15"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^20",
@@ -54,7 +54,7 @@
54
54
  "execa": "9.5.2",
55
55
  "kysely": "0.28.17",
56
56
  "vitest": "4.1.4",
57
- "@hot-updater/test-utils": "1.1.13"
57
+ "@hot-updater/test-utils": "1.1.15"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "tsdown",