keepset 0.2.0 → 0.4.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/dist/index.d.ts CHANGED
@@ -1,100 +1,9 @@
1
- import { z } from "zod";
2
- //#region src/targets/graph-v1.d.ts
3
- /** A JSON scalar: the only values graph/v1 metadata may hold, so `meta` stays a flat record any consumer can tabulate. `z.number()` already rejects NaN and the infinities, which JSON cannot carry. */
4
- export declare const JsonScalarSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
5
- type JsonScalar = z.infer<typeof JsonScalarSchema>;
6
- /** A node: an id, an optional type, and whatever else the dataset carries. The target fixes only what every graph consumer needs, so extra fields pass through untouched. */
7
- export declare const GraphNodeSchema: z.ZodObject<{
8
- id: z.ZodString;
9
- type: z.ZodOptional<z.ZodString>;
10
- }, z.core.$loose>;
11
- type GraphNode = z.infer<typeof GraphNodeSchema>;
12
- /** An edge: source and target node ids, an optional type, and whatever else the dataset carries. Direction is the dataset's own: graph/v1 records it in `meta`, never by duplicating edges. */
13
- export declare const GraphEdgeSchema: z.ZodObject<{
14
- source: z.ZodString;
15
- target: z.ZodString;
16
- type: z.ZodOptional<z.ZodString>;
17
- }, z.core.$loose>;
18
- type GraphEdge = z.infer<typeof GraphEdgeSchema>;
19
- /**
20
- * The graph/v1 normalisation target: `{ meta, nodes, edges }`, the shape the thesis pipeline's benchmark cache already uses. It describes the result `fetchDataset` resolves a graph entry to, not what a source file may contain. Beyond the field shapes it checks the two properties every consumer relies on: node ids are unique, and every edge endpoint names a node.
21
- */
22
- export declare const GraphV1Schema: z.ZodObject<{
23
- meta: z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, unknown>;
24
- nodes: z.ZodArray<z.ZodObject<{
25
- id: z.ZodString;
26
- type: z.ZodOptional<z.ZodString>;
27
- }, z.core.$loose>>;
28
- edges: z.ZodArray<z.ZodObject<{
29
- source: z.ZodString;
30
- target: z.ZodString;
31
- type: z.ZodOptional<z.ZodString>;
32
- }, z.core.$loose>>;
33
- }, z.core.$strict> & {
34
- is: (value: unknown) => value is {
35
- meta: Record<string, string | number | boolean | null>;
36
- nodes: {
37
- [x: string]: unknown;
38
- id: string;
39
- type?: string | undefined;
40
- }[];
41
- edges: {
42
- [x: string]: unknown;
43
- source: string;
44
- target: string;
45
- type?: string | undefined;
46
- }[];
47
- };
48
- };
49
- type GraphV1 = z.infer<typeof GraphV1Schema>;
50
- //#endregion
51
- //#region src/categories.d.ts
52
- /** Every category id the registry knows. A category id is `<kind>/v<version>`: the kind of data, and the version of its normalisation target, so a breaking change to a target is a new category rather than an edit to an old one. */
53
- export declare const CategoryIdSchema: z.ZodEnum<{
54
- "graph/v1": "graph/v1";
55
- }>;
56
- type CategoryId = z.infer<typeof CategoryIdSchema>;
57
- /** The normalisation target each category resolves to, keyed by category id. */
58
- interface CategoryTargets {
59
- readonly "graph/v1": GraphV1;
60
- }
61
- /** The normalised shape of any category: what `fetchDataset` can resolve to. */
62
- type CategoryTarget = CategoryTargets[CategoryId];
63
- /** One category: its id, what it holds, and the schema of its normalisation target. */
64
- interface Category<Id extends CategoryId = CategoryId> {
65
- readonly id: Id;
66
- readonly description: string;
67
- readonly target: z.ZodType<CategoryTargets[Id]>;
68
- }
69
- /**
70
- * Looks up a category by id.
71
- * @param id - Any string; category ids usually come from entry documents, so the argument is untrusted.
72
- * @returns The category.
73
- * @throws UnknownCategoryError when no category has that id.
74
- */
75
- export declare function getCategory<Id extends CategoryId>(id: Id): Category<Id>;
76
- export declare function getCategory(id: string): Category;
77
- /**
78
- * Returns the schema of a category's normalisation target.
79
- * @param id - Any string, as for `getCategory`.
80
- * @returns The target schema.
81
- * @throws UnknownCategoryError when no category has that id.
82
- */
83
- export declare function getTarget<Id extends CategoryId>(id: Id): z.ZodType<CategoryTargets[Id]>;
84
- export declare function getTarget(id: string): z.ZodType<CategoryTarget>;
85
- /**
86
- * The kind of data a category holds: the part of its id before the version.
87
- * @param id - A category id.
88
- * @returns The kind, such as `graph`.
89
- */
90
- export declare function kindOf(id: CategoryId): string;
91
- /** @returns Every registered category, in id order. */
92
- export declare function listCategories(): readonly Category[];
93
- //#endregion
1
+ import { $ as SnapshotSchema, A as SemVerSchema, B as Entry, C as Dataset, D as LineageSchema, E as Lineage, F as ArchiveSchema, G as LicenceSchema, H as HttpUrlSchema, I as Citation, J as RESERVED_META_KEYS, K as Parser, L as CitationSchema, M as Archive, N as ArchiveMember, O as Manifest, P as ArchiveMemberSchema, Q as Snapshot, R as CrosswalkReference, S as CatalogueIndexSchema, T as createCatalogue, U as IdSchema, V as EntrySchema, W as Licence, X as RecipeSchema, Y as Recipe, Z as RelativePathSchema, _ as GraphV1Schema, a as CategoryTargets, b as Catalogue, c as getCategory, d as listCategories, et as Source, f as GraphEdge, g as GraphV1, h as GraphNodeSchema, i as CategoryTarget, it as waybackUrl, j as parseManifest, k as ManifestSchema, l as getTarget, m as GraphNode, n as CategoryId, nt as WaybackTimestampSchema, o as CountedKey, p as GraphEdgeSchema, q as ParserSchema, r as CategoryIdSchema, rt as parseEntry, s as countTarget, t as Category, tt as SourceSchema, u as kindOf, v as JsonScalar, w as DatasetQuery, x as CatalogueIndex, y as JsonScalarSchema, z as CrosswalkReferenceSchema } from "./categories-CUf1VecC.js";
2
+ import { Crosswalk } from "twindex";
94
3
  //#region src/errors.d.ts
