nucleus-core-ts 0.10.236 → 0.10.237
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.build-ok +1 -1
- package/dist/nucleus.config.d.ts +1 -0
- package/dist/src/Client/Replay/answers/aliases.d.ts +20 -0
- package/dist/src/Client/Replay/answers/aliases.js +57 -0
- package/dist/src/Client/Replay/answers/factory.d.ts +24 -0
- package/dist/src/Client/Replay/answers/factory.js +97 -0
- package/dist/src/Client/Replay/answers/index.d.ts +2 -0
- package/dist/src/Client/Replay/answers/index.js +2 -0
- package/dist/src/Client/Replay/answers/match.d.ts +34 -0
- package/dist/src/Client/Replay/answers/match.js +33 -0
- package/dist/src/Client/Replay/channel/channel.d.ts +144 -0
- package/dist/src/Client/Replay/channel/channel.js +150 -0
- package/dist/src/Client/Replay/channel/index.d.ts +1 -0
- package/dist/src/Client/Replay/channel/index.js +1 -0
- package/dist/src/Client/Replay/contract/index.d.ts +4 -0
- package/dist/src/Client/Replay/contract/index.js +4 -0
- package/dist/src/Client/Replay/contract/parse.d.ts +12 -0
- package/dist/src/Client/Replay/contract/parse.js +98 -0
- package/dist/src/Client/Replay/contract/schema.d.ts +290 -0
- package/dist/src/Client/Replay/contract/schema.js +256 -0
- package/dist/src/Client/Replay/contract/types.d.ts +197 -0
- package/dist/src/Client/Replay/contract/types.js +10 -0
- package/dist/src/Client/Replay/contract/v1.d.ts +72 -0
- package/dist/src/Client/Replay/contract/v1.js +70 -0
- package/dist/src/Client/Replay/driver/actions.d.ts +27 -0
- package/dist/src/Client/Replay/driver/actions.js +55 -0
- package/dist/src/Client/Replay/driver/choose.d.ts +15 -0
- package/dist/src/Client/Replay/driver/choose.js +46 -0
- package/dist/src/Client/Replay/driver/find.d.ts +44 -0
- package/dist/src/Client/Replay/driver/find.js +109 -0
- package/dist/src/Client/Replay/driver/index.d.ts +5 -0
- package/dist/src/Client/Replay/driver/index.js +5 -0
- package/dist/src/Client/Replay/driver/input.d.ts +21 -0
- package/dist/src/Client/Replay/driver/input.js +120 -0
- package/dist/src/Client/Replay/driver/run.d.ts +30 -0
- package/dist/src/Client/Replay/driver/run.js +66 -0
- package/dist/src/Client/Replay/index.d.ts +7 -0
- package/dist/src/Client/Replay/index.js +7 -0
- package/dist/src/Client/Replay/realm/clock.d.ts +16 -0
- package/dist/src/Client/Replay/realm/clock.js +19 -0
- package/dist/src/Client/Replay/realm/fetchRouter.d.ts +25 -0
- package/dist/src/Client/Replay/realm/fetchRouter.js +46 -0
- package/dist/src/Client/Replay/realm/frame.d.ts +40 -0
- package/dist/src/Client/Replay/realm/frame.js +38 -0
- package/dist/src/Client/Replay/realm/index.d.ts +5 -0
- package/dist/src/Client/Replay/realm/index.js +5 -0
- package/dist/src/Client/Replay/realm/install.d.ts +26 -0
- package/dist/src/Client/Replay/realm/install.js +27 -0
- package/dist/src/Client/Replay/realm/storage.d.ts +14 -0
- package/dist/src/Client/Replay/realm/storage.js +51 -0
- package/dist/src/Client/Replay/streams/delivery.d.ts +9 -0
- package/dist/src/Client/Replay/streams/delivery.js +28 -0
- package/dist/src/Client/Replay/streams/emit.d.ts +16 -0
- package/dist/src/Client/Replay/streams/emit.js +66 -0
- package/dist/src/Client/Replay/streams/eventSource.d.ts +29 -0
- package/dist/src/Client/Replay/streams/eventSource.js +63 -0
- package/dist/src/Client/Replay/streams/index.d.ts +6 -0
- package/dist/src/Client/Replay/streams/index.js +6 -0
- package/dist/src/Client/Replay/streams/path.d.ts +10 -0
- package/dist/src/Client/Replay/streams/path.js +28 -0
- package/dist/src/Client/Replay/streams/schedule.d.ts +17 -0
- package/dist/src/Client/Replay/streams/schedule.js +39 -0
- package/dist/src/Client/Replay/streams/socket.d.ts +36 -0
- package/dist/src/Client/Replay/streams/socket.js +104 -0
- package/dist/src/Client/Replay/streams/sse.d.ts +20 -0
- package/dist/src/Client/Replay/streams/sse.js +65 -0
- package/dist/src/Client/Replay/timeline/clock.d.ts +8 -0
- package/dist/src/Client/Replay/timeline/clock.js +22 -0
- package/dist/src/Client/Replay/timeline/fakeClock.d.ts +7 -0
- package/dist/src/Client/Replay/timeline/fakeClock.js +43 -0
- package/dist/src/Client/Replay/timeline/index.d.ts +3 -0
- package/dist/src/Client/Replay/timeline/index.js +3 -0
- package/dist/src/Client/Replay/timeline/loader.d.ts +20 -0
- package/dist/src/Client/Replay/timeline/loader.js +84 -0
- package/dist/src/Client/Replay/timeline/timeline.d.ts +36 -0
- package/dist/src/Client/Replay/timeline/timeline.js +149 -0
- package/package.json +5 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Value } from '@sinclair/typebox/value';
|
|
2
|
+
import { ChapterChunkSchema, ManifestSchema } from './schema';
|
|
3
|
+
import { liftRecordingV1, RecordingV1Schema } from './v1';
|
|
4
|
+
const MAX_ISSUES = 8;
|
|
5
|
+
function issues(schema, value) {
|
|
6
|
+
return [
|
|
7
|
+
...Value.Errors(schema, value)
|
|
8
|
+
].slice(0, MAX_ISSUES).map((error)=>`${error.path || '/'}: ${error.message}`);
|
|
9
|
+
}
|
|
10
|
+
function duplicates(ids, label) {
|
|
11
|
+
const seen = new Set();
|
|
12
|
+
const out = [];
|
|
13
|
+
for (const id of ids){
|
|
14
|
+
if (seen.has(id)) out.push(`duplicate ${label} "${id}"`);
|
|
15
|
+
seen.add(id);
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
function manifestProblems(manifest) {
|
|
20
|
+
const chapterIds = new Set(manifest.chapters.map((chapter)=>chapter.id));
|
|
21
|
+
const unknown = chapterIds.size === 0 ? [] : manifest.steps.filter((step)=>!chapterIds.has(step.chapter)).map((step)=>`step "${step.id}" names unknown chapter "${step.chapter}"`);
|
|
22
|
+
const backwards = manifest.chapters.filter((chapter)=>chapter.to < chapter.from).map((chapter)=>`chapter "${chapter.id}" ends before it starts`);
|
|
23
|
+
return [
|
|
24
|
+
...duplicates(manifest.steps.map((step)=>step.id), 'step id'),
|
|
25
|
+
...duplicates(manifest.chapters.map((chapter)=>chapter.id), 'chapter id'),
|
|
26
|
+
...unknown,
|
|
27
|
+
...backwards
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
function chunkProblems(chunk) {
|
|
31
|
+
const order = chunk.streams.flatMap((stream)=>stream.frames.flatMap((frame, index)=>(stream.frames[index - 1]?.seq ?? Number.NEGATIVE_INFINITY) >= frame.seq ? [
|
|
32
|
+
`stream "${stream.id}" frame ${frame.seq} is out of order`
|
|
33
|
+
] : []));
|
|
34
|
+
return [
|
|
35
|
+
...duplicates(chunk.streams.map((stream)=>stream.id), 'stream id'),
|
|
36
|
+
...duplicates(chunk.sockets.map((socket)=>socket.id), 'socket id'),
|
|
37
|
+
...order
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
function readJson(text) {
|
|
41
|
+
try {
|
|
42
|
+
return {
|
|
43
|
+
ok: true,
|
|
44
|
+
value: JSON.parse(text)
|
|
45
|
+
};
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
ok: false,
|
|
49
|
+
errors: [
|
|
50
|
+
`not valid JSON: ${error instanceof Error ? error.message : 'parse failed'}`
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function checkedManifest(manifest) {
|
|
56
|
+
const problems = manifestProblems(manifest);
|
|
57
|
+
return problems.length > 0 ? {
|
|
58
|
+
ok: false,
|
|
59
|
+
errors: problems
|
|
60
|
+
} : {
|
|
61
|
+
ok: true,
|
|
62
|
+
value: manifest
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Reads a recording manifest (schema version 2, or a version 1 recording lifted to it). Never throws on bad input. */ export function parseManifest(text) {
|
|
66
|
+
const json = readJson(text);
|
|
67
|
+
if (!json.ok) return json;
|
|
68
|
+
const value = json.value;
|
|
69
|
+
if (typeof value === 'object' && value !== null && value.schemaVersion === 1) {
|
|
70
|
+
if (!Value.Check(RecordingV1Schema, value)) return {
|
|
71
|
+
ok: false,
|
|
72
|
+
errors: issues(RecordingV1Schema, value)
|
|
73
|
+
};
|
|
74
|
+
return checkedManifest(liftRecordingV1(value));
|
|
75
|
+
}
|
|
76
|
+
if (!Value.Check(ManifestSchema, value)) return {
|
|
77
|
+
ok: false,
|
|
78
|
+
errors: issues(ManifestSchema, value)
|
|
79
|
+
};
|
|
80
|
+
return checkedManifest(value);
|
|
81
|
+
}
|
|
82
|
+
/** Reads one chapter chunk. Never throws on bad input. */ export function parseChapterChunk(text) {
|
|
83
|
+
const json = readJson(text);
|
|
84
|
+
if (!json.ok) return json;
|
|
85
|
+
const value = json.value;
|
|
86
|
+
if (!Value.Check(ChapterChunkSchema, value)) return {
|
|
87
|
+
ok: false,
|
|
88
|
+
errors: issues(ChapterChunkSchema, value)
|
|
89
|
+
};
|
|
90
|
+
const problems = chunkProblems(value);
|
|
91
|
+
return problems.length > 0 ? {
|
|
92
|
+
ok: false,
|
|
93
|
+
errors: problems
|
|
94
|
+
} : {
|
|
95
|
+
ok: true,
|
|
96
|
+
value
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import type { JsonValue, Localized } from './types';
|
|
2
|
+
/** Accepts any JSON document; the structure around it is validated by the schema that embeds it. */
|
|
3
|
+
export declare const JsonValueSchema: import("@sinclair/typebox").TUnsafe<JsonValue>;
|
|
4
|
+
export declare const IdentifierPattern = "^[a-z0-9][a-z0-9-]{0,79}$";
|
|
5
|
+
/** An anchor id, `#n` when the page showed it more than once. */
|
|
6
|
+
export declare const TargetSchema: import("@sinclair/typebox").TString;
|
|
7
|
+
/** A same-origin application path. */
|
|
8
|
+
export declare const AppPathSchema: import("@sinclair/typebox").TString;
|
|
9
|
+
/** `{ en, ...other languages }`: English is required, any other language is free text. */
|
|
10
|
+
export declare const LocalizedSchema: import("@sinclair/typebox").TUnsafe<Localized>;
|
|
11
|
+
export declare const ActionSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
12
|
+
kind: import("@sinclair/typebox").TLiteral<"navigate">;
|
|
13
|
+
path: import("@sinclair/typebox").TString;
|
|
14
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
15
|
+
kind: import("@sinclair/typebox").TLiteral<"click">;
|
|
16
|
+
target: import("@sinclair/typebox").TString;
|
|
17
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
18
|
+
kind: import("@sinclair/typebox").TLiteral<"waitFor">;
|
|
19
|
+
target: import("@sinclair/typebox").TString;
|
|
20
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
21
|
+
kind: import("@sinclair/typebox").TLiteral<"scrollTo">;
|
|
22
|
+
target: import("@sinclair/typebox").TString;
|
|
23
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
24
|
+
kind: import("@sinclair/typebox").TLiteral<"type">;
|
|
25
|
+
target: import("@sinclair/typebox").TString;
|
|
26
|
+
value: import("@sinclair/typebox").TString;
|
|
27
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
28
|
+
kind: import("@sinclair/typebox").TLiteral<"select">;
|
|
29
|
+
target: import("@sinclair/typebox").TString;
|
|
30
|
+
value: import("@sinclair/typebox").TString;
|
|
31
|
+
optionValue: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
32
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
33
|
+
kind: import("@sinclair/typebox").TLiteral<"check">;
|
|
34
|
+
target: import("@sinclair/typebox").TString;
|
|
35
|
+
checked: import("@sinclair/typebox").TBoolean;
|
|
36
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
37
|
+
kind: import("@sinclair/typebox").TLiteral<"key">;
|
|
38
|
+
target: import("@sinclair/typebox").TString;
|
|
39
|
+
key: import("@sinclair/typebox").TString;
|
|
40
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
41
|
+
kind: import("@sinclair/typebox").TLiteral<"file">;
|
|
42
|
+
target: import("@sinclair/typebox").TString;
|
|
43
|
+
files: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
44
|
+
name: import("@sinclair/typebox").TString;
|
|
45
|
+
type: import("@sinclair/typebox").TString;
|
|
46
|
+
}>>;
|
|
47
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
48
|
+
kind: import("@sinclair/typebox").TLiteral<"waitForFrame">;
|
|
49
|
+
stream: import("@sinclair/typebox").TString;
|
|
50
|
+
seq: import("@sinclair/typebox").TInteger;
|
|
51
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
52
|
+
kind: import("@sinclair/typebox").TLiteral<"waitUntil">;
|
|
53
|
+
at: import("@sinclair/typebox").TNumber;
|
|
54
|
+
}>]>;
|
|
55
|
+
export declare const StepSchema: import("@sinclair/typebox").TObject<{
|
|
56
|
+
id: import("@sinclair/typebox").TString;
|
|
57
|
+
chapter: import("@sinclair/typebox").TString;
|
|
58
|
+
at: import("@sinclair/typebox").TNumber;
|
|
59
|
+
caption: import("@sinclair/typebox").TUnsafe<Localized>;
|
|
60
|
+
actions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
61
|
+
kind: import("@sinclair/typebox").TLiteral<"navigate">;
|
|
62
|
+
path: import("@sinclair/typebox").TString;
|
|
63
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
64
|
+
kind: import("@sinclair/typebox").TLiteral<"click">;
|
|
65
|
+
target: import("@sinclair/typebox").TString;
|
|
66
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
67
|
+
kind: import("@sinclair/typebox").TLiteral<"waitFor">;
|
|
68
|
+
target: import("@sinclair/typebox").TString;
|
|
69
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
70
|
+
kind: import("@sinclair/typebox").TLiteral<"scrollTo">;
|
|
71
|
+
target: import("@sinclair/typebox").TString;
|
|
72
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
73
|
+
kind: import("@sinclair/typebox").TLiteral<"type">;
|
|
74
|
+
target: import("@sinclair/typebox").TString;
|
|
75
|
+
value: import("@sinclair/typebox").TString;
|
|
76
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
77
|
+
kind: import("@sinclair/typebox").TLiteral<"select">;
|
|
78
|
+
target: import("@sinclair/typebox").TString;
|
|
79
|
+
value: import("@sinclair/typebox").TString;
|
|
80
|
+
optionValue: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
81
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
82
|
+
kind: import("@sinclair/typebox").TLiteral<"check">;
|
|
83
|
+
target: import("@sinclair/typebox").TString;
|
|
84
|
+
checked: import("@sinclair/typebox").TBoolean;
|
|
85
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
86
|
+
kind: import("@sinclair/typebox").TLiteral<"key">;
|
|
87
|
+
target: import("@sinclair/typebox").TString;
|
|
88
|
+
key: import("@sinclair/typebox").TString;
|
|
89
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
90
|
+
kind: import("@sinclair/typebox").TLiteral<"file">;
|
|
91
|
+
target: import("@sinclair/typebox").TString;
|
|
92
|
+
files: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
93
|
+
name: import("@sinclair/typebox").TString;
|
|
94
|
+
type: import("@sinclair/typebox").TString;
|
|
95
|
+
}>>;
|
|
96
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
97
|
+
kind: import("@sinclair/typebox").TLiteral<"waitForFrame">;
|
|
98
|
+
stream: import("@sinclair/typebox").TString;
|
|
99
|
+
seq: import("@sinclair/typebox").TInteger;
|
|
100
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
101
|
+
kind: import("@sinclair/typebox").TLiteral<"waitUntil">;
|
|
102
|
+
at: import("@sinclair/typebox").TNumber;
|
|
103
|
+
}>]>>;
|
|
104
|
+
}>;
|
|
105
|
+
export declare const AnswerSchema: import("@sinclair/typebox").TObject<{
|
|
106
|
+
key: import("@sinclair/typebox").TString;
|
|
107
|
+
payload: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<JsonValue>>;
|
|
108
|
+
status: import("@sinclair/typebox").TInteger;
|
|
109
|
+
body: import("@sinclair/typebox").TUnsafe<JsonValue>;
|
|
110
|
+
at: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
111
|
+
}>;
|
|
112
|
+
export declare const StreamSchema: import("@sinclair/typebox").TObject<{
|
|
113
|
+
id: import("@sinclair/typebox").TString;
|
|
114
|
+
transport: import("@sinclair/typebox").TLiteral<"sse">;
|
|
115
|
+
match: import("@sinclair/typebox").TObject<{
|
|
116
|
+
method: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"GET">, import("@sinclair/typebox").TLiteral<"POST">]>;
|
|
117
|
+
path: import("@sinclair/typebox").TString;
|
|
118
|
+
query: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>>;
|
|
119
|
+
}>;
|
|
120
|
+
openAt: import("@sinclair/typebox").TNumber;
|
|
121
|
+
closeAt: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TNull]>;
|
|
122
|
+
heartbeat: import("@sinclair/typebox").TObject<{
|
|
123
|
+
everyMs: import("@sinclair/typebox").TInteger;
|
|
124
|
+
line: import("@sinclair/typebox").TString;
|
|
125
|
+
}>;
|
|
126
|
+
frames: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
127
|
+
seq: import("@sinclair/typebox").TInteger;
|
|
128
|
+
at: import("@sinclair/typebox").TNumber;
|
|
129
|
+
data: import("@sinclair/typebox").TString;
|
|
130
|
+
event: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
131
|
+
}>>;
|
|
132
|
+
}>;
|
|
133
|
+
export declare const SocketSchema: import("@sinclair/typebox").TObject<{
|
|
134
|
+
id: import("@sinclair/typebox").TString;
|
|
135
|
+
match: import("@sinclair/typebox").TObject<{
|
|
136
|
+
path: import("@sinclair/typebox").TString;
|
|
137
|
+
}>;
|
|
138
|
+
openAt: import("@sinclair/typebox").TNumber;
|
|
139
|
+
closeAt: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TNull]>;
|
|
140
|
+
closeCode: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
141
|
+
messages: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
142
|
+
at: import("@sinclair/typebox").TNumber;
|
|
143
|
+
data: import("@sinclair/typebox").TString;
|
|
144
|
+
}>>;
|
|
145
|
+
}>;
|
|
146
|
+
export declare const ChapterSchema: import("@sinclair/typebox").TObject<{
|
|
147
|
+
id: import("@sinclair/typebox").TString;
|
|
148
|
+
title: import("@sinclair/typebox").TUnsafe<Localized>;
|
|
149
|
+
from: import("@sinclair/typebox").TNumber;
|
|
150
|
+
to: import("@sinclair/typebox").TNumber;
|
|
151
|
+
rate: import("@sinclair/typebox").TNumber;
|
|
152
|
+
chunk: import("@sinclair/typebox").TString;
|
|
153
|
+
}>;
|
|
154
|
+
export declare const ChapterChunkSchema: import("@sinclair/typebox").TObject<{
|
|
155
|
+
answers: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
156
|
+
key: import("@sinclair/typebox").TString;
|
|
157
|
+
payload: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<JsonValue>>;
|
|
158
|
+
status: import("@sinclair/typebox").TInteger;
|
|
159
|
+
body: import("@sinclair/typebox").TUnsafe<JsonValue>;
|
|
160
|
+
at: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
161
|
+
}>>;
|
|
162
|
+
streams: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
163
|
+
id: import("@sinclair/typebox").TString;
|
|
164
|
+
transport: import("@sinclair/typebox").TLiteral<"sse">;
|
|
165
|
+
match: import("@sinclair/typebox").TObject<{
|
|
166
|
+
method: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"GET">, import("@sinclair/typebox").TLiteral<"POST">]>;
|
|
167
|
+
path: import("@sinclair/typebox").TString;
|
|
168
|
+
query: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>>;
|
|
169
|
+
}>;
|
|
170
|
+
openAt: import("@sinclair/typebox").TNumber;
|
|
171
|
+
closeAt: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TNull]>;
|
|
172
|
+
heartbeat: import("@sinclair/typebox").TObject<{
|
|
173
|
+
everyMs: import("@sinclair/typebox").TInteger;
|
|
174
|
+
line: import("@sinclair/typebox").TString;
|
|
175
|
+
}>;
|
|
176
|
+
frames: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
177
|
+
seq: import("@sinclair/typebox").TInteger;
|
|
178
|
+
at: import("@sinclair/typebox").TNumber;
|
|
179
|
+
data: import("@sinclair/typebox").TString;
|
|
180
|
+
event: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
181
|
+
}>>;
|
|
182
|
+
}>>;
|
|
183
|
+
sockets: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
184
|
+
id: import("@sinclair/typebox").TString;
|
|
185
|
+
match: import("@sinclair/typebox").TObject<{
|
|
186
|
+
path: import("@sinclair/typebox").TString;
|
|
187
|
+
}>;
|
|
188
|
+
openAt: import("@sinclair/typebox").TNumber;
|
|
189
|
+
closeAt: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TNull]>;
|
|
190
|
+
closeCode: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
191
|
+
messages: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
192
|
+
at: import("@sinclair/typebox").TNumber;
|
|
193
|
+
data: import("@sinclair/typebox").TString;
|
|
194
|
+
}>>;
|
|
195
|
+
}>>;
|
|
196
|
+
}>;
|
|
197
|
+
export declare const ManifestSchema: import("@sinclair/typebox").TObject<{
|
|
198
|
+
schemaVersion: import("@sinclair/typebox").TLiteral<2>;
|
|
199
|
+
id: import("@sinclair/typebox").TString;
|
|
200
|
+
title: import("@sinclair/typebox").TUnsafe<Localized>;
|
|
201
|
+
startPath: import("@sinclair/typebox").TString;
|
|
202
|
+
viewport: import("@sinclair/typebox").TObject<{
|
|
203
|
+
width: import("@sinclair/typebox").TInteger;
|
|
204
|
+
height: import("@sinclair/typebox").TInteger;
|
|
205
|
+
}>;
|
|
206
|
+
targetAttribute: import("@sinclair/typebox").TString;
|
|
207
|
+
clock: import("@sinclair/typebox").TObject<{
|
|
208
|
+
epochMs: import("@sinclair/typebox").TNumber;
|
|
209
|
+
durationMs: import("@sinclair/typebox").TNumber;
|
|
210
|
+
}>;
|
|
211
|
+
chapters: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
212
|
+
id: import("@sinclair/typebox").TString;
|
|
213
|
+
title: import("@sinclair/typebox").TUnsafe<Localized>;
|
|
214
|
+
from: import("@sinclair/typebox").TNumber;
|
|
215
|
+
to: import("@sinclair/typebox").TNumber;
|
|
216
|
+
rate: import("@sinclair/typebox").TNumber;
|
|
217
|
+
chunk: import("@sinclair/typebox").TString;
|
|
218
|
+
}>>;
|
|
219
|
+
steps: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
220
|
+
id: import("@sinclair/typebox").TString;
|
|
221
|
+
chapter: import("@sinclair/typebox").TString;
|
|
222
|
+
at: import("@sinclair/typebox").TNumber;
|
|
223
|
+
caption: import("@sinclair/typebox").TUnsafe<Localized>;
|
|
224
|
+
actions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
225
|
+
kind: import("@sinclair/typebox").TLiteral<"navigate">;
|
|
226
|
+
path: import("@sinclair/typebox").TString;
|
|
227
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
228
|
+
kind: import("@sinclair/typebox").TLiteral<"click">;
|
|
229
|
+
target: import("@sinclair/typebox").TString;
|
|
230
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
231
|
+
kind: import("@sinclair/typebox").TLiteral<"waitFor">;
|
|
232
|
+
target: import("@sinclair/typebox").TString;
|
|
233
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
234
|
+
kind: import("@sinclair/typebox").TLiteral<"scrollTo">;
|
|
235
|
+
target: import("@sinclair/typebox").TString;
|
|
236
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
237
|
+
kind: import("@sinclair/typebox").TLiteral<"type">;
|
|
238
|
+
target: import("@sinclair/typebox").TString;
|
|
239
|
+
value: import("@sinclair/typebox").TString;
|
|
240
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
241
|
+
kind: import("@sinclair/typebox").TLiteral<"select">;
|
|
242
|
+
target: import("@sinclair/typebox").TString;
|
|
243
|
+
value: import("@sinclair/typebox").TString;
|
|
244
|
+
optionValue: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
245
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
246
|
+
kind: import("@sinclair/typebox").TLiteral<"check">;
|
|
247
|
+
target: import("@sinclair/typebox").TString;
|
|
248
|
+
checked: import("@sinclair/typebox").TBoolean;
|
|
249
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
250
|
+
kind: import("@sinclair/typebox").TLiteral<"key">;
|
|
251
|
+
target: import("@sinclair/typebox").TString;
|
|
252
|
+
key: import("@sinclair/typebox").TString;
|
|
253
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
254
|
+
kind: import("@sinclair/typebox").TLiteral<"file">;
|
|
255
|
+
target: import("@sinclair/typebox").TString;
|
|
256
|
+
files: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
257
|
+
name: import("@sinclair/typebox").TString;
|
|
258
|
+
type: import("@sinclair/typebox").TString;
|
|
259
|
+
}>>;
|
|
260
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
261
|
+
kind: import("@sinclair/typebox").TLiteral<"waitForFrame">;
|
|
262
|
+
stream: import("@sinclair/typebox").TString;
|
|
263
|
+
seq: import("@sinclair/typebox").TInteger;
|
|
264
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
265
|
+
kind: import("@sinclair/typebox").TLiteral<"waitUntil">;
|
|
266
|
+
at: import("@sinclair/typebox").TNumber;
|
|
267
|
+
}>]>>;
|
|
268
|
+
}>>;
|
|
269
|
+
boot: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
270
|
+
key: import("@sinclair/typebox").TString;
|
|
271
|
+
payload: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<JsonValue>>;
|
|
272
|
+
status: import("@sinclair/typebox").TInteger;
|
|
273
|
+
body: import("@sinclair/typebox").TUnsafe<JsonValue>;
|
|
274
|
+
at: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
275
|
+
}>>;
|
|
276
|
+
assets: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
|
|
277
|
+
path: import("@sinclair/typebox").TString;
|
|
278
|
+
type: import("@sinclair/typebox").TString;
|
|
279
|
+
bytes: import("@sinclair/typebox").TInteger;
|
|
280
|
+
}>>;
|
|
281
|
+
source: import("@sinclair/typebox").TObject<{
|
|
282
|
+
runId: import("@sinclair/typebox").TString;
|
|
283
|
+
recordedAt: import("@sinclair/typebox").TString;
|
|
284
|
+
appVersion: import("@sinclair/typebox").TString;
|
|
285
|
+
}>;
|
|
286
|
+
redactions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
287
|
+
rule: import("@sinclair/typebox").TString;
|
|
288
|
+
count: import("@sinclair/typebox").TInteger;
|
|
289
|
+
}>>;
|
|
290
|
+
}>;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { Type } from '@sinclair/typebox';
|
|
2
|
+
/** Accepts any JSON document; the structure around it is validated by the schema that embeds it. */ export const JsonValueSchema = Type.Unsafe(Type.Any());
|
|
3
|
+
const Text = Type.String({
|
|
4
|
+
minLength: 1,
|
|
5
|
+
maxLength: 600
|
|
6
|
+
});
|
|
7
|
+
export const IdentifierPattern = '^[a-z0-9][a-z0-9-]{0,79}$';
|
|
8
|
+
const Identifier = Type.String({
|
|
9
|
+
pattern: IdentifierPattern
|
|
10
|
+
});
|
|
11
|
+
const Ms = Type.Number({
|
|
12
|
+
minimum: 0
|
|
13
|
+
});
|
|
14
|
+
/** An anchor id, `#n` when the page showed it more than once. */ export const TargetSchema = Type.String({
|
|
15
|
+
pattern: '^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}(#[1-9][0-9]{0,2})?$'
|
|
16
|
+
});
|
|
17
|
+
/** A same-origin application path. */ export const AppPathSchema = Type.String({
|
|
18
|
+
pattern: '^/(?!/)[^\\s#]*$',
|
|
19
|
+
maxLength: 300
|
|
20
|
+
});
|
|
21
|
+
const UrlPath = Type.String({
|
|
22
|
+
pattern: '^/[^\\s?#]*$',
|
|
23
|
+
maxLength: 300
|
|
24
|
+
});
|
|
25
|
+
/** `{ en, ...other languages }`: English is required, any other language is free text. */ export const LocalizedSchema = Type.Unsafe(Type.Intersect([
|
|
26
|
+
Type.Object({
|
|
27
|
+
en: Text
|
|
28
|
+
}),
|
|
29
|
+
Type.Record(Type.String(), Text)
|
|
30
|
+
]));
|
|
31
|
+
const ChosenFile = Type.Object({
|
|
32
|
+
name: Type.String({
|
|
33
|
+
pattern: '^[^\\\\/:*?"<>|]{1,200}$'
|
|
34
|
+
}),
|
|
35
|
+
type: Type.String({
|
|
36
|
+
pattern: '^([a-z0-9!#$&^_.+-]+/[a-z0-9!#$&^_.+-]+)?$',
|
|
37
|
+
maxLength: 120
|
|
38
|
+
})
|
|
39
|
+
}, {
|
|
40
|
+
additionalProperties: false
|
|
41
|
+
});
|
|
42
|
+
const strict = {
|
|
43
|
+
additionalProperties: false
|
|
44
|
+
};
|
|
45
|
+
export const ActionSchema = Type.Union([
|
|
46
|
+
Type.Object({
|
|
47
|
+
kind: Type.Literal('navigate'),
|
|
48
|
+
path: AppPathSchema
|
|
49
|
+
}, strict),
|
|
50
|
+
Type.Object({
|
|
51
|
+
kind: Type.Literal('click'),
|
|
52
|
+
target: TargetSchema
|
|
53
|
+
}, strict),
|
|
54
|
+
Type.Object({
|
|
55
|
+
kind: Type.Literal('waitFor'),
|
|
56
|
+
target: TargetSchema
|
|
57
|
+
}, strict),
|
|
58
|
+
Type.Object({
|
|
59
|
+
kind: Type.Literal('scrollTo'),
|
|
60
|
+
target: TargetSchema
|
|
61
|
+
}, strict),
|
|
62
|
+
Type.Object({
|
|
63
|
+
kind: Type.Literal('type'),
|
|
64
|
+
target: TargetSchema,
|
|
65
|
+
value: Type.String({
|
|
66
|
+
maxLength: 4000
|
|
67
|
+
})
|
|
68
|
+
}, strict),
|
|
69
|
+
Type.Object({
|
|
70
|
+
kind: Type.Literal('select'),
|
|
71
|
+
target: TargetSchema,
|
|
72
|
+
value: Type.String({
|
|
73
|
+
minLength: 1,
|
|
74
|
+
maxLength: 400
|
|
75
|
+
}),
|
|
76
|
+
optionValue: Type.Optional(Type.String({
|
|
77
|
+
minLength: 1,
|
|
78
|
+
maxLength: 400
|
|
79
|
+
}))
|
|
80
|
+
}, strict),
|
|
81
|
+
Type.Object({
|
|
82
|
+
kind: Type.Literal('check'),
|
|
83
|
+
target: TargetSchema,
|
|
84
|
+
checked: Type.Boolean()
|
|
85
|
+
}, strict),
|
|
86
|
+
Type.Object({
|
|
87
|
+
kind: Type.Literal('key'),
|
|
88
|
+
target: TargetSchema,
|
|
89
|
+
key: Type.String({
|
|
90
|
+
minLength: 1,
|
|
91
|
+
maxLength: 40
|
|
92
|
+
})
|
|
93
|
+
}, strict),
|
|
94
|
+
Type.Object({
|
|
95
|
+
kind: Type.Literal('file'),
|
|
96
|
+
target: TargetSchema,
|
|
97
|
+
files: Type.Array(ChosenFile, {
|
|
98
|
+
minItems: 1,
|
|
99
|
+
maxItems: 10
|
|
100
|
+
})
|
|
101
|
+
}, strict),
|
|
102
|
+
Type.Object({
|
|
103
|
+
kind: Type.Literal('waitForFrame'),
|
|
104
|
+
stream: Identifier,
|
|
105
|
+
seq: Type.Integer({
|
|
106
|
+
minimum: 0
|
|
107
|
+
})
|
|
108
|
+
}, strict),
|
|
109
|
+
Type.Object({
|
|
110
|
+
kind: Type.Literal('waitUntil'),
|
|
111
|
+
at: Ms
|
|
112
|
+
}, strict)
|
|
113
|
+
]);
|
|
114
|
+
export const StepSchema = Type.Object({
|
|
115
|
+
id: Identifier,
|
|
116
|
+
chapter: Identifier,
|
|
117
|
+
at: Ms,
|
|
118
|
+
caption: LocalizedSchema,
|
|
119
|
+
actions: Type.Array(ActionSchema, {
|
|
120
|
+
maxItems: 60
|
|
121
|
+
})
|
|
122
|
+
}, strict);
|
|
123
|
+
export const AnswerSchema = Type.Object({
|
|
124
|
+
key: Type.String({
|
|
125
|
+
pattern: '^[A-Z][A-Z0-9_]*$'
|
|
126
|
+
}),
|
|
127
|
+
payload: Type.Optional(JsonValueSchema),
|
|
128
|
+
status: Type.Integer({
|
|
129
|
+
minimum: 100,
|
|
130
|
+
maximum: 599
|
|
131
|
+
}),
|
|
132
|
+
body: JsonValueSchema,
|
|
133
|
+
at: Type.Optional(Ms)
|
|
134
|
+
}, strict);
|
|
135
|
+
const Closing = Type.Union([
|
|
136
|
+
Ms,
|
|
137
|
+
Type.Null()
|
|
138
|
+
]);
|
|
139
|
+
export const StreamSchema = Type.Object({
|
|
140
|
+
id: Identifier,
|
|
141
|
+
transport: Type.Literal('sse'),
|
|
142
|
+
match: Type.Object({
|
|
143
|
+
method: Type.Union([
|
|
144
|
+
Type.Literal('GET'),
|
|
145
|
+
Type.Literal('POST')
|
|
146
|
+
]),
|
|
147
|
+
path: UrlPath,
|
|
148
|
+
query: Type.Optional(Type.Record(Type.String(), Type.String()))
|
|
149
|
+
}, strict),
|
|
150
|
+
openAt: Ms,
|
|
151
|
+
closeAt: Closing,
|
|
152
|
+
heartbeat: Type.Object({
|
|
153
|
+
everyMs: Type.Integer({
|
|
154
|
+
minimum: 1
|
|
155
|
+
}),
|
|
156
|
+
line: Type.String()
|
|
157
|
+
}, strict),
|
|
158
|
+
frames: Type.Array(Type.Object({
|
|
159
|
+
seq: Type.Integer({
|
|
160
|
+
minimum: 0
|
|
161
|
+
}),
|
|
162
|
+
at: Ms,
|
|
163
|
+
data: Type.String(),
|
|
164
|
+
event: Type.Optional(Type.String({
|
|
165
|
+
maxLength: 120
|
|
166
|
+
}))
|
|
167
|
+
}, strict))
|
|
168
|
+
}, strict);
|
|
169
|
+
export const SocketSchema = Type.Object({
|
|
170
|
+
id: Identifier,
|
|
171
|
+
match: Type.Object({
|
|
172
|
+
path: UrlPath
|
|
173
|
+
}, strict),
|
|
174
|
+
openAt: Ms,
|
|
175
|
+
closeAt: Closing,
|
|
176
|
+
closeCode: Type.Optional(Type.Integer({
|
|
177
|
+
minimum: 1000,
|
|
178
|
+
maximum: 4999
|
|
179
|
+
})),
|
|
180
|
+
messages: Type.Array(Type.Object({
|
|
181
|
+
at: Ms,
|
|
182
|
+
data: Type.String()
|
|
183
|
+
}, strict))
|
|
184
|
+
}, strict);
|
|
185
|
+
export const ChapterSchema = Type.Object({
|
|
186
|
+
id: Identifier,
|
|
187
|
+
title: LocalizedSchema,
|
|
188
|
+
from: Ms,
|
|
189
|
+
to: Ms,
|
|
190
|
+
rate: Type.Number({
|
|
191
|
+
exclusiveMinimum: 0,
|
|
192
|
+
maximum: 64
|
|
193
|
+
}),
|
|
194
|
+
chunk: Type.String({
|
|
195
|
+
pattern: '^[A-Za-z0-9][A-Za-z0-9._-]*\\.json$',
|
|
196
|
+
maxLength: 120
|
|
197
|
+
})
|
|
198
|
+
}, strict);
|
|
199
|
+
export const ChapterChunkSchema = Type.Object({
|
|
200
|
+
answers: Type.Array(AnswerSchema),
|
|
201
|
+
streams: Type.Array(StreamSchema),
|
|
202
|
+
sockets: Type.Array(SocketSchema)
|
|
203
|
+
}, strict);
|
|
204
|
+
export const ManifestSchema = Type.Object({
|
|
205
|
+
schemaVersion: Type.Literal(2),
|
|
206
|
+
id: Identifier,
|
|
207
|
+
title: LocalizedSchema,
|
|
208
|
+
startPath: AppPathSchema,
|
|
209
|
+
viewport: Type.Object({
|
|
210
|
+
width: Type.Integer({
|
|
211
|
+
minimum: 1
|
|
212
|
+
}),
|
|
213
|
+
height: Type.Integer({
|
|
214
|
+
minimum: 1
|
|
215
|
+
})
|
|
216
|
+
}, strict),
|
|
217
|
+
targetAttribute: Type.String({
|
|
218
|
+
pattern: '^[a-z][a-z0-9-]*$',
|
|
219
|
+
maxLength: 60
|
|
220
|
+
}),
|
|
221
|
+
clock: Type.Object({
|
|
222
|
+
epochMs: Type.Number(),
|
|
223
|
+
durationMs: Ms
|
|
224
|
+
}, strict),
|
|
225
|
+
chapters: Type.Array(ChapterSchema, {
|
|
226
|
+
maxItems: 100
|
|
227
|
+
}),
|
|
228
|
+
steps: Type.Array(StepSchema, {
|
|
229
|
+
minItems: 1,
|
|
230
|
+
maxItems: 500
|
|
231
|
+
}),
|
|
232
|
+
boot: Type.Array(AnswerSchema),
|
|
233
|
+
assets: Type.Record(Type.String(), Type.Object({
|
|
234
|
+
path: Type.String({
|
|
235
|
+
minLength: 1,
|
|
236
|
+
maxLength: 300
|
|
237
|
+
}),
|
|
238
|
+
type: Type.String({
|
|
239
|
+
maxLength: 120
|
|
240
|
+
}),
|
|
241
|
+
bytes: Type.Integer({
|
|
242
|
+
minimum: 0
|
|
243
|
+
})
|
|
244
|
+
}, strict)),
|
|
245
|
+
source: Type.Object({
|
|
246
|
+
runId: Type.String(),
|
|
247
|
+
recordedAt: Type.String(),
|
|
248
|
+
appVersion: Type.String()
|
|
249
|
+
}, strict),
|
|
250
|
+
redactions: Type.Array(Type.Object({
|
|
251
|
+
rule: Type.String(),
|
|
252
|
+
count: Type.Integer({
|
|
253
|
+
minimum: 0
|
|
254
|
+
})
|
|
255
|
+
}, strict))
|
|
256
|
+
}, strict);
|