@omnizoek/sdk 0.1.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.
@@ -0,0 +1,410 @@
1
+ /**
2
+ * client.ts — Core HTTP client with automatic retry and error mapping.
3
+ */
4
+ interface OmniClientOptions {
5
+ /** Your OmniZoek API key (omni_live_… or omni_test_…) */
6
+ apiKey: string;
7
+ /** Override the base URL — useful for testing. Default: https://api.omnizoek.nl */
8
+ baseUrl?: string;
9
+ /** Max retries on 429 rate-limit responses. Default: 3 */
10
+ maxRetries?: number;
11
+ /** Base delay in ms for exponential backoff. Default: 500 */
12
+ retryDelayMs?: number;
13
+ /** Request timeout in ms. Default: 20000 */
14
+ timeoutMs?: number;
15
+ }
16
+ declare class HttpClient {
17
+ private readonly apiKey;
18
+ private readonly baseUrl;
19
+ private readonly maxRetries;
20
+ private readonly retryDelayMs;
21
+ private readonly timeoutMs;
22
+ constructor(options: OmniClientOptions);
23
+ get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
24
+ post<T>(path: string, body?: unknown): Promise<T>;
25
+ delete(path: string): Promise<void>;
26
+ private _throwFromResponse;
27
+ }
28
+
29
+ interface AddressEnrichParams {
30
+ postcode: string;
31
+ houseNumber: string;
32
+ /** Include EP-Online energy label (default: true) */
33
+ energy?: boolean;
34
+ }
35
+ interface AddressEnrichResponse {
36
+ street: string;
37
+ house_number: string;
38
+ house_letter: string | null;
39
+ house_addition: string | null;
40
+ postcode: string;
41
+ city: string;
42
+ municipality: string | null;
43
+ province: string | null;
44
+ lat: number | null;
45
+ lon: number | null;
46
+ bag_id: string;
47
+ surface_m2: number | null;
48
+ building_year: number | null;
49
+ usage_function: string | null;
50
+ status: string | null;
51
+ energy_label: string | null;
52
+ energy_label_registered: string | null;
53
+ energy_label_valid_until: string | null;
54
+ energy_label_calculation_type: string | null;
55
+ }
56
+ interface IbanToBicParams {
57
+ iban: string;
58
+ }
59
+ interface IbanToBicResponse {
60
+ iban: string;
61
+ bic: string;
62
+ bank_name: string;
63
+ country_code: string;
64
+ }
65
+ interface VatVerifyParams {
66
+ countryCode: string;
67
+ vatNumber: string;
68
+ }
69
+ interface VatVerifyResponse {
70
+ valid: boolean;
71
+ status: string;
72
+ country_code: string;
73
+ vat_number: string;
74
+ company_name: string | null;
75
+ address: string | null;
76
+ checked_at: string;
77
+ }
78
+ type FinanceValidationType = "bsn" | "iban";
79
+ interface ValidateFinanceParams {
80
+ type: FinanceValidationType;
81
+ number: string;
82
+ }
83
+ interface FinanceValidationResponse {
84
+ valid: boolean;
85
+ type: string;
86
+ number: string;
87
+ algorithm: string;
88
+ detail: string;
89
+ }
90
+ interface MinimumWageParams {
91
+ age: number;
92
+ /** Reference date YYYY-MM-DD (defaults to today) */
93
+ date?: string;
94
+ }
95
+ interface MinimumWageResponse {
96
+ age: number;
97
+ date: string;
98
+ hourly_eur: number;
99
+ daily_eur: number;
100
+ monthly_eur: number;
101
+ law_reference: string;
102
+ note: string | null;
103
+ }
104
+ interface HolidaySurchargeParams {
105
+ date: string;
106
+ industry: string;
107
+ }
108
+ interface HolidaySurchargeResponse {
109
+ date: string;
110
+ is_holiday: boolean;
111
+ holiday_name: string | null;
112
+ industry: string;
113
+ surcharge_multiplier: number;
114
+ surcharge_basis: string;
115
+ disclaimer: string;
116
+ }
117
+ interface EnergyLabelParams {
118
+ postcode: string;
119
+ houseNumber: string;
120
+ }
121
+ interface EnergyLabelResponse {
122
+ bag_id: string;
123
+ postcode: string;
124
+ house_number: string;
125
+ energy_label: string;
126
+ label_class: string;
127
+ calculation_type: string | null;
128
+ registered_at: string | null;
129
+ valid_until: string | null;
130
+ }
131
+ interface EmissionZoneParams {
132
+ kenteken: string;
133
+ }
134
+ interface EmissionZoneResponse {
135
+ kenteken: string;
136
+ ze_compliant: boolean;
137
+ fuel_types: string[];
138
+ euro_standard: string | null;
139
+ emission_category: string | null;
140
+ vehicle_category: string | null;
141
+ reason: string;
142
+ zones_checked: string[];
143
+ }
144
+ interface TransitDisruptionsParams {
145
+ stationCode: string;
146
+ }
147
+ interface TransitDisruptionItem {
148
+ type: string;
149
+ title: string;
150
+ cause: string | null;
151
+ start: string | null;
152
+ end: string | null;
153
+ impact: string | null;
154
+ }
155
+ interface TransitDisruptionsResponse {
156
+ station_code: string;
157
+ disruptions: TransitDisruptionItem[];
158
+ retrieved_at: string;
159
+ }
160
+ interface GridTriggerParams {
161
+ /** ISO alpha-2 country code (default: "NL") */
162
+ countryCode?: string;
163
+ }
164
+ interface GridTriggerResponse {
165
+ country_code: string;
166
+ current_price_eur_mwh: number;
167
+ negative_price: boolean;
168
+ trigger: boolean;
169
+ period_start: string | null;
170
+ period_end: string | null;
171
+ retrieved_at: string;
172
+ }
173
+ type OmniWebhookEvent = "key.created" | "key.test_created" | "quota.warning" | "quota.exceeded";
174
+ interface RegisterWebhookParams {
175
+ url: string;
176
+ events: OmniWebhookEvent[];
177
+ }
178
+ interface WebhookCreatedResponse {
179
+ webhook_id: string;
180
+ url: string;
181
+ events: OmniWebhookEvent[];
182
+ /** Shown once — store securely for HMAC signature verification */
183
+ secret: string;
184
+ note: string;
185
+ }
186
+ interface WebhookSummary {
187
+ webhook_id: string;
188
+ url: string;
189
+ events: OmniWebhookEvent[];
190
+ active: boolean;
191
+ created_at: string;
192
+ last_fired_at: string | null;
193
+ failure_count: number;
194
+ }
195
+ interface WebhookListResponse {
196
+ webhooks: WebhookSummary[];
197
+ }
198
+
199
+ declare class GeoModule {
200
+ private readonly http;
201
+ constructor(http: HttpClient);
202
+ /**
203
+ * Enrich a Dutch address with BAG data, coordinates, neighbourhood
204
+ * statistics, energy labels and more.
205
+ *
206
+ * @example
207
+ * const result = await omni.geo.enrichAddress({ postcode: "1012LG", houseNumber: 1 });
208
+ */
209
+ enrichAddress(params: AddressEnrichParams): Promise<AddressEnrichResponse>;
210
+ }
211
+
212
+ declare class FinanceModule {
213
+ private readonly http;
214
+ constructor(http: HttpClient);
215
+ /**
216
+ * Resolve an IBAN to its BIC/SWIFT code and bank name.
217
+ *
218
+ * @example
219
+ * const result = await omni.finance.ibanToBic({ iban: "NL91ABNA0417164300" });
220
+ */
221
+ ibanToBic(params: IbanToBicParams): Promise<IbanToBicResponse>;
222
+ /**
223
+ * Verify a Dutch BTW (VAT) number via the EU VIES service and return
224
+ * company metadata.
225
+ *
226
+ * @example
227
+ * const result = await omni.finance.vatVerify({ vatNumber: "NL123456782B01" });
228
+ */
229
+ vatVerify(params: VatVerifyParams): Promise<VatVerifyResponse>;
230
+ }
231
+
232
+ declare class ComplianceModule {
233
+ private readonly http;
234
+ constructor(http: HttpClient);
235
+ /**
236
+ * Validate a Dutch BSN or IBAN number using checksum algorithms.
237
+ *
238
+ * @example
239
+ * const result = await omni.compliance.validateFinance({ type: "iban", number: "NL91ABNA0417164300" });
240
+ */
241
+ validateFinance(params: ValidateFinanceParams): Promise<FinanceValidationResponse>;
242
+ }
243
+
244
+ declare class HrModule {
245
+ private readonly http;
246
+ constructor(http: HttpClient);
247
+ /**
248
+ * Look up the current Dutch statutory minimum wage for a given age.
249
+ *
250
+ * @example
251
+ * const result = await omni.hr.minimumWage({ age: 21 });
252
+ */
253
+ minimumWage(params: MinimumWageParams): Promise<MinimumWageResponse>;
254
+ /**
255
+ * Check whether a given date is a public holiday (and get the applicable
256
+ * surcharge multiplier for a given industry).
257
+ *
258
+ * @example
259
+ * const result = await omni.hr.holidaySurcharge({ date: "2024-12-25", industry: "retail" });
260
+ */
261
+ holidaySurcharge(params: HolidaySurchargeParams): Promise<HolidaySurchargeResponse>;
262
+ }
263
+
264
+ declare class RealEstateModule {
265
+ private readonly http;
266
+ constructor(http: HttpClient);
267
+ /**
268
+ * Retrieve the official EP-Online energy label for a Dutch address.
269
+ *
270
+ * @example
271
+ * const result = await omni.realEstate.energyLabel({ postcode: "1012LG", houseNumber: 1 });
272
+ */
273
+ energyLabel(params: EnergyLabelParams): Promise<EnergyLabelResponse>;
274
+ }
275
+
276
+ declare class LogisticsModule {
277
+ private readonly http;
278
+ constructor(http: HttpClient);
279
+ /**
280
+ * Check whether a vehicle (by Dutch licence plate / kenteken) is allowed
281
+ * in a zero-emission zone (ZE-zone).
282
+ *
283
+ * @example
284
+ * const result = await omni.logistics.emissionZone({ kenteken: "AB123C" });
285
+ */
286
+ emissionZone(params: EmissionZoneParams): Promise<EmissionZoneResponse>;
287
+ /**
288
+ * Retrieve current and upcoming NS train disruptions, optionally filtered
289
+ * by station code.
290
+ *
291
+ * @example
292
+ * const result = await omni.logistics.transitDisruptions({ stationCode: "ASD" });
293
+ */
294
+ transitDisruptions(params?: TransitDisruptionsParams): Promise<TransitDisruptionsResponse>;
295
+ }
296
+
297
+ declare class EnergyModule {
298
+ private readonly http;
299
+ constructor(http: HttpClient);
300
+ /**
301
+ * Retrieve the current Dutch electricity grid congestion status for a
302
+ * given postal code / province.
303
+ *
304
+ * @example
305
+ * const result = await omni.energy.gridTrigger();
306
+ * const result = await omni.energy.gridTrigger({ countryCode: "NL" });
307
+ */
308
+ gridTrigger(params?: GridTriggerParams): Promise<GridTriggerResponse>;
309
+ }
310
+
311
+ declare class WebhooksModule {
312
+ private readonly http;
313
+ constructor(http: HttpClient);
314
+ /**
315
+ * Register a new outbound webhook. OmniZoek will POST to `url` whenever
316
+ * any of the specified `events` fire.
317
+ *
318
+ * @example
319
+ * const wh = await omni.webhooks.register({
320
+ * url: "https://example.com/hook",
321
+ * events: ["quota.warning"],
322
+ * });
323
+ */
324
+ register(params: RegisterWebhookParams): Promise<WebhookCreatedResponse>;
325
+ /**
326
+ * List all registered webhooks for this API key.
327
+ *
328
+ * @example
329
+ * const { webhooks } = await omni.webhooks.list();
330
+ */
331
+ list(): Promise<WebhookListResponse>;
332
+ /**
333
+ * Delete a webhook by its ID.
334
+ *
335
+ * @example
336
+ * await omni.webhooks.delete("wh_abc123");
337
+ */
338
+ delete(webhookId: string): Promise<void>;
339
+ }
340
+
341
+ /**
342
+ * The main entry point for the OmniZoek SDK.
343
+ *
344
+ * @example
345
+ * ```ts
346
+ * import { OmniClient } from "@omnizoek/sdk";
347
+ *
348
+ * const omni = new OmniClient({ apiKey: "omni_live_…" });
349
+ *
350
+ * const address = await omni.geo.enrichAddress({ postcode: "1012LG", houseNumber: 1 });
351
+ * const wage = await omni.hr.minimumWage({ age: 21 });
352
+ * ```
353
+ */
354
+ declare class OmniClient {
355
+ /** Geographic address enrichment (BAG, CBS, energy labels) */
356
+ readonly geo: GeoModule;
357
+ /** Financial utilities (IBAN → BIC, VAT verification) */
358
+ readonly finance: FinanceModule;
359
+ /** Compliance checks (financial institution registers) */
360
+ readonly compliance: ComplianceModule;
361
+ /** HR calculations (minimum wage, holiday surcharge) */
362
+ readonly hr: HrModule;
363
+ /** Real-estate data (EP-Online energy labels) */
364
+ readonly realEstate: RealEstateModule;
365
+ /** Logistics (ZE-zones, NS disruptions) */
366
+ readonly logistics: LogisticsModule;
367
+ /** Energy (grid congestion triggers) */
368
+ readonly energy: EnergyModule;
369
+ /** Outbound webhooks (register, list, delete) */
370
+ readonly webhooks: WebhooksModule;
371
+ constructor(options: OmniClientOptions);
372
+ }
373
+
374
+ /**
375
+ * errors.ts — Typed error classes for the OmniZoek SDK.
376
+ */
377
+ declare class OmniError extends Error {
378
+ readonly status: number;
379
+ readonly code: string;
380
+ readonly detail: string;
381
+ constructor(message: string, status: number, code: string, detail: string);
382
+ }
383
+ /** 401 — API key missing or invalid. */
384
+ declare class OmniAuthError extends OmniError {
385
+ constructor(detail: string);
386
+ }
387
+ /** 404 — Requested resource not found (address, label, etc.). */
388
+ declare class OmniNotFoundError extends OmniError {
389
+ constructor(detail: string);
390
+ }
391
+ /** 422 — Request parameters failed validation. */
392
+ declare class OmniValidationError extends OmniError {
393
+ constructor(detail: string);
394
+ }
395
+ /** 429 — Rate limit exceeded. Retried automatically by the client. */
396
+ declare class OmniRateLimitError extends OmniError {
397
+ readonly retryAfterMs: number;
398
+ constructor(retryAfterMs: number);
399
+ }
400
+ /** 503 — Upstream data source unavailable (BAG, EP-Online, RDW, etc.). */
401
+ declare class OmniUpstreamError extends OmniError {
402
+ constructor(detail: string);
403
+ }
404
+ /** Network-level failure (DNS, timeout, no internet). */
405
+ declare class OmniNetworkError extends Error {
406
+ readonly cause?: Error;
407
+ constructor(cause: unknown);
408
+ }
409
+
410
+ export { type AddressEnrichParams, type AddressEnrichResponse, type EmissionZoneParams, type EmissionZoneResponse, type EnergyLabelParams, type EnergyLabelResponse, type FinanceValidationResponse, type GridTriggerParams, type GridTriggerResponse, type HolidaySurchargeParams, type HolidaySurchargeResponse, type IbanToBicParams, type IbanToBicResponse, type MinimumWageParams, type MinimumWageResponse, OmniAuthError, OmniClient, type OmniClientOptions, OmniError, OmniNetworkError, OmniNotFoundError, OmniRateLimitError, OmniUpstreamError, OmniValidationError, type RegisterWebhookParams, type TransitDisruptionsParams, type TransitDisruptionsResponse, type ValidateFinanceParams, type VatVerifyParams, type VatVerifyResponse, type WebhookCreatedResponse, type WebhookListResponse, type WebhookSummary };