apaas-oapi-client 0.1.4 → 0.1.8

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
@@ -2,7 +2,6 @@
2
2
 
3
3
  var dayjs = require('dayjs');
4
4
  var axios = require('axios');
5
- var Bottleneck = require('bottleneck');
6
5
 
7
6
  /**
8
7
  * 日志等级枚举
@@ -17,32 +16,7 @@ var LoggerLevel;
17
16
  LoggerLevel[LoggerLevel["trace"] = 5] = "trace";
18
17
  })(LoggerLevel || (LoggerLevel = {}));
19
18
 
20
- /**
21
- * 默认 apaas 限流配置
22
- */
23
- const apaasLimiterOptions = {
24
- minTime: 200, // 每秒最多发起 5 个数据库操作
25
- reservoir: 20, // 最多同时查询 50 个数据库操作
26
- reservoirRefreshAmount: 20, // 每次查询完毕后,重置为 50 个数据库操作
27
- reservoirRefreshInterval: 1000 // 重置时间间隔为 1 秒
28
- };
29
- /**
30
- * 创建限流器
31
- * @param fn 被限流函数
32
- * @param options 自定义限流配置
33
- * @returns 包装后的限流函数
34
- */
35
- async function functionLimiter(fn, options = {}) {
36
- const limiter = new Bottleneck({
37
- minTime: options.minTime || apaasLimiterOptions.minTime,
38
- reservoir: options.reservoir || apaasLimiterOptions.reservoir,
39
- reservoirRefreshAmount: options.reservoirRefreshAmount || apaasLimiterOptions.reservoirRefreshAmount,
40
- reservoirRefreshInterval: options.reservoirRefreshInterval || apaasLimiterOptions.reservoirRefreshInterval
41
- });
42
- const wrapped = limiter.wrap(fn);
43
- return wrapped();
44
- }
45
-
19
+ const { functionLimiter } = require('./limiter');
46
20
  /**
47
21
  * aPaaS OpenAPI 客户端
48
22
  */
