@algolia/ingestion 1.33.0 → 1.34.1
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 +4 -4
- package/dist/browser.d.ts +1 -1
- package/dist/builds/browser.js +30 -27
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +1 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +2 -2
- package/dist/builds/fetch.js +30 -27
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +30 -27
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +30 -27
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +30 -27
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/src/ingestionClient.cjs +30 -27
- package/dist/src/ingestionClient.cjs.map +1 -1
- package/dist/src/ingestionClient.js +42 -32
- package/dist/src/ingestionClient.js.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/package.json +6 -6
package/dist/builds/node.cjs
CHANGED
|
@@ -32,7 +32,7 @@ var import_client_common2 = require("@algolia/client-common");
|
|
|
32
32
|
|
|
33
33
|
// src/ingestionClient.ts
|
|
34
34
|
var import_client_common = require("@algolia/client-common");
|
|
35
|
-
var apiClientVersion = "1.
|
|
35
|
+
var apiClientVersion = "1.34.1";
|
|
36
36
|
var REGIONS = ["eu", "us"];
|
|
37
37
|
function getDefaultHosts(region) {
|
|
38
38
|
const url = "data.{region}.algolia.com".replace("{region}", region);
|
|
@@ -140,7 +140,9 @@ function createIngestionClient({
|
|
|
140
140
|
referenceIndexName
|
|
141
141
|
}, requestOptions) {
|
|
142
142
|
let records = [];
|
|
143
|
+
let offset = 0;
|
|
143
144
|
const responses = [];
|
|
145
|
+
const waitBatchSize = Math.floor(batchSize / 10) || batchSize;
|
|
144
146
|
const objectEntries = objects.entries();
|
|
145
147
|
for (const [i, obj] of objectEntries) {
|
|
146
148
|
records.push(obj);
|
|
@@ -150,33 +152,34 @@ function createIngestionClient({
|
|
|
150
152
|
);
|
|
151
153
|
records = [];
|
|
152
154
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
|
|
164
|
-
}
|
|
165
|
-
return this.getEvent({ runID: resp.runID, eventID: resp.eventID }).catch((error) => {
|
|
166
|
-
if (error.status === 404) {
|
|
167
|
-
return void 0;
|
|
155
|
+
if (waitForTasks && responses.length > 0 && (responses.length % waitBatchSize === 0 || i === objects.length - 1)) {
|
|
156
|
+
for (const resp of responses.slice(offset, offset + waitBatchSize)) {
|
|
157
|
+
if (!resp.eventID) {
|
|
158
|
+
throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
|
|
159
|
+
}
|
|
160
|
+
let retryCount = 0;
|
|
161
|
+
await (0, import_client_common.createIterablePromise)({
|
|
162
|
+
func: async () => {
|
|
163
|
+
if (resp.eventID === void 0 || !resp.eventID) {
|
|
164
|
+
throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
|
|
168
165
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
166
|
+
return this.getEvent({ runID: resp.runID, eventID: resp.eventID }).catch((error) => {
|
|
167
|
+
if (error.status === 404) {
|
|
168
|
+
return void 0;
|
|
169
|
+
}
|
|
170
|
+
throw error;
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
validate: (response) => response !== void 0,
|
|
174
|
+
aggregator: () => retryCount += 1,
|
|
175
|
+
error: {
|
|
176
|
+
validate: () => retryCount >= 50,
|
|
177
|
+
message: () => `The maximum number of retries exceeded. (${retryCount}/${50})`
|
|
178
|
+
},
|
|
179
|
+
timeout: () => Math.min(retryCount * 500, 5e3)
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
offset += waitBatchSize;
|
|
180
183
|
}
|
|
181
184
|
}
|
|
182
185
|
return responses;
|