95
4
  /** The root of this package's error taxonomy: every error keepset throws is a `KeepsetError`, so callers can catch the family with one check. */
96
5
  export declare class KeepsetError extends Error {
97
- constructor(message: string);
6
+ constructor(message: string, options?: ErrorOptions);
98
7
  }
99
8
  /** Thrown when a category id names no category in the registry. Carries the ids that do exist, so the message says what would have been accepted. */
100
9
  export declare class UnknownCategoryError extends KeepsetError {
@@ -107,483 +16,57 @@ interface SyntaxIssue {
107
16
  readonly path: string;
108
17
  readonly message: string;
109
18
  }
110
- /** Thrown when an entry or a catalogue manifest fails its schema. Carries every issue found, not just the first, so one failed parse reports the whole document. */
19
+ /** Thrown when an entry, a catalogue manifest or a catalogue index fails its schema. Carries every issue found, not just the first, so one failed parse reports the whole document. */
111
20
  export declare class CatalogueSyntaxError extends KeepsetError {
112
- readonly document: "entry" | "manifest";
21
+ readonly document: "entry" | "manifest" | "catalogue";
113
22
  readonly issues: readonly SyntaxIssue[];
114
- constructor(document: "entry" | "manifest", issues: readonly SyntaxIssue[]);
23
+ constructor(document: "entry" | "manifest" | "catalogue", issues: readonly SyntaxIssue[]);
24
+ }
25
+ /** Thrown by a parser when a file does not have the format its recipe names. `line` is 1-based, counting every line of the file, so it points at the offending line in an editor. */
26
+ export declare class NativeParseError extends KeepsetError {
27
+ readonly format: string;
28
+ readonly line: number;
29
+ constructor(format: string, line: number, message: string);
30
+ }
31
+ /** Thrown when an archive does not hold exactly one member the recipe's member selector matches, or is not a well-formed archive of its stated kind. */
32
+ export declare class ArchiveError extends KeepsetError {}
33
+ /** Thrown when no entry in the catalogue has the requested id. */
34
+ export declare class DatasetNotFoundError extends KeepsetError {
35
+ readonly datasetId: string;
36
+ constructor(datasetId: string);
37
+ }
38
+ /** The step of a recipe that failed: the recipe itself (not fetchable), downloading the source, unpacking the archive, parsing the native shape, applying the crosswalk, or validating the result against the category target. */
39
+ type RecipeStep = "recipe" | "download" | "extract" | "parse" | "crosswalk" | "validate";
40
+ /** Thrown when running an entry's recipe fails. Names the entry and the failing step, and carries the underlying error as `cause`; a recipe never resolves to a partial or default-shaped result. */
41
+ export declare class RecipeError extends KeepsetError {
42
+ readonly entryId: string;
43
+ readonly step: RecipeStep;
44
+ constructor(entryId: string, step: RecipeStep, message: string, options?: ErrorOptions);
115
45
  }
116
46
  //#endregion
117
- //#region src/entry.d.ts
118
- /** A stable identifier: an entry id, a catalogue id. It starts with a letter or digit, so no id can be `__proto__` or any other name that begins with an underscore. Entry ids stay the same across forks, which is what lets two catalogues be compared entry by entry. */
119
- export declare const IdSchema: z.ZodString;
120
- /** A Wayback Machine timestamp, `YYYYMMDD` or `YYYYMMDDhhmmss`: the moment the snapshot is pinned to. */
121
- export declare const WaybackTimestampSchema: z.ZodString;
122
- /**
123
- * The Wayback Machine URL of a snapshot of `url` at `timestamp`: the page form a person follows. The raw bytes a recipe downloads come from the `id_` form, which `fetchDataset` derives from this one.
124
- * @param timestamp - A Wayback timestamp.
125
- * @param url - The original URL.
126
- * @returns The snapshot URL.
127
- */
128
- export declare function waybackUrl(timestamp: string, url: string): string;
129
- /** A pinned Wayback Machine snapshot of a source. The timestamp is part of the recipe's reproducibility, not incidental metadata, so it travels with the URL and the two are checked against each other. */
130
- export declare const SnapshotSchema: z.ZodObject<{
131
- url: z.ZodURL;
132
- timestamp: z.ZodString;
133
- }, z.core.$strict>;
134
- type Snapshot = z.infer<typeof SnapshotSchema>;
135
- /**
136
- * Where a dataset's bytes come from. A `dead` source no longer serves the bytes the recipe was written against and must carry the snapshot the recipe fetches instead; a `live` source may also carry one, as the pinned record of what it served. The snapshot URL must be exactly `waybackUrl(timestamp, url)`.
137
- */
138
- export declare const SourceSchema: z.ZodObject<{
139
- url: z.ZodURL;
140
- retrieved: z.ZodISODate;
141
- status: z.ZodEnum<{
142
- live: "live";
143
- dead: "dead";
144
- }>;
145
- snapshot: z.ZodOptional<z.ZodObject<{
146
- url: z.ZodURL;
147
- timestamp: z.ZodString;
148
- }, z.core.$strict>>;
149
- }, z.core.$strict>;
150
- type Source = z.infer<typeof SourceSchema>;
151
- /** The licence a dataset is published under: an SPDX identifier, a named licence with the URL of its terms, or a statement that the source records none. A licence the source does not state is recorded as unrecorded rather than guessed. */
152
- export declare const LicenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
153
- kind: z.ZodLiteral<"spdx">;
154
- id: z.ZodString;
155
- }, z.core.$strict>, z.ZodObject<{
156
- kind: z.ZodLiteral<"custom">;
157
- name: z.ZodString;
158
- url: z.ZodURL;
159
- }, z.core.$strict>, z.ZodObject<{
160
- kind: z.ZodLiteral<"unrecorded">;
161
- }, z.core.$strict>], "kind">;
162
- type Licence = z.infer<typeof LicenceSchema>;
163
- /** A work to cite for the dataset: a formatted reference, with its DOI or URL where the source records one. */
164
- export declare const CitationSchema: z.ZodObject<{
165
- text: z.ZodString;
166
- doi: z.ZodOptional<z.ZodString>;
167
- url: z.ZodOptional<z.ZodURL>;
168
- }, z.core.$strict>;
169
- type Citation = z.infer<typeof CitationSchema>;
170
- /** A relative path inside an archive or a catalogue: `/`-separated segments, none empty, `.` or `..`, so it can never climb out of the directory it is resolved against. */
171
- export declare const RelativePathSchema: z.ZodString;
172
- /** Which file of an archive to read: a member path, matched against a member's whole path or its trailing segments (so `net.gml` finds `net/net.gml`), or the member whose name ends with an extension. Either must match exactly one member when the recipe runs; macOS resource-fork members (`__MACOSX/` and `._` files) never match. */
173
- export declare const ArchiveMemberSchema: z.ZodUnion<readonly [z.ZodObject<{
174
- path: z.ZodString;
175
- }, z.core.$strict>, z.ZodObject<{
176
- extension: z.ZodString;
177
- }, z.core.$strict>]>;
178
- type ArchiveMember = z.infer<typeof ArchiveMemberSchema>;
179
- /** How the downloaded bytes unpack into the one file the parser reads. */
180
- export declare const ArchiveSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
181
- kind: z.ZodLiteral<"none">;
182
- }, z.core.$strict>, z.ZodObject<{
183
- kind: z.ZodLiteral<"gzip">;
184
- }, z.core.$strict>, z.ZodObject<{
185
- kind: z.ZodLiteral<"zip">;
186
- member: z.ZodUnion<readonly [z.ZodObject<{
187
- path: z.ZodString;
188
- }, z.core.$strict>, z.ZodObject<{
189
- extension: z.ZodString;
190
- }, z.core.$strict>]>;
191
- }, z.core.$strict>, z.ZodObject<{
192
- kind: z.ZodLiteral<"tar">;
193
- member: z.ZodUnion<readonly [z.ZodObject<{
194
- path: z.ZodString;
195
- }, z.core.$strict>, z.ZodObject<{
196
- extension: z.ZodString;
197
- }, z.core.$strict>]>;
198
- }, z.core.$strict>, z.ZodObject<{
199
- kind: z.ZodLiteral<"tar.gz">;
200
- member: z.ZodUnion<readonly [z.ZodObject<{
201
- path: z.ZodString;
202
- }, z.core.$strict>, z.ZodObject<{
203
- extension: z.ZodString;
204
- }, z.core.$strict>]>;
205
- }, z.core.$strict>], "kind">;
206
- type Archive = z.infer<typeof ArchiveSchema>;
207
- /** The parser that reads the unpacked file into the dataset's native JSON shape, with the options that format needs. Every option is stated in the entry, so a recipe reads the same way wherever it runs. */
208
- export declare const ParserSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
209
- format: z.ZodLiteral<"edge-list">;
210
- encoding: z.ZodEnum<{
211
- "utf-8": "utf-8";
212
- latin1: "latin1";
213
- }>;
214
- delimiter: z.ZodEnum<{
215
- whitespace: "whitespace";
216
- tab: "tab";
217
- comma: "comma";
218
- space: "space";
219
- }>;
220
- skipLines: z.ZodInt;
221
- commentPrefixes: z.ZodArray<z.ZodString>;
222
- sourceColumn: z.ZodInt;
223
- targetColumn: z.ZodInt;
224
- }, z.core.$strict>, z.ZodObject<{
225
- format: z.ZodLiteral<"matrix-market">;
226
- encoding: z.ZodEnum<{
227
- "utf-8": "utf-8";
228
- latin1: "latin1";
229
- }>;
230
- }, z.core.$strict>, z.ZodObject<{
231
- format: z.ZodLiteral<"gml">;
232
- encoding: z.ZodEnum<{
233
- "utf-8": "utf-8";
234
- latin1: "latin1";
235
- }>;
236
- }, z.core.$strict>, z.ZodObject<{
237
- format: z.ZodLiteral<"pajek">;
238
- encoding: z.ZodEnum<{
239
- "utf-8": "utf-8";
240
- latin1: "latin1";
241
- }>;
242
- }, z.core.$strict>], "format">;
243
- type Parser = z.infer<typeof ParserSchema>;
244
- /** How to obtain the dataset: a fetchable recipe naming the source (by index into `sources`), the archive layout and the parser, or a statement that no declarative recipe exists yet and why. */
245
- export declare const RecipeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
246
- status: z.ZodLiteral<"fetchable">;
247
- source: z.ZodInt;
248
- archive: z.ZodDiscriminatedUnion<[z.ZodObject<{
249
- kind: z.ZodLiteral<"none">;
250
- }, z.core.$strict>, z.ZodObject<{
251
- kind: z.ZodLiteral<"gzip">;
252
- }, z.core.$strict>, z.ZodObject<{
253
- kind: z.ZodLiteral<"zip">;
254
- member: z.ZodUnion<readonly [z.ZodObject<{
255
- path: z.ZodString;
256
- }, z.core.$strict>, z.ZodObject<{
257
- extension: z.ZodString;
258
- }, z.core.$strict>]>;
259
- }, z.core.$strict>, z.ZodObject<{
260
- kind: z.ZodLiteral<"tar">;
261
- member: z.ZodUnion<readonly [z.ZodObject<{
262
- path: z.ZodString;
263
- }, z.core.$strict>, z.ZodObject<{
264
- extension: z.ZodString;
265
- }, z.core.$strict>]>;
266
- }, z.core.$strict>, z.ZodObject<{
267
- kind: z.ZodLiteral<"tar.gz">;
268
- member: z.ZodUnion<readonly [z.ZodObject<{
269
- path: z.ZodString;
270
- }, z.core.$strict>, z.ZodObject<{
271
- extension: z.ZodString;
272
- }, z.core.$strict>]>;
273
- }, z.core.$strict>], "kind">;
274
- parser: z.ZodDiscriminatedUnion<[z.ZodObject<{
275
- format: z.ZodLiteral<"edge-list">;
276
- encoding: z.ZodEnum<{
277
- "utf-8": "utf-8";
278
- latin1: "latin1";
279
- }>;
280
- delimiter: z.ZodEnum<{
281
- whitespace: "whitespace";
282
- tab: "tab";
283
- comma: "comma";
284
- space: "space";
285
- }>;
286
- skipLines: z.ZodInt;
287
- commentPrefixes: z.ZodArray<z.ZodString>;
288
- sourceColumn: z.ZodInt;
289
- targetColumn: z.ZodInt;
290
- }, z.core.$strict>, z.ZodObject<{
291
- format: z.ZodLiteral<"matrix-market">;
292
- encoding: z.ZodEnum<{
293
- "utf-8": "utf-8";
294
- latin1: "latin1";
295
- }>;
296
- }, z.core.$strict>, z.ZodObject<{
297
- format: z.ZodLiteral<"gml">;
298
- encoding: z.ZodEnum<{
299
- "utf-8": "utf-8";
300
- latin1: "latin1";
301
- }>;
302
- }, z.core.$strict>, z.ZodObject<{
303
- format: z.ZodLiteral<"pajek">;
304
- encoding: z.ZodEnum<{
305
- "utf-8": "utf-8";
306
- latin1: "latin1";
307
- }>;
308
- }, z.core.$strict>], "format">;
309
- }, z.core.$strict>, z.ZodObject<{
310
- status: z.ZodLiteral<"not-fetchable">;
311
- reason: z.ZodString;
312
- }, z.core.$strict>], "status">;
313
- type Recipe = z.infer<typeof RecipeSchema>;
314
- /** The twindex crosswalk from the native shape to the category target: the document inline, or a `.json` file path relative to the catalogue root, so entries that share a native shape share one crosswalk. */
315
- export declare const CrosswalkReferenceSchema: z.ZodUnion<readonly [z.ZodType<import("twindex").Crosswalk, unknown, z.core.$ZodTypeInternals<import("twindex").Crosswalk, unknown>> & {
316
- is: (value: unknown) => value is import("twindex").Crosswalk;
317
- }, z.ZodObject<{
318
- file: z.ZodString;
319
- }, z.core.$strict>]>;
320
- type CrosswalkReference = z.infer<typeof CrosswalkReferenceSchema>;
321
- /**
322
- * One catalogue entry: the descriptor (id, name, description, domain, tags), the category whose target the entry resolves to, where the bytes come from, the licence and citations, the recipe, the crosswalk, the counts a fetched result is expected to have and the dataset's recorded properties. The kind of data is the category's (`kindOf(category)`), never a second field that could disagree with it.
323
- */
324
- export declare const EntrySchema: z.ZodObject<{
325
- id: z.ZodString;
326
- name: z.ZodString;
327
- description: z.ZodOptional<z.ZodString>;
328
- domain: z.ZodOptional<z.ZodString>;
329
- tags: z.ZodArray<z.ZodString>;
330
- category: z.ZodEnum<{
331
- "graph/v1": "graph/v1";
332
- }>;
333
- sources: z.ZodArray<z.ZodObject<{
334
- url: z.ZodURL;
335
- retrieved: z.ZodISODate;
336
- status: z.ZodEnum<{
337
- live: "live";
338
- dead: "dead";
339
- }>;
340
- snapshot: z.ZodOptional<z.ZodObject<{
341
- url: z.ZodURL;
342
- timestamp: z.ZodString;
343
- }, z.core.$strict>>;
344
- }, z.core.$strict>>;
345
- licence: z.ZodDiscriminatedUnion<[z.ZodObject<{
346
- kind: z.ZodLiteral<"spdx">;
347
- id: z.ZodString;
348
- }, z.core.$strict>, z.ZodObject<{
349
- kind: z.ZodLiteral<"custom">;
350
- name: z.ZodString;
351
- url: z.ZodURL;
352
- }, z.core.$strict>, z.ZodObject<{
353
- kind: z.ZodLiteral<"unrecorded">;
354
- }, z.core.$strict>], "kind">;
355
- citations: z.ZodArray<z.ZodObject<{
356
- text: z.ZodString;
357
- doi: z.ZodOptional<z.ZodString>;
358
- url: z.ZodOptional<z.ZodURL>;
359
- }, z.core.$strict>>;
360
- recipe: z.ZodDiscriminatedUnion<[z.ZodObject<{
361
- status: z.ZodLiteral<"fetchable">;
362
- source: z.ZodInt;
363
- archive: z.ZodDiscriminatedUnion<[z.ZodObject<{
364
- kind: z.ZodLiteral<"none">;
365
- }, z.core.$strict>, z.ZodObject<{
366
- kind: z.ZodLiteral<"gzip">;
367
- }, z.core.$strict>, z.ZodObject<{
368
- kind: z.ZodLiteral<"zip">;
369
- member: z.ZodUnion<readonly [z.ZodObject<{
370
- path: z.ZodString;
371
- }, z.core.$strict>, z.ZodObject<{
372
- extension: z.ZodString;
373
- }, z.core.$strict>]>;
374
- }, z.core.$strict>, z.ZodObject<{
375
- kind: z.ZodLiteral<"tar">;
376
- member: z.ZodUnion<readonly [z.ZodObject<{
377
- path: z.ZodString;
378
- }, z.core.$strict>, z.ZodObject<{
379
- extension: z.ZodString;
380
- }, z.core.$strict>]>;
381
- }, z.core.$strict>, z.ZodObject<{
382
- kind: z.ZodLiteral<"tar.gz">;
383
- member: z.ZodUnion<readonly [z.ZodObject<{
384
- path: z.ZodString;
385
- }, z.core.$strict>, z.ZodObject<{
386
- extension: z.ZodString;
387
- }, z.core.$strict>]>;
388
- }, z.core.$strict>], "kind">;
389
- parser: z.ZodDiscriminatedUnion<[z.ZodObject<{
390
- format: z.ZodLiteral<"edge-list">;
391
- encoding: z.ZodEnum<{
392
- "utf-8": "utf-8";
393
- latin1: "latin1";
394
- }>;
395
- delimiter: z.ZodEnum<{
396
- whitespace: "whitespace";
397
- tab: "tab";
398
- comma: "comma";
399
- space: "space";
400
- }>;
401
- skipLines: z.ZodInt;
402
- commentPrefixes: z.ZodArray<z.ZodString>;
403
- sourceColumn: z.ZodInt;
404
- targetColumn: z.ZodInt;
405
- }, z.core.$strict>, z.ZodObject<{
406
- format: z.ZodLiteral<"matrix-market">;
407
- encoding: z.ZodEnum<{
408
- "utf-8": "utf-8";
409
- latin1: "latin1";
410
- }>;
411
- }, z.core.$strict>, z.ZodObject<{
412
- format: z.ZodLiteral<"gml">;
413
- encoding: z.ZodEnum<{
414
- "utf-8": "utf-8";
415
- latin1: "latin1";
416
- }>;
417
- }, z.core.$strict>, z.ZodObject<{
418
- format: z.ZodLiteral<"pajek">;
419
- encoding: z.ZodEnum<{
420
- "utf-8": "utf-8";
421
- latin1: "latin1";
422
- }>;
423
- }, z.core.$strict>], "format">;
424
- }, z.core.$strict>, z.ZodObject<{
425
- status: z.ZodLiteral<"not-fetchable">;
426
- reason: z.ZodString;
427
- }, z.core.$strict>], "status">;
428
- crosswalk: z.ZodUnion<readonly [z.ZodType<import("twindex").Crosswalk, unknown, z.core.$ZodTypeInternals<import("twindex").Crosswalk, unknown>> & {
429
- is: (value: unknown) => value is import("twindex").Crosswalk;
430
- }, z.ZodObject<{
431
- file: z.ZodString;
432
- }, z.core.$strict>]>;
433
- expectedCounts: z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodInt>, unknown>;
434
- properties: z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, unknown>;
435
- }, z.core.$strict> & {
436
- is: (value: unknown) => value is {
437
- id: string;
438
- name: string;
439
- tags: string[];
440
- category: "graph/v1";
441
- sources: {
442
- url: string;
443
- retrieved: string;
444
- status: "live" | "dead";
445
- snapshot?: {
446
- url: string;
447
- timestamp: string;
448
- } | undefined;
449
- }[];
450
- licence: {
451
- kind: "spdx";
452
- id: string;
453
- } | {
454
- kind: "custom";
455
- name: string;
456
- url: string;
457
- } | {
458
- kind: "unrecorded";
459
- };
460
- citations: {
461
- text: string;
462
- doi?: string | undefined;
463
- url?: string | undefined;
464
- }[];
465
- recipe: {
466
- status: "fetchable";
467
- source: number;
468
- archive: {
469
- kind: "none";
470
- } | {
471
- kind: "gzip";
472
- } | {
473
- kind: "zip";
474
- member: {
475
- path: string;
476
- } | {
477
- extension: string;
478
- };
479
- } | {
480
- kind: "tar";
481
- member: {
482
- path: string;
483
- } | {
484
- extension: string;
485
- };
486
- } | {
487
- kind: "tar.gz";
488
- member: {
489
- path: string;
490
- } | {
491
- extension: string;
492
- };
493
- };
494
- parser: {
495
- format: "edge-list";
496
- encoding: "utf-8" | "latin1";
497
- delimiter: "whitespace" | "tab" | "comma" | "space";
498
- skipLines: number;
499
- commentPrefixes: string[];
500
- sourceColumn: number;
501
- targetColumn: number;
502
- } | {
503
- format: "matrix-market";
504
- encoding: "utf-8" | "latin1";
505
- } | {
506
- format: "gml";
507
- encoding: "utf-8" | "latin1";
508
- } | {
509
- format: "pajek";
510
- encoding: "utf-8" | "latin1";
511
- };
512
- } | {
513
- status: "not-fetchable";
514
- reason: string;
515
- };
516
- crosswalk: import("twindex").Crosswalk | {
517
- file: string;
518
- };
519
- expectedCounts: Record<string, number>;
520
- properties: Record<string, string | number | boolean | null>;
521
- description?: string | undefined;
522
- domain?: string | undefined;
523
- };
524
- };
525
- type Entry = z.infer<typeof EntrySchema>;
526
- /**
527
- * Parses an unknown value as a catalogue entry.
528
- * @param doc - The candidate entry document.
529
- * @returns The validated entry.
530
- * @throws CatalogueSyntaxError carrying every issue found.
531
- */
532
- export declare function parseEntry(doc: unknown): Entry;
533
- //#endregion
534
- //#region src/manifest.d.ts
535
- /** A semantic version, `MAJOR.MINOR.PATCH` with optional pre-release and build parts (https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string). */
536
- export declare const SemVerSchema: z.ZodString;
537
- /** Where a forked catalogue came from: the catalogue it was forked from, the version it forked at and the repository that holds it, which together are what lets a fork's entries be compared with, and brought back to, their origin. */
538
- export declare const LineageSchema: z.ZodObject<{
539
- catalogue: z.ZodString;
540
- version: z.ZodString;
541
- repository: z.ZodURL;
542
- }, z.core.$strict>;
543
- type Lineage = z.infer<typeof LineageSchema>;
47
+ //#region src/bundled.d.ts
544
48
  /**
545
- * A catalogue manifest: the catalogue's own id and version, where it lives, and, for a fork, its lineage. A catalogue is a self-contained set of entry documents beside its manifest, and a fork is its own catalogue with its own id, so lineage may never name the catalogue itself.
49
+ * Lists the datasets in the bundled catalogue that match a query. Browser-safe: a pure read over the index bundled with the package.
50
+ * @param query - The filters; all must match, and none given lists everything.
51
+ * @returns The matching datasets, in entry id order.
546
52
  */
