@oceanum/datamesh 0.4.3 → 0.5.1
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 +22 -1
- package/dist/README.md +52 -0
- package/dist/blosc-BOWv2fO7.js +719 -0
- package/dist/blosc-XU68L2JO.cjs +17 -0
- package/dist/browser-D0q2hNGi.js +524 -0
- package/dist/browser-DqtvmFrh.cjs +1 -0
- package/dist/chunk-INHXZS53-DiyuLb3Z.js +14 -0
- package/dist/chunk-INHXZS53-z3BpFH8p.cjs +1 -0
- package/dist/gzip-9a4q5uuM.cjs +1 -0
- package/dist/gzip-DchmmbTG.js +22 -0
- package/dist/index.cjs +19 -0
- package/dist/index.js +13942 -0
- package/dist/lz4-DUlZKApi.js +640 -0
- package/dist/lz4-DyL8MHib.cjs +15 -0
- package/dist/zlib-BviSziX3.cjs +1 -0
- package/dist/zlib-Din1wO0I.js +22 -0
- package/dist/zstd-BJg46wpa.cjs +15 -0
- package/dist/zstd-DnzmycJs.js +603 -0
- package/package.json +1 -1
- package/proxy/cloudflare/index.js +42 -0
- package/proxy/express/README.md +54 -0
- package/proxy/express/index.js +126 -0
- package/proxy/guide.md +140 -0
- package/src/lib/connector.ts +10 -17
- package/src/lib/datamodel.ts +58 -10
- package/src/lib/session.ts +7 -5
- package/src/lib/zarr.ts +63 -1
- package/typedoc.json +2 -1
package/README.md
CHANGED
|
@@ -28,4 +28,25 @@ const data = await datamesh.query(query);
|
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
[!WARNING]
|
|
31
|
-
DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token.
|
|
31
|
+
DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token.
|
|
32
|
+
|
|
33
|
+
## Using a Datamesh Proxy
|
|
34
|
+
|
|
35
|
+
If you are building a browser application, we recommend using a reverse proxy to keep your Datamesh token secret and to simplify CORS. This package includes an example Cloudflare Worker you can deploy quickly and configure the `Connector` to use.
|
|
36
|
+
|
|
37
|
+
- See the [proxy guide](./proxy/guide.md) for more information.
|
|
38
|
+
|
|
39
|
+
Quick setup:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { Connector } from "@oceanum/datamesh";
|
|
43
|
+
|
|
44
|
+
const PROXY_URL = "https://your-proxy.workers.dev"; // or your own domain
|
|
45
|
+
|
|
46
|
+
const datamesh = new Connector("proxy", {
|
|
47
|
+
service: PROXY_URL,
|
|
48
|
+
gateway: PROXY_URL,
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Deploy the example Worker at `proxy/cloudflare/index.js` and add a secret `DATAMESH_TOKEN` with your Datamesh token in the Worker settings.
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @oceanum/datamesh
|
|
2
|
+
|
|
3
|
+
A typescript library for interacting with the Oceanum.io Datamesh.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can use this library in Node.js, Deno or browser code (with the caveat below)
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @oceanum/datamesh
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { Connector } from "@oceanum/datamesh";
|
|
17
|
+
|
|
18
|
+
//Instatiate the Datamesh Connector
|
|
19
|
+
const datamesh = Connector("my_datamesh_token"); //Get your datamesh token from your Oceanum.io account
|
|
20
|
+
|
|
21
|
+
//Define a datamesh query
|
|
22
|
+
const query = {
|
|
23
|
+
datasource: "oceanum-sizing_giants",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//Get the data
|
|
27
|
+
const data = await datamesh.query(query);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
[!WARNING]
|
|
31
|
+
DO NOT put your Datamesh token directly into browser code. For use in an SPA, you should forward your Datamesh request through a reverse proxy to conceal your token.
|
|
32
|
+
|
|
33
|
+
## Using a Datamesh Proxy
|
|
34
|
+
|
|
35
|
+
If you are building a browser application, we recommend using a reverse proxy to keep your Datamesh token secret and to simplify CORS. This package includes an example Cloudflare Worker you can deploy quickly and configure the `Connector` to use.
|
|
36
|
+
|
|
37
|
+
- See the [proxy guide](./proxy/guide.md) for more information.
|
|
38
|
+
|
|
39
|
+
Quick setup:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { Connector } from "@oceanum/datamesh";
|
|
43
|
+
|
|
44
|
+
const PROXY_URL = "https://your-proxy.workers.dev"; // or your own domain
|
|
45
|
+
|
|
46
|
+
const datamesh = new Connector("proxy", {
|
|
47
|
+
service: PROXY_URL,
|
|
48
|
+
gateway: PROXY_URL,
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Deploy the example Worker at `proxy/cloudflare/index.js` and add a secret `DATAMESH_TOKEN` with your Datamesh token in the Worker settings.
|