apaas-oapi-client 0.1.16 → 0.1.17

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/UserManual.md CHANGED
@@ -22,9 +22,9 @@ aPaaS 平台有完整的 Open API 能力,但是目前这些能力全都以单
22
22
  - ……
23
23
 
24
24
 
25
- <br>
26
25
 
27
- <br>
26
+
27
+
28
28
 
29
29
  **📦 安装**
30
30
 
@@ -36,7 +36,7 @@ yarn add apaas-oapi-client
36
36
 
37
37
  ***
38
38
 
39
- <br>
39
+
40
40
 
41
41
  # **🚀 快速开始**
42
42
 
@@ -62,7 +62,7 @@ main();
62
62
 
63
63
  ***
64
64
 
65
- <br>
65
+
66
66
 
67
67
  ## **🔐 认证**
68
68
 
@@ -77,7 +77,7 @@ main();
77
77
 
78
78
  ***
79
79
 
80
- <br>
80
+
81
81
 
82
82
  ## **📝 日志等级**
83
83
 
@@ -94,7 +94,27 @@ main();
94
94
 
95
95
  ***
96
96
 
97
- <br>
97
+
98
+
99
+ # 💾 **数据模块**
100
+
101
+ ## **📋 对象列表接口**
102
+
103
+ ### **获取所有对象(数据表)**
104
+
105
+ ```JavaScript
106
+ const res = await client.object.list({
107
+ offset: 0,
108
+ limit: 100,
109
+ filter: {
110
+ type: 'custom',
111
+ quickQuery: 'store'
112
+ }
113
+ });
114
+ console.log(res);
115
+ ```
116
+
117
+ ***
98
118
 
99
119
  ## **🔍 查询接口**
100
120
 
@@ -151,7 +171,7 @@ console.log('Items:', items);
151
171
 
152
172
  ***
153
173
 
154
- <br>
174
+
155
175
 
156
176
 
157
177
  ***
@@ -188,7 +208,7 @@ console.log('Items:', items);
188
208
  ```
189
209
 
190
210
 
191
- <br>
211
+
192
212
  ## **✏️ 更新接口**
193
213
 
194
214
  ### **单条更新**
@@ -221,7 +241,7 @@ console.log(res);
221
241
 
222
242
  ***
223
243
 
224
- <br>
244
+
225
245
 
226
246
  ## **🗑️ 删除接口**
227
247
 
@@ -251,68 +271,220 @@ console.log(res);
251
271
 
252
272
  ***
253
273
 
254
- ## **🛠️ 高级**
255
274
 
256
- ### **获取当前** **token**
275
+
276
+ ## **📊 对象元数据接口**
277
+
278
+ ### **获取指定对象字段元数据**
257
279
 
258
280
  ```JavaScript
259
- console.log(client.token);
281
+ const res = await client.object.metadata.field({
282
+ object_name: '_user',
283
+ field_name: '_id'
284
+ });
285
+ console.log(res);
260
286
  ```
261
287
 
262
- ### **获取当前 namespace**
288
+ ### **获取指定对象所有字段信息**
263
289
 
264
290
  ```JavaScript
