catastrogps 1.0.0 → 1.2.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/README.md +132 -41
- package/dist/index.d.mts +293 -2
- package/dist/index.d.ts +293 -2
- package/dist/index.js +291 -56
- package/dist/index.mjs +286 -55
- package/package.json +9 -4
package/dist/index.d.ts
CHANGED
|
@@ -14,11 +14,33 @@ interface CatastroGPSOptions {
|
|
|
14
14
|
interface CountryOption<C extends string = CountryCode> {
|
|
15
15
|
country?: C;
|
|
16
16
|
}
|
|
17
|
+
declare const ADDRESS_COUNTRY_CODES: readonly ["ES", "FR", "IT", "DE", "AT", "NL", "BE", "PL", "CH", "CZ", "DK", "NO", "FI", "EE", "LV", "LT", "SI", "SK", "BG", "GR", "CY", "LU", "LI", "IS", "IE", "UK", "PT"];
|
|
18
|
+
type AddressCountryCode = (typeof ADDRESS_COUNTRY_CODES)[number];
|
|
19
|
+
declare const UNITS_COUNTRY_CODES: readonly ["ES", "PV", "NA"];
|
|
20
|
+
type UnitsCountryCode = (typeof UNITS_COUNTRY_CODES)[number];
|
|
21
|
+
interface PrepaidOverage {
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
balance?: number;
|
|
24
|
+
unitPrice?: number;
|
|
25
|
+
remainingUnits?: number;
|
|
26
|
+
}
|
|
27
|
+
interface BurstLimit {
|
|
28
|
+
limit?: number;
|
|
29
|
+
remaining?: number;
|
|
30
|
+
resetSeconds?: number;
|
|
31
|
+
}
|
|
32
|
+
interface FincaCap {
|
|
33
|
+
cap?: number;
|
|
34
|
+
used?: number;
|
|
35
|
+
}
|
|
17
36
|
interface Quota {
|
|
18
37
|
plan?: string;
|
|
19
38
|
limit?: number;
|
|
20
39
|
remaining?: number;
|
|
21
40
|
resetsAt?: string;
|
|
41
|
+
overage?: PrepaidOverage;
|
|
42
|
+
rateLimit?: BurstLimit;
|
|
43
|
+
fincaCap?: FincaCap;
|
|
22
44
|
}
|
|
23
45
|
interface Parcel {
|
|
24
46
|
refCatastral: string;
|
|
@@ -117,6 +139,233 @@ interface ResolveResult {
|
|
|
117
139
|
candidates: ResolveCandidate[];
|
|
118
140
|
ambiguous: boolean;
|
|
119
141
|
}
|
|
142
|
+
interface AddressCandidatesQuery {
|
|
143
|
+
q?: string;
|
|
144
|
+
country?: AddressCountryCode;
|
|
145
|
+
street?: string;
|
|
146
|
+
number?: number;
|
|
147
|
+
municipality?: string;
|
|
148
|
+
postcode?: string;
|
|
149
|
+
limit?: number;
|
|
150
|
+
}
|
|
151
|
+
interface AddressCandidate {
|
|
152
|
+
refCatastral: string;
|
|
153
|
+
pais: 'ES' | 'PV' | 'NA' | string;
|
|
154
|
+
direccion: string;
|
|
155
|
+
numero?: number;
|
|
156
|
+
codigoPostal?: string;
|
|
157
|
+
municipio: string;
|
|
158
|
+
provincia: string;
|
|
159
|
+
latitud: number;
|
|
160
|
+
longitud: number;
|
|
161
|
+
confianza: number;
|
|
162
|
+
coincideNumero: boolean;
|
|
163
|
+
coincideMunicipio: boolean;
|
|
164
|
+
enCopia: boolean;
|
|
165
|
+
direccionCatastro?: string;
|
|
166
|
+
uso?: string;
|
|
167
|
+
viviendas?: number;
|
|
168
|
+
anioConstruccion?: number;
|
|
169
|
+
}
|
|
170
|
+
interface AddressCandidatesResult {
|
|
171
|
+
consulta: {
|
|
172
|
+
texto: string;
|
|
173
|
+
calle?: string;
|
|
174
|
+
numero?: number;
|
|
175
|
+
municipio?: string;
|
|
176
|
+
codigoPostal?: string;
|
|
177
|
+
};
|
|
178
|
+
candidatos: AddressCandidate[];
|
|
179
|
+
attribution: string;
|
|
180
|
+
}
|
|
181
|
+
interface Unit {
|
|
182
|
+
refCatastral: string;
|
|
183
|
+
escalera: string;
|
|
184
|
+
planta: string;
|
|
185
|
+
puerta: string;
|
|
186
|
+
uso: string;
|
|
187
|
+
superficie: number;
|
|
188
|
+
descripcion: string;
|
|
189
|
+
participacion?: number;
|
|
190
|
+
anio?: number;
|
|
191
|
+
direccion?: string;
|
|
192
|
+
}
|
|
193
|
+
interface Construction {
|
|
194
|
+
escalera: string;
|
|
195
|
+
planta: string;
|
|
196
|
+
puerta: string;
|
|
197
|
+
uso: string;
|
|
198
|
+
superficie: number;
|
|
199
|
+
descripcion: string;
|
|
200
|
+
}
|
|
201
|
+
interface UnitsPageData {
|
|
202
|
+
refCatastral: string;
|
|
203
|
+
direccion?: string;
|
|
204
|
+
codigoPostal?: string;
|
|
205
|
+
municipio?: string;
|
|
206
|
+
provincia?: string;
|
|
207
|
+
usoGeneral?: string;
|
|
208
|
+
superficieTotal?: number;
|
|
209
|
+
anioConstruccion?: number;
|
|
210
|
+
participacion?: string;
|
|
211
|
+
totalUnidades: number;
|
|
212
|
+
totalUnidadesFinca: number;
|
|
213
|
+
unidades: Unit[];
|
|
214
|
+
construcciones?: Construction[];
|
|
215
|
+
truncated: boolean;
|
|
216
|
+
nextCursor?: string;
|
|
217
|
+
dataSource: 'clone' | 'catastro' | string;
|
|
218
|
+
dataDate: string;
|
|
219
|
+
attribution: string;
|
|
220
|
+
}
|
|
221
|
+
interface UnitsPage {
|
|
222
|
+
cursor?: string;
|
|
223
|
+
etag?: string;
|
|
224
|
+
notModified: boolean;
|
|
225
|
+
data: UnitsPageData;
|
|
226
|
+
}
|
|
227
|
+
interface UnitsResult {
|
|
228
|
+
refCatastral: string;
|
|
229
|
+
direccion?: string;
|
|
230
|
+
codigoPostal?: string;
|
|
231
|
+
municipio?: string;
|
|
232
|
+
provincia?: string;
|
|
233
|
+
usoGeneral?: string;
|
|
234
|
+
anioConstruccion?: number;
|
|
235
|
+
totalUnidadesFinca: number;
|
|
236
|
+
unidades: Unit[];
|
|
237
|
+
construcciones: Construction[];
|
|
238
|
+
dataSource: string;
|
|
239
|
+
dataDate: string;
|
|
240
|
+
attribution: string;
|
|
241
|
+
changed: boolean;
|
|
242
|
+
pages: UnitsPage[];
|
|
243
|
+
}
|
|
244
|
+
interface GetUnitsOptions {
|
|
245
|
+
country?: UnitsCountryCode;
|
|
246
|
+
previous?: UnitsResult;
|
|
247
|
+
}
|
|
248
|
+
interface LocatedOptions extends CountryOption<Exclude<CountryCode, 'UK' | 'HR'>> {
|
|
249
|
+
lat?: number;
|
|
250
|
+
lng?: number;
|
|
251
|
+
}
|
|
252
|
+
interface DataSource {
|
|
253
|
+
name?: string;
|
|
254
|
+
provider?: string;
|
|
255
|
+
license?: string;
|
|
256
|
+
attribution?: string;
|
|
257
|
+
url?: string;
|
|
258
|
+
resolution?: string;
|
|
259
|
+
edition?: string;
|
|
260
|
+
}
|
|
261
|
+
type BlockStatus = 'ok' | 'no_data' | 'unavailable';
|
|
262
|
+
interface ProtectedSite {
|
|
263
|
+
code: string;
|
|
264
|
+
name: string;
|
|
265
|
+
type?: 'SPA' | 'SCI' | 'SPA_SCI' | string;
|
|
266
|
+
designation?: string;
|
|
267
|
+
country?: string;
|
|
268
|
+
overlap_pct?: number | null;
|
|
269
|
+
}
|
|
270
|
+
interface Terrain {
|
|
271
|
+
refcat: string;
|
|
272
|
+
country: string;
|
|
273
|
+
relief: {
|
|
274
|
+
status: BlockStatus;
|
|
275
|
+
elevation_m?: {
|
|
276
|
+
mean: number;
|
|
277
|
+
min: number;
|
|
278
|
+
max: number;
|
|
279
|
+
};
|
|
280
|
+
slope?: {
|
|
281
|
+
mean_pct: number;
|
|
282
|
+
mean_deg: number;
|
|
283
|
+
max_pct: number;
|
|
284
|
+
class: string;
|
|
285
|
+
max_class: string;
|
|
286
|
+
share_over_10_pct: number;
|
|
287
|
+
classes_pct: Record<string, number>;
|
|
288
|
+
};
|
|
289
|
+
aspect?: {
|
|
290
|
+
dominant: string;
|
|
291
|
+
dominant_share_pct: number;
|
|
292
|
+
mean_deg: number | null;
|
|
293
|
+
flat_share_pct: number;
|
|
294
|
+
sectors_pct: Record<string, number>;
|
|
295
|
+
};
|
|
296
|
+
sample?: {
|
|
297
|
+
method: string;
|
|
298
|
+
cells: number;
|
|
299
|
+
resolution_m: number;
|
|
300
|
+
};
|
|
301
|
+
source?: DataSource;
|
|
302
|
+
};
|
|
303
|
+
protected_areas: {
|
|
304
|
+
status: BlockStatus;
|
|
305
|
+
intersects?: boolean;
|
|
306
|
+
inside?: boolean;
|
|
307
|
+
max_overlap_pct?: number | null;
|
|
308
|
+
natura2000?: ProtectedSite[];
|
|
309
|
+
national?: ProtectedSite[];
|
|
310
|
+
method?: string;
|
|
311
|
+
sources?: DataSource[];
|
|
312
|
+
};
|
|
313
|
+
climate?: {
|
|
314
|
+
status: BlockStatus;
|
|
315
|
+
baseline?: Record<string, number>;
|
|
316
|
+
recent?: Record<string, number>;
|
|
317
|
+
[key: string]: unknown;
|
|
318
|
+
};
|
|
319
|
+
calculated_at?: string;
|
|
320
|
+
provenance?: string;
|
|
321
|
+
}
|
|
322
|
+
interface GroundMotion {
|
|
323
|
+
refcat: string;
|
|
324
|
+
country: string;
|
|
325
|
+
status: BlockStatus;
|
|
326
|
+
reason?: 'no_reflectors' | 'outside_coverage' | 'parcel_too_large' | string;
|
|
327
|
+
period?: {
|
|
328
|
+
from: string;
|
|
329
|
+
to: string;
|
|
330
|
+
label: string;
|
|
331
|
+
};
|
|
332
|
+
ground_motion?: {
|
|
333
|
+
class: string;
|
|
334
|
+
worst_class?: string;
|
|
335
|
+
vertical: {
|
|
336
|
+
mean_mm_year: number;
|
|
337
|
+
max_subsidence_mm_year?: number;
|
|
338
|
+
max_uplift_mm_year?: number;
|
|
339
|
+
std_mm_year?: number;
|
|
340
|
+
acceleration_mm_year2?: number;
|
|
341
|
+
rmse_mm?: number;
|
|
342
|
+
};
|
|
343
|
+
east_west?: {
|
|
344
|
+
mean_mm_year: number;
|
|
345
|
+
std_mm_year?: number;
|
|
346
|
+
};
|
|
347
|
+
yearly_displacement?: Array<{
|
|
348
|
+
year: number;
|
|
349
|
+
mm: number;
|
|
350
|
+
}>;
|
|
351
|
+
cells_with_data: number;
|
|
352
|
+
cells_considered: number;
|
|
353
|
+
coverage_pct: number;
|
|
354
|
+
basis?: 'parcel' | 'surroundings' | string;
|
|
355
|
+
cell_size_m?: number;
|
|
356
|
+
};
|
|
357
|
+
source?: DataSource;
|
|
358
|
+
calculated_at?: string;
|
|
359
|
+
provenance?: string;
|
|
360
|
+
}
|
|
361
|
+
type MarketData = Record<string, unknown>;
|
|
362
|
+
type ScoreData = Record<string, unknown>;
|
|
363
|
+
type ValueHistory = Record<string, unknown>;
|
|
364
|
+
type Comparison = Record<string, unknown>;
|
|
365
|
+
interface CompareItem {
|
|
366
|
+
reference: string;
|
|
367
|
+
country: EnrichmentCountryCode;
|
|
368
|
+
}
|
|
120
369
|
|
|
121
370
|
declare class ExportResource {
|
|
122
371
|
private readonly client;
|
|
@@ -124,6 +373,14 @@ declare class ExportResource {
|
|
|
124
373
|
file(reference: string, format: ExportFormat, options?: CountryOption): Promise<ArrayBuffer>;
|
|
125
374
|
}
|
|
126
375
|
|
|
376
|
+
declare class FincasResource {
|
|
377
|
+
private readonly client;
|
|
378
|
+
constructor(client: CatastroGPS);
|
|
379
|
+
searchAddress(query: string | AddressCandidatesQuery): Promise<AddressCandidatesResult>;
|
|
380
|
+
pages(refcat14: string, options?: GetUnitsOptions): AsyncGenerator<UnitsPage>;
|
|
381
|
+
units(refcat14: string, options?: GetUnitsOptions): Promise<UnitsResult>;
|
|
382
|
+
}
|
|
383
|
+
|
|
127
384
|
interface PointQuery extends CountryOption {
|
|
128
385
|
lat: number;
|
|
129
386
|
lng: number;
|
|
@@ -137,6 +394,12 @@ declare class ParcelsResource {
|
|
|
137
394
|
geometry(reference: string, options?: CountryOption<Exclude<CountryCode, 'UK'>>): Promise<ParcelGeometry>;
|
|
138
395
|
solar(reference: string, options?: CountryOption<EnrichmentCountryCode>): Promise<SolarEstimate>;
|
|
139
396
|
agriculture(reference: string, options?: CountryOption<EnrichmentCountryCode>): Promise<AgricultureData>;
|
|
397
|
+
terrain(reference: string, options?: LocatedOptions): Promise<Terrain>;
|
|
398
|
+
groundMotion(reference: string, options?: LocatedOptions): Promise<GroundMotion>;
|
|
399
|
+
market(reference: string, options?: CountryOption<EnrichmentCountryCode>): Promise<MarketData>;
|
|
400
|
+
score(reference: string, options?: CountryOption<EnrichmentCountryCode>): Promise<ScoreData>;
|
|
401
|
+
valueHistory(reference: string, options?: CountryOption<EnrichmentCountryCode | 'AT'>): Promise<ValueHistory>;
|
|
402
|
+
compare(parcels: CompareItem[]): Promise<Comparison>;
|
|
140
403
|
}
|
|
141
404
|
|
|
142
405
|
declare const DEFAULT_BASE_URL = "https://api.catastrogps.es";
|
|
@@ -147,10 +410,18 @@ interface RequestOptions {
|
|
|
147
410
|
query?: Query;
|
|
148
411
|
body?: unknown;
|
|
149
412
|
raw?: boolean;
|
|
413
|
+
ifNoneMatch?: string;
|
|
414
|
+
}
|
|
415
|
+
interface ConditionalResponse<T> {
|
|
416
|
+
data?: T;
|
|
417
|
+
etag?: string;
|
|
418
|
+
notModified: boolean;
|
|
419
|
+
quota?: Quota;
|
|
150
420
|
}
|
|
151
421
|
declare class CatastroGPS {
|
|
152
422
|
readonly parcels: ParcelsResource;
|
|
153
423
|
readonly export: ExportResource;
|
|
424
|
+
readonly fincas: FincasResource;
|
|
154
425
|
lastQuota?: Quota;
|
|
155
426
|
private readonly apiKey;
|
|
156
427
|
private readonly baseUrl;
|
|
@@ -158,18 +429,23 @@ declare class CatastroGPS {
|
|
|
158
429
|
private readonly maxRetries;
|
|
159
430
|
private readonly fetchImpl;
|
|
160
431
|
constructor(options?: CatastroGPSOptions);
|
|
432
|
+
searchAddressCandidates(query: string | AddressCandidatesQuery): Promise<AddressCandidatesResult>;
|
|
433
|
+
getUnits(refcat14: string, options?: GetUnitsOptions): Promise<UnitsResult>;
|
|
434
|
+
iterUnitPages(refcat14: string, options?: GetUnitsOptions): AsyncGenerator<UnitsPage>;
|
|
161
435
|
resolve(text: string, options?: {
|
|
162
436
|
hint?: string;
|
|
163
437
|
}): Promise<ResolveResult>;
|
|
164
438
|
request<T>(method: 'GET' | 'POST', path: string, options?: RequestOptions): Promise<T>;
|
|
439
|
+
conditionalRequest<T>(method: 'GET' | 'POST', path: string, options?: RequestOptions): Promise<ConditionalResponse<T>>;
|
|
165
440
|
private once;
|
|
166
441
|
private buildUrl;
|
|
167
442
|
private shouldRetry;
|
|
168
443
|
private retryDelayMs;
|
|
169
444
|
private captureQuota;
|
|
170
445
|
}
|
|
446
|
+
declare function readQuota(headers: Headers): Quota | undefined;
|
|
171
447
|
|
|
172
|
-
declare const VERSION = "1.
|
|
448
|
+
declare const VERSION = "1.2.0";
|
|
173
449
|
|
|
174
450
|
declare class CatastroGPSError extends Error {
|
|
175
451
|
readonly status?: number;
|
|
@@ -195,8 +471,20 @@ declare class NotFoundError extends CatastroGPSError {
|
|
|
195
471
|
declare class ValidationError extends CatastroGPSError {
|
|
196
472
|
name: string;
|
|
197
473
|
}
|
|
474
|
+
declare class PlaceNameError extends ValidationError {
|
|
475
|
+
name: string;
|
|
476
|
+
get location(): {
|
|
477
|
+
lat: number;
|
|
478
|
+
lng: number;
|
|
479
|
+
address?: string;
|
|
480
|
+
label?: string;
|
|
481
|
+
} | undefined;
|
|
482
|
+
}
|
|
198
483
|
declare class CoverageError extends CatastroGPSError {
|
|
199
484
|
name: string;
|
|
485
|
+
get country(): string | undefined;
|
|
486
|
+
get feature(): string | undefined;
|
|
487
|
+
get supportedCountries(): string[];
|
|
200
488
|
}
|
|
201
489
|
declare class AmbiguousReferenceError extends CatastroGPSError {
|
|
202
490
|
name: string;
|
|
@@ -208,6 +496,8 @@ declare class AmbiguousReferenceError extends CatastroGPSError {
|
|
|
208
496
|
}
|
|
209
497
|
declare class QuotaExceededError extends CatastroGPSError {
|
|
210
498
|
name: string;
|
|
499
|
+
quota?: Quota;
|
|
500
|
+
get prepaidBalanceEmpty(): boolean;
|
|
211
501
|
}
|
|
212
502
|
declare class RateLimitError extends CatastroGPSError {
|
|
213
503
|
name: string;
|
|
@@ -215,6 +505,7 @@ declare class RateLimitError extends CatastroGPSError {
|
|
|
215
505
|
}
|
|
216
506
|
declare class ServiceUnavailableError extends CatastroGPSError {
|
|
217
507
|
name: string;
|
|
508
|
+
retryAfterSeconds?: number;
|
|
218
509
|
}
|
|
219
510
|
declare class ServerError extends CatastroGPSError {
|
|
220
511
|
name: string;
|
|
@@ -226,4 +517,4 @@ declare class NetworkError extends CatastroGPSError {
|
|
|
226
517
|
name: string;
|
|
227
518
|
}
|
|
228
519
|
|
|
229
|
-
export { type AddressMatch, type AgricultureData, AmbiguousReferenceError, AuthenticationError, COUNTRY_CODES, CatastroGPS, CatastroGPSError, type CatastroGPSOptions, type CountryCode, type CountryOption, CoverageError, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, ENRICHMENT_COUNTRY_CODES, type EnrichmentCountryCode, type ExportFormat, type FetchLike, ForbiddenError, NetworkError, NotFoundError, type Parcel, type ParcelGeometry, type PointMatch, type PointQuery, type Quota, QuotaExceededError, RateLimitError, type ResolveCandidate, type ResolveResult, ServerError, ServiceUnavailableError, type SolarEstimate, TimeoutError, VERSION, ValidationError };
|
|
520
|
+
export { ADDRESS_COUNTRY_CODES, type AddressCandidate, type AddressCandidatesQuery, type AddressCandidatesResult, type AddressCountryCode, type AddressMatch, type AgricultureData, AmbiguousReferenceError, AuthenticationError, type BlockStatus, type BurstLimit, COUNTRY_CODES, CatastroGPS, CatastroGPSError, type CatastroGPSOptions, type CompareItem, type Comparison, type ConditionalResponse, type Construction, type CountryCode, type CountryOption, CoverageError, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, type DataSource, ENRICHMENT_COUNTRY_CODES, type EnrichmentCountryCode, type ExportFormat, type FetchLike, type FincaCap, ForbiddenError, type GetUnitsOptions, type GroundMotion, type LocatedOptions, type MarketData, NetworkError, NotFoundError, type Parcel, type ParcelGeometry, PlaceNameError, type PointMatch, type PointQuery, type PrepaidOverage, type ProtectedSite, type Quota, QuotaExceededError, RateLimitError, type ResolveCandidate, type ResolveResult, type ScoreData, ServerError, ServiceUnavailableError, type SolarEstimate, type Terrain, TimeoutError, UNITS_COUNTRY_CODES, type Unit, type UnitsCountryCode, type UnitsPage, type UnitsPageData, type UnitsResult, VERSION, ValidationError, type ValueHistory, readQuota };
|