547
- export declare const ManifestSchema: z.ZodObject<{
548
- id: z.ZodString;
549
- name: z.ZodString;
550
- description: z.ZodString;
551
- version: z.ZodString;
552
- repository: z.ZodURL;
553
- lineage: z.ZodOptional<z.ZodObject<{
554
- catalogue: z.ZodString;
555
- version: z.ZodString;
556
- repository: z.ZodURL;
557
- }, z.core.$strict>>;
558
- }, z.core.$strict> & {
559
- is: (value: unknown) => value is {
560
- id: string;
561
- name: string;
562
- description: string;
563
- version: string;
564
- repository: string;
565
- lineage?: {
566
- catalogue: string;
567
- version: string;
568
- repository: string;
569
- } | undefined;
570
- };
571
- };
572
- type Manifest = z.infer<typeof ManifestSchema>;
53
+ export declare function listDatasets(query?: DatasetQuery): Dataset[];
573
54
  /**
574
- * Parses an unknown value as a catalogue manifest.
575
- * @param doc - The candidate manifest document.
576
- * @returns The validated manifest.
577
- * @throws CatalogueSyntaxError carrying every issue found.
55
+ * Returns one dataset of the bundled catalogue: its entry (metadata and recipe) and its resolved crosswalk. Browser-safe.
56
+ * @param id - The entry id.
57
+ * @returns The dataset.
58
+ * @throws DatasetNotFoundError when no entry has that id.
578
59
  */