@@ -59,6 +33,42 @@ class Client {
59
33
  * 对象模块
60
34
  */
61
35
  this.object = {
36
+ metadata: {
37
+ /**
38
+ * 获取指定对象下指定字段的元数据
39
+ * @param params 请求参数 { object_name, field_name }
40
+ * @returns 接口返回结果
41
+ */
42
+ field: async (params) => {
43
+ const { object_name, field_name } = params;
44
+ await this.ensureTokenValid();
45
+ const url = `/api/data/v1/namespaces/${this.namespace}/meta/objects/${object_name}/fields/${field_name}`;
46
+ this.log(LoggerLevel.debug, `[对象字段查询] 📄 开始获取字段元数据 object_name=${object_name}, field_name=${field_name}`);
47
+ const res = await this.axiosInstance.get(url, {
48
+ headers: { Authorization: `${this.accessToken}` }
49
+ });
50
+ this.log(LoggerLevel.debug, `[对象字段查询] 📄 调用完成,返回状态=${res.data.code}`);
51
+ this.log(LoggerLevel.trace, `[对象字段查询] 📄 调用完成,返回信息=${JSON.stringify(res.data)}`);
52
+ return res.data;
53
+ },
54
+ /**
55
+ * 获取指定对象的所有字段信息
56
+ * @param params 请求参数 { object_name }
57
+ * @returns 接口返回结果
58
+ */
59
+ fields: async (params) => {
60
+ const { object_name } = params;
61
+ await this.ensureTokenValid();
62
+ const url = `/api/data/v1/namespaces/${this.namespace}/meta/objects/${object_name}`;
63
+ this.log(LoggerLevel.debug, `[对象字段查询] 📄 开始获取对象字段元数据 object_name=${object_name}`);
64
+ const res = await this.axiosInstance.get(url, {
65
+ headers: { Authorization: `${this.accessToken}` }
66
+ });
67
+ this.log(LoggerLevel.debug, `[对象字段查询] 📄 调用完成,返回状态=${res.data.code}`);
68
+ this.log(LoggerLevel.trace, `[对象字段查询] 📄 调用完成,返回信息=${JSON.stringify(res.data)}`);
69
+ return res.data;
70
+ }
71
+ },
62
72
  search: {
63
73
  /**
64
74
  * 单条记录查询
@@ -72,7 +82,8 @@ class Client {
72
82
  const res = await functionLimiter(async () => {
73
83
  await this.ensureTokenValid();
74
84
  const response = await this.axiosInstance.post(url, { select }, { headers: { Authorization: `${this.accessToken}` } });
75
- this.log(LoggerLevel.info, `[单条查询记录] 🔍 record_id: ${record_id} 查询完成,返回 code: ${response.data.code}`);
85
+ this.log(LoggerLevel.debug, `[单条查询记录] 🔍 查询 record_id: ${record_id} 调用完成,返回状态: ${response.data.code}`);
86
+ this.log(LoggerLevel.trace, `[单条查询记录] 🔍 查询 record_id: ${record_id} 调用完成,返回信息: ${JSON.stringify(response.data)}`);
76
87
  return response.data;
77
88
  });
78
89
  return res;
@@ -83,13 +94,16 @@ class Client {
83
94
  * @returns 接口返回结果
84
95
  */
85
96
  records: async (params) => {
97
+ var _a, _b;
86
98
  const { object_name, data } = params;
87
99
  await this.ensureTokenValid();
88
100
  const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records_query`;
89
101
  const res = await this.axiosInstance.post(url, data, {
90
102
  headers: { Authorization: `${this.accessToken}` }
91
103
  });
92
- this.log(LoggerLevel.debug, `[批量查询记录] 🔍 records_query 调用完成,object_name: ${object_name}`);
104
+ this.log(LoggerLevel.info, `[批量查询记录] 🔍 接口调用完成`);
105
+ this.log(LoggerLevel.debug, `[批量查询记录] 🔍 调用完成,返回状态: ${res.data.code},返回数据总数${((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.total) || 'unknown'}`);
106
+ this.log(LoggerLevel.trace, `[批量查询记录] 🔍 调用完成,返回信息: ${JSON.stringify(res.data)}`);
93
107
  return res.data;
94
108
  },
95
109
  /**
@@ -119,13 +133,92 @@ class Client {
119
133
  this.log(LoggerLevel.info, '[批量查询记录] 🔍 接口返回 total:', total);
120
134
  }
121
135
  nextPageToken = res.data.next_page_token;
136
+ this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询,nextPageToken: ${nextPageToken || ''}`);
122
137
  this.log(LoggerLevel.debug, `[批量查询记录] 🔍 第 ${page} 页查询完成,items.length: ${res.data.items.length}`);
138
+ this.log(LoggerLevel.trace, `[批量查询记录] 🔍 第 ${page} 页查询结果: ${JSON.stringify(res.data.items)}`);
123
139
  return res;
124
140
  });
125
141
  } while (nextPageToken);
126
142
  return { total, items: results };
127
143
  }
128
144
  },
