@ibicash/geolayers-sdk 1.0.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/dist/index.cjs +1037 -0
- package/dist/index.d.cts +1002 -0
- package/dist/index.d.ts +1002 -0
- package/dist/index.js +972 -0
- package/package.json +58 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1037 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
ActiveVolcanoPropsSchema: () => ActiveVolcanoPropsSchema,
|
|
34
|
+
BboxObservationsResultSchema: () => BboxObservationsResultSchema,
|
|
35
|
+
DEFAULT_CONFIG: () => DEFAULT_CONFIG,
|
|
36
|
+
EarthquakePropsSchema: () => EarthquakePropsSchema,
|
|
37
|
+
EventPayloadSchema: () => EventPayloadSchema,
|
|
38
|
+
FlightPropsSchema: () => FlightPropsSchema,
|
|
39
|
+
FlightScheduleResponseSchema: () => FlightScheduleResponseSchema,
|
|
40
|
+
GeoLayersApiError: () => GeoLayersApiError,
|
|
41
|
+
GeoLayersError: () => GeoLayersError,
|
|
42
|
+
GeoLayersSDK: () => GeoLayersSDK,
|
|
43
|
+
GeoLayersValidationError: () => GeoLayersValidationError,
|
|
44
|
+
GeometrySchema: () => GeometrySchema,
|
|
45
|
+
LatestObservationResultSchema: () => LatestObservationResultSchema,
|
|
46
|
+
LayerMetadataSchema: () => LayerMetadataSchema,
|
|
47
|
+
LayerProvider: () => LayerProvider,
|
|
48
|
+
MeasurementValueSchema: () => MeasurementValueSchema,
|
|
49
|
+
ObservationProviderSchema: () => ObservationProviderSchema,
|
|
50
|
+
ObservationQueryResultSchema: () => ObservationQueryResultSchema,
|
|
51
|
+
ObservationStatsResultSchema: () => ObservationStatsResultSchema,
|
|
52
|
+
StandardMeasurementsSchema: () => StandardMeasurementsSchema,
|
|
53
|
+
StandardObservationSchema: () => StandardObservationSchema,
|
|
54
|
+
StationObservationsResultSchema: () => StationObservationsResultSchema,
|
|
55
|
+
StormPropsSchema: () => StormPropsSchema,
|
|
56
|
+
VolcanoPropsSchema: () => VolcanoPropsSchema,
|
|
57
|
+
WeatherStationPropsSchema: () => WeatherStationPropsSchema,
|
|
58
|
+
WildfirePropsSchema: () => WildfirePropsSchema,
|
|
59
|
+
createFeatureCollectionSchema: () => createFeatureCollectionSchema,
|
|
60
|
+
createFeatureSchema: () => createFeatureSchema,
|
|
61
|
+
createLayerResponseSchema: () => createLayerResponseSchema,
|
|
62
|
+
default: () => index_default
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(index_exports);
|
|
65
|
+
|
|
66
|
+
// src/core/client.ts
|
|
67
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
68
|
+
|
|
69
|
+
// src/types/api.ts
|
|
70
|
+
var import_zod = require("zod");
|
|
71
|
+
var LayerProvider = /* @__PURE__ */ ((LayerProvider2) => {
|
|
72
|
+
LayerProvider2["VOLCANOES"] = "volcanoes";
|
|
73
|
+
LayerProvider2["ACTIVE_VOLCANOES"] = "active-volcanoes";
|
|
74
|
+
LayerProvider2["WILDFIRES"] = "wildfires";
|
|
75
|
+
LayerProvider2["ACTIVE_STORMS"] = "active-storms";
|
|
76
|
+
LayerProvider2["RECENT_STORMS"] = "recent-storms";
|
|
77
|
+
LayerProvider2["EARTHQUAKES"] = "earthquakes";
|
|
78
|
+
LayerProvider2["BUOYS_RECENT"] = "buoys-recent";
|
|
79
|
+
LayerProvider2["BUOYS_LATEST"] = "buoys-latest";
|
|
80
|
+
LayerProvider2["NWS_STATIONS"] = "nws-weather-stations";
|
|
81
|
+
LayerProvider2["AZOS_NETWORK"] = "azos-weather-network";
|
|
82
|
+
LayerProvider2["WIS2_STATIONS"] = "wis2-stations";
|
|
83
|
+
LayerProvider2["GLOBAL_FLIGHTS"] = "global-flights";
|
|
84
|
+
LayerProvider2["LIVE_FLIGHTS"] = "live-flights";
|
|
85
|
+
LayerProvider2["FLIGHT_SCHEDULE"] = "flight-schedule";
|
|
86
|
+
return LayerProvider2;
|
|
87
|
+
})(LayerProvider || {});
|
|
88
|
+
var LayerMetadataSchema = import_zod.z.object({
|
|
89
|
+
source: import_zod.z.string(),
|
|
90
|
+
cacheTTL: import_zod.z.number(),
|
|
91
|
+
cached: import_zod.z.boolean(),
|
|
92
|
+
snapshotId: import_zod.z.string().optional()
|
|
93
|
+
});
|
|
94
|
+
var createLayerResponseSchema = (dataSchema) => import_zod.z.object({
|
|
95
|
+
provider: import_zod.z.string(),
|
|
96
|
+
data: dataSchema,
|
|
97
|
+
timestamp: import_zod.z.string(),
|
|
98
|
+
count: import_zod.z.number().optional(),
|
|
99
|
+
metadata: LayerMetadataSchema.optional()
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// src/types/geojson.ts
|
|
103
|
+
var import_zod2 = require("zod");
|
|
104
|
+
var PositionSchema = import_zod2.z.tuple([import_zod2.z.number(), import_zod2.z.number()]).rest(import_zod2.z.number());
|
|
105
|
+
var GeometrySchema = import_zod2.z.discriminatedUnion("type", [
|
|
106
|
+
import_zod2.z.object({ type: import_zod2.z.literal("Point"), coordinates: PositionSchema }),
|
|
107
|
+
import_zod2.z.object({ type: import_zod2.z.literal("LineString"), coordinates: import_zod2.z.array(PositionSchema) }),
|
|
108
|
+
import_zod2.z.object({ type: import_zod2.z.literal("Polygon"), coordinates: import_zod2.z.array(import_zod2.z.array(PositionSchema)) }),
|
|
109
|
+
import_zod2.z.object({ type: import_zod2.z.literal("MultiPoint"), coordinates: import_zod2.z.array(PositionSchema) }),
|
|
110
|
+
import_zod2.z.object({ type: import_zod2.z.literal("MultiLineString"), coordinates: import_zod2.z.array(import_zod2.z.array(PositionSchema)) }),
|
|
111
|
+
import_zod2.z.object({ type: import_zod2.z.literal("MultiPolygon"), coordinates: import_zod2.z.array(import_zod2.z.array(import_zod2.z.array(PositionSchema))) })
|
|
112
|
+
]);
|
|
113
|
+
var createFeatureSchema = (propsSchema) => import_zod2.z.object({
|
|
114
|
+
type: import_zod2.z.literal("Feature"),
|
|
115
|
+
geometry: GeometrySchema,
|
|
116
|
+
properties: propsSchema,
|
|
117
|
+
id: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]).optional()
|
|
118
|
+
});
|
|
119
|
+
var createFeatureCollectionSchema = (propsSchema) => import_zod2.z.object({
|
|
120
|
+
type: import_zod2.z.literal("FeatureCollection"),
|
|
121
|
+
features: import_zod2.z.array(createFeatureSchema(propsSchema)),
|
|
122
|
+
bbox: import_zod2.z.array(import_zod2.z.number()).optional()
|
|
123
|
+
});
|
|
124
|
+
var EarthquakePropsSchema = import_zod2.z.object({
|
|
125
|
+
mag: import_zod2.z.number(),
|
|
126
|
+
place: import_zod2.z.string(),
|
|
127
|
+
time: import_zod2.z.number(),
|
|
128
|
+
updated: import_zod2.z.number(),
|
|
129
|
+
tz: import_zod2.z.number().nullable().optional(),
|
|
130
|
+
url: import_zod2.z.string(),
|
|
131
|
+
detail: import_zod2.z.string(),
|
|
132
|
+
felt: import_zod2.z.number().nullable().optional(),
|
|
133
|
+
cdi: import_zod2.z.number().nullable().optional(),
|
|
134
|
+
mmi: import_zod2.z.number().nullable().optional(),
|
|
135
|
+
alert: import_zod2.z.string().nullable().optional(),
|
|
136
|
+
status: import_zod2.z.string(),
|
|
137
|
+
tsunami: import_zod2.z.number(),
|
|
138
|
+
sig: import_zod2.z.number(),
|
|
139
|
+
net: import_zod2.z.string(),
|
|
140
|
+
code: import_zod2.z.string(),
|
|
141
|
+
ids: import_zod2.z.string(),
|
|
142
|
+
sources: import_zod2.z.string(),
|
|
143
|
+
types: import_zod2.z.string(),
|
|
144
|
+
nst: import_zod2.z.number().nullable().optional(),
|
|
145
|
+
dmin: import_zod2.z.number().nullable().optional(),
|
|
146
|
+
rms: import_zod2.z.number().nullable().optional(),
|
|
147
|
+
gap: import_zod2.z.number().nullable().optional(),
|
|
148
|
+
magType: import_zod2.z.string(),
|
|
149
|
+
type: import_zod2.z.string(),
|
|
150
|
+
title: import_zod2.z.string()
|
|
151
|
+
});
|
|
152
|
+
var VolcanoPropsSchema = import_zod2.z.object({
|
|
153
|
+
volcanoNumber: import_zod2.z.number().nullable().optional(),
|
|
154
|
+
volcanoName: import_zod2.z.string(),
|
|
155
|
+
volcanicLandform: import_zod2.z.string().nullable().optional(),
|
|
156
|
+
primaryVolcanoType: import_zod2.z.string().nullable().optional(),
|
|
157
|
+
lastEruptionYear: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]).nullable().optional(),
|
|
158
|
+
country: import_zod2.z.string(),
|
|
159
|
+
region: import_zod2.z.string().nullable().optional(),
|
|
160
|
+
subregion: import_zod2.z.string().nullable().optional(),
|
|
161
|
+
geologicalSummary: import_zod2.z.string().nullable().optional(),
|
|
162
|
+
latitude: import_zod2.z.number().nullable().optional(),
|
|
163
|
+
longitude: import_zod2.z.number().nullable().optional(),
|
|
164
|
+
elevation: import_zod2.z.number().nullable().optional(),
|
|
165
|
+
tectonicSetting: import_zod2.z.string().nullable().optional(),
|
|
166
|
+
geologicEpoch: import_zod2.z.string().nullable().optional(),
|
|
167
|
+
evidenceCategory: import_zod2.z.string().nullable().optional(),
|
|
168
|
+
primaryPhotoLink: import_zod2.z.string().nullable().optional(),
|
|
169
|
+
primaryPhotoCaption: import_zod2.z.string().nullable().optional(),
|
|
170
|
+
primaryPhotoCredit: import_zod2.z.string().nullable().optional(),
|
|
171
|
+
majorRockType: import_zod2.z.string().nullable().optional()
|
|
172
|
+
});
|
|
173
|
+
var ActiveVolcanoPropsSchema = import_zod2.z.object({
|
|
174
|
+
name: import_zod2.z.string(),
|
|
175
|
+
eventtype: import_zod2.z.string().optional(),
|
|
176
|
+
eventid: import_zod2.z.number().optional(),
|
|
177
|
+
episodeid: import_zod2.z.number().optional(),
|
|
178
|
+
eventname: import_zod2.z.string().optional(),
|
|
179
|
+
glide: import_zod2.z.string().optional(),
|
|
180
|
+
description: import_zod2.z.string().optional(),
|
|
181
|
+
htmldescription: import_zod2.z.string().optional(),
|
|
182
|
+
icon: import_zod2.z.string().optional(),
|
|
183
|
+
iconoverall: import_zod2.z.string().optional(),
|
|
184
|
+
url: import_zod2.z.object({
|
|
185
|
+
geometry: import_zod2.z.string().optional(),
|
|
186
|
+
report: import_zod2.z.string().optional(),
|
|
187
|
+
details: import_zod2.z.string().optional()
|
|
188
|
+
}).optional(),
|
|
189
|
+
alertlevel: import_zod2.z.string().optional(),
|
|
190
|
+
alertscore: import_zod2.z.number().optional(),
|
|
191
|
+
episodealertlevel: import_zod2.z.string().optional(),
|
|
192
|
+
episodealertscore: import_zod2.z.number().optional(),
|
|
193
|
+
istemporary: import_zod2.z.string().optional(),
|
|
194
|
+
iscurrent: import_zod2.z.string().optional(),
|
|
195
|
+
country: import_zod2.z.string().optional(),
|
|
196
|
+
fromdate: import_zod2.z.string().optional(),
|
|
197
|
+
todate: import_zod2.z.string().optional(),
|
|
198
|
+
datemodified: import_zod2.z.string().optional(),
|
|
199
|
+
iso3: import_zod2.z.string().optional(),
|
|
200
|
+
source: import_zod2.z.string().optional(),
|
|
201
|
+
sourceid: import_zod2.z.string().optional(),
|
|
202
|
+
polygonlabel: import_zod2.z.string().optional(),
|
|
203
|
+
class: import_zod2.z.string().optional(),
|
|
204
|
+
affectedcountries: import_zod2.z.array(import_zod2.z.object({
|
|
205
|
+
iso2: import_zod2.z.string().optional(),
|
|
206
|
+
iso3: import_zod2.z.string().optional(),
|
|
207
|
+
countryname: import_zod2.z.string().optional()
|
|
208
|
+
})).optional(),
|
|
209
|
+
severitydata: import_zod2.z.object({
|
|
210
|
+
severity: import_zod2.z.number().optional(),
|
|
211
|
+
severitytext: import_zod2.z.string().optional(),
|
|
212
|
+
severityunit: import_zod2.z.string().optional()
|
|
213
|
+
}).optional(),
|
|
214
|
+
marketType: import_zod2.z.literal("volcano").optional(),
|
|
215
|
+
volcname: import_zod2.z.string().optional()
|
|
216
|
+
});
|
|
217
|
+
var WeatherStationPropsSchema = import_zod2.z.object({
|
|
218
|
+
id: import_zod2.z.string().optional(),
|
|
219
|
+
wigos_station_identifier: import_zod2.z.string().optional(),
|
|
220
|
+
station_identifier: import_zod2.z.string().optional(),
|
|
221
|
+
// Fallback
|
|
222
|
+
name: import_zod2.z.string().optional(),
|
|
223
|
+
station_name: import_zod2.z.string().optional(),
|
|
224
|
+
// Fallback
|
|
225
|
+
provider: import_zod2.z.string().optional(),
|
|
226
|
+
country: import_zod2.z.string().optional(),
|
|
227
|
+
baseUrl: import_zod2.z.string().optional(),
|
|
228
|
+
wis2CollectionId: import_zod2.z.string().optional(),
|
|
229
|
+
marketType: import_zod2.z.string().optional(),
|
|
230
|
+
metadata: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()).optional(),
|
|
231
|
+
measurements: import_zod2.z.record(
|
|
232
|
+
import_zod2.z.string(),
|
|
233
|
+
import_zod2.z.object({
|
|
234
|
+
value: import_zod2.z.union([import_zod2.z.number(), import_zod2.z.string()]),
|
|
235
|
+
unit: import_zod2.z.string().optional()
|
|
236
|
+
})
|
|
237
|
+
).optional()
|
|
238
|
+
});
|
|
239
|
+
var StormPropsSchema = import_zod2.z.object({
|
|
240
|
+
objectid: import_zod2.z.number().optional(),
|
|
241
|
+
stormname: import_zod2.z.string().optional(),
|
|
242
|
+
stormid: import_zod2.z.string().optional(),
|
|
243
|
+
stormnum: import_zod2.z.number().optional(),
|
|
244
|
+
stormtype: import_zod2.z.string().optional(),
|
|
245
|
+
dtg: import_zod2.z.number().optional(),
|
|
246
|
+
year: import_zod2.z.number().optional(),
|
|
247
|
+
month: import_zod2.z.string().optional(),
|
|
248
|
+
day: import_zod2.z.number().optional(),
|
|
249
|
+
hhmm: import_zod2.z.string().optional(),
|
|
250
|
+
tau: import_zod2.z.number().optional(),
|
|
251
|
+
mslp: import_zod2.z.number().optional(),
|
|
252
|
+
basin: import_zod2.z.string().optional(),
|
|
253
|
+
intensity: import_zod2.z.number().optional(),
|
|
254
|
+
ss: import_zod2.z.number().optional(),
|
|
255
|
+
lat: import_zod2.z.number().optional(),
|
|
256
|
+
lon: import_zod2.z.number().optional(),
|
|
257
|
+
// Alias/Common names used in clients/tests
|
|
258
|
+
category: import_zod2.z.number().optional(),
|
|
259
|
+
windSpeed: import_zod2.z.number().optional(),
|
|
260
|
+
pressure: import_zod2.z.number().optional(),
|
|
261
|
+
status: import_zod2.z.string().optional()
|
|
262
|
+
});
|
|
263
|
+
var WildfirePropsSchema = import_zod2.z.object({
|
|
264
|
+
brightness: import_zod2.z.number(),
|
|
265
|
+
bright_ti4: import_zod2.z.number().optional(),
|
|
266
|
+
bright_ti5: import_zod2.z.number().optional(),
|
|
267
|
+
scan: import_zod2.z.number().optional(),
|
|
268
|
+
track: import_zod2.z.number().optional(),
|
|
269
|
+
acq_date: import_zod2.z.string(),
|
|
270
|
+
acq_time: import_zod2.z.string(),
|
|
271
|
+
satellite: import_zod2.z.string().optional(),
|
|
272
|
+
instrument: import_zod2.z.string().optional(),
|
|
273
|
+
confidence: import_zod2.z.union([import_zod2.z.number(), import_zod2.z.string()]).optional(),
|
|
274
|
+
version: import_zod2.z.string().optional(),
|
|
275
|
+
frp: import_zod2.z.number().optional(),
|
|
276
|
+
daynight: import_zod2.z.string().optional()
|
|
277
|
+
});
|
|
278
|
+
var MeasurementValueSchema = import_zod2.z.object({
|
|
279
|
+
value: import_zod2.z.number(),
|
|
280
|
+
unit: import_zod2.z.string(),
|
|
281
|
+
quality: import_zod2.z.enum(["good", "suspect", "estimated", "missing"]).optional()
|
|
282
|
+
});
|
|
283
|
+
var StandardMeasurementsSchema = import_zod2.z.record(import_zod2.z.string(), MeasurementValueSchema);
|
|
284
|
+
var StandardObservationSchema = import_zod2.z.object({
|
|
285
|
+
timestamp: import_zod2.z.string().or(import_zod2.z.date()),
|
|
286
|
+
stationId: import_zod2.z.string(),
|
|
287
|
+
latitude: import_zod2.z.number().optional(),
|
|
288
|
+
longitude: import_zod2.z.number().optional(),
|
|
289
|
+
measurements: StandardMeasurementsSchema,
|
|
290
|
+
metadata: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()).optional(),
|
|
291
|
+
imageUrl: import_zod2.z.string().optional()
|
|
292
|
+
});
|
|
293
|
+
var ObservationQueryResultSchema = import_zod2.z.object({
|
|
294
|
+
stationId: import_zod2.z.string(),
|
|
295
|
+
observations: import_zod2.z.array(StandardObservationSchema),
|
|
296
|
+
count: import_zod2.z.number(),
|
|
297
|
+
timeRange: import_zod2.z.object({
|
|
298
|
+
start: import_zod2.z.string().or(import_zod2.z.date()),
|
|
299
|
+
end: import_zod2.z.string().or(import_zod2.z.date())
|
|
300
|
+
}),
|
|
301
|
+
provider: import_zod2.z.string(),
|
|
302
|
+
cached: import_zod2.z.boolean()
|
|
303
|
+
});
|
|
304
|
+
var FlightPropsSchema = import_zod2.z.object({
|
|
305
|
+
// OpenSky Fields
|
|
306
|
+
icao24: import_zod2.z.string().optional(),
|
|
307
|
+
callsign: import_zod2.z.string().optional(),
|
|
308
|
+
originCountry: import_zod2.z.string().optional(),
|
|
309
|
+
// Airplanes Live Fields
|
|
310
|
+
hex: import_zod2.z.string().optional(),
|
|
311
|
+
flight: import_zod2.z.string().optional(),
|
|
312
|
+
registration: import_zod2.z.string().optional(),
|
|
313
|
+
type: import_zod2.z.string().optional(),
|
|
314
|
+
// Common / Shared
|
|
315
|
+
velocity: import_zod2.z.number().nullable().optional(),
|
|
316
|
+
geoAltitude: import_zod2.z.number().nullable().optional(),
|
|
317
|
+
onGround: import_zod2.z.boolean().nullable().optional(),
|
|
318
|
+
verticalRate: import_zod2.z.number().nullable().optional(),
|
|
319
|
+
baroAltitude: import_zod2.z.union([import_zod2.z.number(), import_zod2.z.string()]).nullable().optional(),
|
|
320
|
+
squawk: import_zod2.z.string().nullable().optional(),
|
|
321
|
+
spi: import_zod2.z.boolean().nullable().optional(),
|
|
322
|
+
positionSource: import_zod2.z.number().nullable().optional(),
|
|
323
|
+
groundSpeed: import_zod2.z.number().nullable().optional(),
|
|
324
|
+
track: import_zod2.z.number().nullable().optional(),
|
|
325
|
+
// LiveFlights synonym
|
|
326
|
+
trueTrack: import_zod2.z.number().nullable().optional(),
|
|
327
|
+
// GlobalFlights synonym
|
|
328
|
+
emergency: import_zod2.z.string().nullable().optional(),
|
|
329
|
+
category: import_zod2.z.string().nullable().optional(),
|
|
330
|
+
// Timestamps
|
|
331
|
+
timePosition: import_zod2.z.number().nullable().optional(),
|
|
332
|
+
lastContact: import_zod2.z.number().nullable().optional(),
|
|
333
|
+
// Sensors
|
|
334
|
+
sensors: import_zod2.z.array(import_zod2.z.number()).nullable().optional()
|
|
335
|
+
});
|
|
336
|
+
var EventPayloadSchema = import_zod2.z.object({
|
|
337
|
+
provider: import_zod2.z.string(),
|
|
338
|
+
type: import_zod2.z.enum(["Feature", "FeatureCollection"]),
|
|
339
|
+
data: import_zod2.z.unknown(),
|
|
340
|
+
// Pode ser qualquer um dos GeoJSONs acima
|
|
341
|
+
timestamp: import_zod2.z.string(),
|
|
342
|
+
action: import_zod2.z.enum(["created", "updated", "deleted"]).optional()
|
|
343
|
+
});
|
|
344
|
+
var FlightScheduleResponseSchema = import_zod2.z.object({
|
|
345
|
+
provider: import_zod2.z.string(),
|
|
346
|
+
data: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
|
|
347
|
+
// AeroDataBox returns varied structure
|
|
348
|
+
timestamp: import_zod2.z.string(),
|
|
349
|
+
count: import_zod2.z.number().optional(),
|
|
350
|
+
metadata: import_zod2.z.object({
|
|
351
|
+
source: import_zod2.z.string(),
|
|
352
|
+
cacheTTL: import_zod2.z.number(),
|
|
353
|
+
cached: import_zod2.z.boolean()
|
|
354
|
+
}).optional()
|
|
355
|
+
});
|
|
356
|
+
var ObservationProviderSchema = import_zod2.z.enum(["wis2", "iem", "buoy", "openmeteo", "nws"]);
|
|
357
|
+
var StationObservationsResultSchema = import_zod2.z.object({
|
|
358
|
+
stationId: import_zod2.z.string(),
|
|
359
|
+
provider: ObservationProviderSchema,
|
|
360
|
+
observations: import_zod2.z.array(StandardObservationSchema),
|
|
361
|
+
count: import_zod2.z.number(),
|
|
362
|
+
timeRange: import_zod2.z.object({
|
|
363
|
+
start: import_zod2.z.string().or(import_zod2.z.date()),
|
|
364
|
+
end: import_zod2.z.string().or(import_zod2.z.date())
|
|
365
|
+
}),
|
|
366
|
+
source: import_zod2.z.literal("data-warehouse")
|
|
367
|
+
});
|
|
368
|
+
var LatestObservationResultSchema = import_zod2.z.object({
|
|
369
|
+
stationId: import_zod2.z.string(),
|
|
370
|
+
provider: ObservationProviderSchema,
|
|
371
|
+
observation: StandardObservationSchema.nullable(),
|
|
372
|
+
source: import_zod2.z.literal("data-warehouse")
|
|
373
|
+
});
|
|
374
|
+
var BboxObservationsResultSchema = import_zod2.z.object({
|
|
375
|
+
bbox: import_zod2.z.tuple([import_zod2.z.number(), import_zod2.z.number(), import_zod2.z.number(), import_zod2.z.number()]),
|
|
376
|
+
provider: ObservationProviderSchema,
|
|
377
|
+
observations: import_zod2.z.array(StandardObservationSchema),
|
|
378
|
+
count: import_zod2.z.number(),
|
|
379
|
+
timeRange: import_zod2.z.object({
|
|
380
|
+
start: import_zod2.z.string().or(import_zod2.z.date()),
|
|
381
|
+
end: import_zod2.z.string().or(import_zod2.z.date())
|
|
382
|
+
}),
|
|
383
|
+
source: import_zod2.z.literal("data-warehouse")
|
|
384
|
+
});
|
|
385
|
+
var ObservationStatsResultSchema = import_zod2.z.object({
|
|
386
|
+
provider: import_zod2.z.string(),
|
|
387
|
+
totalObservations: import_zod2.z.number(),
|
|
388
|
+
source: import_zod2.z.literal("data-warehouse")
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// src/core/config.ts
|
|
392
|
+
var DEFAULT_CONFIG = {
|
|
393
|
+
baseUrl: (typeof process !== "undefined" ? process.env.GEOLAYERS_BASE_URL : void 0) || "",
|
|
394
|
+
timeout: 3e4,
|
|
395
|
+
retries: 2
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
// src/core/errors.ts
|
|
399
|
+
var GeoLayersError = class extends Error {
|
|
400
|
+
constructor(message) {
|
|
401
|
+
super(message);
|
|
402
|
+
this.name = "GeoLayersError";
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
var GeoLayersApiError = class extends GeoLayersError {
|
|
406
|
+
constructor(message, statusCode, response) {
|
|
407
|
+
super(message);
|
|
408
|
+
this.statusCode = statusCode;
|
|
409
|
+
this.response = response;
|
|
410
|
+
this.name = "GeoLayersApiError";
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
var GeoLayersValidationError = class extends GeoLayersError {
|
|
414
|
+
constructor(message, errors) {
|
|
415
|
+
super(message);
|
|
416
|
+
this.errors = errors;
|
|
417
|
+
this.name = "GeoLayersValidationError";
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
// src/core/client.ts
|
|
422
|
+
var BaseClient = class {
|
|
423
|
+
http;
|
|
424
|
+
config;
|
|
425
|
+
constructor(config) {
|
|
426
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
427
|
+
this.http = import_axios.default.create({
|
|
428
|
+
baseURL: this.config.baseUrl,
|
|
429
|
+
timeout: this.config.timeout
|
|
430
|
+
});
|
|
431
|
+
this.setupInterceptors();
|
|
432
|
+
}
|
|
433
|
+
setupInterceptors() {
|
|
434
|
+
this.http.interceptors.request.use((config) => {
|
|
435
|
+
config.headers["X-API-Key"] = this.config.apiKey;
|
|
436
|
+
return config;
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
isRetryableError(error) {
|
|
440
|
+
if (!error.response) return true;
|
|
441
|
+
const status = error.response.status;
|
|
442
|
+
return status >= 500 || status === 429;
|
|
443
|
+
}
|
|
444
|
+
async delay(ms) {
|
|
445
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
446
|
+
}
|
|
447
|
+
async executeWithRetry(requestFn) {
|
|
448
|
+
const maxRetries = this.config.retries ?? 2;
|
|
449
|
+
let lastError = null;
|
|
450
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
451
|
+
try {
|
|
452
|
+
const response = await requestFn();
|
|
453
|
+
return response.data;
|
|
454
|
+
} catch (err) {
|
|
455
|
+
const error = err;
|
|
456
|
+
lastError = error;
|
|
457
|
+
const isLastAttempt = attempt === maxRetries;
|
|
458
|
+
if (isLastAttempt || !this.isRetryableError(error)) {
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
const delayMs = Math.pow(2, attempt) * 1e3;
|
|
462
|
+
await this.delay(delayMs);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (!lastError.response) {
|
|
466
|
+
throw new GeoLayersApiError(lastError.message, 0);
|
|
467
|
+
}
|
|
468
|
+
const { status, data } = lastError.response;
|
|
469
|
+
let message;
|
|
470
|
+
if (typeof data?.message === "string") {
|
|
471
|
+
message = data.message;
|
|
472
|
+
} else if (Array.isArray(data?.message)) {
|
|
473
|
+
message = data.message.join("; ");
|
|
474
|
+
} else if (typeof data?.error === "string") {
|
|
475
|
+
message = data.error;
|
|
476
|
+
} else if (data?.error?.message) {
|
|
477
|
+
message = data.error.message;
|
|
478
|
+
} else {
|
|
479
|
+
message = lastError.message ?? "Unknown error";
|
|
480
|
+
}
|
|
481
|
+
throw new GeoLayersApiError(message, status, data);
|
|
482
|
+
}
|
|
483
|
+
async get(url, params) {
|
|
484
|
+
return this.executeWithRetry(
|
|
485
|
+
() => this.http.get(url, { params })
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
async post(url, body) {
|
|
489
|
+
return this.executeWithRetry(
|
|
490
|
+
() => this.http.post(url, body)
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Helper to parse GeoJSON responses with Zod validation.
|
|
495
|
+
* Eliminates repetitive schema creation across domains.
|
|
496
|
+
*/
|
|
497
|
+
parseGeoJSON(data, propsSchema) {
|
|
498
|
+
const schema = createLayerResponseSchema(createFeatureCollectionSchema(propsSchema));
|
|
499
|
+
return schema.parse(data);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
// src/domains/aviation.ts
|
|
504
|
+
var AviationDomain = class extends BaseClient {
|
|
505
|
+
/**
|
|
506
|
+
* Get all currently tracked flights globally (OpenSky).
|
|
507
|
+
* @param filters Optional bounding box filters. Defaults to whole world.
|
|
508
|
+
*/
|
|
509
|
+
async getGlobalFlights(filters = {}) {
|
|
510
|
+
const params = {
|
|
511
|
+
lamin: filters.lamin ?? -90,
|
|
512
|
+
lomin: filters.lomin ?? -180,
|
|
513
|
+
lamax: filters.lamax ?? 90,
|
|
514
|
+
lomax: filters.lomax ?? 180
|
|
515
|
+
};
|
|
516
|
+
const data = await this.get("/geojson/flights/global", params);
|
|
517
|
+
return this.parseGeoJSON(data, FlightPropsSchema);
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Get live flights (subset of global flights).
|
|
521
|
+
* @param filters Center point and radius filters. Defaults to New York if not provided.
|
|
522
|
+
*/
|
|
523
|
+
async getLiveFlights(filters = { lat: 40.7128, lng: -74.006 }) {
|
|
524
|
+
const params = {
|
|
525
|
+
lat: filters.lat,
|
|
526
|
+
lng: filters.lng,
|
|
527
|
+
radius: filters.radius ?? 250
|
|
528
|
+
};
|
|
529
|
+
const data = await this.get("/geojson/flights/live", params);
|
|
530
|
+
return this.parseGeoJSON(data, FlightPropsSchema);
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Get flight schedule/details by callsign from AeroDataBox.
|
|
534
|
+
* @param callsign Flight identifier (e.g., 'UAL1234', 'AA100')
|
|
535
|
+
* @returns Raw flight schedule data from AeroDataBox API.
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* ```ts
|
|
539
|
+
* const schedule = await sdk.aviation.getFlightSchedule('UAL1234');
|
|
540
|
+
* console.log(schedule.data); // Flight details from AeroDataBox
|
|
541
|
+
* ```
|
|
542
|
+
*/
|
|
543
|
+
async getFlightSchedule(callsign) {
|
|
544
|
+
const data = await this.get("/geojson/flights/schedule", { callsign });
|
|
545
|
+
return FlightScheduleResponseSchema.parse(data);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
// src/domains/events.ts
|
|
550
|
+
var import_zod3 = require("zod");
|
|
551
|
+
var GeoLayersEventTypeSchema = import_zod3.z.enum([
|
|
552
|
+
"earthquake.new",
|
|
553
|
+
"earthquake.updated",
|
|
554
|
+
"storm.new",
|
|
555
|
+
"storm.updated",
|
|
556
|
+
"wildfire.new",
|
|
557
|
+
"wildfire.updated",
|
|
558
|
+
"volcano.alert",
|
|
559
|
+
"snapshot.completed",
|
|
560
|
+
"snapshot.failed",
|
|
561
|
+
"observation.batch"
|
|
562
|
+
]);
|
|
563
|
+
var EventTypesResponseSchema = import_zod3.z.object({
|
|
564
|
+
types: import_zod3.z.array(GeoLayersEventTypeSchema),
|
|
565
|
+
descriptions: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string())
|
|
566
|
+
});
|
|
567
|
+
var EventsDomain = class extends BaseClient {
|
|
568
|
+
/**
|
|
569
|
+
* Get list of available event types for the event stream.
|
|
570
|
+
* @returns Object with event types array and their descriptions.
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```ts
|
|
574
|
+
* const { types, descriptions } = await sdk.eventsMeta.getEventTypes();
|
|
575
|
+
* console.log(types); // ['earthquake.new', 'storm.new', ...]
|
|
576
|
+
* console.log(descriptions['earthquake.new']); // 'New earthquake detected'
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
579
|
+
async getEventTypes() {
|
|
580
|
+
const data = await this.get("/events/types");
|
|
581
|
+
return EventTypesResponseSchema.parse(data);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
// src/domains/fire.ts
|
|
586
|
+
var FireDomain = class extends BaseClient {
|
|
587
|
+
/**
|
|
588
|
+
* Get list of active wildfires/heat anomalies.
|
|
589
|
+
* @param filters Optional filters. Default: last 1 day.
|
|
590
|
+
*/
|
|
591
|
+
async getWildfires(filters = {}) {
|
|
592
|
+
const params = { days: filters.days ?? 1 };
|
|
593
|
+
const data = await this.get("/geojson/wildfires", params);
|
|
594
|
+
return this.parseGeoJSON(data, WildfirePropsSchema);
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
// src/domains/maritime.ts
|
|
599
|
+
var MaritimeDomain = class extends BaseClient {
|
|
600
|
+
/**
|
|
601
|
+
* Get NOAA buoy stations (locations).
|
|
602
|
+
*/
|
|
603
|
+
async getBuoyStations() {
|
|
604
|
+
const data = await this.get("/geojson/buoys/stations");
|
|
605
|
+
return this.parseGeoJSON(data, WeatherStationPropsSchema);
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Get latest buoy observations (real-time-ish).
|
|
609
|
+
*/
|
|
610
|
+
async getLatestBuoyObservations() {
|
|
611
|
+
const data = await this.get("/geojson/buoys/observations");
|
|
612
|
+
return this.parseGeoJSON(data, WeatherStationPropsSchema);
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Get historical observations for a specific buoy.
|
|
616
|
+
* @param buoyId The buoy identifier.
|
|
617
|
+
* @param filters Date range filters.
|
|
618
|
+
*/
|
|
619
|
+
async getBuoyObservations(buoyId, filters) {
|
|
620
|
+
const data = await this.get(`/observations/buoy/${buoyId}`, filters);
|
|
621
|
+
return ObservationQueryResultSchema.parse(data);
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
// src/domains/observations.ts
|
|
626
|
+
var ObservationsDomain = class extends BaseClient {
|
|
627
|
+
/**
|
|
628
|
+
* Get active WIS2 stations that reported data in the last 24 hours.
|
|
629
|
+
*/
|
|
630
|
+
async getActiveWis2Stations() {
|
|
631
|
+
const rawData = await this.get("/observations/wis2/stations/active");
|
|
632
|
+
return this.parseActiveStationsResponse(rawData, "wis2");
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Get active IEM/AZOS stations that reported data in the last 24 hours.
|
|
636
|
+
*/
|
|
637
|
+
async getActiveIemStations() {
|
|
638
|
+
const rawData = await this.get("/observations/iem/stations/active");
|
|
639
|
+
return this.parseActiveStationsResponse(rawData, "iem");
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Get observations for a station from the data warehouse.
|
|
643
|
+
* @param stationId The station identifier.
|
|
644
|
+
* @param filters Query filters including provider and date range.
|
|
645
|
+
*/
|
|
646
|
+
async getStationObservations(stationId, filters) {
|
|
647
|
+
const params = this.buildDateParams(filters);
|
|
648
|
+
const data = await this.get(`/observations/station/${stationId}`, params);
|
|
649
|
+
return StationObservationsResultSchema.parse(data);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Get the latest observation for a station from the data warehouse.
|
|
653
|
+
* @param stationId The station identifier.
|
|
654
|
+
* @param provider The observation provider.
|
|
655
|
+
*/
|
|
656
|
+
async getLatestObservation(stationId, provider) {
|
|
657
|
+
const data = await this.get(`/observations/station/${stationId}/latest`, { provider });
|
|
658
|
+
return LatestObservationResultSchema.parse(data);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Get observations within a geographic bounding box.
|
|
662
|
+
* @param filters Bounding box coordinates and query filters.
|
|
663
|
+
*/
|
|
664
|
+
async getObservationsByBbox(filters) {
|
|
665
|
+
const params = {
|
|
666
|
+
...this.buildDateParams(filters),
|
|
667
|
+
minLon: filters.minLon,
|
|
668
|
+
minLat: filters.minLat,
|
|
669
|
+
maxLon: filters.maxLon,
|
|
670
|
+
maxLat: filters.maxLat
|
|
671
|
+
};
|
|
672
|
+
const data = await this.get("/observations/bbox", params);
|
|
673
|
+
return BboxObservationsResultSchema.parse(data);
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Get data warehouse statistics.
|
|
677
|
+
* @param provider Optional provider filter. If not specified, returns stats for all providers.
|
|
678
|
+
*/
|
|
679
|
+
async getStats(provider) {
|
|
680
|
+
const params = provider ? { provider } : {};
|
|
681
|
+
const data = await this.get("/observations/stats", params);
|
|
682
|
+
return ObservationStatsResultSchema.parse(data);
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Convert time preset to absolute date range parameters.
|
|
686
|
+
*/
|
|
687
|
+
buildDateParams(filters) {
|
|
688
|
+
const params = {
|
|
689
|
+
provider: filters.provider
|
|
690
|
+
};
|
|
691
|
+
if (filters.limit !== void 0) {
|
|
692
|
+
params.limit = filters.limit;
|
|
693
|
+
}
|
|
694
|
+
if (filters.start && filters.end) {
|
|
695
|
+
params.start = filters.start;
|
|
696
|
+
params.end = filters.end;
|
|
697
|
+
return params;
|
|
698
|
+
}
|
|
699
|
+
if (filters.timePreset) {
|
|
700
|
+
const now = /* @__PURE__ */ new Date();
|
|
701
|
+
const presetMs = {
|
|
702
|
+
"1h": 60 * 60 * 1e3,
|
|
703
|
+
"24h": 24 * 60 * 60 * 1e3,
|
|
704
|
+
"7d": 7 * 24 * 60 * 60 * 1e3,
|
|
705
|
+
"30d": 30 * 24 * 60 * 60 * 1e3
|
|
706
|
+
};
|
|
707
|
+
const ms = presetMs[filters.timePreset];
|
|
708
|
+
params.start = new Date(now.getTime() - ms).toISOString();
|
|
709
|
+
params.end = now.toISOString();
|
|
710
|
+
}
|
|
711
|
+
return params;
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Parse active stations response.
|
|
715
|
+
* The endpoint may return either a FeatureCollection directly or wrapped in LayerResponse.
|
|
716
|
+
*/
|
|
717
|
+
parseActiveStationsResponse(rawData, provider) {
|
|
718
|
+
const featureCollection = rawData;
|
|
719
|
+
if (featureCollection?.type === "FeatureCollection") {
|
|
720
|
+
const features = (featureCollection.features ?? []).map((f) => {
|
|
721
|
+
const feature = f;
|
|
722
|
+
return {
|
|
723
|
+
type: "Feature",
|
|
724
|
+
geometry: feature.geometry,
|
|
725
|
+
properties: WeatherStationPropsSchema.parse(feature.properties ?? {}),
|
|
726
|
+
id: feature.id
|
|
727
|
+
};
|
|
728
|
+
});
|
|
729
|
+
return {
|
|
730
|
+
provider: `active-stations-${provider}`,
|
|
731
|
+
data: {
|
|
732
|
+
type: "FeatureCollection",
|
|
733
|
+
features
|
|
734
|
+
},
|
|
735
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
736
|
+
count: features.length
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
return this.parseGeoJSON(rawData, WeatherStationPropsSchema);
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
// src/domains/seismic.ts
|
|
744
|
+
var PRESET_HOURS = {
|
|
745
|
+
"1h": 1,
|
|
746
|
+
"24h": 24,
|
|
747
|
+
"7d": 24 * 7,
|
|
748
|
+
"30d": 24 * 30
|
|
749
|
+
};
|
|
750
|
+
function getTimeRange(preset) {
|
|
751
|
+
const now = /* @__PURE__ */ new Date();
|
|
752
|
+
const hoursAgo = PRESET_HOURS[preset];
|
|
753
|
+
const start = new Date(now.getTime() - hoursAgo * 60 * 60 * 1e3);
|
|
754
|
+
return {
|
|
755
|
+
startTime: start.toISOString(),
|
|
756
|
+
endTime: now.toISOString()
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
var SeismicDomain = class extends BaseClient {
|
|
760
|
+
/**
|
|
761
|
+
* Get earthquakes from a specific time range and minimum magnitude.
|
|
762
|
+
*
|
|
763
|
+
* @param filters - Optional filters. Default: last 24 hours.
|
|
764
|
+
* @returns Promise with earthquake data as GeoJSON FeatureCollection.
|
|
765
|
+
*
|
|
766
|
+
* @example Using default (last 24 hours)
|
|
767
|
+
* ```ts
|
|
768
|
+
* const earthquakes = await sdk.seismic.getEarthquakes();
|
|
769
|
+
* ```
|
|
770
|
+
*
|
|
771
|
+
* @example Using a preset
|
|
772
|
+
* ```ts
|
|
773
|
+
* const earthquakes = await sdk.seismic.getEarthquakes({ timePreset: '7d', minMagnitude: 4.0 });
|
|
774
|
+
* ```
|
|
775
|
+
*
|
|
776
|
+
* @example Using custom date range
|
|
777
|
+
* ```ts
|
|
778
|
+
* const earthquakes = await sdk.seismic.getEarthquakes({
|
|
779
|
+
* startTime: '2024-01-01T00:00:00Z',
|
|
780
|
+
* endTime: '2024-01-31T23:59:59Z',
|
|
781
|
+
* minMagnitude: 5.0,
|
|
782
|
+
* });
|
|
783
|
+
* ```
|
|
784
|
+
*/
|
|
785
|
+
async getEarthquakes(filters) {
|
|
786
|
+
const { timePreset = "24h", startTime, endTime, minMagnitude } = filters ?? {};
|
|
787
|
+
const timeRange = startTime && endTime ? { startTime, endTime } : getTimeRange(timePreset);
|
|
788
|
+
const params = {
|
|
789
|
+
...timeRange,
|
|
790
|
+
...minMagnitude !== void 0 && { minMagnitude }
|
|
791
|
+
};
|
|
792
|
+
const data = await this.get("/geojson/earthquakes", params);
|
|
793
|
+
return this.parseGeoJSON(data, EarthquakePropsSchema);
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// src/domains/tropical.ts
|
|
798
|
+
var TropicalDomain = class extends BaseClient {
|
|
799
|
+
/**
|
|
800
|
+
* Get list of currently active tropical storms/hurricanes.
|
|
801
|
+
*/
|
|
802
|
+
async getActiveStorms() {
|
|
803
|
+
const data = await this.get("/geojson/storms/active");
|
|
804
|
+
return this.parseGeoJSON(data, StormPropsSchema);
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Get list of recent tropical storms/hurricanes.
|
|
808
|
+
*/
|
|
809
|
+
async getRecentStorms() {
|
|
810
|
+
const data = await this.get("/geojson/storms/recent");
|
|
811
|
+
return this.parseGeoJSON(data, StormPropsSchema);
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
// src/domains/volcanic.ts
|
|
816
|
+
var import_zod4 = require("zod");
|
|
817
|
+
var VolcanoesResponseSchema = import_zod4.z.object({
|
|
818
|
+
provider: import_zod4.z.string(),
|
|
819
|
+
data: import_zod4.z.array(createFeatureSchema(VolcanoPropsSchema)),
|
|
820
|
+
timestamp: import_zod4.z.string(),
|
|
821
|
+
count: import_zod4.z.number().optional(),
|
|
822
|
+
metadata: LayerMetadataSchema.optional()
|
|
823
|
+
});
|
|
824
|
+
var VolcanicDomain = class extends BaseClient {
|
|
825
|
+
/**
|
|
826
|
+
* Get list of Holocene volcanoes (Smithsonian Institution).
|
|
827
|
+
* Note: API returns array of Features, normalized to FeatureCollection here.
|
|
828
|
+
*/
|
|
829
|
+
async getVolcanoes() {
|
|
830
|
+
const raw = await this.get("/geojson/volcanoes");
|
|
831
|
+
const parsed = VolcanoesResponseSchema.parse(raw);
|
|
832
|
+
return {
|
|
833
|
+
provider: parsed.provider,
|
|
834
|
+
data: {
|
|
835
|
+
type: "FeatureCollection",
|
|
836
|
+
features: parsed.data
|
|
837
|
+
},
|
|
838
|
+
timestamp: parsed.timestamp,
|
|
839
|
+
count: parsed.count,
|
|
840
|
+
metadata: parsed.metadata
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Get list of currently active volcanoes (GDACS).
|
|
845
|
+
*/
|
|
846
|
+
async getActiveVolcanoes() {
|
|
847
|
+
const data = await this.get("/geojson/volcanoes/active");
|
|
848
|
+
return this.parseGeoJSON(data, ActiveVolcanoPropsSchema);
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
// src/domains/weather.ts
|
|
853
|
+
var WeatherDomain = class extends BaseClient {
|
|
854
|
+
/**
|
|
855
|
+
* Get weather stations from WIS2 network.
|
|
856
|
+
* @param filters Optional pagination filters.
|
|
857
|
+
*/
|
|
858
|
+
async getWis2Stations(filters = {}) {
|
|
859
|
+
const params = {
|
|
860
|
+
limit: filters.limit ?? 100,
|
|
861
|
+
offset: filters.offset ?? 0
|
|
862
|
+
};
|
|
863
|
+
const data = await this.get("/geojson/stations/wis2", params);
|
|
864
|
+
return this.parseGeoJSON(data, WeatherStationPropsSchema);
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Get historical observations for a WIS2 station.
|
|
868
|
+
* @param stationId The station identifier.
|
|
869
|
+
* @param filters Date range and optional WIS2-specific filters.
|
|
870
|
+
*/
|
|
871
|
+
async getWis2Observations(stationId, filters) {
|
|
872
|
+
const data = await this.get(`/observations/wis2/${stationId}`, filters);
|
|
873
|
+
return ObservationQueryResultSchema.parse(data);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Get weather stations from IEM/AZOS network.
|
|
877
|
+
*/
|
|
878
|
+
async getIemStations() {
|
|
879
|
+
const data = await this.get("/geojson/stations/azos");
|
|
880
|
+
return this.parseGeoJSON(data, WeatherStationPropsSchema);
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Get historical observations for an IEM station.
|
|
884
|
+
* @param stationId The station identifier.
|
|
885
|
+
* @param filters Date range filters.
|
|
886
|
+
*/
|
|
887
|
+
async getIemObservations(stationId, filters) {
|
|
888
|
+
const data = await this.get(`/observations/iem/${stationId}`, filters);
|
|
889
|
+
return ObservationQueryResultSchema.parse(data);
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Get weather stations from NWS (National Weather Service) network.
|
|
893
|
+
*/
|
|
894
|
+
async getNWSWeatherStations() {
|
|
895
|
+
const data = await this.get("/geojson/stations/nws");
|
|
896
|
+
return this.parseGeoJSON(data, WeatherStationPropsSchema);
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Get active stations that have reported data in the last 24 hours.
|
|
900
|
+
* @param type The station network type ('iem' or 'wis2').
|
|
901
|
+
*
|
|
902
|
+
* Note: This endpoint returns FeatureCollection directly (not LayerResponse envelope).
|
|
903
|
+
*/
|
|
904
|
+
async getActiveStations(type) {
|
|
905
|
+
const rawData = await this.get("/stations/active", { type });
|
|
906
|
+
const featureCollection = rawData;
|
|
907
|
+
if (featureCollection?.type === "FeatureCollection") {
|
|
908
|
+
const features = (featureCollection.features ?? []).map((f) => {
|
|
909
|
+
const feature = f;
|
|
910
|
+
return {
|
|
911
|
+
type: "Feature",
|
|
912
|
+
geometry: feature.geometry,
|
|
913
|
+
properties: WeatherStationPropsSchema.parse(feature.properties ?? {}),
|
|
914
|
+
id: feature.id
|
|
915
|
+
};
|
|
916
|
+
});
|
|
917
|
+
return {
|
|
918
|
+
provider: `active-stations-${type}`,
|
|
919
|
+
data: {
|
|
920
|
+
type: "FeatureCollection",
|
|
921
|
+
features
|
|
922
|
+
},
|
|
923
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
924
|
+
count: features.length
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
return this.parseGeoJSON(rawData, WeatherStationPropsSchema);
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
// src/events/stream.ts
|
|
932
|
+
var import_events = require("events");
|
|
933
|
+
var EventStream = class extends import_events.EventEmitter {
|
|
934
|
+
eventSource = null;
|
|
935
|
+
url;
|
|
936
|
+
constructor(config) {
|
|
937
|
+
super();
|
|
938
|
+
this.url = `${config.baseUrl}/events/stream?apiKey=${config.apiKey}`;
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Start listening to the event stream.
|
|
942
|
+
*/
|
|
943
|
+
connect() {
|
|
944
|
+
if (this.eventSource) return;
|
|
945
|
+
this.eventSource = new EventSource(this.url);
|
|
946
|
+
this.eventSource.onmessage = (event) => {
|
|
947
|
+
try {
|
|
948
|
+
const rawData = JSON.parse(event.data);
|
|
949
|
+
const payload = EventPayloadSchema.parse(rawData);
|
|
950
|
+
this.emit("data", payload);
|
|
951
|
+
this.emit(payload.provider, payload);
|
|
952
|
+
} catch (err) {
|
|
953
|
+
this.emit("error", err);
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
this.eventSource.onerror = (err) => {
|
|
957
|
+
this.emit("error", err);
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Stop listening to the event stream.
|
|
962
|
+
*/
|
|
963
|
+
disconnect() {
|
|
964
|
+
if (this.eventSource) {
|
|
965
|
+
this.eventSource.close();
|
|
966
|
+
this.eventSource = null;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
on(event, listener) {
|
|
970
|
+
return super.on(event, listener);
|
|
971
|
+
}
|
|
972
|
+
off(event, listener) {
|
|
973
|
+
return super.off(event, listener);
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
// src/index.ts
|
|
978
|
+
var GeoLayersSDK = class {
|
|
979
|
+
seismic;
|
|
980
|
+
volcanic;
|
|
981
|
+
tropical;
|
|
982
|
+
fire;
|
|
983
|
+
weather;
|
|
984
|
+
maritime;
|
|
985
|
+
aviation;
|
|
986
|
+
/** Observation data warehouse and active stations */
|
|
987
|
+
observations;
|
|
988
|
+
/** Real-time event stream (SSE) */
|
|
989
|
+
events;
|
|
990
|
+
/** Event metadata operations (REST) */
|
|
991
|
+
eventsMeta;
|
|
992
|
+
constructor(config) {
|
|
993
|
+
this.seismic = new SeismicDomain(config);
|
|
994
|
+
this.volcanic = new VolcanicDomain(config);
|
|
995
|
+
this.tropical = new TropicalDomain(config);
|
|
996
|
+
this.fire = new FireDomain(config);
|
|
997
|
+
this.weather = new WeatherDomain(config);
|
|
998
|
+
this.maritime = new MaritimeDomain(config);
|
|
999
|
+
this.aviation = new AviationDomain(config);
|
|
1000
|
+
this.observations = new ObservationsDomain(config);
|
|
1001
|
+
this.events = new EventStream(config);
|
|
1002
|
+
this.eventsMeta = new EventsDomain(config);
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
var index_default = GeoLayersSDK;
|
|
1006
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1007
|
+
0 && (module.exports = {
|
|
1008
|
+
ActiveVolcanoPropsSchema,
|
|
1009
|
+
BboxObservationsResultSchema,
|
|
1010
|
+
DEFAULT_CONFIG,
|
|
1011
|
+
EarthquakePropsSchema,
|
|
1012
|
+
EventPayloadSchema,
|
|
1013
|
+
FlightPropsSchema,
|
|
1014
|
+
FlightScheduleResponseSchema,
|
|
1015
|
+
GeoLayersApiError,
|
|
1016
|
+
GeoLayersError,
|
|
1017
|
+
GeoLayersSDK,
|
|
1018
|
+
GeoLayersValidationError,
|
|
1019
|
+
GeometrySchema,
|
|
1020
|
+
LatestObservationResultSchema,
|
|
1021
|
+
LayerMetadataSchema,
|
|
1022
|
+
LayerProvider,
|
|
1023
|
+
MeasurementValueSchema,
|
|
1024
|
+
ObservationProviderSchema,
|
|
1025
|
+
ObservationQueryResultSchema,
|
|
1026
|
+
ObservationStatsResultSchema,
|
|
1027
|
+
StandardMeasurementsSchema,
|
|
1028
|
+
StandardObservationSchema,
|
|
1029
|
+
StationObservationsResultSchema,
|
|
1030
|
+
StormPropsSchema,
|
|
1031
|
+
VolcanoPropsSchema,
|
|
1032
|
+
WeatherStationPropsSchema,
|
|
1033
|
+
WildfirePropsSchema,
|
|
1034
|
+
createFeatureCollectionSchema,
|
|
1035
|
+
createFeatureSchema,
|
|
1036
|
+
createLayerResponseSchema
|
|
1037
|
+
});
|