apaas-oapi-client 0.1.17 β 0.1.18
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 +47 -1
- package/dist/index.d.ts +43 -0
- package/dist/index.js +68 -0
- package/package.json +1 -1
- package/src/index.ts +92 -0
package/UserManual.md
CHANGED
|
@@ -510,7 +510,53 @@ console.log(res);
|
|
|
510
510
|
|
|
511
511
|
***
|
|
512
512
|
|
|
513
|
+
<br>
|
|
513
514
|
|
|
515
|
+
# **π θͺε¨εζ΅η¨ζ¨‘ε**
|
|
516
|
+
|
|
517
|
+
## **V1 ηζ¬ - ζ§θ‘ζ΅η¨**
|
|
518
|
+
|
|
519
|
+
```JavaScript
|
|
520
|
+
const res = await client.automation.v1.execute({
|
|
521
|
+
flow_api_name: 'automation_cd05fdab67d',
|
|
522
|
+
operator: {
|
|
523
|
+
_id: 100,
|
|
524
|
+
email: 'sample@feishu.cn'
|
|
525
|
+
},
|
|
526
|
+
params: {
|
|
527
|
+
varRecord_ab67d031d44: {
|
|
528
|
+
_id: 100
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
console.log(res);
|
|
533
|
+
// θΏε: { code: "0", msg: "success", data: { errMsg, executionId, status, data, errCode } }
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
## **V2 ηζ¬ - ζ§θ‘ζ΅η¨**
|
|
537
|
+
|
|
538
|
+
V2 ηζ¬ζ―ζζ΅η¨ιζ°ζδΊ€εθ½γ
|
|
539
|
+
|
|
540
|
+
```JavaScript
|
|
541
|
+
const res = await client.automation.v2.execute({
|
|
542
|
+
flow_api_name: 'automation_a9ec6ee5fb1',
|
|
543
|
+
operator: {
|
|
544
|
+
_id: 100,
|
|
545
|
+
email: 'sample@feishu.cn'
|
|
546
|
+
},
|
|
547
|
+
params: {
|
|
548
|
+
storeId: 100
|
|
549
|
+
},
|
|
550
|
+
is_resubmit: true,
|
|
551
|
+
pre_instance_id: '1835957428957195'
|
|
552
|
+
});
|
|
553
|
+
console.log(res);
|
|
554
|
+
// θΏε: { code: "0", msg: "success", data: { errMsg, executionId, status, data, errCode } }
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
***
|
|
558
|
+
|
|
559
|
+
<br>
|
|
514
560
|
|
|
515
561
|
# **βοΈ δΊε½ζ°ζ¨‘ε**
|
|
516
562
|
|
|
@@ -524,7 +570,7 @@ console.log(res);
|
|
|
524
570
|
|
|
525
571
|
***
|
|
526
572
|
|
|
527
|
-
|
|
573
|
+
<br>
|
|
528
574
|
|
|
529
575
|
## **π οΈ ι«ηΊ§**
|
|
530
576
|
|
package/dist/index.d.ts
CHANGED
|
@@ -463,6 +463,49 @@ declare class Client {
|
|
|
463
463
|
}>;
|
|
464
464
|
};
|
|
465
465
|
};
|
|
466
|
+
/**
|
|
467
|
+
* θͺε¨εζ΅η¨ζ¨‘ε
|
|
468
|
+
*/
|
|
469
|
+
automation: {
|
|
470
|
+
/**
|
|
471
|
+
* V1 ηζ¬
|
|
472
|
+
*/
|
|
473
|
+
v1: {
|
|
474
|
+
/**
|
|
475
|
+
* ζ§θ‘ζ΅η¨
|
|
476
|
+
* @param params θ―·ζ±εζ° { flow_api_name: string, operator: { _id: number, email: string }, params: any }
|
|
477
|
+
* @returns ζ₯ε£θΏεη»ζ
|
|
478
|
+
*/
|
|
479
|
+
execute: (params: {
|
|
480
|
+
flow_api_name: string;
|
|
481
|
+
operator: {
|
|
482
|
+
_id: number;
|
|
483
|
+
email: string;
|
|
484
|
+
};
|
|
485
|
+
params: any;
|
|
486
|
+
}) => Promise<any>;
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* V2 ηζ¬
|
|
490
|
+
*/
|
|
491
|
+
v2: {
|
|
492
|
+
/**
|
|
493
|
+
* ζ§θ‘ζ΅η¨
|
|
494
|
+
* @param params θ―·ζ±εζ° { flow_api_name: string, operator: { _id: number, email: string }, params: any, is_resubmit?: boolean, pre_instance_id?: string }
|
|
495
|
+
* @returns ζ₯ε£θΏεη»ζ
|
|
496
|
+
*/
|
|
497
|
+
execute: (params: {
|
|
498
|
+
flow_api_name: string;
|
|
499
|
+
operator: {
|
|
500
|
+
_id: number;
|
|
501
|
+
email: string;
|
|
502
|
+
};
|
|
503
|
+
params: any;
|
|
504
|
+
is_resubmit?: boolean;
|
|
505
|
+
pre_instance_id?: string;
|
|
506
|
+
}) => Promise<any>;
|
|
507
|
+
};
|
|
508
|
+
};
|
|
466
509
|
}
|
|
467
510
|
export declare const apaas: {
|
|
468
511
|
Client: typeof Client;
|
package/dist/index.js
CHANGED
|
@@ -935,6 +935,74 @@ class Client {
|
|
|
935
935
|
}
|
|
936
936
|
}
|
|
937
937
|
};
|
|
938
|
+
/**
|
|
939
|
+
* θͺε¨εζ΅η¨ζ¨‘ε
|
|
940
|
+
*/
|
|
941
|
+
this.automation = {
|
|
942
|
+
/**
|
|
943
|
+
* V1 ηζ¬
|
|
944
|
+
*/
|
|
945
|
+
v1: {
|
|
946
|
+
/**
|
|
947
|
+
* ζ§θ‘ζ΅η¨
|
|
948
|
+
* @param params θ―·ζ±εζ° { flow_api_name: string, operator: { _id: number, email: string }, params: any }
|
|
949
|
+
* @returns ζ₯ε£θΏεη»ζ
|
|
950
|
+
*/
|
|
951
|
+
execute: async (params) => {
|
|
952
|
+
const { flow_api_name, operator, params: flowParams } = params;
|
|
953
|
+
await this.ensureTokenValid();
|
|
954
|
+
const url = `/api/flow/v1/namespaces/${this.namespace}/flows/${flow_api_name}/execute`;
|
|
955
|
+
this.log(LoggerLevel.info, `[automation.v1.execute] Executing flow: ${flow_api_name}`);
|
|
956
|
+
const res = await this.axiosInstance.post(url, {
|
|
957
|
+
operator,
|
|
958
|
+
params: flowParams
|
|
959
|
+
}, {
|
|
960
|
+
headers: {
|
|
961
|
+
Authorization: `${this.accessToken}`,
|
|
962
|
+
'Content-Type': 'application/json'
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
this.log(LoggerLevel.debug, `[automation.v1.execute] Flow executed: ${flow_api_name}, code=${res.data.code}`);
|
|
966
|
+
this.log(LoggerLevel.trace, `[automation.v1.execute] Response: ${JSON.stringify(res.data)}`);
|
|
967
|
+
return res.data;
|
|
968
|
+
}
|
|
969
|
+
},
|
|
970
|
+
/**
|
|
971
|
+
* V2 ηζ¬
|
|
972
|
+
*/
|
|
973
|
+
v2: {
|
|
974
|
+
/**
|
|
975
|
+
* ζ§θ‘ζ΅η¨
|
|
976
|
+
* @param params θ―·ζ±εζ° { flow_api_name: string, operator: { _id: number, email: string }, params: any, is_resubmit?: boolean, pre_instance_id?: string }
|
|
977
|
+
* @returns ζ₯ε£θΏεη»ζ
|
|
978
|
+
*/
|
|
979
|
+
execute: async (params) => {
|
|
980
|
+
const { flow_api_name, operator, params: flowParams, is_resubmit, pre_instance_id } = params;
|
|
981
|
+
await this.ensureTokenValid();
|
|
982
|
+
const url = `/v2/namespaces/${this.namespace}/flows/${flow_api_name}/execute`;
|
|
983
|
+
this.log(LoggerLevel.info, `[automation.v2.execute] Executing flow: ${flow_api_name}`);
|
|
984
|
+
const requestData = {
|
|
985
|
+
operator,
|
|
986
|
+
params: flowParams
|
|
987
|
+
};
|
|
988
|
+
if (is_resubmit !== undefined) {
|
|
989
|
+
requestData.is_resubmit = is_resubmit;
|
|
990
|
+
}
|
|
991
|
+
if (pre_instance_id) {
|
|
992
|
+
requestData.pre_instance_id = pre_instance_id;
|
|
993
|
+
}
|
|
994
|
+
const res = await this.axiosInstance.post(url, requestData, {
|
|
995
|
+
headers: {
|
|
996
|
+
Authorization: `${this.accessToken}`,
|
|
997
|
+
'Content-Type': 'application/json'
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
this.log(LoggerLevel.debug, `[automation.v2.execute] Flow executed: ${flow_api_name}, code=${res.data.code}`);
|
|
1001
|
+
this.log(LoggerLevel.trace, `[automation.v2.execute] Response: ${JSON.stringify(res.data)}`);
|
|
1002
|
+
return res.data;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
938
1006
|
this.clientId = options.clientId;
|
|
939
1007
|
this.clientSecret = options.clientSecret;
|
|
940
1008
|
this.namespace = options.namespace;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1298,6 +1298,98 @@ class Client {
|
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
1300
|
};
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* θͺε¨εζ΅η¨ζ¨‘ε
|
|
1304
|
+
*/
|
|
1305
|
+
public automation = {
|
|
1306
|
+
/**
|
|
1307
|
+
* V1 ηζ¬
|
|
1308
|
+
*/
|
|
1309
|
+
v1: {
|
|
1310
|
+
/**
|
|
1311
|
+
* ζ§θ‘ζ΅η¨
|
|
1312
|
+
* @param params θ―·ζ±εζ° { flow_api_name: string, operator: { _id: number, email: string }, params: any }
|
|
1313
|
+
* @returns ζ₯ε£θΏεη»ζ
|
|
1314
|
+
*/
|
|
1315
|
+
execute: async (params: { flow_api_name: string; operator: { _id: number; email: string }; params: any }): Promise<any> => {
|
|
1316
|
+
const { flow_api_name, operator, params: flowParams } = params;
|
|
1317
|
+
await this.ensureTokenValid();
|
|
1318
|
+
|
|
1319
|
+
const url = `/api/flow/v1/namespaces/${this.namespace}/flows/${flow_api_name}/execute`;
|
|
1320
|
+
|
|
1321
|
+
this.log(LoggerLevel.info, `[automation.v1.execute] Executing flow: ${flow_api_name}`);
|
|
1322
|
+
|
|
1323
|
+
const res = await this.axiosInstance.post(
|
|
1324
|
+
url,
|
|
1325
|
+
{
|
|
1326
|
+
operator,
|
|
1327
|
+
params: flowParams
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
headers: {
|
|
1331
|
+
Authorization: `${this.accessToken}`,
|
|
1332
|
+
'Content-Type': 'application/json'
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
);
|
|
1336
|
+
|
|
1337
|
+
this.log(LoggerLevel.debug, `[automation.v1.execute] Flow executed: ${flow_api_name}, code=${res.data.code}`);
|
|
1338
|
+
this.log(LoggerLevel.trace, `[automation.v1.execute] Response: ${JSON.stringify(res.data)}`);
|
|
1339
|
+
|
|
1340
|
+
return res.data;
|
|
1341
|
+
}
|
|
1342
|
+
},
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* V2 ηζ¬
|
|
1346
|
+
*/
|
|
1347
|
+
v2: {
|
|
1348
|
+
/**
|
|
1349
|
+
* ζ§θ‘ζ΅η¨
|
|
1350
|
+
* @param params θ―·ζ±εζ° { flow_api_name: string, operator: { _id: number, email: string }, params: any, is_resubmit?: boolean, pre_instance_id?: string }
|
|
1351
|
+
* @returns ζ₯ε£θΏεη»ζ
|
|
1352
|
+
*/
|
|
1353
|
+
execute: async (params: {
|
|
1354
|
+
flow_api_name: string;
|
|
1355
|
+
operator: { _id: number; email: string };
|
|
1356
|
+
params: any;
|
|
1357
|
+
is_resubmit?: boolean;
|
|
1358
|
+
pre_instance_id?: string;
|
|
1359
|
+
}): Promise<any> => {
|
|
1360
|
+
const { flow_api_name, operator, params: flowParams, is_resubmit, pre_instance_id } = params;
|
|
1361
|
+
await this.ensureTokenValid();
|
|
1362
|
+
|
|
1363
|
+
const url = `/v2/namespaces/${this.namespace}/flows/${flow_api_name}/execute`;
|
|
1364
|
+
|
|
1365
|
+
this.log(LoggerLevel.info, `[automation.v2.execute] Executing flow: ${flow_api_name}`);
|
|
1366
|
+
|
|
1367
|
+
const requestData: any = {
|
|
1368
|
+
operator,
|
|
1369
|
+
params: flowParams
|
|
1370
|
+
};
|
|
1371
|
+
|
|
1372
|
+
if (is_resubmit !== undefined) {
|
|
1373
|
+
requestData.is_resubmit = is_resubmit;
|
|
1374
|
+
}
|
|
1375
|
+
if (pre_instance_id) {
|
|
1376
|
+
requestData.pre_instance_id = pre_instance_id;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
const res = await this.axiosInstance.post(url, requestData, {
|
|
1380
|
+
headers: {
|
|
1381
|
+
Authorization: `${this.accessToken}`,
|
|
1382
|
+
'Content-Type': 'application/json'
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1386
|
+
this.log(LoggerLevel.debug, `[automation.v2.execute] Flow executed: ${flow_api_name}, code=${res.data.code}`);
|
|
1387
|
+
this.log(LoggerLevel.trace, `[automation.v2.execute] Response: ${JSON.stringify(res.data)}`);
|
|
1388
|
+
|
|
1389
|
+
return res.data;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1301
1393
|
}
|
|
1302
1394
|
|
|
1303
1395
|
export const apaas = {
|