@here/olp-sdk-dataservice-read 1.9.0 → 1.12.2

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.
@@ -13,28 +13,12 @@ export declare class MetadataCacheRepository {
13
13
  * @return The [[MetadataCacheRepository]] instance.
14
14
  */
15
15
  constructor(cache: KeyValueCache);
16
- /**
17
- * @deprecated This signature will be removed by 05.2021. Please set the version as the last argument.
18
- * Stores a key-value pair in the cache.
19
- *
20
- * @return True if the operation is successful, false otherwise.
21
- */
22
- put(rq: PartitionsRequest, hrn: string, layerId: string, partitions: MetadataApi.Partition[]): boolean;
23
16
  /**
24
17
  * Stores a key-value pair in the cache.
25
18
  *
26
19
  * @return True if the operation is successful, false otherwise.
27
20
  */
28
21
  put(rq: PartitionsRequest, hrn: string, layerId: string, partitions: MetadataApi.Partition[], version?: number): boolean;
29
- /**
30
- * @deprecated This signature will be removed by 05.2021. Please set the version as the last argument.
31
- * Gets a metadata from the cache.
32
- *
33
- * @param service The name of the API service for which you want to get the base URL.
34
- * @param serviceVersion The service version.
35
- * @return The base URL of the service, or undefined if the base URL does not exist.
36
- */
37
- get(rq: PartitionsRequest, hrn: string, layerId: string): MetadataApi.Partition[] | undefined;
38
22
  /**
39
23
  * Gets a metadata from the cache.
40
24
  *
@@ -32,6 +32,11 @@ class MetadataCacheRepository {
32
32
  constructor(cache) {
33
33
  this.cache = cache;
34
34
  }
35
+ /**
36
+ * Stores a key-value pair in the cache.
37
+ *
38
+ * @return True if the operation is successful, false otherwise.
39
+ */
35
40
  put(rq, hrn, layerId, partitions, version) {
36
41
  const partitionsIds = rq.getPartitionIds();
37
42
  let key;
@@ -40,7 +45,7 @@ class MetadataCacheRepository {
40
45
  key = this.createKey({
41
46
  hrn,
42
47
  layerId,
43
- version: version !== undefined ? version : rq.getVersion(),
48
+ version,
44
49
  partitionId: metadata.partition
45
50
  });
46
51
  this.cache.put(key, JSON.stringify(metadata));
@@ -50,7 +55,7 @@ class MetadataCacheRepository {
50
55
  key = this.createKey({
51
56
  hrn,
52
57
  layerId,
53
- version: version !== undefined ? version : rq.getVersion()
58
+ version
54
59
  });
55
60
  return this.cache.put(key, JSON.stringify(partitions));
56
61
  }
@@ -63,7 +68,7 @@ class MetadataCacheRepository {
63
68
  key = this.createKey({
64
69
  hrn,
65
70
  layerId,
66
- version: version !== undefined ? version : rq.getVersion(),
71
+ version,
67
72
  partitionId
68
73
  });
69
74
  const serializedPartition = this.cache.get(key);
@@ -85,7 +90,7 @@ class MetadataCacheRepository {
85
90
  key = this.createKey({
86
91
  hrn,
87
92
  layerId,
88
- version: version !== undefined ? version : rq.getVersion()
93
+ version
89
94
  });
90
95
  const serializedPartitions = this.cache.get(key);
91
96
  return serializedPartitions
@@ -20,7 +20,7 @@ export declare class ArtifactClient {
20
20
  * @param schemaDetailsRequest The [[SchemaDetailsRequest]] instance.
21
21
  * @return An object with the schema metadata.
22
22
  */
23
- getSchemaDetails(schemaDetailsRequest: SchemaDetailsRequest): Promise<ArtifactApi.GetSchemaResponse>;
23
+ getSchemaDetails(schemaDetailsRequest: SchemaDetailsRequest): Promise<ArtifactApi.GetSchemaResponse | ArtifactApi.GetSchemaResponseObj>;
24
24
  /**
25
25
  * Gets schema data.
26
26
  *
@@ -9,26 +9,6 @@ export declare class PartitionsRequest {
9
9
  private partitionIds?;
10
10
  private additionalFields?;
11
11
  private fetchOption;
12
- /**
13
- * This method is @deprecated and will be removed by 04.2021. If you need to set the version,
14
- * initialize the version client with the new constructor. Otherwise, the latest version will be used.
15
- *
16
- * Gets a layer version for the request.
17
- *
18
- * @return The layer version number.
19
- */
20
- getVersion(): number | undefined;
21
- /**
22
- * This method is @deprecated and will be removed by 04.2021. If you need to set the version,
23
- * initialize the version client with the new constructor. Otherwise, the latest version will be used.
24
- *
25
- * An optional method that sets the provided layer version.
26
- * If the layer version is not specified, the last layer version is used.
27
- *
28
- * @param version Specify the layer version or, if you want to use the latest layer version, set to undefined.
29
- * @returns The updated [[PartitionsRequest]] instance that you can use to chain methods.
30
- */
31
- withVersion(version?: number): PartitionsRequest;
32
12
  /**
33
13
  * An optional free-form tag that is used for grouping billing records together.
34
14
  *
@@ -28,31 +28,6 @@ class PartitionsRequest {
28
28
  constructor() {
29
29
  this.fetchOption = olp_sdk_core_1.FetchOptions.OnlineIfNotFound;
30
30
  }
31
- /**
32
- * This method is @deprecated and will be removed by 04.2021. If you need to set the version,
33
- * initialize the version client with the new constructor. Otherwise, the latest version will be used.
34
- *
35
- * Gets a layer version for the request.
36
- *
37
- * @return The layer version number.
38
- */
39
- getVersion() {
40
- return this.version;
41
- }
42
- /**
43
- * This method is @deprecated and will be removed by 04.2021. If you need to set the version,
44
- * initialize the version client with the new constructor. Otherwise, the latest version will be used.
45
- *
46
- * An optional method that sets the provided layer version.
47
- * If the layer version is not specified, the last layer version is used.
48
- *
49
- * @param version Specify the layer version or, if you want to use the latest layer version, set to undefined.
50
- * @returns The updated [[PartitionsRequest]] instance that you can use to chain methods.
51
- */
52
- withVersion(version) {
53
- this.version = version;
54
- return this;
55
- }
56
31
  /**
57
32
  * An optional free-form tag that is used for grouping billing records together.
58
33
  *
@@ -29,7 +29,6 @@ export declare class QueryClient {
29
29
  */
30
30
  fetchQuadTreeIndex(request: QuadTreeIndexRequest, abortSignal?: AbortSignal): Promise<QueryApi.Index>;
31
31
  /**
32
- * @deprecated This signature will be removed by 04.2021. Please set the version as the last argument.
33
32
  * Gets partitions using their IDs.
34
33
  *
35
34
  * @param request The `PartitionsRequest` instance.
@@ -42,21 +41,7 @@ export declare class QueryClient {
42
41
  *
43
42
  * @return The requested partitions.
44
43
  */
45
- getPartitionsById(request: PartitionsRequest, layerId: string, hrn: HRN, abortSignal?: AbortSignal): Promise<QueryApi.Partitions>;
46
- /**
47
- * Gets partitions using their IDs.
48
- *
49
- * @param request The `PartitionsRequest` instance.
50
- * @param layerId The ID of the layer from which you want to get partitions.
51
- * @param hrn The HERE Resource Name (HRN) of the layer.
52
- * @param abortSignal A signal object that allows you to communicate with a request (such as the `fetch` request)
53
- * and, if required, abort it using the `AbortController` object.
54
- *
55
- * For more information, see the [`AbortController` documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
56
- *
57
- * @return The requested partitions.
58
- */
59
- getPartitionsById(request: PartitionsRequest, layerId: string, hrn: HRN, abortSignal?: AbortSignal, version?: number): Promise<QueryApi.Partitions>;
44
+ getPartitionsById(request: PartitionsRequest, layerId: string, hrn: HRN, abortSignal?: AbortSignal, catalogVersion?: number): Promise<QueryApi.Partitions>;
60
45
  /**
61
46
  * Gets the latest available catalog version
62
47
  */
@@ -100,18 +100,28 @@ class QueryClient {
100
100
  return fetchingQuadTreeIndexFunction(requestBuilder, paramsForFetchQuadTreeIndex);
101
101
  });
102
102
  }
103
+ /**
104
+ * Gets partitions using their IDs.
105
+ *
106
+ * @param request The `PartitionsRequest` instance.
107
+ * @param layerId The ID of the layer from which you want to get partitions.
108
+ * @param hrn The HERE Resource Name (HRN) of the layer.
109
+ * @param abortSignal A signal object that allows you to communicate with a request (such as the `fetch` request)
110
+ * and, if required, abort it using the `AbortController` object.
111
+ *
112
+ * For more information, see the [`AbortController` documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
113
+ *
114
+ * @return The requested partitions.
115
+ */
103
116
  getPartitionsById(request, layerId, hrn, abortSignal, catalogVersion) {
104
117
  return __awaiter(this, void 0, void 0, function* () {
105
118
  const idsList = request.getPartitionIds();
106
- const version = catalogVersion !== undefined
107
- ? catalogVersion
108
- : request.getVersion();
109
119
  if (!idsList) {
110
120
  return Promise.reject("Please provide correct partitionIds list");
111
121
  }
112
122
  const cache = new olp_sdk_dataservice_read_1.MetadataCacheRepository(this.settings.cache);
113
123
  if (request.getFetchOption() !== olp_sdk_core_1.FetchOptions.OnlineOnly) {
114
- const cachedPartitions = cache.get(request, hrn.toString(), layerId, version);
124
+ const cachedPartitions = cache.get(request, hrn.toString(), layerId, catalogVersion);
115
125
  if (cachedPartitions) {
116
126
  return Promise.resolve({
117
127
  partitions: cachedPartitions
@@ -123,7 +133,7 @@ class QueryClient {
123
133
  layerId,
124
134
  partition: idsList,
125
135
  additionalFields: request.getAdditionalFields(),
126
- version: version !== undefined ? `${version}` : undefined
136
+ version: catalogVersion !== undefined ? `${catalogVersion}` : undefined
127
137
  }).catch(err => Promise.reject(err));
128
138
  if (request.getFetchOption() !== olp_sdk_core_1.FetchOptions.OnlineOnly &&
129
139
  medatada &&
@@ -137,7 +147,7 @@ class QueryClient {
137
147
  partition: partition.partition,
138
148
  version: partition.version
139
149
  }));
140
- cache.put(request, hrn.toString(), layerId, partitions, version);
150
+ cache.put(request, hrn.toString(), layerId, partitions, catalogVersion);
141
151
  }
142
152
  return Promise.resolve(medatada);
143
153
  });
@@ -125,30 +125,32 @@ class StreamLayerClient {
125
125
  .catch(error => Promise.reject(error));
126
126
  // Update xCorrelationId
127
127
  this.xCorrelationId = consumeResponse.xCorrelationId;
128
- // Commit offsets
129
- const latestOffsets = consumeResponse.data
130
- .map(msg => msg.offset)
131
- .reduce((acc, curr) => {
132
- acc[curr.partition] =
133
- acc[curr.partition] > curr.offset
134
- ? acc[curr.partition]
135
- : curr.offset;
136
- return acc;
137
- }, {});
138
- yield olp_sdk_dataservice_api_1.StreamApi.doCommitOffsets(requestBuilder, {
139
- commitOffsets: {
140
- offsets: Object.keys(latestOffsets).map(key => ({
141
- partition: +key,
142
- offset: latestOffsets[key]
143
- }))
144
- },
145
- subscriptionId: request.getSubscriptionId(),
146
- mode: request.getMode(),
147
- layerId: this.layerId,
148
- xCorrelationId: this.xCorrelationId
149
- }).catch((error) => __awaiter(this, void 0, void 0, function* () {
150
- console.log(`Commit offsets unsuccessful, error=${error.message}`);
151
- }));
128
+ if (consumeResponse.data.length > 0) {
129
+ // Commit offsets
130
+ const latestOffsets = consumeResponse.data
131
+ .map(msg => msg.offset)
132
+ .reduce((acc, curr) => {
133
+ acc[curr.partition] =
134
+ acc[curr.partition] > curr.offset
135
+ ? acc[curr.partition]
136
+ : curr.offset;
137
+ return acc;
138
+ }, {});
139
+ yield olp_sdk_dataservice_api_1.StreamApi.doCommitOffsets(requestBuilder, {
140
+ commitOffsets: {
141
+ offsets: Object.keys(latestOffsets).map(key => ({
142
+ partition: +key,
143
+ offset: latestOffsets[key]
144
+ }))
145
+ },
146
+ subscriptionId: request.getSubscriptionId(),
147
+ mode: request.getMode(),
148
+ layerId: this.layerId,
149
+ xCorrelationId: this.xCorrelationId
150
+ }).catch((error) => __awaiter(this, void 0, void 0, function* () {
151
+ console.log(`Commit offsets unsuccessful, error=${error.message}`);
152
+ }));
153
+ }
152
154
  return Promise.resolve(consumeResponse.data);
153
155
  });
154
156
  }
@@ -101,7 +101,10 @@ function getTile(request, params, abortSignal) {
101
101
  quadTreeIndex = yield fetchQuadTreeIndex(Object.assign(Object.assign({}, params), { catalogVersion, depth: delta, fetchOptions: request.getFetchOption(), tileKey: parentTileKey, abortSignal, billingTag: request.getBillingTag() })).catch(e => Promise.reject(e));
102
102
  }
103
103
  if (!quadTreeIndex.subQuads || !quadTreeIndex.subQuads.length) {
104
- return Promise.reject(new Error("Error fetching QuadTreeIndex"));
104
+ return Promise.resolve(new Response("No Content", {
105
+ status: 204,
106
+ statusText: "No Content"
107
+ }));
105
108
  }
106
109
  // Return the data for the requested QuadKey or for the closest parent
107
110
  const subQuads = quadTreeIndex.subQuads;
@@ -1,4 +1,3 @@
1
- export * from "./QuadKeyUtils";
2
1
  export * from "./validateBillingTag";
3
2
  export * from "./validatePartitionsIdsList";
4
3
  export * from "./getTile";
@@ -28,7 +28,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
28
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
29
29
  };
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
- __exportStar(require("./QuadKeyUtils"), exports);
32
31
  __exportStar(require("./validateBillingTag"), exports);
33
32
  __exportStar(require("./validatePartitionsIdsList"), exports);
34
33
  __exportStar(require("./getTile"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@here/olp-sdk-dataservice-read",
3
- "version": "1.9.0",
3
+ "version": "1.12.2",
4
4
  "description": "Wrapper around a subset of the HERE Open Location Platform Data REST API related to reading data from OLP catalogs",
5
5
  "main": "index.js",
6
6
  "browser": "index.web.js",
@@ -49,8 +49,8 @@
49
49
  },
50
50
  "license": "Apache-2.0",
51
51
  "dependencies": {
52
- "@here/olp-sdk-core": "^1.4.0",
53
- "@here/olp-sdk-dataservice-api": "^1.9.0",
52
+ "@here/olp-sdk-core": "^1.7.1",
53
+ "@here/olp-sdk-dataservice-api": "^1.12.2",
54
54
  "@here/olp-sdk-fetch": "^1.9.0"
55
55
  },
56
56
  "devDependencies": {
@@ -72,10 +72,10 @@
72
72
  "ts-node": "^8.5.4",
73
73
  "tslint": "^6.1.3",
74
74
  "tslint-config-prettier": "^1.18.0",
75
- "typedoc": "^0.19.2",
75
+ "typedoc": "^0.20.25",
76
76
  "typescript": "4.0.3",
77
77
  "tslib": "1.13.0",
78
78
  "webpack": "^4.41.5",
79
79
  "webpack-cli": "^3.3.10"
80
80
  }
81
- }
81
+ }
@@ -1,18 +0,0 @@
1
- import { QuadKey } from "@here/olp-sdk-core";
2
- /**
3
- * @deprecated This function will be removed by 08.2021.
4
- * Please use the same method from [[TileKey]] class, imported from `@here/olp-sdk-core` package.
5
- *
6
- * Checks if a quadkey is valid.
7
- *
8
- * The number of rows and columns must not be greater than the maximum number of rows and columns in the given level.
9
- * The maximum number of rows and columns in a level is computed as 2 to the power of the level.
10
- *
11
- * @note As the JavaScript number type can hold 53 bits in its mantissa, only levels up to 26 can be
12
- * represented in the number representation returned by [[mortonCodeFromQuadKey]].
13
- * A level must be positive and can't be greater than 26.
14
- *
15
- * @param key The current quadkey.
16
- * @return True if the quadkey is valid, false otherwise.
17
- */
18
- export declare function isValid(key: QuadKey): boolean;
@@ -1,48 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.isValid = void 0;
22
- /**
23
- * @deprecated This function will be removed by 08.2021.
24
- * Please use the same method from [[TileKey]] class, imported from `@here/olp-sdk-core` package.
25
- *
26
- * Checks if a quadkey is valid.
27
- *
28
- * The number of rows and columns must not be greater than the maximum number of rows and columns in the given level.
29
- * The maximum number of rows and columns in a level is computed as 2 to the power of the level.
30
- *
31
- * @note As the JavaScript number type can hold 53 bits in its mantissa, only levels up to 26 can be
32
- * represented in the number representation returned by [[mortonCodeFromQuadKey]].
33
- * A level must be positive and can't be greater than 26.
34
- *
35
- * @param key The current quadkey.
36
- * @return True if the quadkey is valid, false otherwise.
37
- */
38
- function isValid(key) {
39
- // tslint:disable-next-line:no-magic-numbers
40
- if (key.level < 0 || key.level > 26) {
41
- return false;
42
- }
43
- const dimensionAtLevel = Math.pow(2, key.level);
44
- const rowValid = key.row >= 0 && key.row < dimensionAtLevel;
45
- const columnValid = key.column >= 0 && key.column < dimensionAtLevel;
46
- return rowValid && columnValid;
47
- }
48
- exports.isValid = isValid;