@starkeep/storage-sqlite 0.4.0 → 0.5.1
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 +4 -4
- package/dist/{adapter-EloqOiMg.d.cts → adapter-DoVOV6K-.d.cts} +28 -3
- package/dist/{adapter-EloqOiMg.d.ts → adapter-DoVOV6K-.d.ts} +28 -3
- package/dist/index.cjs +537 -208
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +164 -13
- package/dist/index.d.ts +164 -13
- package/dist/index.js +565 -187
- package/dist/index.js.map +1 -1
- package/dist/node-entry.cjs.map +1 -1
- package/dist/node-entry.d.cts +1 -1
- package/dist/node-entry.d.ts +1 -1
- package/dist/node-entry.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -45,10 +45,10 @@ await databaseAdapter.close();
|
|
|
45
45
|
|
|
46
46
|
## API
|
|
47
47
|
|
|
48
|
-
| Export
|
|
49
|
-
|
|
50
|
-
| `SqliteDatabaseAdapter`
|
|
51
|
-
| `SqliteDatabaseAdapterOptions` | Options type: `{ path: string \| ":memory:" }`
|
|
48
|
+
| Export | Description |
|
|
49
|
+
| ------------------------------ | ----------------------------------------------- |
|
|
50
|
+
| `SqliteDatabaseAdapter` | Class implementing `DatabaseAdapter` for SQLite |
|
|
51
|
+
| `SqliteDatabaseAdapterOptions` | Options type: `{ path: string \| ":memory:" }` |
|
|
52
52
|
|
|
53
53
|
The adapter automatically creates the `records` table, indexes, and a `migrations` table on `init()`. WAL journal mode and foreign keys are enabled by default.
|
|
54
54
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatabaseAdapter, RawDatabase, Query, QueryResult, BatchOperation, Transaction, LabelUpsert, LabelRetraction, LabelValueReplacement, FindByLabelQuery, FindByLabelResult, StoredAvailability } from '@starkeep/storage-adapter';
|
|
2
|
-
import { DataRecord, StarkeepId, HLCTimestamp,
|
|
1
|
+
import { DatabaseAdapter, RawDatabase, SincePage, DigestBucket, Query, QueryResult, RecordTypeCount, SharedQueryTarget, ParsedQuery, WhereClause, SoftDeletedScope, ParsedQueryResult, BatchOperation, Transaction, LabelUpsert, LabelRetraction, LabelValueReplacement, FindByLabelQuery, FindByLabelResult, StoredAvailability } from '@starkeep/storage-adapter';
|
|
2
|
+
import { DataRecord, StarkeepId, HLCTimestamp, RecordLabel, MetadataRow } from '@starkeep/protocol-primitives';
|
|
3
3
|
|
|
4
4
|
interface SqliteDatabaseAdapterOptions {
|
|
5
5
|
path: string | ":memory:";
|
|
@@ -66,17 +66,41 @@ declare class SqliteDatabaseAdapter implements DatabaseAdapter {
|
|
|
66
66
|
get(id: StarkeepId): Promise<DataRecord | null>;
|
|
67
67
|
delete(id: StarkeepId, hlc: HLCTimestamp): Promise<void>;
|
|
68
68
|
getNodeWatermarks(): Promise<Record<string, HLCTimestamp>>;
|
|
69
|
+
querySince(peerWatermarks: Record<string, HLCTimestamp>, limit: number): Promise<SincePage<DataRecord>>;
|
|
70
|
+
queryLabelsSince(peerWatermarks: Record<string, HLCTimestamp>, limit: number): Promise<SincePage<RecordLabel>>;
|
|
71
|
+
bucketDigest(prefixLength?: number): Promise<DigestBucket[]>;
|
|
69
72
|
query(query: Query): Promise<QueryResult>;
|
|
73
|
+
countRecords(query: Query): Promise<number>;
|
|
74
|
+
countRecordsByType(query: Query): Promise<RecordTypeCount[]>;
|
|
75
|
+
/**
|
|
76
|
+
* See `DatabaseAdapter.queryShared`. Compiled by the same builder the
|
|
77
|
+
* app-syncable plane uses, against the table the target names on this engine.
|
|
78
|
+
*/
|
|
79
|
+
queryShared(target: SharedQueryTarget, query: ParsedQuery, options?: {
|
|
80
|
+
readonly serverWhere?: readonly WhereClause[];
|
|
81
|
+
readonly softDeleted?: SoftDeletedScope;
|
|
82
|
+
}): Promise<ParsedQueryResult>;
|
|
83
|
+
/** Bind and run a compiled SELECT, adapting values SQLite cannot bind. */
|
|
84
|
+
private selectCompiled;
|
|
70
85
|
batch(operations: BatchOperation[]): Promise<void>;
|
|
71
86
|
transaction<T>(callback: (transaction: Transaction) => Promise<T>): Promise<T>;
|
|
72
|
-
putMetadata(
|
|
87
|
+
putMetadata(recordType: string, row: MetadataRow): Promise<void>;
|
|
73
88
|
getMetadata(typeId: string, recordId: StarkeepId): Promise<MetadataRow | null>;
|
|
74
89
|
getMetadataByIds(typeId: string, recordIds: StarkeepId[]): Promise<Map<StarkeepId, MetadataRow>>;
|
|
75
90
|
deleteMetadata(typeId: string, recordId: StarkeepId): Promise<void>;
|
|
91
|
+
tombstoneMetadata(typeId: string, recordId: StarkeepId, hlc: HLCTimestamp): Promise<void>;
|
|
92
|
+
restoreMetadata(typeId: string, recordId: StarkeepId): Promise<void>;
|
|
93
|
+
private setMetadataTombstone;
|
|
76
94
|
upsertLabels(labels: LabelUpsert[]): Promise<void>;
|
|
77
95
|
retractLabels(retractions: LabelRetraction[]): Promise<void>;
|
|
78
96
|
replaceLabelValues(replacements: LabelValueReplacement[]): Promise<void>;
|
|
79
97
|
getLabelsByRecordIds(recordIds: StarkeepId[]): Promise<Map<StarkeepId, RecordLabel[]>>;
|
|
98
|
+
/**
|
|
99
|
+
* The reverse label read, run through the query grammar — see
|
|
100
|
+
* `label-find.ts`. The grant rides in as `serverWhere` rather than as one of
|
|
101
|
+
* the caller's own predicates, which is the separation every other shared
|
|
102
|
+
* query draws.
|
|
103
|
+
*/
|
|
80
104
|
findByLabel(query: FindByLabelQuery): Promise<FindByLabelResult>;
|
|
81
105
|
putLabel(label: RecordLabel): Promise<void>;
|
|
82
106
|
getLabel(recordId: StarkeepId, appId: string, key: string, value: string): Promise<RecordLabel | null>;
|
|
@@ -96,6 +120,7 @@ declare class SqliteDatabaseAdapter implements DatabaseAdapter {
|
|
|
96
120
|
bytes: number;
|
|
97
121
|
}>;
|
|
98
122
|
tombstoneLabelsForRecord(recordId: StarkeepId, hlc: HLCTimestamp): Promise<void>;
|
|
123
|
+
restoreLabelsForRecord(recordId: StarkeepId, deletedAt: HLCTimestamp, hlc: HLCTimestamp): Promise<void>;
|
|
99
124
|
}
|
|
100
125
|
|
|
101
126
|
export { SqliteDatabaseAdapter as S, type SqliteDatabaseAdapterOptions as a, type SqliteDriver as b };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatabaseAdapter, RawDatabase, Query, QueryResult, BatchOperation, Transaction, LabelUpsert, LabelRetraction, LabelValueReplacement, FindByLabelQuery, FindByLabelResult, StoredAvailability } from '@starkeep/storage-adapter';
|
|
2
|
-
import { DataRecord, StarkeepId, HLCTimestamp,
|
|
1
|
+
import { DatabaseAdapter, RawDatabase, SincePage, DigestBucket, Query, QueryResult, RecordTypeCount, SharedQueryTarget, ParsedQuery, WhereClause, SoftDeletedScope, ParsedQueryResult, BatchOperation, Transaction, LabelUpsert, LabelRetraction, LabelValueReplacement, FindByLabelQuery, FindByLabelResult, StoredAvailability } from '@starkeep/storage-adapter';
|
|
2
|
+
import { DataRecord, StarkeepId, HLCTimestamp, RecordLabel, MetadataRow } from '@starkeep/protocol-primitives';
|
|
3
3
|
|
|
4
4
|
interface SqliteDatabaseAdapterOptions {
|
|
5
5
|
path: string | ":memory:";
|
|
@@ -66,17 +66,41 @@ declare class SqliteDatabaseAdapter implements DatabaseAdapter {
|
|
|
66
66
|
get(id: StarkeepId): Promise<DataRecord | null>;
|
|
67
67
|
delete(id: StarkeepId, hlc: HLCTimestamp): Promise<void>;
|
|
68
68
|
getNodeWatermarks(): Promise<Record<string, HLCTimestamp>>;
|
|
69
|
+
querySince(peerWatermarks: Record<string, HLCTimestamp>, limit: number): Promise<SincePage<DataRecord>>;
|
|
70
|
+
queryLabelsSince(peerWatermarks: Record<string, HLCTimestamp>, limit: number): Promise<SincePage<RecordLabel>>;
|
|
71
|
+
bucketDigest(prefixLength?: number): Promise<DigestBucket[]>;
|
|
69
72
|
query(query: Query): Promise<QueryResult>;
|
|
73
|
+
countRecords(query: Query): Promise<number>;
|
|
74
|
+
countRecordsByType(query: Query): Promise<RecordTypeCount[]>;
|
|
75
|
+
/**
|
|
76
|
+
* See `DatabaseAdapter.queryShared`. Compiled by the same builder the
|
|
77
|
+
* app-syncable plane uses, against the table the target names on this engine.
|
|
78
|
+
*/
|
|
79
|
+
queryShared(target: SharedQueryTarget, query: ParsedQuery, options?: {
|
|
80
|
+
readonly serverWhere?: readonly WhereClause[];
|
|
81
|
+
readonly softDeleted?: SoftDeletedScope;
|
|
82
|
+
}): Promise<ParsedQueryResult>;
|
|
83
|
+
/** Bind and run a compiled SELECT, adapting values SQLite cannot bind. */
|
|
84
|
+
private selectCompiled;
|
|
70
85
|
batch(operations: BatchOperation[]): Promise<void>;
|
|
71
86
|
transaction<T>(callback: (transaction: Transaction) => Promise<T>): Promise<T>;
|
|
72
|
-
putMetadata(
|
|
87
|
+
putMetadata(recordType: string, row: MetadataRow): Promise<void>;
|
|
73
88
|
getMetadata(typeId: string, recordId: StarkeepId): Promise<MetadataRow | null>;
|
|
74
89
|
getMetadataByIds(typeId: string, recordIds: StarkeepId[]): Promise<Map<StarkeepId, MetadataRow>>;
|
|
75
90
|
deleteMetadata(typeId: string, recordId: StarkeepId): Promise<void>;
|
|
91
|
+
tombstoneMetadata(typeId: string, recordId: StarkeepId, hlc: HLCTimestamp): Promise<void>;
|
|
92
|
+
restoreMetadata(typeId: string, recordId: StarkeepId): Promise<void>;
|
|
93
|
+
private setMetadataTombstone;
|
|
76
94
|
upsertLabels(labels: LabelUpsert[]): Promise<void>;
|
|
77
95
|
retractLabels(retractions: LabelRetraction[]): Promise<void>;
|
|
78
96
|
replaceLabelValues(replacements: LabelValueReplacement[]): Promise<void>;
|
|
79
97
|
getLabelsByRecordIds(recordIds: StarkeepId[]): Promise<Map<StarkeepId, RecordLabel[]>>;
|
|
98
|
+
/**
|
|
99
|
+
* The reverse label read, run through the query grammar — see
|
|
100
|
+
* `label-find.ts`. The grant rides in as `serverWhere` rather than as one of
|
|
101
|
+
* the caller's own predicates, which is the separation every other shared
|
|
102
|
+
* query draws.
|
|
103
|
+
*/
|
|
80
104
|
findByLabel(query: FindByLabelQuery): Promise<FindByLabelResult>;
|
|
81
105
|
putLabel(label: RecordLabel): Promise<void>;
|
|
82
106
|
getLabel(recordId: StarkeepId, appId: string, key: string, value: string): Promise<RecordLabel | null>;
|
|
@@ -96,6 +120,7 @@ declare class SqliteDatabaseAdapter implements DatabaseAdapter {
|
|
|
96
120
|
bytes: number;
|
|
97
121
|
}>;
|
|
98
122
|
tombstoneLabelsForRecord(recordId: StarkeepId, hlc: HLCTimestamp): Promise<void>;
|
|
123
|
+
restoreLabelsForRecord(recordId: StarkeepId, deletedAt: HLCTimestamp, hlc: HLCTimestamp): Promise<void>;
|
|
99
124
|
}
|
|
100
125
|
|
|
101
126
|
export { SqliteDatabaseAdapter as S, type SqliteDatabaseAdapterOptions as a, type SqliteDriver as b };
|