@parseapi/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,553 @@
1
+ /**
2
+ * Response types for the parseAPI public API.
3
+ * Shapes are append-only upstream, so these only ever grow.
4
+ * Every field inside a deep object is optional and nullable: the API ships
5
+ * `deep: {}` when deep was requested but is not unlocked on the plan.
6
+ */
7
+ /** The `deep` key is omitted unless the request asked for it. */
8
+ type Deep<T> = Partial<{
9
+ [K in keyof T]: T[K] | null;
10
+ }>;
11
+ interface IpDeep {
12
+ state: string;
13
+ city: string;
14
+ registry: string;
15
+ datacenter: boolean;
16
+ relay: boolean;
17
+ tor: boolean;
18
+ provider: string;
19
+ }
20
+ interface Ip {
21
+ ip: string;
22
+ country: string | null;
23
+ country_name: string | null;
24
+ continent: string | null;
25
+ asn: string | null;
26
+ asn_name: string | null;
27
+ deep?: Deep<IpDeep>;
28
+ }
29
+ interface Continent {
30
+ continent: string;
31
+ name: string;
32
+ region: string;
33
+ subregion: string;
34
+ population: number | null;
35
+ area: number | null;
36
+ emoji: string;
37
+ }
38
+ interface ContinentCountryItem {
39
+ country: string;
40
+ name: string;
41
+ }
42
+ interface ContinentCountries {
43
+ continent: string;
44
+ countries: ContinentCountryItem[];
45
+ }
46
+ interface Country {
47
+ country: string;
48
+ iso3: string;
49
+ numeric: number;
50
+ name: string;
51
+ full_name: string | null;
52
+ local_name: string | null;
53
+ demonym: string | null;
54
+ capital: string | null;
55
+ continent: string;
56
+ region: string | null;
57
+ subregion: string | null;
58
+ population: number | null;
59
+ area: number | null;
60
+ currency: string | null;
61
+ currency_name: string | null;
62
+ currency_symbol: string | null;
63
+ tld: string | null;
64
+ emoji: string | null;
65
+ languages: string[];
66
+ borders: string[];
67
+ }
68
+ interface CountryStateItem {
69
+ state: string;
70
+ name: string;
71
+ type: string | null;
72
+ }
73
+ interface CountryStates {
74
+ country: string;
75
+ states: CountryStateItem[];
76
+ }
77
+ interface State {
78
+ state: string;
79
+ name: string;
80
+ local_name: string | null;
81
+ type: string | null;
82
+ country: string;
83
+ country_name: string | null;
84
+ latitude: number | null;
85
+ longitude: number | null;
86
+ population: number | null;
87
+ area: number | null;
88
+ timezone: string | null;
89
+ }
90
+ interface StateDistrictItem {
91
+ district: string;
92
+ name: string;
93
+ type: string | null;
94
+ }
95
+ interface StateDistricts {
96
+ state: string;
97
+ state_name: string | null;
98
+ country: string;
99
+ country_name: string | null;
100
+ districts: StateDistrictItem[];
101
+ }
102
+ interface District {
103
+ district: string;
104
+ name: string;
105
+ type: string | null;
106
+ state: string | null;
107
+ state_name: string | null;
108
+ country: string;
109
+ country_name: string | null;
110
+ latitude: number | null;
111
+ longitude: number | null;
112
+ population: number | null;
113
+ land_area: number | null;
114
+ water_area: number | null;
115
+ }
116
+ interface City {
117
+ name: string;
118
+ local_name: string | null;
119
+ state: string | null;
120
+ state_name: string | null;
121
+ country: string;
122
+ latitude: number | null;
123
+ longitude: number | null;
124
+ population: number | null;
125
+ timezone: string | null;
126
+ /** Minted parse id (`city_` + 12 chars). Stable pin via `/city/id/{id}`. */
127
+ id: string;
128
+ }
129
+ /** Nearest-city lookups add the distance from the query point. */
130
+ interface CityNearest extends City {
131
+ distance: number;
132
+ distance_mi: number;
133
+ }
134
+ interface CitySearch {
135
+ q: string;
136
+ country?: string;
137
+ state?: string;
138
+ cities: City[];
139
+ }
140
+ interface Postal {
141
+ postal: string;
142
+ city: string | null;
143
+ city_local: string | null;
144
+ district: string | null;
145
+ district_name: string | null;
146
+ district_name_local: string | null;
147
+ state: string | null;
148
+ state_name: string | null;
149
+ state_name_local: string | null;
150
+ country: string;
151
+ latitude: number | null;
152
+ longitude: number | null;
153
+ elevation: number | null;
154
+ elevation_ft: number | null;
155
+ population: number | null;
156
+ timezone: string | null;
157
+ currency: string | null;
158
+ neighbors: string[];
159
+ }
160
+ interface PostalNearbyItem {
161
+ postal: string;
162
+ city: string | null;
163
+ state: string | null;
164
+ country: string;
165
+ distance: number;
166
+ distance_mi: number;
167
+ }
168
+ interface PostalNearby {
169
+ postal: string;
170
+ country: string;
171
+ radius: number;
172
+ unit: string;
173
+ nearby: PostalNearbyItem[];
174
+ }
175
+ interface PostalDistanceEnd {
176
+ postal: string;
177
+ city: string | null;
178
+ }
179
+ interface PostalDistance {
180
+ country: string;
181
+ from: PostalDistanceEnd;
182
+ to: PostalDistanceEnd;
183
+ distance: number;
184
+ distance_mi: number;
185
+ }
186
+ interface EmailDeep {
187
+ deliverable: boolean;
188
+ catchall: boolean;
189
+ }
190
+ interface Email {
191
+ email: string;
192
+ valid: boolean;
193
+ domain: string | null;
194
+ domain_valid: boolean | null;
195
+ role: boolean;
196
+ disposable: boolean;
197
+ deep?: Deep<EmailDeep>;
198
+ }
199
+ interface PhoneDeep {
200
+ type: 'mobile' | 'landline' | 'toll_free' | 'unknown';
201
+ region: string;
202
+ }
203
+ interface Phone {
204
+ valid: boolean;
205
+ e164: string | null;
206
+ country: string | null;
207
+ national: string | null;
208
+ international: string | null;
209
+ deep?: Deep<PhoneDeep>;
210
+ }
211
+ interface MxRecord {
212
+ priority: number;
213
+ host: string;
214
+ }
215
+ interface DomainRegistration {
216
+ registered: boolean;
217
+ created: string | null;
218
+ updated: string | null;
219
+ expires: string | null;
220
+ registrar: string | null;
221
+ status: string[];
222
+ dnssec: boolean;
223
+ }
224
+ interface DomainDeep {
225
+ a: string[];
226
+ aaaa: string[];
227
+ ns: string[];
228
+ mx: MxRecord[];
229
+ txt: string[];
230
+ provider: string;
231
+ registration: DomainRegistration;
232
+ }
233
+ interface Domain {
234
+ domain: string;
235
+ available: boolean;
236
+ deep?: Deep<DomainDeep>;
237
+ }
238
+ interface Mx {
239
+ domain: string;
240
+ mx: MxRecord[];
241
+ }
242
+ interface UseragentDeviceDeep {
243
+ type: string | null;
244
+ brand: string | null;
245
+ model: string | null;
246
+ cpu: string | null;
247
+ touchscreen: boolean | null;
248
+ }
249
+ interface UseragentOsDeep {
250
+ name: string | null;
251
+ version: string | null;
252
+ platform: string | null;
253
+ }
254
+ interface UseragentBrowserBrand {
255
+ brand: string;
256
+ version: string;
257
+ }
258
+ interface UseragentBrowserDeep {
259
+ name: string | null;
260
+ version: string | null;
261
+ type: string | null;
262
+ brands?: UseragentBrowserBrand[];
263
+ }
264
+ interface UseragentEngineDeep {
265
+ name: string | null;
266
+ version: string | null;
267
+ }
268
+ interface UseragentDeep {
269
+ device: UseragentDeviceDeep;
270
+ os: UseragentOsDeep;
271
+ browser: UseragentBrowserDeep;
272
+ engine: UseragentEngineDeep;
273
+ headless: boolean;
274
+ bot?: Record<string, unknown>;
275
+ ai?: boolean;
276
+ }
277
+ interface Useragent {
278
+ useragent: string;
279
+ device: string | null;
280
+ os: string | null;
281
+ browser: string | null;
282
+ bot: boolean;
283
+ mobile: boolean;
284
+ deep?: Deep<UseragentDeep>;
285
+ }
286
+ interface Currency {
287
+ currency: string;
288
+ numeric: number | null;
289
+ name: string;
290
+ name_plural: string | null;
291
+ symbol: string | null;
292
+ symbol_native: string | null;
293
+ digits: number | null;
294
+ countries: string[];
295
+ }
296
+ /** One language by BCP 47 shortest code (en) or ISO 639-3 (eng). Codes are lowercase. */
297
+ interface Language {
298
+ language: string;
299
+ iso3: string | null;
300
+ name: string;
301
+ local_name: string | null;
302
+ script: string | null;
303
+ direction: 'ltr' | 'rtl' | string;
304
+ countries: string[];
305
+ }
306
+ interface CurrencyRate {
307
+ base: string;
308
+ quote: string;
309
+ rate: number;
310
+ date: string;
311
+ source?: string;
312
+ }
313
+ interface TimezoneNextDst {
314
+ at: string;
315
+ dst: boolean;
316
+ offset: string;
317
+ abbreviation: string;
318
+ }
319
+ interface Timezone {
320
+ timezone: string;
321
+ name: string | null;
322
+ abbreviation: string;
323
+ offset: string;
324
+ offset_minutes: number;
325
+ dst: boolean;
326
+ next_dst: TimezoneNextDst | null;
327
+ }
328
+ interface Holiday {
329
+ date: string;
330
+ name: string;
331
+ local_name: string | null;
332
+ /** 'public' for an official day off, 'observance' for cultural days. */
333
+ type: string;
334
+ regions: string[] | null;
335
+ substitute: boolean;
336
+ }
337
+ interface HolidayYear {
338
+ country: string;
339
+ year: number;
340
+ holidays: Holiday[];
341
+ }
342
+ interface HolidayDate {
343
+ country: string;
344
+ date: string;
345
+ holiday: Holiday | null;
346
+ }
347
+ interface Elevation {
348
+ latitude: number;
349
+ longitude: number;
350
+ elevation: number | null;
351
+ elevation_ft: number | null;
352
+ resolution: number | null;
353
+ }
354
+ interface PointDeep {
355
+ city: CityNearest;
356
+ timezone: Timezone;
357
+ }
358
+ interface Point {
359
+ latitude: number;
360
+ longitude: number;
361
+ country: string | null;
362
+ country_name: string | null;
363
+ state: string | null;
364
+ state_name: string | null;
365
+ district: string | null;
366
+ district_name: string | null;
367
+ elevation: number | null;
368
+ elevation_ft: number | null;
369
+ resolution: number | null;
370
+ deep?: Deep<PointDeep>;
371
+ }
372
+ interface WeatherForecastPeriod {
373
+ name: string;
374
+ start: string | null;
375
+ end: string | null;
376
+ daytime: boolean | null;
377
+ temperature: number | null;
378
+ temperature_f: number | null;
379
+ precipitation_chance: number | null;
380
+ wind_speed: number | null;
381
+ wind_speed_mph: number | null;
382
+ wind_direction: number | null;
383
+ condition: string | null;
384
+ condition_name: string | null;
385
+ condition_emoji: string | null;
386
+ }
387
+ interface WeatherAlert {
388
+ event: string;
389
+ severity: string | null;
390
+ urgency: string | null;
391
+ headline: string | null;
392
+ onset: string | null;
393
+ expires: string | null;
394
+ }
395
+ interface WeatherDeep {
396
+ forecast: WeatherForecastPeriod[];
397
+ alerts: WeatherAlert[];
398
+ }
399
+ interface Weather {
400
+ latitude: number;
401
+ longitude: number;
402
+ temperature: number | null;
403
+ temperature_f: number | null;
404
+ feels_like: number | null;
405
+ feels_like_f: number | null;
406
+ dewpoint: number | null;
407
+ dewpoint_f: number | null;
408
+ humidity: number | null;
409
+ wind_speed: number | null;
410
+ wind_speed_mph: number | null;
411
+ wind_gust: number | null;
412
+ wind_gust_mph: number | null;
413
+ wind_direction: number | null;
414
+ pressure: number | null;
415
+ pressure_inhg: number | null;
416
+ visibility: number | null;
417
+ visibility_mi: number | null;
418
+ condition: string | null;
419
+ condition_name: string | null;
420
+ condition_emoji: string | null;
421
+ observed_at: string | null;
422
+ station: string;
423
+ station_name: string | null;
424
+ station_distance: number;
425
+ station_distance_mi: number;
426
+ source: string;
427
+ source_name: string | null;
428
+ deep?: Deep<WeatherDeep>;
429
+ }
430
+ interface EmojiSkin {
431
+ emoji: string;
432
+ tone: string;
433
+ unicode: string | null;
434
+ hex: string | null;
435
+ }
436
+ interface Emoji {
437
+ emoji: string;
438
+ name: string;
439
+ shortcodes: string[];
440
+ codepoints: string[];
441
+ hex: string;
442
+ category: string | null;
443
+ status: string | null;
444
+ version: string | null;
445
+ keywords: string[];
446
+ skins: EmojiSkin[];
447
+ }
448
+ interface EmojiSearch {
449
+ q: string;
450
+ emojis: Emoji[];
451
+ }
452
+
453
+ /** Every non-2xx response from the API. Branch on `code`, never on `message`. */
454
+ declare class ParseAPIError extends Error {
455
+ /** HTTP status */
456
+ readonly status: number;
457
+ /** Machine-readable error code, e.g. 'not_found', 'invalid_api_key', 'rate_limited' */
458
+ readonly code: string;
459
+ /** Link to the docs section for this error */
460
+ readonly docs: string | null;
461
+ /** Send this if you contact support */
462
+ readonly requestId: string | null;
463
+ constructor(status: number, code: string, message: string, docs: string | null, requestId: string | null);
464
+ }
465
+ interface ParseAPIOptions {
466
+ /** Override https://api.parseapi.com (tests, canaries). Also read from PARSEAPI_BASE_URL. */
467
+ baseUrl?: string;
468
+ /** Per-attempt timeout in milliseconds. Default 10000. */
469
+ timeoutMs?: number;
470
+ /** Retries after the first attempt on network errors / 429 / 5xx. Default 2, 0 disables. */
471
+ retries?: number;
472
+ /** Custom fetch implementation (instrumentation, proxies). */
473
+ fetch?: typeof fetch;
474
+ }
475
+ interface DeepOption {
476
+ /** Request the nested deep object. Paid on most endpoints. */
477
+ deep?: boolean;
478
+ }
479
+ declare function parseAPI(apiKey?: string, options?: ParseAPIOptions): {
480
+ ip: ((ip: string, opts?: DeepOption) => Promise<Ip>) & {
481
+ self: (opts?: DeepOption) => Promise<Ip>;
482
+ };
483
+ continent: ((code: string) => Promise<Continent>) & {
484
+ countries: (code: string) => Promise<ContinentCountries>;
485
+ };
486
+ country: ((code: string) => Promise<Country>) & {
487
+ states: (code: string) => Promise<CountryStates>;
488
+ };
489
+ state: ((code: string, opts: {
490
+ country: string;
491
+ }) => Promise<State>) & {
492
+ districts: (code: string, opts: {
493
+ country: string;
494
+ }) => Promise<StateDistricts>;
495
+ };
496
+ district: (code: string, opts?: {
497
+ country?: string;
498
+ }) => Promise<District>;
499
+ city: ((name: string, opts?: {
500
+ country?: string;
501
+ state?: string;
502
+ }) => Promise<City>) & {
503
+ id: (id: string) => Promise<City>;
504
+ search: (q: string, opts?: {
505
+ country?: string;
506
+ state?: string;
507
+ limit?: number;
508
+ }) => Promise<CitySearch>;
509
+ nearest: (lat: number, lon: number) => Promise<CityNearest>;
510
+ };
511
+ postal: ((code: string, opts: {
512
+ country: string;
513
+ }) => Promise<Postal>) & {
514
+ nearby: (code: string, opts: {
515
+ country: string;
516
+ radius?: number;
517
+ unit?: "km" | "mi";
518
+ }) => Promise<PostalNearby>;
519
+ distance: (from: string, to: string, opts: {
520
+ country: string;
521
+ }) => Promise<PostalDistance>;
522
+ };
523
+ email: (email: string, opts?: DeepOption) => Promise<Email>;
524
+ phone: (number: string, opts?: {
525
+ country?: string;
526
+ } & DeepOption) => Promise<Phone>;
527
+ domain: (domain: string, opts?: DeepOption) => Promise<Domain>;
528
+ mx: (domain: string) => Promise<Mx>;
529
+ useragent: (ua: string, opts?: DeepOption) => Promise<Useragent>;
530
+ currency: ((code: string) => Promise<Currency>) & {
531
+ rate: (base: string, quote: string) => Promise<CurrencyRate>;
532
+ };
533
+ language: (code: string) => Promise<Language>;
534
+ timezone: (id: string, opts?: {
535
+ at?: string;
536
+ }) => Promise<Timezone>;
537
+ holiday: ((country: string, opts?: {
538
+ year?: number;
539
+ }) => Promise<HolidayYear>) & {
540
+ date: (country: string, date: string) => Promise<HolidayDate>;
541
+ };
542
+ elevation: (lat: number, lon: number) => Promise<Elevation>;
543
+ point: (lat: number, lon: number, opts?: DeepOption) => Promise<Point>;
544
+ weather: (lat: number, lon: number, opts?: DeepOption) => Promise<Weather>;
545
+ emoji: ((emoji: string) => Promise<Emoji>) & {
546
+ search: (q: string, opts?: {
547
+ limit?: number;
548
+ }) => Promise<EmojiSearch>;
549
+ };
550
+ };
551
+ type ParseAPIClient = ReturnType<typeof parseAPI>;
552
+
553
+ export { type City, type CityNearest, type CitySearch, type Continent, type ContinentCountries, type ContinentCountryItem, type Country, type CountryStateItem, type CountryStates, type Currency, type CurrencyRate, type Deep, type District, type Domain, type DomainDeep, type DomainRegistration, type Elevation, type Email, type EmailDeep, type Emoji, type EmojiSearch, type EmojiSkin, type Holiday, type HolidayDate, type HolidayYear, type Ip, type IpDeep, type Language, type Mx, type MxRecord, type ParseAPIClient, ParseAPIError, type ParseAPIOptions, type Phone, type PhoneDeep, type Point, type PointDeep, type Postal, type PostalDistance, type PostalDistanceEnd, type PostalNearby, type PostalNearbyItem, type State, type StateDistrictItem, type StateDistricts, type Timezone, type TimezoneNextDst, type Useragent, type UseragentBrowserBrand, type UseragentBrowserDeep, type UseragentDeep, type UseragentDeviceDeep, type UseragentEngineDeep, type UseragentOsDeep, type Weather, type WeatherAlert, type WeatherDeep, type WeatherForecastPeriod, parseAPI };