145
+ create: {
146
+ /**
147
+ * 单条记录创建
148
+ * @param params 请求参数 { object_name, record }
149
+ * @returns 接口返回结果
150
+ */
151
+ record: async (params) => {
152
+ const { object_name, record } = params;
153
+ const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records`;
154
+ this.log(LoggerLevel.info, `[单条创建记录] ➕ 开始向对象 ${object_name} 创建记录`);
155
+ const res = await functionLimiter(async () => {
156
+ await this.ensureTokenValid();
157
+ const response = await this.axiosInstance.post(url, { record }, {
158
+ headers: { Authorization: `${this.accessToken}` }
159
+ });
160
+ this.log(LoggerLevel.info, `[单条创建记录] ➕ 向对象 ${object_name} 内创建记录,调用完成`);
161
+ this.log(LoggerLevel.debug, `[单条创建记录] ➕ 向对象 ${object_name} 内创建数据,调用完成,返回状态: ${response.data.code}`);
162
+ this.log(LoggerLevel.trace, `[单条创建记录] ➕ 向对象 ${object_name} 内创建数据,调用完成,返回信息: ${JSON.stringify(response.data)}`);
163
+ return response.data;
164
+ });
165
+ return res;
166
+ },
167
+ /**
168
+ * 批量创建记录
169
+ * @param params 请求参数 { object_name, records }
170
+ * @returns 接口返回结果
171
+ */
172
+ records: async (params) => {
173
+ const { object_name, records } = params;
174
+ await this.ensureTokenValid();
175
+ const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records_batch`;
176
+ const res = await this.axiosInstance.post(url, { records }, {
177
+ headers: { Authorization: `${this.accessToken}` }
178
+ });
179
+ this.log(LoggerLevel.info, `[批量创建记录] ➕ 开始向对象 ${object_name} 批量创建记录`);
180
+ this.log(LoggerLevel.debug, `[批量创建记录] ➕ 向对象 ${object_name} 批量创建记录,调用完成,返回状态: ${res.data.code}`);
181
+ this.log(LoggerLevel.trace, `[批量创建记录] ➕ 向对象 ${object_name} 批量创建记录,调用完成,返回信息: ${JSON.stringify(res.data)}`);
182
+ return res.data;
183
+ },
184
+ /**
185
+ * 分批创建所有记录
186
+ * @param params 请求参数 { object_name, records }
187
+ * @returns { total, items }
188
+ */
189
+ recordsWithIterator: async (params) => {
190
+ const { object_name, records } = params;
191
+ let results = [];
192
+ let total = records.length;
193
+ const chunkSize = 100;
194
+ let page = 0;
195
+ const chunks = [];
196
+ for (let i = 0; i < records.length; i += chunkSize) {
197
+ chunks.push(records.slice(i, i + chunkSize));
198
+ }
199
+ this.log(LoggerLevel.debug, `[批量创建记录] ➕ 总共 ${records.length} 条记录,拆分为 ${chunks.length} 组,每组最多 ${chunkSize} 条`);
200
+ this.log(LoggerLevel.trace, `[批量创建记录] ➕ 总共 ${records.length} 条记录,拆分为 ${chunks.length} 组,每组最多 ${chunkSize} 条`);
201
+ for (const [index, chunk] of chunks.entries()) {
202
+ page += 1;
203
+ this.log(LoggerLevel.debug, `[批量创建记录] ➕ 开始创建第 ${index + 1} 组,共 ${chunk.length} 条`);
204
+ this.log(LoggerLevel.trace, `[批量创建记录] ➕ 开始创建第 ${index + 1} 组,共 ${chunk.length} 条`);
205
+ await functionLimiter(async () => {
206
+ const res = await this.object.create.records({
207
+ object_name,
208
+ records: chunk
209
+ });
210
+ if (res.data && Array.isArray(res.data.items)) {
211
+ results = results.concat(res.data.items);
212
+ }
213
+ this.log(LoggerLevel.info, `[批量创建记录] ➕ 创建第 ${page} 页数据,调用完成,创建数量: ${res.data.items.length}`);
214
+ this.log(LoggerLevel.debug, `[批量创建记录] ➕ 创建第 ${page} 页页数据,调用完成,返回状态: ${res.data.code}`);
215
+ this.log(LoggerLevel.trace, `[批量创建记录] ➕ 创建第 ${page} 页页数据,调用结果: ${JSON.stringify(res.data.items)}`);
216
+ return res;
217
+ });
218
+ }
219
+ return { total, items: results };
220
+ }
221
+ },
129
222
  update: {
130
223
  /**
131
224
  * 单条更新
@@ -139,7 +232,9 @@ class Client {
139
232
  const res = await functionLimiter(async () => {
140
233
  await this.ensureTokenValid();
141
234
  const response = await this.axiosInstance.patch(url, { record }, { headers: { Authorization: `${this.accessToken}` } });
142
- this.log(LoggerLevel.info, `[单条更新记录] 💾 record_id: ${record_id} 更新完成,返回 code: ${response.data.code}`);
235
+ this.log(LoggerLevel.info, `[单条更新记录] 💾 更新 record_id: ${record_id} 调用完成`);
236
+ this.log(LoggerLevel.debug, `[单条更新记录] 💾 更新 record_id: ${record_id} 调用完成,返回状态: ${response.data.code}`);
237
+ this.log(LoggerLevel.trace, `[单条更新记录] 💾 更新 record_id: ${record_id} 调用完成,返回信息: ${JSON.stringify(response.data)}`);
143
238
  return response.data;
144
239
  });
145
240
  return res;
@@ -157,14 +252,17 @@ class Client {
157
252
  for (let i = 0; i < records.length; i += chunkSize) {
158
253
  chunks.push(records.slice(i, i + chunkSize));
159
254
  }
160
- this.log(LoggerLevel.info, `[批量更新记录] 💾 总共 ${records.length} 条记录,拆分为 ${chunks.length} 组,每组最多 ${chunkSize} 条`);
255
+ this.log(LoggerLevel.debug, `[批量更新记录] 💾 总共 ${records.length} 条记录,拆分为 ${chunks.length} 组,每组最多 ${chunkSize} 条`);
256
+ this.log(LoggerLevel.trace, `[批量更新记录] 💾 总共 ${records.length} 条记录,拆分为 ${chunks.length} 组,每组最多 ${chunkSize} 条`);
161
257
  const results = [];
162
258
  for (const [index, chunk] of chunks.entries()) {
163
- this.log(LoggerLevel.info, `[批量更新记录] 💾 开始更新第 ${index + 1} 组,共 ${chunk.length} 条`);
259
+ this.log(LoggerLevel.debug, `[批量更新记录] 💾 开始更新第 ${index + 1} 组,共 ${chunk.length} 条`);
260
+ this.log(LoggerLevel.trace, `[批量更新记录] 💾 开始更新第 ${index + 1} 组,共 ${chunk.length} 条`);
164
261
  const res = await functionLimiter(async () => {
165
262
  await this.ensureTokenValid();
166
263
  const response = await this.axiosInstance.patch(url, { records: chunk }, { headers: { Authorization: `${this.accessToken}` } });
167
- this.log(LoggerLevel.info, `[批量更新记录] 💾 ${index + 1} 组更新完成,返回 code: ${response.data.code}`);
264
+ this.log(LoggerLevel.debug, `[批量更新记录] 💾 更新第 ${index + 1} 组调用完成,返回状态: ${JSON.stringify(response.data)}`);
265
+ this.log(LoggerLevel.trace, `[批量更新记录] 💾 更新第 ${index + 1} 组调用完成,返回信息: ${response.data}`);
168
266
  return response.data;
169
267
  });
170
268
  results.push(res);
@@ -181,13 +279,13 @@ class Client {
181
279
  record: async (params) => {
182
280
  const { object_name, record_id } = params;
183
281
  const url = `/v1/data/namespaces/${this.namespace}/objects/${object_name}/records/${record_id}`;
184
- this.log(LoggerLevel.info, `[单条删除记录] 🗑️ 开始删除 record_id: ${record_id}`);
282
+ this.log(LoggerLevel.trace, `[单条删除记录] 🗑️ 开始删除 record_id: ${record_id}`);
185
283
  const res = await functionLimiter(async () => {
186
284
  await this.ensureTokenValid();
187
285
  const response = await this.axiosInstance.delete(url, {
188
286
  headers: { Authorization: `${this.accessToken}` }
189
287
  });
190
- this.log(LoggerLevel.info, `[单条删除记录] 🗑️ record_id: ${record_id} 删除完成,返回 code: ${response.data.code}`);
288
+ this.log(LoggerLevel.info, `[单条删除记录] 🗑️ 删除 record_id: ${record_id} 调用完成,返回信息: ${JSON.stringify(response.data)}`);
191
289
  return response.data;
192
290
  });
193
291
  return res;
@@ -205,7 +303,7 @@ class Client {
205
303
  for (let i = 0; i < ids.length; i += chunkSize) {
206
304
  chunks.push(ids.slice(i, i + chunkSize));
207
305
  }
208
- this.log(LoggerLevel.info, `[批量删除记录] 🗑️ 总共 ${ids.length} 条记录,拆分为 ${chunks.length} 组,每组最多 ${chunkSize} 条`);
306
+ this.log(LoggerLevel.debug, `[批量删除记录] 🗑️ 总共 ${ids.length} 条记录,拆分为 ${chunks.length} 组,每组最多 ${chunkSize} 条`);
209
307
  const results = [];
210
308
  for (const [index, chunk] of chunks.entries()) {
211
309
  this.log(LoggerLevel.info, `[批量删除记录] 🗑️ 开始删除第 ${index + 1} 组,共 ${chunk.length} 条`);
@@ -215,7 +313,8 @@ class Client {
215
313
  headers: { Authorization: `${this.accessToken}` },
216
314
  data: { ids: chunk }
217
315
  });
218
- this.log(LoggerLevel.info, `[批量删除记录] 🗑️ 第 ${index + 1} 组删除完成,返回 code: ${response.data.code}`);
316
+ this.log(LoggerLevel.debug, `[批量删除记录] 🗑️ 第 ${index + 1} 组删除完成,返回状态: ${response.data.code}`);
317
+ this.log(LoggerLevel.trace, `[批量删除记录] 🗑️ 第 ${index + 1} 组删除完成,返回信息: ${JSON.stringify(response.data)}`);
219
318
  return response.data;
220
319
  });
221
320
  results.push(res);
@@ -224,6 +323,100 @@ class Client {
224
323
  }
225
324
  }
226
325
  };
326
+ /**
327
+ * 部门 ID 交换模块
328
+ */
329
+ this.department = {
330
+ /**
331
+ * 单个部门 ID 交换
332
+ * @param params 请求参数
333
+ * @returns 单个部门映射结果
334
+ */
335
+ exchange: async (params) => {
336
+ const { department_id_type, department_id } = params;
337
+ // department_id_type 可选值:
338
+ // - 'department_id' (如 "1758534140403815")
339
+ // - 'external_department_id' (外部平台 department_id,无固定格式)
340
+ // - 'external_open_department_id' (以 'oc_' 开头的 open_department_id)
341
+ const url = '/api/integration/v2/feishu/getDepartments';
342
+ this.log(LoggerLevel.info, `[部门ID交换] 🔄 开始交换单个部门 ID: ${department_id}`);
343
+ const res = await functionLimiter(async () => {
344
+ await this.ensureTokenValid();
345
+ const response = await this.axiosInstance.post(url, {
346
+ department_id_type,
347
+ department_ids: [department_id]
348
+ }, {
349
+ headers: { Authorization: `${this.accessToken}` }
350
+ });
351
+ this.log(LoggerLevel.debug, `[部门ID交换] 🔄 交换部门 ID: ${department_id} 调用完成,返回状态: ${response.data.code}`);
352
+ this.log(LoggerLevel.debug, `[部门ID交换] 🔄 交换部门 ID: ${department_id} 调用完成,返回信息: ${JSON.stringify(response.data)}`);
353
+ return response.data.data[0]; // 返回第一个元素
354
+ });
355
+ return res;
356
+ },
357
+ /**
358
+ * 批量部门 ID 交换
359
+ * @param params 请求参数
360
+ * @returns 所有子请求的返回结果数组
361
+ */
362
+ batchExchange: async (params) => {
363
+ const { department_id_type, department_ids } = params;
364
+ // department_id_type 可选值:
365
+ // - 'department_id' (如 "1758534140403815")
366
+ // - 'external_department_id' (外部平台 department_id,无固定格式)
367
+ // - 'external_open_department_id' (以 'oc_' 开头的 open_department_id)
368
+ const url = '/api/integration/v2/feishu/getDepartments';
369
+ const chunkSize = 100;
370
+ const chunks = [];
371
+ for (let i = 0; i < department_ids.length; i += chunkSize) {
372
+ chunks.push(department_ids.slice(i, i + chunkSize));
373
+ }
374
+ this.log(LoggerLevel.info, `[批量部门ID交换] 🔄 总共 ${department_ids.length} 个部门 ID,拆分为 ${chunks.length} 组,每组最多 ${chunkSize} 个`);
375
+ const results = [];
376
+ for (const [index, chunk] of chunks.entries()) {
377
+ this.log(LoggerLevel.info, `[批量部门ID交换] 🔄 开始交换第 ${index + 1} 组,共 ${chunk.length} 个`);
378
+ const res = await functionLimiter(async () => {
379
+ await this.ensureTokenValid();
380
+ const response = await this.axiosInstance.post(url, {
381
+ department_id_type,
382
+ department_ids: chunk
383
+ }, {
384
+ headers: { Authorization: `${this.accessToken}` }
385
+ });
386
+ this.log(LoggerLevel.debug, `[批量部门ID交换] 🔄 交换第 ${index + 1} 组调用完成,返回状态: ${response.data.code}`);
387
+ this.log(LoggerLevel.trace, `[批量部门ID交换] 🔄 交换第 ${index + 1} 组调用完成,返回信息: ${JSON.stringify(response.data)}`);
388
+ return response.data.data;
389
+ });
390
+ results.push(...res);
391
+ }
392
+ return results;
393
+ }
394
+ };
395
+ /**
396
+ * 云函数模块
397
+ */
398
+ this.function = {
399
+ /**
400
+ * 调用云函数
401
+ * @param params 请求参数 { name: string; params: any }
402
+ * @returns 接口返回结果
403
+ */
404
+ invoke: async (params) => {
405
+ const { name, params: functionParams } = params;
406
+ await this.ensureTokenValid();
407
+ const url = `/api/cloudfunction/v1/namespaces/${this.namespace}/invoke/${name}`;
408
+ this.log(LoggerLevel.info, `[调用云函数] ☁️ 云函数 ${name} 开始调用`);
409
+ const res = await this.axiosInstance.post(url, { params: functionParams }, {
410
+ headers: {
411
+ Authorization: `${this.accessToken}`,
412
+ 'Content-Type': 'application/json'
413
+ }
414
+ });
415
+ this.log(LoggerLevel.debug, `[调用云函数] ☁️ 云函数 ${name} 调用完成,返回状态: code=${res.data.code}`);
416
+ this.log(LoggerLevel.trace, `[调用云函数] ☁️ 云函数 ${name} 调用完成,返回信息: code=${JSON.stringify(res.data)}`);
417
+ return res.data;
418
+ }
419
+ };
227
420
  this.clientId = options.clientId;
228
421
  this.clientSecret = options.clientSecret;
229
422
  this.namespace = options.namespace;
@@ -232,7 +425,7 @@ class Client {
232
425
  baseURL: 'https://ae-openapi.feishu.cn',
233
426
  headers: { 'Content-Type': 'application/json' }
234
427
  });
