jpsclient 1.4.0 → 1.5.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.
- checksums.yaml +4 -4
- data/lib/jpsclient/api/project_package.rb +53 -0
- data/lib/jpsclient/auth/auth.rb +30 -1
- data/lib/jpsclient/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2709f21c8f075e561ae9b67991774b7bb95872100711cd88890f09a8225652e
|
|
4
|
+
data.tar.gz: 686ed38ce06861e1bec6d1b27c975a40da7c542145f14fbeff33051d3a1b9cbd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0fc9a740eb975486a0851c7d5ef8339b6a4afd59e9999b0d258def275a4381838e0144f9462f7aedb7f8c678feed53ca02af2dbc9743aa51c7758ff5c68d0f2
|
|
7
|
+
data.tar.gz: 7823ba00bb6b794a116892f614d883dbbf8a8a43f885d7bc384adb732db35cc2056fa7ce2d3bba5d924533e53965a293bbbf2f39d63da454abc5a78976503869
|
|
@@ -5,6 +5,7 @@ module JPSClient
|
|
|
5
5
|
#
|
|
6
6
|
# 支持的功能:
|
|
7
7
|
# - 上传项目包
|
|
8
|
+
# - 上传 NuGet 包
|
|
8
9
|
# - 获取项目包列表
|
|
9
10
|
# - 更新项目包信息
|
|
10
11
|
# - 签名项目包
|
|
@@ -36,6 +37,58 @@ module JPSClient
|
|
|
36
37
|
body_params[:chatEnv] ||= params&.dig(:chatEnv)
|
|
37
38
|
body_params[:commitId] ||= params&.dig(:commitId)
|
|
38
39
|
body_params[:projectPackageId] ||= params&.dig(:projectPackageId)
|
|
40
|
+
body_params[:workflowId] ||= params&.dig(:workflowId)
|
|
41
|
+
|
|
42
|
+
# 移除值为nil的键
|
|
43
|
+
body_params.compact!
|
|
44
|
+
|
|
45
|
+
response = @http_client.post(path, body: body_params)
|
|
46
|
+
result = JPSClient::Response.new(response)
|
|
47
|
+
|
|
48
|
+
# 处理 401 错误,自动重新登录
|
|
49
|
+
if result.need_login?
|
|
50
|
+
do_login(force_login: true)
|
|
51
|
+
# 重试请求
|
|
52
|
+
response = @http_client.post(path, body: body_params)
|
|
53
|
+
result = JPSClient::Response.new(response)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
return result.to_h
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# 上传 NuGet 包
|
|
60
|
+
# 用于上传 NuGet 包到项目,不需要 workflowId 参数
|
|
61
|
+
#
|
|
62
|
+
# @param projectId [String] 项目ID(必需)
|
|
63
|
+
# @param params [Hash] 可选参数
|
|
64
|
+
# @option params [String] :packageUrl 包文件URL(必需)
|
|
65
|
+
# @option params [String] :description 包描述
|
|
66
|
+
# @option params [Array<String>] :attachFileUrls 附件文件URL列表
|
|
67
|
+
# @option params [String] :chatEnv 聊天环境
|
|
68
|
+
# @option params [String] :commitId 提交ID
|
|
69
|
+
# @option params [String] :projectPackageId 项目包ID
|
|
70
|
+
# @return [Hash] API响应
|
|
71
|
+
def upload_nuget_package(projectId:nil, params:nil)
|
|
72
|
+
config = @request_config && @request_config["project_package_upload_nuget"]
|
|
73
|
+
raise JPSClient::ExceptionError, "Missing config for project_package_upload_nuget" unless config && config["url"]
|
|
74
|
+
path = config["url"]
|
|
75
|
+
|
|
76
|
+
body_params = {
|
|
77
|
+
projectId: projectId
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# 合并传入的参数
|
|
81
|
+
if params
|
|
82
|
+
params.each { |key,value| body_params[key] = value }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# 确保必要的字段存在(不包括 workflowId)
|
|
86
|
+
body_params[:packageUrl] ||= params&.dig(:packageUrl)
|
|
87
|
+
body_params[:description] ||= params&.dig(:description)
|
|
88
|
+
body_params[:attachFileUrls] ||= params&.dig(:attachFileUrls) || []
|
|
89
|
+
body_params[:chatEnv] ||= params&.dig(:chatEnv)
|
|
90
|
+
body_params[:commitId] ||= params&.dig(:commitId)
|
|
91
|
+
body_params[:projectPackageId] ||= params&.dig(:projectPackageId)
|
|
39
92
|
|
|
40
93
|
# 移除值为nil的键
|
|
41
94
|
body_params.compact!
|
data/lib/jpsclient/auth/auth.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'webrick'
|
|
4
4
|
require 'json'
|
|
5
5
|
require 'net/http'
|
|
6
|
+
require 'net/https'
|
|
6
7
|
require 'uri'
|
|
7
8
|
require 'securerandom'
|
|
8
9
|
require 'digest'
|
|
@@ -79,10 +80,25 @@ module JPSClient
|
|
|
79
80
|
@server_port = @config.server_port
|
|
80
81
|
|
|
81
82
|
@scope_list = [
|
|
83
|
+
'offline_access',
|
|
82
84
|
'task:task:write',
|
|
83
85
|
'task:section:write',
|
|
84
86
|
'task:custom_field:write',
|
|
85
|
-
'task:tasklist:write'
|
|
87
|
+
'task:tasklist:write',
|
|
88
|
+
'drive:drive',
|
|
89
|
+
'wiki:wiki',
|
|
90
|
+
'docx:document',
|
|
91
|
+
'bitable:app',
|
|
92
|
+
'contact:user.employee_id:readonly',
|
|
93
|
+
'docs:document.content:read',
|
|
94
|
+
'im:chat',
|
|
95
|
+
'base:app:copy',
|
|
96
|
+
'base:record:update',
|
|
97
|
+
'task:comment:write',
|
|
98
|
+
'task:comment',
|
|
99
|
+
'task:attachment:write',
|
|
100
|
+
'vc:room:readonly',
|
|
101
|
+
'vc:meeting:readonly'
|
|
86
102
|
]
|
|
87
103
|
|
|
88
104
|
@access_token = nil
|
|
@@ -258,6 +274,9 @@ module JPSClient
|
|
|
258
274
|
# 使用授权码换取 token
|
|
259
275
|
def exchange_code_for_token(code)
|
|
260
276
|
begin
|
|
277
|
+
puts "🔄 获取授权码成功: #{code[0..10]}..."
|
|
278
|
+
puts "🔄 正在换取访问令牌..."
|
|
279
|
+
|
|
261
280
|
request_data = {
|
|
262
281
|
'code' => code,
|
|
263
282
|
'redirectUri' => @redirect_uri,
|
|
@@ -268,6 +287,16 @@ module JPSClient
|
|
|
268
287
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
269
288
|
http.use_ssl = (uri.scheme == 'https')
|
|
270
289
|
|
|
290
|
+
# 配置 SSL 以兼容 OpenSSL 3.x(避免 CRL 检查失败)
|
|
291
|
+
if http.use_ssl?
|
|
292
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
293
|
+
# 创建 SSL 上下文并禁用 CRL 检查
|
|
294
|
+
http.cert_store = OpenSSL::X509::Store.new
|
|
295
|
+
http.cert_store.set_default_paths
|
|
296
|
+
# verify_flags = 0 表示不检查 CRL
|
|
297
|
+
http.cert_store.flags = 0
|
|
298
|
+
end
|
|
299
|
+
|
|
271
300
|
request = Net::HTTP::Post.new(uri)
|
|
272
301
|
request['Content-Type'] = 'application/json'
|
|
273
302
|
request.body = request_data.to_json
|
data/lib/jpsclient/version.rb
CHANGED