keepset 0.39.0 → 0.41.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/{bundled-6dYCPVD-.js → bundled-B1094k0B.js} +12215 -7937
- package/dist/{categories-DijttH_M.d.ts → categories-BbW0rFCf.d.ts} +2857 -286
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/node/fetch-dataset.d.ts +75 -24
- package/dist/node/fetch-dataset.js +1368 -298
- package/dist-cli/keepset.mjs +80 -9
- package/package.json +1 -1
- package/schemas/entry.schema.json +1 -1
- package/schemas/manifest.schema.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ArchiveSchema, A as GraphEdge, At as SourceRecipeSchema, B as DatasetQuery, C as TasksV1, Ct as Recipe, D as collectionOf, Dt as SnapshotSchema, E as Instance, Et as Snapshot, F as GraphV1Schema, Ft as readsCollection, G as Manifest, H as createCatalogue, I as Catalogue, It as waybackUrl, J as parseManifest, K as ManifestSchema, L as CatalogueIndex, M as GraphNode, Mt as SubjectSchema, N as GraphNodeSchema, Nt as WaybackTimestampSchema, O as JsonScalar, Ot as Source, P as GraphV1, Pt as parseEntry, Q as ArchiveMemberSchema, R as CatalogueIndexSchema, S as TasksMetaSchema, St as RESERVED_META_KEYS, T as Collection, Tt as RelativePathSchema, U as Lineage, V as NamespaceNode, W as LineageSchema, X as Archive, Y as AliasSchema, Z as ArchiveMember, _ as isStreamable, _t as LicenceSchema, a as CategoryTargets, at as CollectionFileSchema, b as Task, bt as Parser, c as StreamableId, ct as CrosswalkReferenceSchema, d as countTarget, dt as EntrySchema, et as Citation, f as countedKeys, ft as FilesRecipe, g as getTarget, gt as Licence, h as getStreamedShape, ht as IdSchema, i as CategoryTarget, it as CollectionFile, j as GraphEdgeSchema, jt as SourceSchema, k as JsonScalarSchema, kt as SourceRecipe, l as StreamedNodes, lt as DocumentArchive, m as getCollectionTarget, mt as HttpUrlSchema, n as CategoryId, nt as CollectionArchive, o as CollectionTarget, ot as ColumnNameSchema, p as getCategory, pt as FilesRecipeSchema, q as SemVerSchema, r as CategoryIdSchema, rt as CollectionArchiveSchema, s as CountedKey, st as CrosswalkReference, t as Category, tt as CitationSchema, u as StreamedShape, ut as Entry, v as kindOf, vt as Namespace, w as TasksV1Schema, wt as RecipeSchema, x as TaskSchema, xt as ParserSchema, y as listCategories, yt as NamespaceSchema, z as Dataset } from "./categories-BbW0rFCf.js";
|
|
2
2
|
import { Crosswalk } from "crossmap";
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
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. */
|
|
@@ -117,4 +117,4 @@ export declare function serialise(doc: Entry | Manifest | Crosswalk): string;
|
|
|
117
117
|
*/
|
|
118
118
|
export declare function validateDataset(dataset: Dataset): SyntaxIssue[];
|
|
119
119
|
//#endregion
|
|
120
|
-
export { AliasSchema, type Archive, type ArchiveMember, ArchiveMemberSchema, ArchiveSchema, type Catalogue, type CatalogueIndex, CatalogueIndexSchema, type Category, type CategoryId, CategoryIdSchema, type CategoryTarget, type CategoryTargets, type Citation, CitationSchema, type Collection, type CollectionArchive, CollectionArchiveSchema, type CollectionTarget, ColumnNameSchema, type CountedKey, type CrosswalkReference, CrosswalkReferenceSchema, type Dataset, type DatasetQuery, type DocumentArchive, type Entry, type EntryNames, EntrySchema, type GraphEdge, GraphEdgeSchema, type GraphNode, GraphNodeSchema, type GraphV1, GraphV1Schema, HttpUrlSchema, IdSchema, type Instance, type JsonScalar, JsonScalarSchema, type Licence, LicenceSchema, type Lineage, LineageSchema, type Manifest, ManifestSchema, type Namespace, type NamespaceNode, NamespaceSchema, type Parser, ParserSchema,
|
|
120
|
+
export { AliasSchema, type Archive, type ArchiveMember, ArchiveMemberSchema, ArchiveSchema, type Catalogue, type CatalogueIndex, CatalogueIndexSchema, type Category, type CategoryId, CategoryIdSchema, type CategoryTarget, type CategoryTargets, type Citation, CitationSchema, type Collection, type CollectionArchive, CollectionArchiveSchema, type CollectionFile, CollectionFileSchema, type CollectionTarget, ColumnNameSchema, type CountedKey, type CrosswalkReference, CrosswalkReferenceSchema, type Dataset, type DatasetQuery, type DocumentArchive, type Entry, type EntryNames, EntrySchema, type FilesRecipe, FilesRecipeSchema, type GraphEdge, GraphEdgeSchema, type GraphNode, GraphNodeSchema, type GraphV1, GraphV1Schema, HttpUrlSchema, IdSchema, type Instance, type JsonScalar, JsonScalarSchema, type Licence, LicenceSchema, type Lineage, LineageSchema, type Manifest, ManifestSchema, type Namespace, type NamespaceNode, NamespaceSchema, type Parser, ParserSchema, RESERVED_META_KEYS, type Recipe, RecipeSchema, type RecipeStep, RelativePathSchema, type SegmentAliases, SemVerSchema, type Snapshot, SnapshotSchema, type Source, type SourceRecipe, SourceRecipeSchema, SourceSchema, type StreamableId, type StreamedNodes, type StreamedShape, SubjectSchema, type SyntaxIssue, type Task, TaskSchema, TasksMetaSchema, type TasksV1, TasksV1Schema, WaybackTimestampSchema, collectionOf, countTarget, countedKeys, createCatalogue, getCategory, getCollectionTarget, getStreamedShape, getTarget, isStreamable, kindOf, listCategories, parseEntry, parseManifest, readsCollection, waybackUrl };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TaskSchema, A as SourceRecipeSchema, B as groupsOf, C as LicenceSchema, D as RecipeSchema, E as RESERVED_META_KEYS, G as countedKeys, I as readsCollection, J as getStreamedShape, K as getCategory, L as toIssues, M as SubjectSchema, N as WaybackTimestampSchema, O as RelativePathSchema, P as parseEntry, Q as listCategories, R as waybackUrl, S as IdSchema, T as ParserSchema, U as CategoryIdSchema, V as namesOf, W as countTarget, X as isStreamable, Y as getTarget, Z as kindOf, _ as ColumnNameSchema, a as CatalogueIndexSchema, at as GraphV1Schema, b as FilesRecipeSchema, c as ManifestSchema, ct as CatalogueSyntaxError, d as AliasSchema, dt as KeepsetError, et as TasksMetaSchema, f as ArchiveMemberSchema, ft as NativeParseError, g as CollectionFileSchema, h as CollectionArchiveSchema, i as listNamespaces, it as GraphNodeSchema, j as SourceSchema, k as SnapshotSchema, l as SemVerSchema, lt as DatasetAmbiguousError, m as CitationSchema, mt as UnknownCategoryError, n as getManifest, nt as collectionOf, o as createCatalogue, ot as JsonScalarSchema, p as ArchiveSchema, pt as RecipeError, q as getCollectionTarget, r as listDatasets, rt as GraphEdgeSchema, s as LineageSchema, st as ArchiveError, t as getDataset, tt as TasksV1Schema, u as parseManifest, ut as DatasetNotFoundError, v as CrosswalkReferenceSchema, w as NamespaceSchema, x as HttpUrlSchema, y as EntrySchema, z as NAME_SEPARATOR } from "./bundled-B1094k0B.js";
|
|
2
2
|
import { validateCrosswalk } from "crossmap";
|
|
3
3
|
//#region src/serialise.ts
|
|
4
4
|
/**
|
|
@@ -57,4 +57,4 @@ function validateDataset(dataset) {
|
|
|
57
57
|
return issues;
|
|
58
58
|
}
|
|
59
59
|
//#endregion
|
|
60
|
-
export { AliasSchema, ArchiveError, ArchiveMemberSchema, ArchiveSchema, CatalogueIndexSchema, CatalogueSyntaxError, CategoryIdSchema, CitationSchema, CollectionArchiveSchema, ColumnNameSchema, CrosswalkReferenceSchema, DatasetAmbiguousError, DatasetNotFoundError, EntrySchema, GraphEdgeSchema, GraphNodeSchema, GraphV1Schema, HttpUrlSchema, IdSchema, JsonScalarSchema, KeepsetError, LicenceSchema, LineageSchema, ManifestSchema, NAME_SEPARATOR, NamespaceSchema, NativeParseError, ParserSchema, RESERVED_META_KEYS, RecipeError, RecipeSchema, RelativePathSchema, SemVerSchema, SnapshotSchema, SourceSchema, SubjectSchema, TaskSchema, TasksV1Schema, UnknownCategoryError, WaybackTimestampSchema, collectionOf, countTarget, countedKeys, createCatalogue, getCategory, getCollectionTarget, getDataset, getManifest, getTarget, groupsOf, kindOf, listCategories, listDatasets, listNamespaces, namesOf, parseEntry, parseManifest, serialise, validateDataset, waybackUrl };
|
|
60
|
+
export { AliasSchema, ArchiveError, ArchiveMemberSchema, ArchiveSchema, CatalogueIndexSchema, CatalogueSyntaxError, CategoryIdSchema, CitationSchema, CollectionArchiveSchema, CollectionFileSchema, ColumnNameSchema, CrosswalkReferenceSchema, DatasetAmbiguousError, DatasetNotFoundError, EntrySchema, FilesRecipeSchema, GraphEdgeSchema, GraphNodeSchema, GraphV1Schema, HttpUrlSchema, IdSchema, JsonScalarSchema, KeepsetError, LicenceSchema, LineageSchema, ManifestSchema, NAME_SEPARATOR, NamespaceSchema, NativeParseError, ParserSchema, RESERVED_META_KEYS, RecipeError, RecipeSchema, RelativePathSchema, SemVerSchema, SnapshotSchema, SourceRecipeSchema, SourceSchema, SubjectSchema, TaskSchema, TasksMetaSchema, TasksV1Schema, UnknownCategoryError, WaybackTimestampSchema, collectionOf, countTarget, countedKeys, createCatalogue, getCategory, getCollectionTarget, getDataset, getManifest, getStreamedShape, getTarget, groupsOf, isStreamable, kindOf, listCategories, listDatasets, listNamespaces, namesOf, parseEntry, parseManifest, readsCollection, serialise, validateDataset, waybackUrl };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Et as Snapshot, O as JsonScalar, Ot as Source, c as StreamableId, i as CategoryTarget, l as StreamedNodes, o as CollectionTarget, ut as Entry, z as Dataset } from "../categories-BbW0rFCf.js";
|
|
2
2
|
//#region src/node/fetch-dataset.d.ts
|
|
3
3
|
/** The network port a recipe downloads through: `downloadRaw` by default, which returns the bytes exactly as served, or a stand-in under test. */
|
|
4
4
|
export type FetchPort = (url: string, init: {
|
|
@@ -10,30 +10,65 @@ export interface FetchOptions {
|
|
|
10
10
|
readonly signal?: AbortSignal;
|
|
11
11
|
readonly now?: () => Date;
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
export interface
|
|
15
|
-
readonly entryId: string;
|
|
16
|
-
readonly catalogue: Dataset["catalogue"];
|
|
17
|
-
readonly category: Entry["category"];
|
|
13
|
+
/** One download a result's bytes came from: the entry's source, the URL actually requested (the snapshot's for a dead source) and exactly which bytes arrived. */
|
|
14
|
+
export interface Download {
|
|
18
15
|
readonly source: {
|
|
19
16
|
readonly url: string;
|
|
20
17
|
readonly status: Source["status"];
|
|
21
18
|
readonly snapshot?: Snapshot;
|
|
22
19
|
};
|
|
23
20
|
readonly fetchedUrl: string;
|
|
24
|
-
readonly retrievedAt: string;
|
|
25
21
|
readonly sha256: string;
|
|
26
22
|
readonly byteLength: number;
|
|
23
|
+
}
|
|
24
|
+
/** What every provenance record says: which entry and catalogue produced the result, its category, and when it was fetched. */
|
|
25
|
+
interface ProvenanceOf {
|
|
26
|
+
readonly entryId: string;
|
|
27
|
+
readonly catalogue: Dataset["catalogue"];
|
|
28
|
+
readonly category: Entry["category"];
|
|
29
|
+
readonly retrievedAt: string;
|
|
30
|
+
}
|
|
31
|
+
/** The provenance of a result read from one download: the download, and the archive member or members it was read from. */
|
|
32
|
+
export interface DownloadProvenance extends ProvenanceOf, Download {
|
|
27
33
|
/** The archive member a document was read from. */
|
|
28
34
|
readonly member?: string;
|
|
29
35
|
/** The archive members a collection, or a document read from several files, was read from, in the order they were read. */
|
|
30
36
|
readonly members?: readonly string[];
|
|
31
37
|
}
|
|
32
|
-
/**
|
|
33
|
-
export interface
|
|
34
|
-
readonly
|
|
35
|
-
readonly
|
|
38
|
+
/** One file of a collection read file by file: its download, the file's path in the collection, and the instances it gave (the path itself, or the path joined to each archive member it unpacked into). */
|
|
39
|
+
export interface FileDownload extends Download {
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly instances: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
/** The provenance of a collection read from files downloaded one by one: each file's download, in the order they were read. */
|
|
44
|
+
export interface FilesProvenance extends ProvenanceOf {
|
|
45
|
+
readonly files: readonly FileDownload[];
|
|
46
|
+
}
|
|
47
|
+
/** Where a fetched result's bytes came from: enough to say which entry, catalogue and source produced it, which URL was actually requested, when, and exactly which bytes arrived, for the one download a recipe reads or for each file of a collection read file by file (told apart by `files`). */
|
|
48
|
+
export type Provenance = DownloadProvenance | FilesProvenance;
|
|
49
|
+
/** Whether decoding a dataset's encoded native document gives the native document back, with the provenance of the bytes it was checked on. */
|
|
50
|
+
export type RoundTripReport = {
|
|
51
|
+
readonly holds: true;
|
|
36
52
|
readonly provenance: Provenance;
|
|
53
|
+
} | {
|
|
54
|
+
readonly holds: false;
|
|
55
|
+
readonly path: string;
|
|
56
|
+
readonly message: string;
|
|
57
|
+
readonly provenance: Provenance;
|
|
58
|
+
};
|
|
59
|
+
/** A node a streamed result hands on: a node of a streamable category's target. */
|
|
60
|
+
export type StreamedNode = StreamedNodes[StreamableId];
|
|
61
|
+
/** Where a streamed result goes: the meta once, before any node, then the nodes a page at a time, each already checked against the category's node shape and for an id no earlier node had. A sink that returns a promise is awaited before the next page is read, so a slow sink holds the stream back rather than letting pages pile up. */
|
|
62
|
+
export interface NodeSink {
|
|
63
|
+
readonly meta: (meta: Readonly<Record<string, JsonScalar>>) => void | Promise<void>;
|
|
64
|
+
readonly nodes: (nodes: readonly StreamedNode[]) => void | Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
/** What a streamed fetch ends with, once every node has been handed on: the meta, the provenance of the bytes, how many nodes there were, and any warnings, such as a count that differs from the one the entry records. */
|
|
67
|
+
export interface StreamedDataset {
|
|
68
|
+
readonly dataset: Dataset;
|
|
69
|
+
readonly meta: Readonly<Record<string, JsonScalar>>;
|
|
70
|
+
readonly provenance: DownloadProvenance;
|
|
71
|
+
readonly counts: ReadonlyMap<string, number>;
|
|
37
72
|
readonly warnings: readonly string[];
|
|
38
73
|
}
|
|
39
74
|
/**
|
|
@@ -42,12 +77,19 @@ export interface FetchedDataset {
|
|
|
42
77
|
* @returns The URL to request.
|
|
43
78
|
*/
|
|
44
79
|
export declare function downloadUrl(source: Source): string;
|
|
80
|
+
/** A fetched dataset: the resolved category target (one document, or for a recipe that selects archive members a collection of them), the provenance of the bytes it came from, and any warnings, such as a count that differs from the one the entry records. */
|
|
81
|
+
export interface FetchedDataset {
|
|
82
|
+
readonly dataset: Dataset;
|
|
83
|
+
readonly data: CategoryTarget | CollectionTarget;
|
|
84
|
+
readonly provenance: Provenance;
|
|
85
|
+
readonly warnings: readonly string[];
|
|
86
|
+
}
|
|
45
87
|
/**
|
|
46
88
|
* Runs a dataset's recipe: downloads the source (from its pinned snapshot when the source is dead), unpacks the archive, parses the native shape, applies the crossmap crosswalk and validates the result against the category target. The native document the crosswalk receives is the parser's output with `meta` built from the entry.
|
|
47
89
|
* @param dataset - A dataset from any catalogue.
|
|
48
90
|
* @param options - The network port, abort signal and clock.
|
|
49
91
|
* @returns The resolved target with its provenance and any count warnings.
|
|
50
|
-
* @throws RecipeError naming the entry and the failing step; nothing partial or default-shaped is ever returned.
|
|
92
|
+
* @throws RecipeError naming the entry and the failing step, including for a recipe that streams, which `streamEntry` reads; nothing partial or default-shaped is ever returned.
|
|
51
93
|
*/
|
|
52
94
|
export declare function fetchEntry(dataset: Dataset, options?: FetchOptions): Promise<FetchedDataset>;
|
|
53
95
|
/**
|
|
@@ -58,24 +100,32 @@ export declare function fetchEntry(dataset: Dataset, options?: FetchOptions): Pr
|
|
|
58
100
|
* @throws DatasetNotFoundError when no entry has that id, and RecipeError naming the entry and the failing step when the recipe fails.
|
|
59
101
|
*/
|
|
60
102
|
export declare function fetchDataset(id: string, options?: FetchOptions): Promise<FetchedDataset>;
|
|
61
|
-
/** Whether decoding a dataset's encoded native document gives the native document back, with the provenance of the bytes it was checked on. */
|
|
62
|
-
export type RoundTripReport = {
|
|
63
|
-
readonly holds: true;
|
|
64
|
-
readonly provenance: Provenance;
|
|
65
|
-
} | {
|
|
66
|
-
readonly holds: false;
|
|
67
|
-
readonly path: string;
|
|
68
|
-
readonly message: string;
|
|
69
|
-
readonly provenance: Provenance;
|
|
70
|
-
};
|
|
71
103
|
/**
|
|
72
|
-
* Checks a dataset's crosswalk on its real data: runs the recipe to the native document, then crossmap's `assertRoundTrip`, which encodes it, decodes the result and compares the two over every path the crosswalk promises to preserve.
|
|
104
|
+
* Checks a dataset's crosswalk on its real data: runs the recipe to the native document, then crossmap's `assertRoundTrip`, which encodes it, decodes the result and compares the two over every path the crosswalk promises to preserve. A streamed recipe is checked a page at a time, with the round trip holding on the whole table exactly when it holds on every page, so the table is never held.
|
|
73
105
|
* @param dataset - A dataset from any catalogue.
|
|
74
106
|
* @param options - The network port, abort signal and clock.
|
|
75
107
|
* @returns Whether the round trip holds, and where it first differs when it does not.
|
|
76
108
|
* @throws RecipeError naming the entry and the failing step when the recipe fails before the comparison, or when the crosswalk cannot run.
|
|
77
109
|
*/
|
|
78
110
|
export declare function roundTripEntry(dataset: Dataset, options?: FetchOptions): Promise<RoundTripReport>;
|
|
111
|
+
/**
|
|
112
|
+
* Streams a dataset of the bundled catalogue by id, as `streamEntry` does: for a table too large to hold as one document, whose recipe streams.
|
|
113
|
+
* @param id - The entry id.
|
|
114
|
+
* @param sink - Where the meta and the nodes go.
|
|
115
|
+
* @param options - The network port, abort signal and clock.
|
|
116
|
+
* @returns The meta, the provenance, the node count and any count warnings, once every node has been handed on.
|
|
117
|
+
* @throws DatasetNotFoundError when no entry has that id, and RecipeError as `streamEntry` does.
|
|
118
|
+
*/
|
|
119
|
+
export declare function streamDataset(id: string, sink: NodeSink, options?: FetchOptions): Promise<StreamedDataset>;
|
|
120
|
+
/**
|
|
121
|
+
* Streams a dataset whose table is too large to hold as one document: reads its paged source a page at a time, applies the crosswalk to each page's rows under the document's meta, checks the meta once and each node against the category's node shape and for an id no earlier node had, and hands the nodes on to the sink before reading the next page. What it holds at once is one page's bytes and rows and the ids seen so far (as bytes, not strings), never the table, so the result is the category target `{ meta, nodes }` delivered in order rather than held: the same nodes `fetchEntry` would give, checked by the same rules.
|
|
122
|
+
* @param dataset - A dataset whose recipe streams.
|
|
123
|
+
* @param sink - Where the meta and the nodes go.
|
|
124
|
+
* @param options - The network port, abort signal and clock.
|
|
125
|
+
* @returns The meta, the provenance, the node count and any count warnings, once every node has been handed on.
|
|
126
|
+
* @throws RecipeError naming the entry and the failing step, after which the sink has had the nodes of the pages before the failure and no more; a recipe that does not stream, or a crosswalk that cannot run a page at a time, fails before anything is downloaded.
|
|
127
|
+
*/
|
|
128
|
+
export declare function streamEntry(dataset: Dataset, sink: NodeSink, options?: FetchOptions): Promise<StreamedDataset>;
|
|
79
129
|
/**
|
|
80
130
|
* Runs `roundTripEntry` on a dataset of the bundled catalogue by id.
|
|
81
131
|
* @param id - The entry id.
|
|
@@ -84,4 +134,5 @@ export declare function roundTripEntry(dataset: Dataset, options?: FetchOptions)
|
|
|
84
134
|
* @throws DatasetNotFoundError when no entry has that id, and RecipeError as `roundTripEntry` does.
|
|
85
135
|
*/
|
|
86
136
|
export declare function roundTripDataset(id: string, options?: FetchOptions): Promise<RoundTripReport>;
|
|
87
|
-
//#endregion
|
|
137
|
+
//#endregion
|
|
138
|
+
export {};
|