@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.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/c
|
|
|
4
4
|
|
|
5
5
|
// src/ingestionClient.ts
|
|
6
6
|
import { createAuth, createIterablePromise, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
7
|
-
var apiClientVersion = "1.
|
|
7
|
+
var apiClientVersion = "1.34.1";
|
|
8
8
|
var REGIONS = ["eu", "us"];
|
|
9
9
|
function getDefaultHosts(region) {
|
|
10
10
|
const url = "data.{region}.algolia.com".replace("{region}", region);
|
|
@@ -112,7 +112,9 @@ function createIngestionClient({
|
|
|
112
112
|
referenceIndexName
|
|
113
113
|
}, requestOptions) {
|
|
114
114
|
let records = [];
|
|
115
|
+
let offset = 0;
|
|
115
116
|
const responses = [];
|
|
117
|
+
const waitBatchSize = Math.floor(batchSize / 10) || batchSize;
|
|
116
118
|
const objectEntries = objects.entries();
|
|
117
119
|
for (const [i, obj] of objectEntries) {
|
|
118
120
|
records.push(obj);
|
|
@@ -122,33 +124,34 @@ function createIngestionClient({
|
|
|
122
124
|
);
|
|
123
125
|
records = [];
|
|
124
126
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
|
|
136
|
-
}
|
|
137
|
-
return this.getEvent({ runID: resp.runID, eventID: resp.eventID }).catch((error) => {
|
|
138
|
-
if (error.status === 404) {
|
|
139
|
-
return void 0;
|
|
127
|
+
if (waitForTasks && responses.length > 0 && (responses.length % waitBatchSize === 0 || i === objects.length - 1)) {
|
|
128
|
+
for (const resp of responses.slice(offset, offset + waitBatchSize)) {
|
|
129
|
+
if (!resp.eventID) {
|
|
130
|
+
throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
|
|
131
|
+
}
|
|
132
|
+
let retryCount = 0;
|
|
133
|
+
await createIterablePromise({
|
|
134
|
+
func: async () => {
|
|
135
|
+
if (resp.eventID === void 0 || !resp.eventID) {
|
|
136
|
+
throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
|
|
140
137
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
138
|
+
return this.getEvent({ runID: resp.runID, eventID: resp.eventID }).catch((error) => {
|
|
139
|
+
if (error.status === 404) {
|
|
140
|
+
return void 0;
|
|
141
|
+
}
|
|
142
|
+
throw error;
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
validate: (response) => response !== void 0,
|
|
146
|
+
aggregator: () => retryCount += 1,
|
|
147
|
+
error: {
|
|
148
|
+
validate: () => retryCount >= 50,
|
|
149
|
+
message: () => `The maximum number of retries exceeded. (${retryCount}/${50})`
|
|
150
|
+
},
|
|
151
|
+
timeout: () => Math.min(retryCount * 500, 5e3)
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
offset += waitBatchSize;
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
157
|
return responses;
|