@algolia/ingestion 1.34.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/ingestionClient.ts
|
|
2
2
|
import { createAuth, createIterablePromise, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
3
|
-
var apiClientVersion = "1.34.
|
|
3
|
+
var apiClientVersion = "1.34.1";
|
|
4
4
|
var REGIONS = ["eu", "us"];
|
|
5
5
|
function getDefaultHosts(region) {
|
|
6
6
|
const url = "data.{region}.algolia.com".replace("{region}", region);
|
|
@@ -108,7 +108,9 @@ function createIngestionClient({
|
|
|
108
108
|
referenceIndexName
|
|
109
109
|
}, requestOptions) {
|
|
110
110
|
let records = [];
|
|
111
|
+
let offset = 0;
|
|
111
112
|
const responses = [];
|
|
113
|
+
const waitBatchSize = Math.floor(batchSize / 10) || batchSize;
|
|
112
114
|
const objectEntries = objects.entries();
|
|
113
115
|
for (const [i, obj] of objectEntries) {
|
|
114
116
|
records.push(obj);
|
|
@@ -118,33 +120,34 @@ function createIngestionClient({
|
|
|
118
120
|
);
|
|
119
121
|
records = [];
|
|
120
122
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
|
|
132
|
-
}
|
|
133
|
-
return this.getEvent({ runID: resp.runID, eventID: resp.eventID }).catch((error) => {
|
|
134
|
-
if (error.status === 404) {
|
|
135
|
-
return void 0;
|
|
123
|
+
if (waitForTasks && responses.length > 0 && (responses.length % waitBatchSize === 0 || i === objects.length - 1)) {
|
|
124
|
+
for (const resp of responses.slice(offset, offset + waitBatchSize)) {
|
|
125
|
+
if (!resp.eventID) {
|
|
126
|
+
throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
|
|
127
|
+
}
|
|
128
|
+
let retryCount = 0;
|
|
129
|
+
await createIterablePromise({
|
|
130
|
+
func: async () => {
|
|
131
|
+
if (resp.eventID === void 0 || !resp.eventID) {
|
|
132
|
+
throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
|
|
136
133
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
134
|
+
return this.getEvent({ runID: resp.runID, eventID: resp.eventID }).catch((error) => {
|
|
135
|
+
if (error.status === 404) {
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
138
|
+
throw error;
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
validate: (response) => response !== void 0,
|
|
142
|
+
aggregator: () => retryCount += 1,
|
|
143
|
+
error: {
|
|
144
|
+
validate: () => retryCount >= 50,
|
|
145
|
+
message: () => `The maximum number of retries exceeded. (${retryCount}/${50})`
|
|
146
|
+
},
|
|
147
|
+
timeout: () => Math.min(retryCount * 500, 5e3)
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
offset += waitBatchSize;
|
|
148
151
|
}
|
|
149
152
|
}
|
|
150
153
|
return responses;
|
|
@@ -1397,7 +1400,7 @@ function createIngestionClient({
|
|
|
1397
1400
|
connect: 18e4,
|
|
1398
1401
|
read: 18e4,
|
|
1399
1402
|
write: 18e4,
|
|
1400
|
-
...requestOptions
|
|
1403
|
+
...requestOptions?.timeouts
|
|
1401
1404
|
}
|
|
1402
1405
|
};
|
|
1403
1406
|
return transporter.request(request, requestOptions);
|
|
@@ -1446,7 +1449,7 @@ function createIngestionClient({
|
|
|
1446
1449
|
connect: 18e4,
|
|
1447
1450
|
read: 18e4,
|
|
1448
1451
|
write: 18e4,
|
|
1449
|
-
...requestOptions
|
|
1452
|
+
...requestOptions?.timeouts
|
|
1450
1453
|
}
|
|
1451
1454
|
};
|
|
1452
1455
|
return transporter.request(request, requestOptions);
|
|
@@ -1746,7 +1749,7 @@ function createIngestionClient({
|
|
|
1746
1749
|
connect: 18e4,
|
|
1747
1750
|
read: 18e4,
|
|
1748
1751
|
write: 18e4,
|
|
1749
|
-
...requestOptions
|
|
1752
|
+
...requestOptions?.timeouts
|
|
1750
1753
|
}
|
|
1751
1754
|
};
|
|
1752
1755
|
return transporter.request(request, requestOptions);
|
|
@@ -2030,7 +2033,7 @@ function createIngestionClient({
|
|
|
2030
2033
|
connect: 18e4,
|
|
2031
2034
|
read: 18e4,
|
|
2032
2035
|
write: 18e4,
|
|
2033
|
-
...requestOptions
|
|
2036
|
+
...requestOptions?.timeouts
|
|
2034
2037
|
}
|
|
2035
2038
|
};
|
|
2036
2039
|
return transporter.request(request, requestOptions);
|
|
@@ -2069,7 +2072,7 @@ function createIngestionClient({
|
|
|
2069
2072
|
connect: 18e4,
|
|
2070
2073
|
read: 18e4,
|
|
2071
2074
|
write: 18e4,
|
|
2072
|
-
...requestOptions
|
|
2075
|
+
...requestOptions?.timeouts
|
|
2073
2076
|
}
|
|
2074
2077
|
};
|
|
2075
2078
|
return transporter.request(request, requestOptions);
|
|
@@ -2084,4 +2087,11 @@ export {
|
|
|
2084
2087
|
isScheduleTrigger,
|
|
2085
2088
|
isSubscriptionTrigger
|
|
2086
2089
|
};
|
|
2090
|
+
//# sourceMappingURL=ingestionClient.js.mapEGIONS,
|
|
2091
|
+
apiClientVersion,
|
|
2092
|
+
createIngestionClient,
|
|
2093
|
+
isOnDemandTrigger,
|
|
2094
|
+
isScheduleTrigger,
|
|
2095
|
+
isSubscriptionTrigger
|
|
2096
|
+
};
|
|
2087
2097
|
//# sourceMappingURL=ingestionClient.js.map
|