@agentshouse/mdruntime-adapter 0.1.0-cd23c45caa798 → 0.1.0-cd24cf2286fd6
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/README.md +2 -2
- package/dist/actions.d.ts +4 -72
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +7 -319
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +204 -417
- package/dist/app-reference.d.ts +2 -0
- package/dist/app-reference.d.ts.map +1 -0
- package/dist/app-reference.js +2 -0
- package/dist/chunks.d.ts +38 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +247 -0
- package/dist/crockford.d.ts +4 -0
- package/dist/crockford.d.ts.map +1 -0
- package/dist/crockford.js +3 -0
- package/dist/discovery.d.ts +22 -15
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +75 -56
- package/dist/history.d.ts +12 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +92 -0
- package/dist/house-model.d.ts +641 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +361 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/model.d.ts +5 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +34 -41
- package/dist/read.d.ts +31 -54
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +82 -300
- package/dist/refusal.d.ts +0 -3
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +0 -5
- package/dist/room-types.d.ts +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +123 -0
- package/dist/search.d.ts +5 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +47 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +82 -185
- package/dist/space-schema.d.ts +7 -0
- package/dist/space-schema.d.ts.map +1 -0
- package/dist/space-schema.js +18 -0
- package/dist/stream.d.ts +16 -14
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +230 -408
- package/dist/transport.d.ts +50 -40
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +54 -11
- package/dist/upload.d.ts +12 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +63 -0
- package/dist/write.d.ts +6 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +28 -39
- package/package.json +8 -4
- package/AGENTS.md +0 -304
- package/dist/gather.d.ts +0 -4
- package/dist/gather.d.ts.map +0 -1
- package/dist/gather.js +0 -35
- package/dist/handed.d.ts +0 -15
- package/dist/handed.d.ts.map +0 -1
- package/dist/handed.js +0 -45
- package/dist/part.d.ts +0 -13
- package/dist/part.d.ts.map +0 -1
- package/dist/part.js +0 -80
- package/dist/referrer.d.ts +0 -7
- package/dist/referrer.d.ts.map +0 -1
- package/dist/referrer.js +0 -33
package/dist/read.d.ts
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
import { type HousePart } from './part.js';
|
|
1
|
+
import { type BinaryFile, type BootstrapPage, type SavedFacts } from '@agentshouse/mdruntime';
|
|
4
2
|
import type { HouseMode } from './transport.js';
|
|
5
3
|
import { type LogPosition } from './version.js';
|
|
6
4
|
export type HeadChange = BootstrapPage['changes'][string];
|
|
7
5
|
export type Answered = {
|
|
8
6
|
readonly documents: Map<string, string>;
|
|
7
|
+
readonly facts: Map<string, SavedFacts>;
|
|
9
8
|
readonly revisions: Map<string, string>;
|
|
10
9
|
readonly fileIds: Map<string, string>;
|
|
11
10
|
readonly changes: Map<string, HeadChange>;
|
|
12
11
|
readonly binaryFiles: Map<string, BinaryFile>;
|
|
13
12
|
readonly removals: Set<string>;
|
|
13
|
+
readonly folders: Set<string>;
|
|
14
|
+
readonly folderRemovals: Set<string>;
|
|
14
15
|
};
|
|
15
16
|
export declare function answering(): Answered;
|
|
16
17
|
export declare function revised(answer: Answered, path: string, revision: string): void;
|
|
17
18
|
export declare function forgotten(answer: Answered, path: string): void;
|
|
19
|
+
export declare function folded(answer: Answered, path: string, removed: boolean): void;
|
|
18
20
|
export declare function answered(answer: Answered): Generator<number, {
|
|
19
21
|
documents: Readonly<Record<string, string>>;
|
|
22
|
+
facts: Readonly<Record<string, SavedFacts>>;
|
|
20
23
|
revisions: Readonly<Record<string, string>>;
|
|
21
24
|
fileIds?: Readonly<Record<string, string>>;
|
|
22
25
|
changes: Readonly<Record<string, HeadChange>>;
|
|
23
26
|
binaryFiles: Readonly<Record<string, BinaryFile>>;
|
|
24
27
|
removals: readonly string[];
|
|
28
|
+
folders?: readonly string[];
|
|
29
|
+
folderRemovals?: readonly string[];
|
|
25
30
|
}, void>;
|
|
26
31
|
export type HouseManifestFile = {
|
|
27
32
|
path: string;
|
|
@@ -30,6 +35,8 @@ export type HouseManifestFile = {
|
|
|
30
35
|
sha256?: string;
|
|
31
36
|
head?: HeadChange;
|
|
32
37
|
binary?: BinaryFile;
|
|
38
|
+
facts?: SavedFacts;
|
|
39
|
+
space?: string;
|
|
33
40
|
};
|
|
34
41
|
export type HouseContent = {
|
|
35
42
|
path: string;
|
|
@@ -39,78 +46,48 @@ export type HouseScope = LogPosition & {
|
|
|
39
46
|
anchor: string;
|
|
40
47
|
files: readonly HouseManifestFile[];
|
|
41
48
|
contents: readonly HouseContent[];
|
|
49
|
+
folders?: readonly string[];
|
|
42
50
|
};
|
|
43
|
-
export type
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
export type HouseModels = {
|
|
52
|
+
files: readonly HouseManifestFile[];
|
|
53
|
+
contents: readonly HouseContent[];
|
|
46
54
|
};
|
|
47
|
-
export type
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
export type HouseRoomHead = LogPosition & {
|
|
56
|
+
anchor: string;
|
|
57
|
+
models: HouseModels;
|
|
50
58
|
};
|
|
51
59
|
export type HouseGrant = {
|
|
52
|
-
method: 'GET';
|
|
53
|
-
url: string;
|
|
54
|
-
} | {
|
|
55
|
-
method: 'POST';
|
|
56
60
|
operation: string;
|
|
57
61
|
url: string;
|
|
58
62
|
};
|
|
59
|
-
export type
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
content: string;
|
|
65
|
-
revision: string | undefined;
|
|
66
|
-
version: string;
|
|
67
|
-
head?: HeadChange;
|
|
68
|
-
} | {
|
|
69
|
-
path: string;
|
|
70
|
-
binary: BinaryFile;
|
|
71
|
-
revision: string | undefined;
|
|
72
|
-
version: string;
|
|
73
|
-
head?: HeadChange;
|
|
74
|
-
};
|
|
75
|
-
export type HousePage = {
|
|
76
|
-
after: string;
|
|
77
|
-
through: string;
|
|
78
|
-
read: number;
|
|
79
|
-
};
|
|
80
|
-
export type HouseView = LogPosition & {
|
|
81
|
-
authority: string;
|
|
82
|
-
changes: readonly HouseChange[];
|
|
83
|
-
next?: HousePage;
|
|
84
|
-
};
|
|
85
|
-
type PageFailure = AdapterFailure | {
|
|
86
|
-
kind: 'beyond-horizon';
|
|
87
|
-
};
|
|
88
|
-
export type HouseEnumeration = {
|
|
89
|
-
authorities: readonly HouseView[];
|
|
63
|
+
export type HouseFileAddress = {
|
|
64
|
+
url: string;
|
|
65
|
+
name: string;
|
|
66
|
+
sha256: string;
|
|
67
|
+
mediaType: string;
|
|
90
68
|
};
|
|
91
69
|
export declare function authorityRoot(handle: string): string;
|
|
92
70
|
export declare function schemaPath(handle: string, schema: string): string;
|
|
93
71
|
export declare function parseGrant(body: unknown): HouseGrant | null;
|
|
72
|
+
export declare function parseFileAddress(body: unknown): HouseFileAddress | null;
|
|
94
73
|
export declare function headChange(held: {
|
|
95
74
|
readonly author?: unknown;
|
|
96
75
|
readonly created_at?: unknown;
|
|
97
76
|
}): HeadChange | undefined | null;
|
|
98
77
|
export declare function binaryFileOf(held: Readonly<Record<string, unknown>>): BinaryFile | undefined | null;
|
|
99
|
-
export declare function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
export declare function
|
|
105
|
-
export declare function
|
|
78
|
+
export declare function carriedFacts(held: Readonly<Record<string, unknown>>): {
|
|
79
|
+
facts?: undefined;
|
|
80
|
+
} | {
|
|
81
|
+
facts: SavedFacts;
|
|
82
|
+
};
|
|
83
|
+
export declare function parseFile(value: unknown, mode: HouseMode): HouseManifestFile | null;
|
|
84
|
+
export declare function modelScope(room: HouseRoomHead): HouseScope;
|
|
106
85
|
export declare function bootstrapping(scope: HouseScope): Generator<number, BootstrapPage, void>;
|
|
107
86
|
export type HouseSchema = {
|
|
108
87
|
schema: string | null;
|
|
109
88
|
version: string | null;
|
|
110
89
|
revision: string | null;
|
|
90
|
+
space?: string;
|
|
111
91
|
};
|
|
112
92
|
export declare function schemaOf(scope: HouseScope, schema: string): HouseSchema | null;
|
|
113
|
-
export declare function viewOf(enumeration: HouseEnumeration, tracked: TrackedAuthority): HouseView | undefined;
|
|
114
|
-
export declare function refreshFrom(view: HouseView, fromRoomVersion: string): Promise<RefreshResult>;
|
|
115
|
-
export {};
|
|
116
93
|
//# sourceMappingURL=read.d.ts.map
|
package/dist/read.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,aAAa,EAElB,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAQ1D,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAA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AiB,GAAG,IAAI,CA6BnF;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,UAAU,CAQ1D;AAED,wBAAiB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,CAqBxF;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAY9E"}
|
package/dist/read.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { patching, ROW_WEIGHT,
|
|
2
|
-
import {
|
|
3
|
-
import { DECIMAL, readPosition, roomVersion } from './version.js';
|
|
1
|
+
import { patching, ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
2
|
+
import { roomVersion } from './version.js';
|
|
4
3
|
const REVISION_FILE = /^fr_([0-9a-z]+)\.[0-9a-z]+\.[0-9a-z]$/u;
|
|
5
4
|
function fileOf(revision) {
|
|
6
5
|
return REVISION_FILE.exec(revision)?.[1];
|
|
@@ -8,11 +7,14 @@ function fileOf(revision) {
|
|
|
8
7
|
export function answering() {
|
|
9
8
|
return {
|
|
10
9
|
documents: new Map(),
|
|
10
|
+
facts: new Map(),
|
|
11
11
|
revisions: new Map(),
|
|
12
12
|
fileIds: new Map(),
|
|
13
13
|
changes: new Map(),
|
|
14
14
|
binaryFiles: new Map(),
|
|
15
15
|
removals: new Set(),
|
|
16
|
+
folders: new Set(),
|
|
17
|
+
folderRemovals: new Set(),
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
export function revised(answer, path, revision) {
|
|
@@ -23,25 +25,45 @@ export function revised(answer, path, revision) {
|
|
|
23
25
|
}
|
|
24
26
|
export function forgotten(answer, path) {
|
|
25
27
|
answer.documents.delete(path);
|
|
28
|
+
answer.facts.delete(path);
|
|
26
29
|
answer.revisions.delete(path);
|
|
27
30
|
answer.fileIds.delete(path);
|
|
28
31
|
answer.changes.delete(path);
|
|
29
32
|
answer.binaryFiles.delete(path);
|
|
30
33
|
answer.removals.delete(path);
|
|
31
34
|
}
|
|
32
|
-
export function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
export function folded(answer, path, removed) {
|
|
36
|
+
if (removed) {
|
|
37
|
+
answer.folders.delete(path);
|
|
38
|
+
answer.folderRemovals.add(path);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
answer.folderRemovals.delete(path);
|
|
42
|
+
answer.folders.add(path);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function* pathsOf(paths) {
|
|
46
|
+
const list = [];
|
|
47
|
+
for (const path of paths) {
|
|
48
|
+
list.push(path);
|
|
36
49
|
yield ROW_WEIGHT;
|
|
37
50
|
}
|
|
51
|
+
return list;
|
|
52
|
+
}
|
|
53
|
+
export function* answered(answer) {
|
|
54
|
+
const removals = yield* pathsOf(answer.removals);
|
|
38
55
|
return {
|
|
39
56
|
documents: yield* patching({}, answer.documents),
|
|
57
|
+
facts: yield* patching({}, answer.facts),
|
|
40
58
|
revisions: yield* patching({}, answer.revisions),
|
|
41
59
|
...(answer.fileIds.size === 0 ? {} : { fileIds: yield* patching({}, answer.fileIds) }),
|
|
42
60
|
changes: yield* patching({}, answer.changes),
|
|
43
61
|
binaryFiles: yield* patching({}, answer.binaryFiles),
|
|
44
62
|
removals,
|
|
63
|
+
...(answer.folders.size === 0 ? {} : { folders: yield* pathsOf(answer.folders) }),
|
|
64
|
+
...(answer.folderRemovals.size === 0
|
|
65
|
+
? {}
|
|
66
|
+
: { folderRemovals: yield* pathsOf(answer.folderRemovals) }),
|
|
45
67
|
};
|
|
46
68
|
}
|
|
47
69
|
export function authorityRoot(handle) {
|
|
@@ -59,22 +81,39 @@ export function parseGrant(body) {
|
|
|
59
81
|
const transfer = body.transfer;
|
|
60
82
|
if (typeof transfer.url !== 'string')
|
|
61
83
|
return null;
|
|
62
|
-
if (transfer.method === 'GET')
|
|
63
|
-
return { method: 'GET', url: transfer.url };
|
|
64
84
|
if (transfer.method !== 'POST' || typeof transfer.operation !== 'string')
|
|
65
85
|
return null;
|
|
66
|
-
return {
|
|
86
|
+
return { operation: transfer.operation, url: transfer.url };
|
|
87
|
+
}
|
|
88
|
+
export function parseFileAddress(body) {
|
|
89
|
+
if (typeof body !== 'object' || body === null)
|
|
90
|
+
return null;
|
|
91
|
+
const { download, name, sha256, media_type: mediaType } = body;
|
|
92
|
+
if (typeof download !== 'string' ||
|
|
93
|
+
typeof name !== 'string' ||
|
|
94
|
+
typeof sha256 !== 'string' ||
|
|
95
|
+
typeof mediaType !== 'string') {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
return { url: download, name, sha256, mediaType };
|
|
67
99
|
}
|
|
68
100
|
function changeAuthor(value) {
|
|
69
101
|
if (typeof value !== 'object' || value === null)
|
|
70
102
|
return null;
|
|
71
|
-
const { user, site, name } = value;
|
|
103
|
+
const { user, site, inbox, app, name } = value;
|
|
72
104
|
if (typeof name !== 'string')
|
|
73
105
|
return null;
|
|
74
|
-
|
|
106
|
+
const named = [user, site, inbox, app].filter((id) => id !== undefined);
|
|
107
|
+
if (named.length !== 1)
|
|
108
|
+
return null;
|
|
109
|
+
if (typeof user === 'string')
|
|
75
110
|
return { kind: 'user', id: user, name };
|
|
76
|
-
if (typeof site === 'string'
|
|
111
|
+
if (typeof site === 'string')
|
|
77
112
|
return { kind: 'site', id: site, name };
|
|
113
|
+
if (typeof inbox === 'string')
|
|
114
|
+
return { kind: 'inbox', id: inbox, name };
|
|
115
|
+
if (typeof app === 'string')
|
|
116
|
+
return { kind: 'app', id: app, name };
|
|
78
117
|
return null;
|
|
79
118
|
}
|
|
80
119
|
export function headChange(held) {
|
|
@@ -91,20 +130,23 @@ function headed(head) {
|
|
|
91
130
|
return head === undefined ? {} : { head };
|
|
92
131
|
}
|
|
93
132
|
export function binaryFileOf(held) {
|
|
94
|
-
if (held.
|
|
133
|
+
if (held.media_type === undefined)
|
|
95
134
|
return undefined;
|
|
96
|
-
const {
|
|
97
|
-
if (typeof
|
|
98
|
-
typeof bytes !== 'number' ||
|
|
99
|
-
typeof mediaType !== 'string' ||
|
|
100
|
-
typeof sha256 !== 'string')
|
|
135
|
+
const { bytes, media_type: mediaType, sha256 } = held;
|
|
136
|
+
if (typeof bytes !== 'number' || typeof mediaType !== 'string' || typeof sha256 !== 'string')
|
|
101
137
|
return null;
|
|
102
|
-
return {
|
|
138
|
+
return { byteLength: bytes, mediaType, sha256 };
|
|
103
139
|
}
|
|
104
140
|
function binaried(binary) {
|
|
105
141
|
return binary === undefined ? {} : { binary };
|
|
106
142
|
}
|
|
107
|
-
function
|
|
143
|
+
export function carriedFacts(held) {
|
|
144
|
+
return held.facts === undefined ? {} : { facts: held.facts };
|
|
145
|
+
}
|
|
146
|
+
function carriedSpace(held) {
|
|
147
|
+
return typeof held.space === 'string' ? { space: held.space } : {};
|
|
148
|
+
}
|
|
149
|
+
export function parseFile(value, mode) {
|
|
108
150
|
if (typeof value !== 'object' || value === null)
|
|
109
151
|
return null;
|
|
110
152
|
const file = value;
|
|
@@ -123,6 +165,7 @@ function parseFile(value, mode) {
|
|
|
123
165
|
version: file.sha256,
|
|
124
166
|
...headed(head),
|
|
125
167
|
...binaried(binary),
|
|
168
|
+
...carriedFacts(file),
|
|
126
169
|
};
|
|
127
170
|
}
|
|
128
171
|
if (typeof file.revision !== 'string')
|
|
@@ -134,262 +177,17 @@ function parseFile(value, mode) {
|
|
|
134
177
|
...(typeof file.sha256 === 'string' ? { sha256: file.sha256 } : {}),
|
|
135
178
|
...headed(head),
|
|
136
179
|
...binaried(binary),
|
|
180
|
+
...carriedFacts(file),
|
|
181
|
+
...carriedSpace(file),
|
|
137
182
|
};
|
|
138
183
|
}
|
|
139
|
-
function
|
|
140
|
-
if (typeof value !== 'object' || value === null)
|
|
141
|
-
return null;
|
|
142
|
-
const held = value;
|
|
143
|
-
if (typeof held.manifest !== 'object' || held.manifest === null)
|
|
144
|
-
return null;
|
|
145
|
-
if (!Array.isArray(held.parts))
|
|
146
|
-
return null;
|
|
147
|
-
const manifest = held.manifest;
|
|
148
|
-
if (manifest.scope !== 'room')
|
|
149
|
-
return null;
|
|
150
|
-
const at = readPosition(manifest);
|
|
151
|
-
if (typeof manifest.anchor !== 'string' || manifest.anchor.length === 0 || at === null)
|
|
152
|
-
return null;
|
|
153
|
-
if (typeof manifest.room_handle !== 'string' || manifest.room_handle.length === 0)
|
|
154
|
-
return null;
|
|
155
|
-
const parts = [];
|
|
156
|
-
for (const entry of held.parts) {
|
|
157
|
-
const part = parsePart(entry);
|
|
158
|
-
if (part === null)
|
|
159
|
-
return null;
|
|
160
|
-
parts.push(part);
|
|
161
|
-
}
|
|
162
|
-
return { anchor: manifest.anchor, ...at, parts };
|
|
163
|
-
}
|
|
164
|
-
export function parseParted(body) {
|
|
165
|
-
if (typeof body !== 'object' || body === null)
|
|
166
|
-
return null;
|
|
167
|
-
if (!('scopes' in body) || !Array.isArray(body.scopes))
|
|
168
|
-
return null;
|
|
169
|
-
const rooms = [];
|
|
170
|
-
for (const entry of body.scopes) {
|
|
171
|
-
const room = parseRoomParts(entry);
|
|
172
|
-
if (room === null)
|
|
173
|
-
return null;
|
|
174
|
-
rooms.push(room);
|
|
175
|
-
}
|
|
176
|
-
if (!('next' in body) || body.next === undefined)
|
|
177
|
-
return { rooms };
|
|
178
|
-
const next = body.next;
|
|
179
|
-
if (typeof next !== 'object' || next === null || typeof next.room !== 'string')
|
|
180
|
-
return null;
|
|
181
|
-
return { rooms, next: next.room };
|
|
182
|
-
}
|
|
183
|
-
export function parseSiteParted(body) {
|
|
184
|
-
return parseRoomParts(body);
|
|
185
|
-
}
|
|
186
|
-
export function emptyScope(room) {
|
|
184
|
+
export function modelScope(room) {
|
|
187
185
|
return {
|
|
188
186
|
anchor: room.anchor,
|
|
189
187
|
position: room.position,
|
|
190
188
|
logEpoch: room.logEpoch,
|
|
191
|
-
files:
|
|
192
|
-
contents:
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
function* partLines(text, mode) {
|
|
196
|
-
const files = [];
|
|
197
|
-
const contents = [];
|
|
198
|
-
let start = 0;
|
|
199
|
-
while (start < text.length) {
|
|
200
|
-
const end = text.indexOf('\n', start);
|
|
201
|
-
if (end === -1)
|
|
202
|
-
return null;
|
|
203
|
-
let entry;
|
|
204
|
-
try {
|
|
205
|
-
entry = JSON.parse(text.slice(start, end));
|
|
206
|
-
}
|
|
207
|
-
catch {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
start = end + 1;
|
|
211
|
-
if (folderLine(entry))
|
|
212
|
-
continue;
|
|
213
|
-
const file = parseFile(entry, mode);
|
|
214
|
-
if (file === null)
|
|
215
|
-
return null;
|
|
216
|
-
files.push(file);
|
|
217
|
-
const { content } = entry;
|
|
218
|
-
if (typeof content === 'string')
|
|
219
|
-
contents.push({ path: file.path, content });
|
|
220
|
-
else if (content !== undefined)
|
|
221
|
-
return null;
|
|
222
|
-
yield ROW_WEIGHT;
|
|
223
|
-
}
|
|
224
|
-
return { files, contents };
|
|
225
|
-
}
|
|
226
|
-
function folderLine(entry) {
|
|
227
|
-
if (typeof entry !== 'object' || entry === null || !('folder' in entry))
|
|
228
|
-
return false;
|
|
229
|
-
return typeof entry.folder === 'string' && Object.keys(entry).length === 1;
|
|
230
|
-
}
|
|
231
|
-
export async function housePart(room, body, listed, mode) {
|
|
232
|
-
const payload = await checkedPayload(body, listed);
|
|
233
|
-
if (payload === null)
|
|
234
|
-
return null;
|
|
235
|
-
const text = await gunzipped(payload);
|
|
236
|
-
const read = text === null ? null : await stepped(partLines(text, mode));
|
|
237
|
-
return read === null ? { kind: 'transport-uncertainty' } : { ...emptyScope(room), ...read };
|
|
238
|
-
}
|
|
239
|
-
function parseChange(value, mode) {
|
|
240
|
-
if (typeof value !== 'object' || value === null)
|
|
241
|
-
return null;
|
|
242
|
-
const held = value;
|
|
243
|
-
if (typeof held.path !== 'string')
|
|
244
|
-
return null;
|
|
245
|
-
if (held.removed === true)
|
|
246
|
-
return { path: held.path, removed: true };
|
|
247
|
-
const head = headChange(held);
|
|
248
|
-
const binary = binaryFileOf(held);
|
|
249
|
-
if (head === null || binary === null)
|
|
250
|
-
return null;
|
|
251
|
-
if (binary !== undefined) {
|
|
252
|
-
if (mode === 'credential' && typeof held.revision !== 'string')
|
|
253
|
-
return null;
|
|
254
|
-
const revision = typeof held.revision === 'string' ? held.revision : binary.sha256;
|
|
255
|
-
return { path: held.path, binary, revision, version: revision, ...headed(head) };
|
|
256
|
-
}
|
|
257
|
-
if (mode === 'site') {
|
|
258
|
-
if (typeof held.content !== 'string' || typeof held.sha256 !== 'string')
|
|
259
|
-
return null;
|
|
260
|
-
return {
|
|
261
|
-
path: held.path,
|
|
262
|
-
content: held.content,
|
|
263
|
-
revision: undefined,
|
|
264
|
-
version: held.sha256,
|
|
265
|
-
...headed(head),
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
if (typeof held.content === 'string' && typeof held.revision === 'string') {
|
|
269
|
-
return {
|
|
270
|
-
path: held.path,
|
|
271
|
-
content: held.content,
|
|
272
|
-
revision: held.revision,
|
|
273
|
-
version: held.revision,
|
|
274
|
-
...headed(head),
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
export function parseEnumeration(body, mode) {
|
|
280
|
-
if (typeof body !== 'object' || body === null)
|
|
281
|
-
return null;
|
|
282
|
-
if (!('authorities' in body) || !Array.isArray(body.authorities))
|
|
283
|
-
return null;
|
|
284
|
-
const authorities = [];
|
|
285
|
-
for (const entry of body.authorities) {
|
|
286
|
-
if (typeof entry !== 'object' || entry === null)
|
|
287
|
-
return null;
|
|
288
|
-
const held = entry;
|
|
289
|
-
const at = readPosition(held);
|
|
290
|
-
if (typeof held.authority !== 'string' || at === null)
|
|
291
|
-
return null;
|
|
292
|
-
if (!Array.isArray(held.changes))
|
|
293
|
-
return null;
|
|
294
|
-
const changes = [];
|
|
295
|
-
for (const change of held.changes) {
|
|
296
|
-
const mapped = parseChange(change, mode);
|
|
297
|
-
if (mapped === null)
|
|
298
|
-
return null;
|
|
299
|
-
changes.push(mapped);
|
|
300
|
-
}
|
|
301
|
-
const next = held.next === undefined ? undefined : readPage(held.next);
|
|
302
|
-
if (next === null)
|
|
303
|
-
return null;
|
|
304
|
-
authorities.push({
|
|
305
|
-
authority: held.authority,
|
|
306
|
-
...at,
|
|
307
|
-
changes,
|
|
308
|
-
...(next === undefined ? {} : { next }),
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
return { authorities };
|
|
312
|
-
}
|
|
313
|
-
function readPage(held) {
|
|
314
|
-
if (typeof held !== 'object' || held === null)
|
|
315
|
-
return null;
|
|
316
|
-
const { after, through, read } = held;
|
|
317
|
-
if (typeof after !== 'string' || !DECIMAL.test(after))
|
|
318
|
-
return null;
|
|
319
|
-
if (typeof through !== 'string' || !DECIMAL.test(through))
|
|
320
|
-
return null;
|
|
321
|
-
if (typeof read !== 'number' || !Number.isSafeInteger(read) || read < 0)
|
|
322
|
-
return null;
|
|
323
|
-
return { after, through, read };
|
|
324
|
-
}
|
|
325
|
-
function advances(asked, next) {
|
|
326
|
-
const moved = BigInt(next.through) - BigInt(asked.through);
|
|
327
|
-
return moved > 0n || (moved === 0n && next.after === asked.after && next.read > asked.read);
|
|
328
|
-
}
|
|
329
|
-
export async function wholeView(first, more) {
|
|
330
|
-
const changes = new Map(first.changes.map((change) => [change.path, change]));
|
|
331
|
-
let view = first;
|
|
332
|
-
while (view.next !== undefined) {
|
|
333
|
-
const asked = view.next;
|
|
334
|
-
const page = await more(asked);
|
|
335
|
-
if ('kind' in page)
|
|
336
|
-
return page;
|
|
337
|
-
if (page.position !== asked.through ||
|
|
338
|
-
page.logEpoch !== first.logEpoch ||
|
|
339
|
-
(page.next !== undefined && !advances(asked, page.next))) {
|
|
340
|
-
return { kind: 'transport-uncertainty' };
|
|
341
|
-
}
|
|
342
|
-
for (const change of page.changes) {
|
|
343
|
-
changes.delete(change.path);
|
|
344
|
-
changes.set(change.path, change);
|
|
345
|
-
}
|
|
346
|
-
view = page;
|
|
347
|
-
}
|
|
348
|
-
return {
|
|
349
|
-
authority: first.authority,
|
|
350
|
-
position: view.position,
|
|
351
|
-
logEpoch: first.logEpoch,
|
|
352
|
-
changes: [...changes.values()],
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
export function* advancedScope(scope, view) {
|
|
356
|
-
const files = new Map();
|
|
357
|
-
for (const file of scope.files) {
|
|
358
|
-
files.set(file.path, file);
|
|
359
|
-
yield ROW_WEIGHT;
|
|
360
|
-
}
|
|
361
|
-
const contents = new Map();
|
|
362
|
-
for (const entry of scope.contents) {
|
|
363
|
-
contents.set(entry.path, entry.content);
|
|
364
|
-
yield ROW_WEIGHT;
|
|
365
|
-
}
|
|
366
|
-
for (const change of view.changes) {
|
|
367
|
-
files.delete(change.path);
|
|
368
|
-
contents.delete(change.path);
|
|
369
|
-
yield ROW_WEIGHT;
|
|
370
|
-
if ('removed' in change)
|
|
371
|
-
continue;
|
|
372
|
-
files.set(change.path, {
|
|
373
|
-
path: change.path,
|
|
374
|
-
revision: change.revision,
|
|
375
|
-
version: change.version,
|
|
376
|
-
...headed(change.head),
|
|
377
|
-
...('binary' in change ? { binary: change.binary } : {}),
|
|
378
|
-
});
|
|
379
|
-
if ('content' in change)
|
|
380
|
-
contents.set(change.path, change.content);
|
|
381
|
-
}
|
|
382
|
-
const listed = [];
|
|
383
|
-
for (const [path, content] of contents) {
|
|
384
|
-
listed.push({ path, content });
|
|
385
|
-
yield ROW_WEIGHT;
|
|
386
|
-
}
|
|
387
|
-
return {
|
|
388
|
-
...scope,
|
|
389
|
-
position: view.position,
|
|
390
|
-
logEpoch: view.logEpoch,
|
|
391
|
-
files: [...files.values()],
|
|
392
|
-
contents: listed,
|
|
189
|
+
files: room.models.files,
|
|
190
|
+
contents: room.models.contents,
|
|
393
191
|
};
|
|
394
192
|
}
|
|
395
193
|
export function* bootstrapping(scope) {
|
|
@@ -401,6 +199,8 @@ export function* bootstrapping(scope) {
|
|
|
401
199
|
const answer = answering();
|
|
402
200
|
for (const file of scope.files) {
|
|
403
201
|
yield ROW_WEIGHT;
|
|
202
|
+
if (file.space !== undefined)
|
|
203
|
+
continue;
|
|
404
204
|
if (file.head !== undefined)
|
|
405
205
|
answer.changes.set(file.path, file.head);
|
|
406
206
|
const content = contents.get(file.path);
|
|
@@ -408,10 +208,14 @@ export function* bootstrapping(scope) {
|
|
|
408
208
|
answer.binaryFiles.set(file.path, file.binary);
|
|
409
209
|
else if (content !== undefined)
|
|
410
210
|
answer.documents.set(file.path, content);
|
|
211
|
+
if (file.binary === undefined && file.facts !== undefined)
|
|
212
|
+
answer.facts.set(file.path, file.facts);
|
|
411
213
|
if (file.revision !== undefined)
|
|
412
214
|
revised(answer, file.path, file.revision);
|
|
413
215
|
}
|
|
414
|
-
const
|
|
216
|
+
for (const folder of scope.folders ?? [])
|
|
217
|
+
folded(answer, folder, false);
|
|
218
|
+
const { removals: _removals, folderRemovals: _folderRemovals, ...page } = yield* answered(answer);
|
|
415
219
|
return { kind: 'bootstrap', roomVersion: roomVersion(scope), ...page };
|
|
416
220
|
}
|
|
417
221
|
export function schemaOf(scope, schema) {
|
|
@@ -421,32 +225,10 @@ export function schemaOf(scope, schema) {
|
|
|
421
225
|
const content = scope.contents.find((entry) => entry.path === schema);
|
|
422
226
|
return content === undefined
|
|
423
227
|
? null
|
|
424
|
-
: {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if (roomVersion(view) === fromRoomVersion)
|
|
431
|
-
return { kind: 'still-current' };
|
|
432
|
-
const answer = answering();
|
|
433
|
-
for (const change of view.changes) {
|
|
434
|
-
yield ROW_WEIGHT;
|
|
435
|
-
if ('removed' in change) {
|
|
436
|
-
answer.removals.add(change.path);
|
|
437
|
-
continue;
|
|
438
|
-
}
|
|
439
|
-
if ('content' in change)
|
|
440
|
-
answer.documents.set(change.path, change.content);
|
|
441
|
-
else
|
|
442
|
-
answer.binaryFiles.set(change.path, change.binary);
|
|
443
|
-
if (change.head !== undefined)
|
|
444
|
-
answer.changes.set(change.path, change.head);
|
|
445
|
-
if (change.revision !== undefined)
|
|
446
|
-
revised(answer, change.path, change.revision);
|
|
447
|
-
}
|
|
448
|
-
return { kind: 'net-advancement', roomVersion: roomVersion(view), ...(yield* answered(answer)) };
|
|
449
|
-
}
|
|
450
|
-
export async function refreshFrom(view, fromRoomVersion) {
|
|
451
|
-
return stepped(refreshing(view, fromRoomVersion));
|
|
228
|
+
: {
|
|
229
|
+
schema: content.content,
|
|
230
|
+
version: file.version,
|
|
231
|
+
revision: file.revision ?? null,
|
|
232
|
+
...(file.space === undefined ? {} : { space: file.space }),
|
|
233
|
+
};
|
|
452
234
|
}
|
package/dist/refusal.d.ts
CHANGED
|
@@ -2,8 +2,5 @@ import type { AdapterFailure, DiscoverResult, ProviderRefusal, ScopedRefusal } f
|
|
|
2
2
|
export declare function doorRefusal(body: unknown): ProviderRefusal | null;
|
|
3
3
|
export declare function scopedRefusal(locator: string, scope: ScopedRefusal['scope'], refusal: ProviderRefusal): ScopedRefusal;
|
|
4
4
|
export declare function classifyDoor(status: number, body: unknown, locator: string): AdapterFailure | null;
|
|
5
|
-
export declare function classifyRead(status: number, body: unknown, locator: string): AdapterFailure | {
|
|
6
|
-
kind: 'beyond-horizon';
|
|
7
|
-
} | null;
|
|
8
5
|
export declare function discoveryFailure(status: number, body: unknown): DiscoverResult | null;
|
|
9
6
|
//# sourceMappingURL=refusal.d.ts.map
|
package/dist/refusal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAOjE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,aAAa,CAEf;AAqBD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG,IAAI,CAMvB;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAOjE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,aAAa,CAEf;AAqBD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG,IAAI,CAMvB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAQrF"}
|