@hot-updater/plugin-core 1.0.0-rc.16 → 1.0.0-rc.17

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.
Files changed (51) hide show
  1. package/dist/database/adapter.cjs +9 -0
  2. package/dist/database/adapter.d.cts +34 -1
  3. package/dist/database/adapter.d.mts +34 -1
  4. package/dist/database/adapter.mjs +9 -1
  5. package/dist/{insightsDistinctSummary.mjs → database/distinct.cjs} +23 -10
  6. package/dist/database/distinct.d.cts +16 -0
  7. package/dist/database/distinct.d.mts +16 -0
  8. package/dist/{insightsDistinctSummary.cjs → database/distinct.mjs} +19 -14
  9. package/dist/database/memoryAdapter.cjs +13 -0
  10. package/dist/database/memoryAdapter.mjs +13 -0
  11. package/dist/database/verifyAdapter.cjs +7 -0
  12. package/dist/database/verifyAdapter.mjs +7 -0
  13. package/dist/databaseJsonValue.cjs +0 -2
  14. package/dist/databaseJsonValue.d.cts +3 -3
  15. package/dist/databaseJsonValue.d.mts +3 -3
  16. package/dist/databaseJsonValue.mjs +1 -2
  17. package/dist/index.cjs +0 -4
  18. package/dist/index.d.cts +5 -7
  19. package/dist/index.d.mts +5 -7
  20. package/dist/index.mjs +2 -3
  21. package/dist/internal.cjs +9 -16
  22. package/dist/internal.d.cts +6 -8
  23. package/dist/internal.d.mts +6 -8
  24. package/dist/internal.mjs +4 -5
  25. package/dist/types/databaseConfig.d.cts +29 -1
  26. package/dist/types/databaseConfig.d.mts +29 -1
  27. package/dist/types/databaseRows.d.cts +1 -53
  28. package/dist/types/databaseRows.d.mts +1 -53
  29. package/dist/types/index.d.cts +4 -5
  30. package/dist/types/index.d.mts +4 -5
  31. package/dist/types/internal.d.cts +3 -4
  32. package/dist/types/internal.d.mts +3 -4
  33. package/dist/types/models.d.cts +2 -12
  34. package/dist/types/models.d.mts +2 -12
  35. package/dist/types/public.d.cts +4 -5
  36. package/dist/types/public.d.mts +4 -5
  37. package/package.json +1 -1
  38. package/dist/bundleEventRow.cjs +0 -42
  39. package/dist/bundleEventRow.mjs +0 -41
  40. package/dist/insightsContract.cjs +0 -194
  41. package/dist/insightsContract.d.cts +0 -14
  42. package/dist/insightsContract.d.mts +0 -14
  43. package/dist/insightsContract.mjs +0 -190
  44. package/dist/insightsDistinctSummary.d.cts +0 -12
  45. package/dist/insightsDistinctSummary.d.mts +0 -12
  46. package/dist/insightsOverview.cjs +0 -139
  47. package/dist/insightsOverview.d.cts +0 -42
  48. package/dist/insightsOverview.d.mts +0 -42
  49. package/dist/insightsOverview.mjs +0 -134
  50. package/dist/types/insights.d.cts +0 -172
  51. package/dist/types/insights.d.mts +0 -172