235
- this.log(LoggerLevel.info, 'client initialized');
428
+ this.log(LoggerLevel.info, '[client] initialized');
236
429
  }
237
430
  /**
238
431
  * 设置日志等级
@@ -240,7 +433,7 @@ class Client {
240
433
  */
241
434
  setLoggerLevel(level) {
242
435
  this.loggerLevel = level;
243
- this.log(LoggerLevel.info, `logger level set to ${LoggerLevel[level]}`);
436
+ this.log(LoggerLevel.info, `[logger] logger level set to ${LoggerLevel[level]}`);
244
437
  }
245
438
  /**
246
439
  * 日志打印方法
@@ -259,7 +452,7 @@ class Client {
259
452
  */
260
453
  async init() {
261
454
  await this.ensureTokenValid();
262
- this.log(LoggerLevel.info, 'client ready');
455
+ this.log(LoggerLevel.info, '[client] ready');
263
456
  }
264
457
  /**
265
458
  * 获取 accessToken
@@ -271,30 +464,30 @@ class Client {
271
464
  clientSecret: this.clientSecret
272
465
  });
273
466
  if (res.data.code !== '0') {
274
- this.log(LoggerLevel.error, `[获取认证] 获取 accessToken 失败: ${res.data.msg}`);
467
+ this.log(LoggerLevel.error, `[fetch token] 获取 accessToken 失败: ${res.data.msg}`);
275
468
  throw new Error(`获取 accessToken 失败: ${res.data.msg}`);
276
469
  }
277
470
  this.accessToken = res.data.data.accessToken;
278
471
  this.expireTime = res.data.data.expireTime;
279
- this.log(LoggerLevel.info, '[获取认证] accessToken refreshed');
472
+ this.log(LoggerLevel.info, '[client] token refreshed');
280
473
  }
281
474
  /**
282
475
  * 确保 token 有效,若过期则刷新
283
476
  */
