apaas-oapi-client 0.1.24 → 0.1.25
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/dist/index.js +9 -7
- package/package.json +1 -1
- package/src/index.ts +10 -9
package/dist/index.js
CHANGED
|
@@ -369,7 +369,6 @@ class Client {
|
|
|
369
369
|
this.log(LoggerLevel.warn, '[object.update.recordsWithIterator] Empty records array provided, returning empty result');
|
|
370
370
|
return [];
|
|
371
371
|
}
|
|
372
|
-
const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records_batch`;
|
|
373
372
|
const chunkSize = 100;
|
|
374
373
|
const chunks = [];
|
|
375
374
|
for (let i = 0; i < records.length; i += chunkSize) {
|
|
@@ -379,13 +378,16 @@ class Client {
|
|
|
379
378
|
const results = [];
|
|
380
379
|
for (const [index, chunk] of chunks.entries()) {
|
|
381
380
|
this.log(LoggerLevel.debug, `[object.update.recordsWithIterator] Processing chunk ${index + 1}/${chunks.length}: ${chunk.length} records`);
|
|
382
|
-
const res = await
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this.log(LoggerLevel.debug, `[object.update.recordsWithIterator] Chunk ${index + 1} completed: ${object_name}, code=${response.data.code}`);
|
|
386
|
-
this.log(LoggerLevel.trace, `[object.update.recordsWithIterator] Chunk ${index + 1} response: ${JSON.stringify(response.data)}`);
|
|
387
|
-
return response.data;
|
|
381
|
+
const res = await this.object.update.records({
|
|
382
|
+
object_name,
|
|
383
|
+
records: chunk
|
|
388
384
|
});
|
|
385
|
+
if (res.code !== '0') {
|
|
386
|
+
this.log(LoggerLevel.error, `[object.update.recordsWithIterator] Error updating records: code=${res.code}, msg=${res.msg}`);
|
|
387
|
+
throw new Error(res.msg || `Update failed with code ${res.code}`);
|
|
388
|
+
}
|
|
389
|
+
this.log(LoggerLevel.debug, `[object.update.recordsWithIterator] Chunk ${index + 1} completed: ${object_name}, code=${res.code}`);
|
|
390
|
+
this.log(LoggerLevel.trace, `[object.update.recordsWithIterator] Chunk ${index + 1} response: ${JSON.stringify(res)}`);
|
|
389
391
|
results.push(res);
|
|
390
392
|
}
|
|
391
393
|
return results;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -569,8 +569,6 @@ class Client {
|
|
|
569
569
|
this.log(LoggerLevel.warn, '[object.update.recordsWithIterator] Empty records array provided, returning empty result');
|
|
570
570
|
return [];
|
|
571
571
|
}
|
|
572
|
-
|
|
573
|
-
const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records_batch`;
|
|
574
572
|
|
|
575
573
|
const chunkSize = 100;
|
|
576
574
|
const chunks: any[][] = [];
|
|
@@ -584,15 +582,18 @@ class Client {
|
|
|
584
582
|
for (const [index, chunk] of chunks.entries()) {
|
|
585
583
|
this.log(LoggerLevel.debug, `[object.update.recordsWithIterator] Processing chunk ${index + 1}/${chunks.length}: ${chunk.length} records`);
|
|
586
584
|
|
|
587
|
-
const res = await
|
|
588
|
-
|
|
585
|
+
const res = await this.object.update.records({
|
|
586
|
+
object_name,
|
|
587
|
+
records: chunk
|
|
588
|
+
});
|
|
589
589
|
|
|
590
|
-
|
|
590
|
+
if (res.code !== '0') {
|
|
591
|
+
this.log(LoggerLevel.error, `[object.update.recordsWithIterator] Error updating records: code=${res.code}, msg=${res.msg}`);
|
|
592
|
+
throw new Error(res.msg || `Update failed with code ${res.code}`);
|
|
593
|
+
}
|
|
591
594
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
return response.data;
|
|
595
|
-
});
|
|
595
|
+
this.log(LoggerLevel.debug, `[object.update.recordsWithIterator] Chunk ${index + 1} completed: ${object_name}, code=${res.code}`);
|
|
596
|
+
this.log(LoggerLevel.trace, `[object.update.recordsWithIterator] Chunk ${index + 1} response: ${JSON.stringify(res)}`);
|
|
596
597
|
|
|
597
598
|
results.push(res);
|
|
598
599
|
}
|