@haverstack/record-adapter-do-sqlite 0.27.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +26 -21
- package/dist/index.js +741 -551
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { StackRecordAdapter, JournalOptions, RecordHistory, MutateOptions, AspectWriteOptions, AdapterQuery, Reach, ElementWriteOptions, StoreSeed } from '@haverstack/core/adapter';
|
|
2
|
+
import { StackCapabilities, ConfigContent, StackRecord, TypeId, QueryResult, FileId, BaseId, VersionsQuery, RecordVersion, JournalQuery, RecordJournalEntry, StackType, AssociationEdit, DataAssociation, AuthorityAssociation } from '@haverstack/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Normalizes a SQLite binding's call convention (array-bind-then-step,
|
|
@@ -31,15 +31,9 @@ interface SqlExecutor {
|
|
|
31
31
|
transaction<T>(fn: () => T): T;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/** timezone is optional passthrough app metadata — no default. */
|
|
35
|
-
type StackConfig = {
|
|
36
|
-
entityId: string;
|
|
37
|
-
timezone: string | undefined;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
34
|
/**
|
|
41
35
|
* The engine-independent half of a SQLite-backed StackRecordAdapter: the
|
|
42
|
-
* capability declaration and the delegation of all
|
|
36
|
+
* capability declaration and the delegation of all twenty-three
|
|
43
37
|
* StackRecordAdapter methods onto SharedSqlRecordLogic. Every method here
|
|
44
38
|
* is a forward with no engine-specific content, so an adapter that owns a
|
|
45
39
|
* SqlExecutor already knows how to answer all of them.
|
|
@@ -57,28 +51,33 @@ type StackConfig = {
|
|
|
57
51
|
declare abstract class SharedSqlRecordAdapter implements StackRecordAdapter {
|
|
58
52
|
readonly capabilities: StackCapabilities;
|
|
59
53
|
readonly ownerEntityId: string;
|
|
60
|
-
readonly timezone: string | undefined;
|
|
61
54
|
private readonly record;
|
|
62
|
-
protected constructor(exec: SqlExecutor, config:
|
|
55
|
+
protected constructor(exec: SqlExecutor, config: ConfigContent);
|
|
63
56
|
createRecord(record: StackRecord, opts?: JournalOptions): Promise<StackRecord>;
|
|
57
|
+
importRecord(record: StackRecord, history: RecordHistory): Promise<StackRecord>;
|
|
64
58
|
getRecord(id: string): Promise<StackRecord | null>;
|
|
65
|
-
|
|
59
|
+
patchContent(id: string, patch: Record<string, unknown | null>, opts?: MutateOptions): Promise<StackRecord>;
|
|
60
|
+
setParent(id: string, parentId: string | null, opts?: AspectWriteOptions): Promise<StackRecord>;
|
|
61
|
+
setUnlisted(id: string, unlisted: boolean, opts?: AspectWriteOptions): Promise<StackRecord>;
|
|
66
62
|
deleteRecord(id: string, opts?: {
|
|
67
63
|
purge?: boolean;
|
|
68
64
|
} & MutateOptions): Promise<StackRecord | null>;
|
|
69
65
|
undeleteRecord(id: string, opts?: MutateOptions): Promise<StackRecord>;
|
|
70
66
|
restoreVersion(id: string, version: number, opts?: MutateOptions): Promise<StackRecord>;
|
|
71
67
|
commitMigration(id: string, toTypeId: TypeId, content: Record<string, unknown>, opts?: MutateOptions): Promise<StackRecord>;
|
|
72
|
-
queryRecords(query:
|
|
73
|
-
|
|
68
|
+
queryRecords(query: AdapterQuery): Promise<QueryResult>;
|
|
69
|
+
queryReadable(query: AdapterQuery, reach: Reach): Promise<QueryResult>;
|
|
70
|
+
deleteUnreferencedAttachmentRecords(fileId: FileId, metadataBaseId: BaseId): Promise<StackRecord[]>;
|
|
74
71
|
getVersions(id: string, query?: VersionsQuery): Promise<RecordVersion[]>;
|
|
75
72
|
getVersion(id: string, version: number): Promise<RecordVersion | null>;
|
|
76
|
-
saveVersion(id: string, version: RecordVersion): Promise<void>;
|
|
77
73
|
getJournal(id: string, query?: JournalQuery): Promise<RecordJournalEntry[]>;
|
|
78
74
|
saveType(type: StackType): Promise<void>;
|
|
79
75
|
getType(id: TypeId): Promise<StackType | null>;
|
|
80
76
|
listTypes(): Promise<StackType[]>;
|
|
81
|
-
|
|
77
|
+
editAssociations(id: string, edits: AssociationEdit[], opts?: ElementWriteOptions<DataAssociation>): Promise<StackRecord>;
|
|
78
|
+
setAssociations(id: string, associations: DataAssociation[], opts?: ElementWriteOptions<DataAssociation>): Promise<StackRecord>;
|
|
79
|
+
editAccess(id: string, edits: AssociationEdit[], opts?: ElementWriteOptions<AuthorityAssociation>): Promise<StackRecord>;
|
|
80
|
+
setAccess(id: string, permissions: AuthorityAssociation[], opts?: ElementWriteOptions<AuthorityAssociation>): Promise<StackRecord>;
|
|
82
81
|
abstract flush(): Promise<void>;
|
|
83
82
|
abstract close(): Promise<void>;
|
|
84
83
|
}
|
|
@@ -143,17 +142,23 @@ type DoSQLiteRecordAdapterOpenOptions = {
|
|
|
143
142
|
* provider is called only when the DO's storage has none yet.
|
|
144
143
|
*/
|
|
145
144
|
ownerEntityId: string | (() => string | Promise<string>);
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
seed?: never;
|
|
146
|
+
} | {
|
|
147
|
+
/**
|
|
148
|
+
* The `_config` record and history new storage is created holding: a
|
|
149
|
+
* copy's source's. Storage that already holds a store refuses it.
|
|
150
|
+
*/
|
|
151
|
+
seed: StoreSeed;
|
|
152
|
+
ownerEntityId?: never;
|
|
148
153
|
};
|
|
149
154
|
declare class DoSQLiteRecordAdapter extends SharedSqlRecordAdapter {
|
|
150
155
|
private constructor();
|
|
151
156
|
/**
|
|
152
157
|
* Open the adapter for a DO instance, creating its storage on first use.
|
|
153
158
|
* A DO id either already has a config record (reattach) or it doesn't
|
|
154
|
-
* (first call — opts.ownerEntityId
|
|
155
|
-
* is no `create` option.
|
|
156
|
-
*
|
|
159
|
+
* (first call — opts.ownerEntityId becomes the config), so there
|
|
160
|
+
* is no `create` option. A new store's tables are written in the same
|
|
161
|
+
* transaction as its config record, so storage holds a whole store or none.
|
|
157
162
|
*
|
|
158
163
|
* DO SQLite manages its own durability and rejects PRAGMA journal_mode
|
|
159
164
|
* outright ("not authorized") — verified against the real runtime, not
|