265
- console.log(client.currentNamespace);
291
+ const res = await client.object.metadata.fields({
292
+ object_name: 'object_store'
293
+ });
294
+ console.log(res);
266
295
  ```
267
296
 
268
297
  ***
269
298
 
270
- <br>
271
299
 
272
- ## **💡 备注**
273
300
 
274
- - SDK 默认使用 [axios](https://www.npmjs.com/package/axios) 请求。
275
-
276
- - 内置 [bottleneck](https://www.npmjs.com/package/bottleneck) 进行请求限流。
277
-
278
- - 日志打印默认使用 console.log 并带时间戳,可通过 setLoggerLevel 动态控制输出等级。
279
-
301
+ # **📎 附件模块**
302
+
303
+ ## **文件操作**
304
+
305
+ ### **上传文件**
306
+
307
+ ```JavaScript
308
+ const fs = require('fs');
309
+
310
+ const res = await client.attachment.file.upload({
311
+ file: fs.createReadStream('/path/to/file.zip')
312
+ });
313
+ console.log(res);
314
+ // 返回: { code: "0", msg: "success", data: { fileId, type, name, size } }
315
+ ```
316
+
317
+ ### **下载文件**
318
+
319
+ ```JavaScript
320
+ const fileData = await client.attachment.file.download({
321
+ file_id: '625d2f602af94d46972073db32a99ed2'
322
+ });
323
+ // 返回文件二进制流
324
+ ```
325
+
326
+ ### **删除文件**
327
+
328
+ ```JavaScript
329
+ const res = await client.attachment.file.delete({
330
+ file_id: '625d2f602af94d46972073db32a99ed2'
331
+ });
332
+ console.log(res);
333
+ ```
334
+
335
+ ## **头像图片操作**
336
+
337
+ ### **上传头像图片**
338
+
339
+ ```JavaScript
340
+ const fs = require('fs');
341
+
342
+ const res = await client.attachment.avatar.upload({
343
+ image: fs.createReadStream('/path/to/avatar.jpg')
344
+ });
345
+ console.log(res);
346
+ ```
347
+
348
+ ### **下载头像图片**
349
+
350
+ ```JavaScript
351
+ const imageData = await client.attachment.avatar.download({
352
+ image_id: 'c70d03b21d3c40468ee710d984cfb7a8_o'
353
+ });
354
+ // 返回图片二进制流
355
+ ```
280
356
 
281
357
  ***
282
358
 
283
- <br>
284
359
 
285
- <br>
286
360
 
287
- > [aPaaS OAPI Client SDK](https://www.npmjs.com/package/apaas-oapi-client) 提供支持,如有问题请提交 Issue 反馈。
361
+ # **💽 全局数据模块**
362
+
363
+ ## **全局选项**
364
+
365
+ ### **查询全局选项详情**
366
+
367
+ ```JavaScript
368
+ const res = await client.global.options.detail({
369
+ api_name: 'global_option_abc'
370
+ });
371
+ console.log(res);
372
+ ```
373
+
374
+ ### **查询全局选项列表**
375
+
376
+ ```JavaScript
377
+ const res = await client.global.options.list({
378
+ limit: 10,
379
+ offset: 0,
380
+ filter: { quickQuery: 'Sample Text' }
381
+ });
382
+ console.log(res);
383
+ ```
384
+
385
+ ### **分页查询所有全局选项**
386
+
387
+ ```JavaScript
388
+ const { total, items } = await client.global.options.listWithIterator({
389
+ limit: 100,
390
+ filter: { quickQuery: 'Sample Text' }
391
+ });
392
+ console.log('Total:', total);
393
+ console.log('Items:', items);
394
+ ```
395
+
396
+ ## **环境变量**
397
+
398
+ ### **查询环境变量详情**
399
+
400
+ ```JavaScript
401
+ const res = await client.global.variables.detail({
402
+ api_name: 'global_variable_abc'
403
+ });
404
+ console.log(res);
405
+ ```
406
+
407
+ ### **查询环境变量列表**
408
+
409
+ ```JavaScript
410
+ const res = await client.global.variables.list({
411
+ limit: 10,
412
+ offset: 0,
413
+ filter: { quickQuery: 'Sample Text' }
414
+ });
415
+ console.log(res);
416
+ ```
417
+
418
+ ### **分页查询所有环境变量**
419
+
420
+ ```JavaScript
421
+ const { total, items } = await client.global.variables.listWithIterator({
422
+ limit: 100,
423
+ filter: { quickQuery: 'Sample Text' }
424
+ });
425
+ console.log('Total:', total);
426
+ console.log('Items:', items);
427
+ ```
288
428
 
289
- <br>
290
429
  ***
291
430
 
292
- ## **📊 对象元数据接口**
293
431
 
294
- ### **获取指定对象字段元数据**
432
+
433
+ # **📄 页面模块**
434
+
435
+ ### **获取所有页面**
295
436
 
296
437
  ```JavaScript
