@haverstack/record-adapter-sqlite 0.34.0 → 0.36.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 +27 -21
- package/dist/index.js +740 -579
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StackCapabilities,
|
|
2
|
-
import { StackRecordAdapter, JournalOptions, MutateOptions,
|
|
1
|
+
import { StackCapabilities, ConfigContent, StackRecord, TypeId, QueryResult, FileId, BaseId, VersionsQuery, RecordVersion, JournalQuery, RecordJournalEntry, StackType, AssociationEdit, DataAssociation, AuthorityAssociation, Actor } from '@haverstack/core';
|
|
2
|
+
import { StackRecordAdapter, JournalOptions, RecordHistory, MutateOptions, AspectWriteOptions, AdapterQuery, Reach, ElementWriteOptions, StoreSeed } from '@haverstack/core/adapter';
|
|
3
3
|
import { StackTokenStore, TokenSession, TokenInfo } from '@haverstack/core/wire';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -32,15 +32,14 @@ interface SqlExecutor {
|
|
|
32
32
|
transaction<T>(fn: () => T): T;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
type
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
35
|
+
/** What open() does when the store is missing or present, like O_CREAT / O_EXCL. */
|
|
36
|
+
type StoreCreateMode = 'never' | 'ifMissing' | 'exclusive';
|
|
37
|
+
/** A plain DID, or a lazy provider called only when a store is actually created. */
|
|
38
|
+
type OwnerEntityIdInput = string | (() => string | Promise<string>);
|
|
40
39
|
|
|
41
40
|
/**
|
|
42
41
|
* The engine-independent half of a SQLite-backed StackRecordAdapter: the
|
|
43
|
-
* capability declaration and the delegation of all
|
|
42
|
+
* capability declaration and the delegation of all twenty-three
|
|
44
43
|
* StackRecordAdapter methods onto SharedSqlRecordLogic. Every method here
|
|
45
44
|
* is a forward with no engine-specific content, so an adapter that owns a
|
|
46
45
|
* SqlExecutor already knows how to answer all of them.
|
|
@@ -58,28 +57,33 @@ type StackConfig = {
|
|
|
58
57
|
declare abstract class SharedSqlRecordAdapter implements StackRecordAdapter {
|
|
59
58
|
readonly capabilities: StackCapabilities;
|
|
60
59
|
readonly ownerEntityId: string;
|
|
61
|
-
readonly timezone: string | undefined;
|
|
62
60
|
private readonly record;
|
|
63
|
-
protected constructor(exec: SqlExecutor, config:
|
|
61
|
+
protected constructor(exec: SqlExecutor, config: ConfigContent);
|
|
64
62
|
createRecord(record: StackRecord, opts?: JournalOptions): Promise<StackRecord>;
|
|
63
|
+
importRecord(record: StackRecord, history: RecordHistory): Promise<StackRecord>;
|
|
65
64
|
getRecord(id: string): Promise<StackRecord | null>;
|
|
66
|
-
|
|
65
|
+
patchContent(id: string, patch: Record<string, unknown | null>, opts?: MutateOptions): Promise<StackRecord>;
|
|
66
|
+
setParent(id: string, parentId: string | null, opts?: AspectWriteOptions): Promise<StackRecord>;
|
|
67
|
+
setUnlisted(id: string, unlisted: boolean, opts?: AspectWriteOptions): Promise<StackRecord>;
|
|
67
68
|
deleteRecord(id: string, opts?: {
|
|
68
69
|
purge?: boolean;
|
|
69
70
|
} & MutateOptions): Promise<StackRecord | null>;
|
|
70
71
|
undeleteRecord(id: string, opts?: MutateOptions): Promise<StackRecord>;
|
|
71
72
|
restoreVersion(id: string, version: number, opts?: MutateOptions): Promise<StackRecord>;
|
|
72
73
|
commitMigration(id: string, toTypeId: TypeId, content: Record<string, unknown>, opts?: MutateOptions): Promise<StackRecord>;
|
|
73
|
-
queryRecords(query:
|
|
74
|
-
|
|
74
|
+
queryRecords(query: AdapterQuery): Promise<QueryResult>;
|
|
75
|
+
queryReadable(query: AdapterQuery, reach: Reach): Promise<QueryResult>;
|
|
76
|
+
deleteUnreferencedAttachmentRecords(fileId: FileId, metadataBaseId: BaseId): Promise<StackRecord[]>;
|
|
75
77
|
getVersions(id: string, query?: VersionsQuery): Promise<RecordVersion[]>;
|
|
76
78
|
getVersion(id: string, version: number): Promise<RecordVersion | null>;
|
|
77
|
-
saveVersion(id: string, version: RecordVersion): Promise<void>;
|
|
78
79
|
getJournal(id: string, query?: JournalQuery): Promise<RecordJournalEntry[]>;
|
|
79
80
|
saveType(type: StackType): Promise<void>;
|
|
80
81
|
getType(id: TypeId): Promise<StackType | null>;
|
|
81
82
|
listTypes(): Promise<StackType[]>;
|
|
82
|
-
|
|
83
|
+
editAssociations(id: string, edits: AssociationEdit[], opts?: ElementWriteOptions<DataAssociation>): Promise<StackRecord>;
|
|
84
|
+
setAssociations(id: string, associations: DataAssociation[], opts?: ElementWriteOptions<DataAssociation>): Promise<StackRecord>;
|
|
85
|
+
editAccess(id: string, edits: AssociationEdit[], opts?: ElementWriteOptions<AuthorityAssociation>): Promise<StackRecord>;
|
|
86
|
+
setAccess(id: string, permissions: AuthorityAssociation[], opts?: ElementWriteOptions<AuthorityAssociation>): Promise<StackRecord>;
|
|
83
87
|
abstract flush(): Promise<void>;
|
|
84
88
|
abstract close(): Promise<void>;
|
|
85
89
|
}
|
|
@@ -153,15 +157,9 @@ declare class NativeTokenStore implements StackTokenStore {
|
|
|
153
157
|
* spread-args run/get/all calls to it).
|
|
154
158
|
*/
|
|
155
159
|
|
|
156
|
-
/** What open() does when the store is missing or present, like O_CREAT / O_EXCL. */
|
|
157
|
-
type StoreCreateMode = 'never' | 'ifMissing' | 'exclusive';
|
|
158
|
-
/** A plain DID, or a lazy provider called only when a store is actually created. */
|
|
159
|
-
type OwnerEntityIdInput = string | (() => string | Promise<string>);
|
|
160
160
|
type NativeSQLiteRecordAdapterOpenOptions = {
|
|
161
161
|
/** Absolute path to the .db file. */
|
|
162
162
|
path: string;
|
|
163
|
-
/** IANA timezone string e.g. "America/New_York". Consulted only when a store is created. No default. */
|
|
164
|
-
timezone?: string;
|
|
165
163
|
/**
|
|
166
164
|
* Open even if a lock file from another live process is present.
|
|
167
165
|
* Only needed if that process is gone but its PID was reused by
|
|
@@ -174,6 +172,7 @@ type NativeSQLiteRecordAdapterOpenOptions = {
|
|
|
174
172
|
create?: 'never';
|
|
175
173
|
/** Checked against the existing store's owner; a mismatch throws OwnerMismatchError. */
|
|
176
174
|
ownerEntityId?: string;
|
|
175
|
+
seed?: never;
|
|
177
176
|
} | {
|
|
178
177
|
/** `'ifMissing'` opens the store if present and creates it if not; `'exclusive'` creates it and fails if present. */
|
|
179
178
|
create: 'ifMissing' | 'exclusive';
|
|
@@ -182,6 +181,13 @@ type NativeSQLiteRecordAdapterOpenOptions = {
|
|
|
182
181
|
* existing store's owner; a lazy provider is never called just to compare.
|
|
183
182
|
*/
|
|
184
183
|
ownerEntityId: OwnerEntityIdInput;
|
|
184
|
+
seed?: never;
|
|
185
|
+
} | {
|
|
186
|
+
/** A seed only creates, as `'exclusive'` does: an existing store refuses it. */
|
|
187
|
+
create?: never;
|
|
188
|
+
/** The `_config` record and history the store is created holding: a copy's source's. */
|
|
189
|
+
seed: StoreSeed;
|
|
190
|
+
ownerEntityId?: never;
|
|
185
191
|
});
|
|
186
192
|
declare class NativeSQLiteRecordAdapter extends SharedSqlRecordAdapter {
|
|
187
193
|
private readonly path;
|