@inspectorhub/field-ui 0.0.0-stage → 0.2.1
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/LICENSE +17 -0
- package/README.md +114 -2
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/data-source-B_ogNIa3.d.ts +1519 -0
- package/dist/index.d.ts +155 -0
- package/dist/index.js +62099 -0
- package/dist/testing.d.ts +247 -0
- package/dist/testing.js +612 -0
- package/dist/theme.css +370 -0
- package/package.json +43 -4
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { FieldResources, AiAssistInput, AiAssistResult, CommentsLibraryQuery, CommentsLibraryEntry, CommentsLibraryRow, CostItemWrite, CostItemView, TemplateSearchResult, MediaPoolListing, RepairItemOption, SettingsSheetData, VersionSnapshotEntry, VersionSnapshotContent, VideoFinalizeInput, VideoUploadTicket, FieldCommand, FieldDataSource, NotifyVariant, PendingMediaRecord, CommandDataMap, InspectionPrefs, CommandResult, EditorData, SessionInfo, FieldUrls } from './index.js';
|
|
2
|
+
import 'yjs';
|
|
3
|
+
|
|
4
|
+
/** The `templateSearch` resource: answers `result` (an empty single page by default) and records each input. */
|
|
5
|
+
interface FakeTemplateSearch {
|
|
6
|
+
search(input: {
|
|
7
|
+
q: string;
|
|
8
|
+
page: number;
|
|
9
|
+
}): Promise<TemplateSearchResult>;
|
|
10
|
+
readonly searches: readonly {
|
|
11
|
+
q: string;
|
|
12
|
+
page: number;
|
|
13
|
+
}[];
|
|
14
|
+
/** Replace the page every later search answers. */
|
|
15
|
+
setResult(result: TemplateSearchResult): void;
|
|
16
|
+
}
|
|
17
|
+
declare function createFakeTemplateSearch(initial?: TemplateSearchResult): FakeTemplateSearch;
|
|
18
|
+
type CommentsLibraryResource = NonNullable<FieldResources['commentsLibrary']>;
|
|
19
|
+
/** The `commentsLibrary` resource: lists `rows`, records every list, touch, save and edit. */
|
|
20
|
+
interface FakeCommentsLibrary extends CommentsLibraryResource {
|
|
21
|
+
/** The query of every `list`, in call order (`undefined` when none was passed). */
|
|
22
|
+
readonly lists: readonly (CommentsLibraryQuery | undefined)[];
|
|
23
|
+
readonly touches: readonly string[];
|
|
24
|
+
/** The entry of every stored `save`, in call order. */
|
|
25
|
+
saved(): readonly CommentsLibraryEntry[];
|
|
26
|
+
/** The id and entry of every `edit`, in call order. */
|
|
27
|
+
edited(): readonly {
|
|
28
|
+
id: string;
|
|
29
|
+
entry: CommentsLibraryEntry;
|
|
30
|
+
}[];
|
|
31
|
+
/** Replace the rows every later `list` answers. */
|
|
32
|
+
setRows(rows: CommentsLibraryRow[]): void;
|
|
33
|
+
/** Make every later `save` answer `{ ok: false, error }` and store nothing. */
|
|
34
|
+
failSave(error: string): void;
|
|
35
|
+
}
|
|
36
|
+
declare function createFakeCommentsLibrary(initial?: CommentsLibraryRow[]): FakeCommentsLibrary;
|
|
37
|
+
type AiAssistResource = NonNullable<FieldResources['aiAssist']>;
|
|
38
|
+
/** The `aiAssist` resource: records every request and answers a configurable result per intent. */
|
|
39
|
+
interface FakeAiAssist extends AiAssistResource {
|
|
40
|
+
/** Every request, in call order. */
|
|
41
|
+
readonly runs: readonly AiAssistInput[];
|
|
42
|
+
/** Replace the answer of every later `assist` (default: a draft with the call id `ai-call-1`). */
|
|
43
|
+
answerAssist(result: AiAssistResult): void;
|
|
44
|
+
/** Replace the answer of every later `review` (default: recorded). */
|
|
45
|
+
answerReview(result: AiAssistResult): void;
|
|
46
|
+
/** Make every later request wait until the returned function is called, to hold one in flight. */
|
|
47
|
+
hold(): () => void;
|
|
48
|
+
}
|
|
49
|
+
declare function createFakeAiAssist(): FakeAiAssist;
|
|
50
|
+
type CostItemsResource = NonNullable<FieldResources['costItems']>;
|
|
51
|
+
/**
|
|
52
|
+
* The `costItems` resource: lists `items`, records every list and write. A `create` answers the id `stored-N`
|
|
53
|
+
* (N counting from 1); `update` and `delete` answer ok. `hold` keeps every later write in flight.
|
|
54
|
+
*/
|
|
55
|
+
interface FakeCostItems extends CostItemsResource {
|
|
56
|
+
/** Inspection ids passed to `list`, in call order. */
|
|
57
|
+
readonly lists: readonly string[];
|
|
58
|
+
/** Every write passed to `save`, in call order. */
|
|
59
|
+
readonly writes: readonly {
|
|
60
|
+
inspectionId: string;
|
|
61
|
+
write: CostItemWrite;
|
|
62
|
+
}[];
|
|
63
|
+
/** Replace the lines every later `list` answers. */
|
|
64
|
+
setItems(items: CostItemView[]): void;
|
|
65
|
+
/** Replace the reserve-schedule switch every later `list` answers. */
|
|
66
|
+
setReserveEnabled(enabled: boolean): void;
|
|
67
|
+
/** Make every later `save` answer `{ ok: false }`. */
|
|
68
|
+
failSave(): void;
|
|
69
|
+
/** Keep every later `save` in flight until the returned function is called. */
|
|
70
|
+
hold(): () => void;
|
|
71
|
+
}
|
|
72
|
+
declare function createFakeCostItems(initial?: CostItemView[]): FakeCostItems;
|
|
73
|
+
|
|
74
|
+
type VersionHistoryResource = NonNullable<FieldResources['versionHistory']>;
|
|
75
|
+
type VideoResource = NonNullable<FieldResources['video']>;
|
|
76
|
+
/** The `versionHistory` resource: lists `snapshots`, records every capture, restore and get. */
|
|
77
|
+
interface FakeVersionHistory extends VersionHistoryResource {
|
|
78
|
+
/** Inspection ids passed to `capture`, in call order. */
|
|
79
|
+
readonly captures: readonly string[];
|
|
80
|
+
/** `{ inspectionId, seq }` passed to `restore`, in call order. */
|
|
81
|
+
readonly restores: readonly {
|
|
82
|
+
inspectionId: string;
|
|
83
|
+
seq: number;
|
|
84
|
+
}[];
|
|
85
|
+
/** `{ inspectionId, seq }` passed to `get`, in call order. */
|
|
86
|
+
readonly gets: readonly {
|
|
87
|
+
inspectionId: string;
|
|
88
|
+
seq: number;
|
|
89
|
+
}[];
|
|
90
|
+
/** Number of `list` calls. */
|
|
91
|
+
readonly lists: number;
|
|
92
|
+
/** Replace the versions every later `list` answers. */
|
|
93
|
+
setSnapshots(snapshots: VersionSnapshotEntry[]): void;
|
|
94
|
+
/** Replace the content every later `get` answers. */
|
|
95
|
+
setContent(content: VersionSnapshotContent): void;
|
|
96
|
+
/** Make every later `list` answer not-ok (the host could not read it). */
|
|
97
|
+
failList(error?: string): void;
|
|
98
|
+
/** Make every later `get` answer not-ok. */
|
|
99
|
+
failGet(error?: string): void;
|
|
100
|
+
/** Make every later `capture` answer `{ ok: false, error }`. */
|
|
101
|
+
failCapture(error: string): void;
|
|
102
|
+
/** Make every later `restore` answer `{ ok: false, error }`. */
|
|
103
|
+
failRestore(error: string): void;
|
|
104
|
+
}
|
|
105
|
+
declare function createFakeVersionHistory(initial?: VersionSnapshotEntry[]): FakeVersionHistory;
|
|
106
|
+
/**
|
|
107
|
+
* The `video` resource. Every member answers a neutral success (a stream ticket, a pool row `pool-1`) and
|
|
108
|
+
* records its call; `fail*` makes a step answer not-ok, `holdCreateUpload` keeps one in flight until released.
|
|
109
|
+
*/
|
|
110
|
+
interface FakeVideo extends VideoResource {
|
|
111
|
+
/** Arguments of every `setPoster`, in call order. */
|
|
112
|
+
readonly posters: readonly {
|
|
113
|
+
inspectionId: string;
|
|
114
|
+
streamUid: string;
|
|
115
|
+
posterPct: number;
|
|
116
|
+
}[];
|
|
117
|
+
/** `{ inspectionId, input }` of every `createUpload`, in call order. */
|
|
118
|
+
readonly createUploads: readonly {
|
|
119
|
+
inspectionId: string;
|
|
120
|
+
input: {
|
|
121
|
+
itemId?: string;
|
|
122
|
+
};
|
|
123
|
+
}[];
|
|
124
|
+
/** File names of every `uploadFile`, in call order. */
|
|
125
|
+
readonly uploadedFiles: readonly string[];
|
|
126
|
+
/** Number of `uploadPoster` calls. */
|
|
127
|
+
readonly posterUploads: number;
|
|
128
|
+
/** The input of every `finalize`, in call order. */
|
|
129
|
+
readonly finalizes: readonly {
|
|
130
|
+
inspectionId: string;
|
|
131
|
+
input: VideoFinalizeInput;
|
|
132
|
+
}[];
|
|
133
|
+
/** Replace the ticket every later `createUpload` answers. */
|
|
134
|
+
setTicket(ticket: VideoUploadTicket): void;
|
|
135
|
+
/** Make every later `createUpload` answer `{ ok: false }` (with `error` when given). */
|
|
136
|
+
failCreateUpload(error?: string): void;
|
|
137
|
+
/** Make every later `uploadFile` answer `{ ok: false }`. */
|
|
138
|
+
failUploadFile(error?: string): void;
|
|
139
|
+
/** Make every later `finalize` answer `{ ok: false }`. */
|
|
140
|
+
failFinalize(error?: string): void;
|
|
141
|
+
/** Keep every later `createUpload` in flight until the returned function is called. */
|
|
142
|
+
holdCreateUpload(): () => void;
|
|
143
|
+
}
|
|
144
|
+
declare function createFakeVideo(): FakeVideo;
|
|
145
|
+
/** The `repairItems` resource: lists `items` and counts the reads. */
|
|
146
|
+
interface FakeRepairItems extends NonNullable<FieldResources['repairItems']> {
|
|
147
|
+
readonly lists: number;
|
|
148
|
+
setItems(items: RepairItemOption[]): void;
|
|
149
|
+
}
|
|
150
|
+
declare function createFakeRepairItems(initial?: RepairItemOption[]): FakeRepairItems;
|
|
151
|
+
/** The `mediaPool` resource: answers `listing` (an answered, empty pool by default) and records each read. */
|
|
152
|
+
interface FakeMediaPool extends NonNullable<FieldResources['mediaPool']> {
|
|
153
|
+
readonly lists: readonly string[];
|
|
154
|
+
setListing(listing: MediaPoolListing): void;
|
|
155
|
+
}
|
|
156
|
+
declare function createFakeMediaPool(initial?: MediaPoolListing): FakeMediaPool;
|
|
157
|
+
/** The `settingsSheet` resource: answers `data` (an empty sheet by default, `null` once `setData(null)`) and records each read. */
|
|
158
|
+
interface FakeSettingsSheet extends NonNullable<FieldResources['settingsSheet']> {
|
|
159
|
+
readonly loads: readonly string[];
|
|
160
|
+
setData(data: SettingsSheetData | null): void;
|
|
161
|
+
}
|
|
162
|
+
declare function createFakeSettingsSheet(initial?: SettingsSheetData | null): FakeSettingsSheet;
|
|
163
|
+
|
|
164
|
+
interface FakeSeed {
|
|
165
|
+
data: EditorData;
|
|
166
|
+
session?: Partial<SessionInfo>;
|
|
167
|
+
urls?: Partial<FieldUrls>;
|
|
168
|
+
/** Defaults to empty: every optional capability is absent. */
|
|
169
|
+
resources?: FieldResources;
|
|
170
|
+
platform?: FieldDataSource['platform'];
|
|
171
|
+
/** Initial connectivity; defaults to online. */
|
|
172
|
+
online?: boolean;
|
|
173
|
+
/** Host members the fake leaves out, to exercise the editor's fallback for a host that lacks them. */
|
|
174
|
+
without?: readonly ('restartSession' | 'openUrl')[];
|
|
175
|
+
}
|
|
176
|
+
interface ExecutedCommand {
|
|
177
|
+
inspectionId: string;
|
|
178
|
+
cmd: FieldCommand;
|
|
179
|
+
/** Present only when the caller passed `ExecuteOptions.idempotencyKey`. */
|
|
180
|
+
idempotencyKey?: string;
|
|
181
|
+
}
|
|
182
|
+
/** A `FieldDataSource` backed by memory, with hooks for tests to inspect and perturb it. */
|
|
183
|
+
interface FakeDataSource extends FieldDataSource {
|
|
184
|
+
/** Every command passed to `execute`, in call order. */
|
|
185
|
+
readonly commands: readonly ExecutedCommand[];
|
|
186
|
+
/** Inspection ids passed to `collab.purge`, in call order. */
|
|
187
|
+
readonly purged: readonly string[];
|
|
188
|
+
readonly reloadCount: number;
|
|
189
|
+
/** Number of `restartSession` calls. */
|
|
190
|
+
readonly restartCount: number;
|
|
191
|
+
/** Every address passed to `openUrl`, in call order. */
|
|
192
|
+
readonly openedUrls: readonly string[];
|
|
193
|
+
readonly exitCount: number;
|
|
194
|
+
/** Every `notify` call, in call order. */
|
|
195
|
+
readonly notifications: readonly {
|
|
196
|
+
message: string;
|
|
197
|
+
variant: NotifyVariant | undefined;
|
|
198
|
+
/** Present only when the caller passed `NotifyOptions.durationMs`. */
|
|
199
|
+
durationMs?: number;
|
|
200
|
+
/** Present only when the caller passed `NotifyOptions.action`; `run` is its handler, so a test can press it. */
|
|
201
|
+
action?: {
|
|
202
|
+
label: string;
|
|
203
|
+
run: () => void;
|
|
204
|
+
};
|
|
205
|
+
}[];
|
|
206
|
+
/** Every `media.uploader(...).upload` call, in call order. `hadDoc` is whether a results document was passed. */
|
|
207
|
+
readonly uploads: readonly {
|
|
208
|
+
inspectionId: string;
|
|
209
|
+
rec: PendingMediaRecord;
|
|
210
|
+
hadDoc: boolean;
|
|
211
|
+
}[];
|
|
212
|
+
/** Make every later upload answer `{ ok: false, error }`. */
|
|
213
|
+
failUpload(error: string): void;
|
|
214
|
+
/**
|
|
215
|
+
* Make every later command of this type answer `{ ok: false, error }`. A response
|
|
216
|
+
* registered with `respondWith` for the same command still rides along as `data`,
|
|
217
|
+
* which is how a failed autofill carries its reason.
|
|
218
|
+
*/
|
|
219
|
+
failExecute(type: FieldCommand['type'], error: string): void;
|
|
220
|
+
/** Attach `data` to every later answer for this command (`type`, or `type:op`). */
|
|
221
|
+
respondWith<K extends keyof CommandDataMap>(key: K, data: CommandDataMap[K]): void;
|
|
222
|
+
/** Make every later `media.store.put` reject with this error. */
|
|
223
|
+
failMediaPut(error: Error): void;
|
|
224
|
+
/** Flip connectivity and notify subscribers. */
|
|
225
|
+
setOnline(online: boolean): void;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* An `EditorData` for an inspection with nothing in it. The members the loader
|
|
229
|
+
* always returns as objects carry the loader's default shape; the members it can
|
|
230
|
+
* return as null are null. The text defaults are empty because the real boilerplate
|
|
231
|
+
* belongs to the host.
|
|
232
|
+
*/
|
|
233
|
+
declare function createEmptyEditorData(overrides?: Partial<EditorData>): EditorData;
|
|
234
|
+
/** The `prefs` resource, in memory. Pass it as `resources.prefs`. */
|
|
235
|
+
interface FakePrefs {
|
|
236
|
+
load(): Promise<InspectionPrefs>;
|
|
237
|
+
patch(delta: Partial<InspectionPrefs>): Promise<CommandResult<InspectionPrefs>>;
|
|
238
|
+
/** Every delta passed to a successful `patch`, in call order. */
|
|
239
|
+
readonly patches: readonly Partial<InspectionPrefs>[];
|
|
240
|
+
/** Make every later `patch` answer `{ ok: false, error }` and store nothing. */
|
|
241
|
+
failPatch(error: string): void;
|
|
242
|
+
}
|
|
243
|
+
declare function createFakePrefs(initial?: Partial<InspectionPrefs>): FakePrefs;
|
|
244
|
+
declare function createFakeDataSource(seed: FakeSeed): FakeDataSource;
|
|
245
|
+
|
|
246
|
+
export { createEmptyEditorData, createFakeAiAssist, createFakeCommentsLibrary, createFakeCostItems, createFakeDataSource, createFakeMediaPool, createFakePrefs, createFakeRepairItems, createFakeSettingsSheet, createFakeTemplateSearch, createFakeVersionHistory, createFakeVideo };
|
|
247
|
+
export type { ExecutedCommand, FakeAiAssist, FakeCommentsLibrary, FakeCostItems, FakeDataSource, FakeMediaPool, FakePrefs, FakeRepairItems, FakeSeed, FakeSettingsSheet, FakeTemplateSearch, FakeVersionHistory, FakeVideo };
|