@oceanum/datamesh 0.1.1 → 0.2.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 +4 -3
- package/dist/README.md +31 -0
- package/dist/blosc-CeItQ6qj.cjs +17 -0
- package/dist/blosc-DaK8KnI4.js +719 -0
- package/dist/browser-BDe_cnOJ.cjs +1 -0
- package/dist/browser-CJIXy_XB.js +524 -0
- package/dist/chunk-INHXZS53-DiyuLb3Z.js +14 -0
- package/dist/chunk-INHXZS53-z3BpFH8p.cjs +1 -0
- package/dist/gzip-DfmsOCZR.cjs +1 -0
- package/dist/gzip-TMN4LZ5e.js +24 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11341 -0
- package/dist/lib/connector.d.ts +13 -17
- package/dist/lib/connector.d.ts.map +1 -1
- package/dist/lib/datamodel.d.ts +53 -24
- package/dist/lib/datamodel.d.ts.map +1 -1
- package/dist/lib/datasource.d.ts +8 -30
- package/dist/lib/datasource.d.ts.map +1 -1
- package/dist/lib/observe.d.ts +3 -0
- package/dist/lib/observe.d.ts.map +1 -0
- package/dist/lib/query.d.ts +30 -56
- package/dist/lib/query.d.ts.map +1 -1
- package/dist/lib/zarr.d.ts +2 -2
- package/dist/lz4-CssV0LoA.js +643 -0
- package/dist/lz4-PFaIsPAh.cjs +15 -0
- package/dist/test/fixtures.d.ts +9 -5
- package/dist/test/fixtures.d.ts.map +1 -1
- package/dist/zlib-C-RQJQaC.cjs +1 -0
- package/dist/zlib-DrihHfbK.js +24 -0
- package/dist/zstd-Cqadn9HA.js +610 -0
- package/dist/zstd-_xUhkGOV.cjs +15 -0
- package/package.json +8 -4
- package/src/docs/reverse_proxy.md +0 -0
- package/src/index.js +20 -0
- package/src/index.ts +2 -0
- package/src/lib/connector.ts +33 -23
- package/src/lib/datamodel.ts +165 -25
- package/src/lib/datasource.ts +20 -24
- package/src/lib/observe.ts +21 -0
- package/src/lib/query.ts +26 -50
- package/src/lib/workers/README.md +3 -0
- package/src/test/dataframe.test.ts +108 -0
- package/src/test/dataset.test.ts +1 -1
- package/src/test/datasource.test.ts +1 -1
- package/src/test/fixtures.ts +132 -7
- package/src/test/query.test.ts +1 -1
- package/tsconfig.lib.json +2 -1
- package/tsconfig.vitest-temp.json +50 -0
- package/typedoc.json +5 -1
- package/vite.config.ts +11 -1
- package/vite.config.ts.timestamp-1734584068599-c5119713c3c4e.mjs +67 -0
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
- package/src/lib/workers/sw.js +0 -44
- package/vitest.config.ts +0 -10
- /package/{eslint.config.js → eslint.config.cjs} +0 -0
package/src/lib/query.ts
CHANGED
|
@@ -5,73 +5,47 @@ import duration from "dayjs/plugin/duration";
|
|
|
5
5
|
dayjs.extend(duration);
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* GeoFilterType
|
|
8
|
+
* GeoFilterType type representing types of geofilters.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
Feature = "feature",
|
|
12
|
-
Bbox = "bbox",
|
|
13
|
-
}
|
|
10
|
+
export type GeoFilterType = "feature" | "bbox";
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
|
-
* GeoFilterInterp
|
|
13
|
+
* GeoFilterInterp type representing interpolation methods for geofilters.
|
|
17
14
|
*/
|
|
18
|
-
|
|
19
|
-
Nearest = "nearest",
|
|
20
|
-
Linear = "linear",
|
|
21
|
-
}
|
|
15
|
+
export type GeoFilterInterp = "nearest" | "linear";
|
|
22
16
|
|
|
23
17
|
/**
|
|
24
|
-
* LevelFilterInterp
|
|
18
|
+
* LevelFilterInterp type representing interpolation methods for level filters.
|
|
25
19
|
*/
|
|
26
|
-
|
|
27
|
-
Nearest = "nearest",
|
|
28
|
-
Linear = "linear",
|
|
29
|
-
}
|
|
20
|
+
export type LevelFilterInterp = "nearest" | "linear";
|
|
30
21
|
|
|
31
22
|
/**
|
|
32
|
-
* TimeFilterType
|
|
23
|
+
* TimeFilterType type representing types of time filters.
|
|
33
24
|
*/
|
|
34
|
-
|
|
35
|
-
Range = "range",
|
|
36
|
-
Series = "series",
|
|
37
|
-
Trajectory = "trajectory",
|
|
38
|
-
}
|
|
25
|
+
export type TimeFilterType = "range" | "series" | "trajectory";
|
|
39
26
|
|
|
40
27
|
/**
|
|
41
|
-
* LevelFilterType
|
|
28
|
+
* LevelFilterType type representing types of level filters.
|
|
42
29
|
*/
|
|
43
|
-
|
|
44
|
-
Range = "range",
|
|
45
|
-
Series = "series",
|
|
46
|
-
}
|
|
30
|
+
export type LevelFilterType = "range" | "series";
|
|
47
31
|
|
|
48
32
|
/**
|
|
49
|
-
* ResampleType
|
|
33
|
+
* ResampleType type representing types of resampling.
|
|
50
34
|
*/
|
|
51
|
-
|
|
52
|
-
Mean = "mean",
|
|
53
|
-
Nearest = "nearest",
|
|
54
|
-
Slinear = "linear",
|
|
55
|
-
}
|
|
35
|
+
export type ResampleType = "mean" | "nearest" | "linear";
|
|
56
36
|
|
|
57
37
|
/**
|
|
58
|
-
* AggregateOps
|
|
38
|
+
* AggregateOps type representing aggregation operations.
|
|
59
39
|
*/
|
|
60
|
-
|
|
61
|
-
Mean = "mean",
|
|
62
|
-
Min = "min",
|
|
63
|
-
Max = "max",
|
|
64
|
-
Std = "std",
|
|
65
|
-
Sum = "sum",
|
|
66
|
-
}
|
|
40
|
+
export type AggregateOps = "mean" | "min" | "max" | "std" | "sum";
|
|
67
41
|
|
|
68
42
|
/**
|
|
69
|
-
* Container
|
|
43
|
+
* Container type representing data container types.
|
|
70
44
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
45
|
+
export type Container = "geodataframe" | "dataframe" | "dataset";
|
|
46
|
+
|
|
47
|
+
export interface GeoFilterFeature extends Omit<Feature, "properties"> {
|
|
48
|
+
properties?: Record<string, unknown> | undefined;
|
|
75
49
|
}
|
|
76
50
|
|
|
77
51
|
/**
|
|
@@ -79,7 +53,7 @@ enum Container {
|
|
|
79
53
|
*/
|
|
80
54
|
export type GeoFilter = {
|
|
81
55
|
type: GeoFilterType;
|
|
82
|
-
geom: Array<number[]> |
|
|
56
|
+
geom: Array<number[]> | GeoFilterFeature;
|
|
83
57
|
interp?: GeoFilterInterp;
|
|
84
58
|
resolution?: number;
|
|
85
59
|
alltouched?: boolean;
|
|
@@ -88,7 +62,7 @@ export type GeoFilter = {
|
|
|
88
62
|
/**
|
|
89
63
|
* LevelFilter type representing a vertical subset or interpolation.
|
|
90
64
|
*/
|
|
91
|
-
type LevelFilter = {
|
|
65
|
+
export type LevelFilter = {
|
|
92
66
|
type: LevelFilterType;
|
|
93
67
|
levels: Array<number | null>;
|
|
94
68
|
interp?: LevelFilterInterp;
|
|
@@ -126,7 +100,7 @@ const timeFilterValidate = (timefilter: TimeFilter): TimeFilter => {
|
|
|
126
100
|
const times = timefilter.times.map((t) => stringifyTime(t));
|
|
127
101
|
|
|
128
102
|
return {
|
|
129
|
-
type: timefilter.type ||
|
|
103
|
+
type: timefilter.type || "range",
|
|
130
104
|
times,
|
|
131
105
|
resolution: timefilter.resolution,
|
|
132
106
|
resample: timefilter.resample,
|
|
@@ -136,7 +110,7 @@ const timeFilterValidate = (timefilter: TimeFilter): TimeFilter => {
|
|
|
136
110
|
/**
|
|
137
111
|
* Aggregate type representing aggregation operations.
|
|
138
112
|
*/
|
|
139
|
-
type Aggregate = {
|
|
113
|
+
export type Aggregate = {
|
|
140
114
|
operations: AggregateOps[];
|
|
141
115
|
spatial?: boolean;
|
|
142
116
|
temporal?: boolean;
|
|
@@ -145,7 +119,7 @@ type Aggregate = {
|
|
|
145
119
|
/**
|
|
146
120
|
* CoordSelector type representing coordinate selection.
|
|
147
121
|
*/
|
|
148
|
-
type CoordSelector = {
|
|
122
|
+
export type CoordSelector = {
|
|
149
123
|
coord: string;
|
|
150
124
|
values: Array<string | number>;
|
|
151
125
|
};
|
|
@@ -171,6 +145,7 @@ export interface IQuery {
|
|
|
171
145
|
/**
|
|
172
146
|
* Stage interface representing the result of staging a query.
|
|
173
147
|
*/
|
|
148
|
+
/** @ignore */
|
|
174
149
|
export type Stage = {
|
|
175
150
|
query: Query;
|
|
176
151
|
qhash: string;
|
|
@@ -178,6 +153,7 @@ export type Stage = {
|
|
|
178
153
|
size: number;
|
|
179
154
|
dlen: number;
|
|
180
155
|
coordmap: Record<string, string>;
|
|
156
|
+
coordkeys: Record<string, string>;
|
|
181
157
|
container: Container;
|
|
182
158
|
sig: string;
|
|
183
159
|
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { Connector } from "../lib/connector";
|
|
3
|
+
import { datameshTest } from "./fixtures";
|
|
4
|
+
|
|
5
|
+
datameshTest(
|
|
6
|
+
"dataframe",
|
|
7
|
+
async ({ dataframe }) => {
|
|
8
|
+
// Test with the connector
|
|
9
|
+
const datamesh = new Connector(process.env.DATAMESH_TOKEN);
|
|
10
|
+
const df = await datamesh.loadDatasource("oceanum-js-test-df");
|
|
11
|
+
const data = await df.asDataframe();
|
|
12
|
+
|
|
13
|
+
// Test data structure
|
|
14
|
+
expect(data).toBeInstanceOf(Array);
|
|
15
|
+
expect(data.length).toBe(3);
|
|
16
|
+
|
|
17
|
+
// Test data content
|
|
18
|
+
expect(data[0]).toMatchObject(dataframe.data[0]);
|
|
19
|
+
|
|
20
|
+
// Test spatial progression
|
|
21
|
+
|
|
22
|
+
// Test time series
|
|
23
|
+
const times = data.map((row) => row.time);
|
|
24
|
+
expect(times).toEqual(dataframe.data.map((row) => row.time));
|
|
25
|
+
|
|
26
|
+
// Test numeric values
|
|
27
|
+
const temperatures = data.map((row) => row.temperature);
|
|
28
|
+
expect(temperatures).toEqual(dataframe.data.map((row) => row.temperature));
|
|
29
|
+
},
|
|
30
|
+
{ timeout: 100000 }
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
datameshTest(
|
|
34
|
+
"geodataframe",
|
|
35
|
+
async ({ geodataframe }) => {
|
|
36
|
+
// Test with the connector
|
|
37
|
+
const datamesh = new Connector(process.env.DATAMESH_TOKEN);
|
|
38
|
+
const gdf = await datamesh.loadDatasource("oceanum-js-test-gdf");
|
|
39
|
+
const data = await gdf.asGeojson();
|
|
40
|
+
|
|
41
|
+
// Test GeoJSON structure
|
|
42
|
+
expect(data.type).toBe("FeatureCollection");
|
|
43
|
+
expect(Array.isArray(data.features)).toBe(true);
|
|
44
|
+
expect(data.features.length).toBe(3);
|
|
45
|
+
|
|
46
|
+
// Test first feature structure
|
|
47
|
+
const feature = data.features[0];
|
|
48
|
+
expect(feature.type).toBe("Feature");
|
|
49
|
+
expect(feature.geometry.type).toBe("Point");
|
|
50
|
+
expect(Array.isArray(feature.geometry.coordinates)).toBe(true);
|
|
51
|
+
expect(feature.properties).toBeDefined();
|
|
52
|
+
|
|
53
|
+
// Test spatial progression
|
|
54
|
+
const coordinates = data.features.map((f) => f.geometry.coordinates[0]);
|
|
55
|
+
expect(coordinates).toEqual([174.0, 174.1, 174.2]);
|
|
56
|
+
|
|
57
|
+
// Test time series
|
|
58
|
+
const times = data.features.map((f) => f.properties.time);
|
|
59
|
+
expect(times).toEqual([
|
|
60
|
+
"1970-01-01T00:00:00.000Z",
|
|
61
|
+
"1970-01-02T00:00:00.000Z",
|
|
62
|
+
"1970-01-03T00:00:00.000Z",
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
// Test numeric values
|
|
66
|
+
const temperatures = data.features.map((f) => f.properties.temperature);
|
|
67
|
+
expect(temperatures).toEqual([15.5, 15.8, 15.3]);
|
|
68
|
+
},
|
|
69
|
+
{ timeout: 100000 }
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
datameshTest(
|
|
73
|
+
"dataframe with geometry",
|
|
74
|
+
async ({ dataframe }) => {
|
|
75
|
+
// Test with the connector
|
|
76
|
+
const datamesh = new Connector(process.env.DATAMESH_TOKEN);
|
|
77
|
+
const df = await datamesh.loadDatasource("oceanum-js-test-df");
|
|
78
|
+
const data = await df.asGeojson({
|
|
79
|
+
type: "Point",
|
|
80
|
+
coordinates: [174.0, -41.0],
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Test GeoJSON structure
|
|
84
|
+
expect(data.type).toBe("FeatureCollection");
|
|
85
|
+
expect(Array.isArray(data.features)).toBe(true);
|
|
86
|
+
expect(data.features.length).toBe(3);
|
|
87
|
+
|
|
88
|
+
// Test first feature structure with passed geometry
|
|
89
|
+
const feature = data.features[0];
|
|
90
|
+
expect(feature.type).toBe("Feature");
|
|
91
|
+
expect(feature.geometry.type).toBe("Point");
|
|
92
|
+
expect(feature.geometry.coordinates).toEqual([174.0, -41.0]);
|
|
93
|
+
expect(feature.properties).toBeDefined();
|
|
94
|
+
|
|
95
|
+
// Test properties from dataframe
|
|
96
|
+
expect(feature.properties.temperature).toBeDefined();
|
|
97
|
+
expect(feature.properties.time).toBeDefined();
|
|
98
|
+
|
|
99
|
+
// Test time series
|
|
100
|
+
const times = data.features.map((f) => f.properties.time);
|
|
101
|
+
expect(times).toEqual(dataframe.data.map((row) => row.time));
|
|
102
|
+
|
|
103
|
+
// Test numeric values
|
|
104
|
+
const temperatures = data.features.map((f) => f.properties.temperature);
|
|
105
|
+
expect(temperatures).toEqual(dataframe.data.map((row) => row.temperature));
|
|
106
|
+
},
|
|
107
|
+
{ timeout: 100000 }
|
|
108
|
+
);
|
package/src/test/dataset.test.ts
CHANGED
|
@@ -21,7 +21,7 @@ test("dataset init", async () => {
|
|
|
21
21
|
|
|
22
22
|
datameshTest(
|
|
23
23
|
"dataset zarr",
|
|
24
|
-
async ({ dataset }) => {
|
|
24
|
+
async ({ dataset: Dataset }) => {
|
|
25
25
|
//Test the zarr proxy endpoint directly
|
|
26
26
|
const dstest = await Dataset.zarr(
|
|
27
27
|
DATAMESH_GATEWAY + "/zarr/" + dataset.attrs.id,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assertType, test, expect } from "vitest";
|
|
2
2
|
import { Datasource } from "../lib/datasource";
|
|
3
|
-
import Connector from "../lib/connector";
|
|
3
|
+
import { Connector } from "../lib/connector";
|
|
4
4
|
import { datameshTest } from "./fixtures";
|
|
5
5
|
|
|
6
6
|
test("datasource type", () => {
|
package/src/test/fixtures.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { test } from "vitest";
|
|
4
4
|
import { Datasource, Schema } from "../lib/datasource";
|
|
5
|
+
import { Dataset } from "../lib/datamodel";
|
|
5
6
|
|
|
6
7
|
const DATAMESH_TOKEN: string = process.env.DATAMESH_TOKEN || "$DATAMESH_TOKEN";
|
|
7
8
|
export const HEADERS: HeadersInit = {
|
|
@@ -111,7 +112,7 @@ export const dataset: Schema = {
|
|
|
111
112
|
};
|
|
112
113
|
|
|
113
114
|
export const datameshTest = test.extend({
|
|
114
|
-
metadata: async ({}, use:
|
|
115
|
+
metadata: async ({}, use: (dsrc: Datasource) => Promise<void>) => {
|
|
115
116
|
// setup the fixture before each test function
|
|
116
117
|
console.log(HEADERS);
|
|
117
118
|
const resp = await fetch(DATAMESH_SERVICE + "/datasource/", {
|
|
@@ -133,10 +134,9 @@ export const datameshTest = test.extend({
|
|
|
133
134
|
headers: HEADERS,
|
|
134
135
|
});
|
|
135
136
|
},
|
|
136
|
-
dataset: async ({}, use:
|
|
137
|
+
dataset: async ({}, use: (ds: Schema) => Promise<void>) => {
|
|
137
138
|
// setup the fixture before each test function
|
|
138
|
-
|
|
139
|
-
let resp = await fetch(DATAMESH_GATEWAY + "/data/oceanum-js-test/", {
|
|
139
|
+
let resp = await fetch(DATAMESH_GATEWAY + "/data/oceanum-js-test-ds/", {
|
|
140
140
|
method: "PUT",
|
|
141
141
|
headers: HEADERS,
|
|
142
142
|
body: jsonify(dataset),
|
|
@@ -147,7 +147,7 @@ export const datameshTest = test.extend({
|
|
|
147
147
|
const patch = jsonify({
|
|
148
148
|
coordinates: { t: "time", x: "lon", y: "lat" },
|
|
149
149
|
});
|
|
150
|
-
resp = await fetch(DATAMESH_SERVICE + "/datasource/oceanum-js-test/", {
|
|
150
|
+
resp = await fetch(DATAMESH_SERVICE + "/datasource/oceanum-js-test-ds/", {
|
|
151
151
|
method: "PATCH",
|
|
152
152
|
headers: HEADERS,
|
|
153
153
|
body: patch,
|
|
@@ -155,13 +155,138 @@ export const datameshTest = test.extend({
|
|
|
155
155
|
if (resp.status !== 200) {
|
|
156
156
|
throw new Error("Failed to register dataset");
|
|
157
157
|
}
|
|
158
|
-
dataset.attrs = { id: "oceanum-js-test" };
|
|
158
|
+
dataset.attrs = { id: "oceanum-js-test-ds" };
|
|
159
159
|
|
|
160
160
|
// use the fixture value
|
|
161
161
|
await use(dataset);
|
|
162
162
|
|
|
163
163
|
// cleanup the fixture after each test function
|
|
164
|
-
await fetch(DATAMESH_GATEWAY + "/data/oceanum-js-test", {
|
|
164
|
+
await fetch(DATAMESH_GATEWAY + "/data/oceanum-js-test-ds", {
|
|
165
|
+
method: "DELETE",
|
|
166
|
+
headers: HEADERS,
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
dataframe: async ({}, use: (df: object) => Promise<void>) => {
|
|
170
|
+
// setup the fixture before each test function
|
|
171
|
+
const df = {
|
|
172
|
+
schema: {
|
|
173
|
+
fields: [
|
|
174
|
+
{ name: "time", type: "datetime", tz: "UTC" },
|
|
175
|
+
{ name: "temperature", type: "number" },
|
|
176
|
+
{ name: "elevation", type: "number" },
|
|
177
|
+
],
|
|
178
|
+
primaryKey: ["time"],
|
|
179
|
+
pandas_version: "1.4.0",
|
|
180
|
+
},
|
|
181
|
+
data: [
|
|
182
|
+
{ time: "1970-01-01T00:00:00.000Z", temperature: 15.5, elevation: 100 },
|
|
183
|
+
{ time: "1970-01-02T00:00:00.000Z", temperature: 15.8, elevation: 120 },
|
|
184
|
+
{ time: "1970-01-03T00:00:00.000Z", temperature: 15.3, elevation: 110 },
|
|
185
|
+
],
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
let resp = await fetch(DATAMESH_GATEWAY + "/data/oceanum-js-test-df/", {
|
|
189
|
+
method: "PUT",
|
|
190
|
+
headers: HEADERS,
|
|
191
|
+
body: jsonify(df),
|
|
192
|
+
});
|
|
193
|
+
if (resp.status !== 200) {
|
|
194
|
+
throw new Error("Failed to write dataframe");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const patch = jsonify({
|
|
198
|
+
coordinates: { t: "time" },
|
|
199
|
+
container: "dataframe",
|
|
200
|
+
});
|
|
201
|
+
resp = await fetch(DATAMESH_SERVICE + "/datasource/oceanum-js-test-df/", {
|
|
202
|
+
method: "PATCH",
|
|
203
|
+
headers: HEADERS,
|
|
204
|
+
body: patch,
|
|
205
|
+
});
|
|
206
|
+
if (resp.status !== 200) {
|
|
207
|
+
throw new Error("Failed to register dataframe");
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
//use the fixture value
|
|
211
|
+
await use(df);
|
|
212
|
+
|
|
213
|
+
// cleanup the fixture after each test function
|
|
214
|
+
await fetch(DATAMESH_GATEWAY + "/data/oceanum-js-test-df", {
|
|
215
|
+
method: "DELETE",
|
|
216
|
+
headers: HEADERS,
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
geodataframe: async ({}, use: (df: object) => Promise<void>) => {
|
|
220
|
+
// setup the fixture before each test function
|
|
221
|
+
const gdf = {
|
|
222
|
+
type: "FeatureCollection",
|
|
223
|
+
features: [
|
|
224
|
+
{
|
|
225
|
+
type: "Feature",
|
|
226
|
+
geometry: {
|
|
227
|
+
type: "Point",
|
|
228
|
+
coordinates: [174.0, -37.0],
|
|
229
|
+
},
|
|
230
|
+
properties: {
|
|
231
|
+
time: "1970-01-01T00:00:00.000Z",
|
|
232
|
+
temperature: 15.5,
|
|
233
|
+
elevation: 100,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
type: "Feature",
|
|
238
|
+
geometry: {
|
|
239
|
+
type: "Point",
|
|
240
|
+
coordinates: [174.1, -37.0],
|
|
241
|
+
},
|
|
242
|
+
properties: {
|
|
243
|
+
time: "1970-01-02T00:00:00.000Z",
|
|
244
|
+
temperature: 15.8,
|
|
245
|
+
elevation: 100,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
type: "Feature",
|
|
250
|
+
geometry: {
|
|
251
|
+
type: "Point",
|
|
252
|
+
coordinates: [174.2, -37.0],
|
|
253
|
+
},
|
|
254
|
+
properties: {
|
|
255
|
+
time: "1970-01-03T00:00:00.000Z",
|
|
256
|
+
temperature: 15.3,
|
|
257
|
+
elevation: 100,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
let resp = await fetch(DATAMESH_GATEWAY + "/data/oceanum-js-test-gdf/", {
|
|
264
|
+
method: "PUT",
|
|
265
|
+
headers: HEADERS,
|
|
266
|
+
body: jsonify(gdf),
|
|
267
|
+
});
|
|
268
|
+
if (resp.status !== 200) {
|
|
269
|
+
throw new Error("Failed to write geodataframe");
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const patch = jsonify({
|
|
273
|
+
coordinates: { t: "time", g: "geometry" },
|
|
274
|
+
container: "geodataframe",
|
|
275
|
+
});
|
|
276
|
+
resp = await fetch(DATAMESH_SERVICE + "/datasource/oceanum-js-test-gdf/", {
|
|
277
|
+
method: "PATCH",
|
|
278
|
+
headers: HEADERS,
|
|
279
|
+
body: patch,
|
|
280
|
+
});
|
|
281
|
+
if (resp.status !== 200) {
|
|
282
|
+
throw new Error("Failed to register geodataframe");
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// use the fixture value
|
|
286
|
+
await use(gdf);
|
|
287
|
+
|
|
288
|
+
// cleanup the fixture after each test function
|
|
289
|
+
await fetch(DATAMESH_GATEWAY + "/data/oceanum-js-test-gdf", {
|
|
165
290
|
method: "DELETE",
|
|
166
291
|
headers: HEADERS,
|
|
167
292
|
});
|
package/src/test/query.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assertType, test, expect } from "vitest";
|
|
2
2
|
import { Dataset } from "../lib/datamodel";
|
|
3
3
|
import { Connector } from "../lib/connector";
|
|
4
|
-
import {
|
|
4
|
+
import { datameshTest } from "./fixtures";
|
|
5
5
|
|
|
6
6
|
test("datasource type", () => {
|
|
7
7
|
const query: IQuery = {
|
package/tsconfig.lib.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": false,
|
|
4
|
+
"allowSyntheticDefaultImports": true,
|
|
5
|
+
"composite": true,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"emitDeclarationOnly": false,
|
|
9
|
+
"emitDecoratorMetadata": false,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"importHelpers": true,
|
|
14
|
+
"incremental": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"lib": [
|
|
17
|
+
"es2022"
|
|
18
|
+
],
|
|
19
|
+
"module": "ESNext",
|
|
20
|
+
"moduleResolution": "node",
|
|
21
|
+
"noEmitOnError": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noImplicitOverride": true,
|
|
24
|
+
"noImplicitReturns": true,
|
|
25
|
+
"noUnusedLocals": true,
|
|
26
|
+
"pretty": true,
|
|
27
|
+
"removeComments": false,
|
|
28
|
+
"resolveJsonModule": false,
|
|
29
|
+
"skipDefaultLibCheck": false,
|
|
30
|
+
"skipLibCheck": true,
|
|
31
|
+
"sourceMap": true,
|
|
32
|
+
"strict": true,
|
|
33
|
+
"target": "es2022",
|
|
34
|
+
"paths": {
|
|
35
|
+
"@oceanum/datamesh": [
|
|
36
|
+
"./packages/datamesh"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"tsBuildInfoFile": "/home/dave/Dev/github/oceanum-js/node_modules/vitest/dist/chunks/tsconfig.tmp.tsbuildinfo"
|
|
40
|
+
},
|
|
41
|
+
"include": [],
|
|
42
|
+
"references": [
|
|
43
|
+
{
|
|
44
|
+
"path": "./tsconfig.lib.json"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"path": "./tsconfig.spec.json"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
package/typedoc.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -4,6 +4,7 @@ import dts from "vite-plugin-dts";
|
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin";
|
|
6
6
|
import { nxCopyAssetsPlugin } from "@nx/vite/plugins/nx-copy-assets.plugin";
|
|
7
|
+
import commonjs from "vite-plugin-commonjs";
|
|
7
8
|
|
|
8
9
|
export default defineConfig({
|
|
9
10
|
root: __dirname,
|
|
@@ -15,6 +16,9 @@ export default defineConfig({
|
|
|
15
16
|
entryRoot: "src",
|
|
16
17
|
tsconfigPath: path.join(__dirname, "tsconfig.lib.json"),
|
|
17
18
|
}),
|
|
19
|
+
commonjs({
|
|
20
|
+
transformMixedEsModules: true,
|
|
21
|
+
}),
|
|
18
22
|
],
|
|
19
23
|
// Uncomment this if you are using workers.
|
|
20
24
|
// worker: {
|
|
@@ -42,9 +46,10 @@ export default defineConfig({
|
|
|
42
46
|
// External packages that should not be bundled into your library.
|
|
43
47
|
external: [],
|
|
44
48
|
},
|
|
49
|
+
watch: {},
|
|
45
50
|
},
|
|
46
51
|
test: {
|
|
47
|
-
watch:
|
|
52
|
+
watch: true,
|
|
48
53
|
globals: true,
|
|
49
54
|
environment: "node",
|
|
50
55
|
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
|
|
@@ -53,5 +58,10 @@ export default defineConfig({
|
|
|
53
58
|
reportsDirectory: "../../coverage/packages/datamesh",
|
|
54
59
|
provider: "v8",
|
|
55
60
|
},
|
|
61
|
+
typecheck: {
|
|
62
|
+
enabled: true,
|
|
63
|
+
include: ["**/*.{test,spec}.?(c|m)[jt]s?(x)"],
|
|
64
|
+
checker: "tsc --noEmit --pretty false --watch",
|
|
65
|
+
},
|
|
56
66
|
},
|
|
57
67
|
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// packages/datamesh/vite.config.ts
|
|
2
|
+
import { defineConfig } from "file:///home/dave/Dev/github/oceanum-js/node_modules/vite/dist/node/index.js";
|
|
3
|
+
import dts from "file:///home/dave/Dev/github/oceanum-js/node_modules/vite-plugin-dts/dist/index.mjs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import { nxViteTsPaths } from "file:///home/dave/Dev/github/oceanum-js/node_modules/@nx/vite/plugins/nx-tsconfig-paths.plugin.js";
|
|
6
|
+
import { nxCopyAssetsPlugin } from "file:///home/dave/Dev/github/oceanum-js/node_modules/@nx/vite/plugins/nx-copy-assets.plugin.js";
|
|
7
|
+
var __vite_injected_original_dirname = "/home/dave/Dev/github/oceanum-js/packages/datamesh";
|
|
8
|
+
var vite_config_default = defineConfig({
|
|
9
|
+
root: __vite_injected_original_dirname,
|
|
10
|
+
cacheDir: "../../node_modules/.vite/packages/datamesh",
|
|
11
|
+
plugins: [
|
|
12
|
+
nxViteTsPaths(),
|
|
13
|
+
nxCopyAssetsPlugin(["*.md"]),
|
|
14
|
+
dts({
|
|
15
|
+
entryRoot: "src",
|
|
16
|
+
tsconfigPath: path.join(__vite_injected_original_dirname, "tsconfig.lib.json")
|
|
17
|
+
})
|
|
18
|
+
],
|
|
19
|
+
// Uncomment this if you are using workers.
|
|
20
|
+
// worker: {
|
|
21
|
+
// plugins: [ nxViteTsPaths() ],
|
|
22
|
+
// },
|
|
23
|
+
// Configuration for building your library.
|
|
24
|
+
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
25
|
+
build: {
|
|
26
|
+
outDir: "./dist",
|
|
27
|
+
emptyOutDir: true,
|
|
28
|
+
reportCompressedSize: true,
|
|
29
|
+
commonjsOptions: {
|
|
30
|
+
transformMixedEsModules: true
|
|
31
|
+
},
|
|
32
|
+
lib: {
|
|
33
|
+
// Could also be a dictionary or array of multiple entry points.
|
|
34
|
+
entry: "src/index.ts",
|
|
35
|
+
name: "datamesh",
|
|
36
|
+
fileName: "index",
|
|
37
|
+
// Change this to the formats you want to support.
|
|
38
|
+
// Don't forget to update your package.json as well.
|
|
39
|
+
formats: ["es", "cjs"]
|
|
40
|
+
},
|
|
41
|
+
rollupOptions: {
|
|
42
|
+
// External packages that should not be bundled into your library.
|
|
43
|
+
external: []
|
|
44
|
+
},
|
|
45
|
+
watch: {}
|
|
46
|
+
},
|
|
47
|
+
test: {
|
|
48
|
+
watch: true,
|
|
49
|
+
globals: true,
|
|
50
|
+
environment: "node",
|
|
51
|
+
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
|
|
52
|
+
reporters: ["default"],
|
|
53
|
+
coverage: {
|
|
54
|
+
reportsDirectory: "../../coverage/packages/datamesh",
|
|
55
|
+
provider: "v8"
|
|
56
|
+
},
|
|
57
|
+
typecheck: {
|
|
58
|
+
enabled: true,
|
|
59
|
+
include: ["**/*.{test,spec}.?(c|m)[jt]s?(x)"],
|
|
60
|
+
checker: "tsc --noEmit --pretty false --watch"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
export {
|
|
65
|
+
vite_config_default as default
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsicGFja2FnZXMvZGF0YW1lc2gvdml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvaG9tZS9kYXZlL0Rldi9naXRodWIvb2NlY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