@nextgis/ngw-connector 3.0.0-alpha.1 → 3.0.0-alpha.13
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 +49 -138
- package/lib/index.d.ts +303 -170
- package/lib/ngw-connector.cjs.js +1086 -596
- package/lib/ngw-connector.cjs.js.map +1 -1
- package/lib/ngw-connector.cjs.prod.js +1 -1
- package/lib/ngw-connector.cjs.prod.js.map +1 -1
- package/lib/ngw-connector.esm-browser.js +1483 -860
- package/lib/ngw-connector.esm-browser.js.map +1 -1
- package/lib/ngw-connector.esm-browser.prod.js +1 -1
- package/lib/ngw-connector.esm-browser.prod.js.map +1 -1
- package/lib/ngw-connector.esm-bundler.js +1297 -703
- package/lib/ngw-connector.esm-bundler.js.map +1 -1
- package/lib/ngw-connector.esm-bundler.prod.js +1 -1
- package/lib/ngw-connector.esm-bundler.prod.js.map +1 -1
- package/lib/ngw-connector.global.js +1483 -860
- package/lib/ngw-connector.global.js.map +1 -1
- package/lib/ngw-connector.global.prod.js +1 -1
- package/lib/ngw-connector.global.prod.js.map +1 -1
- package/package.json +9 -6
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
1
|
+
import { Routes } from '@nextgisweb/pyramid/type/route';
|
|
3
2
|
import Cache from '@nextgis/cache';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
4
|
import { FeatureProperties, DeepPartial } from '@nextgis/utils';
|
|
5
|
+
import { LegendSymbol } from '@nextgisweb/render/type/api';
|
|
6
|
+
import { ResourceCls as ResourceCls$1, ResourceRead, CompositeRead } from '@nextgisweb/resource/type/api';
|
|
5
7
|
import { GeoJsonObject, Geometry } from 'geojson';
|
|
8
|
+
import { BasemapWebMapItemRead, BasemapWebMapRead } from '@nextgisweb/basemap/type/api';
|
|
9
|
+
import { FeatureLayerRead } from '@nextgisweb/feature-layer/type/api';
|
|
10
|
+
import { VectorLayerRead } from '@nextgisweb/vector-layer/type/api';
|
|
11
|
+
import { WebMapRead } from '@nextgisweb/webmap/type/api';
|
|
12
|
+
|
|
13
|
+
declare class LunkwillParam {
|
|
14
|
+
static VALUES: (string | null)[];
|
|
15
|
+
private value;
|
|
16
|
+
constructor();
|
|
17
|
+
update(value: string | null, cond?: boolean): void;
|
|
18
|
+
suggest(cond?: boolean): void;
|
|
19
|
+
require(cond?: boolean): void;
|
|
20
|
+
toHeaders(headers: Record<string, string>): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type RouteParameters = {
|
|
24
|
+
[K in keyof Routes]: Routes[K]['pathArr'] | [Routes[K]['pathObj']];
|
|
25
|
+
};
|
|
26
|
+
type RouteName = keyof Routes;
|
|
27
|
+
type GetRouteParam<R extends RouteName> = (RouteParameters[R] & [
|
|
28
|
+
object
|
|
29
|
+
])[0];
|
|
30
|
+
type RequestMethod = keyof RouteMethods<RouteName>;
|
|
31
|
+
type Method = RequestMethod | Uppercase<RequestMethod>;
|
|
32
|
+
type ResponseType = 'blob' | 'json';
|
|
33
|
+
interface RouteRequestOptions<RT extends ResponseType = 'json', ReturnUrl extends boolean = false, Q = any, B = string | null | boolean | Record<string, any> | any[]> extends Omit<RequestInit, 'cache'> {
|
|
34
|
+
headers?: Record<string, string>;
|
|
35
|
+
cache?: boolean;
|
|
36
|
+
query?: Q;
|
|
37
|
+
json?: B;
|
|
38
|
+
/** Has lower priority than the json */
|
|
39
|
+
body?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The type of data that the server will respond with.
|
|
42
|
+
* Can be either 'json' or 'blob'.
|
|
43
|
+
*/
|
|
44
|
+
responseType?: RT;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated use {@link RequestInit.credential}
|
|
47
|
+
* Indicates whether to include credentials such as cookies, authentication headers,
|
|
48
|
+
* or TLS client certificates in cross-site Access-Control requests.
|
|
49
|
+
*/
|
|
50
|
+
withCredentials?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Name to use for caching the request.
|
|
53
|
+
*/
|
|
54
|
+
cacheName?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Properties to override default cache behavior.
|
|
57
|
+
*/
|
|
58
|
+
cacheProps?: Record<string, unknown>;
|
|
59
|
+
lunkwill?: LunkwillParam;
|
|
60
|
+
lunkwillReturnUrl?: ReturnUrl;
|
|
61
|
+
}
|
|
62
|
+
interface GetRequestOptions<Q = any, RT extends ResponseType = 'json', ReturnUrl extends boolean = false> extends Omit<RouteRequestOptions<RT, ReturnUrl, Q>, 'json' | 'body'> {
|
|
63
|
+
method?: 'GET';
|
|
64
|
+
}
|
|
65
|
+
interface RequestOptionsJSON<Q = any, B = string | null | boolean | Record<string, any> | any[], RT extends ResponseType = 'json', M extends Method = Method> extends Omit<RouteRequestOptions<RT, false, Q, B>, 'json' | 'body'> {
|
|
66
|
+
json: B;
|
|
67
|
+
method?: M;
|
|
68
|
+
}
|
|
69
|
+
interface RequestOptionsBody<Q = any, RT extends ResponseType = 'json', M extends Method = Method> extends Omit<RouteRequestOptions<RT, false, Q>, 'json' | 'body'> {
|
|
70
|
+
body: string;
|
|
71
|
+
method?: M;
|
|
72
|
+
}
|
|
73
|
+
type PutRequestOptions<Q = any, B = any, RT extends ResponseType = 'json'> = RequestOptionsJSON<Q, B, RT, 'PUT'> | RequestOptionsBody<Q, RT, 'PUT'>;
|
|
74
|
+
type PostRequestOptions<Q = any, B = any, RT extends ResponseType = 'json'> = RequestOptionsJSON<Q, B, RT, 'POST'> | RequestOptionsBody<Q, RT, 'POST'>;
|
|
75
|
+
type PatchRequestOptions<Q = any, B = any, RT extends ResponseType = 'json'> = RequestOptionsJSON<Q, B, RT, 'PATCH'> | RequestOptionsBody<Q, RT, 'PATCH'>;
|
|
76
|
+
type DeleteRequestOptions<Q = any, RT extends ResponseType = 'json'> = RouteRequestOptions<RT, false, Q>;
|
|
77
|
+
interface MethodRequestOptions<Q = any, B = any, RT extends ResponseType = 'json', ReturnUrl extends boolean = false> {
|
|
78
|
+
get: GetRequestOptions<Q, RT, ReturnUrl>;
|
|
79
|
+
post: PostRequestOptions<Q, B, RT>;
|
|
80
|
+
put: PutRequestOptions<Q, B, RT>;
|
|
81
|
+
patch: PatchRequestOptions<Q, RT>;
|
|
82
|
+
delete: DeleteRequestOptions<Q, RT>;
|
|
83
|
+
}
|
|
84
|
+
type RequestOptionsByMethod<M extends RequestMethod, Q = any, B = any, RT extends ResponseType = 'json', ReturnUrl extends boolean = false> = M extends keyof MethodRequestOptions ? MethodRequestOptions<Q, B, RT, ReturnUrl>[M] : never;
|
|
85
|
+
type ApiRouteParams = Record<string, string>;
|
|
86
|
+
interface LunkwillData {
|
|
87
|
+
status?: string;
|
|
88
|
+
delay_ms?: number;
|
|
89
|
+
}
|
|
90
|
+
type RouteResp<N extends RouteName, M extends RequestMethod> = N extends keyof Routes ? M extends keyof Routes[N] ? 'response' extends keyof Routes[N][M] ? Routes[N][M]['response'] : never : never : never;
|
|
91
|
+
type RouteQuery<N extends RouteName, M extends RequestMethod> = N extends keyof Routes ? M extends keyof Routes[N] ? 'query' extends keyof Routes[N][M] ? Routes[N][M]['query'] : any : never : never;
|
|
92
|
+
type RouteBody<N extends RouteName, M extends RequestMethod> = N extends keyof Routes ? M extends keyof Routes[N] ? 'body' extends keyof Routes[N][M] ? Routes[N][M]['body'] : any : never : never;
|
|
93
|
+
type ToReturn<T = unknown, RT extends ResponseType = 'json', ReturnUrl extends boolean = false> = ReturnUrl extends true ? string : RT extends 'blob' ? Blob : T;
|
|
94
|
+
type HasRequiredKeys<T> = {
|
|
95
|
+
[P in keyof T]-?: object extends Pick<T, P> ? never : P;
|
|
96
|
+
}[keyof T] extends never ? false : true;
|
|
97
|
+
interface RouteMethods<N extends RouteName> {
|
|
98
|
+
url: HasRequiredKeys<RouteQuery<N, 'get'>> extends true ? (options: Pick<RequestOptionsByMethod<'get', RouteQuery<N, 'get'>>, 'query'>) => Promise<string> : (options?: Pick<RequestOptionsByMethod<'get', RouteQuery<N, 'get'>>, 'query'>) => Promise<string>;
|
|
99
|
+
get: HasRequiredKeys<RouteQuery<N, 'get'>> extends true ? <T = RouteResp<N, 'get'>, RT extends ResponseType = 'json', B extends boolean = false>(options: RequestOptionsByMethod<'get', RouteQuery<N, 'get'>, any, RT, B>) => Promise<ToReturn<T, RT, B>> : <T = RouteResp<N, 'get'>, B extends boolean = false, RT extends ResponseType = 'json'>(options?: RequestOptionsByMethod<'get', RouteQuery<N, 'get'>, any, RT, B>) => Promise<ToReturn<T, RT, B>>;
|
|
100
|
+
post: <T = RouteResp<N, 'post'>, RT extends ResponseType = 'json'>(options: RequestOptionsByMethod<'post', RouteQuery<N, 'post'>, RouteBody<N, 'post'>, RT>) => Promise<ToReturn<T, RT>>;
|
|
101
|
+
put: <T = RouteResp<N, 'put'>, RT extends ResponseType = 'json'>(options: RequestOptionsByMethod<'put', RouteQuery<N, 'put'>, RouteBody<N, 'put'>, RT>) => Promise<ToReturn<T, RT>>;
|
|
102
|
+
patch: <T = RouteResp<N, 'patch'>, RT extends ResponseType = 'json'>(options: RequestOptionsByMethod<'patch', RouteQuery<N, 'patch'>, RouteBody<N, 'patch'>, RT>) => Promise<ToReturn<T, RT>>;
|
|
103
|
+
delete: HasRequiredKeys<RouteQuery<N, 'delete'>> extends true ? <T = RouteResp<N, 'delete'>>(options: RequestOptionsByMethod<'delete', RouteQuery<N, 'delete'>>) => Promise<ToReturn<T>> : <T = RouteResp<N, 'delete'>>(options?: RequestOptionsByMethod<'delete', RouteQuery<N, 'delete'>>) => Promise<ToReturn<T>>;
|
|
104
|
+
}
|
|
105
|
+
type MethodAvailable<N extends RouteName, M extends RequestMethod> = M extends 'url' ? RouteMethods<N>['url'] : M extends keyof Routes[N] ? RouteMethods<N>[M] : never;
|
|
106
|
+
type RouteResults<N extends RouteName> = {
|
|
107
|
+
[M in keyof RouteMethods<any>]: MethodAvailable<N, M>;
|
|
108
|
+
};
|
|
109
|
+
type KeysWithMethods<Methods extends RequestMethod[]> = {
|
|
110
|
+
[K in keyof Routes]: Methods extends (keyof Routes[K])[] ? K : never;
|
|
111
|
+
}[keyof Routes];
|
|
112
|
+
type PathKeys = any;
|
|
113
|
+
type KeysWithPaths<P extends PathKeys> = {
|
|
114
|
+
[K in keyof Routes]: P extends Array<keyof Routes[K]['pathObj']> ? K : never;
|
|
115
|
+
}[keyof Routes];
|
|
116
|
+
type KeysWithMethodAndPath<M extends RequestMethod[], P extends PathKeys> = {
|
|
117
|
+
[K in keyof Routes]: K extends KeysWithMethods<M> ? K extends KeysWithPaths<P> ? K : never : never;
|
|
118
|
+
}[keyof Routes];
|
|
119
|
+
|
|
120
|
+
declare class AbortError extends Error {
|
|
121
|
+
constructor(message?: string);
|
|
122
|
+
}
|
|
6
123
|
|
|
7
124
|
interface NgwLayerIdentifyError {
|
|
8
125
|
error: 'Not implemented';
|
|
@@ -476,30 +593,16 @@ interface Permission {
|
|
|
476
593
|
permission: string;
|
|
477
594
|
propagate: boolean;
|
|
478
595
|
}
|
|
479
|
-
|
|
596
|
+
/** @deprecated use ResourceCls from '@nextgisweb/resource/type/api' instead */
|
|
597
|
+
type ResourceCls = ResourceCls$1;
|
|
480
598
|
interface ResourceHierarchy {
|
|
481
599
|
id: number;
|
|
482
600
|
parent: {
|
|
483
601
|
id: any;
|
|
484
602
|
};
|
|
485
603
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
id: number;
|
|
489
|
-
parent: {
|
|
490
|
-
id: number;
|
|
491
|
-
};
|
|
492
|
-
owner_user: {
|
|
493
|
-
id: number;
|
|
494
|
-
};
|
|
495
|
-
permissions: Permission[];
|
|
496
|
-
keyname?: string | null;
|
|
497
|
-
display_name: string;
|
|
498
|
-
description?: string | null;
|
|
499
|
-
children: boolean;
|
|
500
|
-
interfaces: any[];
|
|
501
|
-
scopes: string[];
|
|
502
|
-
}
|
|
604
|
+
/** @deprecated use ResourceRead from '@nextgisweb/resource/type/api' instead */
|
|
605
|
+
type Resource = ResourceRead;
|
|
503
606
|
interface BookmarkProperties {
|
|
504
607
|
name: string;
|
|
505
608
|
place: string;
|
|
@@ -515,16 +618,8 @@ interface NgwTimeFormat {
|
|
|
515
618
|
second: number;
|
|
516
619
|
}
|
|
517
620
|
type NgwDateTimeFormat = NgwDateFormat & NgwTimeFormat;
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
extent_right: number;
|
|
521
|
-
extent_bottom: number;
|
|
522
|
-
extent_top: number;
|
|
523
|
-
extent_constrained: boolean;
|
|
524
|
-
draw_order_enabled: boolean;
|
|
525
|
-
bookmark_resource: ResourceHierarchy;
|
|
526
|
-
root_item: TreeGroup;
|
|
527
|
-
}
|
|
621
|
+
/** @deprecated use WebMapRead from '@nextgisweb/resource/type/api' instead */
|
|
622
|
+
type WebmapResource = WebMapRead;
|
|
528
623
|
interface BasemapResource {
|
|
529
624
|
url: string;
|
|
530
625
|
/**
|
|
@@ -532,16 +627,10 @@ interface BasemapResource {
|
|
|
532
627
|
*/
|
|
533
628
|
qms: string;
|
|
534
629
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
enabled?: boolean;
|
|
540
|
-
opacity?: number;
|
|
541
|
-
}
|
|
542
|
-
interface BasemapWebmap {
|
|
543
|
-
basemaps: BasemapWebmapItem[];
|
|
544
|
-
}
|
|
630
|
+
/** @deprecated use BasemapWebMapItemRead from '@nextgisweb/resource/type/api' instead */
|
|
631
|
+
type BasemapWebmapItem = BasemapWebMapItemRead;
|
|
632
|
+
/** @deprecated use BasemapWebMapRead from '@nextgisweb/resource/type/api' instead */
|
|
633
|
+
type BasemapWebmap = BasemapWebMapRead;
|
|
545
634
|
interface LookupTableResource {
|
|
546
635
|
items: Record<string, string>;
|
|
547
636
|
}
|
|
@@ -557,16 +646,11 @@ interface FeatureLayerField {
|
|
|
557
646
|
label_field: boolean;
|
|
558
647
|
typemod?: unknown;
|
|
559
648
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
}
|
|
649
|
+
/** @deprecated use FeatureLayerRead from '@nextgisweb/resource/type/api' instead */
|
|
650
|
+
type FeatureResource = FeatureLayerRead;
|
|
563
651
|
type GeometryType = 'POINT' | 'LINESTRING' | 'POLYGON' | 'MULTIPOINT' | 'MULTILINESTRING' | 'MULTIPOLYGON' | 'POINTZ' | 'LINESTRINGZ' | 'POLYGONZ' | 'MULTIPOINTZ' | 'MULTILINESTRINGZ' | 'MULTIPOLYGONZ';
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
id: number;
|
|
567
|
-
};
|
|
568
|
-
geometry_type: GeometryType;
|
|
569
|
-
}
|
|
652
|
+
/** @deprecated use VectorLayerRead from '@nextgisweb/resource/type/api' instead */
|
|
653
|
+
type VectorLayer = VectorLayerRead;
|
|
570
654
|
interface FileBucket {
|
|
571
655
|
files: NgwFile[];
|
|
572
656
|
tstamp?: any;
|
|
@@ -639,27 +723,8 @@ interface NgwFile {
|
|
|
639
723
|
interface Resmeta {
|
|
640
724
|
items: Record<string, any>;
|
|
641
725
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
resmeta: Resmeta;
|
|
645
|
-
}
|
|
646
|
-
interface ResourceItem extends ResourceItemMain {
|
|
647
|
-
[cls: string]: any;
|
|
648
|
-
webmap?: WebmapResource;
|
|
649
|
-
feature_layer?: FeatureResource;
|
|
650
|
-
vector_layer?: VectorLayer;
|
|
651
|
-
basemap_layer?: BasemapResource;
|
|
652
|
-
basemap_webmap?: BasemapWebmap;
|
|
653
|
-
lookup_table?: LookupTableResource;
|
|
654
|
-
file_bucket?: FileBucket;
|
|
655
|
-
wmsserver_service?: WmsServerService;
|
|
656
|
-
wmsclient_layer?: WmsClientLayer;
|
|
657
|
-
wmsclient_connection?: WmsClientConnection;
|
|
658
|
-
}
|
|
659
|
-
interface VectorLayerResourceItem extends ResourceItemMain {
|
|
660
|
-
vector_layer: VectorLayer;
|
|
661
|
-
feature_layer: FeatureResource;
|
|
662
|
-
}
|
|
726
|
+
/** @deprecated use CompositeRead from '@nextgisweb/resource/type/api' instead */
|
|
727
|
+
type ResourceItem = CompositeRead;
|
|
663
728
|
|
|
664
729
|
type ResourceStoreItemProperties = {
|
|
665
730
|
[name: string]: any;
|
|
@@ -694,19 +759,11 @@ interface SrsItem {
|
|
|
694
759
|
id: number;
|
|
695
760
|
wkt: string;
|
|
696
761
|
}
|
|
697
|
-
interface Icon {
|
|
698
|
-
format: string;
|
|
699
|
-
data: string;
|
|
700
|
-
}
|
|
701
|
-
interface RenderLegendSymbol {
|
|
702
|
-
display_name: string;
|
|
703
|
-
icon: Icon;
|
|
704
|
-
}
|
|
705
762
|
interface FeatureLayerCount {
|
|
706
763
|
total_count: number;
|
|
707
764
|
}
|
|
708
765
|
type ResourceIdKeynameDef = string | number;
|
|
709
|
-
type ResourceDefinition = ResourceIdKeynameDef | DeepPartial<
|
|
766
|
+
type ResourceDefinition = ResourceIdKeynameDef | DeepPartial<ResourceRead>;
|
|
710
767
|
interface FileUploadResp {
|
|
711
768
|
upload_meta: FileMeta[];
|
|
712
769
|
}
|
|
@@ -741,10 +798,10 @@ interface RequestItemsResponseMap {
|
|
|
741
798
|
interface GetRequestItemsResponseMap extends RequestItemKeys {
|
|
742
799
|
'pyramid.route': PyramidRoute;
|
|
743
800
|
'pyramid.settings': PyramidSettings;
|
|
744
|
-
'resource.item':
|
|
745
|
-
'resource.search':
|
|
801
|
+
'resource.item': CompositeRead;
|
|
802
|
+
'resource.search': CompositeRead[];
|
|
746
803
|
'resource.child': any;
|
|
747
|
-
'resource.collection':
|
|
804
|
+
'resource.collection': CompositeRead[];
|
|
748
805
|
'file_upload.upload': FileUploadResp;
|
|
749
806
|
'layer.extent': NgwExtent;
|
|
750
807
|
'feature_layer.feature.item': FeatureItem;
|
|
@@ -755,7 +812,7 @@ interface GetRequestItemsResponseMap extends RequestItemKeys {
|
|
|
755
812
|
'feature_layer.feature.count': FeatureLayerCount;
|
|
756
813
|
'pyramid.company_logo': string;
|
|
757
814
|
'spatial_ref_sys.collection': SrsItem[];
|
|
758
|
-
'render.legend_symbols':
|
|
815
|
+
'render.legend_symbols': LegendSymbol[];
|
|
759
816
|
}
|
|
760
817
|
interface IdOnly {
|
|
761
818
|
id: number;
|
|
@@ -837,7 +894,7 @@ type RequestMethods = 'POST' | 'GET' | 'PATCH' | 'DELETE' | 'PUT';
|
|
|
837
894
|
type NgwExceptions = 'nextgisweb.resource.exception.ResourceNotFound' | 'nextgisweb.core.exception.InsufficientPermissions';
|
|
838
895
|
interface BaseRequestOptions {
|
|
839
896
|
cache?: boolean;
|
|
840
|
-
signal?: AbortSignal;
|
|
897
|
+
signal?: AbortSignal | null;
|
|
841
898
|
}
|
|
842
899
|
/**
|
|
843
900
|
* Options for configuring requests to NGW.
|
|
@@ -879,7 +936,7 @@ interface RequestOptions<M extends RequestMethods = RequestMethods, K extends ke
|
|
|
879
936
|
/**
|
|
880
937
|
* Signal object that allows you to communicate with a DOM request (such as fetch) and abort it if desired via an AbortController.
|
|
881
938
|
*/
|
|
882
|
-
signal?: AbortSignal;
|
|
939
|
+
signal?: AbortSignal | null;
|
|
883
940
|
/**
|
|
884
941
|
* Parameters to be included in the request URL.
|
|
885
942
|
*/
|
|
@@ -924,60 +981,6 @@ interface GetChildrenOfOptions extends Pick<RequestOptions, 'cache'> {
|
|
|
924
981
|
recursive?: boolean;
|
|
925
982
|
}
|
|
926
983
|
|
|
927
|
-
declare class ResourcesControl {
|
|
928
|
-
cache: Cache<Promise<ResourceItem | undefined>, {
|
|
929
|
-
id?: number | string;
|
|
930
|
-
}>;
|
|
931
|
-
connector: NgwConnector;
|
|
932
|
-
constructor({ connector, cacheId, }: {
|
|
933
|
-
connector: NgwConnector;
|
|
934
|
-
cacheId?: string;
|
|
935
|
-
});
|
|
936
|
-
/**
|
|
937
|
-
* Receive resource from NGW by id, keyname or search-object parameter.
|
|
938
|
-
* @param resource - Resource id, keyname or search-object
|
|
939
|
-
*
|
|
940
|
-
* @remarks
|
|
941
|
-
* Fetching resource would be cached to speed up next call
|
|
942
|
-
*/
|
|
943
|
-
getOne(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem | undefined>;
|
|
944
|
-
getOneOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem>;
|
|
945
|
-
/**
|
|
946
|
-
* A fast way to retrieve resource ID for any resource definition.
|
|
947
|
-
* @param resource - Any available resource definition
|
|
948
|
-
*
|
|
949
|
-
* @remarks
|
|
950
|
-
* There are situations when exactly the resource id is needed
|
|
951
|
-
* (for example, to compose the correct request to the api)
|
|
952
|
-
* then this method will come in handy to facilitate the extraction of the identifier
|
|
953
|
-
* if the resource is specified through a keyname or other parameters.
|
|
954
|
-
*/
|
|
955
|
-
getId(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<number | undefined>;
|
|
956
|
-
/**
|
|
957
|
-
* A fast way to retrieve resource ID for any resource definition.
|
|
958
|
-
* @param resource - Any available resource definition
|
|
959
|
-
*
|
|
960
|
-
* @remarks
|
|
961
|
-
* Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
|
|
962
|
-
* To not make one more checks if the resource is definitely exists
|
|
963
|
-
*/
|
|
964
|
-
getIdOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<number>;
|
|
965
|
-
getMany(resource: DeepPartial<Resource>, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem[]>;
|
|
966
|
-
getParent(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem | undefined>;
|
|
967
|
-
getChildrenOf(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions): Promise<ResourceItem[]>;
|
|
968
|
-
update(resource: ResourceDefinition, data: DeepPartial<ResourceItem>): Promise<ResourceItem | undefined>;
|
|
969
|
-
/**
|
|
970
|
-
* Fast way to delete resource from NGW and clean cache.
|
|
971
|
-
* @param resource - Resource definition
|
|
972
|
-
*/
|
|
973
|
-
delete(resource: ResourceDefinition): Promise<void>;
|
|
974
|
-
private _getChildrenOf;
|
|
975
|
-
private _cleanResourceItemCache;
|
|
976
|
-
private _fetchResourceById;
|
|
977
|
-
private _fetchResourceBy;
|
|
978
|
-
private _resourceCacheFilter;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
984
|
/**
|
|
982
985
|
* Thrown when...
|
|
983
986
|
*/
|
|
@@ -993,6 +996,47 @@ declare class NgwError extends Error {
|
|
|
993
996
|
constructor(er?: Partial<NgwError>);
|
|
994
997
|
}
|
|
995
998
|
|
|
999
|
+
/**
|
|
1000
|
+
* Thrown when ...
|
|
1001
|
+
*/
|
|
1002
|
+
declare class NetworksResponseError extends NgwError {
|
|
1003
|
+
message: string;
|
|
1004
|
+
title: string;
|
|
1005
|
+
detail: string;
|
|
1006
|
+
constructor(obj?: Partial<NetworksResponseError>);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
declare function extractError(error: unknown): NetworksResponseError | {
|
|
1010
|
+
title: any;
|
|
1011
|
+
message: any;
|
|
1012
|
+
detail: any;
|
|
1013
|
+
data: any;
|
|
1014
|
+
} | {
|
|
1015
|
+
title: string;
|
|
1016
|
+
message: string;
|
|
1017
|
+
detail?: undefined;
|
|
1018
|
+
data?: undefined;
|
|
1019
|
+
} | undefined;
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Thrown when ...
|
|
1023
|
+
*/
|
|
1024
|
+
declare class InsufficientPermissionsError extends NgwError {
|
|
1025
|
+
name: string;
|
|
1026
|
+
exception: NgwExceptions;
|
|
1027
|
+
constructor(obj: InsufficientPermissionsError);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
declare function isError(error: unknown): error is Error;
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Thrown when...
|
|
1034
|
+
*/
|
|
1035
|
+
declare class NetworkError extends Error {
|
|
1036
|
+
name: string;
|
|
1037
|
+
constructor(url: string);
|
|
1038
|
+
}
|
|
1039
|
+
|
|
996
1040
|
/**
|
|
997
1041
|
* Thrown when ...
|
|
998
1042
|
*/
|
|
@@ -1002,23 +1046,37 @@ declare class ResourceNotFoundError extends NgwError {
|
|
|
1002
1046
|
constructor(obj?: ResourceNotFoundError);
|
|
1003
1047
|
}
|
|
1004
1048
|
|
|
1049
|
+
type errors_AbortError = AbortError;
|
|
1050
|
+
declare const errors_AbortError: typeof AbortError;
|
|
1051
|
+
type errors_InsufficientPermissionsError = InsufficientPermissionsError;
|
|
1052
|
+
declare const errors_InsufficientPermissionsError: typeof InsufficientPermissionsError;
|
|
1053
|
+
type errors_NetworkError = NetworkError;
|
|
1054
|
+
declare const errors_NetworkError: typeof NetworkError;
|
|
1055
|
+
type errors_NetworksResponseError = NetworksResponseError;
|
|
1056
|
+
declare const errors_NetworksResponseError: typeof NetworksResponseError;
|
|
1057
|
+
type errors_NgwError = NgwError;
|
|
1058
|
+
declare const errors_NgwError: typeof NgwError;
|
|
1059
|
+
type errors_ResourceNotFoundError = ResourceNotFoundError;
|
|
1060
|
+
declare const errors_ResourceNotFoundError: typeof ResourceNotFoundError;
|
|
1061
|
+
declare const errors_extractError: typeof extractError;
|
|
1062
|
+
declare const errors_isError: typeof isError;
|
|
1063
|
+
declare namespace errors {
|
|
1064
|
+
export { errors_AbortError as AbortError, errors_InsufficientPermissionsError as InsufficientPermissionsError, errors_NetworkError as NetworkError, errors_NetworksResponseError as NetworksResponseError, errors_NgwError as NgwError, errors_ResourceNotFoundError as ResourceNotFoundError, errors_extractError as extractError, errors_isError as isError };
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1005
1067
|
declare class NgwConnector {
|
|
1006
1068
|
options: NgwConnectorOptions;
|
|
1007
|
-
static errors:
|
|
1008
|
-
NgwError: typeof NgwError;
|
|
1009
|
-
ResourceNotFoundError: typeof ResourceNotFoundError;
|
|
1010
|
-
};
|
|
1069
|
+
static errors: typeof errors;
|
|
1011
1070
|
id: number;
|
|
1012
1071
|
emitter: EventEmitter<[never]>;
|
|
1013
1072
|
user?: UserInfo;
|
|
1014
|
-
resources: ResourcesControl;
|
|
1015
1073
|
cache: Cache;
|
|
1016
1074
|
withCredentials?: boolean;
|
|
1075
|
+
private client;
|
|
1017
1076
|
private routeStr;
|
|
1018
1077
|
private activeRequests;
|
|
1019
1078
|
private requestTransform?;
|
|
1020
1079
|
constructor(options: NgwConnectorOptions);
|
|
1021
|
-
static create(options: NgwConnectorOptions): NgwConnector;
|
|
1022
1080
|
/**
|
|
1023
1081
|
* Clear the cache.
|
|
1024
1082
|
*/
|
|
@@ -1037,13 +1095,13 @@ declare class NgwConnector {
|
|
|
1037
1095
|
* Can be used to check connection.
|
|
1038
1096
|
* @example
|
|
1039
1097
|
* ```javascript
|
|
1040
|
-
* const connector = new NgwConnector({baseUrl: 'https://demo.nextgis.com'});
|
|
1098
|
+
* const connector = new NgwConnector({ baseUrl: 'https://demo.nextgis.com' });
|
|
1041
1099
|
* connector.connect()
|
|
1042
1100
|
* .then(() => console.log('Ok'))
|
|
1043
1101
|
* .catch((er) => console.log('Connection problem', er));
|
|
1044
1102
|
* ```
|
|
1045
1103
|
*/
|
|
1046
|
-
connect(): Promise<PyramidRoute>;
|
|
1104
|
+
connect({ signal, }?: Pick<RequestOptions, 'signal'>): Promise<PyramidRoute>;
|
|
1047
1105
|
/**
|
|
1048
1106
|
* Quick way to change NextGIS Web user.
|
|
1049
1107
|
* @param credentials - New user credentials
|
|
@@ -1057,13 +1115,89 @@ declare class NgwConnector {
|
|
|
1057
1115
|
/**
|
|
1058
1116
|
* Obtaining the required Headers for authentication of requests in the NGW.
|
|
1059
1117
|
*/
|
|
1060
|
-
getAuthorizationHeaders(credentials?: Credentials): RequestHeaders
|
|
1118
|
+
getAuthorizationHeaders(credentials?: Credentials): RequestHeaders;
|
|
1061
1119
|
makeClientId(credentials?: Credentials): string | undefined;
|
|
1062
1120
|
/** Stop all api requests */
|
|
1063
1121
|
abort(): void;
|
|
1064
1122
|
getActiveApiRequests(): {
|
|
1065
1123
|
[x: number]: AbortController;
|
|
1066
1124
|
};
|
|
1125
|
+
route<N extends RouteName>(name: N, ...rest: RouteParameters[N]): RouteResults<N>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Send request to NGW.
|
|
1128
|
+
* @param url - URL address to NGW
|
|
1129
|
+
* @param params - Query params
|
|
1130
|
+
* @param options - Request options
|
|
1131
|
+
*/
|
|
1132
|
+
makeQuery<R = unknown>(url: string, params?: Params | null, options?: RequestOptions): Promise<R>;
|
|
1133
|
+
protected _loadData<R = unknown>(url: string, options: RequestOptions): Promise<R>;
|
|
1134
|
+
private _login;
|
|
1135
|
+
private _cleanActiveRequest;
|
|
1136
|
+
private _handleHttpError;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
declare class ResourcesControl {
|
|
1140
|
+
cache: Cache<Promise<CompositeRead | undefined>, {
|
|
1141
|
+
id?: number | string;
|
|
1142
|
+
}>;
|
|
1143
|
+
connector: NgwConnectorExtended;
|
|
1144
|
+
constructor({ connector, cacheId, }: {
|
|
1145
|
+
connector: NgwConnectorExtended;
|
|
1146
|
+
cacheId?: string;
|
|
1147
|
+
});
|
|
1148
|
+
/**
|
|
1149
|
+
* Receive resource from NGW by id, keyname or search-object parameter.
|
|
1150
|
+
* @param resource - Resource id, keyname or search-object
|
|
1151
|
+
*
|
|
1152
|
+
* @remarks
|
|
1153
|
+
* Fetching resource would be cached to speed up next call
|
|
1154
|
+
*/
|
|
1155
|
+
getOne(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead | undefined>;
|
|
1156
|
+
getOneOrFail(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead>;
|
|
1157
|
+
/**
|
|
1158
|
+
* A fast way to retrieve resource ID for any resource definition.
|
|
1159
|
+
* @param resource - Any available resource definition
|
|
1160
|
+
*
|
|
1161
|
+
* @remarks
|
|
1162
|
+
* There are situations when exactly the resource id is needed
|
|
1163
|
+
* (for example, to compose the correct request to the api)
|
|
1164
|
+
* then this method will come in handy to facilitate the extraction of the identifier
|
|
1165
|
+
* if the resource is specified through a keyname or other parameters.
|
|
1166
|
+
*/
|
|
1167
|
+
getId(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<number | undefined>;
|
|
1168
|
+
/**
|
|
1169
|
+
* A fast way to retrieve resource ID for any resource definition.
|
|
1170
|
+
* @param resource - Any available resource definition
|
|
1171
|
+
*
|
|
1172
|
+
* @remarks
|
|
1173
|
+
* Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
|
|
1174
|
+
* To not make one more checks if the resource is definitely exists
|
|
1175
|
+
*/
|
|
1176
|
+
getIdOrFail(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<number>;
|
|
1177
|
+
getMany(resource: DeepPartial<ResourceRead>, requestOptions?: GetRequestOptions): Promise<CompositeRead[]>;
|
|
1178
|
+
getParent(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead | undefined>;
|
|
1179
|
+
getChildrenOf(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions): Promise<CompositeRead[]>;
|
|
1180
|
+
update(resource: ResourceDefinition, data: DeepPartial<CompositeRead>): Promise<CompositeRead | undefined>;
|
|
1181
|
+
/**
|
|
1182
|
+
* Fast way to delete resource from NGW and clean cache.
|
|
1183
|
+
* @param resource - Resource definition
|
|
1184
|
+
*/
|
|
1185
|
+
delete(resource: ResourceDefinition): Promise<void>;
|
|
1186
|
+
private _getChildrenOf;
|
|
1187
|
+
private _cleanResourceItemCache;
|
|
1188
|
+
private _fetchResourceById;
|
|
1189
|
+
private _fetchResourceBy;
|
|
1190
|
+
private _resourceCacheFilter;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
declare class NgwConnectorExtended extends NgwConnector {
|
|
1194
|
+
resources: ResourcesControl;
|
|
1195
|
+
constructor(options: NgwConnectorOptions);
|
|
1196
|
+
static create(options: NgwConnectorOptions): NgwConnectorExtended;
|
|
1197
|
+
/**
|
|
1198
|
+
* Clear the cache.
|
|
1199
|
+
*/
|
|
1200
|
+
clearCache(): void;
|
|
1067
1201
|
/**
|
|
1068
1202
|
* Send request to NGW api router.
|
|
1069
1203
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
@@ -1136,64 +1270,63 @@ declare class NgwConnector {
|
|
|
1136
1270
|
* @param params - Request item params or query params
|
|
1137
1271
|
*/
|
|
1138
1272
|
delete<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'DELETE', K> | undefined | null, params?: RequestItemsParams<K>): Promise<DeleteRequestItemsResponseMap[K]>;
|
|
1139
|
-
/**
|
|
1140
|
-
* Send request to NGW.
|
|
1141
|
-
* @param url - URL address to NGW
|
|
1142
|
-
* @param params - Query params
|
|
1143
|
-
* @param options - Request options
|
|
1144
|
-
*/
|
|
1145
|
-
makeQuery<R = unknown>(url: string, params?: Params | null, options?: RequestOptions): Promise<R>;
|
|
1146
1273
|
/**
|
|
1147
1274
|
* {@link ResourcesControl.getOne}
|
|
1148
1275
|
*/
|
|
1149
|
-
getResource(resource: ResourceDefinition, requestOptions?:
|
|
1276
|
+
getResource(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead | undefined>;
|
|
1150
1277
|
/**
|
|
1151
1278
|
* {@link ResourcesControl.getOneOrFail}
|
|
1152
1279
|
*/
|
|
1153
|
-
getResourceOrFail(resource: ResourceDefinition, requestOptions?:
|
|
1280
|
+
getResourceOrFail(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead>;
|
|
1154
1281
|
/**
|
|
1155
1282
|
* @deprecated - use {@link getResource}
|
|
1156
1283
|
*/
|
|
1157
|
-
getResourceBy(resource: DeepPartial<
|
|
1284
|
+
getResourceBy(resource: DeepPartial<ResourceRead>): Promise<CompositeRead | undefined>;
|
|
1158
1285
|
/**
|
|
1159
1286
|
* @deprecated - use {@link getResource}
|
|
1160
1287
|
*/
|
|
1161
|
-
getResourceByKeyname(keyname: string): Promise<
|
|
1288
|
+
getResourceByKeyname(keyname: string): Promise<CompositeRead | undefined>;
|
|
1162
1289
|
/**
|
|
1163
1290
|
* @deprecated - use {@link getResource}
|
|
1164
1291
|
*/
|
|
1165
|
-
getResourceById(id: number): Promise<
|
|
1292
|
+
getResourceById(id: number): Promise<CompositeRead | undefined>;
|
|
1166
1293
|
/**
|
|
1167
1294
|
* {@link ResourcesControl.getId}
|
|
1168
1295
|
*/
|
|
1169
|
-
getResourceId(resource: ResourceDefinition, requestOptions?:
|
|
1296
|
+
getResourceId(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<number | undefined>;
|
|
1170
1297
|
/**
|
|
1171
1298
|
* {@link ResourcesControl.getIdOrFail}
|
|
1172
1299
|
*/
|
|
1173
|
-
getResourceIdOrFail(resource: ResourceDefinition, requestOptions?:
|
|
1300
|
+
getResourceIdOrFail(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<number>;
|
|
1174
1301
|
/**
|
|
1175
1302
|
* {@link ResourcesControl.getMany}
|
|
1176
1303
|
*/
|
|
1177
|
-
getResourcesBy(resource: DeepPartial<
|
|
1304
|
+
getResourcesBy(resource: DeepPartial<ResourceRead>, requestOptions?: GetRequestOptions): Promise<CompositeRead[]>;
|
|
1178
1305
|
/**
|
|
1179
1306
|
* {@link ResourcesControl.getParent}
|
|
1180
1307
|
*/
|
|
1181
|
-
getResourceParent(resource: ResourceDefinition, requestOptions?:
|
|
1308
|
+
getResourceParent(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead | undefined>;
|
|
1182
1309
|
/**
|
|
1183
1310
|
* {@link ResourcesControl.getChildrenOf}
|
|
1184
1311
|
*/
|
|
1185
|
-
getResourceChildren(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions): Promise<
|
|
1312
|
+
getResourceChildren(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions): Promise<CompositeRead[]>;
|
|
1186
1313
|
/**
|
|
1187
1314
|
* {@link ResourcesControl.update}
|
|
1188
1315
|
*/
|
|
1189
|
-
updateResource(resource: ResourceIdKeynameDef, data: DeepPartial<
|
|
1316
|
+
updateResource(resource: ResourceIdKeynameDef, data: DeepPartial<CompositeRead>): Promise<CompositeRead | undefined>;
|
|
1190
1317
|
/**
|
|
1191
1318
|
* {@link ResourcesControl.delete}
|
|
1192
1319
|
*/
|
|
1193
1320
|
deleteResource(resource: ResourceIdKeynameDef): Promise<void>;
|
|
1194
|
-
private _login;
|
|
1195
|
-
private _cleanActiveRequest;
|
|
1196
|
-
private _handleHttpError;
|
|
1197
1321
|
}
|
|
1198
1322
|
|
|
1199
|
-
|
|
1323
|
+
/**
|
|
1324
|
+
* Represents a legend for a specific layer.
|
|
1325
|
+
*/
|
|
1326
|
+
interface LayerLegend {
|
|
1327
|
+
layerId: string;
|
|
1328
|
+
legend: LegendSymbol[];
|
|
1329
|
+
setSymbolRender?: (symbolIndex: number, status: boolean) => void;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
export { type ApiRouteParams, type BaseRequestOptions, type BasemapResource, type BasemapWebmap, type BasemapWebmapItem, type BookmarkProperties, type CreatedResource, type Credentials, type DeleteRequestItemsResponseMap, type DeleteRequestOptions, type FeatureItem, type FeatureItemAttachment, type FeatureItemExtensions, type FeatureItemToNgw, type FeatureLayerCount, type FeatureLayerField, type FeatureLayersIdentify, type FeatureLayersIdentifyItems, type FeatureResource, type FileBucket, type FileMeta, type FileUploadResp, type GeometryType, type GetChildrenOfOptions, type GetRequestItemsResponseMap, type GetRequestOptions, type GetRouteParam, type IdOnly, type KeysWithMethodAndPath, type KeysWithMethods, type KeysWithPaths, type LayerFeature, type LayerLegend, type LoadingQueue, type LookupTableResource, type LunkwillData, type Method, type MethodAvailable, type MethodRequestOptions, type NgwConnectorOptions, type NgwDateFormat, type NgwDateTimeFormat, type NgwExceptions, type NgwExtent, type NgwFile, type NgwLayerIdentifyError, type NgwTimeFormat, type Params, type PatchRequestItemsResponseMap, type PatchRequestOptions, type Permission, type PostRequestItemsResponseMap, type PostRequestOptions, type PutRequestItemsResponseMap, type PutRequestOptions, type PyramidRoute, type PyramidSettings, type PyramidSettingsPyramid, type PyramidSettingsPyramidCompanyLogo, type RequestHeaders, type RequestItemAdditionalParams, type RequestItemKeys, type RequestItemsParams, type RequestItemsParamsMap, type RequestItemsResponseMap, type RequestMethod, type RequestMethods, type RequestOptions, type RequestOptionsBody, type RequestOptionsByMethod, type RequestOptionsJSON, type RequestTransformFunction, type Resmeta, type Resource, type ResourceCls, type ResourceDefinition, type ResourceHierarchy, type ResourceIdKeynameDef, type ResourceItem, type ResourceItemDatatype, type ResourceStoreItem, type ResourceStoreItemDefault, type ResourceStoreItemProperties, type ResponseType, type RouteBody, type RouteMethods, type RouteName, type RouteParameters, type RouteQuery, type RouteRequestOptions, type RouteResp, type RouteResults, type Router, type SrsItem, type ToReturn, type TreeGroup, type TreeItem, type TreeLayer, type UserInfo, type VectorFieldDatatype, type VectorLayer, type WebmapResource, type WmsClientConnection, type WmsClientLayer, type WmsServerService, type WmsServerServiceLayer, NgwConnectorExtended as default };
|