@nextgis/ngw-connector 1.9.4 → 1.11.8
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 +125 -120
- package/lib/index.d.ts +79 -7
- package/lib/ngw-connector.cjs.js +61 -27
- 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 +9 -9
- 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 +9 -9
- 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 +22 -18
- 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 +8 -7
package/README.md
CHANGED
|
@@ -95,126 +95,131 @@ ngwConnector.get(request_name, request_options, arguments);
|
|
|
95
95
|
|
|
96
96
|
[request_options](https://code-api.nextgis.com/interfaces/ngw_connector.RequestOptions.html)
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
|
102
|
-
|
|
|
103
|
-
| auth.
|
|
104
|
-
| auth.group.
|
|
105
|
-
| auth.group.
|
|
106
|
-
| auth.
|
|
107
|
-
| auth.
|
|
108
|
-
| auth.
|
|
109
|
-
| auth.
|
|
110
|
-
| auth.
|
|
111
|
-
| auth.
|
|
112
|
-
| auth.
|
|
113
|
-
| auth.user.
|
|
114
|
-
| auth.user.
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
| collector.
|
|
119
|
-
| collector.
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
| feature_attachment.
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
| feature_layer.feature.
|
|
128
|
-
| feature_layer.feature.
|
|
129
|
-
| feature_layer.feature.
|
|
130
|
-
| feature_layer.feature.
|
|
131
|
-
| feature_layer.
|
|
132
|
-
| feature_layer.
|
|
133
|
-
| feature_layer.
|
|
134
|
-
| feature_layer.
|
|
135
|
-
| feature_layer.
|
|
136
|
-
| feature_layer.
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
| pyramid.
|
|
148
|
-
| pyramid.
|
|
149
|
-
| pyramid.
|
|
150
|
-
| pyramid.
|
|
151
|
-
| pyramid.
|
|
152
|
-
| pyramid.
|
|
153
|
-
| pyramid.
|
|
154
|
-
| pyramid.
|
|
155
|
-
| pyramid.
|
|
156
|
-
| pyramid.
|
|
157
|
-
| pyramid.
|
|
158
|
-
| pyramid.
|
|
159
|
-
| pyramid.
|
|
160
|
-
| pyramid.
|
|
161
|
-
|
|
|
162
|
-
|
|
|
163
|
-
|
|
|
164
|
-
|
|
|
165
|
-
| render.
|
|
166
|
-
|
|
|
167
|
-
|
|
|
168
|
-
|
|
|
169
|
-
| resource.
|
|
170
|
-
| resource.
|
|
171
|
-
| resource.
|
|
172
|
-
| resource.
|
|
173
|
-
| resource.
|
|
174
|
-
| resource.
|
|
175
|
-
| resource.
|
|
176
|
-
| resource.
|
|
177
|
-
| resource.
|
|
178
|
-
| resource.
|
|
179
|
-
| resource.
|
|
180
|
-
| resource.
|
|
181
|
-
| resource.
|
|
182
|
-
| resource.
|
|
183
|
-
| resource.
|
|
184
|
-
| resource.
|
|
185
|
-
|
|
|
186
|
-
|
|
|
187
|
-
|
|
|
188
|
-
| spatial_ref_sys.
|
|
189
|
-
| spatial_ref_sys.
|
|
190
|
-
| spatial_ref_sys.
|
|
191
|
-
|
|
|
192
|
-
|
|
|
193
|
-
|
|
|
194
|
-
|
|
|
195
|
-
|
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
| tracker.
|
|
199
|
-
| tracker.
|
|
200
|
-
| tracker.
|
|
201
|
-
| tracker.
|
|
202
|
-
| tracker.
|
|
203
|
-
| tracker.
|
|
204
|
-
| tracker.
|
|
205
|
-
| tracker.
|
|
206
|
-
| tracker.
|
|
207
|
-
| tracker.
|
|
208
|
-
| tracker.
|
|
209
|
-
| tracker.
|
|
210
|
-
|
|
|
211
|
-
|
|
|
212
|
-
|
|
|
213
|
-
|
|
|
214
|
-
| webmap.
|
|
215
|
-
| webmap.
|
|
216
|
-
|
|
|
217
|
-
|
|
|
98
|
+
<details>
|
|
99
|
+
<summary>API request names</summary>
|
|
100
|
+
|
|
101
|
+
| request name | url | arguments |
|
|
102
|
+
| --------------------------------- | ----------------------------------------------------- | ---------------- |
|
|
103
|
+
| auth.current_user | /api/component/auth/current_user | |
|
|
104
|
+
| auth.group.collection | /api/component/auth/group/ | |
|
|
105
|
+
| auth.group.create | /auth/group/create | |
|
|
106
|
+
| auth.group.delete | /auth/group/{0}/delete | id |
|
|
107
|
+
| auth.group.edit | /auth/group/{0}/edit | id |
|
|
108
|
+
| auth.group.item | /api/component/auth/group/{0} | id |
|
|
109
|
+
| auth.login_cookies | /api/component/auth/login | |
|
|
110
|
+
| auth.logout_cookies | /api/component/auth/logout | |
|
|
111
|
+
| auth.profile | /api/component/auth/profile | |
|
|
112
|
+
| auth.register | /api/component/auth/register | |
|
|
113
|
+
| auth.user.collection | /api/component/auth/user/ | |
|
|
114
|
+
| auth.user.create | /auth/user/create | |
|
|
115
|
+
| auth.user.delete | /auth/user/{0}/delete | id |
|
|
116
|
+
| auth.user.edit | /auth/user/{0}/edit | id |
|
|
117
|
+
| auth.user.item | /api/component/auth/user/{0} | id |
|
|
118
|
+
| collector.resource.read | /collector/resource/{0}/read | id |
|
|
119
|
+
| collector.resource.users | /collector/resource/{0}/users | id |
|
|
120
|
+
| collector.settings | /api/component/collector/settings | |
|
|
121
|
+
| collector.settings.users | /collector/user | |
|
|
122
|
+
| collector.user | /collector/user/{0} | user_id |
|
|
123
|
+
| feature_attachment.collection | /api/resource/{0}/feature/{1}/attachment/ | id,fid |
|
|
124
|
+
| feature_attachment.download | /api/resource/{0}/feature/{1}/attachment/{2}/download | id,fid,aid |
|
|
125
|
+
| feature_attachment.image | /api/resource/{0}/feature/{1}/attachment/{2}/image | id,fid,aid |
|
|
126
|
+
| feature_attachment.item | /api/resource/{0}/feature/{1}/attachment/{2} | id,fid,aid |
|
|
127
|
+
| feature_layer.feature.browse | /resource/{0}/feature/ | id |
|
|
128
|
+
| feature_layer.feature.collection | /api/resource/{0}/feature/ | id |
|
|
129
|
+
| feature_layer.feature.count | /api/resource/{0}/feature_count | id |
|
|
130
|
+
| feature_layer.feature.item | /api/resource/{0}/feature/{1} | id,fid |
|
|
131
|
+
| feature_layer.feature.item_extent | /api/resource/{0}/feature/{1}/extent | id,fid |
|
|
132
|
+
| feature_layer.feature.show | /resource/{0}/feature/{1} | id,feature_id |
|
|
133
|
+
| feature_layer.feature.update | /resource/{0}/feature/{1}/update | id,feature_id |
|
|
134
|
+
| feature_layer.field | /resource/{0}/field/ | id |
|
|
135
|
+
| feature_layer.geojson | /api/resource/{0}/geojson | id |
|
|
136
|
+
| feature_layer.identify | /api/feature_layer/identify | |
|
|
137
|
+
| feature_layer.mvt | /api/component/feature_layer/mvt | |
|
|
138
|
+
| feature_layer.store | /api/resource/{0}/store/ | id |
|
|
139
|
+
| feature_layer.store.item | /resource/{0}/store/{1} | id,feature_id |
|
|
140
|
+
| file_upload.collection | /api/component/file_upload/ | |
|
|
141
|
+
| file_upload.item | /api/component/file_upload/{0} | id |
|
|
142
|
+
| file_upload.upload | /api/component/file_upload/upload | |
|
|
143
|
+
| formbuilder.formbuilder_form_ngfp | /api/resource/{0}/ngfp | id |
|
|
144
|
+
| layer.extent | /api/resource/{0}/extent | id |
|
|
145
|
+
| postgis.connection.inspect | /api/resource/{0}/inspect/ | id |
|
|
146
|
+
| postgis.connection.inspect.table | /api/resource/{0}/inspect/{1}/ | id,table_name |
|
|
147
|
+
| pyramid.company_logo | /api/component/pyramid/company_logo | |
|
|
148
|
+
| pyramid.control_panel | /control-panel | |
|
|
149
|
+
| pyramid.control_panel.sysinfo | /control-panel/sysinfo | |
|
|
150
|
+
| pyramid.cors | /api/component/pyramid/cors | |
|
|
151
|
+
| pyramid.custom_css | /api/component/pyramid/custom_css | |
|
|
152
|
+
| pyramid.estimate_storage | /api/component/pyramid/estimate_storage | |
|
|
153
|
+
| pyramid.healthcheck | /api/component/pyramid/healthcheck | |
|
|
154
|
+
| pyramid.home_path | /api/component/pyramid/home_path | |
|
|
155
|
+
| pyramid.kind_of_data | /api/component/pyramid/kind_of_data | |
|
|
156
|
+
| pyramid.locdata | /api/component/pyramid/locdata/{0}/{1} | component,locale |
|
|
157
|
+
| pyramid.logo | /api/component/pyramid/logo | |
|
|
158
|
+
| pyramid.pkg_version | /api/component/pyramid/pkg_version | |
|
|
159
|
+
| pyramid.route | /api/component/pyramid/route | |
|
|
160
|
+
| pyramid.settings | /api/component/pyramid/settings | |
|
|
161
|
+
| pyramid.statistics | /api/component/pyramid/statistics | |
|
|
162
|
+
| pyramid.storage | /api/component/pyramid/storage | |
|
|
163
|
+
| pyramid.system_name | /api/component/pyramid/system_name | |
|
|
164
|
+
| qgis.style_qml | /api/resource/{0}/qml | id |
|
|
165
|
+
| render.image | /api/component/render/image | |
|
|
166
|
+
| render.legend | /api/resource/{0}/legend | id |
|
|
167
|
+
| render.tile | /api/component/render/tile | |
|
|
168
|
+
| render.tile_cache.seed_status | /api/resource/{0}/tile_cache/seed_status | id |
|
|
169
|
+
| resource.collection | /api/resource/ | |
|
|
170
|
+
| resource.create | /resource/{0}/create | id |
|
|
171
|
+
| resource.delete | /resource/{0}/delete | id |
|
|
172
|
+
| resource.export | /api/resource/{0}/export | id |
|
|
173
|
+
| resource.file_download | /api/resource/{0}/file/{1} | id,name |
|
|
174
|
+
| resource.item | /api/resource/{0} | id |
|
|
175
|
+
| resource.json | /resource/{0}/json | id |
|
|
176
|
+
| resource.permission | /api/resource/{0}/permission | id |
|
|
177
|
+
| resource.permission.explain | /api/resource/{0}/permission/explain | id |
|
|
178
|
+
| resource.preview | /api/resource/{0}/preview.png | id |
|
|
179
|
+
| resource.quota | /api/resource/quota | |
|
|
180
|
+
| resource.resource_export | /api/component/resource/resource_export | |
|
|
181
|
+
| resource.schema | /resource/schema | |
|
|
182
|
+
| resource.search | /api/resource/search/ | |
|
|
183
|
+
| resource.show | /resource/{0} | id |
|
|
184
|
+
| resource.tree | /resource/{0}/tree | id |
|
|
185
|
+
| resource.update | /resource/{0}/update | id |
|
|
186
|
+
| resource.volume | /api/resource/{0}/volume | id |
|
|
187
|
+
| resource.widget | /resource/widget | |
|
|
188
|
+
| spatial_ref_sys.collection | /api/component/spatial_ref_sys/ | |
|
|
189
|
+
| spatial_ref_sys.convert | /api/component/spatial_ref_sys/convert | |
|
|
190
|
+
| spatial_ref_sys.geom_area | /api/component/spatial_ref_sys/{0}/geom_area | id |
|
|
191
|
+
| spatial_ref_sys.geom_length | /api/component/spatial_ref_sys/{0}/geom_length | id |
|
|
192
|
+
| spatial_ref_sys.geom_transform | /api/component/spatial_ref_sys/{0}/geom_transform | id |
|
|
193
|
+
| spatial_ref_sys.get | /api/component/spatial_ref_sys/{0} | id |
|
|
194
|
+
| srs.create | /srs/create | |
|
|
195
|
+
| srs.delete | /srs/{0}/delete | id |
|
|
196
|
+
| srs.edit | /srs/{0}/edit | id |
|
|
197
|
+
| tmsclient.connection.layers | /api/component/tmsclient/{0}/layers/ | id |
|
|
198
|
+
| tracker.export_to_gpx | /tracker/gpx | |
|
|
199
|
+
| tracker.get.stops | /tracker/stops | |
|
|
200
|
+
| tracker.get_amd_static_url | /tracker/amd/static/url/ | |
|
|
201
|
+
| tracker.get_device_types | /tracker/device_types | |
|
|
202
|
+
| tracker.get_full_tracks | /tracker/tracks/full | |
|
|
203
|
+
| tracker.get_last_activity_tracker | /tracker/activity/last | |
|
|
204
|
+
| tracker.get_short_tracks | /tracker/tracks/short | |
|
|
205
|
+
| tracker.get_tracker_last_points | /tracker/last/points | |
|
|
206
|
+
| tracker.get_tracker_lines | /tracker/lines | |
|
|
207
|
+
| tracker.get_tracker_points | /tracker/points | |
|
|
208
|
+
| tracker.get_trackers | /tracker/trackers/tree | |
|
|
209
|
+
| tracker.receive_packet | /tracker/{0}/receive | unique_id |
|
|
210
|
+
| tracker.reports | /tracker/reports/ | |
|
|
211
|
+
| tracker.reports.build | /tracker/report/build/ | |
|
|
212
|
+
| tracker.settings | /api/component/tracker/settings | |
|
|
213
|
+
| vector_layer.dataset | /api/component/vector_layer/dataset | |
|
|
214
|
+
| webmap.annotation.collection | /api/resource/{0}/annotation/ | id |
|
|
215
|
+
| webmap.annotation.item | /api/resource/{0}/annotation/{1} | id,annotation_id |
|
|
216
|
+
| webmap.display | /resource/{0}/display | id |
|
|
217
|
+
| webmap.display.tiny | /resource/{0}/display/tiny | id |
|
|
218
|
+
| webmap.settings | /api/component/webmap/settings | |
|
|
219
|
+
| wfsserver.wfs | /api/resource/{0}/wfs | id |
|
|
220
|
+
| wmsserver.wms | /api/resource/{0}/wms | id |
|
|
221
|
+
|
|
222
|
+
</details>
|
|
218
223
|
|
|
219
224
|
## Commercial support
|
|
220
225
|
|
package/lib/index.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export declare interface FeatureLayerCount {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export declare interface FeatureLayerField {
|
|
89
|
-
datatype:
|
|
89
|
+
datatype: VectorFieldDatatype;
|
|
90
90
|
display_name: string;
|
|
91
91
|
grid_visibility: boolean;
|
|
92
92
|
id: number;
|
|
@@ -299,7 +299,7 @@ declare class NgwConnector {
|
|
|
299
299
|
* @param params - Query params
|
|
300
300
|
* @param options - Request options
|
|
301
301
|
*/
|
|
302
|
-
makeQuery(url: string, params?: Params, options?: RequestOptions): CancelablePromise<
|
|
302
|
+
makeQuery<R = unknown>(url: string, params?: Params | null, options?: RequestOptions): CancelablePromise<R>;
|
|
303
303
|
/**
|
|
304
304
|
* {@inheritDoc ResourcesControl.getOne}
|
|
305
305
|
*/
|
|
@@ -440,7 +440,7 @@ export declare interface PutRequestItemsResponseMap extends RequestItemKeys {
|
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
export declare interface PyramidRoute {
|
|
443
|
-
[requestItemName: string]: string[];
|
|
443
|
+
[requestItemName: string]: [url: string, ...params: string[]];
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
export declare type PyramidSettings = PyramidSettingsPyramid | Record<string, any>;
|
|
@@ -684,6 +684,10 @@ export declare interface RequestOptions<M = RequestMethods> {
|
|
|
684
684
|
onProgress?: (percentComplete: number, event: ProgressEvent) => void;
|
|
685
685
|
}
|
|
686
686
|
|
|
687
|
+
export declare interface Resmeta {
|
|
688
|
+
items: Record<string, any>;
|
|
689
|
+
}
|
|
690
|
+
|
|
687
691
|
export declare interface Resource {
|
|
688
692
|
cls: ResourceCls;
|
|
689
693
|
id: number;
|
|
@@ -724,15 +728,17 @@ export declare interface ResourceItem extends ResourceItemMain {
|
|
|
724
728
|
basemap_webmap?: BasemapWebmap;
|
|
725
729
|
lookup_table?: LookupTableResource;
|
|
726
730
|
file_bucket?: FileBucket;
|
|
731
|
+
wmsserver_service?: WmsServerService;
|
|
732
|
+
wmsclient_layer?: WmsClientLayer;
|
|
733
|
+
wmsclient_connection?: WmsClientConnection;
|
|
727
734
|
}
|
|
728
735
|
|
|
729
|
-
|
|
736
|
+
/** @deprecated - use {@link VectorFieldDatatype} instead */
|
|
737
|
+
export declare type ResourceItemDatatype = VectorFieldDatatype;
|
|
730
738
|
|
|
731
739
|
export declare interface ResourceItemMain {
|
|
732
740
|
resource: Resource;
|
|
733
|
-
resmeta:
|
|
734
|
-
items: Record<string, any>;
|
|
735
|
-
};
|
|
741
|
+
resmeta: Resmeta;
|
|
736
742
|
}
|
|
737
743
|
|
|
738
744
|
/**
|
|
@@ -851,6 +857,8 @@ export declare interface UserInfo {
|
|
|
851
857
|
clientId?: string;
|
|
852
858
|
}
|
|
853
859
|
|
|
860
|
+
export declare type VectorFieldDatatype = 'STRING' | 'REAL' | 'DATE' | 'TIME' | 'DATETIME' | 'BIGINT' | 'INTEGER' | 'BOOLEAN';
|
|
861
|
+
|
|
854
862
|
export declare interface VectorLayer {
|
|
855
863
|
srs: {
|
|
856
864
|
id: number;
|
|
@@ -868,9 +876,73 @@ export declare interface WebmapResource {
|
|
|
868
876
|
extent_right: number;
|
|
869
877
|
extent_bottom: number;
|
|
870
878
|
extent_top: number;
|
|
879
|
+
extent_constrained: boolean;
|
|
871
880
|
draw_order_enabled: boolean;
|
|
872
881
|
bookmark_resource: ResourceHierarchy;
|
|
873
882
|
root_item: TreeGroup;
|
|
874
883
|
}
|
|
875
884
|
|
|
885
|
+
export declare interface WmsClientConnection {
|
|
886
|
+
/** WMS service url */
|
|
887
|
+
url: string;
|
|
888
|
+
/** User name to connect to service */
|
|
889
|
+
username?: string;
|
|
890
|
+
/** Password to connect to service */
|
|
891
|
+
password?: string;
|
|
892
|
+
/** WMS version */
|
|
893
|
+
version?: string;
|
|
894
|
+
/** If equal query - query capabilities from service */
|
|
895
|
+
capcache?: string;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
export declare interface WmsClientLayer {
|
|
899
|
+
/** WMS connection. */
|
|
900
|
+
connection: {
|
|
901
|
+
id: number;
|
|
902
|
+
};
|
|
903
|
+
srs: {
|
|
904
|
+
id: number;
|
|
905
|
+
};
|
|
906
|
+
/**
|
|
907
|
+
* Image format. Available values can fetched from WMS connection ('image/png').
|
|
908
|
+
*/
|
|
909
|
+
imgformat: string;
|
|
910
|
+
/**
|
|
911
|
+
* String with layer identifiers separated with comma. Available layers can fetched from WMS connection.
|
|
912
|
+
*/
|
|
913
|
+
wmslayers: string;
|
|
914
|
+
/** Additional parameters added to each request. This is key and value list. */
|
|
915
|
+
vendor_params: Record<string, string>;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
export declare interface WmsServerService {
|
|
919
|
+
/**
|
|
920
|
+
* Array or WMS service layers. keyname, display_name and resource_id are mandatory.
|
|
921
|
+
*/
|
|
922
|
+
layers: WmsServerServiceLayer[];
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
export declare interface WmsServerServiceLayer {
|
|
926
|
+
/**
|
|
927
|
+
* Key name for WMS service item. Name may be only ASCII symbols without spaces.
|
|
928
|
+
* */
|
|
929
|
+
keyname: string;
|
|
930
|
+
/**
|
|
931
|
+
* Service item name.
|
|
932
|
+
* */
|
|
933
|
+
display_name: string;
|
|
934
|
+
/**
|
|
935
|
+
* Resource identifier which will be WMS layer datasource. Supported types are: vector layer style, raster style, WMS layer.
|
|
936
|
+
* */
|
|
937
|
+
resource_id: number;
|
|
938
|
+
/**
|
|
939
|
+
* Minimum scale to show WMS layer. String in form of `1 : 100000`.
|
|
940
|
+
*/
|
|
941
|
+
min_scale_denom?: string | null;
|
|
942
|
+
/**
|
|
943
|
+
* Maximum scale to show WMS layer. String in form of `1 : 100000`.
|
|
944
|
+
*/
|
|
945
|
+
max_scale_denom?: string | null;
|
|
946
|
+
}
|
|
947
|
+
|
|
876
948
|
export { }
|
package/lib/ngw-connector.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-connector; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/ngw-connector; version: 1.11.8; author: NextGIS */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var events = require('events');
|
|
@@ -23,12 +23,17 @@ class NgwError extends Error {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
function isObject(val) {
|
|
27
|
+
return Object.prototype.toString.call(val) === '[object Object]';
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
let loadData;
|
|
27
31
|
// @ts-ignore
|
|
28
32
|
{
|
|
29
33
|
const url = require('url');
|
|
30
34
|
const http = require('http');
|
|
31
35
|
const https = require('https');
|
|
36
|
+
const FormData = require('form-data');
|
|
32
37
|
const adapterFor = (inputUrl) => {
|
|
33
38
|
const adapters = {
|
|
34
39
|
'http:': http,
|
|
@@ -38,21 +43,46 @@ let loadData;
|
|
|
38
43
|
return adapters[protocol];
|
|
39
44
|
};
|
|
40
45
|
loadData = (url, callback, options = {}, error, onCancel) => {
|
|
46
|
+
const { file, headers, method, data, responseType } = options;
|
|
41
47
|
const request = new Promise((resolve, reject) => {
|
|
42
48
|
const adapter = adapterFor(url);
|
|
43
49
|
if (adapter) {
|
|
44
50
|
const requestOpt = {
|
|
45
|
-
headers:
|
|
46
|
-
method
|
|
51
|
+
headers: headers || {},
|
|
52
|
+
method,
|
|
47
53
|
};
|
|
48
|
-
const body = typeof
|
|
49
|
-
? options.data
|
|
50
|
-
: JSON.stringify(options.data);
|
|
54
|
+
const body = typeof data === 'string' ? data : JSON.stringify(data);
|
|
51
55
|
// https://stackoverflow.com/questions/35589109/node-http-delete-request-no-longer-works-after-upgrading-from-0-10-40
|
|
52
|
-
|
|
56
|
+
let form;
|
|
57
|
+
let uploadedFile = file;
|
|
58
|
+
if (file) {
|
|
59
|
+
const fileMeta = {};
|
|
60
|
+
if (isObject(file) &&
|
|
61
|
+
'file' in file &&
|
|
62
|
+
('filename' in file || 'name' in file)) {
|
|
63
|
+
const { file: file_, name, ...fileMeta_ } = file;
|
|
64
|
+
if (name && !fileMeta_.filename) {
|
|
65
|
+
fileMeta_.filename = name;
|
|
66
|
+
}
|
|
67
|
+
Object.assign(fileMeta, fileMeta_);
|
|
68
|
+
uploadedFile = file_;
|
|
69
|
+
}
|
|
70
|
+
form = new FormData();
|
|
71
|
+
form.append('file', uploadedFile, fileMeta);
|
|
72
|
+
if (data) {
|
|
73
|
+
for (const d in data) {
|
|
74
|
+
form.append(d, data[d]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
Object.assign(requestOpt.headers, {
|
|
78
|
+
// 'content-length': form.getLengthSync(),
|
|
79
|
+
...form.getHeaders(),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (body !== undefined && method !== 'POST') {
|
|
53
83
|
Object.assign(requestOpt.headers, {
|
|
54
|
-
'
|
|
55
|
-
'
|
|
84
|
+
'content-type': 'application/json',
|
|
85
|
+
'content-length': Buffer.byteLength(body),
|
|
56
86
|
});
|
|
57
87
|
}
|
|
58
88
|
const req = adapter.request(url, requestOpt, (resp) => {
|
|
@@ -62,24 +92,32 @@ let loadData;
|
|
|
62
92
|
});
|
|
63
93
|
resp.on('end', () => {
|
|
64
94
|
if (data) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
json = JSON.parse(data);
|
|
68
|
-
if (json && json.status_code && json.status_code) {
|
|
69
|
-
reject(json.message);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (er) {
|
|
73
|
-
reject(er);
|
|
74
|
-
// throw new Error(er);
|
|
95
|
+
if (responseType === 'blob') {
|
|
96
|
+
resolve(data);
|
|
75
97
|
}
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
else {
|
|
99
|
+
let json;
|
|
100
|
+
try {
|
|
101
|
+
json = JSON.parse(data);
|
|
102
|
+
if (json && json.status_code && json.status_code) {
|
|
103
|
+
reject(json.message);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (er) {
|
|
107
|
+
reject(er);
|
|
108
|
+
// throw new Error(er);
|
|
109
|
+
}
|
|
110
|
+
if (json !== undefined) {
|
|
111
|
+
resolve(json);
|
|
112
|
+
}
|
|
78
113
|
}
|
|
79
114
|
}
|
|
80
115
|
reject('no data');
|
|
81
116
|
});
|
|
82
117
|
});
|
|
118
|
+
if (form) {
|
|
119
|
+
form.pipe(req);
|
|
120
|
+
}
|
|
83
121
|
req.on('error', (err) => {
|
|
84
122
|
reject(err);
|
|
85
123
|
});
|
|
@@ -178,10 +216,6 @@ function removeConnector(connector) {
|
|
|
178
216
|
}
|
|
179
217
|
}
|
|
180
218
|
|
|
181
|
-
function isObject(val) {
|
|
182
|
-
return Object.prototype.toString.call(val) === '[object Object]';
|
|
183
|
-
}
|
|
184
|
-
|
|
185
219
|
const exclude = ['description'];
|
|
186
220
|
/**
|
|
187
221
|
* @remarks
|
|
@@ -406,7 +440,7 @@ class ResourcesControl {
|
|
|
406
440
|
}
|
|
407
441
|
}
|
|
408
442
|
_fetchResourceById(id, requestOptions) {
|
|
409
|
-
const promise = () => this.connector.get('resource.item', requestOptions, { id })
|
|
443
|
+
const promise = () => this.connector.get('resource.item', requestOptions, { id });
|
|
410
444
|
return this.cache
|
|
411
445
|
.add('resource.item', promise, {
|
|
412
446
|
id,
|
|
@@ -608,7 +642,7 @@ class NgwConnector$1 {
|
|
|
608
642
|
headers: this.getAuthorizationHeaders(credentials),
|
|
609
643
|
// withCredentials: true
|
|
610
644
|
};
|
|
611
|
-
// Do not use
|
|
645
|
+
// Do not use apiRequest('auth.current_user') to avoid circular-references
|
|
612
646
|
return this.makeQuery('/api/component/auth/current_user', {}, options)
|
|
613
647
|
.then((data) => {
|
|
614
648
|
this.user = data;
|