@nextgis/ngw-connector 3.0.0-alpha.2 → 3.0.0-alpha.22
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 +295 -102
- package/lib/ngw-connector.cjs.js +1045 -608
- 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 +1445 -875
- 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 +1248 -707
- 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 +1445 -875
- 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,123 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { Routes } from '@nextgisweb/pyramid/type/route';
|
|
2
|
+
import { CompositeRead, ResourceRead } from '@nextgisweb/resource/type/api';
|
|
3
3
|
import Cache from '@nextgis/cache';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
4
5
|
import { FeatureProperties, DeepPartial } from '@nextgis/utils';
|
|
6
|
+
import { LegendSymbol } from '@nextgisweb/render/type/api';
|
|
5
7
|
import { GeoJsonObject, Geometry } from 'geojson';
|
|
8
|
+
import { LegendSymbolsEnum } from '@nextgisweb/webmap/type/api';
|
|
9
|
+
|
|
10
|
+
declare class LunkwillParam {
|
|
11
|
+
static VALUES: (string | null)[];
|
|
12
|
+
private value;
|
|
13
|
+
constructor();
|
|
14
|
+
update(value: string | null, cond?: boolean): void;
|
|
15
|
+
suggest(cond?: boolean): void;
|
|
16
|
+
require(cond?: boolean): void;
|
|
17
|
+
toHeaders(headers: Record<string, string>): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type RouteParameters = {
|
|
21
|
+
[K in keyof Routes]: Routes[K]['pathArr'] | [Routes[K]['pathObj']];
|
|
22
|
+
};
|
|
23
|
+
type RouteName = keyof Routes;
|
|
24
|
+
type GetRouteParam<R extends RouteName> = (RouteParameters[R] & [
|
|
25
|
+
object
|
|
26
|
+
])[0];
|
|
27
|
+
type RequestMethod = keyof RouteMethods<RouteName>;
|
|
28
|
+
type Method = RequestMethod | Uppercase<RequestMethod>;
|
|
29
|
+
type CompositeFor<K extends keyof CompositeRead> = CompositeRead & Required<Pick<CompositeRead, K>>;
|
|
30
|
+
type ResponseType = 'blob' | 'json';
|
|
31
|
+
interface RouteRequestOptions<RT extends ResponseType = 'json', ReturnUrl extends boolean = false, Q = any, B = string | null | boolean | Record<string, any> | any[]> extends Omit<RequestInit, 'cache'> {
|
|
32
|
+
headers?: Record<string, string>;
|
|
33
|
+
cache?: boolean;
|
|
34
|
+
query?: Q;
|
|
35
|
+
json?: B;
|
|
36
|
+
/** Has lower priority than the json */
|
|
37
|
+
body?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The type of data that the server will respond with.
|
|
40
|
+
* Can be either 'json' or 'blob'.
|
|
41
|
+
*/
|
|
42
|
+
responseType?: RT;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated use {@link RequestInit.credential}
|
|
45
|
+
* Indicates whether to include credentials such as cookies, authentication headers,
|
|
46
|
+
* or TLS client certificates in cross-site Access-Control requests.
|
|
47
|
+
*/
|
|
48
|
+
withCredentials?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Name to use for caching the request.
|
|
51
|
+
*/
|
|
52
|
+
cacheName?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Properties to override default cache behavior.
|
|
55
|
+
*/
|
|
56
|
+
cacheProps?: Record<string, unknown>;
|
|
57
|
+
lunkwill?: LunkwillParam;
|
|
58
|
+
lunkwillReturnUrl?: ReturnUrl;
|
|
59
|
+
}
|
|
60
|
+
interface GetRequestOptions<Q = any, RT extends ResponseType = 'json', ReturnUrl extends boolean = false> extends Omit<RouteRequestOptions<RT, ReturnUrl, Q>, 'json' | 'body'> {
|
|
61
|
+
method?: 'GET';
|
|
62
|
+
}
|
|
63
|
+
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'> {
|
|
64
|
+
json: B;
|
|
65
|
+
method?: M;
|
|
66
|
+
}
|
|
67
|
+
interface RequestOptionsBody<Q = any, RT extends ResponseType = 'json', M extends Method = Method> extends Omit<RouteRequestOptions<RT, false, Q>, 'json' | 'body'> {
|
|
68
|
+
body: string;
|
|
69
|
+
method?: M;
|
|
70
|
+
}
|
|
71
|
+
type PutRequestOptions<Q = any, B = any, RT extends ResponseType = 'json'> = RequestOptionsJSON<Q, B, RT, 'PUT'> | RequestOptionsBody<Q, RT, 'PUT'>;
|
|
72
|
+
type PostRequestOptions<Q = any, B = any, RT extends ResponseType = 'json'> = RequestOptionsJSON<Q, B, RT, 'POST'> | RequestOptionsBody<Q, RT, 'POST'>;
|
|
73
|
+
type PatchRequestOptions<Q = any, B = any, RT extends ResponseType = 'json'> = RequestOptionsJSON<Q, B, RT, 'PATCH'> | RequestOptionsBody<Q, RT, 'PATCH'>;
|
|
74
|
+
type DeleteRequestOptions<Q = any, RT extends ResponseType = 'json'> = RouteRequestOptions<RT, false, Q>;
|
|
75
|
+
interface MethodRequestOptions<Q = any, B = any, RT extends ResponseType = 'json', ReturnUrl extends boolean = false> {
|
|
76
|
+
get: GetRequestOptions<Q, RT, ReturnUrl>;
|
|
77
|
+
post: PostRequestOptions<Q, B, RT>;
|
|
78
|
+
put: PutRequestOptions<Q, B, RT>;
|
|
79
|
+
patch: PatchRequestOptions<Q, RT>;
|
|
80
|
+
delete: DeleteRequestOptions<Q, RT>;
|
|
81
|
+
}
|
|
82
|
+
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;
|
|
83
|
+
type ApiRouteParams = Record<string, string>;
|
|
84
|
+
interface LunkwillData {
|
|
85
|
+
status?: string;
|
|
86
|
+
delay_ms?: number;
|
|
87
|
+
}
|
|
88
|
+
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;
|
|
89
|
+
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;
|
|
90
|
+
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;
|
|
91
|
+
type ToReturn<T = unknown, RT extends ResponseType = 'json', ReturnUrl extends boolean = false> = ReturnUrl extends true ? string : RT extends 'blob' ? Blob : T;
|
|
92
|
+
type HasRequiredKeys<T> = {
|
|
93
|
+
[P in keyof T]-?: object extends Pick<T, P> ? never : P;
|
|
94
|
+
}[keyof T] extends never ? false : true;
|
|
95
|
+
interface RouteMethods<N extends RouteName> {
|
|
96
|
+
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>;
|
|
97
|
+
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>>;
|
|
98
|
+
post: <T = RouteResp<N, 'post'>, RT extends ResponseType = 'json'>(options: RequestOptionsByMethod<'post', RouteQuery<N, 'post'>, RouteBody<N, 'post'>, RT>) => Promise<ToReturn<T, RT>>;
|
|
99
|
+
put: <T = RouteResp<N, 'put'>, RT extends ResponseType = 'json'>(options: RequestOptionsByMethod<'put', RouteQuery<N, 'put'>, RouteBody<N, 'put'>, RT>) => Promise<ToReturn<T, RT>>;
|
|
100
|
+
patch: <T = RouteResp<N, 'patch'>, RT extends ResponseType = 'json'>(options: RequestOptionsByMethod<'patch', RouteQuery<N, 'patch'>, RouteBody<N, 'patch'>, RT>) => Promise<ToReturn<T, RT>>;
|
|
101
|
+
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>>;
|
|
102
|
+
}
|
|
103
|
+
type MethodAvailable<N extends RouteName, M extends RequestMethod> = M extends 'url' ? RouteMethods<N>['url'] : M extends keyof Routes[N] ? RouteMethods<N>[M] : never;
|
|
104
|
+
type RouteResults<N extends RouteName> = {
|
|
105
|
+
[M in keyof RouteMethods<any>]: MethodAvailable<N, M>;
|
|
106
|
+
};
|
|
107
|
+
type KeysWithMethods<Methods extends RequestMethod[]> = {
|
|
108
|
+
[K in keyof Routes]: Methods extends (keyof Routes[K])[] ? K : never;
|
|
109
|
+
}[keyof Routes];
|
|
110
|
+
type PathKeys = any;
|
|
111
|
+
type KeysWithPaths<P extends PathKeys> = {
|
|
112
|
+
[K in keyof Routes]: P extends Array<keyof Routes[K]['pathObj']> ? K : never;
|
|
113
|
+
}[keyof Routes];
|
|
114
|
+
type KeysWithMethodAndPath<M extends RequestMethod[], P extends PathKeys> = {
|
|
115
|
+
[K in keyof Routes]: K extends KeysWithMethods<M> ? K extends KeysWithPaths<P> ? K : never : never;
|
|
116
|
+
}[keyof Routes];
|
|
117
|
+
|
|
118
|
+
declare class AbortError extends Error {
|
|
119
|
+
constructor(message?: string);
|
|
120
|
+
}
|
|
6
121
|
|
|
7
122
|
interface NgwLayerIdentifyError {
|
|
8
123
|
error: 'Not implemented';
|
|
@@ -476,6 +591,7 @@ interface Permission {
|
|
|
476
591
|
permission: string;
|
|
477
592
|
propagate: boolean;
|
|
478
593
|
}
|
|
594
|
+
/** @deprecated use ResourceCls from '@nextgisweb/resource/type/api' instead */
|
|
479
595
|
type ResourceCls = 'resource_group' | 'postgis_layer' | 'wmsserver_service' | 'basemap_layer' | 'postgis_connection' | 'webmap' | 'wfsserver_service' | 'vector_layer' | 'raster_layer' | 'mapserver_style' | 'qgis_vector_style' | 'qgis_raster_style' | 'raster_style' | 'file_bucket' | 'lookup_table' | 'wmsclient_layer' | 'wmsclient_connection' | 'formbuilder_form' | 'file_bucket' | 'svg_marker_library' | 'ogcfserver_service' | 'tmsclient_connection' | 'tileset' | 'collector_project' | 'demo_project' | 'trackers_group' | 'tracker' | 'terrain_provider' | 'model_3d' | 'tmsclient_layer';
|
|
480
596
|
interface ResourceHierarchy {
|
|
481
597
|
id: number;
|
|
@@ -483,6 +599,7 @@ interface ResourceHierarchy {
|
|
|
483
599
|
id: any;
|
|
484
600
|
};
|
|
485
601
|
}
|
|
602
|
+
/** @deprecated use ResourceRead from '@nextgisweb/resource/type/api' instead */
|
|
486
603
|
interface Resource {
|
|
487
604
|
cls: ResourceCls;
|
|
488
605
|
id: number;
|
|
@@ -515,6 +632,7 @@ interface NgwTimeFormat {
|
|
|
515
632
|
second: number;
|
|
516
633
|
}
|
|
517
634
|
type NgwDateTimeFormat = NgwDateFormat & NgwTimeFormat;
|
|
635
|
+
/** @deprecated use WebMapRead from '@nextgisweb/resource/type/api' instead */
|
|
518
636
|
interface WebmapResource {
|
|
519
637
|
extent_left: number;
|
|
520
638
|
extent_right: number;
|
|
@@ -532,6 +650,7 @@ interface BasemapResource {
|
|
|
532
650
|
*/
|
|
533
651
|
qms: string;
|
|
534
652
|
}
|
|
653
|
+
/** @deprecated use BasemapWebMapItemRead from '@nextgisweb/resource/type/api' instead */
|
|
535
654
|
interface BasemapWebmapItem {
|
|
536
655
|
resource_id: number;
|
|
537
656
|
display_name: string;
|
|
@@ -539,6 +658,7 @@ interface BasemapWebmapItem {
|
|
|
539
658
|
enabled?: boolean;
|
|
540
659
|
opacity?: number;
|
|
541
660
|
}
|
|
661
|
+
/** @deprecated use BasemapWebMapRead from '@nextgisweb/resource/type/api' instead */
|
|
542
662
|
interface BasemapWebmap {
|
|
543
663
|
basemaps: BasemapWebmapItem[];
|
|
544
664
|
}
|
|
@@ -557,10 +677,12 @@ interface FeatureLayerField {
|
|
|
557
677
|
label_field: boolean;
|
|
558
678
|
typemod?: unknown;
|
|
559
679
|
}
|
|
680
|
+
/** @deprecated use FeatureLayerRead from '@nextgisweb/resource/type/api' instead */
|
|
560
681
|
interface FeatureResource {
|
|
561
682
|
fields: FeatureLayerField[];
|
|
562
683
|
}
|
|
563
684
|
type GeometryType = 'POINT' | 'LINESTRING' | 'POLYGON' | 'MULTIPOINT' | 'MULTILINESTRING' | 'MULTIPOLYGON' | 'POINTZ' | 'LINESTRINGZ' | 'POLYGONZ' | 'MULTIPOINTZ' | 'MULTILINESTRINGZ' | 'MULTIPOLYGONZ';
|
|
685
|
+
/** @deprecated use VectorLayerRead from '@nextgisweb/resource/type/api' instead */
|
|
564
686
|
interface VectorLayer {
|
|
565
687
|
srs: {
|
|
566
688
|
id: number;
|
|
@@ -643,6 +765,7 @@ interface ResourceItemMain {
|
|
|
643
765
|
resource: Resource;
|
|
644
766
|
resmeta: Resmeta;
|
|
645
767
|
}
|
|
768
|
+
/** @deprecated use CompositeRead from '@nextgisweb/resource/type/api' instead */
|
|
646
769
|
interface ResourceItem extends ResourceItemMain {
|
|
647
770
|
[cls: string]: any;
|
|
648
771
|
webmap?: WebmapResource;
|
|
@@ -694,19 +817,11 @@ interface SrsItem {
|
|
|
694
817
|
id: number;
|
|
695
818
|
wkt: string;
|
|
696
819
|
}
|
|
697
|
-
interface Icon {
|
|
698
|
-
format: string;
|
|
699
|
-
data: string;
|
|
700
|
-
}
|
|
701
|
-
interface RenderLegendSymbol {
|
|
702
|
-
display_name: string;
|
|
703
|
-
icon: Icon;
|
|
704
|
-
}
|
|
705
820
|
interface FeatureLayerCount {
|
|
706
821
|
total_count: number;
|
|
707
822
|
}
|
|
708
823
|
type ResourceIdKeynameDef = string | number;
|
|
709
|
-
type ResourceDefinition = ResourceIdKeynameDef | DeepPartial<
|
|
824
|
+
type ResourceDefinition = ResourceIdKeynameDef | DeepPartial<ResourceRead>;
|
|
710
825
|
interface FileUploadResp {
|
|
711
826
|
upload_meta: FileMeta[];
|
|
712
827
|
}
|
|
@@ -741,10 +856,10 @@ interface RequestItemsResponseMap {
|
|
|
741
856
|
interface GetRequestItemsResponseMap extends RequestItemKeys {
|
|
742
857
|
'pyramid.route': PyramidRoute;
|
|
743
858
|
'pyramid.settings': PyramidSettings;
|
|
744
|
-
'resource.item':
|
|
745
|
-
'resource.search':
|
|
859
|
+
'resource.item': CompositeRead;
|
|
860
|
+
'resource.search': CompositeRead[];
|
|
746
861
|
'resource.child': any;
|
|
747
|
-
'resource.collection':
|
|
862
|
+
'resource.collection': CompositeRead[];
|
|
748
863
|
'file_upload.upload': FileUploadResp;
|
|
749
864
|
'layer.extent': NgwExtent;
|
|
750
865
|
'feature_layer.feature.item': FeatureItem;
|
|
@@ -755,7 +870,7 @@ interface GetRequestItemsResponseMap extends RequestItemKeys {
|
|
|
755
870
|
'feature_layer.feature.count': FeatureLayerCount;
|
|
756
871
|
'pyramid.company_logo': string;
|
|
757
872
|
'spatial_ref_sys.collection': SrsItem[];
|
|
758
|
-
'render.legend_symbols':
|
|
873
|
+
'render.legend_symbols': LegendSymbol[];
|
|
759
874
|
}
|
|
760
875
|
interface IdOnly {
|
|
761
876
|
id: number;
|
|
@@ -837,7 +952,7 @@ type RequestMethods = 'POST' | 'GET' | 'PATCH' | 'DELETE' | 'PUT';
|
|
|
837
952
|
type NgwExceptions = 'nextgisweb.resource.exception.ResourceNotFound' | 'nextgisweb.core.exception.InsufficientPermissions';
|
|
838
953
|
interface BaseRequestOptions {
|
|
839
954
|
cache?: boolean;
|
|
840
|
-
signal?: AbortSignal;
|
|
955
|
+
signal?: AbortSignal | null;
|
|
841
956
|
}
|
|
842
957
|
/**
|
|
843
958
|
* Options for configuring requests to NGW.
|
|
@@ -879,7 +994,7 @@ interface RequestOptions<M extends RequestMethods = RequestMethods, K extends ke
|
|
|
879
994
|
/**
|
|
880
995
|
* Signal object that allows you to communicate with a DOM request (such as fetch) and abort it if desired via an AbortController.
|
|
881
996
|
*/
|
|
882
|
-
signal?: AbortSignal;
|
|
997
|
+
signal?: AbortSignal | null;
|
|
883
998
|
/**
|
|
884
999
|
* Parameters to be included in the request URL.
|
|
885
1000
|
*/
|
|
@@ -924,60 +1039,6 @@ interface GetChildrenOfOptions extends Pick<RequestOptions, 'cache'> {
|
|
|
924
1039
|
recursive?: boolean;
|
|
925
1040
|
}
|
|
926
1041
|
|
|
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
1042
|
/**
|
|
982
1043
|
* Thrown when...
|
|
983
1044
|
*/
|
|
@@ -993,6 +1054,47 @@ declare class NgwError extends Error {
|
|
|
993
1054
|
constructor(er?: Partial<NgwError>);
|
|
994
1055
|
}
|
|
995
1056
|
|
|
1057
|
+
/**
|
|
1058
|
+
* Thrown when ...
|
|
1059
|
+
*/
|
|
1060
|
+
declare class NetworksResponseError extends NgwError {
|
|
1061
|
+
message: string;
|
|
1062
|
+
title: string;
|
|
1063
|
+
detail: string;
|
|
1064
|
+
constructor(obj?: Partial<NetworksResponseError>);
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
declare function extractError(error: unknown): NetworksResponseError | {
|
|
1068
|
+
title: any;
|
|
1069
|
+
message: any;
|
|
1070
|
+
detail: any;
|
|
1071
|
+
data: any;
|
|
1072
|
+
} | {
|
|
1073
|
+
title: string;
|
|
1074
|
+
message: string;
|
|
1075
|
+
detail?: undefined;
|
|
1076
|
+
data?: undefined;
|
|
1077
|
+
} | undefined;
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Thrown when ...
|
|
1081
|
+
*/
|
|
1082
|
+
declare class InsufficientPermissionsError extends NgwError {
|
|
1083
|
+
name: string;
|
|
1084
|
+
exception: NgwExceptions;
|
|
1085
|
+
constructor(obj: InsufficientPermissionsError);
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
declare function isError(error: unknown): error is Error;
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Thrown when...
|
|
1092
|
+
*/
|
|
1093
|
+
declare class NetworkError extends Error {
|
|
1094
|
+
name: string;
|
|
1095
|
+
constructor(url: string);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
996
1098
|
/**
|
|
997
1099
|
* Thrown when ...
|
|
998
1100
|
*/
|
|
@@ -1002,24 +1104,38 @@ declare class ResourceNotFoundError extends NgwError {
|
|
|
1002
1104
|
constructor(obj?: ResourceNotFoundError);
|
|
1003
1105
|
}
|
|
1004
1106
|
|
|
1107
|
+
type errors_AbortError = AbortError;
|
|
1108
|
+
declare const errors_AbortError: typeof AbortError;
|
|
1109
|
+
type errors_InsufficientPermissionsError = InsufficientPermissionsError;
|
|
1110
|
+
declare const errors_InsufficientPermissionsError: typeof InsufficientPermissionsError;
|
|
1111
|
+
type errors_NetworkError = NetworkError;
|
|
1112
|
+
declare const errors_NetworkError: typeof NetworkError;
|
|
1113
|
+
type errors_NetworksResponseError = NetworksResponseError;
|
|
1114
|
+
declare const errors_NetworksResponseError: typeof NetworksResponseError;
|
|
1115
|
+
type errors_NgwError = NgwError;
|
|
1116
|
+
declare const errors_NgwError: typeof NgwError;
|
|
1117
|
+
type errors_ResourceNotFoundError = ResourceNotFoundError;
|
|
1118
|
+
declare const errors_ResourceNotFoundError: typeof ResourceNotFoundError;
|
|
1119
|
+
declare const errors_extractError: typeof extractError;
|
|
1120
|
+
declare const errors_isError: typeof isError;
|
|
1121
|
+
declare namespace errors {
|
|
1122
|
+
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 };
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1005
1125
|
declare class NgwConnector {
|
|
1006
1126
|
options: NgwConnectorOptions;
|
|
1007
|
-
static errors:
|
|
1008
|
-
NgwError: typeof NgwError;
|
|
1009
|
-
ResourceNotFoundError: typeof ResourceNotFoundError;
|
|
1010
|
-
};
|
|
1127
|
+
static errors: typeof errors;
|
|
1011
1128
|
id: number;
|
|
1012
1129
|
emitter: EventEmitter<[never]>;
|
|
1013
1130
|
user?: UserInfo;
|
|
1014
|
-
resources: ResourcesControl;
|
|
1015
1131
|
cache: Cache;
|
|
1016
1132
|
withCredentials?: boolean;
|
|
1133
|
+
private readonly routeCache;
|
|
1017
1134
|
private client;
|
|
1018
1135
|
private routeStr;
|
|
1019
1136
|
private activeRequests;
|
|
1020
1137
|
private requestTransform?;
|
|
1021
1138
|
constructor(options: NgwConnectorOptions);
|
|
1022
|
-
static create(options: NgwConnectorOptions): NgwConnector;
|
|
1023
1139
|
/**
|
|
1024
1140
|
* Clear the cache.
|
|
1025
1141
|
*/
|
|
@@ -1038,13 +1154,13 @@ declare class NgwConnector {
|
|
|
1038
1154
|
* Can be used to check connection.
|
|
1039
1155
|
* @example
|
|
1040
1156
|
* ```javascript
|
|
1041
|
-
* const connector = new NgwConnector({baseUrl: 'https://demo.nextgis.com'});
|
|
1157
|
+
* const connector = new NgwConnector({ baseUrl: 'https://demo.nextgis.com' });
|
|
1042
1158
|
* connector.connect()
|
|
1043
1159
|
* .then(() => console.log('Ok'))
|
|
1044
1160
|
* .catch((er) => console.log('Connection problem', er));
|
|
1045
1161
|
* ```
|
|
1046
1162
|
*/
|
|
1047
|
-
connect(): Promise<PyramidRoute>;
|
|
1163
|
+
connect({ signal, }?: Pick<RequestOptions, 'signal'>): Promise<PyramidRoute>;
|
|
1048
1164
|
/**
|
|
1049
1165
|
* Quick way to change NextGIS Web user.
|
|
1050
1166
|
* @param credentials - New user credentials
|
|
@@ -1058,13 +1174,89 @@ declare class NgwConnector {
|
|
|
1058
1174
|
/**
|
|
1059
1175
|
* Obtaining the required Headers for authentication of requests in the NGW.
|
|
1060
1176
|
*/
|
|
1061
|
-
getAuthorizationHeaders(credentials?: Credentials): RequestHeaders
|
|
1177
|
+
getAuthorizationHeaders(credentials?: Credentials): RequestHeaders;
|
|
1062
1178
|
makeClientId(credentials?: Credentials): string | undefined;
|
|
1063
1179
|
/** Stop all api requests */
|
|
1064
1180
|
abort(): void;
|
|
1065
1181
|
getActiveApiRequests(): {
|
|
1066
1182
|
[x: number]: AbortController;
|
|
1067
1183
|
};
|
|
1184
|
+
route<N extends RouteName>(name: N, ...rest: RouteParameters[N]): RouteResults<N>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Send request to NGW.
|
|
1187
|
+
* @param url - URL address to NGW
|
|
1188
|
+
* @param params - Query params
|
|
1189
|
+
* @param options - Request options
|
|
1190
|
+
*/
|
|
1191
|
+
makeQuery<R = unknown>(url: string, params?: Params | null, options?: RequestOptions): Promise<R>;
|
|
1192
|
+
protected _loadData<R = unknown>(url: string, options: RequestOptions): Promise<R>;
|
|
1193
|
+
private _login;
|
|
1194
|
+
private _cleanActiveRequest;
|
|
1195
|
+
private _handleHttpError;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
declare class ResourcesControl {
|
|
1199
|
+
cache: Cache<Promise<CompositeRead | undefined>, {
|
|
1200
|
+
id?: number | string;
|
|
1201
|
+
}>;
|
|
1202
|
+
connector: NgwConnectorExtended;
|
|
1203
|
+
constructor({ connector, cacheId, }: {
|
|
1204
|
+
connector: NgwConnectorExtended;
|
|
1205
|
+
cacheId?: string;
|
|
1206
|
+
});
|
|
1207
|
+
/**
|
|
1208
|
+
* Receive resource from NGW by id, keyname or search-object parameter.
|
|
1209
|
+
* @param resource - Resource id, keyname or search-object
|
|
1210
|
+
*
|
|
1211
|
+
* @remarks
|
|
1212
|
+
* Fetching resource would be cached to speed up next call
|
|
1213
|
+
*/
|
|
1214
|
+
getOne(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead | undefined>;
|
|
1215
|
+
getOneOrFail(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead>;
|
|
1216
|
+
/**
|
|
1217
|
+
* A fast way to retrieve resource ID for any resource definition.
|
|
1218
|
+
* @param resource - Any available resource definition
|
|
1219
|
+
*
|
|
1220
|
+
* @remarks
|
|
1221
|
+
* There are situations when exactly the resource id is needed
|
|
1222
|
+
* (for example, to compose the correct request to the api)
|
|
1223
|
+
* then this method will come in handy to facilitate the extraction of the identifier
|
|
1224
|
+
* if the resource is specified through a keyname or other parameters.
|
|
1225
|
+
*/
|
|
1226
|
+
getId(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<number | undefined>;
|
|
1227
|
+
/**
|
|
1228
|
+
* A fast way to retrieve resource ID for any resource definition.
|
|
1229
|
+
* @param resource - Any available resource definition
|
|
1230
|
+
*
|
|
1231
|
+
* @remarks
|
|
1232
|
+
* Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
|
|
1233
|
+
* To not make one more checks if the resource is definitely exists
|
|
1234
|
+
*/
|
|
1235
|
+
getIdOrFail(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<number>;
|
|
1236
|
+
getMany(resource: DeepPartial<ResourceRead>, requestOptions?: GetRequestOptions): Promise<CompositeRead[]>;
|
|
1237
|
+
getParent(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead | undefined>;
|
|
1238
|
+
getChildrenOf(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions): Promise<CompositeRead[]>;
|
|
1239
|
+
update(resource: ResourceDefinition, data: DeepPartial<CompositeRead>): Promise<CompositeRead | undefined>;
|
|
1240
|
+
/**
|
|
1241
|
+
* Fast way to delete resource from NGW and clean cache.
|
|
1242
|
+
* @param resource - Resource definition
|
|
1243
|
+
*/
|
|
1244
|
+
delete(resource: ResourceDefinition): Promise<void>;
|
|
1245
|
+
private _getChildrenOf;
|
|
1246
|
+
private _cleanResourceItemCache;
|
|
1247
|
+
private _fetchResourceById;
|
|
1248
|
+
private _fetchResourceBy;
|
|
1249
|
+
private _resourceCacheFilter;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
declare class NgwConnectorExtended extends NgwConnector {
|
|
1253
|
+
resources: ResourcesControl;
|
|
1254
|
+
constructor(options: NgwConnectorOptions);
|
|
1255
|
+
static create(options: NgwConnectorOptions): NgwConnectorExtended;
|
|
1256
|
+
/**
|
|
1257
|
+
* Clear the cache.
|
|
1258
|
+
*/
|
|
1259
|
+
clearCache(): void;
|
|
1068
1260
|
/**
|
|
1069
1261
|
* Send request to NGW api router.
|
|
1070
1262
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
@@ -1137,64 +1329,65 @@ declare class NgwConnector {
|
|
|
1137
1329
|
* @param params - Request item params or query params
|
|
1138
1330
|
*/
|
|
1139
1331
|
delete<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'DELETE', K> | undefined | null, params?: RequestItemsParams<K>): Promise<DeleteRequestItemsResponseMap[K]>;
|
|
1140
|
-
/**
|
|
1141
|
-
* Send request to NGW.
|
|
1142
|
-
* @param url - URL address to NGW
|
|
1143
|
-
* @param params - Query params
|
|
1144
|
-
* @param options - Request options
|
|
1145
|
-
*/
|
|
1146
|
-
makeQuery<R = unknown>(url: string, params?: Params | null, options?: RequestOptions): Promise<R>;
|
|
1147
1332
|
/**
|
|
1148
1333
|
* {@link ResourcesControl.getOne}
|
|
1149
1334
|
*/
|
|
1150
|
-
getResource(resource: ResourceDefinition, requestOptions?:
|
|
1335
|
+
getResource(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead | undefined>;
|
|
1151
1336
|
/**
|
|
1152
1337
|
* {@link ResourcesControl.getOneOrFail}
|
|
1153
1338
|
*/
|
|
1154
|
-
getResourceOrFail(resource: ResourceDefinition, requestOptions?:
|
|
1339
|
+
getResourceOrFail(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead>;
|
|
1155
1340
|
/**
|
|
1156
1341
|
* @deprecated - use {@link getResource}
|
|
1157
1342
|
*/
|
|
1158
|
-
getResourceBy(resource: DeepPartial<
|
|
1343
|
+
getResourceBy(resource: DeepPartial<ResourceRead>): Promise<CompositeRead | undefined>;
|
|
1159
1344
|
/**
|
|
1160
1345
|
* @deprecated - use {@link getResource}
|
|
1161
1346
|
*/
|
|
1162
|
-
getResourceByKeyname(keyname: string): Promise<
|
|
1347
|
+
getResourceByKeyname(keyname: string): Promise<CompositeRead | undefined>;
|
|
1163
1348
|
/**
|
|
1164
1349
|
* @deprecated - use {@link getResource}
|
|
1165
1350
|
*/
|
|
1166
|
-
getResourceById(id: number): Promise<
|
|
1351
|
+
getResourceById(id: number): Promise<CompositeRead | undefined>;
|
|
1167
1352
|
/**
|
|
1168
1353
|
* {@link ResourcesControl.getId}
|
|
1169
1354
|
*/
|
|
1170
|
-
getResourceId(resource: ResourceDefinition, requestOptions?:
|
|
1355
|
+
getResourceId(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<number | undefined>;
|
|
1171
1356
|
/**
|
|
1172
1357
|
* {@link ResourcesControl.getIdOrFail}
|
|
1173
1358
|
*/
|
|
1174
|
-
getResourceIdOrFail(resource: ResourceDefinition, requestOptions?:
|
|
1359
|
+
getResourceIdOrFail(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<number>;
|
|
1175
1360
|
/**
|
|
1176
1361
|
* {@link ResourcesControl.getMany}
|
|
1177
1362
|
*/
|
|
1178
|
-
getResourcesBy(resource: DeepPartial<
|
|
1363
|
+
getResourcesBy(resource: DeepPartial<ResourceRead>, requestOptions?: GetRequestOptions): Promise<CompositeRead[]>;
|
|
1179
1364
|
/**
|
|
1180
1365
|
* {@link ResourcesControl.getParent}
|
|
1181
1366
|
*/
|
|
1182
|
-
getResourceParent(resource: ResourceDefinition, requestOptions?:
|
|
1367
|
+
getResourceParent(resource: ResourceDefinition, requestOptions?: GetRequestOptions): Promise<CompositeRead | undefined>;
|
|
1183
1368
|
/**
|
|
1184
1369
|
* {@link ResourcesControl.getChildrenOf}
|
|
1185
1370
|
*/
|
|
1186
|
-
getResourceChildren(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions): Promise<
|
|
1371
|
+
getResourceChildren(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions): Promise<CompositeRead[]>;
|
|
1187
1372
|
/**
|
|
1188
1373
|
* {@link ResourcesControl.update}
|
|
1189
1374
|
*/
|
|
1190
|
-
updateResource(resource: ResourceIdKeynameDef, data: DeepPartial<
|
|
1375
|
+
updateResource(resource: ResourceIdKeynameDef, data: DeepPartial<CompositeRead>): Promise<CompositeRead | undefined>;
|
|
1191
1376
|
/**
|
|
1192
1377
|
* {@link ResourcesControl.delete}
|
|
1193
1378
|
*/
|
|
1194
1379
|
deleteResource(resource: ResourceIdKeynameDef): Promise<void>;
|
|
1195
|
-
private _login;
|
|
1196
|
-
private _cleanActiveRequest;
|
|
1197
|
-
private _handleHttpError;
|
|
1198
1380
|
}
|
|
1199
1381
|
|
|
1200
|
-
|
|
1382
|
+
/**
|
|
1383
|
+
* Represents a legend for a specific layer.
|
|
1384
|
+
*/
|
|
1385
|
+
interface LayerLegend {
|
|
1386
|
+
layerId: string;
|
|
1387
|
+
legend?: LegendSymbol[];
|
|
1388
|
+
resourceId: number;
|
|
1389
|
+
setSymbolRender?: (symbolIndex: number, status: boolean) => void;
|
|
1390
|
+
legendSymbols?: LegendSymbolsEnum;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
export { type ApiRouteParams, type BaseRequestOptions, type BasemapResource, type BasemapWebmap, type BasemapWebmapItem, type BookmarkProperties, type CompositeFor, 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 ResourceItemMain, 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 VectorLayerResourceItem, type WebmapResource, type WmsClientConnection, type WmsClientLayer, type WmsServerService, type WmsServerServiceLayer, NgwConnectorExtended as default };
|