Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/tests-and-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Tests and Lint

on:
push:
branches: ["main"]
pull_request:

permissions:
contents: read

jobs:
quality:
name: Tests and lint
runs-on: ubuntu-latest

steps:
- name: Checkout JS client
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Enable Corepack
run: corepack enable

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run lint
run: yarn lint

- name: Run tests
run: yarn test:ci
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,27 @@ const [subset, metadata] = await client.selectDataset({
});
```

Use `bounds` for rectangular lon/lat selections. Tuple bounds are
`[west, south, east, north]`.

```typescript
const [westernEurope, metadata] = await client.selectDataset({
request: {
organization: "ecmwf",
collection: "era5",
dataset: "temperature_2m",
variant: "finalized"
},
selection: {
bounds: [-12, 35, 16, 60],
timeRange: {
start: "2024-01-01T00:00:00Z",
end: "2024-01-07T23:00:00Z",
},
}
});
```

### Geographic shape selections

The client supports advanced geographic selections beyond single points:
Expand Down
24 changes: 24 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";

export default tseslint.config(
{
ignores: ["coverage/**", "dist/**", "node_modules/**"],
},
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ["**/*.ts", "**/*.js"],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
"@typescript-eslint/no-this-alias": "off",
"no-undef": "off",
},
},
);
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dclimate/dclimate-client-js",
"version": "0.5.7",
"version": "0.5.8",
"description": "JavaScript client for dClimate datasets using jaxray and IPFS stores",
"type": "module",
"main": "./dist/node/index.js",
Expand All @@ -26,7 +26,9 @@
"build:browser": "tsc -p tsconfig.browser.json",
"build:node": "tsc -p tsconfig.node.json",
"build": "npm run build:browser && npm run build:node",
"lint": "eslint .",
"test": "vitest",
"test:ci": "vitest run",
"test:coverage": "vitest run --coverage",
"prepare": "npm run build",
"prepublishOnly": "npm run build"
Expand All @@ -53,7 +55,11 @@
"@opentelemetry/api": "^1.9.1"
},
"devDependencies": {
"@eslint/js": "10.0.1",
"eslint": "10.4.1",
"globals": "17.6.0",
"typescript": "^5.4.0",
"typescript-eslint": "8.61.0",
"vitest": "^4.1.0"
},
"publishConfig": {
Expand Down
9 changes: 4 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ export class DClimateClient {
request.variant,
resolvedOrganization
);
resolvedCollection = resolvedInfo.collectionId;
resolvedOrganization = resolvedInfo.organizationId ?? resolvedOrganization;
const resolvedOrganizationId =
resolvedInfo.organizationId ?? resolvedOrganization;

// Multiple variants with concat metadata found
// Load and concatenate based on dclimate:concatPriority
return this.loadAndConcatenateVariants(
{
...request,
collection: resolvedInfo.collectionId,
organization: resolvedInfo.organizationId ?? resolvedOrganization,
organization: resolvedOrganizationId,
variant: request.variant,
},
concatenableItems,
Expand All @@ -184,7 +184,6 @@ export class DClimateClient {

// Fall back to single variant loading
let cid: string | null = null;
let resolvedPath: string;
let metadataDataset = request.dataset;
let metadataCollection = resolvedCollection || request.collection;
let metadataVariant = request.variant ?? "";
Expand Down Expand Up @@ -231,7 +230,7 @@ export class DClimateClient {

// Build path from resolved names
const pathParts = [metadataCollection, metadataDataset, metadataVariant].filter(Boolean);
resolvedPath = pathParts.join("-");
const resolvedPath = pathParts.join("-");

const dataset = await openDatasetFromCid(cid, {
gatewayUrl,
Expand Down
Loading
Loading