@tapd/tapd-node-sdk 1.32.0-beta.4 → 1.42.1-alpha.0

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.
@@ -0,0 +1,60 @@
1
+ ## 简介 🐕🐕
2
+ > 主要用于调用TAPD api v2 接口的SDK<( ̄︶ ̄)↗[GO!]
3
+
4
+ > 推荐版本: NodeJs 14.13.0+
5
+
6
+ ## Install
7
+ 安装SDK包
8
+ ```
9
+ npm install @opentapd/tapd-node-sdk
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ #### DEMO
15
+ ```javascript
16
+ const SDK = require('@opentapd/tapd-node-sdk');
17
+
18
+ const api = new SDK({
19
+ client: 'gggg123', // 你的应用CODE
20
+ secret: '112A5B9F-D7B9-EC9C-B688-24E44F5043C4', // 密钥 注意保密
21
+ });
22
+
23
+
24
+ // api 详细文档可参考tapdAPI的文档
25
+ api.getStories({
26
+ workspace_id: '755'
27
+ }).then(data => {
28
+ console.log(data);
29
+ }).catch(e => console.log(e));
30
+
31
+ // 文件上传接口使用方式
32
+ var file = fs.createReadStream('your file path')
33
+
34
+ // 支持Buffer
35
+ // const {FILE}= require('@tencent/tapd-node-sdk');
36
+ // const { Readable } = require('stream');
37
+ // //Readable
38
+ // const file_stdout = Readable.from(bitmap);
39
+ // var file = new FILE({
40
+ // stdout: file_stdout,
41
+ // filename: 'test.jpg',
42
+ // });
43
+
44
+ api.uploadImage({
45
+ workspace_id: "755",
46
+ image: file
47
+ }).then(data => {
48
+ console.log(data);
49
+ }).catch(e => console.log(e));
50
+
51
+
52
+ api.uploadImage({
53
+ workspace_id: "755",
54
+ image: file
55
+ }).then(data => {
56
+ console.log(data);
57
+ }).catch(e => console.log(e));
58
+ ```
59
+
60
+ #### [查看所有SDK方法和参数](https://o.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/)
@@ -1,7 +1,7 @@
1
1
  ## 简介 🐕🐕
2
2
  > 主要用于调用TAPD api v2 接口的SDK<( ̄︶ ̄)↗[GO!]
3
3
 
4
- > 推荐版本: NodeJs 12.13.0+
4
+ > 推荐版本: NodeJs 14.13.0+
5
5
 
6
6
  ## Install
7
7
  安装SDK包
package/README.oa.md ADDED
@@ -0,0 +1,103 @@
1
+ ## 简介 🐕🐕
2
+
3
+ > 主要用于调用TAPD api v2 接口的SDK<( ̄︶ ̄)↗[GO!]
4
+
5
+ > 推荐版本: NodeJs 14.13.0+
6
+
7
+ ## Install
8
+ 设置npm工具使用软件源的registry
9
+ ```
10
+ npm config set registry https://mirrors.tencent.com/npm/
11
+ ```
12
+ 安装SDK包
13
+ ```
14
+ npm install @tencent/tapd-node-sdk
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ #### 申请应用
20
+ 1. 申请和使用应用
21
+ https://o.tapd.woa.com/document/api-doc/API%E6%96%87%E6%A1%A3/%E5%BC%80%E6%94%BE%E5%B9%B3%E5%8F%B0%E5%BA%94%E7%94%A8API%E4%BD%BF%E7%94%A8%E6%8C%87%E5%BC%95.html
22
+
23
+ 2. 复制应用ID和密钥
24
+ https://o.tapd.woa.com/admin/{你的应用标识}/dashboard
25
+ ![Alt](https://o.tapd.woa.com/document/img/tapd_20417300_1638862843_15.png)
26
+
27
+
28
+ #### DEMO
29
+ ```javascript
30
+ const SDK = require('@tencent/tapd-node-sdk');
31
+
32
+
33
+
34
+
35
+ const api = new SDK({
36
+ client: 'gggg123', // 你的应用CODE
37
+ secret: '112A5B9F-D7B9-EC9C-B688-24E44F5043C4', // 密钥 注意保密
38
+ });
39
+
40
+
41
+ // api 详细文档可参考tapdAPI的文档
42
+ api.getStories({
43
+ workspace_id: '755'
44
+ }).then(data => {
45
+ console.log(data);
46
+ }).catch(e => console.log(e));
47
+
48
+ // 文件上传接口使用方式
49
+ var file = fs.createReadStream('your file path')
50
+
51
+ // 支持Buffer
52
+ // const {FILE}= require('@tencent/tapd-node-sdk');
53
+ // const { Readable } = require('stream');
54
+ // //Readable
55
+ // const file_stdout = Readable.from(bitmap);
56
+ // var file = new FILE({
57
+ // stdout: file_stdout,
58
+ // filename: 'test.jpg',
59
+ // });
60
+
61
+ api.uploadImage({
62
+ workspace_id: "755",
63
+ image: file
64
+ }).then(data => {
65
+ console.log(data);
66
+ }).catch(e => console.log(e));
67
+
68
+
69
+ api.uploadImage({
70
+ workspace_id: "755",
71
+ image: file
72
+ }).then(data => {
73
+ console.log(data);
74
+ }).catch(e => console.log(e));
75
+ ```
76
+
77
+ #### [查看所有SDK方法和参数](https://o.tapd.woa.com/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/)
78
+
79
+ #### IDC 网络的使用
80
+ 1. 怎看自己是不是IDC网络, 查看这个[链接](https://iwiki.woa.com/tencent/static/iwiki-editor-pro/dist/preview.html?space=&page=1227785302&id=131410&name=6997554869969258912(1).MP4&size=1160018&language=zh)
81
+
82
+ 2. 如果是IDC网络怎么设置
83
+ ```javascript
84
+ const SDK = require('@tencent/tapd-node-sdk');
85
+
86
+ const api = new SDK({
87
+ client: 'gggg123', // 你的应用CODE
88
+ secret: '112A5B9F-D7B9-EC9C-B688-24E44F5043C4', // 密钥 注意保密
89
+ env: 'idc'
90
+ });
91
+
92
+ ```
93
+
94
+
95
+ ## Artifact
96
+ https://mirrors.tencent.com/#/private/npm/detail?repo_id=537&project_name=%40tencent%2Ftapd-node-sdk&search_label=package_name&search_value=tapd-node-sdk&page_num=1
97
+
98
+ ## 其他问题
99
+
100
+ 提issue可能看不到,找tapd客服解决反馈。
101
+
102
+ ## Contributions
103
+ 欢迎参与SDK共建!开发&共建流程,请参照 [contributing.md](https://git.woa.com/tapd-plugin-core/tplugin-sdk/blob/dev/CONTRIBUTING.md)。
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@tapd/tapd-node-sdk",
3
- "version": "1.32.0-beta.4",
3
+ "version": "1.42.1-alpha.0",
4
4
  "description": "node sdk for open tapd ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
7
  "test": "npm run test",
8
8
  "generate": "npm install && node scripts/sdk.generator",
9
- "lint": "npx eslint --fix --ext .js ./src ./scripts ./test"
9
+ "build": "node scripts/sdk.generator",
10
+ "lint": "npx eslint --fix --ext .js ./src ./scripts ./test",
11
+ "ex_replace_package_json": "node ../../../scripts/replace-tencent-in-package-json/main.js @tapd",
12
+ "replace_package_json": "node ../../../scripts/replace-tencent-in-package-json/main.js @opentapd"
10
13
  },
11
14
  "keywords": [
12
15
  "node",
@@ -19,12 +22,13 @@
19
22
  "devDependencies": {
20
23
  "@babel/core": "^7.15.0",
21
24
  "ejs": "^3.1.6",
22
- "eslint": "^7.32.0"
25
+ "eslint": "^7.32.0",
26
+ "eslint-config-tencent": "^1.0.4"
23
27
  },
24
28
  "dependencies": {
25
29
  "axios": "^0.21.4",
26
- "form-data": "^2.3.3",
27
30
  "camel-case": "^4.1.2",
31
+ "form-data": "^2.3.3",
28
32
  "js-base64": "^3.7.2",
29
33
  "lodash": "^4.17.21",
30
34
  "lodash.get": "^4.4.2",
@@ -37,7 +41,8 @@
37
41
  "files": [
38
42
  "src"
39
43
  ],
40
- "npm": {
41
- "alias": "@tencent/tapd-node-sdk"
42
- }
44
+ "directories": {
45
+ "test": "test"
46
+ },
47
+ "gitHead": "8f02238ddf5e60e934b8be8643372667566c43b1"
43
48
  }
package/src/index.js CHANGED
@@ -7435,6 +7435,38 @@ module.exports = class API extends SDK {
7435
7435
  );
7436
7436
  }
7437
7437
 
7438
+ /**
7439
+ * @description 项目集关联项目
7440
+ * @link o.tapd.tencent.com/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/program/program_relate_workspace.html
7441
+ * @scope program#w
7442
+
7443
+ */
7444
+ programRelateWorkspace(...args) {
7445
+ return this.oAuthRequest.apply(
7446
+ this, [
7447
+ '/program/program_relate_workspace',
7448
+ 'POST',
7449
+ ...args
7450
+ ]
7451
+ );
7452
+ }
7453
+
7454
+ /**
7455
+ * @description 项目集批量关联/取消关联业务对象
7456
+ * @link o.tapd.tencent.com/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/program/program_bind_entities.html
7457
+ * @scope program#w
7458
+
7459
+ */
7460
+ programBindEntities(...args) {
7461
+ return this.oAuthRequest.apply(
7462
+ this, [
7463
+ '/program/program_bind_entities',
7464
+ 'POST',
7465
+ ...args
7466
+ ]
7467
+ );
7468
+ }
7469
+
7438
7470
 
7439
7471
  }
7440
7472
  module.exports.FILE = FILE;
package/src/sdk.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const get = require('lodash.get');
2
2
  const Axios = require('./axios');
3
+ const crypto = require('crypto');
3
4
  const { ReadStream } = require('fs');
4
5
  const FormData = require('form-data');
5
6
  const { Base64 } = require('js-base64');
@@ -12,11 +13,13 @@ class SDK {
12
13
  address = '',
13
14
  accessToken = '',
14
15
  authType = '',
16
+ rioToken = '',
15
17
  } = {}) {
16
18
  this.client = client;
17
19
  this.secret = secret;
18
20
  this.address = address;
19
21
  this.axios = Axios(this.address);
22
+ this.rioToken = rioToken;
20
23
 
21
24
  if (authType !== '') {
22
25
  this.authType = authType;
@@ -129,6 +132,15 @@ class SDK {
129
132
  const authHeader = this.isOauth() ? `Bearer ${accessToken}` : `Basic ${Base64.encode(`${this.client}:${this.secret}`)}`;
130
133
  const upperMethod = method.toUpperCase();
131
134
 
135
+ const headers = {}
136
+ if ( this.rioToken !== ""){
137
+ const timestamp = (Date.now() / 1000).toFixed()
138
+ const signature = crypto.createHash('sha256').update(`${timestamp}${this.rioToken }${timestamp}`).digest('hex');
139
+
140
+ headers['timestamp'] = timestamp
141
+ headers['signature'] = signature
142
+ }
143
+
132
144
  const config = {
133
145
  ...args,
134
146
  method,
@@ -136,7 +148,7 @@ class SDK {
136
148
  params: upperMethod === 'GET' ? params : {},
137
149
  data: upperMethod === 'GET' ? undefined : params,
138
150
  // 使用Bearer or Basic方式发起鉴权
139
- headers: { Authorization: authHeader },
151
+ headers: { ...headers, ...{ Authorization: authHeader }},
140
152
  };
141
153
 
142
154
  if (Object.values(params).some(value => value instanceof ReadStream || value instanceof FILE)) {