@agentshouse/mdruntime 0.1.0-alpha.8 → 0.1.0-c436a939f2119
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 +210 -0
- package/README.md +44 -0
- package/dist/adapter.d.ts +223 -25
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +2 -3
- package/dist/attachment.d.ts +3 -0
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +8 -0
- package/dist/bootstrap.d.ts +6 -7
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +32 -28
- package/dist/change-set.d.ts +33 -0
- package/dist/change-set.d.ts.map +1 -0
- package/dist/change-set.js +87 -0
- package/dist/change.d.ts +9 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +6 -5
- package/dist/client.d.ts +75 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +171 -0
- package/dist/collection.d.ts +24 -15
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +69 -77
- package/dist/connection.d.ts +79 -36
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1699 -953
- package/dist/conversation.d.ts +79 -0
- package/dist/conversation.d.ts.map +1 -0
- package/dist/conversation.js +557 -0
- package/dist/durability.d.ts +8 -3
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -61
- package/dist/file.d.ts +20 -0
- package/dist/file.d.ts.map +1 -0
- package/dist/file.js +126 -0
- package/dist/host.d.ts +14 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +198 -0
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +10 -9
- package/dist/index.d.ts +14 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/log.js +5 -6
- package/dist/memory.d.ts +17 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +269 -113
- package/dist/model.d.ts +10 -25
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +18 -21
- package/dist/observation.d.ts +25 -0
- package/dist/observation.d.ts.map +1 -0
- package/dist/observation.js +85 -0
- package/dist/outcome.d.ts +22 -18
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +1 -13
- package/dist/overlay.d.ts +9 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +187 -43
- package/dist/paths.d.ts +0 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +12 -19
- package/dist/query.d.ts +210 -9
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +420 -15
- package/dist/read-side.d.ts +14 -0
- package/dist/read-side.d.ts.map +1 -0
- package/dist/read-side.js +371 -0
- package/dist/refresh.d.ts +4 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +45 -30
- package/dist/replica.d.ts +27 -6
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +237 -30
- package/dist/room-draft.d.ts +124 -0
- package/dist/room-draft.d.ts.map +1 -0
- package/dist/room-draft.js +327 -0
- package/dist/rows.d.ts +41 -0
- package/dist/rows.d.ts.map +1 -0
- package/dist/rows.js +100 -0
- package/dist/save.d.ts +10 -6
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +267 -333
- package/dist/search.d.ts +61 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +125 -0
- package/dist/status.d.ts +9 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +11 -14
- package/dist/store.d.ts +85 -18
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +380 -97
- package/dist/transfer.d.ts +5 -0
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transfer.js +1 -5
- package/dist/wire.d.ts +64 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +124 -0
- package/package.json +15 -13
- package/dist/adapter.js.map +0 -1
- package/dist/bootstrap.js.map +0 -1
- package/dist/change.js.map +0 -1
- package/dist/collection.js.map +0 -1
- package/dist/connection.js.map +0 -1
- package/dist/durability.js.map +0 -1
- package/dist/identity.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/log.js.map +0 -1
- package/dist/memory.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/outcome.js.map +0 -1
- package/dist/overlay.js.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/query.js.map +0 -1
- package/dist/refresh.js.map +0 -1
- package/dist/replica.js.map +0 -1
- package/dist/save.js.map +0 -1
- package/dist/status.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/transfer.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function declaredAttachments(pages) {
|
|
2
|
+
const byReference = new Map();
|
|
3
|
+
for (const page of pages) {
|
|
4
|
+
for (const attachment of page)
|
|
5
|
+
byReference.set(attachment.reference, attachment);
|
|
6
|
+
}
|
|
7
|
+
return [...byReference.values()].sort((left, right) => left.reference < right.reference ? -1 : left.reference > right.reference ? 1 : 0);
|
|
8
|
+
}
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { AttachedModelBinding } from './model.js';
|
|
2
1
|
import type { ModelState } from './model.js';
|
|
3
2
|
import type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';
|
|
4
|
-
import { type
|
|
3
|
+
import { type Staged } from './replica.js';
|
|
5
4
|
import { type Unconfirmed } from './transfer.js';
|
|
6
|
-
export type BootstrapOutcome =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export type BootstrapOutcome = Staged | Unconfirmed | AdapterFailure;
|
|
6
|
+
export declare function bootstrapRoom(adapter: Adapter, authorization: Authorization, room: DiscoveredRoom, models: {
|
|
7
|
+
collection: ModelState;
|
|
8
|
+
selection: ModelState;
|
|
9
|
+
}, continuing: () => boolean): Promise<BootstrapOutcome>;
|
|
11
10
|
//# sourceMappingURL=bootstrap.d.ts.map
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,aAAa,EACb,cAAc,EAGf,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,WAAW,GAAG,cAAc,CAAC;AAErE,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,EACzD,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAgD3B"}
|
package/dist/bootstrap.js
CHANGED
|
@@ -1,53 +1,57 @@
|
|
|
1
|
+
import { declaredAttachments } from './attachment.js';
|
|
1
2
|
import { readStaged } from './replica.js';
|
|
2
3
|
import { unconfirmed } from './transfer.js';
|
|
3
|
-
export async function bootstrapRoom(adapter, authorization, room,
|
|
4
|
+
export async function bootstrapRoom(adapter, authorization, room, models, continuing) {
|
|
4
5
|
const first = await adapter.bootstrap(authorization, {
|
|
5
6
|
locator: room.locator,
|
|
6
|
-
selection: room.replica.selection
|
|
7
|
+
selection: room.replica.selection,
|
|
7
8
|
});
|
|
8
|
-
if (first.kind !== 'bootstrap')
|
|
9
|
+
if (first.kind !== 'bootstrap')
|
|
10
|
+
return first;
|
|
9
11
|
const roomVersion = first.roomVersion;
|
|
10
|
-
const documents = {
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
const revisions = {
|
|
14
|
-
...first.revisions
|
|
15
|
-
};
|
|
12
|
+
const documents = { ...first.documents };
|
|
13
|
+
const revisions = { ...first.revisions };
|
|
14
|
+
const changes = { ...first.changes };
|
|
16
15
|
const binaryTargets = new Set(first.binaryTargets);
|
|
16
|
+
const attachments = [first.attachments ?? []];
|
|
17
17
|
let pageToken = first.pageToken;
|
|
18
|
-
while(pageToken !== undefined){
|
|
18
|
+
while (pageToken !== undefined) {
|
|
19
|
+
if (!continuing())
|
|
20
|
+
return unconfirmed;
|
|
19
21
|
const page = await adapter.bootstrap(authorization, {
|
|
20
22
|
locator: room.locator,
|
|
21
23
|
selection: room.replica.selection,
|
|
22
|
-
pageToken
|
|
24
|
+
pageToken,
|
|
23
25
|
});
|
|
24
|
-
if (page.kind !== 'bootstrap')
|
|
25
|
-
|
|
26
|
+
if (page.kind !== 'bootstrap')
|
|
27
|
+
return page;
|
|
28
|
+
if (page.roomVersion !== roomVersion)
|
|
29
|
+
return unconfirmed;
|
|
26
30
|
Object.assign(documents, page.documents);
|
|
27
31
|
Object.assign(revisions, page.revisions);
|
|
28
|
-
|
|
32
|
+
Object.assign(changes, page.changes);
|
|
33
|
+
for (const target of page.binaryTargets)
|
|
34
|
+
binaryTargets.add(target);
|
|
35
|
+
attachments.push(page.attachments ?? []);
|
|
29
36
|
pageToken = page.pageToken;
|
|
30
37
|
}
|
|
31
|
-
|
|
38
|
+
return readStaged({
|
|
32
39
|
locator: room.locator,
|
|
33
|
-
collectionRoot: room.collectionRoot,
|
|
34
40
|
name: room.name,
|
|
35
41
|
operations: room.operations,
|
|
36
42
|
replica: room.replica,
|
|
37
43
|
attachedModel: room.attachedModel,
|
|
38
|
-
model,
|
|
44
|
+
model: models.collection,
|
|
45
|
+
typedSelection: room.typedSelection ?? null,
|
|
46
|
+
selectionModel: models.selection,
|
|
47
|
+
untypedFolders: room.untypedFolders ?? [],
|
|
39
48
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
40
49
|
roomVersion,
|
|
41
50
|
documents,
|
|
42
|
-
binaryTargets: [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
kind: 'staged',
|
|
49
|
-
confirmed
|
|
50
|
-
};
|
|
51
|
+
binaryTargets: [...binaryTargets].sort(),
|
|
52
|
+
revisions,
|
|
53
|
+
changes,
|
|
54
|
+
written: Object.fromEntries(Object.keys(documents).map((path) => [path, roomVersion])),
|
|
55
|
+
attachments: declaredAttachments(attachments),
|
|
56
|
+
});
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Replica } from './replica.js';
|
|
2
|
+
import { type Row } from './rows.js';
|
|
3
|
+
export type DocumentChange = {
|
|
4
|
+
locator: string;
|
|
5
|
+
path: string;
|
|
6
|
+
before: readonly Row[];
|
|
7
|
+
after: readonly Row[];
|
|
8
|
+
};
|
|
9
|
+
export type MessageChange = {
|
|
10
|
+
conversation: string;
|
|
11
|
+
identity: string;
|
|
12
|
+
};
|
|
13
|
+
export type ChangeSet = {
|
|
14
|
+
documents: readonly DocumentChange[];
|
|
15
|
+
drafts: readonly {
|
|
16
|
+
locator: string;
|
|
17
|
+
path: string;
|
|
18
|
+
}[];
|
|
19
|
+
rooms: readonly string[];
|
|
20
|
+
queues: readonly string[];
|
|
21
|
+
presentations: readonly string[];
|
|
22
|
+
messages: readonly MessageChange[];
|
|
23
|
+
conversations: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: {
|
|
26
|
+
drafts?: readonly string[];
|
|
27
|
+
room?: boolean;
|
|
28
|
+
queue?: boolean;
|
|
29
|
+
presentation?: string;
|
|
30
|
+
}): ChangeSet;
|
|
31
|
+
export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
|
|
32
|
+
export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
|
|
33
|
+
//# sourceMappingURL=change-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../src/change-set.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAU,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,EAAE,CAAC;IACvB,KAAK,EAAE,SAAS,GAAG,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;IACrC,MAAM,EAAE,SAAS;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;AAwBF,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,GAAG,IAAI,EACtB,KAAK,EAAE,OAAO,GAAG,IAAI,EACrB,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,SAAS,CAkDX;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,SAAS,CAUX;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAUrE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { untyped } from './collection.js';
|
|
2
|
+
import { sameChange } from './overlay.js';
|
|
3
|
+
import { beneath } from './paths.js';
|
|
4
|
+
import { compositionOf, sameMembership } from './replica.js';
|
|
5
|
+
import { rowsOf } from './rows.js';
|
|
6
|
+
function rowsAt(locator, replica, path) {
|
|
7
|
+
if (replica === null)
|
|
8
|
+
return [];
|
|
9
|
+
const document = replica.visible.collection.documents[path];
|
|
10
|
+
const carried = Object.hasOwn(replica.visible.documents, path) &&
|
|
11
|
+
untyped(replica.confirmed.record.untypedFolders, path);
|
|
12
|
+
if (document === undefined && !carried && !replica.visible.binaryTargets.includes(path)) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
return rowsOf(locator, path, document ?? null, compositionOf(replica.confirmed.record), replica.visible.changes[path] ?? null);
|
|
16
|
+
}
|
|
17
|
+
function modelShape(model) {
|
|
18
|
+
return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);
|
|
19
|
+
}
|
|
20
|
+
export function changeSet(locator, before, after, changed = {}) {
|
|
21
|
+
const paths = new Set([
|
|
22
|
+
...Object.keys(before?.visible.documents ?? {}),
|
|
23
|
+
...Object.keys(after?.visible.documents ?? {}),
|
|
24
|
+
...(before?.visible.binaryTargets ?? []),
|
|
25
|
+
...(after?.visible.binaryTargets ?? []),
|
|
26
|
+
]);
|
|
27
|
+
const documents = [];
|
|
28
|
+
const oldRoom = before?.confirmed.record;
|
|
29
|
+
const newRoom = after?.confirmed.record;
|
|
30
|
+
const collectionChanged = oldRoom !== undefined &&
|
|
31
|
+
newRoom !== undefined &&
|
|
32
|
+
modelShape(oldRoom.model) !== modelShape(newRoom.model);
|
|
33
|
+
const selectionChanged = oldRoom !== undefined &&
|
|
34
|
+
newRoom !== undefined &&
|
|
35
|
+
modelShape(oldRoom.selectionModel) !== modelShape(newRoom.selectionModel);
|
|
36
|
+
const reclassified = oldRoom !== undefined && newRoom !== undefined && !sameMembership(oldRoom, newRoom);
|
|
37
|
+
for (const path of paths) {
|
|
38
|
+
const selected = newRoom?.typedSelection?.roots.some((root) => beneath(root, path)) ?? false;
|
|
39
|
+
const carried = newRoom !== undefined && untyped(newRoom.untypedFolders, path);
|
|
40
|
+
const retyped = selected ? selectionChanged : !carried && collectionChanged;
|
|
41
|
+
if (before?.visible.documents[path] === after?.visible.documents[path] &&
|
|
42
|
+
before?.visible.binaryTargets.includes(path) ===
|
|
43
|
+
after?.visible.binaryTargets.includes(path) &&
|
|
44
|
+
before?.visible.revisions[path] === after?.visible.revisions[path] &&
|
|
45
|
+
sameChange(before?.visible.changes[path], after?.visible.changes[path]) &&
|
|
46
|
+
!retyped &&
|
|
47
|
+
!reclassified)
|
|
48
|
+
continue;
|
|
49
|
+
documents.push({
|
|
50
|
+
locator,
|
|
51
|
+
path,
|
|
52
|
+
before: rowsAt(locator, before, path),
|
|
53
|
+
after: rowsAt(locator, after, path),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
documents,
|
|
58
|
+
drafts: (changed.drafts ?? []).map((path) => ({ locator, path })),
|
|
59
|
+
rooms: changed.room ? [locator] : [],
|
|
60
|
+
queues: changed.queue ? [locator] : [],
|
|
61
|
+
presentations: changed.presentation === undefined ? [] : [changed.presentation],
|
|
62
|
+
messages: [],
|
|
63
|
+
conversations: [],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function conversationChangeSet(messages, conversations) {
|
|
67
|
+
return {
|
|
68
|
+
documents: [],
|
|
69
|
+
drafts: [],
|
|
70
|
+
rooms: [],
|
|
71
|
+
queues: [],
|
|
72
|
+
presentations: [],
|
|
73
|
+
messages,
|
|
74
|
+
conversations: [...new Set(conversations)],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function mergeChangeSets(sets) {
|
|
78
|
+
return {
|
|
79
|
+
documents: sets.flatMap((set) => set.documents),
|
|
80
|
+
drafts: sets.flatMap((set) => set.drafts),
|
|
81
|
+
rooms: [...new Set(sets.flatMap((set) => set.rooms))],
|
|
82
|
+
queues: [...new Set(sets.flatMap((set) => set.queues))],
|
|
83
|
+
presentations: [...new Set(sets.flatMap((set) => set.presentations))],
|
|
84
|
+
messages: sets.flatMap((set) => set.messages),
|
|
85
|
+
conversations: [...new Set(sets.flatMap((set) => set.conversations))],
|
|
86
|
+
};
|
|
87
|
+
}
|
package/dist/change.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export type Change = {
|
|
|
17
17
|
readonly path: string;
|
|
18
18
|
readonly fields: Readonly<Record<string, unknown>>;
|
|
19
19
|
readonly sections: Readonly<Record<string, string>>;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: 'create';
|
|
22
|
+
readonly path: string;
|
|
23
|
+
readonly content: string;
|
|
20
24
|
} | {
|
|
21
25
|
readonly kind: 'replace';
|
|
22
26
|
readonly path: string;
|
|
@@ -54,12 +58,17 @@ export type Precondition = {
|
|
|
54
58
|
readonly kind: 'absent';
|
|
55
59
|
readonly path: string;
|
|
56
60
|
};
|
|
61
|
+
export type WrittenBy = {
|
|
62
|
+
readonly app: string;
|
|
63
|
+
readonly release: string;
|
|
64
|
+
};
|
|
57
65
|
export type ChangeBatch = {
|
|
58
66
|
validation?: import('./model.js').ValidationReceipt;
|
|
59
67
|
readonly id: string;
|
|
60
68
|
readonly baseRoomVersion: string;
|
|
61
69
|
readonly changes: readonly Change[];
|
|
62
70
|
readonly preconditions: readonly Precondition[];
|
|
71
|
+
readonly writtenBy?: WrittenBy;
|
|
63
72
|
};
|
|
64
73
|
export declare function immutable(batch: ChangeBatch): ChangeBatch;
|
|
65
74
|
//# sourceMappingURL=change.d.ts.map
|
package/dist/change.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change.d.ts","sourceRoot":"","sources":["../src/change.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GACd;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5E;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7E;IAAE,QAAQ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AE,CAAC;AAEvD,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,CAAC,EAAE,OAAO,YAAY,EAAE,iBAAiB,CAAC;IACpD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,SAAS,YAAY,EAAE,CAAC;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAChC,CAAC;AAUF,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAEzD"}
|
package/dist/change.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
function frozen(value) {
|
|
2
|
-
if (Array.isArray(value))
|
|
3
|
-
|
|
2
|
+
if (Array.isArray(value))
|
|
3
|
+
return Object.freeze(value.map((item) => frozen(item)));
|
|
4
|
+
if (value === null || typeof value !== 'object')
|
|
5
|
+
return value;
|
|
4
6
|
const copy = {};
|
|
5
|
-
for (const [name, item] of Object.entries(value))
|
|
7
|
+
for (const [name, item] of Object.entries(value))
|
|
8
|
+
copy[name] = frozen(item);
|
|
6
9
|
return Object.freeze(copy);
|
|
7
10
|
}
|
|
8
11
|
export function immutable(batch) {
|
|
9
12
|
return frozen(batch);
|
|
10
13
|
}
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=change.js.map
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { AppRoom, AppSlot, ConnectionRefusal, HistoryQuery, RoomTypes, SavedRoomDraft, SaveResult } from './connection.js';
|
|
2
|
+
import type { HistoryResult, ServiceMode } from './adapter.js';
|
|
3
|
+
import type { ChatDraft, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
4
|
+
import { type Observation } from './observation.js';
|
|
5
|
+
import type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';
|
|
6
|
+
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';
|
|
7
|
+
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
8
|
+
import type { SearchRequest, SearchResult } from './search.js';
|
|
9
|
+
import type { SyncStatus } from './status.js';
|
|
10
|
+
import { type RuntimePort } from './wire.js';
|
|
11
|
+
export type MdRuntimeClient = {
|
|
12
|
+
rooms(): Promise<readonly AppRoom[]>;
|
|
13
|
+
slots(): Promise<readonly AppSlot[]>;
|
|
14
|
+
query: {
|
|
15
|
+
(query: DocumentQuery): Promise<DocumentResult>;
|
|
16
|
+
(query: GroupQuery): Promise<GroupResult>;
|
|
17
|
+
};
|
|
18
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
19
|
+
types(locator: string): Promise<RoomTypes>;
|
|
20
|
+
syncStatus(): Promise<SyncStatus>;
|
|
21
|
+
serviceMode(): Promise<ServiceMode>;
|
|
22
|
+
roomDraft: {
|
|
23
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
24
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
25
|
+
write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
|
|
26
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
27
|
+
};
|
|
28
|
+
save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
29
|
+
outcome(identifier: string): Promise<SubmissionOutcome | null>;
|
|
30
|
+
presentation: {
|
|
31
|
+
read(): Promise<unknown>;
|
|
32
|
+
write(value: unknown): Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
conversation: {
|
|
35
|
+
list(): Promise<readonly ConversationEntry[]>;
|
|
36
|
+
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
37
|
+
create(input: unknown): Promise<CallResult>;
|
|
38
|
+
send(conversation: string): Promise<CallResult>;
|
|
39
|
+
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
40
|
+
interrupt(conversation: string): Promise<CallResult>;
|
|
41
|
+
kill(conversation: string): Promise<CallResult>;
|
|
42
|
+
cancel(conversation: string, turn: string): Promise<CallResult>;
|
|
43
|
+
delete(conversation: string): Promise<CallResult>;
|
|
44
|
+
};
|
|
45
|
+
chatDraft: {
|
|
46
|
+
write(conversation: string, draft: ChatDraft): Promise<void>;
|
|
47
|
+
discard(conversation: string): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryResult>;
|
|
50
|
+
call(name: string, input: unknown): Promise<CallResult>;
|
|
51
|
+
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
52
|
+
log(): Promise<string>;
|
|
53
|
+
storageLoss(): Promise<string | null>;
|
|
54
|
+
persistence(): Promise<boolean>;
|
|
55
|
+
deploymentFacts(): Promise<unknown>;
|
|
56
|
+
observe: {
|
|
57
|
+
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
58
|
+
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
59
|
+
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
60
|
+
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
61
|
+
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
62
|
+
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
63
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
|
|
64
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
|
|
65
|
+
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
66
|
+
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
67
|
+
(topic: 'presentation'): Promise<Observation<unknown>>;
|
|
68
|
+
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
69
|
+
};
|
|
70
|
+
reauthorize(): Promise<void>;
|
|
71
|
+
};
|
|
72
|
+
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
73
|
+
export type { Observation } from './observation.js';
|
|
74
|
+
export type { RuntimePort } from './wire.js';
|
|
75
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAY,KAAK,WAAW,EAAiB,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAOL,KAAK,WAAW,EAIjB,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,IAAI,OAA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AW,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC,CAAC;QAC/E,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC,CAAC;QACnE,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QACvD,CACE,KAAK,EAAE,cAAc,EACrB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;KAC3C,CAAC;IACF,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAwLnE;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { observed } from './observation.js';
|
|
2
|
+
import { answer, AUTHORIZATION_ENDED, carried, envelope, PORT_CLOSED, PROTOCOL_MISMATCH, } from './wire.js';
|
|
3
|
+
export function connectMdRuntime(port) {
|
|
4
|
+
let sequence = 0;
|
|
5
|
+
let refusal = null;
|
|
6
|
+
let ended = null;
|
|
7
|
+
const calls = new Map();
|
|
8
|
+
const opening = new Map();
|
|
9
|
+
const observations = new Map();
|
|
10
|
+
const send = (message) => {
|
|
11
|
+
port.postMessage(envelope(message));
|
|
12
|
+
};
|
|
13
|
+
function begin(id, topic, first) {
|
|
14
|
+
const handle = observed(first, () => {
|
|
15
|
+
observations.delete(id);
|
|
16
|
+
if (refusal === null)
|
|
17
|
+
send({ kind: 'stop', id });
|
|
18
|
+
}, topic === 'query');
|
|
19
|
+
observations.set(id, { topic, handle });
|
|
20
|
+
return handle.observation;
|
|
21
|
+
}
|
|
22
|
+
function refuse(reported) {
|
|
23
|
+
refusal = reported;
|
|
24
|
+
for (const { topic, handle } of observations.values()) {
|
|
25
|
+
if (topic === 'connection-refusal')
|
|
26
|
+
handle.receive(reported);
|
|
27
|
+
}
|
|
28
|
+
const failure = new Error(reported.reason);
|
|
29
|
+
for (const [id, waiting] of opening) {
|
|
30
|
+
if (waiting.topic === 'connection-refusal')
|
|
31
|
+
waiting.settle(begin(id, waiting.topic, reported));
|
|
32
|
+
else
|
|
33
|
+
waiting.fail(failure);
|
|
34
|
+
}
|
|
35
|
+
opening.clear();
|
|
36
|
+
for (const waiting of calls.values())
|
|
37
|
+
waiting.fail(failure);
|
|
38
|
+
calls.clear();
|
|
39
|
+
}
|
|
40
|
+
function end(reason) {
|
|
41
|
+
if (ended !== null)
|
|
42
|
+
return;
|
|
43
|
+
ended = reason;
|
|
44
|
+
const failure = new Error(reason);
|
|
45
|
+
for (const waiting of opening.values())
|
|
46
|
+
waiting.fail(failure);
|
|
47
|
+
opening.clear();
|
|
48
|
+
for (const waiting of calls.values())
|
|
49
|
+
waiting.fail(failure);
|
|
50
|
+
calls.clear();
|
|
51
|
+
for (const { handle } of observations.values())
|
|
52
|
+
handle.end();
|
|
53
|
+
observations.clear();
|
|
54
|
+
}
|
|
55
|
+
port.addEventListener('message', (event) => {
|
|
56
|
+
const wire = carried(event.data);
|
|
57
|
+
if (wire === null)
|
|
58
|
+
return;
|
|
59
|
+
if (!wire.matching) {
|
|
60
|
+
refuse(PROTOCOL_MISMATCH);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const message = answer(wire.message);
|
|
64
|
+
if (message === null)
|
|
65
|
+
return;
|
|
66
|
+
if (message.kind === 'refusal') {
|
|
67
|
+
refuse(message.refusal);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (message.kind === 'ended') {
|
|
71
|
+
end(AUTHORIZATION_ENDED);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (message.kind === 'event') {
|
|
75
|
+
observations.get(message.id)?.handle.receive(message.value);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const waiting = opening.get(message.id);
|
|
79
|
+
if (waiting !== undefined) {
|
|
80
|
+
opening.delete(message.id);
|
|
81
|
+
if (message.kind === 'failure')
|
|
82
|
+
waiting.fail(new Error(message.message));
|
|
83
|
+
else
|
|
84
|
+
waiting.settle(begin(message.id, waiting.topic, message.value));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const called = calls.get(message.id);
|
|
88
|
+
if (called === undefined)
|
|
89
|
+
return;
|
|
90
|
+
calls.delete(message.id);
|
|
91
|
+
if (message.kind === 'failure')
|
|
92
|
+
called.fail(new Error(message.message));
|
|
93
|
+
else
|
|
94
|
+
called.settle(message.value);
|
|
95
|
+
});
|
|
96
|
+
port.addEventListener('close', () => {
|
|
97
|
+
end(PORT_CLOSED);
|
|
98
|
+
});
|
|
99
|
+
port.start();
|
|
100
|
+
send({ kind: 'hello' });
|
|
101
|
+
function ask(member, input) {
|
|
102
|
+
if (ended !== null)
|
|
103
|
+
return Promise.reject(new Error(ended));
|
|
104
|
+
if (refusal !== null)
|
|
105
|
+
return Promise.reject(new Error(refusal.reason));
|
|
106
|
+
const id = (sequence += 1);
|
|
107
|
+
return new Promise((settle, fail) => {
|
|
108
|
+
calls.set(id, { settle: settle, fail });
|
|
109
|
+
send({ kind: 'call', id, member, input });
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function watch(topic, input) {
|
|
113
|
+
if (ended !== null)
|
|
114
|
+
return Promise.reject(new Error(ended));
|
|
115
|
+
const id = (sequence += 1);
|
|
116
|
+
if (refusal !== null) {
|
|
117
|
+
return topic === 'connection-refusal'
|
|
118
|
+
? Promise.resolve(begin(id, topic, refusal))
|
|
119
|
+
: Promise.reject(new Error(refusal.reason));
|
|
120
|
+
}
|
|
121
|
+
return new Promise((settle, fail) => {
|
|
122
|
+
opening.set(id, { topic, settle, fail });
|
|
123
|
+
send({ kind: 'observe', id, topic, input });
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
rooms: () => ask('rooms', []),
|
|
128
|
+
slots: () => ask('slots', []),
|
|
129
|
+
query: ((query) => ask('query', [query])),
|
|
130
|
+
search: (request) => ask('search', [request]),
|
|
131
|
+
types: (locator) => ask('types', [locator]),
|
|
132
|
+
syncStatus: () => ask('syncStatus', []),
|
|
133
|
+
serviceMode: () => ask('serviceMode', []),
|
|
134
|
+
roomDraft: {
|
|
135
|
+
list: () => ask('roomDraft.list', []),
|
|
136
|
+
read: (room, path) => ask('roomDraft.read', [room, path]),
|
|
137
|
+
write: (room, path, revision, parts) => ask('roomDraft.write', [room, path, revision, parts]),
|
|
138
|
+
discard: (room, path, revision) => ask('roomDraft.discard', [room, path, revision]),
|
|
139
|
+
},
|
|
140
|
+
save: (room, roomDrafts) => ask('save', [room, roomDrafts]),
|
|
141
|
+
outcome: (identifier) => ask('outcome', [identifier]),
|
|
142
|
+
presentation: {
|
|
143
|
+
read: () => ask('presentation.read', []),
|
|
144
|
+
write: (value) => ask('presentation.write', [value]),
|
|
145
|
+
},
|
|
146
|
+
conversation: {
|
|
147
|
+
list: () => ask('conversation.list', []),
|
|
148
|
+
read: (conversation, options) => ask('conversation.read', [conversation, options]),
|
|
149
|
+
create: (input) => ask('conversation.create', [input]),
|
|
150
|
+
send: (conversation) => ask('conversation.send', [conversation]),
|
|
151
|
+
answer: (conversation, answer) => ask('conversation.answer', [conversation, answer]),
|
|
152
|
+
interrupt: (conversation) => ask('conversation.interrupt', [conversation]),
|
|
153
|
+
kill: (conversation) => ask('conversation.kill', [conversation]),
|
|
154
|
+
cancel: (conversation, turn) => ask('conversation.cancel', [conversation, turn]),
|
|
155
|
+
delete: (conversation) => ask('conversation.delete', [conversation]),
|
|
156
|
+
},
|
|
157
|
+
chatDraft: {
|
|
158
|
+
write: (conversation, draft) => ask('chatDraft.write', [conversation, draft]),
|
|
159
|
+
discard: (conversation) => ask('chatDraft.discard', [conversation]),
|
|
160
|
+
},
|
|
161
|
+
history: (locator, path, query) => ask('history', [locator, path, query]),
|
|
162
|
+
call: (name, input) => ask('call', [name, input]),
|
|
163
|
+
reached: (locator, roomVersion, path) => ask('reached', [locator, roomVersion, path]),
|
|
164
|
+
log: () => ask('log', []),
|
|
165
|
+
storageLoss: () => ask('storageLoss', []),
|
|
166
|
+
persistence: () => ask('persistence', []),
|
|
167
|
+
deploymentFacts: () => ask('deploymentFacts', []),
|
|
168
|
+
observe: ((topic, ...input) => watch(topic, input)),
|
|
169
|
+
reauthorize: () => ask('reauthorize', []),
|
|
170
|
+
};
|
|
171
|
+
}
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import { type Document, type Validation } from '@agentshouse/mdmodel';
|
|
2
|
-
import type {
|
|
3
|
-
import type { AttachedModelBinding, ModelState } from './model.js';
|
|
2
|
+
import type { ModelState } from './model.js';
|
|
4
3
|
import type { MdModelIdentity } from './adapter.js';
|
|
4
|
+
import type { Refused } from './transfer.js';
|
|
5
5
|
export declare const MD_MODEL: MdModelIdentity;
|
|
6
|
-
export declare const PRESENTED: Selector;
|
|
7
|
-
export type MdType = {
|
|
8
|
-
name: string;
|
|
9
|
-
path: string;
|
|
10
|
-
fields: Readonly<Record<string, unknown>>;
|
|
11
|
-
sections: Readonly<Record<string, unknown>>;
|
|
12
|
-
};
|
|
13
6
|
export type Collection = {
|
|
14
7
|
documents: Readonly<Record<string, Document>>;
|
|
15
|
-
|
|
8
|
+
composition: Composition;
|
|
16
9
|
};
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
export type Composition = {
|
|
11
|
+
model: ModelState;
|
|
12
|
+
selection: {
|
|
13
|
+
roots: readonly string[];
|
|
14
|
+
model: ModelState;
|
|
15
|
+
} | null;
|
|
16
|
+
untypedFolders: readonly string[];
|
|
22
17
|
};
|
|
18
|
+
export declare function untyped(roots: readonly string[], path: string): boolean;
|
|
19
|
+
export declare function governing(composition: Composition, path: string): ModelState;
|
|
20
|
+
type Previous = {
|
|
21
|
+
text: Readonly<Record<string, string>>;
|
|
22
|
+
collection: Collection;
|
|
23
|
+
};
|
|
24
|
+
export declare function parseCollection(text: Readonly<Record<string, string>>, composition: Composition, previous?: Previous): Collection;
|
|
25
|
+
export declare function readCollection(text: Readonly<Record<string, string>>, composition: Composition, previous?: Previous): {
|
|
26
|
+
kind: 'read';
|
|
27
|
+
collection: Collection;
|
|
28
|
+
} | Refused;
|
|
29
|
+
export declare function validRoot(root: unknown): root is string;
|
|
30
|
+
export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Validation;
|
|
31
|
+
export {};
|
|
23
32
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EAEb,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,QAAQ,EAAE,eAAwE,CAAC;AAIhG,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9C,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE;QAA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