@haverstack/record-adapter-do-sqlite 0.26.0 → 0.28.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 CHANGED
@@ -1,5 +1,5 @@
1
- import { StackCapabilities, StackRecord, RecordChangeSet, RecordVersion, ActorOptions, TypeId, StackQuery, QueryResult, FileId, VersionsQuery, JournalQuery, RecordJournalEntry, StackType, AssociationEdit } from '@haverstack/core';
2
- import { StackRecordAdapter, JournalOptions } from '@haverstack/core/adapter';
1
+ import { StackCapabilities, StackRecord, TypeId, QueryResult, FileId, BaseId, VersionsQuery, RecordVersion, JournalQuery, RecordJournalEntry, StackType, AssociationEdit, DataAssociation, AuthorityAssociation } from '@haverstack/core';
2
+ import { StackRecordAdapter, JournalOptions, MutateOptions, AspectWriteOptions, AdapterQuery, Reach, ElementWriteOptions } from '@haverstack/core/adapter';
3
3
 
4
4
  /**
5
5
  * Normalizes a SQLite binding's call convention (array-bind-then-step,
@@ -23,14 +23,10 @@ interface SqlExecutor {
23
23
  /** Run a parameterized statement and return all result rows. */
24
24
  all<T = Record<string, unknown>>(sql: string, params?: readonly unknown[]): T[];
25
25
  /**
26
- * Run `fn` atomically: every statement it issues commits together, or
27
- * none do if it throws. `fn` must be synchronous and call back into
28
- * this executor only — not every engine's transaction primitive can
29
- * straddle a suspended call. A binding with a real multi-statement
30
- * transaction (BEGIN/COMMIT/ROLLBACK) implements this with one; a
31
- * binding whose transaction primitive is itself a callback wrapper
32
- * (e.g. a Durable Object's storage.transactionSync) can pass `fn`
33
- * straight through to it.
26
+ * Run `fn` atomically: every statement it issues commits, or none do if it
27
+ * throws. A callback rather than BEGIN/COMMIT text because some engines
28
+ * only offer one (a Durable Object's storage.transactionSync); for the
29
+ * same reason `fn` must be synchronous and use only this executor.
34
30
  */
35
31
  transaction<T>(fn: () => T): T;
36
32
  }
@@ -43,7 +39,7 @@ type StackConfig = {
43
39
 
44
40
  /**
45
41
  * The engine-independent half of a SQLite-backed StackRecordAdapter: the
46
- * capability declaration and the delegation of all seventeen
42
+ * capability declaration and the delegation of all twenty-three
47
43
  * StackRecordAdapter methods onto SharedSqlRecordLogic. Every method here
48
44
  * is a forward with no engine-specific content, so an adapter that owns a
49
45
  * SqlExecutor already knows how to answer all of them.
@@ -66,30 +62,18 @@ declare abstract class SharedSqlRecordAdapter implements StackRecordAdapter {
66
62
  protected constructor(exec: SqlExecutor, config: StackConfig);
67
63
  createRecord(record: StackRecord, opts?: JournalOptions): Promise<StackRecord>;
68
64
  getRecord(id: string): Promise<StackRecord | null>;
69
- mutateRecord(id: string, changes: RecordChangeSet, opts?: {
70
- ifVersion?: number;
71
- snapshot?: RecordVersion;
72
- bumpsVersion?: boolean;
73
- } & ActorOptions & JournalOptions): Promise<StackRecord>;
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>;
74
68
  deleteRecord(id: string, opts?: {
75
69
  purge?: boolean;
76
- ifVersion?: number;
77
- snapshot?: RecordVersion;
78
- } & ActorOptions & JournalOptions): Promise<StackRecord | null>;
79
- undeleteRecord(id: string, opts?: {
80
- ifVersion?: number;
81
- snapshot?: RecordVersion;
82
- } & ActorOptions & JournalOptions): Promise<StackRecord>;
83
- restoreVersion(id: string, version: number, opts?: {
84
- ifVersion?: number;
85
- snapshot?: RecordVersion;
86
- } & ActorOptions & JournalOptions): Promise<StackRecord>;
87
- commitMigration(id: string, toTypeId: TypeId, content: Record<string, unknown>, opts?: {
88
- ifVersion?: number;
89
- snapshot?: RecordVersion;
90
- } & ActorOptions & JournalOptions): Promise<StackRecord>;
91
- queryRecords(query: StackQuery): Promise<QueryResult>;
92
- deleteUnreferencedAttachmentRecords(fileId: FileId, metadataTypeIds: TypeId[]): Promise<StackRecord[]>;
70
+ } & MutateOptions): Promise<StackRecord | null>;
71
+ undeleteRecord(id: string, opts?: MutateOptions): Promise<StackRecord>;
72
+ restoreVersion(id: string, version: number, opts?: MutateOptions): Promise<StackRecord>;
73
+ commitMigration(id: string, toTypeId: TypeId, content: Record<string, unknown>, opts?: MutateOptions): Promise<StackRecord>;
74
+ queryRecords(query: AdapterQuery): Promise<QueryResult>;
75
+ queryReadable(query: AdapterQuery, reach: Reach): Promise<QueryResult>;
76
+ deleteUnreferencedAttachmentRecords(fileId: FileId, metadataBaseId: BaseId): Promise<StackRecord[]>;
93
77
  getVersions(id: string, query?: VersionsQuery): Promise<RecordVersion[]>;
94
78
  getVersion(id: string, version: number): Promise<RecordVersion | null>;
95
79
  saveVersion(id: string, version: RecordVersion): Promise<void>;
@@ -97,7 +81,10 @@ declare abstract class SharedSqlRecordAdapter implements StackRecordAdapter {
97
81
  saveType(type: StackType): Promise<void>;
98
82
  getType(id: TypeId): Promise<StackType | null>;
99
83
  listTypes(): Promise<StackType[]>;
100
- amendAssociations(recordId: string, changes: AssociationEdit[], opts?: JournalOptions): Promise<StackRecord>;
84
+ editAssociations(id: string, edits: AssociationEdit[], opts?: ElementWriteOptions<DataAssociation>): Promise<StackRecord>;
85
+ setAssociations(id: string, associations: DataAssociation[], opts?: ElementWriteOptions<DataAssociation>): Promise<StackRecord>;
86
+ editAccess(id: string, edits: AssociationEdit[], opts?: ElementWriteOptions<AuthorityAssociation>): Promise<StackRecord>;
87
+ setAccess(id: string, permissions: AuthorityAssociation[], opts?: ElementWriteOptions<AuthorityAssociation>): Promise<StackRecord>;
101
88
  abstract flush(): Promise<void>;
102
89
  abstract close(): Promise<void>;
103
90
  }