@qzsy/group-sdk 0.1.1 → 0.1.3
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/CHANGELOG.md +35 -1
- package/README.md +9 -7
- package/dist/client.d.ts +35 -0
- package/dist/constants.d.ts +8 -0
- package/dist/errors.d.ts +13 -0
- package/dist/index.cjs +45 -43
- package/dist/index.d.ts +6 -49
- package/dist/index.js +23 -48
- package/package.json +6 -5
- package/dist/index.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# 变更记录
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### 变更
|
|
6
|
+
|
|
7
|
+
- 常量改为从 `@qzsy/unipay-sdk` 复用(`GROUP_LIMITS` / `GROUP_STATEMENT_SCOPES`),不再在本包维护副本;契约校验脚本改为比对 SDK 与网关
|
|
8
|
+
- 操作人示例改为 ASCII;SDK 会在发请求前拒绝中文操作人名
|
|
9
|
+
- `withOperator()` 显式重建客户端(复制凭据与 fetch),换身份后的首个请求会重新取令牌
|
|
10
|
+
- 声明 Node ≥ 20.19(CJS 产物通过 `require(esm)` 依赖 ESM-only 的 `@qzsy/unipay-sdk`)
|
|
11
|
+
- 类型检查纳入测试文件(`tsconfig.test.json`);构建不再产出指向未发布源码的 `.d.ts.map`
|
|
12
|
+
|
|
13
|
+
### 升级说明
|
|
14
|
+
|
|
15
|
+
- 依赖 `@qzsy/unipay-sdk@^0.3.2`
|
|
16
|
+
- 公开 API 不变
|
|
17
|
+
|
|
18
|
+
## 0.1.2
|
|
19
|
+
|
|
20
|
+
### 重构(不改变对外行为)
|
|
21
|
+
|
|
22
|
+
- 按职责拆分为 `client.ts`(客户端)/ `constants.ts`(上限与 scope)/ `errors.ts`(错误文案),`index.ts` 只做导出
|
|
23
|
+
- 默认操作人合并下沉到 `@qzsy/unipay-sdk` 的 `GroupClient.defaultOperator`:本包不再逐个覆写 5 个写方法,新增写接口不会漏带操作人
|
|
24
|
+
- 操作人只随写请求(带幂等键)发送;读请求继续保持不携带(新增传输层门禁,防止将来给读方法传 options 时泄漏)
|
|
25
|
+
- `describeGroupError` 去掉多余类型断言,网关错误直接用 `message`
|
|
26
|
+
- 新增 `scripts/check-group-contract.ts` 校验本包常量与网关 `group-queries.ts` 一致
|
|
27
|
+
|
|
28
|
+
### 升级说明
|
|
29
|
+
|
|
30
|
+
- 依赖 `@qzsy/unipay-sdk@^0.3.1`
|
|
31
|
+
- 公开 API 不变(`createGroupClient` / `GroupSdkClient` / `GROUP_LIMITS` / `GROUP_STATEMENT_SCOPES` / `describeGroupError`)
|
|
32
|
+
|
|
33
|
+
## 0.1.1
|
|
34
|
+
|
|
35
|
+
- 与 0.1.0 功能相同;首次发布时 npm 暂存队列延迟,重新发布以让 `latest` 指向可用版本
|
|
36
|
+
|
|
3
37
|
## 0.1.0
|
|
4
38
|
|
|
5
39
|
首个版本:群兴云集团 SaaS 对接支付网关的独立 SDK。
|
|
@@ -10,4 +44,4 @@
|
|
|
10
44
|
- 五个写接口(建主体 / 建应用 / 绑通道 / 进件 / 申请分账)自动携带 `X-Operator-*`
|
|
11
45
|
- 导出 `GROUP_LIMITS`、`GROUP_STATEMENT_SCOPES` 常量与 `describeGroupError` 错误格式化
|
|
12
46
|
- 完整转出 `@qzsy/unipay-sdk`:集团侧只装一个包,即可同时使用应用维度接口(下单 / 收银台 / 退款 / 付款)
|
|
13
|
-
- 覆盖接口:G-1~G-10 读接口、W-1~W-6 写接口
|
|
47
|
+
- 覆盖接口:G-1~G-10 读接口、W-1~W-6 写接口
|
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
底层 HTTP、OAuth 令牌缓存、错误模型全部复用 [`@qzsy/unipay-sdk`](https://www.npmjs.com/package/@qzsy/unipay-sdk),所以集团侧只需要安装这一个包:应用维度(下单、收银台、退款、付款)的能力也一并可用。
|
|
6
6
|
|
|
7
|
-
- Node.js ≥
|
|
8
|
-
- ESM / CJS / TypeScript
|
|
7
|
+
- Node.js ≥ 20.19(原生 `fetch` 与 `require(esm)`;无运行时依赖)
|
|
8
|
+
- ESM / CJS / TypeScript 类型三者齐全(CJS 依赖 Node ≥ 20.19 的 `require(esm)`;更早版本请用 ESM 入口)
|
|
9
9
|
- 金额一律「分」为单位,时间一律 ISO 8601 字符串
|
|
10
10
|
|
|
11
11
|
## 安装
|
|
@@ -53,6 +53,7 @@ const { entity } = await group.createEntity({
|
|
|
53
53
|
const { application, credential } = await group.createApplication({
|
|
54
54
|
entity_id: entity.id,
|
|
55
55
|
name: '西湖店小程序',
|
|
56
|
+
slug: 'xihu-mini', // 组织内唯一;留空会按名称生成,生成不出合法 slug 时必填
|
|
56
57
|
wechat_app_id: 'wx1234567890abcdef',
|
|
57
58
|
})
|
|
58
59
|
|
|
@@ -140,17 +141,18 @@ const { items: payouts, next_cursor } = await group.listGroupPayouts({
|
|
|
140
141
|
const group = createGroupClient({ baseUrl, clientId, clientSecret, operator })
|
|
141
142
|
|
|
142
143
|
// 方式二:换一个身份(复用同一套凭据)
|
|
143
|
-
const asStoreManager = group.withOperator({ id: 'store_1_manager', name: '
|
|
144
|
+
const asStoreManager = group.withOperator({ id: 'store_1_manager', name: 'Store Manager' })
|
|
144
145
|
|
|
145
146
|
// 单次覆盖
|
|
146
|
-
await group.createEntity(input, { operator: { id: 'manager_2', name: '
|
|
147
|
+
await group.createEntity(input, { operator: { id: 'manager_2', name: 'Ops' } })
|
|
147
148
|
```
|
|
148
149
|
|
|
149
|
-
>
|
|
150
|
+
> 三个字段都会进 HTTP 头,**只能使用 ASCII 可见字符**(中文名会被 SDK 在发请求前拒绝,报「只能使用 ASCII 可见字符」)。操作人只随写请求(同时带幂等键)发送,读请求不带。
|
|
151
|
+
> `withOperator()` 复用同一套凭据,但令牌缓存是实例级的 —— 换身份后的第一个请求会重新取一次令牌。
|
|
150
152
|
|
|
151
153
|
## 幂等
|
|
152
154
|
|
|
153
|
-
所有写接口自动携带 `Idempotency-Key
|
|
155
|
+
所有写接口自动携带 `Idempotency-Key`(每次调用生成;401 刷新令牌后的自动重试会复用同一把键)。**网络超时后请自行重试并显式传 `{ idempotencyKey }` 复用**,否则会生成新键。业务侧更应依赖自然幂等键:
|
|
154
156
|
|
|
155
157
|
- W-1 建主体:`license_no` 相同 → 返回已有主体
|
|
156
158
|
- W-2 建应用:`(entity_id, slug, LIVE)` 相同 → 返回已有应用,`credential` 为 `null`
|
|
@@ -187,4 +189,4 @@ import type {
|
|
|
187
189
|
|
|
188
190
|
## 许可
|
|
189
191
|
|
|
190
|
-
|
|
192
|
+
MIT。问题请提给支付网关仓库。
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GroupClient, type GroupClientOptions, type GroupOperator } from '@qzsy/unipay-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* 集团 SDK 的构造参数:在集团凭据之外,可带一个默认操作人。
|
|
4
|
+
*
|
|
5
|
+
* `operator` 是对外的简写,内部映射到 `GroupClient` 的 `defaultOperator`,
|
|
6
|
+
* 由基类在组装请求头时合并(不在本包重复实现)。
|
|
7
|
+
*/
|
|
8
|
+
export interface GroupSdkOptions extends Omit<GroupClientOptions, 'defaultOperator'> {
|
|
9
|
+
/**
|
|
10
|
+
* 默认操作人:集团总管理员代门店操作时上报,网关写入审计与审批单。
|
|
11
|
+
* 单个调用也可以用 `{ operator }` 覆盖。
|
|
12
|
+
*
|
|
13
|
+
* 三个字段都会进 HTTP 头,**只能使用 ASCII 可见字符**(中文名会被 SDK 提前拒绝)。
|
|
14
|
+
*/
|
|
15
|
+
operator?: GroupOperator;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 带默认操作人的集团客户端。
|
|
19
|
+
*
|
|
20
|
+
* 相比基类只多两件事:`defaultOperator` 可读、`withOperator()` 换身份复用凭据;
|
|
21
|
+
* 操作人合并在基类的传输层完成,这里不再逐方法覆写。
|
|
22
|
+
*/
|
|
23
|
+
export declare class GroupSdkClient extends GroupClient {
|
|
24
|
+
constructor(options: GroupSdkOptions);
|
|
25
|
+
/** 构造时配置的默认操作人 */
|
|
26
|
+
get defaultOperator(): GroupOperator | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* 换一个默认操作人:复用同一套凭据与 fetch 实现,返回新客户端。
|
|
29
|
+
*
|
|
30
|
+
* 注意令牌缓存是实例级的,换身份后的第一个请求会重新取一次令牌。
|
|
31
|
+
*/
|
|
32
|
+
withOperator(operator: GroupOperator): GroupSdkClient;
|
|
33
|
+
}
|
|
34
|
+
/** 创建集团客户端(推荐入口) */
|
|
35
|
+
export declare function createGroupClient(options: GroupSdkOptions): GroupSdkClient;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把任意错误整理成可展示的文案:网关错误直接用 `message`(`GatewayError` 已经把
|
|
3
|
+
* `problem.detail`/`problem.title` 合成为 message),其它错误取 `message`,兜底「未知错误」。
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* try {
|
|
7
|
+
* await group.createEntity(input)
|
|
8
|
+
* } catch (error) {
|
|
9
|
+
* toast.error(describeGroupError(error))
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function describeGroupError(error: unknown): string;
|
package/dist/index.cjs
CHANGED
|
@@ -57,69 +57,71 @@ var __export = (target, all) => {
|
|
|
57
57
|
// src/index.ts
|
|
58
58
|
var exports_src = {};
|
|
59
59
|
__export(exports_src, {
|
|
60
|
-
GROUP_LIMITS: () => GROUP_LIMITS,
|
|
61
|
-
GROUP_STATEMENT_SCOPES: () => GROUP_STATEMENT_SCOPES,
|
|
62
|
-
GroupClient: () => import_unipay_sdk.GroupClient,
|
|
60
|
+
GROUP_LIMITS: () => import_unipay_sdk2.GROUP_LIMITS,
|
|
61
|
+
GROUP_STATEMENT_SCOPES: () => import_unipay_sdk2.GROUP_STATEMENT_SCOPES,
|
|
63
62
|
GroupSdkClient: () => GroupSdkClient,
|
|
64
|
-
UnifiedPay: () => import_unipay_sdk.UnifiedPay,
|
|
65
63
|
createGroupClient: () => createGroupClient,
|
|
66
64
|
describeGroupError: () => describeGroupError
|
|
67
65
|
});
|
|
68
66
|
module.exports = __toCommonJS(exports_src);
|
|
67
|
+
|
|
68
|
+
// src/client.ts
|
|
69
|
+
var exports_client = {};
|
|
70
|
+
__export(exports_client, {
|
|
71
|
+
GroupSdkClient: () => GroupSdkClient,
|
|
72
|
+
createGroupClient: () => createGroupClient
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// src/constants.ts
|
|
76
|
+
var exports_constants = {};
|
|
77
|
+
__export(exports_constants, {
|
|
78
|
+
GROUP_LIMITS: () => import_unipay_sdk2.GROUP_LIMITS,
|
|
79
|
+
GROUP_STATEMENT_SCOPES: () => import_unipay_sdk2.GROUP_STATEMENT_SCOPES
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// src/errors.ts
|
|
83
|
+
var exports_errors = {};
|
|
84
|
+
__export(exports_errors, {
|
|
85
|
+
describeGroupError: () => describeGroupError
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// src/client.ts
|
|
69
89
|
var import_unipay_sdk = require("@qzsy/unipay-sdk");
|
|
70
|
-
__reExport(exports_src, require("@qzsy/unipay-sdk"), module.exports);
|
|
71
|
-
var GROUP_STATEMENT_SCOPES = ["ORG", "ENTITY", "STORE"];
|
|
72
|
-
var GROUP_LIMITS = {
|
|
73
|
-
list: 100,
|
|
74
|
-
page: 500,
|
|
75
|
-
snapshot: 200,
|
|
76
|
-
statementLines: 1000
|
|
77
|
-
};
|
|
78
90
|
|
|
79
91
|
class GroupSdkClient extends import_unipay_sdk.GroupClient {
|
|
80
|
-
sdkOptions;
|
|
81
92
|
constructor(options) {
|
|
82
|
-
const { operator
|
|
83
|
-
super(clientOptions);
|
|
84
|
-
this.sdkOptions = options;
|
|
93
|
+
const { operator, ...clientOptions } = options;
|
|
94
|
+
super({ ...clientOptions, ...operator ? { defaultOperator: operator } : {} });
|
|
85
95
|
}
|
|
86
96
|
get defaultOperator() {
|
|
87
|
-
return this.
|
|
97
|
+
return this.groupOperator;
|
|
88
98
|
}
|
|
89
99
|
withOperator(operator) {
|
|
90
|
-
return new GroupSdkClient({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return super.createEntity(input, this.withDefaultOperator(options));
|
|
100
|
-
}
|
|
101
|
-
async createApplication(input, options = {}) {
|
|
102
|
-
return super.createApplication(input, this.withDefaultOperator(options));
|
|
103
|
-
}
|
|
104
|
-
async bindApplicationChannel(input, options = {}) {
|
|
105
|
-
return super.bindApplicationChannel(input, this.withDefaultOperator(options));
|
|
106
|
-
}
|
|
107
|
-
async createMerchantAccount(input, options = {}) {
|
|
108
|
-
return super.createMerchantAccount(input, this.withDefaultOperator(options));
|
|
109
|
-
}
|
|
110
|
-
async applyEscrowPermission(accountId, options = {}) {
|
|
111
|
-
return super.applyEscrowPermission(accountId, this.withDefaultOperator(options));
|
|
100
|
+
return new GroupSdkClient({
|
|
101
|
+
baseUrl: this.baseUrl,
|
|
102
|
+
clientId: this.clientId,
|
|
103
|
+
clientSecret: this.clientSecret,
|
|
104
|
+
scope: this.scope,
|
|
105
|
+
fetch: this.fetchImpl,
|
|
106
|
+
tokenRefreshSkewSeconds: this.tokenRefreshSkewSeconds,
|
|
107
|
+
operator
|
|
108
|
+
});
|
|
112
109
|
}
|
|
113
110
|
}
|
|
114
111
|
function createGroupClient(options) {
|
|
115
112
|
return new GroupSdkClient(options);
|
|
116
113
|
}
|
|
114
|
+
// src/constants.ts
|
|
115
|
+
var import_unipay_sdk2 = require("@qzsy/unipay-sdk");
|
|
116
|
+
// src/errors.ts
|
|
117
|
+
var import_unipay_sdk3 = require("@qzsy/unipay-sdk");
|
|
117
118
|
function describeGroupError(error) {
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
return problem?.detail || problem?.title || error.message || "网关返回了错误";
|
|
121
|
-
}
|
|
119
|
+
if (import_unipay_sdk3.isGatewayError(error))
|
|
120
|
+
return error.message || "网关返回了错误";
|
|
122
121
|
if (error instanceof Error)
|
|
123
122
|
return error.message;
|
|
124
123
|
return "未知错误";
|
|
125
124
|
}
|
|
125
|
+
|
|
126
|
+
// src/index.ts
|
|
127
|
+
__reExport(exports_src, require("@qzsy/unipay-sdk"), module.exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @qzsy/group-sdk
|
|
3
3
|
*
|
|
4
4
|
* 群兴云集团 SaaS 对接统一支付网关:集团凭据 → 多营业执照主体 → 每执照一个小程序应用
|
|
5
|
-
* → 门店账单与佣金付款。底层 HTTP
|
|
5
|
+
* → 门店账单与佣金付款。底层 HTTP、令牌缓存、操作人与类型复用 `@qzsy/unipay-sdk`。
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
8
|
* const group = createGroupClient({
|
|
@@ -16,54 +16,11 @@
|
|
|
16
16
|
* const { items } = await group.listEntities() // G-2
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
export type GroupStatementScope = (typeof GROUP_STATEMENT_SCOPES)[number];
|
|
23
|
-
/** 列表类接口的服务端上限:普通列表 100、单页 500、快照每维 200、账单明细 1000 */
|
|
24
|
-
export declare const GROUP_LIMITS: {
|
|
25
|
-
readonly list: 100;
|
|
26
|
-
readonly page: 500;
|
|
27
|
-
readonly snapshot: 200;
|
|
28
|
-
readonly statementLines: 1000;
|
|
29
|
-
};
|
|
30
|
-
/** 集团 SDK 的构造参数:在集团凭据之外,可带一个默认操作人 */
|
|
31
|
-
export interface GroupSdkOptions extends GroupClientOptions {
|
|
32
|
-
/**
|
|
33
|
-
* 默认操作人:集团总管理员代门店操作时上报,网关写入审计与审批单。
|
|
34
|
-
* 单个调用也可以用 `{ operator }` 覆盖。
|
|
35
|
-
*/
|
|
36
|
-
operator?: GroupOperator;
|
|
37
|
-
}
|
|
19
|
+
export { GroupSdkClient, createGroupClient, type GroupSdkOptions } from './client';
|
|
20
|
+
export { GROUP_LIMITS, GROUP_STATEMENT_SCOPES, type GroupStatementScope } from './constants';
|
|
21
|
+
export { describeGroupError } from './errors';
|
|
38
22
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* 与 `GroupClient` 的唯一差别:写接口不传 `options.operator` 时自动带上构造时的操作人,
|
|
42
|
-
* 集团侧不用每个写操作都重复拼 `X-Operator-*`。
|
|
43
|
-
*/
|
|
44
|
-
export declare class GroupSdkClient extends GroupClient {
|
|
45
|
-
/** 构造参数(保留一份,便于 `withOperator` 换身份复用连接配置) */
|
|
46
|
-
private readonly sdkOptions;
|
|
47
|
-
constructor(options: GroupSdkOptions);
|
|
48
|
-
/** 构造时配置的默认操作人 */
|
|
49
|
-
get defaultOperator(): GroupOperator | undefined;
|
|
50
|
-
/** 换一个默认操作人:复用同一套凭据,返回新客户端 */
|
|
51
|
-
withOperator(operator: GroupOperator): GroupSdkClient;
|
|
52
|
-
/** 写操作合并默认操作人(显式传入的优先) */
|
|
53
|
-
private withDefaultOperator;
|
|
54
|
-
createEntity(input: CreateGroupEntityInput, options?: GroupMutationOptions): Promise<GroupEntityResponse>;
|
|
55
|
-
createApplication(input: CreateGroupApplicationInput, options?: GroupMutationOptions): Promise<GroupApplicationResponse>;
|
|
56
|
-
bindApplicationChannel(input: BindGroupApplicationChannelInput, options?: GroupMutationOptions): Promise<GroupApplicationChannelResponse>;
|
|
57
|
-
createMerchantAccount(input: CreateGroupMerchantAccountInput, options?: GroupMutationOptions): Promise<GroupMerchantAccountResponse>;
|
|
58
|
-
applyEscrowPermission(accountId: string, options?: GroupMutationOptions): Promise<GroupEscrowApplication>;
|
|
59
|
-
}
|
|
60
|
-
/** 创建集团客户端(推荐入口) */
|
|
61
|
-
export declare function createGroupClient(options: GroupSdkOptions): GroupSdkClient;
|
|
62
|
-
/**
|
|
63
|
-
* 把任意错误整理成可展示的文案:优先用网关的 `problem.detail`,
|
|
64
|
-
* 否则回退 `message`,最后兜底。
|
|
23
|
+
* 底层客户端与全部类型:集团侧只装这一个包,
|
|
24
|
+
* 应用维度(下单/收银台/退款/付款)的能力与 `GroupClient` 在这里一并转出。
|
|
65
25
|
*/
|
|
66
|
-
export declare function describeGroupError(error: unknown): string;
|
|
67
|
-
export { GroupClient, UnifiedPay };
|
|
68
26
|
export * from '@qzsy/unipay-sdk';
|
|
69
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,72 +1,47 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import {
|
|
3
|
-
GroupClient,
|
|
4
|
-
isGatewayError,
|
|
5
|
-
UnifiedPay
|
|
6
|
-
} from "@qzsy/unipay-sdk";
|
|
7
|
-
|
|
8
|
-
export * from "@qzsy/unipay-sdk";
|
|
9
|
-
var GROUP_STATEMENT_SCOPES = ["ORG", "ENTITY", "STORE"];
|
|
10
|
-
var GROUP_LIMITS = {
|
|
11
|
-
list: 100,
|
|
12
|
-
page: 500,
|
|
13
|
-
snapshot: 200,
|
|
14
|
-
statementLines: 1000
|
|
15
|
-
};
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import { GroupClient } from "@qzsy/unipay-sdk";
|
|
16
3
|
|
|
17
4
|
class GroupSdkClient extends GroupClient {
|
|
18
|
-
sdkOptions;
|
|
19
5
|
constructor(options) {
|
|
20
|
-
const { operator
|
|
21
|
-
super(clientOptions);
|
|
22
|
-
this.sdkOptions = options;
|
|
6
|
+
const { operator, ...clientOptions } = options;
|
|
7
|
+
super({ ...clientOptions, ...operator ? { defaultOperator: operator } : {} });
|
|
23
8
|
}
|
|
24
9
|
get defaultOperator() {
|
|
25
|
-
return this.
|
|
10
|
+
return this.groupOperator;
|
|
26
11
|
}
|
|
27
12
|
withOperator(operator) {
|
|
28
|
-
return new GroupSdkClient({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return super.createEntity(input, this.withDefaultOperator(options));
|
|
38
|
-
}
|
|
39
|
-
async createApplication(input, options = {}) {
|
|
40
|
-
return super.createApplication(input, this.withDefaultOperator(options));
|
|
41
|
-
}
|
|
42
|
-
async bindApplicationChannel(input, options = {}) {
|
|
43
|
-
return super.bindApplicationChannel(input, this.withDefaultOperator(options));
|
|
44
|
-
}
|
|
45
|
-
async createMerchantAccount(input, options = {}) {
|
|
46
|
-
return super.createMerchantAccount(input, this.withDefaultOperator(options));
|
|
47
|
-
}
|
|
48
|
-
async applyEscrowPermission(accountId, options = {}) {
|
|
49
|
-
return super.applyEscrowPermission(accountId, this.withDefaultOperator(options));
|
|
13
|
+
return new GroupSdkClient({
|
|
14
|
+
baseUrl: this.baseUrl,
|
|
15
|
+
clientId: this.clientId,
|
|
16
|
+
clientSecret: this.clientSecret,
|
|
17
|
+
scope: this.scope,
|
|
18
|
+
fetch: this.fetchImpl,
|
|
19
|
+
tokenRefreshSkewSeconds: this.tokenRefreshSkewSeconds,
|
|
20
|
+
operator
|
|
21
|
+
});
|
|
50
22
|
}
|
|
51
23
|
}
|
|
52
24
|
function createGroupClient(options) {
|
|
53
25
|
return new GroupSdkClient(options);
|
|
54
26
|
}
|
|
27
|
+
// src/constants.ts
|
|
28
|
+
import { GROUP_LIMITS, GROUP_STATEMENT_SCOPES } from "@qzsy/unipay-sdk";
|
|
29
|
+
// src/errors.ts
|
|
30
|
+
import { isGatewayError } from "@qzsy/unipay-sdk";
|
|
55
31
|
function describeGroupError(error) {
|
|
56
|
-
if (isGatewayError(error))
|
|
57
|
-
|
|
58
|
-
return problem?.detail || problem?.title || error.message || "网关返回了错误";
|
|
59
|
-
}
|
|
32
|
+
if (isGatewayError(error))
|
|
33
|
+
return error.message || "网关返回了错误";
|
|
60
34
|
if (error instanceof Error)
|
|
61
35
|
return error.message;
|
|
62
36
|
return "未知错误";
|
|
63
37
|
}
|
|
38
|
+
|
|
39
|
+
// src/index.ts
|
|
40
|
+
export * from "@qzsy/unipay-sdk";
|
|
64
41
|
export {
|
|
65
42
|
GROUP_LIMITS,
|
|
66
43
|
GROUP_STATEMENT_SCOPES,
|
|
67
|
-
GroupClient,
|
|
68
44
|
GroupSdkClient,
|
|
69
|
-
UnifiedPay,
|
|
70
45
|
createGroupClient,
|
|
71
46
|
describeGroupError
|
|
72
47
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qzsy/group-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "群兴云集团 SaaS 对接统一支付网关的 TypeScript SDK:集团凭据、多主体/多应用管理、门店账单与佣金付款",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,15 +22,16 @@
|
|
|
22
22
|
],
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "bun run build:js && bun run build:types",
|
|
25
|
+
"build": "bun run clean && bun run build:js && bun run build:types",
|
|
26
26
|
"build:js": "bun build src/index.ts --outfile dist/index.js --target node --format esm --external @qzsy/unipay-sdk && bun build src/index.ts --outfile dist/index.cjs --target node --format cjs --external @qzsy/unipay-sdk",
|
|
27
27
|
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
28
28
|
"prepublishOnly": "bun run build && bun test",
|
|
29
29
|
"test": "bun test",
|
|
30
|
-
"type-check": "tsc --noEmit"
|
|
30
|
+
"type-check": "tsc -p tsconfig.test.json --noEmit",
|
|
31
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@qzsy/unipay-sdk": "^0.3.
|
|
34
|
+
"@qzsy/unipay-sdk": "^0.3.2"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"directory": "packages/group-sdk"
|
|
51
52
|
},
|
|
52
53
|
"engines": {
|
|
53
|
-
"node": ">=
|
|
54
|
+
"node": ">=20.19"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@repo/typescript-config": "workspace:*",
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,WAAW,EAEX,UAAU,EACV,KAAK,gCAAgC,EACrC,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,EAEpC,KAAK,+BAA+B,EACpC,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAA;AAEzB,yBAAyB;AACzB,eAAO,MAAM,sBAAsB,YAAI,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAA;AACzE,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEzE,qDAAqD;AACrD,eAAO,MAAM,YAAY;aACvB,IAAI,EAAE,GAAG;aACT,IAAI,EAAE,GAAG;aACT,QAAQ,EAAE,GAAG;aACb,cAAc,EAAE,IAAI;CACZ,CAAA;AAEV,qCAAqC;AACrC,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACzD;;;OAGG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAA;CACzB;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAC7C,6CAA6C;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAE5C,YAAY,OAAO,EAAE,eAAe,EAInC;IAED,kBAAkB;IAClB,IAAI,eAAe,IAAI,aAAa,GAAG,SAAS,CAE/C;IAED,8BAA8B;IAC9B,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,cAAc,CAEpD;IAED,0BAA0B;IAC1B,OAAO,CAAC,mBAAmB;IAMZ,YAAY,CACzB,KAAK,EAAE,sBAAsB,EAC7B,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;IAEc,iBAAiB,CAC9B,KAAK,EAAE,2BAA2B,EAClC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAEnC;IAEc,sBAAsB,CACnC,KAAK,EAAE,gCAAgC,EACvC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,+BAA+B,CAAC,CAE1C;IAEc,qBAAqB,CAClC,KAAK,EAAE,+BAA+B,EACtC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,4BAA4B,CAAC,CAEvC;IAEc,qBAAqB,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,sBAAsB,CAAC,CAEjC;CACF;AAED,oBAAoB;AACpB,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc,CAE1E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOzD;AAOD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAA;AAClC,cAAc,kBAAkB,CAAA"}
|