@ankhorage/contracts 26.5.0 → 26.7.0
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/flow.d.ts +239 -0
- package/dist/flow.d.ts.map +1 -0
- package/dist/flow.js +2 -0
- package/dist/flow.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/structure/generated.d.ts +2 -2
- package/dist/structure/generated.js +2 -2
- package/dist/structure/generated.js.map +1 -1
- package/dist/website.d.ts +260 -0
- package/dist/website.d.ts.map +1 -0
- package/dist/website.js +2 -0
- package/dist/website.js.map +1 -0
- package/package.json +10 -2
- package/src/flow.test.ts +218 -0
- package/src/flow.ts +254 -0
- package/src/flowPackedConsumer.test.ts +98 -0
- package/src/index.ts +2 -0
- package/src/structure/generated.ts +2 -2
- package/src/website.test.ts +39 -0
- package/src/website.ts +287 -0
package/src/website.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import type { MediaAssetReference } from './media.js';
|
|
2
|
+
import type { SerializableValue } from './serializable.js';
|
|
3
|
+
import type { UiNode } from './types.js';
|
|
4
|
+
|
|
5
|
+
/*** A versioned, portable capture of the observable state of one website. */
|
|
6
|
+
export interface WebsiteObservationDocument {
|
|
7
|
+
readonly schemaVersion: 1;
|
|
8
|
+
readonly documentId: string;
|
|
9
|
+
readonly collectedAt: string;
|
|
10
|
+
readonly source: WebsiteSource;
|
|
11
|
+
readonly site: WebsiteSite;
|
|
12
|
+
readonly pages: readonly WebsitePageObservation[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/*** The scraper identity and immutable crawl revision that produced a website document. */
|
|
16
|
+
export interface WebsiteSource {
|
|
17
|
+
readonly crawlerId: string;
|
|
18
|
+
readonly crawlerVersion: string;
|
|
19
|
+
readonly crawlId: string;
|
|
20
|
+
readonly revision: string | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/*** A site identity and its canonical entry URL. */
|
|
24
|
+
export interface WebsiteSite {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly url: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*** One observed page, including its ordered navigation and captured render states. */
|
|
30
|
+
export interface WebsitePageObservation {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly url: string;
|
|
33
|
+
readonly path: string;
|
|
34
|
+
readonly navigation: readonly WebsiteNavigationItem[];
|
|
35
|
+
readonly viewports: readonly WebsiteViewport[];
|
|
36
|
+
readonly states: readonly WebsiteState[];
|
|
37
|
+
readonly nodes: readonly WebsiteObservedNode[];
|
|
38
|
+
readonly assets: readonly WebsiteAsset[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/*** One ordered, source-linked navigation target observed on a page. */
|
|
42
|
+
export interface WebsiteNavigationItem {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly label: string;
|
|
45
|
+
readonly url: string;
|
|
46
|
+
readonly sourceRef: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*** A rendered viewport used while observing responsive website state. */
|
|
50
|
+
export interface WebsiteViewport {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
readonly width: number;
|
|
53
|
+
readonly height: number;
|
|
54
|
+
readonly devicePixelRatio: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/*** A named rendered state, such as default, hover, or expanded. */
|
|
58
|
+
export interface WebsiteState {
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly name: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/*** A stable DOM node and every source-linked observation collected for it. */
|
|
64
|
+
export interface WebsiteObservedNode {
|
|
65
|
+
readonly sourceRef: string;
|
|
66
|
+
readonly parentSourceRef: string | null;
|
|
67
|
+
readonly ancestorSourceRefs: readonly string[];
|
|
68
|
+
readonly dom: WebsiteDomNode;
|
|
69
|
+
readonly textRuns: readonly WebsiteTextRun[];
|
|
70
|
+
readonly links: readonly WebsiteLink[];
|
|
71
|
+
readonly media: readonly WebsiteMediaReference[];
|
|
72
|
+
readonly observations: readonly WebsiteNodeObservation[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/*** A portable DOM identity with safe semantic attributes only. */
|
|
76
|
+
export interface WebsiteDomNode {
|
|
77
|
+
readonly tagName: string;
|
|
78
|
+
readonly childIndex: number;
|
|
79
|
+
readonly attributes: Readonly<Record<string, string>>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/*** A text run retained separately from its DOM node so inline styled spans are not lost. */
|
|
83
|
+
export interface WebsiteTextRun {
|
|
84
|
+
readonly sourceRef: string;
|
|
85
|
+
readonly text: string;
|
|
86
|
+
readonly start: number;
|
|
87
|
+
readonly end: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*** A source-linked hyperlink observed on a DOM node. */
|
|
91
|
+
export interface WebsiteLink {
|
|
92
|
+
readonly sourceRef: string;
|
|
93
|
+
readonly url: string;
|
|
94
|
+
readonly label: string | null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/*** An image, video, audio, or embedded media reference observed on a DOM node. */
|
|
98
|
+
export interface WebsiteMediaReference {
|
|
99
|
+
readonly sourceRef: string;
|
|
100
|
+
readonly assetId: string | null;
|
|
101
|
+
readonly url: string;
|
|
102
|
+
readonly kind: 'audio' | 'document' | 'embed' | 'image' | 'video';
|
|
103
|
+
readonly alt: string | null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/*** One viewport/state-specific visual observation of a DOM node. */
|
|
107
|
+
export interface WebsiteNodeObservation {
|
|
108
|
+
readonly viewportId: string;
|
|
109
|
+
readonly stateId: string;
|
|
110
|
+
readonly availability: WebsiteAvailability;
|
|
111
|
+
readonly rect: WebsiteBoundingRect | null;
|
|
112
|
+
readonly css: WebsiteComputedCss | null;
|
|
113
|
+
readonly provenance: WebsiteObservationProvenance;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/*** Whether a source value was available without fabricating a replacement. */
|
|
117
|
+
export interface WebsiteAvailability {
|
|
118
|
+
readonly status: 'available' | 'missing';
|
|
119
|
+
readonly missing: WebsiteMissingValue | null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/*** The explicit reason a website source value could not be observed. */
|
|
123
|
+
export interface WebsiteMissingValue {
|
|
124
|
+
readonly code: string;
|
|
125
|
+
readonly message: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/*** A bounding rectangle measured in CSS pixels. */
|
|
129
|
+
export interface WebsiteBoundingRect {
|
|
130
|
+
readonly x: number;
|
|
131
|
+
readonly y: number;
|
|
132
|
+
readonly width: number;
|
|
133
|
+
readonly height: number;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/*** Computed visual CSS values needed to describe, not assess, a rendered website. */
|
|
137
|
+
export interface WebsiteComputedCss {
|
|
138
|
+
readonly display: string;
|
|
139
|
+
readonly position: string;
|
|
140
|
+
readonly visibility: string;
|
|
141
|
+
readonly color: string;
|
|
142
|
+
readonly backgroundColor: string;
|
|
143
|
+
readonly borderColor: string;
|
|
144
|
+
readonly borderRadius: string;
|
|
145
|
+
readonly borderWidth: string;
|
|
146
|
+
readonly boxShadow: string;
|
|
147
|
+
readonly fontFamily: string;
|
|
148
|
+
readonly fontSize: string;
|
|
149
|
+
readonly fontStyle: string;
|
|
150
|
+
readonly fontWeight: string;
|
|
151
|
+
readonly letterSpacing: string;
|
|
152
|
+
readonly lineHeight: string;
|
|
153
|
+
readonly textAlign: string;
|
|
154
|
+
readonly textDecoration: string;
|
|
155
|
+
readonly opacity: string;
|
|
156
|
+
readonly overflow: string;
|
|
157
|
+
readonly overflowX: string;
|
|
158
|
+
readonly overflowY: string;
|
|
159
|
+
readonly backgroundImage: string;
|
|
160
|
+
readonly backgroundPosition: string;
|
|
161
|
+
readonly backgroundRepeat: string;
|
|
162
|
+
readonly backgroundSize: string;
|
|
163
|
+
readonly margin: WebsiteBoxEdges;
|
|
164
|
+
readonly padding: WebsiteBoxEdges;
|
|
165
|
+
readonly alignContent: string;
|
|
166
|
+
readonly alignItems: string;
|
|
167
|
+
readonly alignSelf: string;
|
|
168
|
+
readonly gap: string;
|
|
169
|
+
readonly flexDirection: string;
|
|
170
|
+
readonly flexBasis: string;
|
|
171
|
+
readonly flexGrow: string;
|
|
172
|
+
readonly flexShrink: string;
|
|
173
|
+
readonly flexWrap: string;
|
|
174
|
+
readonly justifyContent: string;
|
|
175
|
+
readonly justifyItems: string;
|
|
176
|
+
readonly justifySelf: string;
|
|
177
|
+
readonly order: string;
|
|
178
|
+
readonly placeContent: string;
|
|
179
|
+
readonly placeItems: string;
|
|
180
|
+
readonly placeSelf: string;
|
|
181
|
+
readonly gridAutoColumns: string;
|
|
182
|
+
readonly gridAutoFlow: string;
|
|
183
|
+
readonly gridAutoRows: string;
|
|
184
|
+
readonly gridColumn: string;
|
|
185
|
+
readonly gridColumnEnd: string;
|
|
186
|
+
readonly gridColumnStart: string;
|
|
187
|
+
readonly gridRow: string;
|
|
188
|
+
readonly gridRowEnd: string;
|
|
189
|
+
readonly gridRowStart: string;
|
|
190
|
+
readonly gridTemplateColumns: string;
|
|
191
|
+
readonly gridTemplateRows: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/*** The four computed edges of a CSS box value. */
|
|
195
|
+
export interface WebsiteBoxEdges {
|
|
196
|
+
readonly top: string;
|
|
197
|
+
readonly right: string;
|
|
198
|
+
readonly bottom: string;
|
|
199
|
+
readonly left: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/*** How an observation was obtained from the source page. */
|
|
203
|
+
export interface WebsiteObservationProvenance {
|
|
204
|
+
readonly sourceUrl: string;
|
|
205
|
+
readonly capturedAt: string;
|
|
206
|
+
readonly method: 'browser' | 'html' | 'network';
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/*** A reusable media asset discovered during the crawl. */
|
|
210
|
+
export interface WebsiteAsset {
|
|
211
|
+
readonly id: string;
|
|
212
|
+
readonly url: string;
|
|
213
|
+
readonly kind: WebsiteMediaReference['kind'];
|
|
214
|
+
readonly contentType: string | null;
|
|
215
|
+
readonly sourceRefs: readonly string[];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/*** A versioned canonical component recognition derived from website observations. */
|
|
219
|
+
export interface WebsiteRecognitionDocument {
|
|
220
|
+
readonly schemaVersion: 1;
|
|
221
|
+
readonly documentId: string;
|
|
222
|
+
readonly observedDocumentId: string;
|
|
223
|
+
readonly recognizedAt: string;
|
|
224
|
+
readonly source: WebsiteSource;
|
|
225
|
+
readonly site: WebsiteSite;
|
|
226
|
+
readonly navigation: readonly WebsiteNavigationItem[];
|
|
227
|
+
readonly pages: readonly WebsitePageRecognition[];
|
|
228
|
+
readonly designTokens: readonly WebsiteDesignToken[];
|
|
229
|
+
readonly media: readonly WebsiteRecognizedMedia[];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/*** A recognized page with its canonical UiNode tree and retained source mapping. */
|
|
233
|
+
export interface WebsitePageRecognition {
|
|
234
|
+
readonly id: string;
|
|
235
|
+
readonly url: string;
|
|
236
|
+
readonly path: string;
|
|
237
|
+
readonly root: UiNode;
|
|
238
|
+
readonly nodes: readonly WebsiteRecognizedNode[];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/*** A source-linked canonical UiNode mapping; component shape remains owned by UiNode. */
|
|
242
|
+
export interface WebsiteRecognizedNode {
|
|
243
|
+
readonly id: UiNode['id'];
|
|
244
|
+
readonly componentType: UiNode['type'];
|
|
245
|
+
readonly sourceRefs: readonly string[];
|
|
246
|
+
readonly confidence: number;
|
|
247
|
+
readonly props: readonly WebsiteRecognizedProp[];
|
|
248
|
+
readonly responsive: readonly WebsiteResponsiveVariant[];
|
|
249
|
+
readonly status: 'recognized' | 'unresolved';
|
|
250
|
+
readonly unresolved: WebsiteUnresolvedNode | null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/*** A normalized UiNode property and the exact serializable values observed before normalization. */
|
|
254
|
+
export interface WebsiteRecognizedProp {
|
|
255
|
+
readonly name: string;
|
|
256
|
+
readonly value: SerializableValue;
|
|
257
|
+
readonly originalValues: readonly SerializableValue[];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/*** A viewport-specific UiNode property override retained by the recognition. */
|
|
261
|
+
export interface WebsiteResponsiveVariant {
|
|
262
|
+
readonly viewportId: string;
|
|
263
|
+
readonly props: readonly WebsiteRecognizedProp[];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/*** A visible source node that could not be mapped without silently discarding it. */
|
|
267
|
+
export interface WebsiteUnresolvedNode {
|
|
268
|
+
readonly reason: string;
|
|
269
|
+
readonly sourceRefs: readonly string[];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/*** A normalized design token with its exact source values retained. */
|
|
273
|
+
export interface WebsiteDesignToken {
|
|
274
|
+
readonly id: string;
|
|
275
|
+
readonly kind: 'color' | 'radius' | 'shadow' | 'spacing' | 'typography';
|
|
276
|
+
readonly value: SerializableValue;
|
|
277
|
+
readonly originalValues: readonly SerializableValue[];
|
|
278
|
+
readonly sourceRefs: readonly string[];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/*** A recognized portable media reference, optionally compatible with an app media asset. */
|
|
282
|
+
export interface WebsiteRecognizedMedia {
|
|
283
|
+
readonly id: string;
|
|
284
|
+
readonly sourceRefs: readonly string[];
|
|
285
|
+
readonly originalUrl: string;
|
|
286
|
+
readonly asset: MediaAssetReference | null;
|
|
287
|
+
}
|