apaas-oapi-client 0.1.12 → 0.1.14

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
@@ -148,12 +148,14 @@ class Client {
148
148
  let nextPageToken = '';
149
149
  let total = 0;
150
150
  let page = 0;
151
+ const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records_query`;
151
152
  do {
152
153
  await functionLimiter(async () => {
154
+ var _a, _b, _c;
153
155
  const mergedData = { ...data, page_token: nextPageToken || '' };
154
- const res = await this.object.search.records({
155
- object_name,
156
- data: mergedData
156
+ await this.ensureTokenValid();
157
+ const res = await this.axiosInstance.post(url, mergedData, {
158
+ headers: { Authorization: `${this.accessToken}` }
157
159
  });
158
160
  page += 1;
159
161
  if (res.data && Array.isArray(res.data.items)) {
@@ -161,12 +163,15 @@ class Client {
161
163
  }
162
164
  if (page === 1) {
163
165
  total = res.data.total || 0;
164
- this.log(LoggerLevel.info, '[批量查询记录] 🔍 查询object_name=${object_name}, 接口返回 total:', total);
166
+ this.log(LoggerLevel.info, `[批量查询记录] 🔍 object_name=${object_name}, 接口返回 total: ${total}`);
165
167
  }
168
+ const totalPages = Math.ceil(total / (data.page_size || 100));
169
+ const padLength = String(totalPages).length;
170
+ this.log(LoggerLevel.info, `[批量查询记录] 🔍 [${String(page).padStart(padLength, '0')}/${totalPages}] 接口调用完成`);
171
+ this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询, nextPageToken: ${((_a = res.data) === null || _a === void 0 ? void 0 : _a.next_page_token) || ''}`);
172
+ this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询完成, items.length: ${(_b = res.data.items) === null || _b === void 0 ? void 0 : _b.length}`);
173
+ this.log(LoggerLevel.trace, `[批量查询记录] 🔍 第 ${page} 页查询结果: ${JSON.stringify((_c = res.data) === null || _c === void 0 ? void 0 : _c.items)}`);
166
174
  nextPageToken = res.data.next_page_token;
167
- this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询, nextPageToken: ${nextPageToken || ''}`);
168
- this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询完成, items.length: ${res.data.items.length}`);
169
- this.log(LoggerLevel.trace, `[批量查询记录] 🔍 第 ${page} 页查询结果: ${JSON.stringify(res.data.items)}`);
170
175
  return res;
171
176
  });
172
177
  } while (nextPageToken);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apaas-oapi-client",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "main": "dist/index.js",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
package/src/index.ts CHANGED
@@ -284,13 +284,16 @@ class Client {
284
284
  let total = 0;
285
285
  let page = 0;
286
286
 
287
+ const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records_query`;
288
+
287
289
  do {
288
290
  const pageRes = await functionLimiter(async () => {
289
291
  const mergedData = { ...data, page_token: nextPageToken || '' };
290
292
 
291
- const res = await this.object.search.records({
292
- object_name,
293
- data: mergedData
293
+ await this.ensureTokenValid();
294
+
295
+ const res = await this.axiosInstance.post(url, mergedData, {
296
+ headers: { Authorization: `${this.accessToken}` }
294
297
  });
295
298
 
296
299
  page += 1;
@@ -301,14 +304,19 @@ class Client {
301
304
 
302
305
  if (page === 1) {
303
306
  total = res.data.total || 0;
304
- this.log(LoggerLevel.info, '[批量查询记录] 🔍 查询object_name=${object_name}, 接口返回 total:', total);
307
+ this.log(LoggerLevel.info, `[批量查询记录] 🔍 object_name=${object_name}, 接口返回 total: ${total}`);
305
308
  }
306
309
 
310
+ const totalPages = Math.ceil(total / (data.page_size || 100));
311
+ const padLength = String(totalPages).length;
312
+
313
+ this.log(LoggerLevel.info, `[批量查询记录] 🔍 [${String(page).padStart(padLength, '0')}/${totalPages}] 接口调用完成`);
314
+ this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询, nextPageToken: ${res.data?.next_page_token || ''}`);
315
+ this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询完成, items.length: ${res.data.items?.length}`);
316
+ this.log(LoggerLevel.trace, `[批量查询记录] 🔍 第 ${page} 页查询结果: ${JSON.stringify(res.data?.items)}`);
317
+
307
318
  nextPageToken = res.data.next_page_token;
308
319
 
309
- this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询, nextPageToken: ${nextPageToken || ''}`);
310
- this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询完成, items.length: ${res.data.items.length}`);
311
- this.log(LoggerLevel.trace, `[批量查询记录] 🔍 第 ${page} 页查询结果: ${JSON.stringify(res.data.items)}`);
312
320
  return res;
313
321
  });
314
322
  } while (nextPageToken);