apaas-oapi-client 0.1.25 → 0.1.26

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 CHANGED
@@ -260,11 +260,11 @@ class Client {
260
260
  /**
261
261
  * 分批创建所有记录 - 支持超过 100 条数据,自动拆分
262
262
  * @description 创建多条记录到指定对象中,超过 100 条数据会自动拆分为多次请求
263
- * @param params 请求参数 { object_name, records }
263
+ * @param params 请求参数 { object_name, records, limit }
264
264
  * @returns { total, items }
265
265
  */
266
266
  recordsWithIterator: async (params) => {
267
- const { object_name, records } = params;
267
+ const { object_name, records, limit = 100 } = params;
268
268
  // 参数校验
269
269
  if (!records || !Array.isArray(records)) {
270
270
  this.log(LoggerLevel.error, '[object.create.recordsWithIterator] Invalid records parameter: must be a non-empty array');
@@ -276,7 +276,7 @@ class Client {
276
276
  }
277
277
  let results = [];
278
278
  let total = records.length;
279
- const chunkSize = 100;
279
+ const chunkSize = limit;
280
280
  let page = 0;
281
281
  const chunks = [];
282
282
  for (let i = 0; i < records.length; i += chunkSize) {
@@ -359,7 +359,7 @@ class Client {
359
359
  * @returns 所有子请求的返回结果数组
360
360
  */
361
361
  recordsWithIterator: async (params) => {
362
- const { object_name, records } = params;
362
+ const { object_name, records, limit = 100 } = params;
363
363
  // 参数校验
364
364
  if (!records || !Array.isArray(records)) {
365
365
  this.log(LoggerLevel.error, '[object.update.recordsWithIterator] Invalid records parameter: must be a non-empty array');
@@ -369,7 +369,7 @@ 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 chunkSize = 100;
372
+ const chunkSize = limit;
373
373
  const chunks = [];
374
374
  for (let i = 0; i < records.length; i += chunkSize) {
375
375
  chunks.push(records.slice(i, i + chunkSize));
@@ -446,7 +446,7 @@ class Client {
446
446
  * @returns 所有子请求的返回结果数组
447
447
  */
448
448
  recordsWithIterator: async (params) => {
449
- const { object_name, ids } = params;
449
+ const { object_name, ids, limit = 100 } = params;
450
450
  // 参数校验
451
451
  if (!ids || !Array.isArray(ids)) {
452
452
  this.log(LoggerLevel.error, '[object.delete.recordsWithIterator] Invalid ids parameter: must be a non-empty array');
@@ -457,7 +457,7 @@ class Client {
457
457
  return [];
458
458
  }
459
459
  const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records_batch`;
460
- const chunkSize = 100;
460
+ const chunkSize = limit;
461
461
  const chunks = [];
462
462
  for (let i = 0; i < ids.length; i += chunkSize) {
463
463
  chunks.push(ids.slice(i, i + chunkSize));
@@ -163,12 +163,13 @@ declare class Client {
163
163
  /**
164
164
  * 分批创建所有记录 - 支持超过 100 条数据,自动拆分
165
165
  * @description 创建多条记录到指定对象中,超过 100 条数据会自动拆分为多次请求
166
- * @param params 请求参数 { object_name, records }
166
+ * @param params 请求参数 { object_name, records, limit }
167
167
  * @returns { total, items }
168
168
  */
169
169
  recordsWithIterator: (params: {
170
170
  object_name: string;
171
171
  records: any[];
172
+ limit?: number;
172
173
  }) => Promise<{
173
174
  total: number;
174
175
  items: any[];
@@ -205,6 +206,7 @@ declare class Client {
205
206
  recordsWithIterator: (params: {
206
207
  object_name: string;
207
208
  records: any[];
209
+ limit?: number;
208
210
  }) => Promise<any[]>;
209
211
  };
210
212
  delete: {
@@ -237,6 +239,7 @@ declare class Client {
237
239
  recordsWithIterator: (params: {
238
240
  object_name: string;
239
241
  ids: string[];
242
+ limit?: number;
240
243
  }) => Promise<any[]>;
241
244
  };
242
245
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apaas-oapi-client",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "main": "dist/index.js",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
package/src/index.ts CHANGED
@@ -432,11 +432,11 @@ class Client {
432
432
  /**
433
433
  * 分批创建所有记录 - 支持超过 100 条数据,自动拆分
434
434
  * @description 创建多条记录到指定对象中,超过 100 条数据会自动拆分为多次请求
435
- * @param params 请求参数 { object_name, records }
435
+ * @param params 请求参数 { object_name, records, limit }
436
436
  * @returns { total, items }
437
437
  */
438
- recordsWithIterator: async (params: { object_name: string; records: any[] }): Promise<{ total: number; items: any[] }> => {
439
- const { object_name, records } = params;
438
+ recordsWithIterator: async (params: { object_name: string; records: any[]; limit?: number }): Promise<{ total: number; items: any[] }> => {
439
+ const { object_name, records, limit = 100 } = params;
440
440
 
441
441
  // 参数校验
442
442
  if (!records || !Array.isArray(records)) {
@@ -451,7 +451,7 @@ class Client {
451
451
 
452
452
  let results: any[] = [];
453
453
  let total = records.length;
454
- const chunkSize = 100;
454
+ const chunkSize = limit;
455
455
  let page = 0;
456
456
 
457
457
  const chunks: any[][] = [];
@@ -556,8 +556,8 @@ class Client {
556
556
  * @param params 请求参数
557
557
  * @returns 所有子请求的返回结果数组
558
558
  */
559
- recordsWithIterator: async (params: { object_name: string; records: any[] }): Promise<any[]> => {
560
- const { object_name, records } = params;
559
+ recordsWithIterator: async (params: { object_name: string; records: any[]; limit?: number }): Promise<any[]> => {
560
+ const { object_name, records, limit = 100 } = params;
561
561
 
562
562
  // 参数校验
563
563
  if (!records || !Array.isArray(records)) {
@@ -570,7 +570,7 @@ class Client {
570
570
  return [];
571
571
  }
572
572
 
573
- const chunkSize = 100;
573
+ const chunkSize = limit;
574
574
  const chunks: any[][] = [];
575
575
  for (let i = 0; i < records.length; i += chunkSize) {
576
576
  chunks.push(records.slice(i, i + chunkSize));
@@ -667,8 +667,8 @@ class Client {
667
667
  * @param params 请求参数
668
668
  * @returns 所有子请求的返回结果数组
669
669
  */
670
- recordsWithIterator: async (params: { object_name: string; ids: string[] }): Promise<any[]> => {
671
- const { object_name, ids } = params;
670
+ recordsWithIterator: async (params: { object_name: string; ids: string[]; limit?: number }): Promise<any[]> => {
671
+ const { object_name, ids, limit = 100 } = params;
672
672
 
673
673
  // 参数校验
674
674
  if (!ids || !Array.isArray(ids)) {
@@ -683,7 +683,7 @@ class Client {
683
683
 
684
684
  const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records_batch`;
685
685
 
686
- const chunkSize = 100;
686
+ const chunkSize = limit;
687
687
  const chunks: string[][] = [];
688
688
  for (let i = 0; i < ids.length; i += chunkSize) {
689
689
  chunks.push(ids.slice(i, i + chunkSize));