@@ -20,6 +20,14 @@ const findPhysicalIndex = (table, name) => {
20
20
  * columns, then the key columns that neither `eq` nor `sort` fixes.
21
21
  */
22
22
  const indexOrderColumns = (table, index) => [...index.sort, ...table.key.filter((column) => !index.sort.includes(column) && !index.eq.includes(column))];
23
+ /**
24
+ * When a row of a table with retention expires, in epoch milliseconds, or
25
+ * undefined when the table keeps its rows or the row's time is null.
26
+ */
27
+ const expiresAt = (table, row) => {
28
+ const time = table.retention && row[table.retention.column];
29
+ return typeof time === "number" ? time + table.retention.ms : void 0;
30
+ };
23
31
  /** The primary key of a row, in key-column order. */
24
32
  const rowKey = (table, row) => table.key.map((column) => {
25
33
  const value = row[column];
@@ -31,6 +39,7 @@ exports.DATABASE_MAX_MULTI_VALUES = DATABASE_MAX_MULTI_VALUES;
31
39
  exports.DATABASE_MAX_QUERY_LIMIT = DATABASE_MAX_QUERY_LIMIT;
32
40
  exports.DATABASE_VERSION_COLUMN = DATABASE_VERSION_COLUMN;
33
41
  exports.DatabaseSchemaError = DatabaseSchemaError;
42
+ exports.expiresAt = expiresAt;
34
43
  exports.findPhysicalColumn = findPhysicalColumn;
35
44
  exports.findPhysicalIndex = findPhysicalIndex;
36
45
  exports.indexOrderColumns = indexOrderColumns;
@@ -39,6 +39,12 @@ interface PhysicalIndex {
39
39
  /** The `eq` values identify at most one row. */
40
40
  readonly unique?: true;
41
41
  }
42
+ /** How long a table's rows live: `ms` past the epoch milliseconds in `column`. */
43
+ interface PhysicalRetention {
44
+ /** An integer column; a row whose value is null never expires. */
45
+ readonly column: string;
46
+ readonly ms: number;
47
+ }
42
48
  interface PhysicalTable {
43
49
  /** The logical name; each adapter applies its own table prefix. */
44
50
  readonly name: string;
@@ -46,6 +52,12 @@ interface PhysicalTable {
46
52
  /** Primary-key columns, in order. */
47
53
  readonly key: readonly string[];
48
54
  readonly indexes: readonly PhysicalIndex[];
55
+ /**
56
+ * Rows expire at {@link expiresAt}. A backend with a native TTL stamps it
57
+ * on every item the row has, its index copies included, and deletes them
58
+ * itself; any other adapter implements `prune`, which the engine calls.
59
+ */
60
+ readonly retention?: PhysicalRetention;
49
61
  }
50
62
  interface QueryBound {
51
63
  /** A prefix of the index's order columns (see `indexOrderColumns`). */
@@ -125,6 +137,22 @@ interface DatabaseAdapter {
125
137
  */
126
138
  query(table: PhysicalTable, request: QueryRequest): Promise<readonly StoredRow[]>;
127
139
  write(ops: readonly WriteOp[]): Promise<WriteResult>;
140
+ /**
141
+ * Deletes rows, as read, with their index entries: best effort, without
142
+ * guards, and not atomically. It is for rows the caller has already
143
+ * recorded as consumed, so deleting one twice, or one already gone, is
144
+ * harmless. A backend that bills transactional deletes more implements it
145
+ * with its plain batch delete; without it, callers delete through `write`.
146
+ */
147
+ deleteConsumed?(table: PhysicalTable, rows: readonly StoredRow[]): Promise<void>;
148
+ /**
149
+ * Deletes up to `limit` rows of a table with retention whose retention
150
+ * column is at or below `before`, oldest first (ties in any order), with
151
+ * their index entries, rechecking the column as it deletes, so a row a
152
+ * concurrent write moved past `before` stays. Resolves to the number
153
+ * deleted. A backend that expires rows natively leaves it out.
154
+ */
155
+ prune?(table: PhysicalTable, before: number, limit: number): Promise<number>;
128
156
  /** Called only by `@hot-updater/server/db` tooling. */
129
157
  readonly migrations?: {
130
158
  apply(tables: readonly PhysicalTable[]): Promise<void>;
@@ -144,7 +172,12 @@ declare const findPhysicalIndex: (table: PhysicalTable, name: string) => Physica
144
172
  * columns, then the key columns that neither `eq` nor `sort` fixes.
145
173
  */
146
174
  declare const indexOrderColumns: (table: PhysicalTable, index: PhysicalIndex) => readonly string[];
175
+ /**
176
+ * When a row of a table with retention expires, in epoch milliseconds, or
177
+ * undefined when the table keeps its rows or the row's time is null.
178
+ */
179
+ declare const expiresAt: (table: PhysicalTable, row: StoredRow) => number | undefined;
147
180
  /** The primary key of a row, in key-column order. */
148
181
  declare const rowKey: (table: PhysicalTable, row: StoredRow) => DatabaseKey;
149
182
  //#endregion
150
- export { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey };
183
+ export { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalRetention, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, expiresAt, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey };
@@ -39,6 +39,12 @@ interface PhysicalIndex {
39
39
  /** The `eq` values identify at most one row. */
40
40
  readonly unique?: true;
41
41
  }
42
+ /** How long a table's rows live: `ms` past the epoch milliseconds in `column`. */
43
+ interface PhysicalRetention {
44
+ /** An integer column; a row whose value is null never expires. */
45
+ readonly column: string;
46
+ readonly ms: number;
47
+ }
42
48
  interface PhysicalTable {
43
49
  /** The logical name; each adapter applies its own table prefix. */
44
50
  readonly name: string;
@@ -46,6 +52,12 @@ interface PhysicalTable {
46
52
  /** Primary-key columns, in order. */
47
53
  readonly key: readonly string[];
48
54
  readonly indexes: readonly PhysicalIndex[];
55
+ /**
56
+ * Rows expire at {@link expiresAt}. A backend with a native TTL stamps it
57
+ * on every item the row has, its index copies included, and deletes them
58
+ * itself; any other adapter implements `prune`, which the engine calls.
59
+ */
60
+ readonly retention?: PhysicalRetention;
49
61
  }
50
62
  interface QueryBound {
51
63
  /** A prefix of the index's order columns (see `indexOrderColumns`). */
@@ -125,6 +137,22 @@ interface DatabaseAdapter {
125
137
  */
126
138
  query(table: PhysicalTable, request: QueryRequest): Promise<readonly StoredRow[]>;
127
139
  write(ops: readonly WriteOp[]): Promise<WriteResult>;
140
+ /**
141
+ * Deletes rows, as read, with their index entries: best effort, without
142
+ * guards, and not atomically. It is for rows the caller has already
143
+ * recorded as consumed, so deleting one twice, or one already gone, is
144
+ * harmless. A backend that bills transactional deletes more implements it
145
+ * with its plain batch delete; without it, callers delete through `write`.
146
+ */
147
+ deleteConsumed?(table: PhysicalTable, rows: readonly StoredRow[]): Promise<void>;
148
+ /**
149
+ * Deletes up to `limit` rows of a table with retention whose retention
150
+ * column is at or below `before`, oldest first (ties in any order), with
151
+ * their index entries, rechecking the column as it deletes, so a row a
152
+ * concurrent write moved past `before` stays. Resolves to the number
153
+ * deleted. A backend that expires rows natively leaves it out.
154
+ */
155
+ prune?(table: PhysicalTable, before: number, limit: number): Promise<number>;
128
156
  /** Called only by `@hot-updater/server/db` tooling. */
129
157
  readonly migrations?: {
130
158
  apply(tables: readonly PhysicalTable[]): Promise<void>;
@@ -144,7 +172,12 @@ declare const findPhysicalIndex: (table: PhysicalTable, name: string) => Physica
144
172
  * columns, then the key columns that neither `eq` nor `sort` fixes.
145
173
  */
146
174
  declare const indexOrderColumns: (table: PhysicalTable, index: PhysicalIndex) => readonly string[];
175
+ /**
176
+ * When a row of a table with retention expires, in epoch milliseconds, or
177
+ * undefined when the table keeps its rows or the row's time is null.
178
+ */
179
+ declare const expiresAt: (table: PhysicalTable, row: StoredRow) => number | undefined;
147
180
  /** The primary key of a row, in key-column order. */
148
181
  declare const rowKey: (table: PhysicalTable, row: StoredRow) => DatabaseKey;
149
182
  //#endregion
150
- export { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey };
183
+ export { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalRetention, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, expiresAt, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey };
@@ -20,6 +20,14 @@ const findPhysicalIndex = (table, name) => {
20
20
  * columns, then the key columns that neither `eq` nor `sort` fixes.
21
21
  */
22
22
  const indexOrderColumns = (table, index) => [...index.sort, ...table.key.filter((column) => !index.sort.includes(column) && !index.eq.includes(column))];
23
+ /**
24
+ * When a row of a table with retention expires, in epoch milliseconds, or
25
+ * undefined when the table keeps its rows or the row's time is null.
26
+ */
27
+ const expiresAt = (table, row) => {
28
+ const time = table.retention && row[table.retention.column];
29
+ return typeof time === "number" ? time + table.retention.ms : void 0;
30
+ };
23
31
  /** The primary key of a row, in key-column order. */
24
32
  const rowKey = (table, row) => table.key.map((column) => {
25
33
  const value = row[column];
@@ -27,4 +35,4 @@ const rowKey = (table, row) => table.key.map((column) => {
27
35
  return value;
28
36
  });
29
37
  //#endregion
30
- export { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseSchemaError, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey };
38
+ export { DATABASE_MAX_MULTI_VALUES, DATABASE_MAX_QUERY_LIMIT, DATABASE_VERSION_COLUMN, DatabaseSchemaError, expiresAt, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey };
@@ -1,4 +1,9 @@
1
- //#region src/insightsDistinctSummary.ts
1
+ //#region src/database/distinct.ts
2
+ /**
3
+ * HyperLogLog sketches, the storage engine's `distinct` aggregate metric: a
4
+ * sketch is 1,024 registers stored as a 1,024-character string, so adding a
5
+ * value, merging sketches, and counting one never need the values back.
6
+ */
2
7
  const PRECISION = 10;
3
8
  const REGISTER_COUNT = 1024;
4
9
  const MAX_RANK = 55;
@@ -13,17 +18,17 @@ const hash = (value) => {
13
18
  const OFFSET = 33;
14
19
  const decode = (summary) => {
15
20
  if (!summary) return new Uint8Array(REGISTER_COUNT);
16
- if (summary.length !== REGISTER_COUNT) throw new Error("Invalid Insights distinct summary");
21
+ if (summary.length !== REGISTER_COUNT) throw new Error("Invalid distinct sketch");
17
22
  const registers = new Uint8Array(REGISTER_COUNT);
18
23
  for (let index = 0; index < REGISTER_COUNT; index += 1) {
19
24
  const value = summary.charCodeAt(index) - OFFSET;
20
- if (!Number.isInteger(value) || value < 0 || value > MAX_RANK) throw new Error("Invalid Insights distinct summary");
25
+ if (!Number.isInteger(value) || value < 0 || value > MAX_RANK) throw new Error("Invalid distinct sketch");
21
26
  registers[index] = value;
22
27
  }
23
28
  return registers;
24
29
  };
25
30
  const encode = (registers) => Array.from(registers, (value) => String.fromCharCode(value + OFFSET)).join("");
26
- const getInsightsDistinctRegister = (identity) => {
31
+ const distinctRegister = (identity) => {
27
32
  const value = hash(identity);
28
33
  const index = Number(value & BigInt(1023));
29
34
  let remainder = value >> BigInt(PRECISION);
@@ -38,13 +43,15 @@ const getInsightsDistinctRegister = (identity) => {
38
43
  character: String.fromCharCode(rank + OFFSET)
39
44
  };
40
45
  };
41
- const addInsightsDistinct = (summary, identity) => {
46
+ /** The sketch with `identity` added; a missing sketch is the empty one. */
47
+ const addDistinct = (summary, identity) => {
42
48
  const registers = decode(summary);
43
- const { index, rank } = getInsightsDistinctRegister(identity);
49
+ const { index, rank } = distinctRegister(identity);
44
50
  registers[index] = Math.max(registers[index], rank);
45
51
  return encode(registers);
46
52
  };
47
- const mergeInsightsDistinct = (summaries) => {
53
+ /** The union of sketches, register by register. */
54
+ const mergeDistinct = (summaries) => {
48
55
  const merged = new Uint8Array(REGISTER_COUNT);
49
56
  for (const summary of summaries) {
50
57
  const registers = decode(summary);
@@ -52,7 +59,8 @@ const mergeInsightsDistinct = (summaries) => {
52
59
  }
53
60
  return encode(merged);
54
61
  };
55
- const countInsightsDistinct = (summary) => {
62
+ /** The estimated number of distinct values a sketch holds. */
63
+ const countDistinct = (summary) => {
56
64
  const registers = decode(summary);
57
65
  let inverseSum = 0;
58
66
  let empty = 0;
@@ -64,6 +72,11 @@ const countInsightsDistinct = (summary) => {
64
72
  const estimate = raw <= 2.5 * REGISTER_COUNT && empty > 0 ? REGISTER_COUNT * Math.log(REGISTER_COUNT / empty) : raw;
65
73
  return Math.max(0, Math.round(estimate));
66
74
  };
67
- const emptyInsightsDistinct = () => encode(new Uint8Array(REGISTER_COUNT));
75
+ /** A sketch that holds no value. */
76
+ const emptyDistinct = () => encode(new Uint8Array(REGISTER_COUNT));
68
77
  //#endregion
69
- export { addInsightsDistinct, countInsightsDistinct, emptyInsightsDistinct, getInsightsDistinctRegister, mergeInsightsDistinct };
78
+ exports.addDistinct = addDistinct;
79
+ exports.countDistinct = countDistinct;
80
+ exports.distinctRegister = distinctRegister;
81
+ exports.emptyDistinct = emptyDistinct;
82
+ exports.mergeDistinct = mergeDistinct;
@@ -0,0 +1,16 @@
1
+ //#region src/database/distinct.d.ts
2
+ declare const distinctRegister: (identity: string) => {
3
+ index: number;
4
+ rank: number;
5
+ character: string;
6
+ };
7
+ /** The sketch with `identity` added; a missing sketch is the empty one. */
8
+ declare const addDistinct: (summary: string | null | undefined, identity: string) => string;
9
+ /** The union of sketches, register by register. */
10
+ declare const mergeDistinct: (summaries: readonly (string | null | undefined)[]) => string;
11
+ /** The estimated number of distinct values a sketch holds. */
12
+ declare const countDistinct: (summary: string | null | undefined) => number;
13
+ /** A sketch that holds no value. */
14
+ declare const emptyDistinct: () => string;
15
+ //#endregion
16
+ export { addDistinct, countDistinct, distinctRegister, emptyDistinct, mergeDistinct };
@@ -0,0 +1,16 @@
1
+ //#region src/database/distinct.d.ts
2
+ declare const distinctRegister: (identity: string) => {
3
+ index: number;
4
+ rank: number;
5
+ character: string;
6
+ };
7
+ /** The sketch with `identity` added; a missing sketch is the empty one. */
8
+ declare const addDistinct: (summary: string | null | undefined, identity: string) => string;
9
+ /** The union of sketches, register by register. */
10
+ declare const mergeDistinct: (summaries: readonly (string | null | undefined)[]) => string;
11
+ /** The estimated number of distinct values a sketch holds. */
12
+ declare const countDistinct: (summary: string | null | undefined) => number;
13
+ /** A sketch that holds no value. */
14
+ declare const emptyDistinct: () => string;
15
+ //#endregion
16
+ export { addDistinct, countDistinct, distinctRegister, emptyDistinct, mergeDistinct };
@@ -1,4 +1,9 @@
1
- //#region src/insightsDistinctSummary.ts
1
+ //#region src/database/distinct.ts
2
+ /**
3
+ * HyperLogLog sketches, the storage engine's `distinct` aggregate metric: a
4
+ * sketch is 1,024 registers stored as a 1,024-character string, so adding a
5
+ * value, merging sketches, and counting one never need the values back.
6
+ */
2
7
  const PRECISION = 10;
3
8
  const REGISTER_COUNT = 1024;
4
9
  const MAX_RANK = 55;
@@ -13,17 +18,17 @@ const hash = (value) => {
13
18
  const OFFSET = 33;
14
19
  const decode = (summary) => {
15
20
  if (!summary) return new Uint8Array(REGISTER_COUNT);
16
- if (summary.length !== REGISTER_COUNT) throw new Error("Invalid Insights distinct summary");
21
+ if (summary.length !== REGISTER_COUNT) throw new Error("Invalid distinct sketch");
17
22
  const registers = new Uint8Array(REGISTER_COUNT);
18
23
  for (let index = 0; index < REGISTER_COUNT; index += 1) {
19
24
  const value = summary.charCodeAt(index) - OFFSET;
20
- if (!Number.isInteger(value) || value < 0 || value > MAX_RANK) throw new Error("Invalid Insights distinct summary");
25
+ if (!Number.isInteger(value) || value < 0 || value > MAX_RANK) throw new Error("Invalid distinct sketch");
21
26
  registers[index] = value;
22
27
  }
23
28
  return registers;
24
29
  };
25
30
  const encode = (registers) => Array.from(registers, (value) => String.fromCharCode(value + OFFSET)).join("");
26
- const getInsightsDistinctRegister = (identity) => {
31
+ const distinctRegister = (identity) => {
27
32
  const value = hash(identity);
28
33
  const index = Number(value & BigInt(1023));
29
34
  let remainder = value >> BigInt(PRECISION);
@@ -38,13 +43,15 @@ const getInsightsDistinctRegister = (identity) => {
38
43
  character: String.fromCharCode(rank + OFFSET)
39
44
  };
40
45
  };
41
- const addInsightsDistinct = (summary, identity) => {
46
+ /** The sketch with `identity` added; a missing sketch is the empty one. */
47
+ const addDistinct = (summary, identity) => {
42
48
  const registers = decode(summary);
43
- const { index, rank } = getInsightsDistinctRegister(identity);
49
+ const { index, rank } = distinctRegister(identity);
44
50
  registers[index] = Math.max(registers[index], rank);
45
51
  return encode(registers);
46
52
  };
47
- const mergeInsightsDistinct = (summaries) => {
53
+ /** The union of sketches, register by register. */
54
+ const mergeDistinct = (summaries) => {
48
55
  const merged = new Uint8Array(REGISTER_COUNT);
49
56
  for (const summary of summaries) {
50
57
  const registers = decode(summary);
@@ -52,7 +59,8 @@ const mergeInsightsDistinct = (summaries) => {
52
59
  }
53
60
  return encode(merged);
54
61
  };
55
- const countInsightsDistinct = (summary) => {
62
+ /** The estimated number of distinct values a sketch holds. */
63
+ const countDistinct = (summary) => {
56
64
  const registers = decode(summary);
57
65
  let inverseSum = 0;
58
66
  let empty = 0;
@@ -64,10 +72,7 @@ const countInsightsDistinct = (summary) => {
64
72
  const estimate = raw <= 2.5 * REGISTER_COUNT && empty > 0 ? REGISTER_COUNT * Math.log(REGISTER_COUNT / empty) : raw;
65
73
  return Math.max(0, Math.round(estimate));
66
74
  };
67
- const emptyInsightsDistinct = () => encode(new Uint8Array(REGISTER_COUNT));
75
+ /** A sketch that holds no value. */
76
+ const emptyDistinct = () => encode(new Uint8Array(REGISTER_COUNT));
68
77
  //#endregion
69
- exports.addInsightsDistinct = addInsightsDistinct;
70
- exports.countInsightsDistinct = countInsightsDistinct;
71
- exports.emptyInsightsDistinct = emptyInsightsDistinct;
72
- exports.getInsightsDistinctRegister = getInsightsDistinctRegister;
73
- exports.mergeInsightsDistinct = mergeInsightsDistinct;
78
+ export { addDistinct, countDistinct, distinctRegister, emptyDistinct, mergeDistinct };
@@ -85,6 +85,19 @@ const createMemoryAdapter = (options = {}) => {
85
85
  state = draft;
86
86
  return { ok: true };
87
87
  },
88
+ async prune(table, before, limit) {
89
+ const column = table.retention?.column ?? "";
90
+ /** Oldest first; the key breaks a tie. */
91
+ const order = (row) => [row[column], ...require_adapter.rowKey(table, row)];
92
+ const doomed = [...rowsOf(table)].filter(([, row]) => {
93
+ const time = row[column];
94
+ return typeof time === "number" && time <= before;
95
+ }).sort(([, left], [, right]) => require_values.compareTuples(order(left), order(right))).slice(0, limit);
96
+ const rows = new Map(rowsOf(table));
97
+ for (const [id] of doomed) rows.delete(id);
98
+ state = new Map(state).set(prefix + table.name, rows);
99
+ return doomed.length;
100
+ },
88
101
  migrations: { async apply(tables) {
89
102
  const next = new Map(state);
90
103
  for (const table of tables) {
@@ -85,6 +85,19 @@ const createMemoryAdapter = (options = {}) => {
85
85
  state = draft;
86
86
  return { ok: true };
87
87
  },
88
+ async prune(table, before, limit) {
89
+ const column = table.retention?.column ?? "";
90
+ /** Oldest first; the key breaks a tie. */
91
+ const order = (row) => [row[column], ...rowKey(table, row)];
92
+ const doomed = [...rowsOf(table)].filter(([, row]) => {
93
+ const time = row[column];
94
+ return typeof time === "number" && time <= before;
95
+ }).sort(([, left], [, right]) => compareTuples(order(left), order(right))).slice(0, limit);
96
+ const rows = new Map(rowsOf(table));
97
+ for (const [id] of doomed) rows.delete(id);
98
+ state = new Map(state).set(prefix + table.name, rows);
99
+ return doomed.length;
100
+ },
88
101
  migrations: { async apply(tables) {
89
102
  const next = new Map(state);
90
103
  for (const table of tables) {
@@ -114,6 +114,13 @@ const verifyAdapter = (adapter, options = {}) => {
114
114
  }
115
115
  return rows;
116
116
  },
117
+ ...adapter.prune && { async prune(table, before, limit) {
118
+ if (table.retention === void 0) fail(`${table.name} has no retention to prune by.`);
119
+ if (!Number.isSafeInteger(limit) || limit < 1) fail("prune limit must be a positive integer.");
120
+ const deleted = await adapter.prune(table, before, limit);
121
+ if (!Number.isSafeInteger(deleted) || deleted < 0 || deleted > limit) fail(`${table.name} prune reported ${deleted} rows for ${limit}.`);
122
+ return deleted;
123
+ } },
117
124
  async write(ops) {
118
125
  verifyWrite(adapter, ops);
119
126
  const result = await adapter.write(ops);
@@ -114,6 +114,13 @@ const verifyAdapter = (adapter, options = {}) => {
114
114
  }
115
115
  return rows;
116
116
  },
117
+ ...adapter.prune && { async prune(table, before, limit) {
118
+ if (table.retention === void 0) fail(`${table.name} has no retention to prune by.`);
119
+ if (!Number.isSafeInteger(limit) || limit < 1) fail("prune limit must be a positive integer.");
120
+ const deleted = await adapter.prune(table, before, limit);
121
+ if (!Number.isSafeInteger(deleted) || deleted < 0 || deleted > limit) fail(`${table.name} prune reported ${deleted} rows for ${limit}.`);
122
+ return deleted;
123
+ } },
117
124
  async write(ops) {
118
125
  verifyWrite(adapter, ops);
119
126
  const result = await adapter.write(ops);
@@ -33,9 +33,7 @@ const isDatabaseJsonValue = (value) => {
33
33
  };
34
34
  const isDatabaseJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && isDatabaseJsonValue(value);
35
35
  const isDatabaseMetadataObject = (value) => isDatabaseJsonObject(value) && (!Object.hasOwn(value, "app_version") || typeof value["app_version"] === "string");
36
- const isDatabaseBundleEventMetadata = (value) => isDatabaseJsonObject(value) && (value.username === null || typeof value.username === "string") && typeof value.cohort === "string" && (value.update_strategy === null || value.update_strategy === "fingerprint" || value.update_strategy === "appVersion") && (value.fingerprint_hash === null || typeof value.fingerprint_hash === "string") && (value.sdk_version === null || typeof value.sdk_version === "string");
37
36
  //#endregion
38
- exports.isDatabaseBundleEventMetadata = isDatabaseBundleEventMetadata;
39
37
  exports.isDatabaseJsonObject = isDatabaseJsonObject;
40
38
  exports.isDatabaseJsonValue = isDatabaseJsonValue;
41
39
  exports.isDatabaseMetadataObject = isDatabaseMetadataObject;
@@ -1,7 +1,7 @@
1
- import { DatabaseBundleEventMetadata, DatabaseBundleMetadata } from "./types/databaseRows.cjs";
1
+ import { DatabaseBundleMetadata, DatabaseJsonObject } from "./types/databaseRows.cjs";
2
2
  import "./types/index.cjs";
3
3
  //#region src/databaseJsonValue.d.ts
4
+ declare const isDatabaseJsonObject: (value: unknown) => value is DatabaseJsonObject;
4
5
  declare const isDatabaseMetadataObject: (value: unknown) => value is DatabaseBundleMetadata;
5
- declare const isDatabaseBundleEventMetadata: (value: unknown) => value is DatabaseBundleEventMetadata;
6
6
  //#endregion
7
- export { isDatabaseBundleEventMetadata, isDatabaseMetadataObject };
7
+ export { isDatabaseJsonObject, isDatabaseMetadataObject };
@@ -1,7 +1,7 @@
1
- import { DatabaseBundleEventMetadata, DatabaseBundleMetadata } from "./types/databaseRows.mjs";
1
+ import { DatabaseBundleMetadata, DatabaseJsonObject } from "./types/databaseRows.mjs";
2
2
  import "./types/index.mjs";
3
3
  //#region src/databaseJsonValue.d.ts
4
+ declare const isDatabaseJsonObject: (value: unknown) => value is DatabaseJsonObject;
4
5
  declare const isDatabaseMetadataObject: (value: unknown) => value is DatabaseBundleMetadata;
5
- declare const isDatabaseBundleEventMetadata: (value: unknown) => value is DatabaseBundleEventMetadata;
6
6
  //#endregion
7
- export { isDatabaseBundleEventMetadata, isDatabaseMetadataObject };
7
+ export { isDatabaseJsonObject, isDatabaseMetadataObject };
@@ -33,6 +33,5 @@ const isDatabaseJsonValue = (value) => {
33
33
  };
34
34
  const isDatabaseJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && isDatabaseJsonValue(value);
35
35
  const isDatabaseMetadataObject = (value) => isDatabaseJsonObject(value) && (!Object.hasOwn(value, "app_version") || typeof value["app_version"] === "string");
36
- const isDatabaseBundleEventMetadata = (value) => isDatabaseJsonObject(value) && (value.username === null || typeof value.username === "string") && typeof value.cohort === "string" && (value.update_strategy === null || value.update_strategy === "fingerprint" || value.update_strategy === "appVersion") && (value.fingerprint_hash === null || typeof value.fingerprint_hash === "string") && (value.sdk_version === null || typeof value.sdk_version === "string");
37
36
  //#endregion
38
- export { isDatabaseBundleEventMetadata, isDatabaseJsonObject, isDatabaseJsonValue, isDatabaseMetadataObject };
37
+ export { isDatabaseJsonObject, isDatabaseJsonValue, isDatabaseMetadataObject };
package/dist/index.cjs CHANGED
@@ -13,7 +13,6 @@ const require_semverSatisfies = require("./semverSatisfies.cjs");
13
13
  const require_filterCompatibleAppVersions = require("./filterCompatibleAppVersions.cjs");
14
14
  const require_generateMinBundleId = require("./generateMinBundleId.cjs");
15
15
  const require_uuidv7 = require("./uuidv7.cjs");
16
- const require_insightsContract = require("./insightsContract.cjs");
17
16
  const require_releaseCatalogCompiler = require("./releaseCatalogCompiler.cjs");
18
17
  const require_releaseManagement = require("./releaseManagement.cjs");
19
18
  const require_releaseCatalogMutation = require("./releaseCatalogMutation.cjs");
@@ -40,7 +39,6 @@ exports.assertStorageOperations = require_createStoragePlugin.assertStorageOpera
40
39
  exports.bundleToPatchRows = require_databaseRows.bundleToPatchRows;
41
40
  exports.bundleToRow = require_databaseRows.bundleToRow;
42
41
  exports.canonicalizeAppVersion = require_releaseCatalogCompiler.canonicalizeAppVersion;
43
- exports.compareInsightsText = require_insightsContract.compareInsightsText;
44
42
  exports.compileReleaseCatalog = require_releaseCatalogCompiler.compileReleaseCatalog;
45
43
  exports.createBundleSigningHandler = require_remoteBundleSigning.createBundleSigningHandler;
46
44
  exports.createBundleStorageKey = require_bundleStorageLayout.createBundleStorageKey;
@@ -64,9 +62,7 @@ exports.getManifestAssetDownloadPath = require_assetStorageLayout.getManifestAss
64
62
  exports.getManifestAssetStoragePath = require_assetStorageLayout.getManifestAssetStoragePath;
65
63
  exports.isBrotliManifestAssetPath = require_assetStorageLayout.isBrotliManifestAssetPath;
66
64
  exports.isContentAddressedAssetFileHash = require_contentAddressedAssets.isContentAddressedAssetFileHash;
67
- exports.isDatabaseBundleEventMetadata = require_databaseJsonValue.isDatabaseBundleEventMetadata;
68
65
  exports.isDatabaseMetadataObject = require_databaseJsonValue.isDatabaseMetadataObject;
69
- exports.isInsightsMovementEvent = require_insightsContract.isInsightsMovementEvent;
70
66
  exports.isRemoteDatabase = require_databaseConfig.isRemoteDatabase;
71
67
  Object.defineProperty(exports, "isUUIDv7", {
72
68
  enumerable: true,
package/dist/index.d.cts CHANGED
@@ -3,12 +3,11 @@ import { createStorageUriWithRelativePath, getManifestAssetDownloadPath, getMani
3
3
  import { CONTENT_ADDRESSED_ASSET_PREFIX, getContentAddressedAssetStoragePath, isContentAddressedAssetFileHash } from "./contentAddressedAssets.cjs";
4
4
  import { getContentType } from "./contentType.cjs";
5
5
  import { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases } from "./releaseCatalogCompiler.cjs";
6
- import { ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./types/databaseConfig.cjs";
6
+ import { AggregateBatching, ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./types/databaseConfig.cjs";
7
7
  import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./types/utils.cjs";
8
- import { ApiKeyRow, BundleEventRow, BundleEventRowBase, BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleEventMetadata, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
8
+ import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
9
9
  import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./types/databaseOperations.cjs";
10
- import { InsightsBundleEventFilter, InsightsCountEventsInput, InsightsCountLatestEventsInput, InsightsCoverage, InsightsEventCursor, InsightsEventFilter, InsightsFindLatestEventsInput, InsightsGetAppUsageInput, InsightsGetAppUsageResult, InsightsGetReleaseActivityInput, InsightsGetReleaseActivityResult, InsightsListEventsInput, InsightsModel, InsightsRecordEventInput, InsightsScope, InsightsTimeRange, ReleaseActivityMetrics, ReleaseReference } from "./types/insights.cjs";
11
- import { ApiKeyModel, ChannelDeleteResult, ChannelInsertResult } from "./types/models.cjs";
10
+ import { ChannelDeleteResult, ChannelInsertResult } from "./types/models.cjs";
12
11
  import { ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, Bundle, BundleSigningPlugin, ConfigInput, FingerprintExtraSources, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Platform, PlatformConfig, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePlugin, StoragePutInput, StoragePutResult, supportedIosPlatforms } from "./types/index.cjs";
13
12
  import { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope } from "./releaseCatalogMutation.cjs";
14
13
  import { PromoteReleaseResult, ReleaseManagementError, ReleasePolicyPatch } from "./releaseManagement.cjs";
@@ -16,14 +15,13 @@ import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpd
16
15
  import { DatabaseBundleNotFoundError, DatabasePluginInputError, DatabasePluginInputErrorCode, DatabaseRowReferencedError } from "./databaseErrors.cjs";
17
16
  import { createStorageKeyBuilder } from "./createStorageKeyBuilder.cjs";
18
17
  import { CreateStoragePluginOptions, StorageOperation, StoragePluginWith, assertStorageOperations, createStoragePlugin } from "./createStoragePlugin.cjs";
19
- import { isDatabaseBundleEventMetadata, isDatabaseMetadataObject } from "./databaseJsonValue.cjs";
18
+ import { isDatabaseMetadataObject } from "./databaseJsonValue.cjs";
20
19
  import { BundleRowHydrationError, BundleRowHydrationErrorReason, bundleToPatchRows, bundleToRow, releaseRowToRelease, releaseToRow, rowToBundle, rowsToBundles } from "./databaseRows.cjs";
21
20
  import { filterCompatibleAppVersions } from "./filterCompatibleAppVersions.cjs";
22
21
  import { generateMinBundleId } from "./generateMinBundleId.cjs";
23
- import { compareInsightsText, isInsightsMovementEvent } from "./insightsContract.cjs";
24
22
  import { CreateStorageUriInput, ParsedStorageUri, createStorageUri, parseStorageUri } from "./parseStorageUri.cjs";
25
23
  import { BundleSigningHandlerOptions, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, RemoteSigningOptions, createBundleSigningHandler, remoteSigning } from "./remoteBundleSigning.cjs";
26
24
  import { semverSatisfies } from "./semverSatisfies.cjs";
27
25
  import { createStorageDownloadPath, createStorageDownloadUrl, parseStorageDownloadPath } from "./storageDownloadPath.cjs";
28
26
  import { createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, isUUIDv7 } from "./uuidv7.cjs";
29
- export { type ApiKeyModel, type ApiKeyRow, ApplePlatform, BUNDLE_STORAGE_PREFIX, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundleEventRow, type BundleEventRowBase, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningHandlerOptions, BundleSigningPlugin, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, CreateStoragePluginOptions, CreateStorageUriInput, type DatabaseBundleEventMetadata, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, type DatabaseJsonObject, type DatabaseJsonValue, DatabasePluginInputError, type DatabasePluginInputErrorCode, DatabaseRowReferencedError, type DeployReleasePolicy, type Deployment, type EngineDatabase, FingerprintExtraSources, HasMultipleCallSignatures, type HotUpdaterCoreApi, type InsightsBundleEventFilter, type InsightsCountEventsInput, type InsightsCountLatestEventsInput, type InsightsCoverage, type InsightsEventCursor, type InsightsEventFilter, type InsightsFindLatestEventsInput, type InsightsGetAppUsageInput, type InsightsGetAppUsageResult, type InsightsGetReleaseActivityInput, type InsightsGetReleaseActivityResult, type InsightsListEventsInput, type InsightsModel, type InsightsRecordEventInput, type InsightsScope, type InsightsTimeRange, IosBuildDestination, type KeysetInput, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, ParsedStorageUri, type Platform, PlatformConfig, Primitive, PromoteReleaseResult, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, type ReleaseActivityMetrics, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseReference, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RemoteSigningOptions, RequiredDeep, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePlugin, StoragePluginWith, StoragePutInput, StoragePutResult, type StoredBundleDeployment, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareInsightsText, compileReleaseCatalog, createBundleSigningHandler, createBundleStorageKey, createStorageDownloadPath, createStorageDownloadUrl, createStorageKeyBuilder, createStoragePlugin, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBundleEventMetadata, isDatabaseMetadataObject, isInsightsMovementEvent, isRemoteDatabase, isUUIDv7, parseStorageDownloadPath, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowToBundle, rowsToBundles, semverSatisfies, supportedIosPlatforms };
27
+ export { type AggregateBatching, ApplePlatform, BUNDLE_STORAGE_PREFIX, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningHandlerOptions, BundleSigningPlugin, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, CreateStoragePluginOptions, CreateStorageUriInput, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, type DatabaseJsonObject, type DatabaseJsonValue, DatabasePluginInputError, type DatabasePluginInputErrorCode, DatabaseRowReferencedError, type DeployReleasePolicy, type Deployment, type EngineDatabase, FingerprintExtraSources, HasMultipleCallSignatures, type HotUpdaterCoreApi, IosBuildDestination, type KeysetInput, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, ParsedStorageUri, type Platform, PlatformConfig, Primitive, PromoteReleaseResult, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RemoteSigningOptions, RequiredDeep, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePlugin, StoragePluginWith, StoragePutInput, StoragePutResult, type StoredBundleDeployment, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compileReleaseCatalog, createBundleSigningHandler, createBundleStorageKey, createStorageDownloadPath, createStorageDownloadUrl, createStorageKeyBuilder, createStoragePlugin, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseMetadataObject, isRemoteDatabase, isUUIDv7, parseStorageDownloadPath, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowToBundle, rowsToBundles, semverSatisfies, supportedIosPlatforms };
package/dist/index.d.mts CHANGED
@@ -3,12 +3,11 @@ import { createStorageUriWithRelativePath, getManifestAssetDownloadPath, getMani
3
3
  import { CONTENT_ADDRESSED_ASSET_PREFIX, getContentAddressedAssetStoragePath, isContentAddressedAssetFileHash } from "./contentAddressedAssets.mjs";
4
4
  import { getContentType } from "./contentType.mjs";
5
5
  import { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases } from "./releaseCatalogCompiler.mjs";
6
- import { ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./types/databaseConfig.mjs";
6
+ import { AggregateBatching, ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./types/databaseConfig.mjs";
7
7
  import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./types/utils.mjs";
8
- import { ApiKeyRow, BundleEventRow, BundleEventRowBase, BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleEventMetadata, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
8
+ import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
9
9
  import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./types/databaseOperations.mjs";
10
- import { InsightsBundleEventFilter, InsightsCountEventsInput, InsightsCountLatestEventsInput, InsightsCoverage, InsightsEventCursor, InsightsEventFilter, InsightsFindLatestEventsInput, InsightsGetAppUsageInput, InsightsGetAppUsageResult, InsightsGetReleaseActivityInput, InsightsGetReleaseActivityResult, InsightsListEventsInput, InsightsModel, InsightsRecordEventInput, InsightsScope, InsightsTimeRange, ReleaseActivityMetrics, ReleaseReference } from "./types/insights.mjs";
11
- import { ApiKeyModel, ChannelDeleteResult, ChannelInsertResult } from "./types/models.mjs";
10
+ import { ChannelDeleteResult, ChannelInsertResult } from "./types/models.mjs";
12
11
  import { ApplePlatform, BasePluginArgs, BuildPlugin, BuildPluginConfig, Bundle, BundleSigningPlugin, ConfigInput, FingerprintExtraSources, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, Platform, PlatformConfig, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePlugin, StoragePutInput, StoragePutResult, supportedIosPlatforms } from "./types/index.mjs";
13
12
  import { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope } from "./releaseCatalogMutation.mjs";
14
13
  import { PromoteReleaseResult, ReleaseManagementError, ReleasePolicyPatch } from "./releaseManagement.mjs";
@@ -16,14 +15,13 @@ import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpd
16
15
  import { DatabaseBundleNotFoundError, DatabasePluginInputError, DatabasePluginInputErrorCode, DatabaseRowReferencedError } from "./databaseErrors.mjs";
17
16
  import { createStorageKeyBuilder } from "./createStorageKeyBuilder.mjs";
18
17
  import { CreateStoragePluginOptions, StorageOperation, StoragePluginWith, assertStorageOperations, createStoragePlugin } from "./createStoragePlugin.mjs";
19
- import { isDatabaseBundleEventMetadata, isDatabaseMetadataObject } from "./databaseJsonValue.mjs";
18
+ import { isDatabaseMetadataObject } from "./databaseJsonValue.mjs";
20
19
  import { BundleRowHydrationError, BundleRowHydrationErrorReason, bundleToPatchRows, bundleToRow, releaseRowToRelease, releaseToRow, rowToBundle, rowsToBundles } from "./databaseRows.mjs";
21
20
  import { filterCompatibleAppVersions } from "./filterCompatibleAppVersions.mjs";
22
21
  import { generateMinBundleId } from "./generateMinBundleId.mjs";
23
- import { compareInsightsText, isInsightsMovementEvent } from "./insightsContract.mjs";
24
22
  import { CreateStorageUriInput, ParsedStorageUri, createStorageUri, parseStorageUri } from "./parseStorageUri.mjs";
25
23
  import { BundleSigningHandlerOptions, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, RemoteSigningOptions, createBundleSigningHandler, remoteSigning } from "./remoteBundleSigning.mjs";
26
24
  import { semverSatisfies } from "./semverSatisfies.mjs";
27
25
  import { createStorageDownloadPath, createStorageDownloadUrl, parseStorageDownloadPath } from "./storageDownloadPath.mjs";
28
26
  import { createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, isUUIDv7 } from "./uuidv7.mjs";
29
- export { type ApiKeyModel, type ApiKeyRow, ApplePlatform, BUNDLE_STORAGE_PREFIX, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundleEventRow, type BundleEventRowBase, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningHandlerOptions, BundleSigningPlugin, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, CreateStoragePluginOptions, CreateStorageUriInput, type DatabaseBundleEventMetadata, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, type DatabaseJsonObject, type DatabaseJsonValue, DatabasePluginInputError, type DatabasePluginInputErrorCode, DatabaseRowReferencedError, type DeployReleasePolicy, type Deployment, type EngineDatabase, FingerprintExtraSources, HasMultipleCallSignatures, type HotUpdaterCoreApi, type InsightsBundleEventFilter, type InsightsCountEventsInput, type InsightsCountLatestEventsInput, type InsightsCoverage, type InsightsEventCursor, type InsightsEventFilter, type InsightsFindLatestEventsInput, type InsightsGetAppUsageInput, type InsightsGetAppUsageResult, type InsightsGetReleaseActivityInput, type InsightsGetReleaseActivityResult, type InsightsListEventsInput, type InsightsModel, type InsightsRecordEventInput, type InsightsScope, type InsightsTimeRange, IosBuildDestination, type KeysetInput, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, ParsedStorageUri, type Platform, PlatformConfig, Primitive, PromoteReleaseResult, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, type ReleaseActivityMetrics, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseReference, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RemoteSigningOptions, RequiredDeep, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePlugin, StoragePluginWith, StoragePutInput, StoragePutResult, type StoredBundleDeployment, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareInsightsText, compileReleaseCatalog, createBundleSigningHandler, createBundleStorageKey, createStorageDownloadPath, createStorageDownloadUrl, createStorageKeyBuilder, createStoragePlugin, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBundleEventMetadata, isDatabaseMetadataObject, isInsightsMovementEvent, isRemoteDatabase, isUUIDv7, parseStorageDownloadPath, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowToBundle, rowsToBundles, semverSatisfies, supportedIosPlatforms };
27
+ export { type AggregateBatching, ApplePlatform, BUNDLE_STORAGE_PREFIX, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningHandlerOptions, BundleSigningPlugin, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, CreateStoragePluginOptions, CreateStorageUriInput, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, type DatabaseJsonObject, type DatabaseJsonValue, DatabasePluginInputError, type DatabasePluginInputErrorCode, DatabaseRowReferencedError, type DeployReleasePolicy, type Deployment, type EngineDatabase, FingerprintExtraSources, HasMultipleCallSignatures, type HotUpdaterCoreApi, IosBuildDestination, type KeysetInput, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, ParsedStorageUri, type Platform, PlatformConfig, Primitive, PromoteReleaseResult, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RemoteSigningOptions, RequiredDeep, SigningConfig, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePlugin, StoragePluginWith, StoragePutInput, StoragePutResult, type StoredBundleDeployment, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compileReleaseCatalog, createBundleSigningHandler, createBundleStorageKey, createStorageDownloadPath, createStorageDownloadUrl, createStorageKeyBuilder, createStoragePlugin, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseMetadataObject, isRemoteDatabase, isUUIDv7, parseStorageDownloadPath, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowToBundle, rowsToBundles, semverSatisfies, supportedIosPlatforms };