@oceanum/datamesh 0.1.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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # datamesh
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build datamesh` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test datamesh` to execute the unit tests via [Vitest](https://vitest.dev/).
@@ -0,0 +1,3 @@
1
+ export * from "./lib/connector";
2
+ export * from "./lib/datasource";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,97 @@
1
+ import { Datasource } from "./datasource";
2
+ import { IQuery } from "./query";
3
+ import { Dataset, DatameshStore } from "./datamodel";
4
+ /**
5
+ * Datamesh connector class.
6
+ *
7
+ * All datamesh operations are methods of this class.
8
+ */
9
+ declare class Connector {
10
+ private _token;
11
+ private _proto;
12
+ private _host;
13
+ private _authHeaders;
14
+ private _gateway;
15
+ /**
16
+ * Datamesh connector constructor
17
+ *
18
+ * @param token - Your datamesh access token. Defaults to environment variable DATAMESH_TOKEN if defined else $DATAMESH_TOKEN
19
+ * @param service - URL of datamesh service. Defaults to environment variable DATAMESH_SERVICE or "https://datamesh.oceanum.io".
20
+ * @param gateway - URL of gateway service. Defaults to "https://gateway.<datamesh_service_domain>".
21
+ * @param user - Organisation user name for the datamesh connection. Defaults to None.
22
+ *
23
+ * @throws {Error} - If a valid token is not provided.
24
+ */
25
+ constructor(token?: string, service?: string, gateway?: string);
26
+ /**
27
+ * Get datamesh host.
28
+ *
29
+ * @returns The datamesh server host.
30
+ */
31
+ get host(): string;
32
+ /**
33
+ * Check the status of the metadata server.
34
+ *
35
+ * @returns True if the metadata server is up, false otherwise.
36
+ */
37
+ status(): Promise<boolean>;
38
+ /**
39
+ * Validate response from server.
40
+ *
41
+ * @param response - The response object to validate.
42
+ * @throws {Error} - If the response contains an error status code.
43
+ */
44
+ private validateResponse;
45
+ /**
46
+ * Request metadata from datamesh.
47
+ *
48
+ * @param datasourceId - The ID of the datasource to request.
49
+ * @param params - Additional parameters for the request.
50
+ * @returns The response from the server.
51
+ */
52
+ private metadataRequest;
53
+ /**
54
+ * Request data from datamesh.
55
+ *
56
+ * @param datasourceId - The ID of the datasource to request.
57
+ * @param dataFormat - The format of the requested data. Defaults to "application/json".
58
+ * @param cache - Whether to cache the response. Defaults to false.
59
+ * @returns The path to the cached file.
60
+ */
61
+ dataRequest(datasourceId: string, dataFormat?: string): Promise<Blob>;
62
+ /**
63
+ * Stage a query to the datamesh.
64
+ *
65
+ * @param query - The query to stage.
66
+ * @returns The staged response.
67
+ */
68
+ private stageRequest;
69
+ /**
70
+ * Execute a query to the datamesh.
71
+ *
72
+ * @param query - The query to execute.
73
+ * @param useDask - Whether to use Dask for execution. Defaults to false.
74
+ * @param cacheTimeout - The cache timeout for the query. Defaults to 0.
75
+ * @returns The response from the server.
76
+ */
77
+ query(query: IQuery): Promise<Dataset<DatameshStore> | null>;
78
+ /**
79
+ * Get a datasource instance from the datamesh.
80
+ *
81
+ * @param datasourceId - Unique datasource ID.
82
+ * @returns The datasource instance.
83
+ * @throws {Error} - If the datasource cannot be found or is not authorized.
84
+ */
85
+ getDatasource(datasourceId: string): Promise<Datasource>;
86
+ /**
87
+ * Load a datasource into the work environment.
88
+ *
89
+ * @param datasourceId - Unique datasource ID.
90
+ * @param parameters - Additional datasource parameters.
91
+ * @param useDask - Whether to use Dask for loading. Defaults to false.
92
+ * @returns The datasource container.
93
+ */
94
+ loadDatasource(datasourceId: string, parameters?: Record<string, string | number>): Promise<Dataset<DatameshStore> | null>;
95
+ }
96
+ export default Connector;
97
+ //# sourceMappingURL=connector.d.ts.map
@@ -0,0 +1 @@
1
+ {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 import { CachedHTTPStore } from "./zarr";
2
+ import * as zarr from "@zarrita/core";
3
+ import { DataType, Listable, Location } from "@zarrita/core";
4
+ import { Mutable, AsyncReadable } from "@zarrita/storage";
5
+ import { Slice } from "@zarrita/indexing";
6
+ import { Schema } from "./datasource";
7
+ declare type ATypedArray = Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Float32Array | Float64Array;
8
+ declare type Scalar = string | number | boolean;
9
+ declare type NDArray = Scalar[] | Scalar[][] | Scalar[][][] | Scalar[][][][] | ATypedArray[] | ATypedArray[][] | ATypedArray[][][] | ATypedArray[][][][];
10
+ declare type Data = NDArray | ATypedArray | Scalar;
11
+ /**
12
+ * Represents a data variable.
13
+ */
14
+ export declare type DataVariable = {
15
+ /**
16
+ * Attributes of the variable.
17
+ */
18
+ attrs: Record<string, string | unknown>;
19
+ /**
20
+ * Dimensions of the variable
21
+ * */
22
+ dims: string[];
23
+ /**
24
+ * Datatype of the variable.
25
+ */
26
+ dtype?: string;
27
+ /**
28
+ * Data associated with the variable.
29
+ */
30
+ data?: Data;
31
+ };
32
+ export declare type DatameshStore = Location<Listable<AsyncReadable>>;
33
+ export declare type TempStore = Location<Mutable>;
34
+ /**
35
+ * Represents a data variable within a dataset.
36
+ */
37
+ export declare class DataVar<DType extends DataType, S extends TempStore | DatameshStore> {
38
+ /**
39
+ * Creates an instance of DataVar.
40
+ * @param id - The identifier for the data variable.
41
+ * @param dims - The dimensions associated with the data variable.
42
+ * @param attrs - The attributes of the data variable, represented as a record of key-value pairs.
43
+ * @param arr - The zarr array associated with the data variable.
44
+ */
45
+ id: string;
46
+ dims: string[];
47
+ attrs: Record<string, unknown>;
48
+ arr: S extends TempStore ? zarr.Array<DType, Mutable> : zarr.Array<DType, AsyncReadable>;
49
+ constructor(id: string, dims: string[], attrs: Record<string, unknown>, arr: S extends TempStore ? zarr.Array<DType, Mutable> : zarr.Array<DType, AsyncReadable>);
50
+ /**
51
+ * Retrieves the data from the zarr array. If the data is already cached, it returns the cached data.
52
+ * @param slice - Optional slice parameters to retrieve specific data from the zarr array.
53
+ * @returns A promise that resolves to the data of the zarr array.
54
+ */
55
+ get(slice?: (null | Slice | number)[] | null | undefined): Promise<Data>;
56
+ }
57
+ /**
58
+ * Represents a dataset with dimensions, data variables, and attributes.
59
+ * Implements the DatasetApi interface.
60
+ */
61
+ export declare class Dataset<S extends DatameshStore | TempStore> {
62
+ /**
63
+ * Creates an instance of Dataset.
64
+ * @param dims - The dimensions of the dataset.
65
+ * @param data_vars - The data variables of the dataset.
66
+ * @param attrs - The attributes of the dataset.
67
+ * @param root - The root group of the dataset.
68
+ */
69
+ dims: Record<string, number>;
70
+ data_vars: S extends TempStore ? Record<string, DataVar<DataType, TempStore>> : Record<string, DataVar<DataType, DatameshStore>>;
71
+ attrs: Record<string, unknown>;
72
+ root: S;
73
+ constructor(dims: Record<string, number>, data_vars: S extends TempStore ? Record<string, DataVar<DataType, TempStore>> : Record<string, DataVar<DataType, DatameshStore>>, attrs: Record<string, unknown>, root: S);
74
+ /**
75
+ * Creates a Dataset instance from a Zarr store.
76
+ * @param gateway - The URL of the datamesh gateway.
77
+ * @param authHeaders - The authentication headers.
78
+ * @param parameters - Optional parameters for the request.
79
+ * @param chunks - Optional chunking strategy.
80
+ * @param downsample - Optional downsampling strategy.
81
+ * @returns A promise that resolves to a Dataset instance.
82
+ */
83
+ static zarr(url: string, authHeaders: Record<string, string>, parameters?: Record<string, string | number>, chunks?: string, downsample?: Record<string, number>): Promise<Dataset<zarr.Location<zarr.Listable<CachedHTTPStore>>>>;
84
+ /**
85
+ * Initializes an in memory Dataset instance from a data object.
86
+ * @param datasource - An object containing id, dimensions, data variables, and attributes.
87
+ */
88
+ static init(datasource: Schema): Promise<void>;
89
+ /**
90
+ * Converts the data variables into a dataframe format.
91
+ *
92
+ * @returns {Promise<Record<string, unknown>[]>} A promise that resolves to an array of records,
93
+ * where each record represents a row in the dataframe.
94
+ *
95
+ * @remarks
96
+ * This method iterates over the data variables, retrieves their dimensions and data,
97
+ * and then flattens the data into a dataframe structure.
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const dataframe = await instance.to_dataframe();
102
+ * console.log(dataframe);
103
+ * ```
104
+ */
105
+ to_dataframe(): Promise<Record<string, unknown>[]>;
106
+ /**
107
+ * Asynchronously assigns data to a variable in the dataset.
108
+ *
109
+ * @param varid - The identifier for the variable.
110
+ * @param dims - An array of dimension names corresponding to the data.
111
+ * @param data - The data to be assigned, which can be a multi-dimensional array.
112
+ * @param attrs - Optional. A record of attributes to be associated with the variable.
113
+ * @param dtype - The data type of the variable.
114
+ * @param chunks - Optional. An array specifying the chunk sizes for the data.
115
+
116
+ * @returns A promise that resolves when the data has been successfully assigned.
117
+ * @throws Will throw an error if the shape of the data does not match the provided dimensions.
118
+ * @throws Will throw an error if an existing dimension size does not match the new data.
119
+ */
120
+ assign(varid: string, dims: string[], data: Data, attrs?: Record<string, unknown>, chunks?: number[]): Promise<void>;
121
+ }
122
+ export {};
123
+ //# sourceMappingURL=datamodel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datamodel.d.ts","sourceRoot":"","sources":["../../src/lib/datamodel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAc,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAY,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,aAAK,WAAW,GACZ,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AACjB,aAAK,MAAM,GAAG,MAAM,GAAG,MAAM,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AAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAmCrC;;;OAGG;WACU,IAAI,CAAC,UAAU,EAAE,MAAM;IASpC;;;;;;;;;;;;;;;OAeG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAYxD;;;;;;;;;;;;;OAaG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,IAAI,EACV,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC;CAgCjB"}
@@ -0,0 +1,118 @@
1
+ import { Geometry } from "geojson";
2
+ import dayjs from "dayjs";
3
+ import duration from "dayjs/plugin/duration";
4
+ import { DataVariable } from "./datamodel";
5
+ /**
6
+ * Represents a data variable.
7
+ */
8
+ declare enum Coordinate {
9
+ "Station" = "s",
10
+ "Ensemble" = "e",
11
+ "Raster band" = "b",
12
+ "Category" = "c",
13
+ "Quantile" = "q",
14
+ "Season" = "n",
15
+ "Month" = "m",
16
+ "Time" = "t",
17
+ "Vertical coordinate" = "z",
18
+ "Horizontal northerly" = "y",
19
+ "Horizontal easterly" = "x",
20
+ "Geometry" = "g",
21
+ "Frequency" = "f",
22
+ "Direction" = "d",
23
+ "Coordinate_i" = "i",
24
+ "Coordinate_j" = "j",
25
+ "Coordinate_k" = "k"
26
+ }
27
+ declare type Coordinates = {
28
+ [key in Coordinate]?: string;
29
+ };
30
+ /**
31
+ * Represents the schema of a data source.
32
+ */
33
+ export declare type Schema = {
34
+ /**
35
+ * Attributes of the schema.
36
+ */
37
+ attrs?: Record<string, string | number>;
38
+ /**
39
+ * Dimensions of the schema.
40
+ */
41
+ dims: Record<string, number>;
42
+ /**
43
+ * Coordinates of the schema.
44
+ */
45
+ coords?: Record<string, DataVariable>;
46
+ /**
47
+ * Data variables of the schema.
48
+ */
49
+ data_vars: Record<string, DataVariable>;
50
+ };
51
+ /**
52
+ * Represents a data source.
53
+ */
54
+ export declare type Datasource = {
55
+ /**
56
+ * Unique identifier for the data source.
57
+ */
58
+ id: string;
59
+ /**
60
+ * Name of the data source.
61
+ */
62
+ name: string;
63
+ /**
64
+ * Description of the data source.
65
+ */
66
+ description?: string;
67
+ /**
68
+ * Parameters associated with the data source.
69
+ */
70
+ parameters?: Record<string, unknown>;
71
+ /**
72
+ * Geometric representation of the data source.
73
+ */
74
+ geom?: Geometry;
75
+ /**
76
+ * Start time for the data source.
77
+ */
78
+ tstart?: dayjs.Dayjs;
79
+ /**
80
+ * End time for the data source.
81
+ */
82
+ tend?: dayjs.Dayjs;
83
+ /**
84
+ * Forecast time period for the data source.
85
+ */
86
+ pforecast?: duration.Duration;
87
+ /**
88
+ * Archive time period for the data source.
89
+ */
90
+ parchive?: duration.Duration;
91
+ /**
92
+ * Tags associated with the data source.
93
+ */
94
+ tags?: string[];
95
+ /**
96
+ * Additional information about the data source.
97
+ */
98
+ info?: Record<string, unknown>;
99
+ /**
100
+ * Schema information for the data source.
101
+ */
102
+ schema: Schema;
103
+ /**
104
+ * Coordinate mappings for the data source.
105
+ */
106
+ coordinates: Coordinates;
107
+ /**
108
+ * Additional details about the data source.
109
+ */
110
+ details?: string;
111
+ /**
112
+ * Last modified date of the data source.
113
+ */
114
+ last_modified?: Date;
115
+ driver: string;
116
+ };
117
+ export {};
118
+ //# sourceMappingURL=datasource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/lib/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,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AEnB;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAE7B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,aAAa,CAAC,EAAE,IAAI,CAAC;IAErB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,161 @@
1
+ import { Feature } from "geojson";
2
+ import dayjs from "dayjs";
3
+ import duration from "dayjs/plugin/duration";
4
+ /**
5
+ * GeoFilterType enum representing types of geofilters.
6
+ */
7
+ declare enum GeoFilterType {
8
+ Feature = "feature",
9
+ Bbox = "bbox"
10
+ }
11
+ /**
12
+ * GeoFilterInterp enum representing interpolation methods for geofilters.
13
+ */
14
+ declare enum GeoFilterInterp {
15
+ Nearest = "nearest",
16
+ Linear = "linear"
17
+ }
18
+ /**
19
+ * LevelFilterInterp enum representing interpolation methods for level filters.
20
+ */
21
+ declare enum LevelFilterInterp {
22
+ Nearest = "nearest",
23
+ Linear = "linear"
24
+ }
25
+ /**
26
+ * TimeFilterType enum representing types of time filters.
27
+ */
28
+ declare enum TimeFilterType {
29
+ Range = "range",
30
+ Series = "series",
31
+ Trajectory = "trajectory"
32
+ }
33
+ /**
34
+ * LevelFilterType enum representing types of level filters.
35
+ */
36
+ declare enum LevelFilterType {
37
+ Range = "range",
38
+ Series = "series"
39
+ }
40
+ /**
41
+ * ResampleType enum representing types of resampling.
42
+ */
43
+ declare enum ResampleType {
44
+ Mean = "mean",
45
+ Nearest = "nearest",
46
+ Slinear = "linear"
47
+ }
48
+ /**
49
+ * AggregateOps enum representing aggregation operations.
50
+ */
51
+ declare enum AggregateOps {
52
+ Mean = "mean",
53
+ Min = "min",
54
+ Max = "max",
55
+ Std = "std",
56
+ Sum = "sum"
57
+ }
58
+ /**
59
+ * Container enum representing data container types.
60
+ */
61
+ declare enum Container {
62
+ GeoDataFrame = "geodataframe",
63
+ DataFrame = "dataframe",
64
+ Dataset = "dataset"
65
+ }
66
+ /**
67
+ * GeoFilter type representing a spatial subset or interpolation.
68
+ */
69
+ export declare type GeoFilter = {
70
+ type: GeoFilterType;
71
+ geom: Array<number[]> | Feature;
72
+ interp?: GeoFilterInterp;
73
+ resolution?: number;
74
+ alltouched?: boolean;
75
+ };
76
+ /**
77
+ * LevelFilter type representing a vertical subset or interpolation.
78
+ */
79
+ declare type LevelFilter = {
80
+ type: LevelFilterType;
81
+ levels: Array<number | null>;
82
+ interp?: LevelFilterInterp;
83
+ };
84
+ /**
85
+ * TimeFilter type representing a temporal subset or interpolation.
86
+ */
87
+ export declare type TimeFilter = {
88
+ type?: TimeFilterType;
89
+ times: Array<Date | dayjs.Dayjs | duration.Duration | string>;
90
+ resolution?: string;
91
+ resample?: ResampleType;
92
+ };
93
+ /**
94
+ * Aggregate type representing aggregation operations.
95
+ */
96
+ declare type Aggregate = {
97
+ operations: AggregateOps[];
98
+ spatial?: boolean;
99
+ temporal?: boolean;
100
+ };
101
+ /**
102
+ * CoordSelector type representing coordinate selection.
103
+ */
104
+ declare type CoordSelector = {
105
+ coord: string;
106
+ values: Array<string | number>;
107
+ };
108
+ /**
109
+ * Query interface representing a Datamesh query.
110
+ */
111
+ export interface IQuery {
112
+ datasource: string;
113
+ parameters?: Record<string, number | string | number[] | string[]>;
114
+ description?: string;
115
+ variables?: string[];
116
+ timefilter?: TimeFilter;
117
+ geofilter?: GeoFilter;
118
+ levelfilter?: LevelFilter;
119
+ coordfilter?: CoordSelector[];
120
+ crs?: string | number;
121
+ aggregate?: Aggregate;
122
+ limit?: number;
123
+ id?: string;
124
+ }
125
+ /**
126
+ * Stage interface representing the result of staging a query.
127
+ */
128
+ export declare type Stage = {
129
+ query: Query;
130
+ qhash: string;
131
+ formats: string[];
132
+ size: number;
133
+ dlen: number;
134
+ coordmap: Record<string, string>;
135
+ container: Container;
136
+ sig: string;
137
+ };
138
+ /**
139
+ * Query class representing a Datamesh query.
140
+ */
141
+ export declare class Query implements IQuery {
142
+ datasource: string;
143
+ parameters?: Record<string, number | string | number[] | string[]>;
144
+ description?: string;
145
+ variables?: string[];
146
+ timefilter?: TimeFilter;
147
+ geofilter?: GeoFilter;
148
+ levelfilter?: LevelFilter;
149
+ coordfilter?: CoordSelector[];
150
+ crs?: string | number;
151
+ aggregate?: Aggregate;
152
+ limit?: number;
153
+ id?: string;
154
+ constructor(query: IQuery);
155
+ /**
156
+ * Returns the query as a JSON object.
157
+ */
158
+ toJSON(): Record<string, unknown>;
159
+ }
160
+ export {};
161
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/lib/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAI7C;;GAEG;AACH,aAAK,aAAa;IAChB,OAAO,YAAY;IACnB,IAAI,SAAS;CACd;AAED;;GAEG;AACH,aAAK,eAAe;IAClB,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,aAAK,iBAAiB;IACpB,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,aAAK,cAAc;IACjB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,UAAU,eAAe;CAC1B;AAED;;GAEG;AACH,aAAK,eAAe;IAClB,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,aAAK,YAAY;IACf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ACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;gBAEA,KAAK,EAAE,MAAM;IAezB;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAgBlC"}
@@ -0,0 +1,20 @@
1
+ import { UseStore } from "idb-keyval";
2
+ import { AsyncReadable, AsyncMutable, AbsolutePath } from "@zarrita/storage";
3
+ export declare class CachedHTTPStore implements AsyncReadable {
4
+ cache: UseStore | undefined;
5
+ url: string;
6
+ cache_prefix: string;
7
+ fetchOptions: RequestInit;
8
+ constructor(root: string, authHeaders: Record<string, string>, parameters?: Record<string, string | number>, chunks?: string, downsample?: Record<string, number>, nocache?: boolean);
9
+ get(item: string, options?: RequestInit, retry?: number): Promise<Uint8Array | undefined>;
10
+ }
11
+ export declare class IDBStore implements AsyncMutable {
12
+ root: string;
13
+ cache: UseStore;
14
+ constructor(root: string);
15
+ get(key: AbsolutePath): Promise<Uint8Array | undefined>;
16
+ has(key: AbsolutePath): Promise<boolean>;
17
+ set(key: AbsolutePath, value: Uint8Array): Promise<void>;
18
+ delete(key: AbsolutePath): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=zarr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zarr.d.ts","sourceRoot":"","sources":["../../src/lib/zarr.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,QAAQ,EACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAM7E,qBAAa,eAAgB,YAAW,aAAa;IACnD,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,WAAW,CAAC;gBAExB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC5C,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,CAAC,EAAE,OAAO;IAiBb,GAAG,CACP,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,WAAW,EACrB,KAAK,SAAI,GACR,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;CAsCnC;AAED,qBAAa,QAAS,YAAW,YAAY;IAExB,IAAI,EAAE,MAAM;IAD/B,KAAK,EAAE,QAAQ,CAAC;gBACG,IAAI,EAAE,MAAM;IAIzB,GAAG,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAQvD,GAAG,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAIxC,GAAG,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD,MAAM,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/C"}
@@ -0,0 +1,8 @@
1
+ /// <reference lib="dom" />
2
+ import { Schema } from "../lib/datasource";
3
+ export declare const dataset: Schema;
4
+ export declare const datameshTest: import("@vitest/runner/dist/tasks-K5XERDtv").e<{
5
+ metadata: ({}: {}, use: Function) => Promise<void>;
6
+ dataset: ({}: {}, use: Function) => Promise<void>;
7
+ }>;
8
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/test/fixtures.ts"],"names":[],"mappings":";AAGA,OAAO,EAAc,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAkDvD,eAAO,MAAM,OAAO,EAAE,MAerB,CAAC;AAEF,eAAO,MAAM,YAAY;4BACG,QAAQ;2BAsBT,QAAQ;EAqBjC,CAAC"}