297
- const res = await client.object.metadata.field({
298
- object_name: '_user',
299
- field_name: '_id'
438
+ const res = await client.page.list({
439
+ limit: 10,
440
+ offset: 0
300
441
  });
301
442
  console.log(res);
302
443
  ```
303
444
 
304
- ### **获取指定对象所有字段信息**
445
+ ### **分页查询所有页面**
305
446
 
306
447
  ```JavaScript
307
- const res = await client.object.metadata.fields({
308
- object_name: 'object_store'
448
+ const { total, items } = await client.page.listWithIterator({
449
+ limit: 100
450
+ });
451
+ console.log('Total:', total);
452
+ console.log('Items:', items);
453
+ ```
454
+
455
+ ### **获取页面详情**
456
+
457
+ ```JavaScript
458
+ const res = await client.page.detail({
459
+ page_id: 'appPage_aadd64dlqamdo'
309
460
  });
310
461
  console.log(res);
311
462
  ```
312
463
 
464
+ ### **获取页面访问地址**
465
+
466
+ ```JavaScript
467
+ const res = await client.page.url({
468
+ page_id: 'appPage_aadd64dlqamdo',
469
+ pageParams: { var_EzpvJsER: '1234567890' },
470
+ parentPageParams: {
471
+ navId: 'aadd64bapmic2',
472
+ pageApiName: 'page_aaddmtkqgicbg'
473
+ },
474
+ navId: 'aadd64bapmic2',
475
+ tabId: 'tab_legqch3h'
476
+ });
477
+ console.log(res);
478
+ // 返回: { code: "0", msg: "success", data: { link: "https://..." } }
479
+ ```
480
+
313
481
  ***
314
482
 
315
- ## **🏢 部门 ID 交换**
483
+
484
+
485
+ # **🏢 部门模块**
486
+
487
+ ## **部门 ID 交换**
316
488
 
317
489
  ### **单个部门 ID 交换**
318
490
 
@@ -338,7 +510,9 @@ console.log(res);
338
510
 
339
511
  ***
340
512
 
341
- ## **☁️ 云函数调用**
513
+
514
+
515
+ # **☁️ 云函数模块**
342
516
 
343
517
  ```JavaScript
344
518
  const res = await client.function.invoke({
@@ -348,4 +522,47 @@ const res = await client.function.invoke({
348
522
  console.log(res);
349
523
  ```
350
524
 
525
+ ***
526
+
527
+
528
+
529
+ ## **🛠️ 高级**
530
+
531
+ ### **获取当前 token**
532
+
533
+ ```JavaScript
534
+ console.log(client.token);
535
+ ```
536
+
537
+ ### **获取 token 过期时间**
538
+
539
+ ```JavaScript
540
+ console.log(client.tokenExpireTime); // 返回剩余秒数
541
+ ```
542
+
543
+ ### **获取当前 namespace**
544
+
545
+ ```JavaScript
546
+ console.log(client.currentNamespace);
547
+ ```
548
+
549
+ ***
550
+
551
+
552
+
553
+ ## **💡 备注**
554
+
555
+ - 本 SDK 默认使用 [axios](https://www.npmjs.com/package/axios) 请求。
556
+
557
+ - 内置 [bottleneck](https://www.npmjs.com/package/bottleneck) 进行请求限流。
558
+
559
+ - 日志打印默认使用 console.log 并带时间戳,可通过 setLoggerLevel 动态控制输出等级。
560
+
561
+
562
+ ***
563
+
564
+
565
+
566
+ > 由 [aPaaS OAPI Client SDK](https://www.npmjs.com/package/apaas-oapi-client) 提供支持,如有问题请提交 Issue 反馈。
567
+
351
568
  ---
package/dist/index.d.ts CHANGED
@@ -277,6 +277,192 @@ declare class Client {
277
277
  params: any;
278
278
  }) => Promise<any>;
279
279
  };
280
+ /**
281
+ * 页面模块
282
+ */
283
+ page: {
284
+ /**
285
+ * 获取所有页面
286
+ * @param params 请求参数 { limit: number (max 200), offset: number }
287
+ * @returns 接口返回结果
288
+ */
289
+ list: (params: {
290
+ limit: number;
291
+ offset: number;
292
+ }) => Promise<any>;
293
+ /**
294
+ * 获取所有页面 - 支持自动分页,获取全部数据
295
+ * @description 该方法会自动处理分页,直到获取所有页面数据
296
+ * @param params 请求参数 { limit?: number }
297
+ * @returns { total, items }
298
+ */
299
+ listWithIterator: (params?: {
300
+ limit?: number;
301
+ }) => Promise<{
302
+ total: number;
303
+ items: any[];
304
+ }>;
305
+ /**
306
+ * 获取页面详情
307
+ * @param params 请求参数 { page_id: string }
308
+ * @returns 接口返回结果
309
+ */
310
+ detail: (params: {
311
+ page_id: string;
312
+ }) => Promise<any>;
313
+ /**
314
+ * 获取页面访问地址
315
+ * @param params 请求参数 { page_id: string, pageParams?: any, parentPageParams?: any, navId?: string, tabId?: string }
316
+ * @returns 接口返回结果
317
+ */
318
+ url: (params: {
319
+ page_id: string;
320
+ pageParams?: any;
321
+ parentPageParams?: any;
322
+ navId?: string;
323
+ tabId?: string;
324
+ }) => Promise<any>;
325
+ };
326
+ /**
327
+ * 附件模块
328
+ */
329
+ attachment: {
330
+ /**
331
+ * 文件操作
332
+ */
333
+ file: {
334
+ /**
335
+ * 上传文件
336
+ * @param params 请求参数 { file: any }
337
+ * @returns 接口返回结果
338
+ */
339
+ upload: (params: {
340
+ file: any;
341
+ }) => Promise<any>;
342
+ /**
343
+ * 下载文件
344
+ * @param params 请求参数 { file_id: string }
345
+ * @returns 文件二进制流
346
+ */
347
+ download: (params: {
348
+ file_id: string;
349
+ }) => Promise<any>;
350
+ /**
351
+ * 删除文件
352
+ * @param params 请求参数 { file_id: string }
353
+ * @returns 接口返回结果
354
+ */
355
+ delete: (params: {
356
+ file_id: string;
357
+ }) => Promise<any>;
358
+ };
359
+ /**
360
+ * 头像图片操作
361
+ */
362
+ avatar: {
363
+ /**
364
+ * 上传头像图片
365
+ * @param params 请求参数 { image: any }
366
+ * @returns 接口返回结果
367
+ */
368
+ upload: (params: {
369
+ image: any;
370
+ }) => Promise<any>;
371
+ /**
372
+ * 下载头像图片
373
+ * @param params 请求参数 { image_id: string }
374
+ * @returns 图片二进制流
375
+ */
376
+ download: (params: {
377
+ image_id: string;
378
+ }) => Promise<any>;
379
+ };
380
+ };
381
+ /**
382
+ * 全局数据模块
383
+ */
384
+ global: {
385
+ /**
386
+ * 全局选项
387
+ */
388
+ options: {
389
+ /**
390
+ * 查询全局选项详情
391
+ * @param params 请求参数 { api_name: string }
392
+ * @returns 接口返回结果
393
+ */
394
+ detail: (params: {
395
+ api_name: string;
396
+ }) => Promise<any>;
397
+ /**
398
+ * 查询全局选项列表
399
+ * @param params 请求参数 { limit: number, offset: number, filter?: { quickQuery?: string } }
400
+ * @returns 接口返回结果
401
+ */
402
+ list: (params: {
403
+ limit: number;
404
+ offset: number;
405
+ filter?: {
406
+ quickQuery?: string;
407
+ };
408
+ }) => Promise<any>;
409
+ /**
410
+ * 查询所有全局选项 - 支持自动分页,获取全部数据
411
+ * @description 该方法会自动处理分页,直到获取所有全局选项数据
412
+ * @param params 请求参数 { limit?: number, filter?: { quickQuery?: string } }
413
+ * @returns { total, items }
414
+ */
415
+ listWithIterator: (params?: {
416
+ limit?: number;
417
+ filter?: {
418
+ quickQuery?: string;
419
+ };
420
+ }) => Promise<{
421
+ total: number;
422
+ items: any[];
423
+ }>;
424
+ };
425
+ /**
426
+ * 环境变量
427
+ */
428
+ variables: {
429
+ /**
430
+ * 查询环境变量详情
431
+ * @param params 请求参数 { api_name: string }
432
+ * @returns 接口返回结果
433
+ */
434
+ detail: (params: {
435
+ api_name: string;
436
+ }) => Promise<any>;
437
+ /**
438
+ * 查询环境变量列表
439
+ * @param params 请求参数 { limit: number, offset: number, filter?: { quickQuery?: string } }
440
+ * @returns 接口返回结果
441
+ */
442
+ list: (params: {
443
+ limit: number;
444
+ offset: number;
445
+ filter?: {
446
+ quickQuery?: string;
447
+ };
448
+ }) => Promise<any>;
449
+ /**
450
+ * 查询所有环境变量 - 支持自动分页,获取全部数据
451
+ * @description 该方法会自动处理分页,直到获取所有环境变量数据
452
+ * @param params 请求参数 { limit?: number, filter?: { quickQuery?: string } }
453
+ * @returns { total, items }
454
+ */
455
+ listWithIterator: (params?: {
456
+ limit?: number;
457
+ filter?: {
458
+ quickQuery?: string;
459
+ };
460
+ }) => Promise<{
461
+ total: number;
462
+ items: any[];
463
+ }>;
464
+ };
465
+ };
280
466
  }
281
467
  export declare const apaas: {
282
468
  Client: typeof Client;