@hot-updater/plugin-core 1.0.0-rc.17 → 1.0.0-rc.21
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 +33 -0
- package/dist/baseCandidateKey.cjs +50 -0
- package/dist/baseCandidateKey.d.cts +27 -0
- package/dist/baseCandidateKey.d.mts +27 -0
- package/dist/baseCandidateKey.mjs +49 -0
- package/dist/createStorageAdapter.cjs +8 -0
- package/dist/createStorageAdapter.d.cts +9 -0
- package/dist/createStorageAdapter.d.mts +9 -0
- package/dist/createStorageAdapter.mjs +7 -0
- package/dist/database/adapter.cjs +20 -5
- package/dist/database/adapter.d.cts +25 -8
- package/dist/database/adapter.d.mts +25 -8
- package/dist/database/adapter.mjs +21 -4
- package/dist/database/distinct.cjs +12 -6
- package/dist/database/distinct.d.cts +13 -11
- package/dist/database/distinct.d.mts +13 -11
- package/dist/database/distinct.mjs +13 -6
- package/dist/database/memoryAdapter.cjs +2 -10
- package/dist/database/memoryAdapter.d.cts +2 -4
- package/dist/database/memoryAdapter.d.mts +2 -4
- package/dist/database/memoryAdapter.mjs +2 -10
- package/dist/database/values.cjs +5 -1
- package/dist/database/values.d.cts +8 -21
- package/dist/database/values.d.mts +8 -21
- package/dist/database/values.mjs +5 -1
- package/dist/database/verifyAdapter.cjs +1 -0
- package/dist/database/verifyAdapter.d.cts +8 -0
- package/dist/database/verifyAdapter.d.mts +8 -0
- package/dist/database/verifyAdapter.mjs +1 -0
- package/dist/databaseErrors.cjs +4 -4
- package/dist/databaseErrors.d.cts +6 -6
- package/dist/databaseErrors.d.mts +6 -6
- package/dist/databaseErrors.mjs +4 -4
- package/dist/databaseJsonValue.cjs +6 -0
- package/dist/databaseJsonValue.d.cts +6 -0
- package/dist/databaseJsonValue.d.mts +6 -0
- package/dist/databaseJsonValue.mjs +6 -0
- package/dist/databaseMetadata.cjs +3 -3
- package/dist/databaseMetadata.mjs +3 -3
- package/dist/databaseRows.cjs +6 -6
- package/dist/databaseRows.d.cts +1 -1
- package/dist/databaseRows.d.mts +1 -1
- package/dist/databaseRows.mjs +1 -1
- package/dist/engine/core/schema.cjs +279 -0
- package/dist/engine/core/schema.d.cts +312 -0
- package/dist/engine/core/schema.d.mts +312 -0
- package/dist/engine/core/schema.mjs +277 -0
- package/dist/engine/createEngine.cjs +72 -0
- package/dist/engine/createEngine.d.cts +45 -0
- package/dist/engine/createEngine.d.mts +45 -0
- package/dist/engine/createEngine.mjs +72 -0
- package/dist/engine/database/aggregateBatching.cjs +627 -0
- package/dist/engine/database/aggregateBatching.mjs +626 -0
- package/dist/engine/database/cursor.cjs +42 -0
- package/dist/engine/database/cursor.mjs +38 -0
- package/dist/engine/database/database.cjs +68 -0
- package/dist/engine/database/database.mjs +68 -0
- package/dist/engine/database/engine.cjs +37 -0
- package/dist/engine/database/engine.mjs +37 -0
- package/dist/engine/database/engineAggregates.cjs +120 -0
- package/dist/engine/database/engineAggregates.mjs +117 -0
- package/dist/engine/database/engineReads.cjs +182 -0
- package/dist/engine/database/engineReads.d.cts +10 -0
- package/dist/engine/database/engineReads.d.mts +10 -0
- package/dist/engine/database/engineReads.mjs +181 -0
- package/dist/engine/database/engineTransaction.cjs +399 -0
- package/dist/engine/database/engineTransaction.d.cts +18 -0
- package/dist/engine/database/engineTransaction.d.mts +18 -0
- package/dist/engine/database/engineTransaction.mjs +398 -0
- package/dist/engine/database/fence.cjs +156 -0
- package/dist/engine/database/fence.d.cts +41 -0
- package/dist/engine/database/fence.d.mts +41 -0
- package/dist/engine/database/fence.mjs +149 -0
- package/dist/engine/database/kv/kvAdapter.cjs +293 -0
- package/dist/engine/database/kv/kvAdapter.d.cts +116 -0
- package/dist/engine/database/kv/kvAdapter.d.mts +116 -0
- package/dist/engine/database/kv/kvAdapter.mjs +292 -0
- package/dist/engine/database/readMeter.cjs +80 -0
- package/dist/engine/database/readMeter.d.cts +34 -0
- package/dist/engine/database/readMeter.d.mts +34 -0
- package/dist/engine/database/readMeter.mjs +79 -0
- package/dist/engine/database/resolveSchema.cjs +197 -0
- package/dist/engine/database/resolveSchema.d.cts +35 -0
- package/dist/engine/database/resolveSchema.d.mts +35 -0
- package/dist/engine/database/resolveSchema.mjs +195 -0
- package/dist/engine/database/retention.cjs +100 -0
- package/dist/engine/database/retention.mjs +98 -0
- package/dist/engine/database/sql/sqlAdapter.cjs +290 -0
- package/dist/engine/database/sql/sqlAdapter.d.cts +45 -0
- package/dist/engine/database/sql/sqlAdapter.d.mts +45 -0
- package/dist/engine/database/sql/sqlAdapter.mjs +288 -0
- package/dist/engine/database/sql/sqlSchema.cjs +175 -0
- package/dist/engine/database/sql/sqlSchema.d.cts +45 -0
- package/dist/engine/database/sql/sqlSchema.d.mts +45 -0
- package/dist/engine/database/sql/sqlSchema.mjs +169 -0
- package/dist/engine/db/coreDatabase.cjs +94 -0
- package/dist/engine/db/coreDatabase.d.cts +78 -0
- package/dist/engine/db/coreDatabase.d.mts +78 -0
- package/dist/engine/db/coreDatabase.mjs +86 -0
- package/dist/engine/db/engineMigrator.cjs +53 -0
- package/dist/engine/db/engineMigrator.mjs +53 -0
- package/dist/engine/db/engineSql.cjs +26 -0
- package/dist/engine/db/engineSql.d.cts +16 -0
- package/dist/engine/db/engineSql.d.mts +16 -0
- package/dist/engine/db/engineSql.mjs +25 -0
- package/dist/engine/db/engineSqlMigrator.cjs +67 -0
- package/dist/engine/db/engineSqlMigrator.d.cts +21 -0
- package/dist/engine/db/engineSqlMigrator.d.mts +21 -0
- package/dist/engine/db/engineSqlMigrator.mjs +67 -0
- package/dist/engine/db/fixedMigratorShared.cjs +12 -0
- package/dist/engine/db/fixedMigratorShared.mjs +11 -0
- package/dist/engine/db/schemaSettings.cjs +63 -0
- package/dist/engine/db/schemaSettings.d.cts +7 -0
- package/dist/engine/db/schemaSettings.d.mts +7 -0
- package/dist/engine/db/schemaSettings.mjs +62 -0
- package/dist/engine/db/settingsMigrator.cjs +94 -0
- package/dist/engine/db/settingsMigrator.d.cts +25 -0
- package/dist/engine/db/settingsMigrator.d.mts +25 -0
- package/dist/engine/db/settingsMigrator.mjs +91 -0
- package/dist/engine/db/types.d.cts +78 -0
- package/dist/engine/db/types.d.mts +78 -0
- package/dist/index.cjs +86 -7
- package/dist/index.d.cts +36 -6
- package/dist/index.d.mts +36 -6
- package/dist/index.mjs +26 -4
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.cjs +0 -5
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.mjs +1 -5
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.cjs +8 -0
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.mjs +9 -2
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.cjs +4 -0
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.mjs +4 -1
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.cjs +0 -5
- package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.mjs +2 -6
- package/dist/releaseCatalogCompiler.cjs +26 -25
- package/dist/releaseCatalogCompiler.d.cts +1 -2
- package/dist/releaseCatalogCompiler.d.mts +2 -3
- package/dist/releaseCatalogCompiler.mjs +3 -7
- package/dist/remoteBundleSigning.d.cts +2 -2
- package/dist/remoteBundleSigning.d.mts +2 -2
- package/dist/serverPlugin/busy.cjs +36 -0
- package/dist/serverPlugin/busy.d.cts +12 -0
- package/dist/serverPlugin/busy.d.mts +12 -0
- package/dist/serverPlugin/busy.mjs +36 -0
- package/dist/serverPlugin/configError.cjs +7 -0
- package/dist/serverPlugin/configError.d.cts +7 -0
- package/dist/serverPlugin/configError.d.mts +7 -0
- package/dist/serverPlugin/configError.mjs +7 -0
- package/dist/serverPlugin/coreReads.d.cts +48 -0
- package/dist/serverPlugin/coreReads.d.mts +48 -0
- package/dist/serverPlugin/databaseHandle.d.cts +105 -0
- package/dist/serverPlugin/databaseHandle.d.mts +105 -0
- package/dist/serverPlugin/definePlugin.cjs +5 -0
- package/dist/serverPlugin/definePlugin.d.cts +130 -0
- package/dist/serverPlugin/definePlugin.d.mts +130 -0
- package/dist/serverPlugin/definePlugin.mjs +5 -0
- package/dist/serverPlugin/definitions.d.cts +76 -0
- package/dist/serverPlugin/definitions.d.mts +76 -0
- package/dist/serverPlugin/errors.cjs +37 -0
- package/dist/serverPlugin/errors.d.cts +29 -0
- package/dist/serverPlugin/errors.d.mts +29 -0
- package/dist/serverPlugin/errors.mjs +32 -0
- package/dist/serverPlugin/schema.cjs +24 -0
- package/dist/serverPlugin/schema.d.cts +90 -0
- package/dist/serverPlugin/schema.d.mts +90 -0
- package/dist/serverPlugin/schema.mjs +23 -0
- package/dist/types/databaseConfig.cjs +1 -1
- package/dist/types/databaseConfig.d.cts +8 -1
- package/dist/types/databaseConfig.d.mts +8 -1
- package/dist/types/databaseConfig.mjs +1 -1
- package/dist/types/databaseRows.d.cts +1 -1
- package/dist/types/databaseRows.d.mts +1 -1
- package/dist/types/index.d.cts +26 -14
- package/dist/types/index.d.mts +26 -14
- package/dist/types/public.d.cts +1 -1
- package/dist/types/public.d.mts +1 -1
- package/dist/uuidv7.cjs +3 -3
- package/dist/uuidv7.d.cts +1 -1
- package/dist/uuidv7.d.mts +1 -1
- package/dist/uuidv7.mjs +1 -1
- package/package.json +10 -7
- package/dist/createStoragePlugin.cjs +0 -8
- package/dist/createStoragePlugin.d.cts +0 -9
- package/dist/createStoragePlugin.d.mts +0 -9
- package/dist/createStoragePlugin.mjs +0 -7
- package/dist/internal.cjs +0 -38
- package/dist/internal.d.cts +0 -12
- package/dist/internal.d.mts +0 -12
- package/dist/internal.mjs +0 -8
- package/dist/types/internal.d.cts +0 -4
- package/dist/types/internal.d.mts +0 -4
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { DatabaseAdapter } from "./adapter.mjs";
|
|
2
2
|
//#region src/database/memoryAdapter.d.ts
|
|
3
|
+
/** `createMemoryAdapter`'s options. */
|
|
3
4
|
interface MemoryAdapterOptions {
|
|
5
|
+
/** Prefixes every table's name, so several servers can share one store. */
|
|
4
6
|
readonly tablePrefix?: string;
|
|
5
|
-
/** Test-only: the most ops `fits()` accepts. */
|
|
6
|
-
readonly maxOps?: number;
|
|
7
|
-
/** Test-only: rows per internal page, so `query` has to loop pages. */
|
|
8
|
-
readonly nativePageSize?: number;
|
|
9
7
|
}
|
|
10
8
|
/**
|
|
11
9
|
* The reference adapter: every read is a consistent snapshot and every write
|
|
@@ -47,7 +47,7 @@ const createMemoryAdapter = (options = {}) => {
|
|
|
47
47
|
const rowsOf = (table) => state.get(prefix + table.name) ?? /* @__PURE__ */ new Map();
|
|
48
48
|
return {
|
|
49
49
|
id: "memory",
|
|
50
|
-
fits: (
|
|
50
|
+
fits: () => true,
|
|
51
51
|
async get(table, keys) {
|
|
52
52
|
const rows = rowsOf(table);
|
|
53
53
|
return keys.map((key) => {
|
|
@@ -58,15 +58,7 @@ const createMemoryAdapter = (options = {}) => {
|
|
|
58
58
|
async query(table, request) {
|
|
59
59
|
const index = findPhysicalIndex(table, request.index);
|
|
60
60
|
const direction = request.order === "asc" ? 1 : -1;
|
|
61
|
-
|
|
62
|
-
const pageSize = options.nativePageSize ?? request.limit;
|
|
63
|
-
const rows = [];
|
|
64
|
-
while (rows.length < request.limit) {
|
|
65
|
-
const page = ordered.slice(rows.length, rows.length + Math.min(pageSize, request.limit - rows.length));
|
|
66
|
-
if (page.length === 0) break;
|
|
67
|
-
rows.push(...page);
|
|
68
|
-
}
|
|
69
|
-
return rows.map((row) => structuredClone(row));
|
|
61
|
+
return [...rowsOf(table).values()].filter((row) => matchesQuery(table, index, request, row)).sort((left, right) => direction * compareTuples(indexOrderTuple(table, index, left), indexOrderTuple(table, index, right))).slice(0, request.limit).map((row) => structuredClone(row));
|
|
70
62
|
},
|
|
71
63
|
async write(ops) {
|
|
72
64
|
const draft = new Map(state);
|
package/dist/database/values.cjs
CHANGED
|
@@ -3,7 +3,11 @@ const require_adapter = require("./adapter.cjs");
|
|
|
3
3
|
var DatabaseValueError = class extends Error {
|
|
4
4
|
name = "DatabaseValueError";
|
|
5
5
|
};
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Compares strings in UTF-8 byte order, which is Unicode code point order:
|
|
8
|
+
* the order the engine sorts string keys in. A plugin that merges rows from
|
|
9
|
+
* several reads, as Insights does, keeps that order with it.
|
|
10
|
+
*/
|
|
7
11
|
const compareUtf8 = (left, right) => {
|
|
8
12
|
let leftIndex = 0;
|
|
9
13
|
let rightIndex = 0;
|
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PhysicalTable, StoredRow } from "./adapter.cjs";
|
|
2
2
|
//#region src/database/values.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Compares strings in UTF-8 byte order, which is Unicode code point order:
|
|
5
|
+
* the order the engine sorts string keys in. A plugin that merges rows from
|
|
6
|
+
* several reads, as Insights does, keeps that order with it.
|
|
7
|
+
*/
|
|
7
8
|
declare const compareUtf8: (left: string, right: string) => number;
|
|
8
|
-
/**
|
|
9
|
-
declare const compareKeyValues: (left: DatabaseKeyValue, right: DatabaseKeyValue) => number;
|
|
10
|
-
/** Compares tuples element by element; a shorter equal prefix sorts first. */
|
|
11
|
-
declare const compareTuples: (left: readonly DatabaseKeyValue[], right: readonly DatabaseKeyValue[]) => number;
|
|
12
|
-
/** JSON text with object keys sorted, so a value compares equal after a store reorders map keys. */
|
|
13
|
-
declare const canonicalJson: (value: DatabaseValue | undefined) => string;
|
|
14
|
-
declare const isKeyValue: (value: unknown) => value is DatabaseKeyValue;
|
|
15
|
-
/** Every `eq` tuple a row is indexed under; none when an index field is null. */
|
|
16
|
-
declare const indexEntries: (table: PhysicalTable, index: PhysicalIndex, row: StoredRow) => readonly DatabaseKey[];
|
|
17
|
-
/** The row's position in an index read, following `indexOrderColumns`. */
|
|
18
|
-
declare const indexOrderTuple: (table: PhysicalTable, index: PhysicalIndex, row: StoredRow) => DatabaseKey;
|
|
19
|
-
/** Whether a stored row belongs to the result range of a query. */
|
|
20
|
-
declare const matchesQuery: (table: PhysicalTable, index: PhysicalIndex, request: QueryRequest, row: StoredRow) => boolean;
|
|
9
|
+
/** `normalizeStoredRow`'s options. */
|
|
21
10
|
interface NormalizeOptions {
|
|
22
11
|
/** The backend returns JSON and multi-valued columns as text. */
|
|
23
12
|
readonly jsonText: boolean;
|
|
24
13
|
}
|
|
25
|
-
/** Converts a backend value (int8 text, BigInt, Decimal, 0/1, JSON text) to a stored value. */
|
|
26
|
-
declare const normalizeStoredValue: (column: PhysicalColumn, raw: unknown, options: NormalizeOptions) => DatabaseValue;
|
|
27
14
|
/** Converts every column of a backend row; unknown backend columns are dropped. */
|
|
28
15
|
declare const normalizeStoredRow: (table: PhysicalTable, raw: Readonly<Record<string, unknown>>, options: NormalizeOptions) => StoredRow;
|
|
29
16
|
//#endregion
|
|
30
|
-
export {
|
|
17
|
+
export { NormalizeOptions, compareUtf8, normalizeStoredRow };
|
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PhysicalTable, StoredRow } from "./adapter.mjs";
|
|
2
2
|
//#region src/database/values.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Compares strings in UTF-8 byte order, which is Unicode code point order:
|
|
5
|
+
* the order the engine sorts string keys in. A plugin that merges rows from
|
|
6
|
+
* several reads, as Insights does, keeps that order with it.
|
|
7
|
+
*/
|
|
7
8
|
declare const compareUtf8: (left: string, right: string) => number;
|
|
8
|
-
/**
|
|
9
|
-
declare const compareKeyValues: (left: DatabaseKeyValue, right: DatabaseKeyValue) => number;
|
|
10
|
-
/** Compares tuples element by element; a shorter equal prefix sorts first. */
|
|
11
|
-
declare const compareTuples: (left: readonly DatabaseKeyValue[], right: readonly DatabaseKeyValue[]) => number;
|
|
12
|
-
/** JSON text with object keys sorted, so a value compares equal after a store reorders map keys. */
|
|
13
|
-
declare const canonicalJson: (value: DatabaseValue | undefined) => string;
|
|
14
|
-
declare const isKeyValue: (value: unknown) => value is DatabaseKeyValue;
|
|
15
|
-
/** Every `eq` tuple a row is indexed under; none when an index field is null. */
|
|
16
|
-
declare const indexEntries: (table: PhysicalTable, index: PhysicalIndex, row: StoredRow) => readonly DatabaseKey[];
|
|
17
|
-
/** The row's position in an index read, following `indexOrderColumns`. */
|
|
18
|
-
declare const indexOrderTuple: (table: PhysicalTable, index: PhysicalIndex, row: StoredRow) => DatabaseKey;
|
|
19
|
-
/** Whether a stored row belongs to the result range of a query. */
|
|
20
|
-
declare const matchesQuery: (table: PhysicalTable, index: PhysicalIndex, request: QueryRequest, row: StoredRow) => boolean;
|
|
9
|
+
/** `normalizeStoredRow`'s options. */
|
|
21
10
|
interface NormalizeOptions {
|
|
22
11
|
/** The backend returns JSON and multi-valued columns as text. */
|
|
23
12
|
readonly jsonText: boolean;
|
|
24
13
|
}
|
|
25
|
-
/** Converts a backend value (int8 text, BigInt, Decimal, 0/1, JSON text) to a stored value. */
|
|
26
|
-
declare const normalizeStoredValue: (column: PhysicalColumn, raw: unknown, options: NormalizeOptions) => DatabaseValue;
|
|
27
14
|
/** Converts every column of a backend row; unknown backend columns are dropped. */
|
|
28
15
|
declare const normalizeStoredRow: (table: PhysicalTable, raw: Readonly<Record<string, unknown>>, options: NormalizeOptions) => StoredRow;
|
|
29
16
|
//#endregion
|
|
30
|
-
export {
|
|
17
|
+
export { NormalizeOptions, compareUtf8, normalizeStoredRow };
|
package/dist/database/values.mjs
CHANGED
|
@@ -3,7 +3,11 @@ import { findPhysicalColumn, indexOrderColumns } from "./adapter.mjs";
|
|
|
3
3
|
var DatabaseValueError = class extends Error {
|
|
4
4
|
name = "DatabaseValueError";
|
|
5
5
|
};
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Compares strings in UTF-8 byte order, which is Unicode code point order:
|
|
8
|
+
* the order the engine sorts string keys in. A plugin that merges rows from
|
|
9
|
+
* several reads, as Insights does, keeps that order with it.
|
|
10
|
+
*/
|
|
7
11
|
const compareUtf8 = (left, right) => {
|
|
8
12
|
let leftIndex = 0;
|
|
9
13
|
let rightIndex = 0;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_adapter = require("./adapter.cjs");
|
|
2
2
|
const require_values = require("./values.cjs");
|
|
3
3
|
//#region src/database/verifyAdapter.ts
|
|
4
|
+
/** What `verifyAdapter` throws when an adapter call breaks the adapter contract. */
|
|
4
5
|
var DatabaseAdapterContractError = class extends Error {
|
|
5
6
|
name = "DatabaseAdapterContractError";
|
|
6
7
|
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { DatabaseAdapter } from "./adapter.cjs";
|
|
2
2
|
//#region src/database/verifyAdapter.d.ts
|
|
3
|
+
/** What `verifyAdapter` throws when an adapter call breaks the adapter contract. */
|
|
3
4
|
declare class DatabaseAdapterContractError extends Error {
|
|
4
5
|
readonly name = "DatabaseAdapterContractError";
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Reads at the adapter, as `verifyAdapter` and `meterReads` count them:
|
|
9
|
+
* what a store that bills by read charges for.
|
|
10
|
+
*/
|
|
6
11
|
interface DatabaseReadCount {
|
|
7
12
|
/** `get` calls and the keys they asked for, found or not. */
|
|
8
13
|
readonly gets: number;
|
|
@@ -11,14 +16,17 @@ interface DatabaseReadCount {
|
|
|
11
16
|
readonly queries: number;
|
|
12
17
|
readonly rows: number;
|
|
13
18
|
}
|
|
19
|
+
/** The read count of a `verifyAdapter` adapter, in total and by table. */
|
|
14
20
|
interface DatabaseReadMeter {
|
|
15
21
|
total(): DatabaseReadCount;
|
|
16
22
|
byTable(table: string): DatabaseReadCount;
|
|
17
23
|
reset(): void;
|
|
18
24
|
}
|
|
25
|
+
/** The adapter `verifyAdapter` returns, with its reads counted. */
|
|
19
26
|
interface VerifiedDatabaseAdapter extends DatabaseAdapter {
|
|
20
27
|
readonly reads: DatabaseReadMeter;
|
|
21
28
|
}
|
|
29
|
+
/** `verifyAdapter`'s options. */
|
|
22
30
|
interface VerifyAdapterOptions {
|
|
23
31
|
/** After a short page, probe once past its last row to prove the range ended. */
|
|
24
32
|
readonly probeShortPages?: boolean;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { DatabaseAdapter } from "./adapter.mjs";
|
|
2
2
|
//#region src/database/verifyAdapter.d.ts
|
|
3
|
+
/** What `verifyAdapter` throws when an adapter call breaks the adapter contract. */
|
|
3
4
|
declare class DatabaseAdapterContractError extends Error {
|
|
4
5
|
readonly name = "DatabaseAdapterContractError";
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Reads at the adapter, as `verifyAdapter` and `meterReads` count them:
|
|
9
|
+
* what a store that bills by read charges for.
|
|
10
|
+
*/
|
|
6
11
|
interface DatabaseReadCount {
|
|
7
12
|
/** `get` calls and the keys they asked for, found or not. */
|
|
8
13
|
readonly gets: number;
|
|
@@ -11,14 +16,17 @@ interface DatabaseReadCount {
|
|
|
11
16
|
readonly queries: number;
|
|
12
17
|
readonly rows: number;
|
|
13
18
|
}
|
|
19
|
+
/** The read count of a `verifyAdapter` adapter, in total and by table. */
|
|
14
20
|
interface DatabaseReadMeter {
|
|
15
21
|
total(): DatabaseReadCount;
|
|
16
22
|
byTable(table: string): DatabaseReadCount;
|
|
17
23
|
reset(): void;
|
|
18
24
|
}
|
|
25
|
+
/** The adapter `verifyAdapter` returns, with its reads counted. */
|
|
19
26
|
interface VerifiedDatabaseAdapter extends DatabaseAdapter {
|
|
20
27
|
readonly reads: DatabaseReadMeter;
|
|
21
28
|
}
|
|
29
|
+
/** `verifyAdapter`'s options. */
|
|
22
30
|
interface VerifyAdapterOptions {
|
|
23
31
|
/** After a short page, probe once past its last row to prove the range ended. */
|
|
24
32
|
readonly probeShortPages?: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { findPhysicalIndex, rowKey } from "./adapter.mjs";
|
|
2
2
|
import { compareTuples, indexOrderTuple, isKeyValue, matchesQuery } from "./values.mjs";
|
|
3
3
|
//#region src/database/verifyAdapter.ts
|
|
4
|
+
/** What `verifyAdapter` throws when an adapter call breaks the adapter contract. */
|
|
4
5
|
var DatabaseAdapterContractError = class extends Error {
|
|
5
6
|
name = "DatabaseAdapterContractError";
|
|
6
7
|
};
|
package/dist/databaseErrors.cjs
CHANGED
|
@@ -16,15 +16,15 @@ var DatabaseRowReferencedError = class extends Error {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
/** Input a database operation refuses before touching storage. */
|
|
19
|
-
var
|
|
19
|
+
var DatabaseAdapterInputError = class extends Error {
|
|
20
20
|
code;
|
|
21
|
-
name = "
|
|
21
|
+
name = "DatabaseAdapterInputError";
|
|
22
22
|
constructor(code) {
|
|
23
|
-
super(`Invalid database
|
|
23
|
+
super(`Invalid database adapter input: ${code}`);
|
|
24
24
|
this.code = code;
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
//#endregion
|
|
28
|
+
exports.DatabaseAdapterInputError = DatabaseAdapterInputError;
|
|
28
29
|
exports.DatabaseBundleNotFoundError = DatabaseBundleNotFoundError;
|
|
29
|
-
exports.DatabasePluginInputError = DatabasePluginInputError;
|
|
30
30
|
exports.DatabaseRowReferencedError = DatabaseRowReferencedError;
|
|
@@ -10,12 +10,12 @@ declare class DatabaseRowReferencedError extends Error {
|
|
|
10
10
|
readonly name = "DatabaseRowReferencedError";
|
|
11
11
|
constructor();
|
|
12
12
|
}
|
|
13
|
-
type
|
|
13
|
+
type DatabaseAdapterInputErrorCode = "invalid-data" | "invalid-field" | "invalid-pagination" | "invalid-query" | "invalid-result";
|
|
14
14
|
/** Input a database operation refuses before touching storage. */
|
|
15
|
-
declare class
|
|
16
|
-
readonly code:
|
|
17
|
-
readonly name = "
|
|
18
|
-
constructor(code:
|
|
15
|
+
declare class DatabaseAdapterInputError extends Error {
|
|
16
|
+
readonly code: DatabaseAdapterInputErrorCode;
|
|
17
|
+
readonly name = "DatabaseAdapterInputError";
|
|
18
|
+
constructor(code: DatabaseAdapterInputErrorCode);
|
|
19
19
|
}
|
|
20
20
|
//#endregion
|
|
21
|
-
export {
|
|
21
|
+
export { DatabaseAdapterInputError, DatabaseAdapterInputErrorCode, DatabaseBundleNotFoundError, DatabaseRowReferencedError };
|
|
@@ -10,12 +10,12 @@ declare class DatabaseRowReferencedError extends Error {
|
|
|
10
10
|
readonly name = "DatabaseRowReferencedError";
|
|
11
11
|
constructor();
|
|
12
12
|
}
|
|
13
|
-
type
|
|
13
|
+
type DatabaseAdapterInputErrorCode = "invalid-data" | "invalid-field" | "invalid-pagination" | "invalid-query" | "invalid-result";
|
|
14
14
|
/** Input a database operation refuses before touching storage. */
|
|
15
|
-
declare class
|
|
16
|
-
readonly code:
|
|
17
|
-
readonly name = "
|
|
18
|
-
constructor(code:
|
|
15
|
+
declare class DatabaseAdapterInputError extends Error {
|
|
16
|
+
readonly code: DatabaseAdapterInputErrorCode;
|
|
17
|
+
readonly name = "DatabaseAdapterInputError";
|
|
18
|
+
constructor(code: DatabaseAdapterInputErrorCode);
|
|
19
19
|
}
|
|
20
20
|
//#endregion
|
|
21
|
-
export {
|
|
21
|
+
export { DatabaseAdapterInputError, DatabaseAdapterInputErrorCode, DatabaseBundleNotFoundError, DatabaseRowReferencedError };
|
package/dist/databaseErrors.mjs
CHANGED
|
@@ -16,13 +16,13 @@ var DatabaseRowReferencedError = class extends Error {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
/** Input a database operation refuses before touching storage. */
|
|
19
|
-
var
|
|
19
|
+
var DatabaseAdapterInputError = class extends Error {
|
|
20
20
|
code;
|
|
21
|
-
name = "
|
|
21
|
+
name = "DatabaseAdapterInputError";
|
|
22
22
|
constructor(code) {
|
|
23
|
-
super(`Invalid database
|
|
23
|
+
super(`Invalid database adapter input: ${code}`);
|
|
24
24
|
this.code = code;
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
//#endregion
|
|
28
|
-
export {
|
|
28
|
+
export { DatabaseAdapterInputError, DatabaseBundleNotFoundError, DatabaseRowReferencedError };
|
|
@@ -31,6 +31,12 @@ const isDatabaseJsonValue = (value) => {
|
|
|
31
31
|
};
|
|
32
32
|
return validate(value);
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Whether `value` is a plain object of JSON values a store keeps as they
|
|
36
|
+
* are: no cycles, accessors, non-finite numbers, or class instances. A
|
|
37
|
+
* plugin checks a `json` field's value with it before it writes, as
|
|
38
|
+
* Insights does for an event's metadata.
|
|
39
|
+
*/
|
|
34
40
|
const isDatabaseJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && isDatabaseJsonValue(value);
|
|
35
41
|
const isDatabaseMetadataObject = (value) => isDatabaseJsonObject(value) && (!Object.hasOwn(value, "app_version") || typeof value["app_version"] === "string");
|
|
36
42
|
//#endregion
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { DatabaseBundleMetadata, DatabaseJsonObject } from "./types/databaseRows.cjs";
|
|
2
2
|
import "./types/index.cjs";
|
|
3
3
|
//#region src/databaseJsonValue.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Whether `value` is a plain object of JSON values a store keeps as they
|
|
6
|
+
* are: no cycles, accessors, non-finite numbers, or class instances. A
|
|
7
|
+
* plugin checks a `json` field's value with it before it writes, as
|
|
8
|
+
* Insights does for an event's metadata.
|
|
9
|
+
*/
|
|
4
10
|
declare const isDatabaseJsonObject: (value: unknown) => value is DatabaseJsonObject;
|
|
5
11
|
declare const isDatabaseMetadataObject: (value: unknown) => value is DatabaseBundleMetadata;
|
|
6
12
|
//#endregion
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { DatabaseBundleMetadata, DatabaseJsonObject } from "./types/databaseRows.mjs";
|
|
2
2
|
import "./types/index.mjs";
|
|
3
3
|
//#region src/databaseJsonValue.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Whether `value` is a plain object of JSON values a store keeps as they
|
|
6
|
+
* are: no cycles, accessors, non-finite numbers, or class instances. A
|
|
7
|
+
* plugin checks a `json` field's value with it before it writes, as
|
|
8
|
+
* Insights does for an event's metadata.
|
|
9
|
+
*/
|
|
4
10
|
declare const isDatabaseJsonObject: (value: unknown) => value is DatabaseJsonObject;
|
|
5
11
|
declare const isDatabaseMetadataObject: (value: unknown) => value is DatabaseBundleMetadata;
|
|
6
12
|
//#endregion
|
|
@@ -31,6 +31,12 @@ const isDatabaseJsonValue = (value) => {
|
|
|
31
31
|
};
|
|
32
32
|
return validate(value);
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Whether `value` is a plain object of JSON values a store keeps as they
|
|
36
|
+
* are: no cycles, accessors, non-finite numbers, or class instances. A
|
|
37
|
+
* plugin checks a `json` field's value with it before it writes, as
|
|
38
|
+
* Insights does for an event's metadata.
|
|
39
|
+
*/
|
|
34
40
|
const isDatabaseJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && isDatabaseJsonValue(value);
|
|
35
41
|
const isDatabaseMetadataObject = (value) => isDatabaseJsonObject(value) && (!Object.hasOwn(value, "app_version") || typeof value["app_version"] === "string");
|
|
36
42
|
//#endregion
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_databaseErrors = require("./databaseErrors.cjs");
|
|
2
2
|
const require_databaseJsonValue = require("./databaseJsonValue.cjs");
|
|
3
|
-
let
|
|
3
|
+
let _hot_updater_protocol = require("@hot-updater/protocol");
|
|
4
4
|
//#region src/databaseMetadata.ts
|
|
5
5
|
const bundleMetadataToRow = (metadata) => {
|
|
6
|
-
const value = (0,
|
|
6
|
+
const value = (0, _hot_updater_protocol.stripBundleArtifactMetadata)(metadata);
|
|
7
7
|
if (value === void 0) return {};
|
|
8
|
-
if (!require_databaseJsonValue.isDatabaseMetadataObject(value)) throw new require_databaseErrors.
|
|
8
|
+
if (!require_databaseJsonValue.isDatabaseMetadataObject(value)) throw new require_databaseErrors.DatabaseAdapterInputError("invalid-data");
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
11
|
//#endregion
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabaseAdapterInputError } from "./databaseErrors.mjs";
|
|
2
2
|
import { isDatabaseMetadataObject } from "./databaseJsonValue.mjs";
|
|
3
|
-
import { stripBundleArtifactMetadata } from "@hot-updater/
|
|
3
|
+
import { stripBundleArtifactMetadata } from "@hot-updater/protocol";
|
|
4
4
|
//#region src/databaseMetadata.ts
|
|
5
5
|
const bundleMetadataToRow = (metadata) => {
|
|
6
6
|
const value = stripBundleArtifactMetadata(metadata);
|
|
7
7
|
if (value === void 0) return {};
|
|
8
|
-
if (!isDatabaseMetadataObject(value)) throw new
|
|
8
|
+
if (!isDatabaseMetadataObject(value)) throw new DatabaseAdapterInputError("invalid-data");
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
11
|
//#endregion
|
package/dist/databaseRows.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_databaseMetadata = require("./databaseMetadata.cjs");
|
|
2
|
-
let
|
|
2
|
+
let _hot_updater_protocol = require("@hot-updater/protocol");
|
|
3
3
|
//#region src/databaseRows.ts
|
|
4
4
|
const releaseToRow = (release, scopeKey) => ({
|
|
5
5
|
id: release.id,
|
|
@@ -66,12 +66,12 @@ const bundleToRow = (bundle) => {
|
|
|
66
66
|
platform: bundle.platform,
|
|
67
67
|
git_commit_hash: bundle.gitCommitHash,
|
|
68
68
|
metadata,
|
|
69
|
-
manifest_storage_uri: (0,
|
|
70
|
-
manifest_file_hash: (0,
|
|
71
|
-
asset_base_storage_uri: (0,
|
|
69
|
+
manifest_storage_uri: (0, _hot_updater_protocol.getManifestStorageUri)(bundle),
|
|
70
|
+
manifest_file_hash: (0, _hot_updater_protocol.getManifestFileHash)(bundle),
|
|
71
|
+
asset_base_storage_uri: (0, _hot_updater_protocol.getAssetBaseStorageUri)(bundle)
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
-
const bundleToPatchRows = (bundle) => (0,
|
|
74
|
+
const bundleToPatchRows = (bundle) => (0, _hot_updater_protocol.getBundlePatches)(bundle).map((patch, orderIndex) => ({
|
|
75
75
|
id: `${bundle.id}:${patch.baseBundleId}`,
|
|
76
76
|
bundle_id: bundle.id,
|
|
77
77
|
base_bundle_id: patch.baseBundleId,
|
|
@@ -95,7 +95,7 @@ const rowToBundle = (row, patchRows = []) => {
|
|
|
95
95
|
id: row.id,
|
|
96
96
|
platform: row.platform,
|
|
97
97
|
gitCommitHash: row.git_commit_hash,
|
|
98
|
-
metadata: (0,
|
|
98
|
+
metadata: (0, _hot_updater_protocol.stripBundleArtifactMetadata)(row.metadata),
|
|
99
99
|
manifestStorageUri: row.manifest_storage_uri,
|
|
100
100
|
manifestFileHash: row.manifest_file_hash,
|
|
101
101
|
assetBaseStorageUri: row.asset_base_storage_uri,
|
package/dist/databaseRows.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BundlePatchRow, BundleRow, ReleaseRow } from "./types/databaseRows.cjs";
|
|
2
2
|
import "./types/index.cjs";
|
|
3
|
-
import { Bundle, Release } from "@hot-updater/
|
|
3
|
+
import { Bundle, Release } from "@hot-updater/protocol";
|
|
4
4
|
//#region src/databaseRows.d.ts
|
|
5
5
|
declare const releaseToRow: (release: Release, scopeKey: string) => ReleaseRow;
|
|
6
6
|
declare const releaseRowToRelease: (row: ReleaseRow) => Release;
|
package/dist/databaseRows.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BundlePatchRow, BundleRow, ReleaseRow } from "./types/databaseRows.mjs";
|
|
2
2
|
import "./types/index.mjs";
|
|
3
|
-
import { Bundle, Release } from "@hot-updater/
|
|
3
|
+
import { Bundle, Release } from "@hot-updater/protocol";
|
|
4
4
|
//#region src/databaseRows.d.ts
|
|
5
5
|
declare const releaseToRow: (release: Release, scopeKey: string) => ReleaseRow;
|
|
6
6
|
declare const releaseRowToRelease: (row: ReleaseRow) => Release;
|
package/dist/databaseRows.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bundleMetadataToRow } from "./databaseMetadata.mjs";
|
|
2
|
-
import { getAssetBaseStorageUri, getBundlePatches, getManifestFileHash, getManifestStorageUri, stripBundleArtifactMetadata } from "@hot-updater/
|
|
2
|
+
import { getAssetBaseStorageUri, getBundlePatches, getManifestFileHash, getManifestStorageUri, stripBundleArtifactMetadata } from "@hot-updater/protocol";
|
|
3
3
|
//#region src/databaseRows.ts
|
|
4
4
|
const releaseToRow = (release, scopeKey) => ({
|
|
5
5
|
id: release.id,
|