@nextgis/ngw-connector 2.3.0 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +45 -37
- package/lib/ngw-connector.cjs.js +194 -185
- 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 +321 -548
- 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 +304 -217
- 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 +321 -548
- 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 +6 -6
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import Cache from '@nextgis/cache';
|
|
4
|
-
import CancelablePromise from '@nextgis/cancelable-promise';
|
|
5
4
|
import { FeatureProperties, DeepPartial } from '@nextgis/utils';
|
|
6
5
|
import { GeoJsonObject, Geometry } from 'geojson';
|
|
7
6
|
|
|
@@ -800,7 +799,11 @@ interface RequestHeaders {
|
|
|
800
799
|
}
|
|
801
800
|
type RequestMethods = 'POST' | 'GET' | 'PATCH' | 'DELETE' | 'PUT';
|
|
802
801
|
type NgwExceptions = 'nextgisweb.resource.exception.ResourceNotFound' | 'nextgisweb.core.exception.InsufficientPermissions';
|
|
803
|
-
interface
|
|
802
|
+
interface BaseRequestOptions {
|
|
803
|
+
cache?: boolean;
|
|
804
|
+
signal?: AbortSignal;
|
|
805
|
+
}
|
|
806
|
+
interface RequestOptions<M extends RequestMethods = RequestMethods, K extends keyof RequestItemsParamsMap = keyof RequestItemsParamsMap> extends BaseRequestOptions {
|
|
804
807
|
data?: any;
|
|
805
808
|
file?: File;
|
|
806
809
|
method?: M;
|
|
@@ -811,6 +814,9 @@ interface RequestOptions<M extends RequestMethods = RequestMethods, K extends ke
|
|
|
811
814
|
signal?: AbortSignal;
|
|
812
815
|
params?: RequestItemsParams<K>;
|
|
813
816
|
onProgress?: (percentComplete: number, event: ProgressEvent) => void;
|
|
817
|
+
cacheName?: string;
|
|
818
|
+
/** Use to override default cache props */
|
|
819
|
+
cacheProps?: Record<string, unknown>;
|
|
814
820
|
}
|
|
815
821
|
type RequestItemAdditionalParams = {
|
|
816
822
|
[name: string]: any;
|
|
@@ -838,7 +844,7 @@ interface GetChildrenOfOptions extends Pick<RequestOptions, 'cache'> {
|
|
|
838
844
|
}
|
|
839
845
|
|
|
840
846
|
declare class ResourcesControl {
|
|
841
|
-
cache: Cache<
|
|
847
|
+
cache: Cache<Promise<ResourceItem | undefined>, {
|
|
842
848
|
id?: number | string;
|
|
843
849
|
}>;
|
|
844
850
|
connector: NgwConnector;
|
|
@@ -853,8 +859,8 @@ declare class ResourcesControl {
|
|
|
853
859
|
* @remarks
|
|
854
860
|
* Fetching resource would be cached to speed up next call
|
|
855
861
|
*/
|
|
856
|
-
getOne(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
857
|
-
getOneOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
862
|
+
getOne(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem | undefined>;
|
|
863
|
+
getOneOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem>;
|
|
858
864
|
/**
|
|
859
865
|
* A fast way to retrieve resource ID for any resource definition.
|
|
860
866
|
* @param resource - Any available resource definition
|
|
@@ -865,7 +871,7 @@ declare class ResourcesControl {
|
|
|
865
871
|
* then this method will come in handy to facilitate the extraction of the identifier
|
|
866
872
|
* if the resource is specified through a keyname or other parameters.
|
|
867
873
|
*/
|
|
868
|
-
getId(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
874
|
+
getId(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<number | undefined>;
|
|
869
875
|
/**
|
|
870
876
|
* A fast way to retrieve resource ID for any resource definition.
|
|
871
877
|
* @param resource - Any available resource definition
|
|
@@ -874,16 +880,16 @@ declare class ResourcesControl {
|
|
|
874
880
|
* Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
|
|
875
881
|
* To not make one more checks if the resource is definitely exists
|
|
876
882
|
*/
|
|
877
|
-
getIdOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
878
|
-
getMany(resource: DeepPartial<Resource>, requestOptions?: RequestOptions<'GET'>):
|
|
879
|
-
getParent(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
880
|
-
getChildrenOf(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions):
|
|
881
|
-
update(resource: ResourceDefinition, data: DeepPartial<ResourceItem>):
|
|
883
|
+
getIdOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<number>;
|
|
884
|
+
getMany(resource: DeepPartial<Resource>, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem[]>;
|
|
885
|
+
getParent(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem | undefined>;
|
|
886
|
+
getChildrenOf(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions): Promise<ResourceItem[]>;
|
|
887
|
+
update(resource: ResourceDefinition, data: DeepPartial<ResourceItem>): Promise<ResourceItem | undefined>;
|
|
882
888
|
/**
|
|
883
889
|
* Fast way to delete resource from NGW and clean cache.
|
|
884
890
|
* @param resource - Resource definition
|
|
885
891
|
*/
|
|
886
|
-
delete(resource: ResourceDefinition):
|
|
892
|
+
delete(resource: ResourceDefinition): Promise<void>;
|
|
887
893
|
private _getChildrenOf;
|
|
888
894
|
private _cleanResourceItemCache;
|
|
889
895
|
private _fetchResourceById;
|
|
@@ -955,17 +961,17 @@ declare class NgwConnector {
|
|
|
955
961
|
* .catch((er) => console.log('Connection problem', er));
|
|
956
962
|
* ```
|
|
957
963
|
*/
|
|
958
|
-
connect():
|
|
964
|
+
connect(): Promise<PyramidRoute>;
|
|
959
965
|
/**
|
|
960
966
|
* Quick way to change NextGIS Web user.
|
|
961
967
|
* @param credentials - New user credentials
|
|
962
968
|
*/
|
|
963
|
-
login(credentials: Credentials, options?: RequestOptions):
|
|
969
|
+
login(credentials: Credentials, options?: RequestOptions): Promise<UserInfo>;
|
|
964
970
|
/**
|
|
965
971
|
* Disconnecting a user. Aborting all current requests
|
|
966
972
|
*/
|
|
967
973
|
logout(): void;
|
|
968
|
-
getUserInfo(credentials?: Credentials, options?: RequestOptions):
|
|
974
|
+
getUserInfo(credentials?: Credentials, options?: RequestOptions): Promise<UserInfo>;
|
|
969
975
|
/**
|
|
970
976
|
* Obtaining the required Headers for authentication of requests in the NGW.
|
|
971
977
|
*/
|
|
@@ -973,7 +979,9 @@ declare class NgwConnector {
|
|
|
973
979
|
makeClientId(credentials?: Credentials): string | undefined;
|
|
974
980
|
/** Stop all api requests */
|
|
975
981
|
abort(): void;
|
|
976
|
-
getActiveApiRequests():
|
|
982
|
+
getActiveApiRequests(): {
|
|
983
|
+
[x: number]: AbortController;
|
|
984
|
+
};
|
|
977
985
|
/**
|
|
978
986
|
* Send request to NGW api router.
|
|
979
987
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
@@ -1003,7 +1011,7 @@ declare class NgwConnector {
|
|
|
1003
1011
|
*
|
|
1004
1012
|
* ```
|
|
1005
1013
|
*/
|
|
1006
|
-
apiRequest<K extends keyof RequestItemsParamsMap, P extends RequestItemKeys = RequestItemKeys>(name: K, params_?: RequestItemsParams<K>, requestOptions?: RequestOptions):
|
|
1014
|
+
apiRequest<K extends keyof RequestItemsParamsMap, P extends RequestItemKeys = RequestItemKeys>(name: K, params_?: RequestItemsParams<K>, requestOptions?: RequestOptions): Promise<P[K]>;
|
|
1007
1015
|
/**
|
|
1008
1016
|
* Shortcut method for send POST request to NGW.
|
|
1009
1017
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
@@ -1017,93 +1025,93 @@ declare class NgwConnector {
|
|
|
1017
1025
|
* .catch((error) => console.warn(error));
|
|
1018
1026
|
* ```
|
|
1019
1027
|
*/
|
|
1020
|
-
post<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'POST', K>, params?: RequestItemsParams<K>):
|
|
1028
|
+
post<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'POST', K>, params?: RequestItemsParams<K>): Promise<PostRequestItemsResponseMap[K]>;
|
|
1021
1029
|
/**
|
|
1022
1030
|
* Shortcut method for send GET request to NGW.
|
|
1023
1031
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
1024
1032
|
* @param options - Request options
|
|
1025
1033
|
* @param params - Request item params or query params
|
|
1026
1034
|
*/
|
|
1027
|
-
get<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'GET', K> | undefined | null, params?: RequestItemsParams<K>):
|
|
1035
|
+
get<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'GET', K> | undefined | null, params?: RequestItemsParams<K>): Promise<GetRequestItemsResponseMap[K]>;
|
|
1028
1036
|
/**
|
|
1029
1037
|
* Shortcut method for send PATCH request to NGW.
|
|
1030
1038
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
1031
1039
|
* @param options - Request options
|
|
1032
1040
|
* @param params - Request item params or query params
|
|
1033
1041
|
*/
|
|
1034
|
-
patch<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'PATCH', K>, params?: RequestItemsParams<K>):
|
|
1042
|
+
patch<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'PATCH', K>, params?: RequestItemsParams<K>): Promise<PatchRequestItemsResponseMap[K]>;
|
|
1035
1043
|
/**
|
|
1036
1044
|
* Shortcut method for send PUT request to NGW.
|
|
1037
1045
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
1038
1046
|
* @param options - Request options
|
|
1039
1047
|
* @param params - Request item params or query params
|
|
1040
1048
|
*/
|
|
1041
|
-
put<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'PUT', K>, params?: RequestItemsParams<K>):
|
|
1049
|
+
put<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'PUT', K>, params?: RequestItemsParams<K>): Promise<PutRequestItemsResponseMap[K]>;
|
|
1042
1050
|
/**
|
|
1043
1051
|
* Shortcut method for send DELETE request to NGW.
|
|
1044
1052
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
1045
1053
|
* @param options - Request options
|
|
1046
1054
|
* @param params - Request item params or query params
|
|
1047
1055
|
*/
|
|
1048
|
-
delete<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'DELETE', K> | undefined | null, params?: RequestItemsParams<K>):
|
|
1056
|
+
delete<K extends keyof RequestItemsParamsMap>(name: K, options?: RequestOptions<'DELETE', K> | undefined | null, params?: RequestItemsParams<K>): Promise<DeleteRequestItemsResponseMap[K]>;
|
|
1049
1057
|
/**
|
|
1050
1058
|
* Send request to NGW.
|
|
1051
1059
|
* @param url - URL address to NGW
|
|
1052
1060
|
* @param params - Query params
|
|
1053
1061
|
* @param options - Request options
|
|
1054
1062
|
*/
|
|
1055
|
-
makeQuery<R = unknown>(url: string, params?: Params | null, options?: RequestOptions):
|
|
1063
|
+
makeQuery<R = unknown>(url: string, params?: Params | null, options?: RequestOptions): Promise<R>;
|
|
1056
1064
|
/**
|
|
1057
1065
|
* {@link ResourcesControl.getOne}
|
|
1058
1066
|
*/
|
|
1059
|
-
getResource(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
1067
|
+
getResource(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem | undefined>;
|
|
1060
1068
|
/**
|
|
1061
1069
|
* {@link ResourcesControl.getOneOrFail}
|
|
1062
1070
|
*/
|
|
1063
|
-
getResourceOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
1071
|
+
getResourceOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem>;
|
|
1064
1072
|
/**
|
|
1065
1073
|
* @deprecated - use {@link getResource}
|
|
1066
1074
|
*/
|
|
1067
|
-
getResourceBy(resource: DeepPartial<Resource>):
|
|
1075
|
+
getResourceBy(resource: DeepPartial<Resource>): Promise<ResourceItem | undefined>;
|
|
1068
1076
|
/**
|
|
1069
1077
|
* @deprecated - use {@link getResource}
|
|
1070
1078
|
*/
|
|
1071
|
-
getResourceByKeyname(keyname: string):
|
|
1079
|
+
getResourceByKeyname(keyname: string): Promise<ResourceItem | undefined>;
|
|
1072
1080
|
/**
|
|
1073
1081
|
* @deprecated - use {@link getResource}
|
|
1074
1082
|
*/
|
|
1075
|
-
getResourceById(id: number):
|
|
1083
|
+
getResourceById(id: number): Promise<ResourceItem | undefined>;
|
|
1076
1084
|
/**
|
|
1077
1085
|
* {@link ResourcesControl.getId}
|
|
1078
1086
|
*/
|
|
1079
|
-
getResourceId(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
1087
|
+
getResourceId(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<number | undefined>;
|
|
1080
1088
|
/**
|
|
1081
1089
|
* {@link ResourcesControl.getIdOrFail}
|
|
1082
1090
|
*/
|
|
1083
|
-
getResourceIdOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
1091
|
+
getResourceIdOrFail(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<number>;
|
|
1084
1092
|
/**
|
|
1085
1093
|
* {@link ResourcesControl.getMany}
|
|
1086
1094
|
*/
|
|
1087
|
-
getResourcesBy(resource: DeepPartial<Resource>, requestOptions?: RequestOptions<'GET'>):
|
|
1095
|
+
getResourcesBy(resource: DeepPartial<Resource>, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem[]>;
|
|
1088
1096
|
/**
|
|
1089
1097
|
* {@link ResourcesControl.getParent}
|
|
1090
1098
|
*/
|
|
1091
|
-
getResourceParent(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>):
|
|
1099
|
+
getResourceParent(resource: ResourceDefinition, requestOptions?: RequestOptions<'GET'>): Promise<ResourceItem | undefined>;
|
|
1092
1100
|
/**
|
|
1093
1101
|
* {@link ResourcesControl.getChildrenOf}
|
|
1094
1102
|
*/
|
|
1095
|
-
getResourceChildren(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions):
|
|
1103
|
+
getResourceChildren(resource: ResourceDefinition, requestOptions?: GetChildrenOfOptions): Promise<ResourceItem[]>;
|
|
1096
1104
|
/**
|
|
1097
1105
|
* {@link ResourcesControl.update}
|
|
1098
1106
|
*/
|
|
1099
|
-
updateResource(resource: ResourceIdKeynameDef, data: DeepPartial<ResourceItem>):
|
|
1107
|
+
updateResource(resource: ResourceIdKeynameDef, data: DeepPartial<ResourceItem>): Promise<ResourceItem | undefined>;
|
|
1100
1108
|
/**
|
|
1101
1109
|
* {@link ResourcesControl.delete}
|
|
1102
1110
|
*/
|
|
1103
|
-
deleteResource(resource: ResourceIdKeynameDef):
|
|
1111
|
+
deleteResource(resource: ResourceIdKeynameDef): Promise<void>;
|
|
1104
1112
|
private _login;
|
|
1105
|
-
private
|
|
1113
|
+
private _cleanActiveRequest;
|
|
1106
1114
|
private _handleHttpError;
|
|
1107
1115
|
}
|
|
1108
1116
|
|
|
1109
|
-
export { type BasemapResource, type BasemapWebmap, type BasemapWebmapItem, type BookmarkProperties, type CreatedResource, type Credentials, type DeleteRequestItemsResponseMap, 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 IdOnly, type LayerFeature, type LoadingQueue, type LookupTableResource, type NgwConnectorOptions, type NgwDateFormat, type NgwDateTimeFormat, type NgwExceptions, type NgwExtent, type NgwFile, type NgwLayerIdentifyError, type NgwTimeFormat, type Params, type PatchRequestItemsResponseMap, type Permission, type PostRequestItemsResponseMap, type PutRequestItemsResponseMap, type PyramidRoute, type PyramidSettings, type PyramidSettingsPyramid, type PyramidSettingsPyramidCompanyLogo, type RenderLegendSymbol, type RequestHeaders, type RequestItemAdditionalParams, type RequestItemKeys, type RequestItemsParams, type RequestItemsParamsMap, type RequestItemsResponseMap, type RequestMethods, type RequestOptions, 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 Router, type SrsItem, type TreeGroup, type TreeItem, type TreeLayer, type UserInfo, type VectorFieldDatatype, type VectorLayer, type VectorLayerResourceItem, type WebmapResource, type WmsClientConnection, type WmsClientLayer, type WmsServerService, type WmsServerServiceLayer, NgwConnector as default };
|
|
1117
|
+
export { type BaseRequestOptions, type BasemapResource, type BasemapWebmap, type BasemapWebmapItem, type BookmarkProperties, type CreatedResource, type Credentials, type DeleteRequestItemsResponseMap, 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 IdOnly, type LayerFeature, type LoadingQueue, type LookupTableResource, type NgwConnectorOptions, type NgwDateFormat, type NgwDateTimeFormat, type NgwExceptions, type NgwExtent, type NgwFile, type NgwLayerIdentifyError, type NgwTimeFormat, type Params, type PatchRequestItemsResponseMap, type Permission, type PostRequestItemsResponseMap, type PutRequestItemsResponseMap, type PyramidRoute, type PyramidSettings, type PyramidSettingsPyramid, type PyramidSettingsPyramidCompanyLogo, type RenderLegendSymbol, type RequestHeaders, type RequestItemAdditionalParams, type RequestItemKeys, type RequestItemsParams, type RequestItemsParamsMap, type RequestItemsResponseMap, type RequestMethods, type RequestOptions, 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 Router, type SrsItem, type TreeGroup, type TreeItem, type TreeLayer, type UserInfo, type VectorFieldDatatype, type VectorLayer, type VectorLayerResourceItem, type WebmapResource, type WmsClientConnection, type WmsClientLayer, type WmsServerService, type WmsServerServiceLayer, NgwConnector as default };
|