qing-client 0.0.38 → 0.0.40
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/lib/client/BaseClient.js +1 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +16 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +7 -1
- package/lib/service/DeliveryStreamService.d.ts +80 -0
- package/lib/service/DeliveryStreamService.js +176 -0
- package/lib/service/EzAbilityService.d.ts +58 -0
- package/lib/service/EzAbilityService.js +90 -0
- package/lib/types/delivery-stream.d.ts +66 -0
- package/lib/types/delivery-stream.js +4 -0
- package/lib/types/ez-ability.d.ts +51 -0
- package/lib/types/ez-ability.js +4 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +1 -0
- package/package.json +1 -1
package/lib/client/BaseClient.js
CHANGED
|
@@ -163,6 +163,7 @@ class BaseClient {
|
|
|
163
163
|
case "providers": return this.config.providerServiceUrl;
|
|
164
164
|
case "org": return this.config.orgServiceUrl; // 组织感知服务
|
|
165
165
|
case "gateway-h5": return this.config.gatewayH5ServiceUrl;
|
|
166
|
+
case "ez-ability": return this.config.ezAbilityServiceUrl; // EzAI 能力服务
|
|
166
167
|
default: throw new Error(`Unsupported service: ${this.serviceName}`);
|
|
167
168
|
}
|
|
168
169
|
}
|
package/lib/client/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { ProviderService } from "../service/ProviderService";
|
|
|
9
9
|
import { UsageService } from "../service/UsageService";
|
|
10
10
|
import { FrontHostService } from "../service/FrontHostService";
|
|
11
11
|
import { OrgService } from "../service/OrgService";
|
|
12
|
+
import { DeliveryStreamService } from "../service/DeliveryStreamService";
|
|
13
|
+
import { EzAbilityService } from "../service/EzAbilityService";
|
|
12
14
|
import { ClientConfig, UserContext } from "../types";
|
|
13
15
|
export declare class Client {
|
|
14
16
|
protected config: ClientConfig;
|
|
@@ -23,6 +25,8 @@ export declare class Client {
|
|
|
23
25
|
readonly usage: UsageService;
|
|
24
26
|
readonly frontHost: FrontHostService;
|
|
25
27
|
readonly org: OrgService;
|
|
28
|
+
readonly deliveryStream: DeliveryStreamService;
|
|
29
|
+
readonly ezAbility: EzAbilityService;
|
|
26
30
|
protected isFrontendMode: boolean;
|
|
27
31
|
constructor(config: ClientConfig);
|
|
28
32
|
setUserContext(context: UserContext): this;
|
package/lib/client/index.js
CHANGED
|
@@ -12,6 +12,8 @@ const ProviderService_1 = require("../service/ProviderService");
|
|
|
12
12
|
const UsageService_1 = require("../service/UsageService");
|
|
13
13
|
const FrontHostService_1 = require("../service/FrontHostService");
|
|
14
14
|
const OrgService_1 = require("../service/OrgService");
|
|
15
|
+
const DeliveryStreamService_1 = require("../service/DeliveryStreamService");
|
|
16
|
+
const EzAbilityService_1 = require("../service/EzAbilityService");
|
|
15
17
|
class Client {
|
|
16
18
|
constructor(config) {
|
|
17
19
|
this.config = config;
|
|
@@ -27,6 +29,8 @@ class Client {
|
|
|
27
29
|
this.usage = new UsageService_1.UsageService(config);
|
|
28
30
|
this.frontHost = new FrontHostService_1.FrontHostService(config);
|
|
29
31
|
this.org = new OrgService_1.OrgService(config);
|
|
32
|
+
this.deliveryStream = new DeliveryStreamService_1.DeliveryStreamService(config);
|
|
33
|
+
this.ezAbility = new EzAbilityService_1.EzAbilityService(config);
|
|
30
34
|
}
|
|
31
35
|
// 后端模式:设置用户上下文
|
|
32
36
|
setUserContext(context) {
|
|
@@ -42,6 +46,8 @@ class Client {
|
|
|
42
46
|
this.usage.setUserContext(context);
|
|
43
47
|
this.frontHost.setUserContext(context);
|
|
44
48
|
this.org.setUserContext(context);
|
|
49
|
+
this.deliveryStream.setUserContext(context);
|
|
50
|
+
this.ezAbility.setUserContext(context);
|
|
45
51
|
}
|
|
46
52
|
else {
|
|
47
53
|
console.warn("setUserContext() 仅在后端模式下有效");
|
|
@@ -62,6 +68,8 @@ class Client {
|
|
|
62
68
|
this.usage.setProjectId(projectId);
|
|
63
69
|
this.frontHost.setProjectId(projectId);
|
|
64
70
|
this.org.setProjectId(projectId);
|
|
71
|
+
this.deliveryStream.setProjectId(projectId);
|
|
72
|
+
this.ezAbility.setProjectId(projectId);
|
|
65
73
|
}
|
|
66
74
|
else {
|
|
67
75
|
console.warn("setProjectId() 仅在前端模式下有效");
|
|
@@ -82,6 +90,8 @@ class Client {
|
|
|
82
90
|
this.usage.setAppId(appId);
|
|
83
91
|
this.frontHost.setAppId(appId);
|
|
84
92
|
this.org.setAppId(appId);
|
|
93
|
+
this.deliveryStream.setAppId(appId);
|
|
94
|
+
this.ezAbility.setAppId(appId);
|
|
85
95
|
}
|
|
86
96
|
else {
|
|
87
97
|
console.warn("setAppId() 仅在前端模式下有效");
|
|
@@ -102,6 +112,8 @@ class Client {
|
|
|
102
112
|
this.usage.setProjectAndApp(projectId, appId);
|
|
103
113
|
this.frontHost.setProjectAndApp(projectId, appId);
|
|
104
114
|
this.org.setProjectAndApp(projectId, appId);
|
|
115
|
+
this.deliveryStream.setProjectAndApp(projectId, appId);
|
|
116
|
+
this.ezAbility.setProjectAndApp(projectId, appId);
|
|
105
117
|
}
|
|
106
118
|
else {
|
|
107
119
|
console.warn("setProjectAndApp() 仅在前端模式下有效");
|
|
@@ -121,6 +133,8 @@ class Client {
|
|
|
121
133
|
await this.usage.setToken(token);
|
|
122
134
|
await this.frontHost.setToken(token);
|
|
123
135
|
await this.org.setToken(token);
|
|
136
|
+
await this.deliveryStream.setToken(token);
|
|
137
|
+
await this.ezAbility.setToken(token);
|
|
124
138
|
}
|
|
125
139
|
// 清除认证令牌(两种模式都需要)
|
|
126
140
|
async clearToken() {
|
|
@@ -135,6 +149,8 @@ class Client {
|
|
|
135
149
|
await this.usage.clearToken();
|
|
136
150
|
await this.frontHost.clearToken();
|
|
137
151
|
await this.org.clearToken();
|
|
152
|
+
await this.deliveryStream.clearToken();
|
|
153
|
+
await this.ezAbility.clearToken();
|
|
138
154
|
}
|
|
139
155
|
}
|
|
140
156
|
exports.Client = Client;
|
package/lib/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export { FrontHostService } from "./service/FrontHostService";
|
|
|
10
10
|
export { ProviderService } from "./service/ProviderService";
|
|
11
11
|
export { UsageService } from "./service/UsageService";
|
|
12
12
|
export { OrgService } from "./service/OrgService";
|
|
13
|
+
export { DeliveryStreamService } from "./service/DeliveryStreamService";
|
|
14
|
+
export { EzAbilityService } from "./service/EzAbilityService";
|
|
13
15
|
export * from './types';
|
|
14
16
|
export * from './types/msg';
|
|
15
17
|
export * from './types/token';
|
|
@@ -23,3 +25,5 @@ export { BaseClient } from './client/BaseClient';
|
|
|
23
25
|
export * from "./types/provider";
|
|
24
26
|
export * from "./types/usage";
|
|
25
27
|
export * from "./types/org";
|
|
28
|
+
export * from "./types/delivery-stream";
|
|
29
|
+
export * from "./types/ez-ability";
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.BaseClient = exports.OrgService = exports.UsageService = exports.ProviderService = exports.FrontHostService = exports.AuditLogService = exports.AigcService = exports.FileService = exports.UserService = exports.TokenService = exports.MsgService = exports.AuthService = exports.Client = void 0;
|
|
17
|
+
exports.BaseClient = exports.EzAbilityService = exports.DeliveryStreamService = exports.OrgService = exports.UsageService = exports.ProviderService = exports.FrontHostService = exports.AuditLogService = exports.AigcService = exports.FileService = exports.UserService = exports.TokenService = exports.MsgService = exports.AuthService = exports.Client = void 0;
|
|
18
18
|
// 导出核心客户端类
|
|
19
19
|
var client_1 = require("./client");
|
|
20
20
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
@@ -41,6 +41,10 @@ var UsageService_1 = require("./service/UsageService");
|
|
|
41
41
|
Object.defineProperty(exports, "UsageService", { enumerable: true, get: function () { return UsageService_1.UsageService; } });
|
|
42
42
|
var OrgService_1 = require("./service/OrgService");
|
|
43
43
|
Object.defineProperty(exports, "OrgService", { enumerable: true, get: function () { return OrgService_1.OrgService; } });
|
|
44
|
+
var DeliveryStreamService_1 = require("./service/DeliveryStreamService");
|
|
45
|
+
Object.defineProperty(exports, "DeliveryStreamService", { enumerable: true, get: function () { return DeliveryStreamService_1.DeliveryStreamService; } });
|
|
46
|
+
var EzAbilityService_1 = require("./service/EzAbilityService");
|
|
47
|
+
Object.defineProperty(exports, "EzAbilityService", { enumerable: true, get: function () { return EzAbilityService_1.EzAbilityService; } });
|
|
44
48
|
// 导出所有类型定义
|
|
45
49
|
__exportStar(require("./types"), exports);
|
|
46
50
|
__exportStar(require("./types/msg"), exports);
|
|
@@ -55,3 +59,5 @@ Object.defineProperty(exports, "BaseClient", { enumerable: true, get: function (
|
|
|
55
59
|
__exportStar(require("./types/provider"), exports);
|
|
56
60
|
__exportStar(require("./types/usage"), exports);
|
|
57
61
|
__exportStar(require("./types/org"), exports);
|
|
62
|
+
__exportStar(require("./types/delivery-stream"), exports);
|
|
63
|
+
__exportStar(require("./types/ez-ability"), exports);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BaseClient } from "../client/BaseClient";
|
|
2
|
+
import { ClientConfig, RequestOptions, PaginatedResponse } from "../types";
|
|
3
|
+
import { Stream, CreateStreamRequest, UpdateStreamRequest, StreamListQuery, Requirement, CreateRequirementRequest, UpdateRequirementRequest, RequirementListQuery } from "../types/delivery-stream";
|
|
4
|
+
/**
|
|
5
|
+
* Delivery Stream Service SDK
|
|
6
|
+
*
|
|
7
|
+
* 业务交付建模服务 - Stream(业务演进容器)& Requirement(需求池)
|
|
8
|
+
*
|
|
9
|
+
* MVP 特性:
|
|
10
|
+
* - scopeMode = personal(个人可见性)
|
|
11
|
+
* - Requirement 必须绑定 Stream
|
|
12
|
+
* - 软删除策略
|
|
13
|
+
*/
|
|
14
|
+
export declare class DeliveryStreamService extends BaseClient {
|
|
15
|
+
constructor(config: ClientConfig);
|
|
16
|
+
/**
|
|
17
|
+
* 创建 Stream
|
|
18
|
+
* POST /api/delivery-stream/streams (网关转发到 /api/v1/streams)
|
|
19
|
+
*/
|
|
20
|
+
createStream(request: CreateStreamRequest, options?: RequestOptions): Promise<Stream>;
|
|
21
|
+
/**
|
|
22
|
+
* 获取 Stream 详情
|
|
23
|
+
* GET /api/delivery-stream/streams/:id
|
|
24
|
+
*/
|
|
25
|
+
getStream(streamId: string, options?: RequestOptions): Promise<Stream>;
|
|
26
|
+
/**
|
|
27
|
+
* 获取 Stream 列表
|
|
28
|
+
* GET /api/delivery-stream/streams
|
|
29
|
+
*
|
|
30
|
+
* 注意:只能查看自己创建的 Stream(personal 可见性)
|
|
31
|
+
*/
|
|
32
|
+
listStreams(query?: StreamListQuery, options?: RequestOptions): Promise<PaginatedResponse<Stream>>;
|
|
33
|
+
/**
|
|
34
|
+
* 更新 Stream
|
|
35
|
+
* PUT /api/delivery-stream/streams/:id
|
|
36
|
+
*/
|
|
37
|
+
updateStream(streamId: string, request: UpdateStreamRequest, options?: RequestOptions): Promise<Stream>;
|
|
38
|
+
/**
|
|
39
|
+
* 删除 Stream(软删除)
|
|
40
|
+
* DELETE /api/delivery-stream/streams/:id
|
|
41
|
+
*/
|
|
42
|
+
deleteStream(streamId: string, options?: RequestOptions): Promise<null>;
|
|
43
|
+
/**
|
|
44
|
+
* 创建 Requirement
|
|
45
|
+
* POST /api/delivery-stream/streams/:streamId/requirements
|
|
46
|
+
*/
|
|
47
|
+
createRequirement(streamId: string, request: CreateRequirementRequest, options?: RequestOptions): Promise<Requirement>;
|
|
48
|
+
/**
|
|
49
|
+
* 获取 Requirement 详情
|
|
50
|
+
* GET /api/delivery-stream/streams/:streamId/requirements/:id
|
|
51
|
+
*/
|
|
52
|
+
getRequirement(streamId: string, requirementId: string, options?: RequestOptions): Promise<Requirement>;
|
|
53
|
+
/**
|
|
54
|
+
* 获取 Requirement 列表
|
|
55
|
+
* GET /api/delivery-stream/streams/:streamId/requirements
|
|
56
|
+
*/
|
|
57
|
+
listRequirements(streamId: string, query?: RequirementListQuery, options?: RequestOptions): Promise<PaginatedResponse<Requirement>>;
|
|
58
|
+
/**
|
|
59
|
+
* 更新 Requirement
|
|
60
|
+
* PUT /api/delivery-stream/streams/:streamId/requirements/:id
|
|
61
|
+
*/
|
|
62
|
+
updateRequirement(streamId: string, requirementId: string, request: UpdateRequirementRequest, options?: RequestOptions): Promise<Requirement>;
|
|
63
|
+
/**
|
|
64
|
+
* 删除 Requirement(软删除)
|
|
65
|
+
* DELETE /api/delivery-stream/streams/:streamId/requirements/:id
|
|
66
|
+
*/
|
|
67
|
+
deleteRequirement(streamId: string, requirementId: string, options?: RequestOptions): Promise<null>;
|
|
68
|
+
/**
|
|
69
|
+
* 检查 Stream 是否存在
|
|
70
|
+
*/
|
|
71
|
+
streamExists(streamId: string, options?: RequestOptions): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* 归档 Stream(快捷方法)
|
|
74
|
+
*/
|
|
75
|
+
archiveStream(streamId: string, options?: RequestOptions): Promise<Stream>;
|
|
76
|
+
/**
|
|
77
|
+
* 激活 Stream(快捷方法)
|
|
78
|
+
*/
|
|
79
|
+
activateStream(streamId: string, options?: RequestOptions): Promise<Stream>;
|
|
80
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeliveryStreamService = void 0;
|
|
4
|
+
const BaseClient_1 = require("../client/BaseClient");
|
|
5
|
+
/**
|
|
6
|
+
* Delivery Stream Service SDK
|
|
7
|
+
*
|
|
8
|
+
* 业务交付建模服务 - Stream(业务演进容器)& Requirement(需求池)
|
|
9
|
+
*
|
|
10
|
+
* MVP 特性:
|
|
11
|
+
* - scopeMode = personal(个人可见性)
|
|
12
|
+
* - Requirement 必须绑定 Stream
|
|
13
|
+
* - 软删除策略
|
|
14
|
+
*/
|
|
15
|
+
class DeliveryStreamService extends BaseClient_1.BaseClient {
|
|
16
|
+
constructor(config) {
|
|
17
|
+
super(config, 'delivery-stream');
|
|
18
|
+
}
|
|
19
|
+
// ==================== Stream CRUD ====================
|
|
20
|
+
/**
|
|
21
|
+
* 创建 Stream
|
|
22
|
+
* POST /api/delivery-stream/streams (网关转发到 /api/v1/streams)
|
|
23
|
+
*/
|
|
24
|
+
async createStream(request, options) {
|
|
25
|
+
return this.request('/streams', {
|
|
26
|
+
...options,
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body: request
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 获取 Stream 详情
|
|
33
|
+
* GET /api/delivery-stream/streams/:id
|
|
34
|
+
*/
|
|
35
|
+
async getStream(streamId, options) {
|
|
36
|
+
return this.request(`/streams/${streamId}`, {
|
|
37
|
+
...options,
|
|
38
|
+
method: 'GET'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 获取 Stream 列表
|
|
43
|
+
* GET /api/delivery-stream/streams
|
|
44
|
+
*
|
|
45
|
+
* 注意:只能查看自己创建的 Stream(personal 可见性)
|
|
46
|
+
*/
|
|
47
|
+
async listStreams(query, options) {
|
|
48
|
+
const params = {};
|
|
49
|
+
if (query?.status !== undefined) {
|
|
50
|
+
params.status = query.status;
|
|
51
|
+
}
|
|
52
|
+
if (query?.page !== undefined) {
|
|
53
|
+
params.page = query.page;
|
|
54
|
+
}
|
|
55
|
+
if (query?.limit !== undefined) {
|
|
56
|
+
params.limit = query.limit;
|
|
57
|
+
}
|
|
58
|
+
return this.paginatedRequest('/streams', {
|
|
59
|
+
...options,
|
|
60
|
+
method: 'GET',
|
|
61
|
+
params
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 更新 Stream
|
|
66
|
+
* PUT /api/delivery-stream/streams/:id
|
|
67
|
+
*/
|
|
68
|
+
async updateStream(streamId, request, options) {
|
|
69
|
+
return this.request(`/streams/${streamId}`, {
|
|
70
|
+
...options,
|
|
71
|
+
method: 'PUT',
|
|
72
|
+
body: request
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 删除 Stream(软删除)
|
|
77
|
+
* DELETE /api/delivery-stream/streams/:id
|
|
78
|
+
*/
|
|
79
|
+
async deleteStream(streamId, options) {
|
|
80
|
+
return this.request(`/streams/${streamId}`, {
|
|
81
|
+
...options,
|
|
82
|
+
method: 'DELETE'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// ==================== Requirement CRUD ====================
|
|
86
|
+
// Requirement 是 Stream 的嵌套资源,所有操作都需要 streamId
|
|
87
|
+
/**
|
|
88
|
+
* 创建 Requirement
|
|
89
|
+
* POST /api/delivery-stream/streams/:streamId/requirements
|
|
90
|
+
*/
|
|
91
|
+
async createRequirement(streamId, request, options) {
|
|
92
|
+
return this.request(`/streams/${streamId}/requirements`, {
|
|
93
|
+
...options,
|
|
94
|
+
method: 'POST',
|
|
95
|
+
body: request
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 获取 Requirement 详情
|
|
100
|
+
* GET /api/delivery-stream/streams/:streamId/requirements/:id
|
|
101
|
+
*/
|
|
102
|
+
async getRequirement(streamId, requirementId, options) {
|
|
103
|
+
return this.request(`/streams/${streamId}/requirements/${requirementId}`, {
|
|
104
|
+
...options,
|
|
105
|
+
method: 'GET'
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 获取 Requirement 列表
|
|
110
|
+
* GET /api/delivery-stream/streams/:streamId/requirements
|
|
111
|
+
*/
|
|
112
|
+
async listRequirements(streamId, query, options) {
|
|
113
|
+
const params = {};
|
|
114
|
+
if (query?.status !== undefined) {
|
|
115
|
+
params.status = query.status;
|
|
116
|
+
}
|
|
117
|
+
if (query?.page !== undefined) {
|
|
118
|
+
params.page = query.page;
|
|
119
|
+
}
|
|
120
|
+
if (query?.limit !== undefined) {
|
|
121
|
+
params.limit = query.limit;
|
|
122
|
+
}
|
|
123
|
+
return this.paginatedRequest(`/streams/${streamId}/requirements`, {
|
|
124
|
+
...options,
|
|
125
|
+
method: 'GET',
|
|
126
|
+
params
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 更新 Requirement
|
|
131
|
+
* PUT /api/delivery-stream/streams/:streamId/requirements/:id
|
|
132
|
+
*/
|
|
133
|
+
async updateRequirement(streamId, requirementId, request, options) {
|
|
134
|
+
return this.request(`/streams/${streamId}/requirements/${requirementId}`, {
|
|
135
|
+
...options,
|
|
136
|
+
method: 'PUT',
|
|
137
|
+
body: request
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 删除 Requirement(软删除)
|
|
142
|
+
* DELETE /api/delivery-stream/streams/:streamId/requirements/:id
|
|
143
|
+
*/
|
|
144
|
+
async deleteRequirement(streamId, requirementId, options) {
|
|
145
|
+
return this.request(`/streams/${streamId}/requirements/${requirementId}`, {
|
|
146
|
+
...options,
|
|
147
|
+
method: 'DELETE'
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// ==================== 便捷方法 ====================
|
|
151
|
+
/**
|
|
152
|
+
* 检查 Stream 是否存在
|
|
153
|
+
*/
|
|
154
|
+
async streamExists(streamId, options) {
|
|
155
|
+
try {
|
|
156
|
+
await this.getStream(streamId, options);
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 归档 Stream(快捷方法)
|
|
165
|
+
*/
|
|
166
|
+
async archiveStream(streamId, options) {
|
|
167
|
+
return this.updateStream(streamId, { status: 'Archived' }, options);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 激活 Stream(快捷方法)
|
|
171
|
+
*/
|
|
172
|
+
async activateStream(streamId, options) {
|
|
173
|
+
return this.updateStream(streamId, { status: 'Active' }, options);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.DeliveryStreamService = DeliveryStreamService;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { BaseClient } from "../client/BaseClient";
|
|
2
|
+
import { ClientConfig } from "../types";
|
|
3
|
+
import { EnumerateRequirementsRequest, EnumerateRequirementsResponse, TaskQueryResponse } from "../types/ez-ability";
|
|
4
|
+
/**
|
|
5
|
+
* EzAbility 服务 - AI 能力服务客户端
|
|
6
|
+
*
|
|
7
|
+
* 功能:
|
|
8
|
+
* - 需求枚举(异步任务)
|
|
9
|
+
* - 任务状态查询
|
|
10
|
+
* - 任务取消
|
|
11
|
+
*
|
|
12
|
+
* 注意:任务进度通过 WebSocket 网关推送,不在此 SDK 中处理
|
|
13
|
+
*/
|
|
14
|
+
export declare class EzAbilityService extends BaseClient {
|
|
15
|
+
constructor(config: ClientConfig);
|
|
16
|
+
/**
|
|
17
|
+
* 创建需求枚举任务
|
|
18
|
+
*
|
|
19
|
+
* 异步任务,立即返回 taskId
|
|
20
|
+
* 进度通过 WebSocket 推送
|
|
21
|
+
*
|
|
22
|
+
* @param request 需求描述
|
|
23
|
+
* @returns 任务信息
|
|
24
|
+
*/
|
|
25
|
+
enumerateRequirements(request: EnumerateRequirementsRequest): Promise<EnumerateRequirementsResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* 查询任务状态
|
|
28
|
+
*
|
|
29
|
+
* 用于轮询或重连后恢复任务状态
|
|
30
|
+
*
|
|
31
|
+
* @param taskId 任务ID
|
|
32
|
+
* @returns 任务详情
|
|
33
|
+
*/
|
|
34
|
+
getTask(taskId: string): Promise<TaskQueryResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* 取消任务
|
|
37
|
+
*
|
|
38
|
+
* @param taskId 任务ID
|
|
39
|
+
* @returns 取消结果
|
|
40
|
+
*/
|
|
41
|
+
cancelTask(taskId: string): Promise<{
|
|
42
|
+
message: string;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* 等待任务完成(轮询方式)
|
|
46
|
+
*
|
|
47
|
+
* 注意:推荐使用 WebSocket 接收进度,此方法仅用于简单场景
|
|
48
|
+
*
|
|
49
|
+
* @param taskId 任务ID
|
|
50
|
+
* @param options 轮询选项
|
|
51
|
+
* @returns 任务结果
|
|
52
|
+
*/
|
|
53
|
+
waitForTask(taskId: string, options?: {
|
|
54
|
+
pollInterval?: number;
|
|
55
|
+
timeout?: number;
|
|
56
|
+
onProgress?: (task: TaskQueryResponse) => void;
|
|
57
|
+
}): Promise<TaskQueryResponse>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EzAbilityService = void 0;
|
|
4
|
+
// npm/src/service/EzAbilityService.ts
|
|
5
|
+
const BaseClient_1 = require("../client/BaseClient");
|
|
6
|
+
/**
|
|
7
|
+
* EzAbility 服务 - AI 能力服务客户端
|
|
8
|
+
*
|
|
9
|
+
* 功能:
|
|
10
|
+
* - 需求枚举(异步任务)
|
|
11
|
+
* - 任务状态查询
|
|
12
|
+
* - 任务取消
|
|
13
|
+
*
|
|
14
|
+
* 注意:任务进度通过 WebSocket 网关推送,不在此 SDK 中处理
|
|
15
|
+
*/
|
|
16
|
+
class EzAbilityService extends BaseClient_1.BaseClient {
|
|
17
|
+
constructor(config) {
|
|
18
|
+
super(config, "ez-ability");
|
|
19
|
+
}
|
|
20
|
+
// ==================== 需求枚举 ====================
|
|
21
|
+
/**
|
|
22
|
+
* 创建需求枚举任务
|
|
23
|
+
*
|
|
24
|
+
* 异步任务,立即返回 taskId
|
|
25
|
+
* 进度通过 WebSocket 推送
|
|
26
|
+
*
|
|
27
|
+
* @param request 需求描述
|
|
28
|
+
* @returns 任务信息
|
|
29
|
+
*/
|
|
30
|
+
async enumerateRequirements(request) {
|
|
31
|
+
return this.request("/requirements/enumerate", {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: request,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// ==================== 任务管理 ====================
|
|
37
|
+
/**
|
|
38
|
+
* 查询任务状态
|
|
39
|
+
*
|
|
40
|
+
* 用于轮询或重连后恢复任务状态
|
|
41
|
+
*
|
|
42
|
+
* @param taskId 任务ID
|
|
43
|
+
* @returns 任务详情
|
|
44
|
+
*/
|
|
45
|
+
async getTask(taskId) {
|
|
46
|
+
return this.request(`/requirements/tasks/${taskId}`, { method: "GET" });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 取消任务
|
|
50
|
+
*
|
|
51
|
+
* @param taskId 任务ID
|
|
52
|
+
* @returns 取消结果
|
|
53
|
+
*/
|
|
54
|
+
async cancelTask(taskId) {
|
|
55
|
+
return this.request(`/requirements/tasks/${taskId}`, { method: "DELETE" });
|
|
56
|
+
}
|
|
57
|
+
// ==================== 便捷方法 ====================
|
|
58
|
+
/**
|
|
59
|
+
* 等待任务完成(轮询方式)
|
|
60
|
+
*
|
|
61
|
+
* 注意:推荐使用 WebSocket 接收进度,此方法仅用于简单场景
|
|
62
|
+
*
|
|
63
|
+
* @param taskId 任务ID
|
|
64
|
+
* @param options 轮询选项
|
|
65
|
+
* @returns 任务结果
|
|
66
|
+
*/
|
|
67
|
+
async waitForTask(taskId, options) {
|
|
68
|
+
const pollInterval = options?.pollInterval || 2000;
|
|
69
|
+
const timeout = options?.timeout || 300000;
|
|
70
|
+
const startTime = Date.now();
|
|
71
|
+
while (true) {
|
|
72
|
+
const task = await this.getTask(taskId);
|
|
73
|
+
// 回调进度
|
|
74
|
+
if (options?.onProgress) {
|
|
75
|
+
options.onProgress(task);
|
|
76
|
+
}
|
|
77
|
+
// 任务完成
|
|
78
|
+
if (task.status === 'completed' || task.status === 'failed' || task.status === 'cancelled') {
|
|
79
|
+
return task;
|
|
80
|
+
}
|
|
81
|
+
// 检查超时
|
|
82
|
+
if (Date.now() - startTime > timeout) {
|
|
83
|
+
throw new Error(`Task ${taskId} timeout after ${timeout}ms`);
|
|
84
|
+
}
|
|
85
|
+
// 等待下次轮询
|
|
86
|
+
await new Promise(resolve => setTimeout(resolve, pollInterval));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.EzAbilityService = EzAbilityService;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export type StreamStatus = 'Draft' | 'Active' | 'Archived';
|
|
2
|
+
export interface Stream {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
status: StreamStatus;
|
|
6
|
+
description?: string;
|
|
7
|
+
owner?: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
userId: string;
|
|
10
|
+
visibilityScope: 'personal';
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CreateStreamRequest {
|
|
15
|
+
name: string;
|
|
16
|
+
status?: StreamStatus;
|
|
17
|
+
description?: string;
|
|
18
|
+
owner?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface UpdateStreamRequest {
|
|
21
|
+
name?: string;
|
|
22
|
+
status?: StreamStatus;
|
|
23
|
+
description?: string;
|
|
24
|
+
owner?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface StreamListQuery {
|
|
27
|
+
status?: StreamStatus;
|
|
28
|
+
page?: number;
|
|
29
|
+
limit?: number;
|
|
30
|
+
}
|
|
31
|
+
export type RequirementStatus = 'New' | 'Accepted' | 'Planned' | 'Released' | 'Dropped';
|
|
32
|
+
export interface Requirement {
|
|
33
|
+
id: string;
|
|
34
|
+
title: string;
|
|
35
|
+
content: string;
|
|
36
|
+
source: string;
|
|
37
|
+
status: RequirementStatus;
|
|
38
|
+
streamId: string;
|
|
39
|
+
expectedRelease?: string;
|
|
40
|
+
actualRelease?: string;
|
|
41
|
+
projectId: string;
|
|
42
|
+
userId: string;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
updatedAt: string;
|
|
45
|
+
}
|
|
46
|
+
export interface CreateRequirementRequest {
|
|
47
|
+
title: string;
|
|
48
|
+
content: string;
|
|
49
|
+
source: string;
|
|
50
|
+
status?: RequirementStatus;
|
|
51
|
+
expectedRelease?: string;
|
|
52
|
+
actualRelease?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface UpdateRequirementRequest {
|
|
55
|
+
title?: string;
|
|
56
|
+
content?: string;
|
|
57
|
+
source?: string;
|
|
58
|
+
status?: RequirementStatus;
|
|
59
|
+
expectedRelease?: string;
|
|
60
|
+
actualRelease?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface RequirementListQuery {
|
|
63
|
+
status?: RequirementStatus;
|
|
64
|
+
page?: number;
|
|
65
|
+
limit?: number;
|
|
66
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
2
|
+
export interface TaskProgressEvent {
|
|
3
|
+
taskId: string;
|
|
4
|
+
type: string;
|
|
5
|
+
status: TaskStatus;
|
|
6
|
+
progress: number;
|
|
7
|
+
currentStep?: string;
|
|
8
|
+
delta?: any;
|
|
9
|
+
result?: any;
|
|
10
|
+
error?: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
}
|
|
13
|
+
export interface EnumerateRequirementsRequest {
|
|
14
|
+
/** 需求描述(用户的原始需求文本) */
|
|
15
|
+
userRequest: string;
|
|
16
|
+
/** 枚举轮数(1-10),轮数越多需求越全面,默认 5 */
|
|
17
|
+
maxRounds?: number;
|
|
18
|
+
/** 指定使用的模型(不传则使用服务默认模型) */
|
|
19
|
+
model?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface EnumerateRequirementsResponse {
|
|
22
|
+
taskId: string;
|
|
23
|
+
status: TaskStatus;
|
|
24
|
+
message: string;
|
|
25
|
+
}
|
|
26
|
+
export interface EnumerateRequirementsResult {
|
|
27
|
+
requirements: string[];
|
|
28
|
+
totalRounds: number;
|
|
29
|
+
totalCount: number;
|
|
30
|
+
}
|
|
31
|
+
export interface TaskQueryResponse {
|
|
32
|
+
taskId: string;
|
|
33
|
+
type: string;
|
|
34
|
+
status: TaskStatus;
|
|
35
|
+
progress: number;
|
|
36
|
+
currentStep?: string;
|
|
37
|
+
output?: any;
|
|
38
|
+
error?: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
startedAt?: string;
|
|
41
|
+
completedAt?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface AbilityCallRequest {
|
|
44
|
+
abilityId: string;
|
|
45
|
+
params: Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
export interface AbilityCallResponse {
|
|
48
|
+
taskId: string;
|
|
49
|
+
status: TaskStatus;
|
|
50
|
+
message: string;
|
|
51
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface ClientConfig {
|
|
|
33
33
|
providerServiceUrl?: string;
|
|
34
34
|
gatewayH5ServiceUrl?: string;
|
|
35
35
|
orgServiceUrl?: string;
|
|
36
|
+
deliveryStreamServiceUrl?: string;
|
|
37
|
+
ezAbilityServiceUrl?: string;
|
|
36
38
|
tokenStorage?: TokenStorage;
|
|
37
39
|
projectId?: string;
|
|
38
40
|
orgId?: string;
|
|
@@ -61,3 +63,4 @@ export interface RequestOptions {
|
|
|
61
63
|
export * from "./provider";
|
|
62
64
|
export * from "./usage";
|
|
63
65
|
export * from "./audit";
|
|
66
|
+
export * from "./ez-ability";
|
package/lib/types/index.js
CHANGED