zenit-sdk 0.1.3 → 0.1.5
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/package.json +1 -1
- package/dist/chunk-URDEEWUZ.mjs +0 -4077
- package/dist/chunk-URDEEWUZ.mjs.map +0 -1
- package/dist/index-BSljZaYk.d.mts +0 -778
- package/dist/index-BSljZaYk.d.ts +0 -778
- package/dist/index.d.mts +0 -105
- package/dist/index.d.ts +0 -105
- package/dist/index.js +0 -5311
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1218
- package/dist/index.mjs.map +0 -1
- package/dist/react/index.d.mts +0 -4
- package/dist/react/index.d.ts +0 -4
- package/dist/react/index.js +0 -4108
- package/dist/react/index.js.map +0 -1
- package/dist/react/index.mjs +0 -53
- package/dist/react/index.mjs.map +0 -1
|
@@ -1,778 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import L, { PathOptions } from 'leaflet';
|
|
3
|
-
import 'lucide-react';
|
|
4
|
-
|
|
5
|
-
interface ZenitSdkError {
|
|
6
|
-
success: false;
|
|
7
|
-
statusCode: number;
|
|
8
|
-
timestamp?: string;
|
|
9
|
-
path?: string;
|
|
10
|
-
method?: string;
|
|
11
|
-
error?: string;
|
|
12
|
-
message: string;
|
|
13
|
-
}
|
|
14
|
-
type TokenResolver = () => {
|
|
15
|
-
accessToken?: string;
|
|
16
|
-
sdkToken?: string;
|
|
17
|
-
};
|
|
18
|
-
type AuthorizationHeaderResolver = () => Record<string, string>;
|
|
19
|
-
interface HttpClientOptions {
|
|
20
|
-
baseUrl: string;
|
|
21
|
-
resolveTokens?: TokenResolver;
|
|
22
|
-
resolveAuthorizationHeader?: AuthorizationHeaderResolver;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Minimal fetch-based HTTP client for the Zenit SDK.
|
|
26
|
-
* Responsible for setting base URL, auth headers and error normalization.
|
|
27
|
-
*
|
|
28
|
-
* - El header `Authorization` se usa para JWT de usuario o JWT obtenido vía `/sdk-auth/exchange`.
|
|
29
|
-
* - El header `X-SDK-Token` se usa para enviar el token SDK crudo a endpoints como
|
|
30
|
-
* `/sdk-auth/validate` y `/sdk-auth/exchange`.
|
|
31
|
-
*/
|
|
32
|
-
declare class HttpClient {
|
|
33
|
-
private baseUrl;
|
|
34
|
-
private readonly resolveTokens?;
|
|
35
|
-
private readonly resolveAuthorizationHeader;
|
|
36
|
-
constructor(options: HttpClientOptions);
|
|
37
|
-
/**
|
|
38
|
-
* Update base URL at runtime (e.g. when a host injects config).
|
|
39
|
-
*/
|
|
40
|
-
setBaseUrl(baseUrl: string): void;
|
|
41
|
-
get<T>(path: string, options?: RequestInit): Promise<T>;
|
|
42
|
-
post<T>(path: string, body?: unknown, options?: RequestInit): Promise<T>;
|
|
43
|
-
put<T>(path: string, body?: unknown, options?: RequestInit): Promise<T>;
|
|
44
|
-
patch<T>(path: string, body?: unknown, options?: RequestInit): Promise<T>;
|
|
45
|
-
delete<T>(path: string, options?: RequestInit): Promise<T>;
|
|
46
|
-
private request;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
type LoginRequest = {
|
|
50
|
-
email: string;
|
|
51
|
-
password: string;
|
|
52
|
-
};
|
|
53
|
-
type UserSummary = {
|
|
54
|
-
id: number | string;
|
|
55
|
-
email: string;
|
|
56
|
-
roles: string[];
|
|
57
|
-
employeeCode?: string;
|
|
58
|
-
};
|
|
59
|
-
type LoginResponse = {
|
|
60
|
-
accessToken: string;
|
|
61
|
-
refreshToken: string;
|
|
62
|
-
user: UserSummary;
|
|
63
|
-
};
|
|
64
|
-
type RefreshResponse = {
|
|
65
|
-
accessToken: string;
|
|
66
|
-
refreshToken: string;
|
|
67
|
-
};
|
|
68
|
-
type MeResponse = UserSummary;
|
|
69
|
-
type ValidateResponse = {
|
|
70
|
-
valid: boolean;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Client to manage user authentication endpoints.
|
|
75
|
-
*/
|
|
76
|
-
declare class ZenitAuthClient {
|
|
77
|
-
private readonly http;
|
|
78
|
-
private readonly updateTokens;
|
|
79
|
-
private readonly config;
|
|
80
|
-
constructor(http: HttpClient, updateTokens: (tokens: {
|
|
81
|
-
accessToken?: string;
|
|
82
|
-
refreshToken?: string;
|
|
83
|
-
}) => void, config: ZenitSdkConfig);
|
|
84
|
-
login(credentials: LoginRequest): Promise<LoginResponse>;
|
|
85
|
-
refresh(refreshToken?: string): Promise<RefreshResponse>;
|
|
86
|
-
me(): Promise<MeResponse>;
|
|
87
|
-
validate(): Promise<ValidateResponse>;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
type SdkTokenValidateResponse = {
|
|
91
|
-
valid: boolean;
|
|
92
|
-
clientId?: string | number;
|
|
93
|
-
clientName?: string;
|
|
94
|
-
scopes?: string[];
|
|
95
|
-
reason?: string;
|
|
96
|
-
};
|
|
97
|
-
type SdkTokenExchangeResponse = {
|
|
98
|
-
accessToken: string;
|
|
99
|
-
expiresIn: number;
|
|
100
|
-
tokenType: 'Bearer';
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Client to manage SDK token validation and exchange endpoints.
|
|
105
|
-
*/
|
|
106
|
-
declare class ZenitSdkAuthClient {
|
|
107
|
-
private readonly http;
|
|
108
|
-
private readonly updateAccessToken;
|
|
109
|
-
private readonly config;
|
|
110
|
-
constructor(http: HttpClient, updateAccessToken: (token?: string) => void, config: ZenitSdkConfig);
|
|
111
|
-
/**
|
|
112
|
-
* Validate an SDK token. If no token argument is provided, it falls back to config.sdkToken.
|
|
113
|
-
*/
|
|
114
|
-
validateSdkToken(token?: string): Promise<SdkTokenValidateResponse>;
|
|
115
|
-
/**
|
|
116
|
-
* Exchange an SDK token for an access token. Token can come from method args or config.sdkToken.
|
|
117
|
-
*/
|
|
118
|
-
exchangeSdkToken(token?: string): Promise<SdkTokenExchangeResponse>;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
interface LayerDto {
|
|
122
|
-
id: number | string;
|
|
123
|
-
name?: string;
|
|
124
|
-
description?: string;
|
|
125
|
-
totalFeatures?: number;
|
|
126
|
-
layerType?: string;
|
|
127
|
-
[key: string]: unknown;
|
|
128
|
-
}
|
|
129
|
-
type LayerSummary = Pick<LayerDto, 'id' | 'name'>;
|
|
130
|
-
interface GeoJsonPoint {
|
|
131
|
-
type: 'Point';
|
|
132
|
-
coordinates: [number, number];
|
|
133
|
-
[key: string]: unknown;
|
|
134
|
-
}
|
|
135
|
-
interface GeoJsonPolygon {
|
|
136
|
-
type: 'Polygon';
|
|
137
|
-
coordinates: number[][][];
|
|
138
|
-
[key: string]: unknown;
|
|
139
|
-
}
|
|
140
|
-
interface GeoJsonFeature<TProperties = Record<string, unknown>, TGeometry = unknown> {
|
|
141
|
-
type: 'Feature';
|
|
142
|
-
geometry: TGeometry;
|
|
143
|
-
properties?: TProperties;
|
|
144
|
-
[key: string]: unknown;
|
|
145
|
-
}
|
|
146
|
-
interface GeoJsonFeatureCollection<TProperties = Record<string, unknown>, TGeometry = GeoJsonPoint | GeoJsonPolygon | unknown> {
|
|
147
|
-
type: 'FeatureCollection';
|
|
148
|
-
features: Array<GeoJsonFeature<TProperties, TGeometry>>;
|
|
149
|
-
[key: string]: unknown;
|
|
150
|
-
}
|
|
151
|
-
interface GeoJsonGeometryCollection<TGeometry = unknown> {
|
|
152
|
-
type: 'GeometryCollection';
|
|
153
|
-
geometries: TGeometry[];
|
|
154
|
-
[key: string]: unknown;
|
|
155
|
-
}
|
|
156
|
-
interface Bbox {
|
|
157
|
-
minLon: number;
|
|
158
|
-
minLat: number;
|
|
159
|
-
maxLon: number;
|
|
160
|
-
maxLat: number;
|
|
161
|
-
}
|
|
162
|
-
type LayerDataStrategy = 'geojson' | 'bbox' | 'intersect';
|
|
163
|
-
interface ApiEnvelope<TData, TMetadata = Record<string, unknown>> {
|
|
164
|
-
success: boolean;
|
|
165
|
-
timestamp?: string;
|
|
166
|
-
path?: string;
|
|
167
|
-
method?: string;
|
|
168
|
-
data: TData;
|
|
169
|
-
message?: string;
|
|
170
|
-
metadata?: TMetadata;
|
|
171
|
-
limitedMessage?: string;
|
|
172
|
-
totalFeatures?: number;
|
|
173
|
-
}
|
|
174
|
-
type ApiResponseData<TData, TMetadata = Record<string, unknown>> = ApiEnvelope<TData, TMetadata>;
|
|
175
|
-
interface LayerMetadata {
|
|
176
|
-
totalFeatures?: number;
|
|
177
|
-
limit?: number;
|
|
178
|
-
limited?: boolean;
|
|
179
|
-
limitedMessage?: string;
|
|
180
|
-
[key: string]: unknown;
|
|
181
|
-
}
|
|
182
|
-
interface GeoJsonRequestOptions {
|
|
183
|
-
maxFeatures?: number;
|
|
184
|
-
simplify?: boolean;
|
|
185
|
-
}
|
|
186
|
-
interface GeoJsonBBoxRequest extends GeoJsonRequestOptions {
|
|
187
|
-
id: number | string;
|
|
188
|
-
bbox: Bbox;
|
|
189
|
-
}
|
|
190
|
-
interface GeoJsonIntersectRequest extends GeoJsonRequestOptions {
|
|
191
|
-
id: number | string;
|
|
192
|
-
geometry: unknown;
|
|
193
|
-
}
|
|
194
|
-
interface LayerAoi {
|
|
195
|
-
bbox?: Bbox;
|
|
196
|
-
geometry?: GeoJsonGeometryCollection;
|
|
197
|
-
}
|
|
198
|
-
interface ResolveLayerStrategyParams {
|
|
199
|
-
layerDetail: LayerDto;
|
|
200
|
-
bbox?: Bbox;
|
|
201
|
-
filterBBox?: Bbox;
|
|
202
|
-
filteredGeoJSON?: GeoJsonFeatureCollection | null;
|
|
203
|
-
isVisible?: boolean;
|
|
204
|
-
maxFeaturesFullGeojson?: number;
|
|
205
|
-
allowLargeGeojson?: boolean;
|
|
206
|
-
}
|
|
207
|
-
interface ResolveLayerStrategyResult {
|
|
208
|
-
strategy: LayerDataStrategy;
|
|
209
|
-
intersectionGeometry?: GeoJsonGeometryCollection | null;
|
|
210
|
-
effectiveBBox?: Bbox;
|
|
211
|
-
}
|
|
212
|
-
interface LoadLayerDataParams extends GeoJsonRequestOptions {
|
|
213
|
-
id: number | string;
|
|
214
|
-
layerDetail: LayerDto;
|
|
215
|
-
bbox?: Bbox;
|
|
216
|
-
filterBBox?: Bbox;
|
|
217
|
-
filteredGeoJSON?: GeoJsonFeatureCollection | null;
|
|
218
|
-
isVisible?: boolean;
|
|
219
|
-
maxFeaturesFullGeojson?: number;
|
|
220
|
-
allowLargeGeojson?: boolean;
|
|
221
|
-
}
|
|
222
|
-
interface LoadLayerDataResult<TMetadata = LayerMetadata> {
|
|
223
|
-
geojson: GeoJsonFeatureCollection;
|
|
224
|
-
strategy: LayerDataStrategy;
|
|
225
|
-
limitedMessage?: string;
|
|
226
|
-
totalFeatures?: number;
|
|
227
|
-
metadata?: TMetadata;
|
|
228
|
-
}
|
|
229
|
-
interface LayerFeatureCatalogItem {
|
|
230
|
-
id: string;
|
|
231
|
-
featureIndex: number;
|
|
232
|
-
properties: Record<string, string | number | boolean | null>;
|
|
233
|
-
bboxGeometry: GeoJsonPolygon;
|
|
234
|
-
centroid: GeoJsonPoint;
|
|
235
|
-
areaKm2: string;
|
|
236
|
-
geometryType: string;
|
|
237
|
-
}
|
|
238
|
-
interface LayerFeaturesCatalogDto {
|
|
239
|
-
layerId: number;
|
|
240
|
-
layerName: string;
|
|
241
|
-
layerType: string;
|
|
242
|
-
totalFeatures: number;
|
|
243
|
-
features: LayerFeatureCatalogItem[];
|
|
244
|
-
}
|
|
245
|
-
type FilterValue = string | number | boolean | Array<string | number | boolean>;
|
|
246
|
-
type LayerFilters = Record<string, FilterValue | null | undefined>;
|
|
247
|
-
interface FilterMultipleMetadata {
|
|
248
|
-
totalLayers?: number;
|
|
249
|
-
totalFeatures?: number;
|
|
250
|
-
appliedFilters?: Record<string, string | string[]>;
|
|
251
|
-
bbox?: unknown;
|
|
252
|
-
warnings?: string[];
|
|
253
|
-
layers?: Array<{
|
|
254
|
-
layerId: number;
|
|
255
|
-
layerName?: string;
|
|
256
|
-
featuresCount?: number;
|
|
257
|
-
}>;
|
|
258
|
-
[key: string]: unknown;
|
|
259
|
-
}
|
|
260
|
-
interface FilterMultipleLayerMeta {
|
|
261
|
-
layerId: number | string;
|
|
262
|
-
layerType?: string;
|
|
263
|
-
totalFeatures?: number;
|
|
264
|
-
label?: string;
|
|
265
|
-
prefilters?: LayerFilters;
|
|
266
|
-
}
|
|
267
|
-
interface FilterMultipleWithFallbackResult {
|
|
268
|
-
perLayer: Record<string, GeoJsonFeatureCollection>;
|
|
269
|
-
metadata?: FilterMultipleMetadata;
|
|
270
|
-
aoi?: LayerAoi | null;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
interface MapSettings {
|
|
274
|
-
center?: {
|
|
275
|
-
lat: number;
|
|
276
|
-
lon: number;
|
|
277
|
-
} | [number, number];
|
|
278
|
-
zoom?: number;
|
|
279
|
-
basemap?: string;
|
|
280
|
-
}
|
|
281
|
-
interface MapLayerConfig {
|
|
282
|
-
layerId?: number | string;
|
|
283
|
-
isVisible?: boolean;
|
|
284
|
-
order?: number | string;
|
|
285
|
-
displayOrder?: number | string;
|
|
286
|
-
opacity?: number | string;
|
|
287
|
-
layer?: LayerDto;
|
|
288
|
-
name?: string;
|
|
289
|
-
layerType?: string;
|
|
290
|
-
geometryType?: string;
|
|
291
|
-
/** Estilo de la capa, cuando viene embebido en el MapDto */
|
|
292
|
-
style?: {
|
|
293
|
-
color?: string;
|
|
294
|
-
weight?: number;
|
|
295
|
-
fillColor?: string;
|
|
296
|
-
fillOpacity?: number;
|
|
297
|
-
} | null;
|
|
298
|
-
layerConfig?: {
|
|
299
|
-
prefilters?: Record<string, unknown>;
|
|
300
|
-
[key: string]: unknown;
|
|
301
|
-
};
|
|
302
|
-
/** Filtros aplicados actualmente a esta capa (se setea después de operaciones de filtrado) */
|
|
303
|
-
appliedFilters?: Record<string, string | string[]>;
|
|
304
|
-
[key: string]: unknown;
|
|
305
|
-
}
|
|
306
|
-
interface NormalizedMapLayer {
|
|
307
|
-
layerId: number | string;
|
|
308
|
-
isVisible: boolean;
|
|
309
|
-
opacity: number;
|
|
310
|
-
displayOrder: number;
|
|
311
|
-
layer?: LayerDto;
|
|
312
|
-
layerType?: string;
|
|
313
|
-
geometryType?: string;
|
|
314
|
-
layerName?: string;
|
|
315
|
-
mapLayer: MapLayerConfig;
|
|
316
|
-
}
|
|
317
|
-
interface MapDto {
|
|
318
|
-
id: number | string;
|
|
319
|
-
mapType?: {
|
|
320
|
-
code?: string;
|
|
321
|
-
};
|
|
322
|
-
settings?: MapSettings;
|
|
323
|
-
mapLayers?: MapLayerConfig[];
|
|
324
|
-
layers?: LayerSummary[];
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
declare class ZenitMapsClient {
|
|
328
|
-
private readonly httpClient;
|
|
329
|
-
constructor(httpClient: HttpClient);
|
|
330
|
-
getMap(mapId: number | string, includeLayers?: boolean): Promise<MapDto>;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
declare function buildLayerFilters(filters?: LayerFilters): URLSearchParams;
|
|
334
|
-
declare function buildFilterMultipleParams(params: {
|
|
335
|
-
layerIds: Array<number | string>;
|
|
336
|
-
filters?: LayerFilters;
|
|
337
|
-
}): URLSearchParams;
|
|
338
|
-
declare const DEFAULT_MAX_FEATURES_FULL_GEOJSON = 50000;
|
|
339
|
-
declare function shouldUseFilterMultiple(layerType?: string): boolean;
|
|
340
|
-
declare function shouldSkipGeojsonDownload(layerType?: string, totalFeatures?: number, thresholds?: {
|
|
341
|
-
maxFeatures: number;
|
|
342
|
-
allowLargeGeojson?: boolean;
|
|
343
|
-
}): boolean;
|
|
344
|
-
declare function buildAoiFromFeatureCollection(featureCollection: GeoJsonFeatureCollection, metadata?: FilterMultipleMetadata): LayerAoi | null;
|
|
345
|
-
declare function resolveLayerStrategy(params: ResolveLayerStrategyParams): ResolveLayerStrategyResult;
|
|
346
|
-
declare function buildLimitedMessage(metadata?: LayerMetadata): string | undefined;
|
|
347
|
-
declare class ZenitLayersClient {
|
|
348
|
-
private readonly httpClient;
|
|
349
|
-
constructor(httpClient: HttpClient);
|
|
350
|
-
getLayer(layerId: number | string): Promise<ApiResponseData<LayerDto>>;
|
|
351
|
-
getLayerGeoJson(layerId: number | string, options?: GeoJsonRequestOptions): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
352
|
-
getLayerFeaturesCatalog(layerId: number | string, options?: {
|
|
353
|
-
layerType?: string;
|
|
354
|
-
geometryType?: string;
|
|
355
|
-
strict?: boolean;
|
|
356
|
-
}): Promise<ApiResponseData<LayerFeaturesCatalogDto>>;
|
|
357
|
-
getLayerFeatures(layerId: number | string, featureIds: Array<number | string>): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
358
|
-
filterLayerFeatures(layerId: number | string, filters: LayerFilters): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
359
|
-
filterMultipleLayersFeatures(params: {
|
|
360
|
-
layerIds: Array<number | string>;
|
|
361
|
-
filters?: LayerFilters;
|
|
362
|
-
}): Promise<ApiResponseData<GeoJsonFeatureCollection, FilterMultipleMetadata>>;
|
|
363
|
-
filterMultiple(params: {
|
|
364
|
-
layerIds: Array<number | string>;
|
|
365
|
-
filters?: LayerFilters;
|
|
366
|
-
}): Promise<ApiResponseData<GeoJsonFeatureCollection, FilterMultipleMetadata>>;
|
|
367
|
-
/**
|
|
368
|
-
* Resilient filter-multiple helper:
|
|
369
|
-
* - Usa filter-multiple SOLO en capas multipolygon.
|
|
370
|
-
* - Para otras capas aplica filterLayerFeatures o getLayerGeoJson según haya filtros.
|
|
371
|
-
* - Nunca falla toda la operación por una capa inválida.
|
|
372
|
-
*
|
|
373
|
-
* Para mejor detección de layerType, pasa layerMetas con el layerType de cada capa.
|
|
374
|
-
*/
|
|
375
|
-
filterMultipleWithFallback(params: {
|
|
376
|
-
layerIds: Array<number | string>;
|
|
377
|
-
filters?: LayerFilters;
|
|
378
|
-
layerMetas?: FilterMultipleLayerMeta[];
|
|
379
|
-
maxFeaturesFullGeojson?: number;
|
|
380
|
-
allowLargeGeojson?: boolean;
|
|
381
|
-
}): Promise<FilterMultipleWithFallbackResult>;
|
|
382
|
-
getLayerGeoJsonBBox(request: GeoJsonBBoxRequest): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
383
|
-
getLayerGeoJsonIntersect(request: GeoJsonIntersectRequest): Promise<ApiResponseData<GeoJsonFeatureCollection>>;
|
|
384
|
-
getLayerTileTemplate(layerId: number | string): Promise<string>;
|
|
385
|
-
loadLayerData(params: LoadLayerDataParams): Promise<LoadLayerDataResult>;
|
|
386
|
-
loadFilteredFeatures(params: {
|
|
387
|
-
layerIds: Array<number | string>;
|
|
388
|
-
filters: LayerFilters;
|
|
389
|
-
}): Promise<{
|
|
390
|
-
geojson: GeoJsonFeatureCollection;
|
|
391
|
-
metadata?: FilterMultipleMetadata;
|
|
392
|
-
totalFeatures?: number;
|
|
393
|
-
}>;
|
|
394
|
-
private fetchByStrategy;
|
|
395
|
-
private unwrapResponse;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
type ZenitRuntimeConfig = {
|
|
399
|
-
baseUrl: string;
|
|
400
|
-
accessToken?: string;
|
|
401
|
-
sdkToken?: string;
|
|
402
|
-
mapId?: number;
|
|
403
|
-
defaultFilters?: Record<string, unknown>;
|
|
404
|
-
};
|
|
405
|
-
/**
|
|
406
|
-
* Normalize an unknown filters payload into a plain object.
|
|
407
|
-
*/
|
|
408
|
-
declare const normalizeFilters: (filters: unknown) => Record<string, unknown>;
|
|
409
|
-
/**
|
|
410
|
-
* Merge two filter objects into a new one (next overrides base).
|
|
411
|
-
*/
|
|
412
|
-
declare const mergeFilters: (base?: Record<string, unknown>, next?: Record<string, unknown>) => Record<string, unknown>;
|
|
413
|
-
/**
|
|
414
|
-
* Resolve runtime config from unknown input, validating and normalizing fields.
|
|
415
|
-
*/
|
|
416
|
-
declare const resolveRuntimeConfig: (input: unknown) => ZenitRuntimeConfig | null;
|
|
417
|
-
|
|
418
|
-
interface ZenitSdkConfig {
|
|
419
|
-
baseUrl: string;
|
|
420
|
-
sdkToken?: string;
|
|
421
|
-
accessToken?: string;
|
|
422
|
-
refreshToken?: string;
|
|
423
|
-
onAuthError?(error: ZenitSdkError): void;
|
|
424
|
-
onTokenRefreshed?(tokens: {
|
|
425
|
-
accessToken: string;
|
|
426
|
-
refreshToken?: string;
|
|
427
|
-
}): void;
|
|
428
|
-
defaultFilters?: Record<string, unknown>;
|
|
429
|
-
}
|
|
430
|
-
declare class ZenitClient {
|
|
431
|
-
private readonly config;
|
|
432
|
-
private accessToken?;
|
|
433
|
-
private refreshToken?;
|
|
434
|
-
private sdkToken?;
|
|
435
|
-
private defaultFilters?;
|
|
436
|
-
private readonly httpClient;
|
|
437
|
-
readonly auth: ZenitAuthClient;
|
|
438
|
-
readonly sdkAuth: ZenitSdkAuthClient;
|
|
439
|
-
readonly maps: ZenitMapsClient;
|
|
440
|
-
readonly layers: ZenitLayersClient;
|
|
441
|
-
constructor(config: ZenitSdkConfig);
|
|
442
|
-
/**
|
|
443
|
-
* Update tokens in memory and propagate to config callbacks.
|
|
444
|
-
*/
|
|
445
|
-
private updateTokens;
|
|
446
|
-
private updateAccessTokenFromSdkExchange;
|
|
447
|
-
/**
|
|
448
|
-
* Update the access token at runtime.
|
|
449
|
-
*/
|
|
450
|
-
setAccessToken(token?: string): void;
|
|
451
|
-
/**
|
|
452
|
-
* Update the refresh token at runtime.
|
|
453
|
-
*/
|
|
454
|
-
setRefreshToken(token?: string): void;
|
|
455
|
-
/**
|
|
456
|
-
* Update the SDK token at runtime.
|
|
457
|
-
*/
|
|
458
|
-
setSdkToken(token?: string): void;
|
|
459
|
-
/**
|
|
460
|
-
* Update both access token and SDK token at once.
|
|
461
|
-
*/
|
|
462
|
-
setAuth(params: {
|
|
463
|
-
accessToken?: string;
|
|
464
|
-
sdkToken?: string;
|
|
465
|
-
}): void;
|
|
466
|
-
/**
|
|
467
|
-
* Update base URL at runtime (e.g. injected config from a host app).
|
|
468
|
-
*/
|
|
469
|
-
setBaseUrl(baseUrl: string): void;
|
|
470
|
-
/**
|
|
471
|
-
* Store default filters for UI integrations.
|
|
472
|
-
*/
|
|
473
|
-
setDefaultFilters(filters: Record<string, unknown> | undefined): void;
|
|
474
|
-
/**
|
|
475
|
-
* Return default filters for UI integrations.
|
|
476
|
-
*/
|
|
477
|
-
getDefaultFilters(): Record<string, unknown> | undefined;
|
|
478
|
-
/**
|
|
479
|
-
* Get a readonly snapshot of the current SDK config.
|
|
480
|
-
*/
|
|
481
|
-
getConfig(): Readonly<ZenitSdkConfig>;
|
|
482
|
-
/**
|
|
483
|
-
* Get a readonly snapshot of runtime config for debugging or host integrations.
|
|
484
|
-
*/
|
|
485
|
-
getRuntimeConfig(): Readonly<ZenitRuntimeConfig>;
|
|
486
|
-
/**
|
|
487
|
-
* Build an authorization header on demand using the current token values.
|
|
488
|
-
*/
|
|
489
|
-
getAuthorizationHeader(): Record<string, string>;
|
|
490
|
-
getHttpClient(): HttpClient;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
type LayerLike = Pick<MapLayerConfig | NormalizedMapLayer, 'layerId' | 'isVisible' | 'opacity'>;
|
|
494
|
-
interface LayerBaseState {
|
|
495
|
-
layerId: number | string;
|
|
496
|
-
baseVisible: boolean;
|
|
497
|
-
baseOpacity: number;
|
|
498
|
-
}
|
|
499
|
-
interface LayerOverrideState {
|
|
500
|
-
layerId: number | string;
|
|
501
|
-
overrideVisible?: boolean | null;
|
|
502
|
-
overrideOpacity?: number | string | null;
|
|
503
|
-
}
|
|
504
|
-
interface EffectiveLayerState extends LayerBaseState, LayerOverrideState {
|
|
505
|
-
visible: boolean;
|
|
506
|
-
opacity: number;
|
|
507
|
-
}
|
|
508
|
-
declare function initLayerStates(mapLayers: LayerLike[]): EffectiveLayerState[];
|
|
509
|
-
declare function applyLayerOverrides(states: EffectiveLayerState[], overrides: LayerOverrideState[]): EffectiveLayerState[];
|
|
510
|
-
declare function resetOverrides(states: EffectiveLayerState[]): EffectiveLayerState[];
|
|
511
|
-
|
|
512
|
-
interface ChatRequestDto {
|
|
513
|
-
message: string;
|
|
514
|
-
conversationId?: number;
|
|
515
|
-
filteredLayerIds?: number[];
|
|
516
|
-
filters?: Record<string, unknown>;
|
|
517
|
-
userId?: number | null;
|
|
518
|
-
}
|
|
519
|
-
interface SuggestedAction {
|
|
520
|
-
id?: string | number;
|
|
521
|
-
type?: 'highlight' | 'zoom' | 'filter' | 'navigate';
|
|
522
|
-
label?: string;
|
|
523
|
-
action?: string;
|
|
524
|
-
layerId?: number;
|
|
525
|
-
featureId?: number | string;
|
|
526
|
-
filter?: {
|
|
527
|
-
property: string;
|
|
528
|
-
operator: 'equals' | 'contains' | 'gt' | 'lt' | 'in';
|
|
529
|
-
value: string | number | boolean | Array<string | number>;
|
|
530
|
-
};
|
|
531
|
-
bbox?: [number, number, number, number] | {
|
|
532
|
-
minLon: number;
|
|
533
|
-
minLat: number;
|
|
534
|
-
maxLon: number;
|
|
535
|
-
maxLat: number;
|
|
536
|
-
};
|
|
537
|
-
coordinates?: {
|
|
538
|
-
lat: number;
|
|
539
|
-
lon: number;
|
|
540
|
-
};
|
|
541
|
-
payload?: Record<string, unknown>;
|
|
542
|
-
}
|
|
543
|
-
interface ChatResponseDto {
|
|
544
|
-
conversationId: number;
|
|
545
|
-
answer: string;
|
|
546
|
-
metadata?: Record<string, unknown>;
|
|
547
|
-
suggestedActions?: SuggestedAction[];
|
|
548
|
-
relevantFeatures?: Array<Record<string, unknown>>;
|
|
549
|
-
needsMoreInfo?: boolean;
|
|
550
|
-
followUpQuestions?: string[];
|
|
551
|
-
confidence?: number;
|
|
552
|
-
systemMetadata?: Record<string, unknown>;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
interface ChatServiceConfig {
|
|
556
|
-
baseUrl: string;
|
|
557
|
-
accessToken?: string;
|
|
558
|
-
getAccessToken?: () => string | Promise<string>;
|
|
559
|
-
}
|
|
560
|
-
interface ChatRequestOptions {
|
|
561
|
-
baseUrl?: string;
|
|
562
|
-
accessToken?: string;
|
|
563
|
-
getAccessToken?: () => string | Promise<string>;
|
|
564
|
-
signal?: AbortSignal;
|
|
565
|
-
}
|
|
566
|
-
interface ChatStreamCallbacks {
|
|
567
|
-
onChunk?: (chunk: ChatResponseDto, aggregatedText: string) => void;
|
|
568
|
-
onComplete?: (response: ChatResponseDto) => void;
|
|
569
|
-
onError?: (error: unknown) => void;
|
|
570
|
-
}
|
|
571
|
-
declare const sendMessage: (mapId: number, request: ChatRequestDto, options?: ChatRequestOptions, config?: ChatServiceConfig) => Promise<ChatResponseDto>;
|
|
572
|
-
declare const sendMessageStream: (mapId: number, request: ChatRequestDto, callbacks?: ChatStreamCallbacks, options?: ChatRequestOptions, config?: ChatServiceConfig) => Promise<ChatResponseDto>;
|
|
573
|
-
declare const createChatService: (config: ChatServiceConfig) => {
|
|
574
|
-
sendMessage: (mapId: number, request: ChatRequestDto, options?: ChatRequestOptions) => Promise<ChatResponseDto>;
|
|
575
|
-
sendMessageStream: (mapId: number, request: ChatRequestDto, callbacks?: ChatStreamCallbacks, options?: ChatRequestOptions) => Promise<ChatResponseDto>;
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
interface LayerStyle$1 {
|
|
579
|
-
color?: string;
|
|
580
|
-
weight?: number;
|
|
581
|
-
fillColor?: string;
|
|
582
|
-
fillOpacity?: number;
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Resuelve el color de acento para una capa basado en su estilo.
|
|
586
|
-
* Prioridad: fillColor → color → null
|
|
587
|
-
*/
|
|
588
|
-
declare function resolveLayerAccent(style?: LayerStyle$1 | null): string | null;
|
|
589
|
-
/**
|
|
590
|
-
* Obtiene el color de acento para una capa, con fallback a un color neutral.
|
|
591
|
-
* @param style - El estilo de la capa
|
|
592
|
-
* @param fallback - Color de fallback (por defecto gris neutral)
|
|
593
|
-
*/
|
|
594
|
-
declare function getLayerColor(style?: LayerStyle$1 | null, fallback?: string): string;
|
|
595
|
-
/**
|
|
596
|
-
* Busca el estilo de una capa en un arreglo de mapLayers por su layerId.
|
|
597
|
-
*/
|
|
598
|
-
declare function getStyleByLayerId(layerId: string | number, mapLayers?: Array<{
|
|
599
|
-
layerId: number | string;
|
|
600
|
-
style?: LayerStyle$1 | null;
|
|
601
|
-
}>): LayerStyle$1 | null;
|
|
602
|
-
/**
|
|
603
|
-
* Obtiene el color de acento de una capa por su layerId.
|
|
604
|
-
*/
|
|
605
|
-
declare function getAccentByLayerId(layerId: string | number, mapLayers?: Array<{
|
|
606
|
-
layerId: number | string;
|
|
607
|
-
style?: LayerStyle$1 | null;
|
|
608
|
-
}>): string | null;
|
|
609
|
-
|
|
610
|
-
interface LayerSnapshot {
|
|
611
|
-
layerId: number | string;
|
|
612
|
-
visible: boolean;
|
|
613
|
-
opacity: number;
|
|
614
|
-
}
|
|
615
|
-
interface ZenitMapRef {
|
|
616
|
-
setLayerOpacity: (layerId: number | string, opacity: number) => void;
|
|
617
|
-
setLayerVisibility: (layerId: number | string, visible: boolean) => void;
|
|
618
|
-
fitBounds: (bbox: Bbox, options?: {
|
|
619
|
-
padding?: [number, number];
|
|
620
|
-
animate?: boolean;
|
|
621
|
-
}) => void;
|
|
622
|
-
fitToBbox: (bbox: Bbox, padding?: number) => void;
|
|
623
|
-
fitToGeoJson: (fc: GeoJsonFeatureCollection, padding?: number) => void;
|
|
624
|
-
setView: (coordinates: {
|
|
625
|
-
lat: number;
|
|
626
|
-
lon: number;
|
|
627
|
-
}, zoom?: number) => void;
|
|
628
|
-
getLayerSnapshot: () => LayerSnapshot[];
|
|
629
|
-
restoreLayerSnapshot: (snapshot: LayerSnapshot[]) => void;
|
|
630
|
-
highlightFeature: (layerId: number | string, featureId?: number | string) => void;
|
|
631
|
-
updateLayerGeoJson: (layerId: number | string, featureCollection: GeoJsonFeatureCollection) => void;
|
|
632
|
-
restoreLayerGeoJson: (layerId: number | string) => void;
|
|
633
|
-
getMapInstance: () => L.Map | null;
|
|
634
|
-
}
|
|
635
|
-
interface ZenitMapProps {
|
|
636
|
-
client: ZenitClient;
|
|
637
|
-
mapId: number;
|
|
638
|
-
height?: string;
|
|
639
|
-
width?: string;
|
|
640
|
-
initialZoom?: number;
|
|
641
|
-
initialCenter?: [number, number];
|
|
642
|
-
showLayerPanel?: boolean;
|
|
643
|
-
overlayGeojson?: GeoJsonFeatureCollection | null;
|
|
644
|
-
overlayStyle?: PathOptions;
|
|
645
|
-
layerControls?: Array<{
|
|
646
|
-
layerId: number | string;
|
|
647
|
-
visible?: boolean;
|
|
648
|
-
opacity?: number;
|
|
649
|
-
}>;
|
|
650
|
-
layerStates?: EffectiveLayerState[];
|
|
651
|
-
layerGeojson?: Record<string | number, GeoJsonFeatureCollection | null | undefined>;
|
|
652
|
-
onLayerStateChange?: (states: EffectiveLayerState[]) => void;
|
|
653
|
-
onError?: (error: unknown, ctx: 'map') => void;
|
|
654
|
-
onLoadingChange?: (ctx: 'map', loading: boolean) => void;
|
|
655
|
-
onFeatureClick?: (feature: any, layerId?: number | string) => void;
|
|
656
|
-
onFeatureHover?: (feature: any, layerId?: number | string) => void;
|
|
657
|
-
featureInfoMode?: 'popup' | 'none';
|
|
658
|
-
mapLayers?: Array<{
|
|
659
|
-
layerId: number | string;
|
|
660
|
-
style?: LayerStyle$1 | null;
|
|
661
|
-
}>;
|
|
662
|
-
zoomToBbox?: Bbox | null;
|
|
663
|
-
zoomToGeojson?: GeoJsonFeatureCollection | null;
|
|
664
|
-
onZoomChange?: (zoom: number) => void;
|
|
665
|
-
onMapReady?: (map: L.Map) => void;
|
|
666
|
-
}
|
|
667
|
-
declare const ZenitMap: React.ForwardRefExoticComponent<ZenitMapProps & React.RefAttributes<ZenitMapRef>>;
|
|
668
|
-
|
|
669
|
-
interface LayerStyle {
|
|
670
|
-
color?: string;
|
|
671
|
-
weight?: number;
|
|
672
|
-
fillColor?: string;
|
|
673
|
-
fillOpacity?: number;
|
|
674
|
-
}
|
|
675
|
-
interface ZenitLayerManagerProps {
|
|
676
|
-
client: ZenitClient;
|
|
677
|
-
mapId: number | string;
|
|
678
|
-
side?: 'left' | 'right';
|
|
679
|
-
className?: string;
|
|
680
|
-
style?: React.CSSProperties;
|
|
681
|
-
height?: string;
|
|
682
|
-
layerStates?: EffectiveLayerState[];
|
|
683
|
-
onLayerStatesChange?: (states: EffectiveLayerState[]) => void;
|
|
684
|
-
mapZoom?: number;
|
|
685
|
-
autoOpacityOnZoom?: boolean;
|
|
686
|
-
autoOpacityConfig?: {
|
|
687
|
-
minZoom?: number;
|
|
688
|
-
maxZoom?: number;
|
|
689
|
-
minOpacity?: number;
|
|
690
|
-
maxOpacity?: number;
|
|
691
|
-
};
|
|
692
|
-
showUploadTab?: boolean;
|
|
693
|
-
showLayerVisibilityIcon?: boolean;
|
|
694
|
-
layerFeatureCounts?: Record<string | number, number | null | undefined>;
|
|
695
|
-
mapLayers?: Array<{
|
|
696
|
-
layerId: number | string;
|
|
697
|
-
geometryType?: string | null;
|
|
698
|
-
layerType?: string | null;
|
|
699
|
-
name?: string | null;
|
|
700
|
-
style?: LayerStyle | null;
|
|
701
|
-
bboxGeometry?: GeoJsonPolygon | null;
|
|
702
|
-
displayOrder?: number | null;
|
|
703
|
-
}>;
|
|
704
|
-
onZoomToLayer?: (layerId: number | string, bboxGeometry?: GeoJsonPolygon | null) => void;
|
|
705
|
-
onApplyLayerFilter?: (params: {
|
|
706
|
-
layerId: number | string;
|
|
707
|
-
field: string;
|
|
708
|
-
value: string;
|
|
709
|
-
}) => Promise<void> | void;
|
|
710
|
-
onClearLayerFilter?: (params: {
|
|
711
|
-
layerId: number | string;
|
|
712
|
-
field?: string;
|
|
713
|
-
}) => Promise<void> | void;
|
|
714
|
-
}
|
|
715
|
-
declare const ZenitLayerManager: React.FC<ZenitLayerManagerProps>;
|
|
716
|
-
|
|
717
|
-
interface ZenitFeatureFilterPanelProps {
|
|
718
|
-
title?: string;
|
|
719
|
-
description?: string;
|
|
720
|
-
className?: string;
|
|
721
|
-
style?: React.CSSProperties;
|
|
722
|
-
filters?: LayerFilters;
|
|
723
|
-
onChange?: (filters: LayerFilters) => void;
|
|
724
|
-
children?: React.ReactNode;
|
|
725
|
-
}
|
|
726
|
-
declare const ZenitFeatureFilterPanel: React.FC<ZenitFeatureFilterPanelProps>;
|
|
727
|
-
|
|
728
|
-
interface FloatingChatBoxProps {
|
|
729
|
-
mapId?: number;
|
|
730
|
-
filteredLayerIds?: number[];
|
|
731
|
-
filters?: Record<string, unknown>;
|
|
732
|
-
userId?: number | null;
|
|
733
|
-
baseUrl?: string;
|
|
734
|
-
accessToken?: string;
|
|
735
|
-
getAccessToken?: () => string | Promise<string>;
|
|
736
|
-
onActionClick?: (action: SuggestedAction) => void;
|
|
737
|
-
/** Called when the chat panel opens or closes. */
|
|
738
|
-
onOpenChange?: (isOpen: boolean) => void;
|
|
739
|
-
/** When true, the floating action button is hidden (panel can still be open). */
|
|
740
|
-
hideButton?: boolean;
|
|
741
|
-
/**
|
|
742
|
-
* Controlled open state. When provided, the component uses this as the source of truth.
|
|
743
|
-
* Use with `onOpenChange` to control the chat panel externally.
|
|
744
|
-
*/
|
|
745
|
-
open?: boolean;
|
|
746
|
-
}
|
|
747
|
-
declare const FloatingChatBox: React.FC<FloatingChatBoxProps>;
|
|
748
|
-
|
|
749
|
-
declare const useSendMessage: (config?: ChatServiceConfig) => {
|
|
750
|
-
sendMessage: (mapId: number, request: ChatRequestDto, options?: ChatRequestOptions) => Promise<ChatResponseDto>;
|
|
751
|
-
isLoading: boolean;
|
|
752
|
-
error: unknown;
|
|
753
|
-
};
|
|
754
|
-
declare const useSendMessageStream: (config?: ChatServiceConfig) => {
|
|
755
|
-
sendMessage: (mapId: number, request: ChatRequestDto, options?: ChatRequestOptions) => Promise<ChatResponseDto>;
|
|
756
|
-
isStreaming: boolean;
|
|
757
|
-
streamingText: string;
|
|
758
|
-
completeResponse: ChatResponseDto | null;
|
|
759
|
-
error: unknown;
|
|
760
|
-
reset: () => void;
|
|
761
|
-
};
|
|
762
|
-
|
|
763
|
-
interface ZoomOpacityOptions {
|
|
764
|
-
minZoom?: number;
|
|
765
|
-
maxZoom?: number;
|
|
766
|
-
minFactor?: number;
|
|
767
|
-
maxFactor?: number;
|
|
768
|
-
minOpacity?: number;
|
|
769
|
-
maxOpacity?: number;
|
|
770
|
-
}
|
|
771
|
-
declare function clampNumber(value: number, min: number, max: number): number;
|
|
772
|
-
declare function clampOpacity(value: number): number;
|
|
773
|
-
declare function isPolygonLayer(layerType?: string, geometryType?: string): boolean;
|
|
774
|
-
declare function getZoomOpacityFactor(zoom: number, options?: ZoomOpacityOptions): number;
|
|
775
|
-
declare function getLayerZoomOpacityFactor(zoom: number, layerType?: string, geometryType?: string, options?: ZoomOpacityOptions): number;
|
|
776
|
-
declare function getEffectiveLayerOpacity(baseOpacity: number, zoom: number, layerType?: string, geometryType?: string, options?: ZoomOpacityOptions): number;
|
|
777
|
-
|
|
778
|
-
export { type LoadLayerDataParams as $, ZenitLayersClient as A, type Bbox as B, type LayerDto as C, DEFAULT_MAX_FEATURES_FULL_GEOJSON as D, type LayerSummary as E, type FilterMultipleMetadata as F, type GeoJsonFeature as G, type HttpClientOptions as H, type GeoJsonPoint as I, type GeoJsonGeometryCollection as J, type LayerDataStrategy as K, type LayerFilters as L, type MapDto as M, type NormalizedMapLayer as N, type ApiEnvelope as O, type ApiResponseData as P, type LayerMetadata as Q, type RefreshResponse as R, type SdkTokenValidateResponse as S, type GeoJsonBBoxRequest as T, type UserSummary as U, type ValidateResponse as V, type GeoJsonIntersectRequest as W, type LayerAoi as X, type ResolveLayerStrategyParams as Y, type ZenitSdkConfig as Z, type ResolveLayerStrategyResult as _, type GeoJsonFeatureCollection as a, type LoadLayerDataResult as a0, type LayerFeatureCatalogItem as a1, type LayerFeaturesCatalogDto as a2, type FilterValue as a3, type FilterMultipleLayerMeta as a4, type FilterMultipleWithFallbackResult as a5, type LayerBaseState as a6, type LayerOverrideState as a7, type EffectiveLayerState as a8, initLayerStates as a9, type ZoomOpacityOptions as aA, clampNumber as aB, clampOpacity as aC, isPolygonLayer as aD, getZoomOpacityFactor as aE, getLayerZoomOpacityFactor as aF, getEffectiveLayerOpacity as aG, applyLayerOverrides as aa, resetOverrides as ab, type ChatServiceConfig as ac, type ChatRequestOptions as ad, type ChatStreamCallbacks as ae, sendMessage as af, sendMessageStream as ag, createChatService as ah, type ChatRequestDto as ai, type SuggestedAction as aj, type ChatResponseDto as ak, ZenitMap as al, type ZenitMapRef as am, type LayerSnapshot as an, type ZenitMapProps as ao, ZenitLayerManager as ap, ZenitFeatureFilterPanel as aq, FloatingChatBox as ar, type FloatingChatBoxProps as as, useSendMessage as at, useSendMessageStream as au, type LayerStyle$1 as av, resolveLayerAccent as aw, getLayerColor as ax, getStyleByLayerId as ay, getAccentByLayerId as az, type GeoJsonRequestOptions as b, type GeoJsonPolygon as c, ZenitClient as d, type ZenitRuntimeConfig as e, type LoginRequest as f, type LoginResponse as g, type MeResponse as h, ZenitAuthClient as i, type SdkTokenExchangeResponse as j, ZenitSdkAuthClient as k, type ZenitSdkError as l, mergeFilters as m, normalizeFilters as n, HttpClient as o, ZenitMapsClient as p, type MapSettings as q, resolveRuntimeConfig as r, type MapLayerConfig as s, buildLayerFilters as t, buildFilterMultipleParams as u, shouldUseFilterMultiple as v, shouldSkipGeojsonDownload as w, buildAoiFromFeatureCollection as x, resolveLayerStrategy as y, buildLimitedMessage as z };
|