@here/olp-sdk-dataservice-read 1.13.0 → 2.0.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/README.md +1 -1
- package/bundle.umd.dev.js +301 -0
- package/bundle.umd.min.js +1 -0
- package/lib/cache/MetadataCacheRepository.js +129 -0
- package/lib/cache/QuadTreeIndexCacheRepository.js +59 -0
- package/lib/cache/index.js +32 -0
- package/lib/client/ArtifactClient.js +96 -0
- package/lib/client/CatalogClient.js +206 -0
- package/lib/client/CatalogRequest.js +47 -0
- package/lib/client/CatalogVersionRequest.js +85 -0
- package/lib/client/CatalogsRequest.js +67 -0
- package/lib/client/ConfigClient.js +72 -0
- package/lib/client/DataRequest.js +115 -0
- package/lib/client/IndexLayerClient.js +111 -0
- package/lib/client/IndexQueryRequest.js +63 -0
- package/lib/client/LayerVersionsRequest.js +64 -0
- package/lib/client/PartitionsRequest.js +124 -0
- package/lib/client/PollRequest.js +63 -0
- package/lib/client/QuadKeyPartitionsRequest.js +110 -0
- package/lib/client/QuadTreeIndexRequest.js +168 -0
- package/lib/client/QueryClient.js +169 -0
- package/lib/client/SchemaDetailsRequest.js +68 -0
- package/lib/client/SchemaRequest.js +67 -0
- package/lib/client/SeekRequest.js +70 -0
- package/lib/client/StatisticsClient.js +127 -0
- package/lib/client/StatisticsRequest.js +134 -0
- package/lib/client/StreamLayerClient.js +252 -0
- package/lib/client/SubscribeRequest.js +101 -0
- package/lib/client/SummaryRequest.js +66 -0
- package/lib/client/TileRequest.js +118 -0
- package/lib/client/UnsubscribeRequest.js +63 -0
- package/lib/client/VersionedLayerClient.js +230 -0
- package/lib/client/VolatileLayerClient.js +194 -0
- package/lib/client/index.js +57 -0
- package/lib/index.js +33 -0
- package/lib/utils/getTile.js +166 -0
- package/lib/utils/index.js +33 -0
- package/lib/utils/validateBillingTag.js +37 -0
- package/lib/utils/validatePartitionsIdsList.js +38 -0
- package/package.json +9 -9
- package/webpack.config.js +26 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2020 HERE Europe B.V.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
* License-Filename: LICENSE
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.UnsubscribeRequest = void 0;
|
|
22
|
+
/**
|
|
23
|
+
* Prepares information for calls to the platform Stream Service.
|
|
24
|
+
*/
|
|
25
|
+
class UnsubscribeRequest {
|
|
26
|
+
/**
|
|
27
|
+
* Gets the subscription mode for the request.
|
|
28
|
+
*
|
|
29
|
+
* @return The subscription mode.
|
|
30
|
+
*/
|
|
31
|
+
getMode() {
|
|
32
|
+
return this.mode;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A setter for the provided subscription mode.
|
|
36
|
+
*
|
|
37
|
+
* @param mode The subscription mode.
|
|
38
|
+
* @returns The [[UnsubscribeRequest]] instance that you can use to chain methods.
|
|
39
|
+
*/
|
|
40
|
+
withMode(mode) {
|
|
41
|
+
this.mode = mode;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets the subscription id for the request.
|
|
46
|
+
*
|
|
47
|
+
* @return The subscription id.
|
|
48
|
+
*/
|
|
49
|
+
getSubscriptionId() {
|
|
50
|
+
return this.subscriptionId;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A setter for the provided subscription id.
|
|
54
|
+
*
|
|
55
|
+
* @param id The subscription id.
|
|
56
|
+
* @returns The [[UnsubscribeRequest]] instance that you can use to chain methods.
|
|
57
|
+
*/
|
|
58
|
+
withSubscriptionId(id) {
|
|
59
|
+
this.subscriptionId = id;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.UnsubscribeRequest = UnsubscribeRequest;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2019-2021 HERE Europe B.V.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
* License-Filename: LICENSE
|
|
19
|
+
*/
|
|
20
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
21
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.VersionedLayerClient = void 0;
|
|
31
|
+
const olp_sdk_core_1 = require("@here/olp-sdk-core");
|
|
32
|
+
const olp_sdk_dataservice_api_1 = require("@here/olp-sdk-dataservice-api");
|
|
33
|
+
const olp_sdk_dataservice_read_1 = require("@here/olp-sdk-dataservice-read");
|
|
34
|
+
/**
|
|
35
|
+
* Describes a versioned layer and provides the possibility to get partitions metadata and data.
|
|
36
|
+
*/
|
|
37
|
+
class VersionedLayerClient {
|
|
38
|
+
/**
|
|
39
|
+
* Creates the [[VersionedLayerClient]] instance with VersionedLayerClientParams.
|
|
40
|
+
*
|
|
41
|
+
* @param params parameters for use to initialize VersionLayerClient.
|
|
42
|
+
*/
|
|
43
|
+
constructor(params) {
|
|
44
|
+
this.apiVersion = "v1";
|
|
45
|
+
this.hrn = params.catalogHrn.toString();
|
|
46
|
+
this.layerId = params.layerId;
|
|
47
|
+
this.settings = params.settings;
|
|
48
|
+
if (params.version !== undefined && params.version >= 0) {
|
|
49
|
+
this.version = params.version;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @brief Fetches data of a tile or its closest ancestor.
|
|
54
|
+
* Use this API for tile-tree structures where children tile data is aggregated and stored in parent tiles.
|
|
55
|
+
*
|
|
56
|
+
* @param request The `TileRequest` instance that contains a complete set
|
|
57
|
+
* of request parameters.
|
|
58
|
+
* @param abortSignal A signal object that allows you to communicate with a request (such as the `fetch` request)
|
|
59
|
+
* and, if required, abort it using the `AbortController` object.
|
|
60
|
+
*
|
|
61
|
+
* For more information, see the [`AbortController` documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
62
|
+
*
|
|
63
|
+
* @return Tile data (if it exists) or the nearest parent tile data
|
|
64
|
+
*/
|
|
65
|
+
getAggregatedData(request, abortSignal) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
let catalogVersion = this.version;
|
|
68
|
+
if (catalogVersion === undefined) {
|
|
69
|
+
catalogVersion = yield this.getLatestVersion(request.getBillingTag());
|
|
70
|
+
}
|
|
71
|
+
const params = {
|
|
72
|
+
catalogHrn: olp_sdk_core_1.HRN.fromString(this.hrn),
|
|
73
|
+
layerId: this.layerId,
|
|
74
|
+
layerType: "versioned",
|
|
75
|
+
settings: this.settings,
|
|
76
|
+
catalogVersion
|
|
77
|
+
};
|
|
78
|
+
return olp_sdk_dataservice_read_1.getTile(request, params, abortSignal);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Fetches partition data using one of the following methods: ID, quadkey, or data handle.
|
|
83
|
+
*
|
|
84
|
+
* @param dataRequest The [[DataRequest]] instance of the configured request parameters.
|
|
85
|
+
* @param abortSignal A signal object that allows you to communicate with a request (such as the `fetch` request)
|
|
86
|
+
* and, if required, abort it using the `AbortController` object.
|
|
87
|
+
*
|
|
88
|
+
* For more information, see the [`AbortController` documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
89
|
+
*
|
|
90
|
+
* @return The data from the requested partition.
|
|
91
|
+
*/
|
|
92
|
+
getData(dataRequest, abortSignal) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const dataHandle = dataRequest.getDataHandle();
|
|
95
|
+
if (dataHandle) {
|
|
96
|
+
return this.downloadPartition(dataHandle, abortSignal, dataRequest.getBillingTag());
|
|
97
|
+
}
|
|
98
|
+
const partitionId = dataRequest.getPartitionId();
|
|
99
|
+
if (this.version === undefined) {
|
|
100
|
+
// fetch the latest version and lock it to the instance.
|
|
101
|
+
this.version = yield this.getLatestVersion(dataRequest.getBillingTag()).catch(error => Promise.reject(error));
|
|
102
|
+
}
|
|
103
|
+
if (this.version === undefined) {
|
|
104
|
+
return Promise.reject(new Error(`Unable to retrieve latest version. Please provide version to the DataRequest or lock version in the constructor`));
|
|
105
|
+
}
|
|
106
|
+
if (partitionId) {
|
|
107
|
+
const partitionIdDataHandle = yield this.getDataHandleByPartitionId(partitionId, dataRequest.getFetchOption(), dataRequest.getBillingTag()).catch(error => Promise.reject(error));
|
|
108
|
+
return this.downloadPartition(partitionIdDataHandle, abortSignal, dataRequest.getBillingTag());
|
|
109
|
+
}
|
|
110
|
+
return Promise.reject(new Error(`No data provided. Add dataHandle, partitionId or quadKey to the DataRequest object`));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
getPartitions(request, abortSignal) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
if (this.version === undefined) {
|
|
116
|
+
// fetch the latest version and lock it to the instance.
|
|
117
|
+
this.version = yield this.getLatestVersion(request.getBillingTag()).catch(error => Promise.reject(error));
|
|
118
|
+
}
|
|
119
|
+
if (this.version === undefined) {
|
|
120
|
+
return Promise.reject(new Error(`Unable to retrieve latest version. Please provide version to the Request or lock version in the constructor`));
|
|
121
|
+
}
|
|
122
|
+
if (request instanceof olp_sdk_dataservice_read_1.QuadKeyPartitionsRequest) {
|
|
123
|
+
const quadKey = request.getQuadKey();
|
|
124
|
+
if (!quadKey) {
|
|
125
|
+
return Promise.reject(new Error("Please provide correct QuadKey"));
|
|
126
|
+
}
|
|
127
|
+
const queryClient = new olp_sdk_dataservice_read_1.QueryClient(this.settings);
|
|
128
|
+
const quadTreeIndexRequest = new olp_sdk_dataservice_read_1.QuadTreeIndexRequest(olp_sdk_core_1.HRN.fromString(this.hrn), this.layerId, "versioned")
|
|
129
|
+
.withQuadKey(quadKey)
|
|
130
|
+
.withVersion(this.version)
|
|
131
|
+
.withDepth(request.getDepth())
|
|
132
|
+
.withAdditionalFields(request.getAdditionalFields());
|
|
133
|
+
return queryClient.fetchQuadTreeIndex(quadTreeIndexRequest, abortSignal);
|
|
134
|
+
}
|
|
135
|
+
if (request.getPartitionIds()) {
|
|
136
|
+
const queryClient = new olp_sdk_dataservice_read_1.QueryClient(this.settings);
|
|
137
|
+
return queryClient.getPartitionsById(request, this.layerId, olp_sdk_core_1.HRN.fromString(this.hrn), abortSignal, this.version);
|
|
138
|
+
}
|
|
139
|
+
const cache = new olp_sdk_dataservice_read_1.MetadataCacheRepository(this.settings.cache);
|
|
140
|
+
if (request.getFetchOption() !== olp_sdk_core_1.FetchOptions.OnlineOnly) {
|
|
141
|
+
const partitions = cache.get(request, this.hrn.toString(), this.layerId, this.version);
|
|
142
|
+
if (partitions) {
|
|
143
|
+
const additionalFields = request.getAdditionalFields();
|
|
144
|
+
let existFields;
|
|
145
|
+
if (additionalFields) {
|
|
146
|
+
existFields = additionalFields.filter((field) => {
|
|
147
|
+
return partitions.every(partition => partition[field] !== undefined);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (!additionalFields ||
|
|
151
|
+
!existFields ||
|
|
152
|
+
additionalFields.length === existFields.length) {
|
|
153
|
+
return Promise.resolve({ partitions });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const metaRequestBilder = yield this.getRequestBuilder("metadata", olp_sdk_core_1.HRN.fromString(this.hrn), abortSignal).catch(error => Promise.reject(error));
|
|
158
|
+
const metadata = yield olp_sdk_dataservice_api_1.MetadataApi.getPartitions(metaRequestBilder, {
|
|
159
|
+
version: this.version,
|
|
160
|
+
layerId: this.layerId,
|
|
161
|
+
additionalFields: request.getAdditionalFields(),
|
|
162
|
+
billingTag: request.getBillingTag()
|
|
163
|
+
}).catch(error => Promise.reject(error));
|
|
164
|
+
if (request.getFetchOption() !== olp_sdk_core_1.FetchOptions.OnlineOnly &&
|
|
165
|
+
metadata.partitions.length) {
|
|
166
|
+
cache.put(request, this.hrn.toString(), this.layerId, metadata.partitions, this.version);
|
|
167
|
+
}
|
|
168
|
+
return Promise.resolve(metadata);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Fetch and returns partition metadata
|
|
173
|
+
* @param partitionId The name of the partition to fetch.
|
|
174
|
+
* @param version The version of the layer to fetch
|
|
175
|
+
* @param fetchOption The option of caching (online only or return from cache if exist)
|
|
176
|
+
* @returns A promise of partition metadata which used to get partition data
|
|
177
|
+
*/
|
|
178
|
+
getDataHandleByPartitionId(partitionId, fetchOption, billingTag) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const queryClient = new olp_sdk_dataservice_read_1.QueryClient(this.settings);
|
|
181
|
+
const partitionsRequest = new olp_sdk_dataservice_read_1.PartitionsRequest()
|
|
182
|
+
.withPartitionIds([partitionId])
|
|
183
|
+
.withFetchOption(fetchOption);
|
|
184
|
+
if (billingTag) {
|
|
185
|
+
partitionsRequest.withBillingTag(billingTag);
|
|
186
|
+
}
|
|
187
|
+
const metadata = yield queryClient.getPartitionsById(partitionsRequest, this.layerId, olp_sdk_core_1.HRN.fromString(this.hrn), undefined, this.version);
|
|
188
|
+
return metadata.partitions &&
|
|
189
|
+
metadata.partitions[0] &&
|
|
190
|
+
metadata.partitions[0].dataHandle
|
|
191
|
+
? metadata.partitions[0].dataHandle
|
|
192
|
+
: Promise.reject(new olp_sdk_core_1.HttpError(olp_sdk_core_1.STATUS_CODES.NOT_FOUND, `No partition dataHandle for partition ${partitionId}. HRN: ${this.hrn}`));
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Gets the latest available catalog version what can be used as latest layer version
|
|
197
|
+
*/
|
|
198
|
+
getLatestVersion(billingTag) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
const builder = yield this.getRequestBuilder("metadata", olp_sdk_core_1.HRN.fromString(this.hrn)).catch(error => Promise.reject(error));
|
|
201
|
+
const latestVersion = yield olp_sdk_dataservice_api_1.MetadataApi.latestVersion(builder, {
|
|
202
|
+
startVersion: -1,
|
|
203
|
+
billingTag
|
|
204
|
+
}).catch(error => Promise.reject(error));
|
|
205
|
+
return Promise.resolve(latestVersion.version);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
downloadPartition(dataHandle, abortSignal, billingTag) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
const builder = yield this.getRequestBuilder("blob", olp_sdk_core_1.HRN.fromString(this.hrn), abortSignal).catch(error => Promise.reject(error));
|
|
211
|
+
return olp_sdk_dataservice_api_1.BlobApi.getBlob(builder, {
|
|
212
|
+
dataHandle,
|
|
213
|
+
layerId: this.layerId,
|
|
214
|
+
billingTag
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Fetch baseUrl and create requestBuilder for sending requests to the API Lookup Service.
|
|
220
|
+
* @param builderType endpoint name is needed to create propriate requestBuilder
|
|
221
|
+
*
|
|
222
|
+
* @returns requestBuilder
|
|
223
|
+
*/
|
|
224
|
+
getRequestBuilder(builderType, hrn, abortSignal) {
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
return olp_sdk_core_1.RequestFactory.create(builderType, this.apiVersion, this.settings, hrn, abortSignal);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.VersionedLayerClient = VersionedLayerClient;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2019-2021 HERE Europe B.V.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
* License-Filename: LICENSE
|
|
19
|
+
*/
|
|
20
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
21
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.VolatileLayerClient = void 0;
|
|
31
|
+
const olp_sdk_core_1 = require("@here/olp-sdk-core");
|
|
32
|
+
const olp_sdk_dataservice_api_1 = require("@here/olp-sdk-dataservice-api");
|
|
33
|
+
const olp_sdk_dataservice_read_1 = require("@here/olp-sdk-dataservice-read");
|
|
34
|
+
/**
|
|
35
|
+
* Describes a voaltile layer and provides the possibility to get partitions metadata and data.
|
|
36
|
+
*/
|
|
37
|
+
class VolatileLayerClient {
|
|
38
|
+
/**
|
|
39
|
+
* Creates the [[VolatileLayerClient]] instance with VolatileLayerClientParams.
|
|
40
|
+
*
|
|
41
|
+
* @param params parameters for use to initialize VolatileLayerClient.
|
|
42
|
+
*/
|
|
43
|
+
constructor(params) {
|
|
44
|
+
this.apiVersion = "v1";
|
|
45
|
+
this.hrn = params.catalogHrn.toString();
|
|
46
|
+
this.layerId = params.layerId;
|
|
47
|
+
this.settings = params.settings;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @brief Fetches data of a tile or its closest ancestor.
|
|
51
|
+
* Use this API for tile-tree structures where children tile data is aggregated and stored in parent tiles.
|
|
52
|
+
*
|
|
53
|
+
* @param request The `TileRequest` instance that contains a complete set
|
|
54
|
+
* of request parameters.
|
|
55
|
+
* @param abortSignal A signal object that allows you to communicate with a request (such as the `fetch` request)
|
|
56
|
+
* and, if required, abort it using the `AbortController` object.
|
|
57
|
+
*
|
|
58
|
+
* For more information, see the [`AbortController` documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
59
|
+
*
|
|
60
|
+
* @return Tile data (if it exists) or the nearest parent tile data
|
|
61
|
+
*/
|
|
62
|
+
getAggregatedData(request, abortSignal) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const params = {
|
|
65
|
+
catalogHrn: olp_sdk_core_1.HRN.fromString(this.hrn),
|
|
66
|
+
layerId: this.layerId,
|
|
67
|
+
layerType: "volatile",
|
|
68
|
+
settings: this.settings
|
|
69
|
+
};
|
|
70
|
+
return olp_sdk_dataservice_read_1.getTile(request, params, abortSignal);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Fetches partition data using one of the following methods: ID, quadkey, or data handle.
|
|
75
|
+
*
|
|
76
|
+
* @param dataRequest The [[DataRequest]] instance of the configured request parameters.
|
|
77
|
+
* @param abortSignal A signal object that allows you to communicate with a request (such as the `fetch` request)
|
|
78
|
+
* and, if required, abort it using the `AbortController` object.
|
|
79
|
+
*
|
|
80
|
+
* For more information, see the [`AbortController` documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
81
|
+
*
|
|
82
|
+
* @return The data from the requested partition.
|
|
83
|
+
*/
|
|
84
|
+
getData(dataRequest, abortSignal) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const dataHandle = dataRequest.getDataHandle();
|
|
87
|
+
const partitionId = dataRequest.getPartitionId();
|
|
88
|
+
if (dataHandle !== undefined || partitionId !== undefined) {
|
|
89
|
+
if (dataHandle) {
|
|
90
|
+
return this.downloadPartition(dataHandle, abortSignal, dataRequest.getBillingTag());
|
|
91
|
+
}
|
|
92
|
+
if (partitionId) {
|
|
93
|
+
const partitionIdDataHandle = yield this.getDataHandleByPartitionId(partitionId, dataRequest.getFetchOption(), dataRequest.getBillingTag()).catch(error => Promise.reject(error));
|
|
94
|
+
return this.downloadPartition(partitionIdDataHandle, abortSignal, dataRequest.getBillingTag());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return Promise.reject(new Error(`No data provided. Add dataHandle, partitionId or quadKey to the DataRequest object`));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
getPartitions(request, abortSignal) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
if (request instanceof olp_sdk_dataservice_read_1.QuadKeyPartitionsRequest) {
|
|
103
|
+
const quadKey = request.getQuadKey();
|
|
104
|
+
if (!quadKey) {
|
|
105
|
+
return Promise.reject(new Error("Please provide correct QuadKey"));
|
|
106
|
+
}
|
|
107
|
+
const queryClient = new olp_sdk_dataservice_read_1.QueryClient(this.settings);
|
|
108
|
+
const quadTreeIndexRequest = new olp_sdk_dataservice_read_1.QuadTreeIndexRequest(olp_sdk_core_1.HRN.fromString(this.hrn), this.layerId, "volatile")
|
|
109
|
+
.withQuadKey(quadKey)
|
|
110
|
+
.withDepth(request.getDepth())
|
|
111
|
+
.withAdditionalFields(request.getAdditionalFields());
|
|
112
|
+
return queryClient.fetchQuadTreeIndex(quadTreeIndexRequest, abortSignal);
|
|
113
|
+
}
|
|
114
|
+
if (request.getPartitionIds()) {
|
|
115
|
+
const queryClient = new olp_sdk_dataservice_read_1.QueryClient(this.settings);
|
|
116
|
+
return queryClient.getPartitionsById(request, this.layerId, olp_sdk_core_1.HRN.fromString(this.hrn), abortSignal);
|
|
117
|
+
}
|
|
118
|
+
const cache = new olp_sdk_dataservice_read_1.MetadataCacheRepository(this.settings.cache);
|
|
119
|
+
if (request.getFetchOption() !== olp_sdk_core_1.FetchOptions.OnlineOnly) {
|
|
120
|
+
const partitions = cache.get(request, this.hrn.toString(), this.layerId);
|
|
121
|
+
if (partitions) {
|
|
122
|
+
const additionalFields = request.getAdditionalFields();
|
|
123
|
+
let existFields;
|
|
124
|
+
if (additionalFields) {
|
|
125
|
+
existFields = additionalFields.filter((field) => {
|
|
126
|
+
return partitions.every(partition => partition[field] !== undefined);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (!additionalFields ||
|
|
130
|
+
!existFields ||
|
|
131
|
+
additionalFields.length === existFields.length) {
|
|
132
|
+
return Promise.resolve({ partitions });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const metaRequestBilder = yield this.getRequestBuilder("metadata", olp_sdk_core_1.HRN.fromString(this.hrn)).catch(error => Promise.reject(error));
|
|
137
|
+
const metadata = yield olp_sdk_dataservice_api_1.MetadataApi.getPartitions(metaRequestBilder, {
|
|
138
|
+
layerId: this.layerId,
|
|
139
|
+
additionalFields: request.getAdditionalFields(),
|
|
140
|
+
billingTag: request.getBillingTag()
|
|
141
|
+
}).catch(error => Promise.reject(error));
|
|
142
|
+
if (request.getFetchOption() !== olp_sdk_core_1.FetchOptions.OnlineOnly &&
|
|
143
|
+
metadata.partitions.length) {
|
|
144
|
+
cache.put(request, this.hrn.toString(), this.layerId, metadata.partitions);
|
|
145
|
+
}
|
|
146
|
+
return Promise.resolve(metadata);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
downloadPartition(dataHandle, abortSignal, billingTag) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
const builder = yield this.getRequestBuilder("volatile-blob", olp_sdk_core_1.HRN.fromString(this.hrn), abortSignal).catch(error => Promise.reject(error));
|
|
152
|
+
return olp_sdk_dataservice_api_1.VolatileBlobApi.getVolatileBlob(builder, {
|
|
153
|
+
dataHandle,
|
|
154
|
+
layerId: this.layerId,
|
|
155
|
+
billingTag
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Fetches baseUrl and creates requestBuilder for sending requests to the API Lookup Service.
|
|
161
|
+
* @param builderType endpoint name is needed to create propriate requestBuilder
|
|
162
|
+
*
|
|
163
|
+
* @returns requestBuilder
|
|
164
|
+
*/
|
|
165
|
+
getRequestBuilder(builderType, hrn, abortSignal) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
return olp_sdk_core_1.RequestFactory.create(builderType, this.apiVersion, this.settings, hrn, abortSignal);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Fetch and returns partition metadata
|
|
172
|
+
* @param partitionId The name of the partition to fetch.
|
|
173
|
+
* @param fetchOption The option of caching (online only or return from cache if exist)
|
|
174
|
+
* @returns A promise of partition metadata which used to get partition data
|
|
175
|
+
*/
|
|
176
|
+
getDataHandleByPartitionId(partitionId, fetchOption, billingTag) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const queryClient = new olp_sdk_dataservice_read_1.QueryClient(this.settings);
|
|
179
|
+
const partitionsRequest = new olp_sdk_dataservice_read_1.PartitionsRequest()
|
|
180
|
+
.withPartitionIds([partitionId])
|
|
181
|
+
.withFetchOption(fetchOption);
|
|
182
|
+
if (billingTag) {
|
|
183
|
+
partitionsRequest.withBillingTag(billingTag);
|
|
184
|
+
}
|
|
185
|
+
const metadata = yield queryClient.getPartitionsById(partitionsRequest, this.layerId, olp_sdk_core_1.HRN.fromString(this.hrn));
|
|
186
|
+
return metadata.partitions &&
|
|
187
|
+
metadata.partitions[0] &&
|
|
188
|
+
metadata.partitions[0].dataHandle
|
|
189
|
+
? metadata.partitions[0].dataHandle
|
|
190
|
+
: Promise.reject(new olp_sdk_core_1.HttpError(olp_sdk_core_1.STATUS_CODES.NOT_FOUND, `No partition dataHandle for partition ${partitionId}. HRN: ${this.hrn}`));
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
exports.VolatileLayerClient = VolatileLayerClient;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2019-2021 HERE Europe B.V.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
* License-Filename: LICENSE
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
__exportStar(require("./CatalogClient"), exports);
|
|
32
|
+
__exportStar(require("./CatalogRequest"), exports);
|
|
33
|
+
__exportStar(require("./DataRequest"), exports);
|
|
34
|
+
__exportStar(require("./StatisticsClient"), exports);
|
|
35
|
+
__exportStar(require("./StatisticsRequest"), exports);
|
|
36
|
+
__exportStar(require("./SummaryRequest"), exports);
|
|
37
|
+
__exportStar(require("./VersionedLayerClient"), exports);
|
|
38
|
+
__exportStar(require("./VolatileLayerClient"), exports);
|
|
39
|
+
__exportStar(require("./ConfigClient"), exports);
|
|
40
|
+
__exportStar(require("./CatalogsRequest"), exports);
|
|
41
|
+
__exportStar(require("./SchemaDetailsRequest"), exports);
|
|
42
|
+
__exportStar(require("./ArtifactClient"), exports);
|
|
43
|
+
__exportStar(require("./PartitionsRequest"), exports);
|
|
44
|
+
__exportStar(require("./QueryClient"), exports);
|
|
45
|
+
__exportStar(require("./QuadTreeIndexRequest"), exports);
|
|
46
|
+
__exportStar(require("./QuadKeyPartitionsRequest"), exports);
|
|
47
|
+
__exportStar(require("./SchemaRequest"), exports);
|
|
48
|
+
__exportStar(require("./CatalogVersionRequest"), exports);
|
|
49
|
+
__exportStar(require("./LayerVersionsRequest"), exports);
|
|
50
|
+
__exportStar(require("./IndexLayerClient"), exports);
|
|
51
|
+
__exportStar(require("./IndexQueryRequest"), exports);
|
|
52
|
+
__exportStar(require("./StreamLayerClient"), exports);
|
|
53
|
+
__exportStar(require("./SubscribeRequest"), exports);
|
|
54
|
+
__exportStar(require("./PollRequest"), exports);
|
|
55
|
+
__exportStar(require("./UnsubscribeRequest"), exports);
|
|
56
|
+
__exportStar(require("./SeekRequest"), exports);
|
|
57
|
+
__exportStar(require("./TileRequest"), exports);
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2019-2021 HERE Europe B.V.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
* License-Filename: LICENSE
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
__exportStar(require("./utils"), exports);
|
|
32
|
+
__exportStar(require("./client"), exports);
|
|
33
|
+
__exportStar(require("./cache"), exports);
|