284
477
  async ensureTokenValid() {
285
478
  if (this.disableTokenCache) {
286
- this.log(LoggerLevel.debug, '[获取认证] token cache disabled, refreshing token');
479
+ this.log(LoggerLevel.debug, '[client] token cache disabled, refreshing token');
287
480
  await this.getAccessToken();
288
481
  return;
289
482
  }
290
483
  if (!this.accessToken || !this.expireTime) {
291
- this.log(LoggerLevel.debug, '[获取认证] no token cached, fetching new token');
484
+ this.log(LoggerLevel.debug, '[client] no token cached, fetching new token');
292
485
  await this.getAccessToken();
293
486
  return;
294
487
  }
295
488
  const now = dayjs().valueOf();
296
489
  if (now + 60 * 1000 > this.expireTime) {
297
- this.log(LoggerLevel.debug, '[获取认证] token expired, refreshing');
490
+ this.log(LoggerLevel.debug, '[client] token expired, refreshing');
298
491
  await this.getAccessToken();
299
492
  }
300
493
  }
@@ -308,7 +501,7 @@ class Client {
308
501
  * 获取当前 namespace
309
502
  */
310
503
  get currentNamespace() {
311
- this.log(LoggerLevel.debug, `[获取命名空间] 当前命名空间: ${this.namespace}`);
504
+ this.log(LoggerLevel.debug, `🏷️ [获取命名空间] 当前命名空间: ${this.namespace}`);
312
505
  return this.namespace;
313
506
  }
314
507
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "apaas-oapi-client",
3
- "version": "0.1.4",
3
+ "version": "0.1.8",
4
+ "main": "dist/index.js",
4
5
  "exports": {
5
- "./node-sdk": "./dist/index.js",
6
- ".": "./dist/index.js"
6
+ ".": "./dist/index.js",
7
+ "./node-sdk": "./dist/index.js"
7
8
  },
8
- "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
10
10
  "type": "commonjs",
11
11
  "scripts": {