@chrtco/sdk 0.3.2
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 +126 -0
- package/dist/index.cjs +223 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +156 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.js +195 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @chrtco/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the [CHRT](https://chrt.co) nautical chart API.
|
|
4
|
+
|
|
5
|
+
Zero dependencies · Works in Node 18+, browsers, Deno, Bun · Full TypeScript types
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @chrtco/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Chrt } from '@chrtco/sdk';
|
|
17
|
+
|
|
18
|
+
const chrt = new Chrt('chrt_live_...');
|
|
19
|
+
|
|
20
|
+
// Get depth areas in a bounding box
|
|
21
|
+
const features = await chrt.features({
|
|
22
|
+
bbox: [-71, 42, -70, 43],
|
|
23
|
+
layer: 'DEPARE',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Find buoys near a position
|
|
27
|
+
const nearby = await chrt.query({
|
|
28
|
+
point: [-70.86, 42.02],
|
|
29
|
+
radius: 2000,
|
|
30
|
+
layer: 'BOYCAR,BOYLAT',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// List ENC cells
|
|
34
|
+
const cells = await chrt.cells.list({ source: 'NOAA' });
|
|
35
|
+
|
|
36
|
+
// Get a specific cell
|
|
37
|
+
const cell = await chrt.cells.get('US5MA11M');
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Mapbox GL JS / MapLibre
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import mapboxgl from 'mapbox-gl';
|
|
44
|
+
import { Chrt } from '@chrtco/sdk';
|
|
45
|
+
|
|
46
|
+
const chrt = new Chrt('chrt_live_...');
|
|
47
|
+
|
|
48
|
+
const map = new mapboxgl.Map({
|
|
49
|
+
container: 'map',
|
|
50
|
+
style: chrt.styleUrl(),
|
|
51
|
+
center: [-70.25, 43.66],
|
|
52
|
+
zoom: 12,
|
|
53
|
+
transformRequest: chrt.transformRequest(),
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const chrt = new Chrt({
|
|
61
|
+
apiKey: 'chrt_live_...',
|
|
62
|
+
baseUrl: 'https://api.chrt.co/v1', // default
|
|
63
|
+
retries: 2, // retry on 5xx, default 2
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API Reference
|
|
68
|
+
|
|
69
|
+
### `chrt.features(options)`
|
|
70
|
+
Query GeoJSON features by bounding box.
|
|
71
|
+
|
|
72
|
+
| Option | Type | Required | Description |
|
|
73
|
+
|--------|------|----------|-------------|
|
|
74
|
+
| `bbox` | `[w, s, e, n]` | ✓ | Bounding box |
|
|
75
|
+
| `layer` | `string` | | S-57 layer code (e.g. `DEPARE`) |
|
|
76
|
+
| `limit` | `number` | | Max results (default 100) |
|
|
77
|
+
| `offset` | `number` | | Pagination offset |
|
|
78
|
+
|
|
79
|
+
### `chrt.query(options)`
|
|
80
|
+
Spatial proximity search around a point.
|
|
81
|
+
|
|
82
|
+
| Option | Type | Required | Description |
|
|
83
|
+
|--------|------|----------|-------------|
|
|
84
|
+
| `point` | `[lng, lat]` | ✓ | Centre point |
|
|
85
|
+
| `radius` | `number` | | Radius in metres (default 1000) |
|
|
86
|
+
| `layer` | `string` | | Comma-separated layer codes |
|
|
87
|
+
| `limit` | `number` | | Max results |
|
|
88
|
+
|
|
89
|
+
### `chrt.cells.list(options?)`
|
|
90
|
+
List available ENC cells.
|
|
91
|
+
|
|
92
|
+
### `chrt.cells.get(cellId)`
|
|
93
|
+
Get metadata for a specific cell.
|
|
94
|
+
|
|
95
|
+
### `chrt.tiles.styleUrl()`
|
|
96
|
+
Returns a Mapbox/MapLibre-compatible `style.json` URL.
|
|
97
|
+
|
|
98
|
+
### `chrt.tiles.tileUrl(z, x, y)`
|
|
99
|
+
Returns a single vector tile URL.
|
|
100
|
+
|
|
101
|
+
### `chrt.tiles.groups()`
|
|
102
|
+
List available tileset groups.
|
|
103
|
+
|
|
104
|
+
### `chrt.styleUrl()`
|
|
105
|
+
Shortcut for `chrt.tiles.styleUrl()`.
|
|
106
|
+
|
|
107
|
+
### `chrt.transformRequest()`
|
|
108
|
+
Returns a `transformRequest` function for Mapbox GL / MapLibre that auto-injects the API key.
|
|
109
|
+
|
|
110
|
+
## Error Handling
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { Chrt, ChrtError } from '@chrtco/sdk';
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
await chrt.features({ bbox: [-71, 42, -70, 43] });
|
|
117
|
+
} catch (e) {
|
|
118
|
+
if (e instanceof ChrtError) {
|
|
119
|
+
console.error(e.status, e.code, e.message);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Chrt: () => Chrt,
|
|
24
|
+
ChrtError: () => ChrtError
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/client.ts
|
|
29
|
+
var DEFAULT_BASE_URL = "https://api.chrt.co/v1";
|
|
30
|
+
var ChrtError = class extends Error {
|
|
31
|
+
status;
|
|
32
|
+
code;
|
|
33
|
+
body;
|
|
34
|
+
constructor(status, body) {
|
|
35
|
+
super(body?.message ?? body?.error ?? `CHRT API error ${status}`);
|
|
36
|
+
this.name = "ChrtError";
|
|
37
|
+
this.status = status;
|
|
38
|
+
this.code = body?.code;
|
|
39
|
+
this.body = body;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var HttpClient = class {
|
|
43
|
+
apiKey;
|
|
44
|
+
baseUrl;
|
|
45
|
+
retries;
|
|
46
|
+
constructor(apiKey, baseUrl, retries = 2) {
|
|
47
|
+
this.apiKey = apiKey;
|
|
48
|
+
this.baseUrl = (baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
49
|
+
this.retries = retries;
|
|
50
|
+
}
|
|
51
|
+
getBaseUrl() {
|
|
52
|
+
return this.baseUrl;
|
|
53
|
+
}
|
|
54
|
+
getApiKey() {
|
|
55
|
+
return this.apiKey;
|
|
56
|
+
}
|
|
57
|
+
async request(path, params) {
|
|
58
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
59
|
+
if (params) {
|
|
60
|
+
for (const [k, v] of Object.entries(params)) {
|
|
61
|
+
if (v !== void 0) url.searchParams.set(k, String(v));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let lastError = null;
|
|
65
|
+
for (let attempt = 0; attempt <= this.retries; attempt++) {
|
|
66
|
+
try {
|
|
67
|
+
const res = await fetch(url.toString(), {
|
|
68
|
+
headers: { "x-api-key": this.apiKey }
|
|
69
|
+
});
|
|
70
|
+
if (!res.ok) {
|
|
71
|
+
let body;
|
|
72
|
+
try {
|
|
73
|
+
body = await res.json();
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
const err = new ChrtError(res.status, body);
|
|
77
|
+
if (res.status >= 500 && attempt < this.retries) {
|
|
78
|
+
lastError = err;
|
|
79
|
+
await sleep(100 * 2 ** attempt);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
throw err;
|
|
83
|
+
}
|
|
84
|
+
return await res.json();
|
|
85
|
+
} catch (e) {
|
|
86
|
+
if (e instanceof ChrtError) throw e;
|
|
87
|
+
lastError = e;
|
|
88
|
+
if (attempt < this.retries) {
|
|
89
|
+
await sleep(100 * 2 ** attempt);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
throw lastError ?? new Error("CHRT API request failed");
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
function sleep(ms) {
|
|
98
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/endpoints/tiles.ts
|
|
102
|
+
var TilesEndpoint = class {
|
|
103
|
+
constructor(http) {
|
|
104
|
+
this.http = http;
|
|
105
|
+
}
|
|
106
|
+
/** Full style.json URL with API key as query param */
|
|
107
|
+
styleUrl() {
|
|
108
|
+
return `${this.http.getBaseUrl()}/tiles/style.json?key=${this.http.getApiKey()}`;
|
|
109
|
+
}
|
|
110
|
+
/** Individual tile URL template */
|
|
111
|
+
tileUrl(z, x, y, format = "mvt") {
|
|
112
|
+
return `${this.http.getBaseUrl()}/tiles/${z}/${x}/${y}.${format}?key=${this.http.getApiKey()}`;
|
|
113
|
+
}
|
|
114
|
+
/** List available tileset groups */
|
|
115
|
+
async groups() {
|
|
116
|
+
return this.http.request("/tiles/groups");
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/endpoints/cells.ts
|
|
121
|
+
var CellsEndpoint = class {
|
|
122
|
+
constructor(http) {
|
|
123
|
+
this.http = http;
|
|
124
|
+
}
|
|
125
|
+
/** List ENC cells with optional filters */
|
|
126
|
+
async list(options) {
|
|
127
|
+
return this.http.request("/cells", options);
|
|
128
|
+
}
|
|
129
|
+
/** Get a single cell by ID */
|
|
130
|
+
async get(cellId) {
|
|
131
|
+
return this.http.request(`/cells/${encodeURIComponent(cellId)}`);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/endpoints/features.ts
|
|
136
|
+
var FeaturesEndpoint = class {
|
|
137
|
+
constructor(http) {
|
|
138
|
+
this.http = http;
|
|
139
|
+
}
|
|
140
|
+
/** Query features within a bounding box */
|
|
141
|
+
async list(options) {
|
|
142
|
+
return this.http.request("/features", {
|
|
143
|
+
bbox: options.bbox.join(","),
|
|
144
|
+
layer: options.layer,
|
|
145
|
+
limit: options.limit,
|
|
146
|
+
offset: options.offset
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/endpoints/query.ts
|
|
152
|
+
var QueryEndpoint = class {
|
|
153
|
+
constructor(http) {
|
|
154
|
+
this.http = http;
|
|
155
|
+
}
|
|
156
|
+
/** Spatial proximity search around a point */
|
|
157
|
+
async nearby(options) {
|
|
158
|
+
return this.http.request("/query", {
|
|
159
|
+
point: options.point.join(","),
|
|
160
|
+
radius: options.radius,
|
|
161
|
+
layer: options.layer,
|
|
162
|
+
limit: options.limit
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/index.ts
|
|
168
|
+
var Chrt = class {
|
|
169
|
+
/** Tile endpoints — styleUrl, tileUrl, groups */
|
|
170
|
+
tiles;
|
|
171
|
+
/** Cell catalogue endpoints — list, get */
|
|
172
|
+
cells;
|
|
173
|
+
featuresEp;
|
|
174
|
+
queryEp;
|
|
175
|
+
http;
|
|
176
|
+
constructor(apiKeyOrConfig) {
|
|
177
|
+
const config = typeof apiKeyOrConfig === "string" ? { apiKey: apiKeyOrConfig } : apiKeyOrConfig;
|
|
178
|
+
this.http = new HttpClient(config.apiKey, config.baseUrl, config.retries);
|
|
179
|
+
this.tiles = new TilesEndpoint(this.http);
|
|
180
|
+
this.cells = new CellsEndpoint(this.http);
|
|
181
|
+
this.featuresEp = new FeaturesEndpoint(this.http);
|
|
182
|
+
this.queryEp = new QueryEndpoint(this.http);
|
|
183
|
+
}
|
|
184
|
+
/* ── Convenience shortcuts ───────────────────────── */
|
|
185
|
+
/** Query GeoJSON features by bounding box */
|
|
186
|
+
async features(options) {
|
|
187
|
+
return this.featuresEp.list(options);
|
|
188
|
+
}
|
|
189
|
+
/** Spatial proximity query around a point */
|
|
190
|
+
async query(options) {
|
|
191
|
+
return this.queryEp.nearby(options);
|
|
192
|
+
}
|
|
193
|
+
/* ── Map integration helpers ─────────────────────── */
|
|
194
|
+
/** Returns a style.json URL ready for Mapbox GL / MapLibre */
|
|
195
|
+
styleUrl() {
|
|
196
|
+
return this.tiles.styleUrl();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Returns a `transformRequest` function for Mapbox GL JS / MapLibre GL JS.
|
|
200
|
+
* Injects the API key header for requests to api.chrt.co.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* const map = new mapboxgl.Map({
|
|
204
|
+
* style: chrt.styleUrl(),
|
|
205
|
+
* transformRequest: chrt.transformRequest(),
|
|
206
|
+
* });
|
|
207
|
+
*/
|
|
208
|
+
transformRequest() {
|
|
209
|
+
const apiKey = this.http.getApiKey();
|
|
210
|
+
return (url) => {
|
|
211
|
+
if (url.includes("api.chrt.co")) {
|
|
212
|
+
return { url, headers: { "x-api-key": apiKey } };
|
|
213
|
+
}
|
|
214
|
+
return void 0;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
219
|
+
0 && (module.exports = {
|
|
220
|
+
Chrt,
|
|
221
|
+
ChrtError
|
|
222
|
+
});
|
|
223
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/endpoints/tiles.ts","../src/endpoints/cells.ts","../src/endpoints/features.ts","../src/endpoints/query.ts"],"sourcesContent":["import { HttpClient, ChrtError } from \"./client.js\";\nimport { TilesEndpoint } from \"./endpoints/tiles.js\";\nimport { CellsEndpoint } from \"./endpoints/cells.js\";\nimport { FeaturesEndpoint } from \"./endpoints/features.js\";\nimport { QueryEndpoint } from \"./endpoints/query.js\";\nimport type {\n ChrtConfig,\n FeaturesOptions,\n QueryOptions,\n CellsOptions,\n FeatureCollection,\n CellsResponse,\n CellDetail,\n TransformRequest,\n} from \"./types.js\";\n\nexport class Chrt {\n /** Tile endpoints — styleUrl, tileUrl, groups */\n readonly tiles: TilesEndpoint;\n /** Cell catalogue endpoints — list, get */\n readonly cells: CellsEndpoint;\n\n private featuresEp: FeaturesEndpoint;\n private queryEp: QueryEndpoint;\n private http: HttpClient;\n\n constructor(apiKeyOrConfig: string | ChrtConfig) {\n const config =\n typeof apiKeyOrConfig === \"string\"\n ? { apiKey: apiKeyOrConfig }\n : apiKeyOrConfig;\n\n this.http = new HttpClient(config.apiKey, config.baseUrl, config.retries);\n this.tiles = new TilesEndpoint(this.http);\n this.cells = new CellsEndpoint(this.http);\n this.featuresEp = new FeaturesEndpoint(this.http);\n this.queryEp = new QueryEndpoint(this.http);\n }\n\n /* ── Convenience shortcuts ───────────────────────── */\n\n /** Query GeoJSON features by bounding box */\n async features(options: FeaturesOptions): Promise<FeatureCollection> {\n return this.featuresEp.list(options);\n }\n\n /** Spatial proximity query around a point */\n async query(options: QueryOptions): Promise<FeatureCollection> {\n return this.queryEp.nearby(options);\n }\n\n /* ── Map integration helpers ─────────────────────── */\n\n /** Returns a style.json URL ready for Mapbox GL / MapLibre */\n styleUrl(): string {\n return this.tiles.styleUrl();\n }\n\n /**\n * Returns a `transformRequest` function for Mapbox GL JS / MapLibre GL JS.\n * Injects the API key header for requests to api.chrt.co.\n *\n * @example\n * const map = new mapboxgl.Map({\n * style: chrt.styleUrl(),\n * transformRequest: chrt.transformRequest(),\n * });\n */\n transformRequest(): (url: string) => TransformRequest | undefined {\n const apiKey = this.http.getApiKey();\n return (url: string) => {\n if (url.includes(\"api.chrt.co\")) {\n return { url, headers: { \"x-api-key\": apiKey } };\n }\n return undefined;\n };\n }\n}\n\n/* ── Re-exports ────────────────────────────────────── */\n\nexport { ChrtError } from \"./client.js\";\nexport type {\n ChrtConfig,\n FeaturesOptions,\n QueryOptions,\n CellsOptions,\n FeatureCollection,\n GeoJsonFeature,\n GeoJsonGeometry,\n CellsResponse,\n CellDetail,\n TileGroup,\n TileGroupsResponse,\n TransformRequest,\n} from \"./types.js\";\n","import type { ChrtErrorBody } from \"./types.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.chrt.co/v1\";\n\nexport class ChrtError extends Error {\n status: number;\n code?: string;\n body?: ChrtErrorBody;\n\n constructor(status: number, body?: ChrtErrorBody) {\n super(body?.message ?? body?.error ?? `CHRT API error ${status}`);\n this.name = \"ChrtError\";\n this.status = status;\n this.code = body?.code;\n this.body = body;\n }\n}\n\nexport class HttpClient {\n private apiKey: string;\n private baseUrl: string;\n private retries: number;\n\n constructor(apiKey: string, baseUrl?: string, retries = 2) {\n this.apiKey = apiKey;\n this.baseUrl = (baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.retries = retries;\n }\n\n getBaseUrl(): string {\n return this.baseUrl;\n }\n\n getApiKey(): string {\n return this.apiKey;\n }\n\n async request<T>(path: string, params?: Record<string, string | number | undefined>): Promise<T> {\n const url = new URL(`${this.baseUrl}${path}`);\n if (params) {\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) url.searchParams.set(k, String(v));\n }\n }\n\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt <= this.retries; attempt++) {\n try {\n const res = await fetch(url.toString(), {\n headers: { \"x-api-key\": this.apiKey },\n });\n\n if (!res.ok) {\n let body: ChrtErrorBody | undefined;\n try {\n body = await res.json() as ChrtErrorBody;\n } catch {\n /* empty */\n }\n const err = new ChrtError(res.status, body);\n\n // Only retry on 5xx\n if (res.status >= 500 && attempt < this.retries) {\n lastError = err;\n await sleep(100 * 2 ** attempt);\n continue;\n }\n throw err;\n }\n\n return (await res.json()) as T;\n } catch (e) {\n if (e instanceof ChrtError) throw e;\n lastError = e as Error;\n if (attempt < this.retries) {\n await sleep(100 * 2 ** attempt);\n continue;\n }\n }\n }\n\n throw lastError ?? new Error(\"CHRT API request failed\");\n }\n}\n\nfunction sleep(ms: number) {\n return new Promise((r) => setTimeout(r, ms));\n}\n","import type { HttpClient } from \"../client.js\";\nimport type { TileGroupsResponse } from \"../types.js\";\n\nexport class TilesEndpoint {\n constructor(private http: HttpClient) {}\n\n /** Full style.json URL with API key as query param */\n styleUrl(): string {\n return `${this.http.getBaseUrl()}/tiles/style.json?key=${this.http.getApiKey()}`;\n }\n\n /** Individual tile URL template */\n tileUrl(z: number, x: number, y: number, format: \"pbf\" | \"mvt\" = \"mvt\"): string {\n return `${this.http.getBaseUrl()}/tiles/${z}/${x}/${y}.${format}?key=${this.http.getApiKey()}`;\n }\n\n /** List available tileset groups */\n async groups(): Promise<TileGroupsResponse> {\n return this.http.request<TileGroupsResponse>(\"/tiles/groups\");\n }\n}\n","import type { HttpClient } from \"../client.js\";\nimport type { CellsOptions, CellsResponse, CellDetail } from \"../types.js\";\n\nexport class CellsEndpoint {\n constructor(private http: HttpClient) {}\n\n /** List ENC cells with optional filters */\n async list(options?: CellsOptions): Promise<CellsResponse> {\n return this.http.request<CellsResponse>(\"/cells\", options as Record<string, string | number | undefined>);\n }\n\n /** Get a single cell by ID */\n async get(cellId: string): Promise<CellDetail> {\n return this.http.request<CellDetail>(`/cells/${encodeURIComponent(cellId)}`);\n }\n}\n","import type { HttpClient } from \"../client.js\";\nimport type { FeaturesOptions, FeatureCollection } from \"../types.js\";\n\nexport class FeaturesEndpoint {\n constructor(private http: HttpClient) {}\n\n /** Query features within a bounding box */\n async list(options: FeaturesOptions): Promise<FeatureCollection> {\n return this.http.request<FeatureCollection>(\"/features\", {\n bbox: options.bbox.join(\",\"),\n layer: options.layer,\n limit: options.limit,\n offset: options.offset,\n });\n }\n}\n","import type { HttpClient } from \"../client.js\";\nimport type { QueryOptions, FeatureCollection } from \"../types.js\";\n\nexport class QueryEndpoint {\n constructor(private http: HttpClient) {}\n\n /** Spatial proximity search around a point */\n async nearby(options: QueryOptions): Promise<FeatureCollection> {\n return this.http.request<FeatureCollection>(\"/query\", {\n point: options.point.join(\",\"),\n radius: options.radius,\n layer: options.layer,\n limit: options.limit,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,mBAAmB;AAElB,IAAM,YAAN,cAAwB,MAAM;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,QAAgB,MAAsB;AAChD,UAAM,MAAM,WAAW,MAAM,SAAS,kBAAkB,MAAM,EAAE;AAChE,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO,MAAM;AAClB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,aAAN,MAAiB;AAAA,EACd;AAAA,EACA;AA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;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
interface GeoJsonGeometry {
|
|
2
|
+
type: string;
|
|
3
|
+
coordinates: unknown;
|
|
4
|
+
}
|
|
5
|
+
interface GeoJsonFeature<P = Record<string, unknown>> {
|
|
6
|
+
type: "Feature";
|
|
7
|
+
geometry: GeoJsonGeometry;
|
|
8
|
+
properties: P;
|
|
9
|
+
}
|
|
10
|
+
interface FeatureCollection<P = Record<string, unknown>> {
|
|
11
|
+
type: "FeatureCollection";
|
|
12
|
+
features: GeoJsonFeature<P>[];
|
|
13
|
+
total_count?: number;
|
|
14
|
+
limit?: number;
|
|
15
|
+
offset?: number;
|
|
16
|
+
}
|
|
17
|
+
interface FeaturesOptions {
|
|
18
|
+
/** Bounding box as [west, south, east, north] */
|
|
19
|
+
bbox: [number, number, number, number];
|
|
20
|
+
/** S-57 layer code, e.g. "DEPARE", "LIGHTS" */
|
|
21
|
+
layer?: string;
|
|
22
|
+
/** Max features to return (default 100) */
|
|
23
|
+
limit?: number;
|
|
24
|
+
/** Pagination offset */
|
|
25
|
+
offset?: number;
|
|
26
|
+
}
|
|
27
|
+
interface QueryOptions {
|
|
28
|
+
/** [longitude, latitude] */
|
|
29
|
+
point: [number, number];
|
|
30
|
+
/** Search radius in metres (default 1000) */
|
|
31
|
+
radius?: number;
|
|
32
|
+
/** Comma-separated layer codes */
|
|
33
|
+
layer?: string;
|
|
34
|
+
limit?: number;
|
|
35
|
+
}
|
|
36
|
+
interface CellsOptions {
|
|
37
|
+
/** Filter by chart source, e.g. "NOAA" */
|
|
38
|
+
source?: string;
|
|
39
|
+
/** Filter by status */
|
|
40
|
+
status?: string;
|
|
41
|
+
limit?: number;
|
|
42
|
+
offset?: number;
|
|
43
|
+
}
|
|
44
|
+
interface CellDetail {
|
|
45
|
+
cell_id: string;
|
|
46
|
+
title: string | null;
|
|
47
|
+
chart_source: string;
|
|
48
|
+
status: string;
|
|
49
|
+
scale: number | null;
|
|
50
|
+
scale_band: string | null;
|
|
51
|
+
edition: number | null;
|
|
52
|
+
update_number: number | null;
|
|
53
|
+
issue_date: string | null;
|
|
54
|
+
bbox_north: number | null;
|
|
55
|
+
bbox_south: number | null;
|
|
56
|
+
bbox_east: number | null;
|
|
57
|
+
bbox_west: number | null;
|
|
58
|
+
}
|
|
59
|
+
interface CellsResponse {
|
|
60
|
+
cells: CellDetail[];
|
|
61
|
+
total_count: number;
|
|
62
|
+
limit: number;
|
|
63
|
+
offset: number;
|
|
64
|
+
}
|
|
65
|
+
interface TileGroup {
|
|
66
|
+
id: string;
|
|
67
|
+
display_name: string;
|
|
68
|
+
tileset_id: string;
|
|
69
|
+
layer_names: string[];
|
|
70
|
+
}
|
|
71
|
+
interface TileGroupsResponse {
|
|
72
|
+
groups: TileGroup[];
|
|
73
|
+
}
|
|
74
|
+
interface TransformRequest {
|
|
75
|
+
url: string;
|
|
76
|
+
headers: Record<string, string>;
|
|
77
|
+
}
|
|
78
|
+
interface ChrtErrorBody {
|
|
79
|
+
error: string;
|
|
80
|
+
code?: string;
|
|
81
|
+
message?: string;
|
|
82
|
+
}
|
|
83
|
+
interface ChrtConfig {
|
|
84
|
+
/** API key (chrt_live_… or chrt_test_…) */
|
|
85
|
+
apiKey: string;
|
|
86
|
+
/** Override base URL (default https://api.chrt.co/v1) */
|
|
87
|
+
baseUrl?: string;
|
|
88
|
+
/** Max retries on 5xx/network errors (default 2) */
|
|
89
|
+
retries?: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
declare class ChrtError extends Error {
|
|
93
|
+
status: number;
|
|
94
|
+
code?: string;
|
|
95
|
+
body?: ChrtErrorBody;
|
|
96
|
+
constructor(status: number, body?: ChrtErrorBody);
|
|
97
|
+
}
|
|
98
|
+
declare class HttpClient {
|
|
99
|
+
private apiKey;
|
|
100
|
+
private baseUrl;
|
|
101
|
+
private retries;
|
|
102
|
+
constructor(apiKey: string, baseUrl?: string, retries?: number);
|
|
103
|
+
getBaseUrl(): string;
|
|
104
|
+
getApiKey(): string;
|
|
105
|
+
request<T>(path: string, params?: Record<string, string | number | undefined>): Promise<T>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class TilesEndpoint {
|
|
109
|
+
private http;
|
|
110
|
+
constructor(http: HttpClient);
|
|
111
|
+
/** Full style.json URL with API key as query param */
|
|
112
|
+
styleUrl(): string;
|
|
113
|
+
/** Individual tile URL template */
|
|
114
|
+
tileUrl(z: number, x: number, y: number, format?: "pbf" | "mvt"): string;
|
|
115
|
+
/** List available tileset groups */
|
|
116
|
+
groups(): Promise<TileGroupsResponse>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare class CellsEndpoint {
|
|
120
|
+
private http;
|
|
121
|
+
constructor(http: HttpClient);
|
|
122
|
+
/** List ENC cells with optional filters */
|
|
123
|
+
list(options?: CellsOptions): Promise<CellsResponse>;
|
|
124
|
+
/** Get a single cell by ID */
|
|
125
|
+
get(cellId: string): Promise<CellDetail>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
declare class Chrt {
|
|
129
|
+
/** Tile endpoints — styleUrl, tileUrl, groups */
|
|
130
|
+
readonly tiles: TilesEndpoint;
|
|
131
|
+
/** Cell catalogue endpoints — list, get */
|
|
132
|
+
readonly cells: CellsEndpoint;
|
|
133
|
+
private featuresEp;
|
|
134
|
+
private queryEp;
|
|
135
|
+
private http;
|
|
136
|
+
constructor(apiKeyOrConfig: string | ChrtConfig);
|
|
137
|
+
/** Query GeoJSON features by bounding box */
|
|
138
|
+
features(options: FeaturesOptions): Promise<FeatureCollection>;
|
|
139
|
+
/** Spatial proximity query around a point */
|
|
140
|
+
query(options: QueryOptions): Promise<FeatureCollection>;
|
|
141
|
+
/** Returns a style.json URL ready for Mapbox GL / MapLibre */
|
|
142
|
+
styleUrl(): string;
|
|
143
|
+
/**
|
|
144
|
+
* Returns a `transformRequest` function for Mapbox GL JS / MapLibre GL JS.
|
|
145
|
+
* Injects the API key header for requests to api.chrt.co.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* const map = new mapboxgl.Map({
|
|
149
|
+
* style: chrt.styleUrl(),
|
|
150
|
+
* transformRequest: chrt.transformRequest(),
|
|
151
|
+
* });
|
|
152
|
+
*/
|
|
153
|
+
transformRequest(): (url: string) => TransformRequest | undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export { type CellDetail, type CellsOptions, type CellsResponse, Chrt, type ChrtConfig, ChrtError, type FeatureCollection, type FeaturesOptions, type GeoJsonFeature, type GeoJsonGeometry, type QueryOptions, type TileGroup, type TileGroupsResponse, type TransformRequest };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
interface GeoJsonGeometry {
|
|
2
|
+
type: string;
|
|
3
|
+
coordinates: unknown;
|
|
4
|
+
}
|
|
5
|
+
interface GeoJsonFeature<P = Record<string, unknown>> {
|
|
6
|
+
type: "Feature";
|
|
7
|
+
geometry: GeoJsonGeometry;
|
|
8
|
+
properties: P;
|
|
9
|
+
}
|
|
10
|
+
interface FeatureCollection<P = Record<string, unknown>> {
|
|
11
|
+
type: "FeatureCollection";
|
|
12
|
+
features: GeoJsonFeature<P>[];
|
|
13
|
+
total_count?: number;
|
|
14
|
+
limit?: number;
|
|
15
|
+
offset?: number;
|
|
16
|
+
}
|
|
17
|
+
interface FeaturesOptions {
|
|
18
|
+
/** Bounding box as [west, south, east, north] */
|
|
19
|
+
bbox: [number, number, number, number];
|
|
20
|
+
/** S-57 layer code, e.g. "DEPARE", "LIGHTS" */
|
|
21
|
+
layer?: string;
|
|
22
|
+
/** Max features to return (default 100) */
|
|
23
|
+
limit?: number;
|
|
24
|
+
/** Pagination offset */
|
|
25
|
+
offset?: number;
|
|
26
|
+
}
|
|
27
|
+
interface QueryOptions {
|
|
28
|
+
/** [longitude, latitude] */
|
|
29
|
+
point: [number, number];
|
|
30
|
+
/** Search radius in metres (default 1000) */
|
|
31
|
+
radius?: number;
|
|
32
|
+
/** Comma-separated layer codes */
|
|
33
|
+
layer?: string;
|
|
34
|
+
limit?: number;
|
|
35
|
+
}
|
|
36
|
+
interface CellsOptions {
|
|
37
|
+
/** Filter by chart source, e.g. "NOAA" */
|
|
38
|
+
source?: string;
|
|
39
|
+
/** Filter by status */
|
|
40
|
+
status?: string;
|
|
41
|
+
limit?: number;
|
|
42
|
+
offset?: number;
|
|
43
|
+
}
|
|
44
|
+
interface CellDetail {
|
|
45
|
+
cell_id: string;
|
|
46
|
+
title: string | null;
|
|
47
|
+
chart_source: string;
|
|
48
|
+
status: string;
|
|
49
|
+
scale: number | null;
|
|
50
|
+
scale_band: string | null;
|
|
51
|
+
edition: number | null;
|
|
52
|
+
update_number: number | null;
|
|
53
|
+
issue_date: string | null;
|
|
54
|
+
bbox_north: number | null;
|
|
55
|
+
bbox_south: number | null;
|
|
56
|
+
bbox_east: number | null;
|
|
57
|
+
bbox_west: number | null;
|
|
58
|
+
}
|
|
59
|
+
interface CellsResponse {
|
|
60
|
+
cells: CellDetail[];
|
|
61
|
+
total_count: number;
|
|
62
|
+
limit: number;
|
|
63
|
+
offset: number;
|
|
64
|
+
}
|
|
65
|
+
interface TileGroup {
|
|
66
|
+
id: string;
|
|
67
|
+
display_name: string;
|
|
68
|
+
tileset_id: string;
|
|
69
|
+
layer_names: string[];
|
|
70
|
+
}
|
|
71
|
+
interface TileGroupsResponse {
|
|
72
|
+
groups: TileGroup[];
|
|
73
|
+
}
|
|
74
|
+
interface TransformRequest {
|
|
75
|
+
url: string;
|
|
76
|
+
headers: Record<string, string>;
|
|
77
|
+
}
|
|
78
|
+
interface ChrtErrorBody {
|
|
79
|
+
error: string;
|
|
80
|
+
code?: string;
|
|
81
|
+
message?: string;
|
|
82
|
+
}
|
|
83
|
+
interface ChrtConfig {
|
|
84
|
+
/** API key (chrt_live_… or chrt_test_…) */
|
|
85
|
+
apiKey: string;
|
|
86
|
+
/** Override base URL (default https://api.chrt.co/v1) */
|
|
87
|
+
baseUrl?: string;
|
|
88
|
+
/** Max retries on 5xx/network errors (default 2) */
|
|
89
|
+
retries?: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
declare class ChrtError extends Error {
|
|
93
|
+
status: number;
|
|
94
|
+
code?: string;
|
|
95
|
+
body?: ChrtErrorBody;
|
|
96
|
+
constructor(status: number, body?: ChrtErrorBody);
|
|
97
|
+
}
|
|
98
|
+
declare class HttpClient {
|
|
99
|
+
private apiKey;
|
|
100
|
+
private baseUrl;
|
|
101
|
+
private retries;
|
|
102
|
+
constructor(apiKey: string, baseUrl?: string, retries?: number);
|
|
103
|
+
getBaseUrl(): string;
|
|
104
|
+
getApiKey(): string;
|
|
105
|
+
request<T>(path: string, params?: Record<string, string | number | undefined>): Promise<T>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class TilesEndpoint {
|
|
109
|
+
private http;
|
|
110
|
+
constructor(http: HttpClient);
|
|
111
|
+
/** Full style.json URL with API key as query param */
|
|
112
|
+
styleUrl(): string;
|
|
113
|
+
/** Individual tile URL template */
|
|
114
|
+
tileUrl(z: number, x: number, y: number, format?: "pbf" | "mvt"): string;
|
|
115
|
+
/** List available tileset groups */
|
|
116
|
+
groups(): Promise<TileGroupsResponse>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare class CellsEndpoint {
|
|
120
|
+
private http;
|
|
121
|
+
constructor(http: HttpClient);
|
|
122
|
+
/** List ENC cells with optional filters */
|
|
123
|
+
list(options?: CellsOptions): Promise<CellsResponse>;
|
|
124
|
+
/** Get a single cell by ID */
|
|
125
|
+
get(cellId: string): Promise<CellDetail>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
declare class Chrt {
|
|
129
|
+
/** Tile endpoints — styleUrl, tileUrl, groups */
|
|
130
|
+
readonly tiles: TilesEndpoint;
|
|
131
|
+
/** Cell catalogue endpoints — list, get */
|
|
132
|
+
readonly cells: CellsEndpoint;
|
|
133
|
+
private featuresEp;
|
|
134
|
+
private queryEp;
|
|
135
|
+
private http;
|
|
136
|
+
constructor(apiKeyOrConfig: string | ChrtConfig);
|
|
137
|
+
/** Query GeoJSON features by bounding box */
|
|
138
|
+
features(options: FeaturesOptions): Promise<FeatureCollection>;
|
|
139
|
+
/** Spatial proximity query around a point */
|
|
140
|
+
query(options: QueryOptions): Promise<FeatureCollection>;
|
|
141
|
+
/** Returns a style.json URL ready for Mapbox GL / MapLibre */
|
|
142
|
+
styleUrl(): string;
|
|
143
|
+
/**
|
|
144
|
+
* Returns a `transformRequest` function for Mapbox GL JS / MapLibre GL JS.
|
|
145
|
+
* Injects the API key header for requests to api.chrt.co.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* const map = new mapboxgl.Map({
|
|
149
|
+
* style: chrt.styleUrl(),
|
|
150
|
+
* transformRequest: chrt.transformRequest(),
|
|
151
|
+
* });
|
|
152
|
+
*/
|
|
153
|
+
transformRequest(): (url: string) => TransformRequest | undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export { type CellDetail, type CellsOptions, type CellsResponse, Chrt, type ChrtConfig, ChrtError, type FeatureCollection, type FeaturesOptions, type GeoJsonFeature, type GeoJsonGeometry, type QueryOptions, type TileGroup, type TileGroupsResponse, type TransformRequest };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
var DEFAULT_BASE_URL = "https://api.chrt.co/v1";
|
|
3
|
+
var ChrtError = class extends Error {
|
|
4
|
+
status;
|
|
5
|
+
code;
|
|
6
|
+
body;
|
|
7
|
+
constructor(status, body) {
|
|
8
|
+
super(body?.message ?? body?.error ?? `CHRT API error ${status}`);
|
|
9
|
+
this.name = "ChrtError";
|
|
10
|
+
this.status = status;
|
|
11
|
+
this.code = body?.code;
|
|
12
|
+
this.body = body;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var HttpClient = class {
|
|
16
|
+
apiKey;
|
|
17
|
+
baseUrl;
|
|
18
|
+
retries;
|
|
19
|
+
constructor(apiKey, baseUrl, retries = 2) {
|
|
20
|
+
this.apiKey = apiKey;
|
|
21
|
+
this.baseUrl = (baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
22
|
+
this.retries = retries;
|
|
23
|
+
}
|
|
24
|
+
getBaseUrl() {
|
|
25
|
+
return this.baseUrl;
|
|
26
|
+
}
|
|
27
|
+
getApiKey() {
|
|
28
|
+
return this.apiKey;
|
|
29
|
+
}
|
|
30
|
+
async request(path, params) {
|
|
31
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
32
|
+
if (params) {
|
|
33
|
+
for (const [k, v] of Object.entries(params)) {
|
|
34
|
+
if (v !== void 0) url.searchParams.set(k, String(v));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
let lastError = null;
|
|
38
|
+
for (let attempt = 0; attempt <= this.retries; attempt++) {
|
|
39
|
+
try {
|
|
40
|
+
const res = await fetch(url.toString(), {
|
|
41
|
+
headers: { "x-api-key": this.apiKey }
|
|
42
|
+
});
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
let body;
|
|
45
|
+
try {
|
|
46
|
+
body = await res.json();
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
const err = new ChrtError(res.status, body);
|
|
50
|
+
if (res.status >= 500 && attempt < this.retries) {
|
|
51
|
+
lastError = err;
|
|
52
|
+
await sleep(100 * 2 ** attempt);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
return await res.json();
|
|
58
|
+
} catch (e) {
|
|
59
|
+
if (e instanceof ChrtError) throw e;
|
|
60
|
+
lastError = e;
|
|
61
|
+
if (attempt < this.retries) {
|
|
62
|
+
await sleep(100 * 2 ** attempt);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw lastError ?? new Error("CHRT API request failed");
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function sleep(ms) {
|
|
71
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/endpoints/tiles.ts
|
|
75
|
+
var TilesEndpoint = class {
|
|
76
|
+
constructor(http) {
|
|
77
|
+
this.http = http;
|
|
78
|
+
}
|
|
79
|
+
/** Full style.json URL with API key as query param */
|
|
80
|
+
styleUrl() {
|
|
81
|
+
return `${this.http.getBaseUrl()}/tiles/style.json?key=${this.http.getApiKey()}`;
|
|
82
|
+
}
|
|
83
|
+
/** Individual tile URL template */
|
|
84
|
+
tileUrl(z, x, y, format = "mvt") {
|
|
85
|
+
return `${this.http.getBaseUrl()}/tiles/${z}/${x}/${y}.${format}?key=${this.http.getApiKey()}`;
|
|
86
|
+
}
|
|
87
|
+
/** List available tileset groups */
|
|
88
|
+
async groups() {
|
|
89
|
+
return this.http.request("/tiles/groups");
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// src/endpoints/cells.ts
|
|
94
|
+
var CellsEndpoint = class {
|
|
95
|
+
constructor(http) {
|
|
96
|
+
this.http = http;
|
|
97
|
+
}
|
|
98
|
+
/** List ENC cells with optional filters */
|
|
99
|
+
async list(options) {
|
|
100
|
+
return this.http.request("/cells", options);
|
|
101
|
+
}
|
|
102
|
+
/** Get a single cell by ID */
|
|
103
|
+
async get(cellId) {
|
|
104
|
+
return this.http.request(`/cells/${encodeURIComponent(cellId)}`);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// src/endpoints/features.ts
|
|
109
|
+
var FeaturesEndpoint = class {
|
|
110
|
+
constructor(http) {
|
|
111
|
+
this.http = http;
|
|
112
|
+
}
|
|
113
|
+
/** Query features within a bounding box */
|
|
114
|
+
async list(options) {
|
|
115
|
+
return this.http.request("/features", {
|
|
116
|
+
bbox: options.bbox.join(","),
|
|
117
|
+
layer: options.layer,
|
|
118
|
+
limit: options.limit,
|
|
119
|
+
offset: options.offset
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// src/endpoints/query.ts
|
|
125
|
+
var QueryEndpoint = class {
|
|
126
|
+
constructor(http) {
|
|
127
|
+
this.http = http;
|
|
128
|
+
}
|
|
129
|
+
/** Spatial proximity search around a point */
|
|
130
|
+
async nearby(options) {
|
|
131
|
+
return this.http.request("/query", {
|
|
132
|
+
point: options.point.join(","),
|
|
133
|
+
radius: options.radius,
|
|
134
|
+
layer: options.layer,
|
|
135
|
+
limit: options.limit
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// src/index.ts
|
|
141
|
+
var Chrt = class {
|
|
142
|
+
/** Tile endpoints — styleUrl, tileUrl, groups */
|
|
143
|
+
tiles;
|
|
144
|
+
/** Cell catalogue endpoints — list, get */
|
|
145
|
+
cells;
|
|
146
|
+
featuresEp;
|
|
147
|
+
queryEp;
|
|
148
|
+
http;
|
|
149
|
+
constructor(apiKeyOrConfig) {
|
|
150
|
+
const config = typeof apiKeyOrConfig === "string" ? { apiKey: apiKeyOrConfig } : apiKeyOrConfig;
|
|
151
|
+
this.http = new HttpClient(config.apiKey, config.baseUrl, config.retries);
|
|
152
|
+
this.tiles = new TilesEndpoint(this.http);
|
|
153
|
+
this.cells = new CellsEndpoint(this.http);
|
|
154
|
+
this.featuresEp = new FeaturesEndpoint(this.http);
|
|
155
|
+
this.queryEp = new QueryEndpoint(this.http);
|
|
156
|
+
}
|
|
157
|
+
/* ── Convenience shortcuts ───────────────────────── */
|
|
158
|
+
/** Query GeoJSON features by bounding box */
|
|
159
|
+
async features(options) {
|
|
160
|
+
return this.featuresEp.list(options);
|
|
161
|
+
}
|
|
162
|
+
/** Spatial proximity query around a point */
|
|
163
|
+
async query(options) {
|
|
164
|
+
return this.queryEp.nearby(options);
|
|
165
|
+
}
|
|
166
|
+
/* ── Map integration helpers ─────────────────────── */
|
|
167
|
+
/** Returns a style.json URL ready for Mapbox GL / MapLibre */
|
|
168
|
+
styleUrl() {
|
|
169
|
+
return this.tiles.styleUrl();
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Returns a `transformRequest` function for Mapbox GL JS / MapLibre GL JS.
|
|
173
|
+
* Injects the API key header for requests to api.chrt.co.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* const map = new mapboxgl.Map({
|
|
177
|
+
* style: chrt.styleUrl(),
|
|
178
|
+
* transformRequest: chrt.transformRequest(),
|
|
179
|
+
* });
|
|
180
|
+
*/
|
|
181
|
+
transformRequest() {
|
|
182
|
+
const apiKey = this.http.getApiKey();
|
|
183
|
+
return (url) => {
|
|
184
|
+
if (url.includes("api.chrt.co")) {
|
|
185
|
+
return { url, headers: { "x-api-key": apiKey } };
|
|
186
|
+
}
|
|
187
|
+
return void 0;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
export {
|
|
192
|
+
Chrt,
|
|
193
|
+
ChrtError
|
|
194
|
+
};
|
|
195
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/endpoints/tiles.ts","../src/endpoints/cells.ts","../src/endpoints/features.ts","../src/endpoints/query.ts","../src/index.ts"],"sourcesContent":["import type { ChrtErrorBody } from \"./types.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.chrt.co/v1\";\n\nexport class ChrtError extends Error {\n status: number;\n code?: string;\n body?: ChrtErrorBody;\n\n constructor(status: number, body?: ChrtErrorBody) {\n super(body?.message ?? body?.error ?? `CHRT API error ${status}`);\n this.name = \"ChrtError\";\n this.status = status;\n this.code = body?.code;\n this.body = body;\n }\n}\n\nexport class HttpClient {\n private apiKey: string;\n private baseUrl: string;\n private retries: number;\n\n constructor(apiKey: string, baseUrl?: string, retries = 2) {\n this.apiKey = apiKey;\n this.baseUrl = (baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.retries = retries;\n }\n\n getBaseUrl(): string {\n return this.baseUrl;\n }\n\n getApiKey(): string {\n return this.apiKey;\n }\n\n async request<T>(path: string, params?: Record<string, string | number | undefined>): Promise<T> {\n const url = new URL(`${this.baseUrl}${path}`);\n if (params) {\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) url.searchParams.set(k, String(v));\n }\n }\n\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt <= this.retries; attempt++) {\n try {\n const res = await fetch(url.toString(), {\n headers: { \"x-api-key\": this.apiKey },\n });\n\n if (!res.ok) {\n let body: ChrtErrorBody | undefined;\n try {\n body = await res.json() as ChrtErrorBody;\n } catch {\n /* empty */\n }\n const err = new ChrtError(res.status, body);\n\n // Only retry on 5xx\n if (res.status >= 500 && attempt < this.retries) {\n lastError = err;\n await sleep(100 * 2 ** attempt);\n continue;\n }\n throw err;\n }\n\n return (await res.json()) as T;\n } catch (e) {\n if (e instanceof ChrtError) throw e;\n lastError = e as Error;\n if (attempt < this.retries) {\n await sleep(100 * 2 ** attempt);\n continue;\n }\n }\n }\n\n throw lastError ?? new Error(\"CHRT API request failed\");\n }\n}\n\nfunction sleep(ms: number) {\n return new Promise((r) => setTimeout(r, ms));\n}\n","import type { HttpClient } from \"../client.js\";\nimport type { TileGroupsResponse } from \"../types.js\";\n\nexport class TilesEndpoint {\n constructor(private http: HttpClient) {}\n\n /** Full style.json URL with API key as query param */\n styleUrl(): string {\n return `${this.http.getBaseUrl()}/tiles/style.json?key=${this.http.getApiKey()}`;\n }\n\n /** Individual tile URL template */\n tileUrl(z: number, x: number, y: number, format: \"pbf\" | \"mvt\" = \"mvt\"): string {\n return `${this.http.getBaseUrl()}/tiles/${z}/${x}/${y}.${format}?key=${this.http.getApiKey()}`;\n }\n\n /** List available tileset groups */\n async groups(): Promise<TileGroupsResponse> {\n return this.http.request<TileGroupsResponse>(\"/tiles/groups\");\n }\n}\n","import type { HttpClient } from \"../client.js\";\nimport type { CellsOptions, CellsResponse, CellDetail } from \"../types.js\";\n\nexport class CellsEndpoint {\n constructor(private http: HttpClient) {}\n\n /** List ENC cells with optional filters */\n async list(options?: CellsOptions): Promise<CellsResponse> {\n return this.http.request<CellsResponse>(\"/cells\", options as Record<string, string | number | undefined>);\n }\n\n /** Get a single cell by ID */\n async get(cellId: string): Promise<CellDetail> {\n return this.http.request<CellDetail>(`/cells/${encodeURIComponent(cellId)}`);\n }\n}\n","import type { HttpClient } from \"../client.js\";\nimport type { FeaturesOptions, FeatureCollection } from \"../types.js\";\n\nexport class FeaturesEndpoint {\n constructor(private http: HttpClient) {}\n\n /** Query features within a bounding box */\n async list(options: FeaturesOptions): Promise<FeatureCollection> {\n return this.http.request<FeatureCollection>(\"/features\", {\n bbox: options.bbox.join(\",\"),\n layer: options.layer,\n limit: options.limit,\n offset: options.offset,\n });\n }\n}\n","import type { HttpClient } from \"../client.js\";\nimport type { QueryOptions, FeatureCollection } from \"../types.js\";\n\nexport class QueryEndpoint {\n constructor(private http: HttpClient) {}\n\n /** Spatial proximity search around a point */\n async nearby(options: QueryOptions): Promise<FeatureCollection> {\n return this.http.request<FeatureCollection>(\"/query\", {\n point: options.point.join(\",\"),\n radius: options.radius,\n layer: options.layer,\n limit: options.limit,\n });\n }\n}\n","import { HttpClient, ChrtError } from \"./client.js\";\nimport { TilesEndpoint } from \"./endpoints/tiles.js\";\nimport { CellsEndpoint } from \"./endpoints/cells.js\";\nimport { FeaturesEndpoint } from \"./endpoints/features.js\";\nimport { QueryEndpoint } from \"./endpoints/query.js\";\nimport type {\n ChrtConfig,\n FeaturesOptions,\n QueryOptions,\n CellsOptions,\n FeatureCollection,\n CellsResponse,\n CellDetail,\n TransformRequest,\n} from \"./types.js\";\n\nexport class Chrt {\n /** Tile endpoints — styleUrl, tileUrl, groups */\n readonly tiles: TilesEndpoint;\n /** Cell catalogue endpoints — list, get */\n readonly cells: CellsEndpoint;\n\n private featuresEp: FeaturesEndpoint;\n private queryEp: QueryEndpoint;\n private http: HttpClient;\n\n constructor(apiKeyOrConfig: string | ChrtConfig) {\n const config =\n typeof apiKeyOrConfig === \"string\"\n ? { apiKey: apiKeyOrConfig }\n : apiKeyOrConfig;\n\n this.http = new HttpClient(config.apiKey, config.baseUrl, config.retries);\n this.tiles = new TilesEndpoint(this.http);\n this.cells = new CellsEndpoint(this.http);\n this.featuresEp = new FeaturesEndpoint(this.http);\n this.queryEp = new QueryEndpoint(this.http);\n }\n\n /* ── Convenience shortcuts ───────────────────────── */\n\n /** Query GeoJSON features by bounding box */\n async features(options: FeaturesOptions): Promise<FeatureCollection> {\n return this.featuresEp.list(options);\n }\n\n /** Spatial proximity query around a point */\n async query(options: QueryOptions): Promise<FeatureCollection> {\n return this.queryEp.nearby(options);\n }\n\n /* ── Map integration helpers ─────────────────────── */\n\n /** Returns a style.json URL ready for Mapbox GL / MapLibre */\n styleUrl(): string {\n return this.tiles.styleUrl();\n }\n\n /**\n * Returns a `transformRequest` function for Mapbox GL JS / MapLibre GL JS.\n * Injects the API key header for requests to api.chrt.co.\n *\n * @example\n * const map = new mapboxgl.Map({\n * style: chrt.styleUrl(),\n * transformRequest: chrt.transformRequest(),\n * });\n */\n transformRequest(): (url: string) => TransformRequest | undefined {\n const apiKey = this.http.getApiKey();\n return (url: string) => {\n if (url.includes(\"api.chrt.co\")) {\n return { url, headers: { \"x-api-key\": apiKey } };\n }\n return undefined;\n };\n }\n}\n\n/* ── Re-exports ────────────────────────────────────── */\n\nexport { ChrtError } from \"./client.js\";\nexport type {\n ChrtConfig,\n FeaturesOptions,\n QueryOptions,\n CellsOptions,\n FeatureCollection,\n GeoJsonFeature,\n GeoJsonGeometry,\n CellsResponse,\n CellDetail,\n TileGroup,\n TileGroupsResponse,\n TransformRequest,\n} from \"./types.js\";\n"],"mappings":";AAEA,IAAM,mBAAmB;AAElB,IAAM,YAAN,cAAwB,MAAM;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EAEA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;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,mBAAkE;AAChE,UAAM,SAAS,KAAK,KAAK,UAAU;AACnC,WAAO,CAAC,QAAgB;AACtB,UAAI,IAAI,SAAS,aAAa,GAAG;AAC/B,eAAO,EAAE,KAAK,SAAS,EAAE,aAAa,OAAO,EAAE;AAAA,MACjD;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chrtco/sdk",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "Official TypeScript SDK for the CHRT nautical chart API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": ["dist", "README.md"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"dev": "tsup --watch",
|
|
20
|
+
"typecheck": "tsc --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"keywords": ["chrt", "nautical", "charts", "maritime", "enc", "s57", "mapbox", "maplibre", "gis", "api"],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/chrt-co/enc-hub",
|
|
27
|
+
"directory": "packages/sdk"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://chrt.co/docs/sdks",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"tsup": "^8.0.0",
|
|
32
|
+
"typescript": "^5.4.0"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|