579
- export declare function parseManifest(doc: unknown): Manifest;
60
+ export declare function getDataset(id: string): Dataset;
61
+ /** @returns The bundled catalogue's manifest: its id, version and repository. */
62
+ export declare function getManifest(): Manifest;
580
63
  //#endregion
581
64
  //#region src/serialise.d.ts
582
65
  /**
583
- * Serialises a catalogue document as its file holds it: two-space indented JSON in the schema's key order with a trailing newline. A parsed document keeps the schema's key order, so parsing a file written this way and serialising the result reproduces the file byte for byte.
584
- * @param doc - A parsed entry or manifest.
66
+ * Serialises a catalogue document (an entry, a manifest or a crosswalk file) as its file holds it: two-space indented JSON with keys in ascending order and a trailing newline. The form depends only on the document's content, so parsing a file written this way and serialising the result reproduces the file byte for byte.
67
+ * @param doc - A parsed entry, manifest or crosswalk.
585
68
  * @returns The file text.
586
69
  */
587
- export declare function serialise(doc: Entry | Manifest): string;
70
+ export declare function serialise(doc: Entry | Manifest | Crosswalk): string;
588
71
  //#endregion
589
- export type { Archive, ArchiveMember, Category, CategoryId, CategoryTarget, CategoryTargets, Citation, CrosswalkReference, Entry, GraphEdge, GraphNode, GraphV1, JsonScalar, Licence, Lineage, Manifest, Parser, Recipe, Snapshot, Source, SyntaxIssue };
72
+ export { type Archive, type ArchiveMember, ArchiveMemberSchema, ArchiveSchema, type Catalogue, type CatalogueIndex, CatalogueIndexSchema, type Category, type CategoryId, CategoryIdSchema, type CategoryTarget, type CategoryTargets, type Citation, CitationSchema, type CountedKey, type CrosswalkReference, CrosswalkReferenceSchema, type Dataset, type DatasetQuery, type Entry, EntrySchema, type GraphEdge, GraphEdgeSchema, type GraphNode, GraphNodeSchema, type GraphV1, GraphV1Schema, HttpUrlSchema, IdSchema, type JsonScalar, JsonScalarSchema, type Licence, LicenceSchema, type Lineage, LineageSchema, type Manifest, ManifestSchema, type Parser, ParserSchema, RESERVED_META_KEYS, type Recipe, RecipeSchema, type RecipeStep, RelativePathSchema, SemVerSchema, type Snapshot, SnapshotSchema, type Source, SourceSchema, type SyntaxIssue, WaybackTimestampSchema, countTarget, createCatalogue, getCategory, getTarget, kindOf, listCategories, parseEntry, parseManifest, waybackUrl };