@agentshouse/mdruntime 0.1.0-cb0eb0d87ff49 → 0.1.0-cb2e390ee7b89
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/AGENTS.md +275 -285
- package/dist/acquisition.d.ts +14 -0
- package/dist/acquisition.d.ts.map +1 -0
- package/dist/acquisition.js +24 -0
- package/dist/adapter.d.ts +25 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +2 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +2 -1
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/kit.d.ts +2 -1
- package/dist/chat/kit.d.ts.map +1 -1
- package/dist/chat/kit.js +3 -3
- package/dist/chat/list.d.ts +2 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +42 -5
- package/dist/chat/messages.d.ts +1 -0
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +4 -0
- package/dist/chat/provider.d.ts +1 -1
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +34 -19
- package/dist/chat/question.d.ts +1 -1
- package/dist/chat/question.d.ts.map +1 -1
- package/dist/chat/question.js +7 -18
- package/dist/chat/ready.d.ts +1 -0
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +2 -2
- package/dist/chat/style.js +1 -1
- package/dist/client.d.ts +8 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -5
- package/dist/connection.d.ts +19 -3
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +741 -100
- package/dist/conversation.d.ts +7 -0
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +202 -39
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/host.d.ts +15 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +85 -8
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/memory.d.ts +8 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +26 -6
- package/dist/model.d.ts +3 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +1 -1
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +9 -3
- package/dist/outcome.d.ts +8 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +27 -3
- package/dist/query.d.ts +24 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +32 -5
- package/dist/reach.d.ts +6 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +18 -3
- package/dist/react.d.ts +4 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +6 -4
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +169 -47
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +6 -0
- package/dist/replica.d.ts +5 -1
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +30 -5
- package/dist/room-draft.d.ts +13 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +2 -2
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +17 -1
- package/dist/search.d.ts +28 -7
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +93 -13
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +26 -4
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +92 -25
- package/dist/windows.d.ts +18 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +80 -0
- package/dist/wire.d.ts +144 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +50 -31
- package/package.json +2 -2
package/dist/seed.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { KeyedResult } from './observation.js';
|
|
2
|
+
import type { QueryRows } from './query.js';
|
|
3
|
+
export type EntrySeed = {
|
|
4
|
+
readonly at: Readonly<Record<string, string>>;
|
|
5
|
+
readonly queries: readonly {
|
|
6
|
+
readonly query: unknown;
|
|
7
|
+
readonly rows: QueryRows;
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
export type Seeded = {
|
|
11
|
+
readonly rows: QueryRows;
|
|
12
|
+
readonly at: Readonly<Record<string, string>>;
|
|
13
|
+
};
|
|
14
|
+
export declare function entrySeedOf(value: unknown): EntrySeed | null;
|
|
15
|
+
export declare function seededResult(seed: Seeded): KeyedResult;
|
|
16
|
+
//# sourceMappingURL=seed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAA4C,SAAS,EAAE,MAAM,YAAY,CAAC;AAGtF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;CACpF,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC;AAwCjG,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAe5D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAoBtD"}
|
package/dist/seed.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { documentKey } from './rows.js';
|
|
2
|
+
function plain(value) {
|
|
3
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
function windowOf(value) {
|
|
6
|
+
const { next, total } = value;
|
|
7
|
+
if (next !== undefined && typeof next !== 'string')
|
|
8
|
+
return null;
|
|
9
|
+
if (total !== undefined && !Number.isSafeInteger(total))
|
|
10
|
+
return null;
|
|
11
|
+
return {
|
|
12
|
+
...(next === undefined ? {} : { next }),
|
|
13
|
+
...(total === undefined ? {} : { total: total }),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function rowsOf(value) {
|
|
17
|
+
if (!plain(value))
|
|
18
|
+
return null;
|
|
19
|
+
const window = windowOf(value);
|
|
20
|
+
if (window === null)
|
|
21
|
+
return null;
|
|
22
|
+
if (Array.isArray(value.groups)) {
|
|
23
|
+
const groups = value.groups;
|
|
24
|
+
return groups.every((group) => plain(group) && Array.isArray(group.key) && typeof group.count === 'number')
|
|
25
|
+
? { groups: groups, ...window }
|
|
26
|
+
: null;
|
|
27
|
+
}
|
|
28
|
+
if (!Array.isArray(value.documents))
|
|
29
|
+
return null;
|
|
30
|
+
const documents = value.documents;
|
|
31
|
+
return documents.every((document) => plain(document) && typeof document.room === 'string' && typeof document.path === 'string')
|
|
32
|
+
? { documents: documents, ...window }
|
|
33
|
+
: null;
|
|
34
|
+
}
|
|
35
|
+
export function entrySeedOf(value) {
|
|
36
|
+
if (!plain(value) || !plain(value.at) || !Array.isArray(value.queries))
|
|
37
|
+
return null;
|
|
38
|
+
const at = {};
|
|
39
|
+
for (const [room, version] of Object.entries(value.at)) {
|
|
40
|
+
if (typeof version !== 'string')
|
|
41
|
+
return null;
|
|
42
|
+
at[room] = version;
|
|
43
|
+
}
|
|
44
|
+
const queries = [];
|
|
45
|
+
for (const entry of value.queries) {
|
|
46
|
+
if (!plain(entry) || !plain(entry.query))
|
|
47
|
+
return null;
|
|
48
|
+
const rows = rowsOf(entry.rows);
|
|
49
|
+
if (rows === null)
|
|
50
|
+
return null;
|
|
51
|
+
queries.push({ query: entry.query, rows });
|
|
52
|
+
}
|
|
53
|
+
return { at, queries };
|
|
54
|
+
}
|
|
55
|
+
export function seededResult(seed) {
|
|
56
|
+
const coverage = {
|
|
57
|
+
rooms: Object.entries(seed.at).map(([room, generation]) => ({
|
|
58
|
+
room,
|
|
59
|
+
generation,
|
|
60
|
+
current: false,
|
|
61
|
+
})),
|
|
62
|
+
indexes: [],
|
|
63
|
+
overlay: [],
|
|
64
|
+
};
|
|
65
|
+
if ('groups' in seed.rows) {
|
|
66
|
+
return {
|
|
67
|
+
result: { ...seed.rows, coverage },
|
|
68
|
+
keys: seed.rows.groups.map((_group, index) => index),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
result: { ...seed.rows, coverage },
|
|
73
|
+
keys: seed.rows.documents.map((document) => documentKey(document.room, document.path)),
|
|
74
|
+
};
|
|
75
|
+
}
|
package/dist/status.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Open } from './open.js';
|
|
2
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
2
3
|
import type { ReturnReason } from './room-draft.js';
|
|
3
4
|
export type AttentionEntry = {
|
|
4
5
|
room: string;
|
|
5
6
|
path: string;
|
|
6
7
|
returned: ReturnReason;
|
|
8
|
+
} | {
|
|
9
|
+
room: string;
|
|
10
|
+
refusal: ProviderRefusal;
|
|
7
11
|
};
|
|
8
12
|
export type SyncStatus = {
|
|
9
13
|
state: Open<'pending' | 'syncing' | 'synced'>;
|
package/dist/status.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,IAAI,CAAC,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC;IAC9C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,UAMtB,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAE3D;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAErD;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAQhE"}
|
package/dist/store.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { ChatDraftFile } from './file.js';
|
|
|
7
7
|
import type { Submission } from './outcome.js';
|
|
8
8
|
import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
|
|
9
9
|
export declare const STORE_SCHEMA = 25;
|
|
10
|
-
export declare const AUTHORED_SCHEMA =
|
|
10
|
+
export declare const AUTHORED_SCHEMA = 3;
|
|
11
11
|
export type ReplicaRecord = {
|
|
12
12
|
locator: string;
|
|
13
13
|
name: string;
|
|
@@ -23,10 +23,11 @@ export type ReplicaRecord = {
|
|
|
23
23
|
documents: Readonly<Record<string, string>>;
|
|
24
24
|
binaries: Readonly<Record<string, HeldBinary>>;
|
|
25
25
|
revisions: Readonly<Record<string, string>>;
|
|
26
|
+
fileIds: Readonly<Record<string, string>>;
|
|
26
27
|
changes: Readonly<Record<string, HeadChange>>;
|
|
27
28
|
written: Readonly<Record<string, string>>;
|
|
28
29
|
};
|
|
29
|
-
export type StagedLayer = Pick<ReplicaRecord, 'documents' | 'binaries' | 'revisions' | 'changes' | 'written'>;
|
|
30
|
+
export type StagedLayer = Pick<ReplicaRecord, 'documents' | 'binaries' | 'revisions' | 'fileIds' | 'changes' | 'written'>;
|
|
30
31
|
export type TransferRecord = {
|
|
31
32
|
locator: string;
|
|
32
33
|
transfer: string;
|
|
@@ -46,6 +47,9 @@ export type PendingState = {
|
|
|
46
47
|
readonly upload?: unknown;
|
|
47
48
|
readonly accepted?: string;
|
|
48
49
|
};
|
|
50
|
+
export type TargetRecord = {
|
|
51
|
+
established: boolean;
|
|
52
|
+
};
|
|
49
53
|
export type QueueRecord = {
|
|
50
54
|
locator: string;
|
|
51
55
|
pending: readonly {
|
|
@@ -62,6 +66,10 @@ export type HeldConversation = {
|
|
|
62
66
|
read: string | null | undefined;
|
|
63
67
|
partial: boolean;
|
|
64
68
|
};
|
|
69
|
+
export type MessageWindow = {
|
|
70
|
+
messages: AcceptedMessage[];
|
|
71
|
+
more: boolean;
|
|
72
|
+
};
|
|
65
73
|
export type ConversationWrite = {
|
|
66
74
|
conversation: string;
|
|
67
75
|
messages: readonly AcceptedMessage[];
|
|
@@ -82,6 +90,12 @@ export type ChatDraftRecord = {
|
|
|
82
90
|
files: readonly ChatDraftFile[];
|
|
83
91
|
revision: string;
|
|
84
92
|
submitted?: readonly ChatSubmission[];
|
|
93
|
+
moves?: readonly string[];
|
|
94
|
+
};
|
|
95
|
+
export type CallRecord = {
|
|
96
|
+
readonly operation: string;
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly input: unknown;
|
|
85
99
|
};
|
|
86
100
|
export type RecordWrite = {
|
|
87
101
|
next: ReplicaRecord;
|
|
@@ -91,6 +105,7 @@ export type RecordWrite = {
|
|
|
91
105
|
export type AuthoredWrite = {
|
|
92
106
|
locator: string;
|
|
93
107
|
queue: readonly ChangeBatch[];
|
|
108
|
+
founded?: readonly ChangeBatch[];
|
|
94
109
|
saved?: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
95
110
|
roomDrafts?: readonly RoomDraftRecord[];
|
|
96
111
|
consumedRoomDrafts?: readonly string[];
|
|
@@ -107,6 +122,8 @@ export type RuntimeStore = {
|
|
|
107
122
|
declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[]): Promise<void>;
|
|
108
123
|
member(): Promise<Member | null>;
|
|
109
124
|
keepMember(member: Member | null): Promise<void>;
|
|
125
|
+
targets(): Promise<Readonly<Record<string, TargetRecord>>>;
|
|
126
|
+
keepTargets(targets: Readonly<Record<string, TargetRecord>>): Promise<void>;
|
|
110
127
|
queues(): Promise<readonly QueueRecord[]>;
|
|
111
128
|
submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
|
|
112
129
|
accept(locator: string, id: string, roomVersion: string): Promise<void>;
|
|
@@ -116,14 +133,18 @@ export type RuntimeStore = {
|
|
|
116
133
|
present(record: PresentationRecord): Promise<void>;
|
|
117
134
|
conversations(): Promise<readonly HeldConversation[]>;
|
|
118
135
|
keepMessages(write: ConversationWrite): Promise<void>;
|
|
119
|
-
messageWindow(conversation: string, limit: number | undefined): Promise<
|
|
136
|
+
messageWindow(conversation: string, limit: number | undefined, before: readonly [string, string] | null): Promise<MessageWindow>;
|
|
137
|
+
messageCount(conversation: string): Promise<number>;
|
|
120
138
|
messagesAfter(conversation: string, identity: string | null): Promise<AcceptedMessage[]>;
|
|
121
139
|
messageIdentities(conversation: string): Promise<readonly string[]>;
|
|
122
140
|
turnArrived(conversation: string, turn: string): Promise<boolean>;
|
|
123
141
|
dropConversations(conversations: readonly string[]): Promise<void>;
|
|
124
142
|
chatDrafts(): Promise<readonly ChatDraftRecord[]>;
|
|
125
|
-
|
|
143
|
+
keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
|
|
126
144
|
dropChatDraft(conversation: string): Promise<void>;
|
|
145
|
+
calls(): Promise<readonly CallRecord[]>;
|
|
146
|
+
keepCall(record: CallRecord): Promise<void>;
|
|
147
|
+
dropCall(operation: string): Promise<void>;
|
|
127
148
|
keepRoomDraft(record: RoomDraftRecord): Promise<void>;
|
|
128
149
|
discardRoomDraft(locator: string, path: string): Promise<void>;
|
|
129
150
|
fences(): Promise<readonly string[]>;
|
|
@@ -149,5 +170,6 @@ export declare function authoredBy(holder: string): Promise<boolean>;
|
|
|
149
170
|
export declare function authoredBinding(): Promise<string | null>;
|
|
150
171
|
export declare function bindAuthored(binding: string): Promise<void>;
|
|
151
172
|
export declare function removeRuntimeStore(holder?: string): Promise<boolean>;
|
|
173
|
+
export declare function openDatabase(name: string, version: number, upgrade: (opening: IDBOpenDBRequest, oldVersion: number) => void): Promise<IDBDatabase>;
|
|
152
174
|
export declare function openRuntimeStore(fenced: (locator: string) => boolean): Promise<RuntimeStore>;
|
|
153
175
|
//# sourceMappingURL=store.d.ts.map
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,MAAM,EACN,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,MAAM,EACN,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MA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AAO,CAAC,OAAO,CAAC,CAK1E;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,GAC/D,OAAO,CAAC,WAAW,CAAC,CAetB;AA4BD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GACnC,OAAO,CAAC,YAAY,CAAC,CA8cvB"}
|
package/dist/store.js
CHANGED
|
@@ -16,21 +16,24 @@ const PRESENTATION = 'presentation';
|
|
|
16
16
|
const CONVERSATIONS = 'conversations';
|
|
17
17
|
const MESSAGES = 'messages';
|
|
18
18
|
const CHAT_DRAFTS = 'chatDrafts';
|
|
19
|
+
const CALLS = 'calls';
|
|
19
20
|
const QUEUES = 'queues';
|
|
20
21
|
const FACTS = 'facts';
|
|
21
22
|
const CURRENT = 'current';
|
|
22
23
|
const MEMBER = 'member';
|
|
24
|
+
const TARGETS = 'targets';
|
|
23
25
|
const GENERATION = 'generation';
|
|
24
26
|
const HOLDER = 'holder';
|
|
25
27
|
const BINDING = 'binding';
|
|
26
28
|
export const STORE_SCHEMA = 25;
|
|
27
29
|
const REPLICA_SHAPE = 23;
|
|
28
|
-
export const AUTHORED_SCHEMA =
|
|
30
|
+
export const AUTHORED_SCHEMA = 3;
|
|
29
31
|
const AUTHORED_STORES = [
|
|
30
32
|
[QUEUES, { keyPath: 'locator' }],
|
|
31
33
|
[PENDING_CHANGES, { keyPath: ['locator', 'id'] }],
|
|
32
34
|
[ROOM_DRAFTS, { keyPath: ['locator', 'path'] }],
|
|
33
35
|
[CHAT_DRAFTS, { keyPath: 'conversation' }],
|
|
36
|
+
[CALLS, { keyPath: 'operation' }],
|
|
34
37
|
[FACTS, undefined],
|
|
35
38
|
[FENCES, { keyPath: 'locator' }],
|
|
36
39
|
];
|
|
@@ -98,7 +101,7 @@ function accepted({ conversation: _held, ...message }) {
|
|
|
98
101
|
return message;
|
|
99
102
|
}
|
|
100
103
|
function roomRecord(record) {
|
|
101
|
-
const { documents, binaries, revisions, changes, written, ...room } = record;
|
|
104
|
+
const { documents, binaries, revisions, fileIds, changes, written, ...room } = record;
|
|
102
105
|
return room;
|
|
103
106
|
}
|
|
104
107
|
function chatDraftRecord(record) {
|
|
@@ -124,13 +127,15 @@ async function readTransfer(store, locator, transfer, receive) {
|
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
function emptyLayer() {
|
|
127
|
-
return { documents: {}, binaries: {}, revisions: {}, changes: {}, written: {} };
|
|
130
|
+
return { documents: {}, binaries: {}, revisions: {}, fileIds: {}, changes: {}, written: {} };
|
|
128
131
|
}
|
|
129
132
|
async function readLayer(transaction, locator, transfer) {
|
|
130
133
|
const layer = emptyLayer();
|
|
131
134
|
const head = (held) => {
|
|
132
135
|
if (held.revision !== null)
|
|
133
136
|
layer.revisions[held.path] = held.revision;
|
|
137
|
+
if (held.fileId !== null)
|
|
138
|
+
layer.fileIds[held.path] = held.fileId;
|
|
134
139
|
if (held.change !== null)
|
|
135
140
|
layer.changes[held.path] = held.change;
|
|
136
141
|
};
|
|
@@ -153,6 +158,7 @@ function documentRecord(locator, transfer, layer, path) {
|
|
|
153
158
|
path,
|
|
154
159
|
content: layer.documents[path],
|
|
155
160
|
revision: layer.revisions[path] ?? null,
|
|
161
|
+
fileId: layer.fileIds[path] ?? null,
|
|
156
162
|
change: layer.changes[path] ?? null,
|
|
157
163
|
written: layer.written[path] ?? null,
|
|
158
164
|
};
|
|
@@ -163,6 +169,7 @@ function binaryFileRecord(locator, transfer, layer, path) {
|
|
|
163
169
|
transfer,
|
|
164
170
|
path,
|
|
165
171
|
revision: layer.revisions[path] ?? null,
|
|
172
|
+
fileId: layer.fileIds[path] ?? null,
|
|
166
173
|
change: layer.changes[path] ?? null,
|
|
167
174
|
binary: layer.binaries[path],
|
|
168
175
|
};
|
|
@@ -175,6 +182,7 @@ function writeLayer(transaction, locator, transfer, next, base) {
|
|
|
175
182
|
: new Set([
|
|
176
183
|
...differing(base.documents, next.documents),
|
|
177
184
|
...differing(base.revisions, next.revisions),
|
|
185
|
+
...differing(base.fileIds, next.fileIds),
|
|
178
186
|
...differing(base.written, next.written),
|
|
179
187
|
...differing(base.changes, next.changes, sameChange),
|
|
180
188
|
...differing(base.binaries, next.binaries, sameBinary),
|
|
@@ -272,11 +280,26 @@ export async function removeRuntimeStore(holder) {
|
|
|
272
280
|
await removeDatabase(AUTHORED);
|
|
273
281
|
return false;
|
|
274
282
|
}
|
|
283
|
+
export function openDatabase(name, version, upgrade) {
|
|
284
|
+
return new Promise((resolve, reject) => {
|
|
285
|
+
const opening = indexedDB.open(name, version);
|
|
286
|
+
opening.onupgradeneeded = (event) => upgrade(opening, event.oldVersion);
|
|
287
|
+
opening.onsuccess = () => resolve(opening.result);
|
|
288
|
+
opening.onerror = () => {
|
|
289
|
+
if (opening.error?.name !== 'VersionError') {
|
|
290
|
+
reject(opening.error);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
removeDatabase(name)
|
|
294
|
+
.then(() => openDatabase(name, version, upgrade))
|
|
295
|
+
.then(resolve, reject);
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
}
|
|
275
299
|
function openReplica() {
|
|
276
|
-
|
|
277
|
-
opening.onupgradeneeded = (event) => {
|
|
300
|
+
return openDatabase(DATABASE, STORE_SCHEMA, (opening, oldVersion) => {
|
|
278
301
|
const database = opening.result;
|
|
279
|
-
if (
|
|
302
|
+
if (oldVersion < REPLICA_SHAPE) {
|
|
280
303
|
for (const name of [...database.objectStoreNames])
|
|
281
304
|
database.deleteObjectStore(name);
|
|
282
305
|
}
|
|
@@ -290,19 +313,16 @@ function openReplica() {
|
|
|
290
313
|
if (!messages.indexNames.contains(name))
|
|
291
314
|
messages.createIndex(name, keyPath);
|
|
292
315
|
}
|
|
293
|
-
};
|
|
294
|
-
return settled(opening);
|
|
316
|
+
});
|
|
295
317
|
}
|
|
296
318
|
function openAuthored() {
|
|
297
|
-
|
|
298
|
-
opening.onupgradeneeded = () => {
|
|
319
|
+
return openDatabase(AUTHORED, AUTHORED_SCHEMA, (opening) => {
|
|
299
320
|
const database = opening.result;
|
|
300
321
|
for (const [name, parameters] of AUTHORED_STORES) {
|
|
301
322
|
if (!database.objectStoreNames.contains(name))
|
|
302
323
|
database.createObjectStore(name, parameters);
|
|
303
324
|
}
|
|
304
|
-
};
|
|
305
|
-
return settled(opening);
|
|
325
|
+
});
|
|
306
326
|
}
|
|
307
327
|
export async function openRuntimeStore(fenced) {
|
|
308
328
|
const authored = await openAuthored();
|
|
@@ -320,7 +340,7 @@ export async function openRuntimeStore(fenced) {
|
|
|
320
340
|
}
|
|
321
341
|
return records;
|
|
322
342
|
},
|
|
323
|
-
async keepAuthored({ locator, queue, saved, roomDrafts, consumedRoomDrafts }) {
|
|
343
|
+
async keepAuthored({ locator, queue, founded, saved, roomDrafts, consumedRoomDrafts }) {
|
|
324
344
|
if (fenced(locator))
|
|
325
345
|
return;
|
|
326
346
|
const transaction = authored.transaction([QUEUES, PENDING_CHANGES, ROOM_DRAFTS], 'readwrite');
|
|
@@ -350,6 +370,16 @@ export async function openRuntimeStore(fenced) {
|
|
|
350
370
|
});
|
|
351
371
|
}
|
|
352
372
|
}
|
|
373
|
+
for (const batch of founded ?? []) {
|
|
374
|
+
if (!before.has(batch.id))
|
|
375
|
+
continue;
|
|
376
|
+
const stored = pending.get([locator, batch.id]);
|
|
377
|
+
stored.onsuccess = () => {
|
|
378
|
+
const record = stored.result;
|
|
379
|
+
if (record !== undefined)
|
|
380
|
+
pending.put({ ...record, batch });
|
|
381
|
+
};
|
|
382
|
+
}
|
|
353
383
|
};
|
|
354
384
|
const draftStore = transaction.objectStore(ROOM_DRAFTS);
|
|
355
385
|
for (const path of consumedRoomDrafts ?? [])
|
|
@@ -414,6 +444,16 @@ export async function openRuntimeStore(fenced) {
|
|
|
414
444
|
transaction.objectStore(DECLARATIONS).put(member, MEMBER);
|
|
415
445
|
await completed(transaction);
|
|
416
446
|
},
|
|
447
|
+
async targets() {
|
|
448
|
+
const transaction = database.transaction(DECLARATIONS, 'readonly');
|
|
449
|
+
const held = await settled(transaction.objectStore(DECLARATIONS).get(TARGETS));
|
|
450
|
+
return held ?? {};
|
|
451
|
+
},
|
|
452
|
+
async keepTargets(targets) {
|
|
453
|
+
const transaction = database.transaction(DECLARATIONS, 'readwrite');
|
|
454
|
+
transaction.objectStore(DECLARATIONS).put(targets, TARGETS);
|
|
455
|
+
await completed(transaction);
|
|
456
|
+
},
|
|
417
457
|
async queues() {
|
|
418
458
|
const transaction = authored.transaction([QUEUES, PENDING_CHANGES], 'readonly');
|
|
419
459
|
const [queues, pending] = await Promise.all([
|
|
@@ -501,16 +541,17 @@ export async function openRuntimeStore(fenced) {
|
|
|
501
541
|
}
|
|
502
542
|
await completed(transaction);
|
|
503
543
|
},
|
|
504
|
-
async messageWindow(conversation, limit) {
|
|
544
|
+
async messageWindow(conversation, limit, before) {
|
|
505
545
|
const transaction = database.transaction(MESSAGES, 'readonly');
|
|
506
546
|
const index = transaction.objectStore(MESSAGES).index('position');
|
|
507
|
-
const range = IDBKeyRange.bound([conversation], [conversation, []]);
|
|
547
|
+
const range = IDBKeyRange.bound([conversation], [conversation, before?.[0] ?? []]);
|
|
548
|
+
const earlier = ({ position, identity }) => before === null || position < before[0] || (position === before[0] && identity < before[1]);
|
|
508
549
|
if (limit === undefined) {
|
|
509
|
-
|
|
550
|
+
const held = await settled(index.getAll(range));
|
|
551
|
+
return { messages: held.filter(earlier).map(accepted), more: false };
|
|
510
552
|
}
|
|
511
553
|
const latest = [];
|
|
512
|
-
|
|
513
|
-
return latest;
|
|
554
|
+
let more = false;
|
|
514
555
|
await new Promise((resolve, reject) => {
|
|
515
556
|
const cursor = index.openCursor(range, 'prev');
|
|
516
557
|
cursor.onerror = () => reject(cursor.error);
|
|
@@ -520,14 +561,25 @@ export async function openRuntimeStore(fenced) {
|
|
|
520
561
|
resolve();
|
|
521
562
|
return;
|
|
522
563
|
}
|
|
523
|
-
|
|
524
|
-
if (
|
|
525
|
-
resolve();
|
|
526
|
-
else
|
|
564
|
+
const record = at.value;
|
|
565
|
+
if (!earlier(record)) {
|
|
527
566
|
at.continue();
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
if (latest.length === limit) {
|
|
570
|
+
more = true;
|
|
571
|
+
resolve();
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
latest.push(accepted(record));
|
|
575
|
+
at.continue();
|
|
528
576
|
};
|
|
529
577
|
});
|
|
530
|
-
return latest.reverse();
|
|
578
|
+
return { messages: latest.reverse(), more };
|
|
579
|
+
},
|
|
580
|
+
async messageCount(conversation) {
|
|
581
|
+
const transaction = database.transaction(MESSAGES, 'readonly');
|
|
582
|
+
return settled(transaction.objectStore(MESSAGES).index('conversation').count(conversation));
|
|
531
583
|
},
|
|
532
584
|
async messagesAfter(conversation, identity) {
|
|
533
585
|
const transaction = database.transaction(MESSAGES, 'readonly');
|
|
@@ -569,9 +621,10 @@ export async function openRuntimeStore(fenced) {
|
|
|
569
621
|
const held = await settled(transaction.objectStore(CHAT_DRAFTS).getAll());
|
|
570
622
|
return held.map(chatDraftRecord);
|
|
571
623
|
},
|
|
572
|
-
async
|
|
624
|
+
async keepChatDrafts(records) {
|
|
573
625
|
const transaction = authored.transaction(CHAT_DRAFTS, 'readwrite');
|
|
574
|
-
|
|
626
|
+
for (const record of records)
|
|
627
|
+
transaction.objectStore(CHAT_DRAFTS).put(record);
|
|
575
628
|
await completed(transaction);
|
|
576
629
|
},
|
|
577
630
|
async dropChatDraft(conversation) {
|
|
@@ -579,6 +632,20 @@ export async function openRuntimeStore(fenced) {
|
|
|
579
632
|
transaction.objectStore(CHAT_DRAFTS).delete(conversation);
|
|
580
633
|
await completed(transaction);
|
|
581
634
|
},
|
|
635
|
+
async calls() {
|
|
636
|
+
const transaction = authored.transaction(CALLS, 'readonly');
|
|
637
|
+
return settled(transaction.objectStore(CALLS).getAll());
|
|
638
|
+
},
|
|
639
|
+
async keepCall(record) {
|
|
640
|
+
const transaction = authored.transaction(CALLS, 'readwrite');
|
|
641
|
+
transaction.objectStore(CALLS).put(record);
|
|
642
|
+
await completed(transaction);
|
|
643
|
+
},
|
|
644
|
+
async dropCall(operation) {
|
|
645
|
+
const transaction = authored.transaction(CALLS, 'readwrite');
|
|
646
|
+
transaction.objectStore(CALLS).delete(operation);
|
|
647
|
+
await completed(transaction);
|
|
648
|
+
},
|
|
582
649
|
async keepRoomDraft(record) {
|
|
583
650
|
if (fenced(record.locator))
|
|
584
651
|
return;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const MAXIMUM_WINDOW = 1000;
|
|
2
|
+
export declare const FROM_START = "[]";
|
|
3
|
+
export type Ordering = {
|
|
4
|
+
readonly direction: 'asc' | 'desc';
|
|
5
|
+
readonly nulls: 'first' | 'last';
|
|
6
|
+
readonly stringSort: 'lexical' | 'locale';
|
|
7
|
+
readonly locale: string | undefined;
|
|
8
|
+
readonly localeOptions: Intl.CollatorOptions | undefined;
|
|
9
|
+
};
|
|
10
|
+
export type Windowed<T> = {
|
|
11
|
+
readonly kept: readonly T[];
|
|
12
|
+
readonly next: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export declare function beyond(values: readonly unknown[], cursor: readonly unknown[], orderings: readonly Ordering[]): boolean;
|
|
15
|
+
export declare function cursorOf(values: readonly unknown[]): string;
|
|
16
|
+
export declare function decodedCursor(text: string): readonly unknown[] | null;
|
|
17
|
+
export declare function windowed<T>(entries: readonly T[], limit: number | null, after: string | undefined, cursor: (entry: T) => string): Windowed<T>;
|
|
18
|
+
//# sourceMappingURL=windows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windows.d.ts","sourceRoot":"","sources":["../src/windows.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,OAAO,CAAC;AAEn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4
|
+
if (left == null && right == null)
|
|
5
|
+
return 0;
|
|
6
|
+
if (left == null)
|
|
7
|
+
return ordering.nulls === 'first' ? -1 : 1;
|
|
8
|
+
if (right == null)
|
|
9
|
+
return ordering.nulls === 'first' ? 1 : -1;
|
|
10
|
+
if (typeof left === 'string' && typeof right === 'string' && ordering.stringSort === 'locale') {
|
|
11
|
+
return left.localeCompare(right, ordering.locale, ordering.localeOptions);
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
14
|
+
for (let at = 0; at < Math.min(left.length, right.length); at += 1) {
|
|
15
|
+
const result = ascending(left[at], right[at], ordering);
|
|
16
|
+
if (result !== 0)
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
return left.length - right.length;
|
|
20
|
+
}
|
|
21
|
+
if (typeof left === 'object')
|
|
22
|
+
return typeof right === 'object' ? 0 : 1;
|
|
23
|
+
if (typeof right === 'object')
|
|
24
|
+
return -1;
|
|
25
|
+
const held = left;
|
|
26
|
+
const other = right;
|
|
27
|
+
if (held < other)
|
|
28
|
+
return -1;
|
|
29
|
+
if (held > other)
|
|
30
|
+
return 1;
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
function compared(left, right, ordering) {
|
|
34
|
+
if (ordering.direction === 'asc')
|
|
35
|
+
return ascending(left, right, ordering);
|
|
36
|
+
return ascending(right, left, {
|
|
37
|
+
...ordering,
|
|
38
|
+
nulls: ordering.nulls === 'first' ? 'last' : 'first',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function keyCompared(left, right) {
|
|
42
|
+
if (typeof left !== typeof right)
|
|
43
|
+
return typeof left === 'string' ? -1 : 1;
|
|
44
|
+
const held = left;
|
|
45
|
+
const other = right;
|
|
46
|
+
if (held < other)
|
|
47
|
+
return -1;
|
|
48
|
+
if (held > other)
|
|
49
|
+
return 1;
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
export function beyond(values, cursor, orderings) {
|
|
53
|
+
for (let at = 0; at < orderings.length; at += 1) {
|
|
54
|
+
const result = compared(values[at], cursor[at], orderings[at]);
|
|
55
|
+
if (result !== 0)
|
|
56
|
+
return result > 0;
|
|
57
|
+
}
|
|
58
|
+
return keyCompared(values[orderings.length], cursor[orderings.length]) > 0;
|
|
59
|
+
}
|
|
60
|
+
export function cursorOf(values) {
|
|
61
|
+
return JSON.stringify(values);
|
|
62
|
+
}
|
|
63
|
+
export function decodedCursor(text) {
|
|
64
|
+
try {
|
|
65
|
+
const decoded = JSON.parse(text);
|
|
66
|
+
return Array.isArray(decoded) ? decoded : null;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function windowed(entries, limit, after, cursor) {
|
|
73
|
+
if (limit === null || entries.length <= limit)
|
|
74
|
+
return { kept: entries, next: undefined };
|
|
75
|
+
const kept = entries.slice(0, limit);
|
|
76
|
+
return {
|
|
77
|
+
kept,
|
|
78
|
+
next: kept.length === 0 ? (after ?? FROM_START) : cursor(kept[kept.length - 1]),
|
|
79
|
+
};
|
|
80
|
+
}
|