@h-ai/api-contract 0.1.0-alpha.67 → 0.1.0-alpha.69
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/README.en.md +30 -0
- package/README.ja.md +30 -0
- package/README.md +30 -0
- package/dist/ai/index.d.ts +981 -200
- package/dist/ai/index.js +2 -2
- package/dist/{chunk-RVSGP2GF.js → chunk-5XQIW67A.js} +6 -18
- package/dist/chunk-5XQIW67A.js.map +1 -0
- package/dist/chunk-CCCPHO6X.js +19 -0
- package/dist/chunk-CCCPHO6X.js.map +1 -0
- package/dist/{chunk-VSPYX4DD.js → chunk-G55ATYDA.js} +64 -39
- package/dist/chunk-G55ATYDA.js.map +1 -0
- package/dist/{chunk-3QSKWVLP.js → chunk-IVZVAWEF.js} +30 -17
- package/dist/chunk-IVZVAWEF.js.map +1 -0
- package/dist/{chunk-CUU2F6YD.js → chunk-JKPLID6E.js} +2 -2
- package/dist/chunk-JKPLID6E.js.map +1 -0
- package/dist/chunk-OQG36ECJ.js +140 -0
- package/dist/chunk-OQG36ECJ.js.map +1 -0
- package/dist/{chunk-JIQINMLG.js → chunk-R5GDWFYC.js} +7 -7
- package/dist/chunk-R5GDWFYC.js.map +1 -0
- package/dist/feedback/index.d.ts +1504 -0
- package/dist/feedback/index.js +5 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/iam/index.d.ts +845 -32
- package/dist/iam/index.js +3 -2
- package/dist/index.d.ts +855 -90
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/dist/payment/index.d.ts +220 -30
- package/dist/payment/index.js +2 -2
- package/dist/storage/index.d.ts +414 -161
- package/dist/storage/index.js +2 -2
- package/package.json +8 -3
- package/dist/chunk-3QSKWVLP.js.map +0 -1
- package/dist/chunk-CUU2F6YD.js.map +0 -1
- package/dist/chunk-JIQINMLG.js.map +0 -1
- package/dist/chunk-RVSGP2GF.js.map +0 -1
- package/dist/chunk-VSPYX4DD.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { iamContract
|
|
2
|
-
export { IamAdminCreateUserInputSchema, IamAdminResetPasswordInputSchema, IamAdminUpdateUserInputSchema, IamAgreementDisplaySchema, IamAuthResultSchema, IamChangePasswordInputSchema, IamConfirmPasswordResetInputSchema, IamCreatePermissionInputSchema, IamCreateRoleInputSchema, IamCurrentUserSchema, IamLdapLoginInputSchema, IamListPermissionsInputSchema, IamListUsersInputSchema, IamLoginInputSchema, IamLogoutInputSchema, IamOtpLoginInputSchema, IamPermissionSchema, IamPermissionTypeSchema, IamPublicConfigSchema, IamRefreshTokenDataSchema, IamRefreshTokenInputSchema, IamRegisterInputSchema, IamRequestPasswordResetInputSchema, IamRoleSchema, IamSendOtpDataSchema, IamSendOtpInputSchema, IamTokenPairSchema, IamUpdateCurrentUserInputSchema, IamUpdateRoleInputSchema, IamUserIdInputSchema, IamUserSchema
|
|
3
|
-
import { storageContract } from './chunk-
|
|
4
|
-
export { StorageDeleteFilesInputSchema, StorageFileKeyInputSchema, StorageFileMetadataSchema, StorageListFilesDataSchema, StorageListFilesInputSchema, StoragePresignDownloadInputSchema, StoragePresignUploadInputSchema, StoragePresignedUrlSchema } from './chunk-
|
|
5
|
-
import { aiContract } from './chunk-
|
|
6
|
-
export { AUDIO_WS_PATH, AiAssistantMessageSchema, AiChatCompletionChoiceSchema, AiChatCompletionDataSchema, AiChatCompletionInputSchema, AiChatHistoryDataSchema, AiChatHistoryInputSchema, AiChatMessageSchema, AiChatRecordSchema, AiImageContentSchema, AiMemoryEntrySchema, AiMemoryListDataSchema, AiMemoryListInputSchema, AiMemoryRecallDataSchema, AiMemoryRecallInputSchema, AiMemoryTypeSchema, AiMessageContentSchema, AiMessageRoleSchema, AiSendMessageDataSchema, AiSendMessageInputSchema, AiSessionInfoSchema, AiSessionListDataSchema, AiSessionListInputSchema, AiTextContentSchema, AiTokenUsageSchema, AiToolCallSchema, AiToolDefinitionSchema,
|
|
7
|
-
import { paymentContract } from './chunk-
|
|
8
|
-
export { PaymentCreateOrderDataSchema, PaymentCreateOrderInputSchema, PaymentNotifyMessageSchema, PaymentOrderSchema, PaymentProviderSchema, PaymentQueryOrderInputSchema, PaymentRefundDataSchema, PaymentRefundInputSchema, PaymentStripeNotifyDataSchema, PaymentTradeTypeSchema } from './chunk-
|
|
9
|
-
import {
|
|
10
|
-
export {
|
|
1
|
+
import { iamContract } from './chunk-5XQIW67A.js';
|
|
2
|
+
export { IamAdminCreateUserInputSchema, IamAdminResetPasswordInputSchema, IamAdminUpdateUserInputSchema, IamAgreementDisplaySchema, IamAuthResultSchema, IamChangePasswordInputSchema, IamConfirmPasswordResetInputSchema, IamCreatePermissionInputSchema, IamCreateRoleInputSchema, IamCurrentUserSchema, IamLdapLoginInputSchema, IamListPermissionsInputSchema, IamListUsersInputSchema, IamLoginInputSchema, IamLogoutInputSchema, IamOtpLoginInputSchema, IamPermissionSchema, IamPermissionTypeSchema, IamPublicConfigSchema, IamRefreshTokenDataSchema, IamRefreshTokenInputSchema, IamRegisterInputSchema, IamRequestPasswordResetInputSchema, IamRoleSchema, IamSendOtpDataSchema, IamSendOtpInputSchema, IamTokenPairSchema, IamUpdateCurrentUserInputSchema, IamUpdateRoleInputSchema, IamUserIdInputSchema, IamUserSchema } from './chunk-5XQIW67A.js';
|
|
3
|
+
import { storageContract } from './chunk-IVZVAWEF.js';
|
|
4
|
+
export { StorageDeleteFilesInputSchema, StorageDeleteSummarySchema, StorageFileKeyInputSchema, StorageFileMetadataSchema, StorageListFilesDataSchema, StorageListFilesInputSchema, StoragePresignDownloadInputSchema, StoragePresignUploadInputSchema, StoragePresignedUrlSchema } from './chunk-IVZVAWEF.js';
|
|
5
|
+
import { aiContract } from './chunk-G55ATYDA.js';
|
|
6
|
+
export { AUDIO_WS_PATH, AiAssistantMessageSchema, AiChatCompletionChoiceSchema, AiChatCompletionDataSchema, AiChatCompletionInputSchema, AiChatHistoryDataSchema, AiChatHistoryInputSchema, AiChatMessageSchema, AiChatRecordSchema, AiImageContentSchema, AiMemoryEntrySchema, AiMemoryListDataSchema, AiMemoryListInputSchema, AiMemoryRecallDataSchema, AiMemoryRecallInputSchema, AiMemoryTypeSchema, AiMessageContentSchema, AiMessageRoleSchema, AiSendMessageDataSchema, AiSendMessageInputSchema, AiSessionInfoSchema, AiSessionListDataSchema, AiSessionListInputSchema, AiTextContentSchema, AiTokenUsageSchema, AiToolCallSchema, AiToolDefinitionSchema, AudioFormatSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema } from './chunk-G55ATYDA.js';
|
|
7
|
+
import { paymentContract } from './chunk-R5GDWFYC.js';
|
|
8
|
+
export { PaymentCreateOrderDataSchema, PaymentCreateOrderInputSchema, PaymentNotifyMessageSchema, PaymentOrderSchema, PaymentProviderSchema, PaymentQueryOrderInputSchema, PaymentRefundDataSchema, PaymentRefundInputSchema, PaymentStripeNotifyDataSchema, PaymentTradeTypeSchema } from './chunk-R5GDWFYC.js';
|
|
9
|
+
import { feedbackContract } from './chunk-OQG36ECJ.js';
|
|
10
|
+
export { FeedbackAppendEvidenceInputSchema, FeedbackAttachmentDataSchema, FeedbackAttachmentInputSchema, FeedbackAttachmentQuerySchema, FeedbackAttachmentSchema, FeedbackCollectionStatusSchema, FeedbackCompleteInputSchema, FeedbackDetailSchema, FeedbackEvidenceAckSchema, FeedbackEvidenceInputSchema, FeedbackEvidenceQuerySchema, FeedbackEvidenceSchema, FeedbackExportInputSchema, FeedbackExportQuerySchema, FeedbackHistorySchema, FeedbackIdInputSchema, FeedbackJobSchema, FeedbackListInputSchema, FeedbackNotificationStatusSchema, FeedbackReportSchema, FeedbackRetryInputSchema, FeedbackSetStatusInputSchema, FeedbackStatusSchema, FeedbackSubmitInputSchema, FeedbackUploadInputSchema } from './chunk-OQG36ECJ.js';
|
|
11
|
+
import { paginatedSchema } from './chunk-CCCPHO6X.js';
|
|
12
|
+
export { PaginationQuerySchema, paginatedSchema } from './chunk-CCCPHO6X.js';
|
|
13
|
+
import { pathOf, route, HaiVoidResultSchema, haiResultSchema } from './chunk-JKPLID6E.js';
|
|
14
|
+
export { HaiErrorSchema } from './chunk-JKPLID6E.js';
|
|
11
15
|
import { z } from 'zod';
|
|
12
16
|
|
|
13
17
|
// src/composition/create-api-contract.ts
|
|
@@ -43,7 +47,9 @@ var apiContract = {
|
|
|
43
47
|
/** AI 领域 contract(聊天 / 记忆 / 会话)。 */
|
|
44
48
|
ai: aiContract,
|
|
45
49
|
/** Payment 领域 contract。 */
|
|
46
|
-
payment: paymentContract
|
|
50
|
+
payment: paymentContract,
|
|
51
|
+
/** 用户反馈、证据采集和离线导出。 */
|
|
52
|
+
feedback: feedbackContract
|
|
47
53
|
};
|
|
48
54
|
var IdParamSchema = z.object({
|
|
49
55
|
id: z.string().min(1)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/composition/create-api-contract.ts","../src/api-contract-main.ts","../src/common/response-schemas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/composition/create-api-contract.ts","../src/api-contract-main.ts","../src/common/response-schemas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAyDO,SAAS,kBAA4D,OAAA,EAAmC;AAC7G,EAAA,MAAM,WAA8C,EAAC;AAErD,EAAA,KAAA,MAAW,CAAC,MAAA,EAAQ,cAAc,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC9D,IAAA,IAAI,cAAA,EAAgB;AAClB,MAAA,QAAA,CAAS,MAAM,CAAA,GAAI,cAAA;AAAA,IACrB;AAAA,EACF;AAEA,EAAA,OAAO,QAAA;AACT;;;ACzBO,IAAM,WAAA,GAAc;AAAA;AAAA,EAEzB,MAAA,EAAQ,iBAAA;AAAA;AAAA,EAGR,eAAA;AAAA;AAAA,EAEA,gBAAA,EAAkB,mBAAA;AAAA;AAAA,EAElB,eAAA;AAAA;AAAA,EAEA,KAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA;AAAA,EAIA,GAAA,EAAK,WAAA;AAAA;AAAA,EAEL,OAAA,EAAS,eAAA;AAAA;AAAA,EAET,EAAA,EAAI,UAAA;AAAA;AAAA,EAEJ,OAAA,EAAS,eAAA;AAAA;AAAA,EAET,QAAA,EAAU;AACZ;AC/CO,IAAM,aAAA,GAAgB,EAAE,MAAA,CAAO;AAAA,EACpC,EAAA,EAAI,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC;AACtB,CAAC","file":"index.js","sourcesContent":["/**\n * @h-ai/api-contract — Contract 组合工具\n *\n * 提供将多个领域 contract 组合为应用级 contract 的工厂函数。\n * 仅描述接口边界,不包含任何 procedure 实现。\n * @module create-api-contract\n */\n\nimport type { AnyContractRouter } from '@orpc/contract'\n\n/**\n * API contract 组合输入。key 为领域名称,value 为领域 contract 或 false/undefined(跳过该领域)。\n * @example\n * ```ts\n * import type { CreateApiContractOptions } from '@h-ai/api-contract'\n * import { apiContract } from '@h-ai/api-contract'\n *\n * const parts = { iam: apiContract.iam, payment: false } satisfies CreateApiContractOptions\n * const contract = apiContract.create(parts)\n * void contract.iam.auth.login\n * ```\n */\nexport type CreateApiContractOptions = Record<string, AnyContractRouter | false | undefined>\n\n/**\n * 根据输入过滤 false/undefined 后得到的应用级 contract 类型。\n * @example\n * ```ts\n * import type { CreatedApiContract } from '@h-ai/api-contract'\n * import { apiContract } from '@h-ai/api-contract'\n *\n * const parts = { iam: apiContract.iam, payment: false } as const\n * const contract: CreatedApiContract<typeof parts> = apiContract.create(parts)\n * void contract.iam.auth.login\n * ```\n */\nexport type CreatedApiContract<T extends CreateApiContractOptions> = {\n readonly [K in keyof T as T[K] extends false | undefined ? never : K]: Exclude<T[K], false | undefined>\n}\n\n/**\n * 按领域组合应用级 API contract。\n *\n * contract 只描述接口边界;具体的 procedure 实现由 `@h-ai/serv` 的 feature 模块或应用层提供。\n * 传入 `false` 或 `undefined` 的领域将从最终 contract 中移除,类型也会同步收窄。\n *\n * @param options - 各领域 contract(传 false/undefined 表示禁用该领域)\n * @returns 过滤后的应用级 oRPC contract router\n * @example\n * ```ts\n * import { apiContract } from '@h-ai/api-contract'\n *\n * const contract = apiContract.create({ iam: apiContract.iam, payment: false })\n * const loginPath = apiContract.pathOf(contract.iam.auth.login)\n * void loginPath\n * ```\n */\nexport function createApiContract<const T extends CreateApiContractOptions>(options: T): CreatedApiContract<T> {\n const contract: Record<string, AnyContractRouter> = {}\n\n for (const [domain, domainContract] of Object.entries(options)) {\n if (domainContract) {\n contract[domain] = domainContract\n }\n }\n\n return contract as CreatedApiContract<T>\n}\n","/**\n * @h-ai/api-contract — 统一命名空间入口\n *\n * 将 contract 组合工厂、HaiResult schema 工具与各领域 contract 集中暴露在\n * `apiContract.*` 之下。应用层只需 `import { apiContract } from '@h-ai/api-contract'`\n * 即可完成所有 contract 装配,无需感知子模块路径或 `@orpc/contract` 实现细节。\n *\n * @module api-contract-main\n *\n * @example\n * ```ts\n * import { apiContract } from '@h-ai/api-contract'\n *\n * const contract = apiContract.create({\n * iam: apiContract.iam,\n * storage: apiContract.storage,\n * ai: apiContract.ai,\n * })\n * ```\n */\n\nimport { aiContract } from './ai/ai-contract.js'\nimport { paginatedSchema } from './common/pagination-schemas.js'\nimport { haiResultSchema, HaiVoidResultSchema } from './common/result-schemas.js'\nimport { pathOf, route } from './common/route.js'\nimport { createApiContract } from './composition/create-api-contract.js'\nimport { feedbackContract } from './feedback/feedback-contract.js'\nimport { iamContract } from './iam/iam-contract.js'\nimport { paymentContract } from './payment/payment-contract.js'\nimport { storageContract } from './storage/storage-contract.js'\n\n/**\n * hai-framework API contract 统一入口(扁平命名空间)。\n * @example\n * ```ts\n * import { apiContract } from '@h-ai/api-contract'\n *\n * const contract = apiContract.create({ iam: apiContract.iam, payment: false })\n * const loginPath = apiContract.pathOf(contract.iam.auth.login)\n * void loginPath\n * ```\n */\nexport const apiContract = {\n /** 组合任意领域 contract,过滤掉 `false` / `undefined`,输出可被 serv 挂载的 router。 */\n create: createApiContract,\n\n /** 把 data schema 包成 `HaiResult<T>` 区分联合,供 procedure `.output(...)` 使用。 */\n haiResultSchema,\n /** `HaiResult<void>` 常量 schema。 */\n voidResultSchema: HaiVoidResultSchema,\n /** 分页响应 schema 工厂。 */\n paginatedSchema,\n /** 创建 oRPC contract 路由节点,供自定义 contract 定义 HTTP 元数据。 */\n route,\n /** 从 contract procedure 读取其唯一业务路径。 */\n pathOf,\n\n // 领域 contract(框架内置)\n /** IAM 领域 contract(认证 / 用户 / 角色 / 权限)。 */\n iam: iamContract,\n /** Storage 领域 contract(预签名 URL / 文件管理)。 */\n storage: storageContract,\n /** AI 领域 contract(聊天 / 记忆 / 会话)。 */\n ai: aiContract,\n /** Payment 领域 contract。 */\n payment: paymentContract,\n /** 用户反馈、证据采集和离线导出。 */\n feedback: feedbackContract,\n}\n","/**\n * @h-ai/api-contract — 通用响应 Schema\n *\n * 跨领域共用的基础请求 / 响应结构,如 ID 路径参数。\n * @module response-schemas\n */\n\nimport { z } from 'zod'\n\n/**\n * 通用 ID 路径参数 Schema。用于 `GET /resource/{id}` 等 RESTful 路由的输入校验。\n * @example\n * ```ts\n * import { IdParamSchema } from '@h-ai/api-contract'\n *\n * const value = IdParamSchema.parse({\n * id: 'example-1'\n * })\n * void value\n * ```\n */\nexport const IdParamSchema = z.object({\n id: z.string().min(1),\n})\n"]}
|
package/dist/payment/index.d.ts
CHANGED
|
@@ -2,7 +2,16 @@ import * as _orpc_contract from '@orpc/contract';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { HaiResult } from '@h-ai/core';
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Payment 领域 oRPC contract。
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { apiContract } from '@h-ai/api-contract'
|
|
10
|
+
*
|
|
11
|
+
* const contract = apiContract.payment
|
|
12
|
+
* void contract
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
6
15
|
declare const paymentContract: {
|
|
7
16
|
orders: {
|
|
8
17
|
create: _orpc_contract.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
@@ -16,13 +25,10 @@ declare const paymentContract: {
|
|
|
16
25
|
tradeType: z.ZodEnum<{
|
|
17
26
|
jsapi: "jsapi";
|
|
18
27
|
h5: "h5";
|
|
19
|
-
app: "app";
|
|
20
|
-
native: "native";
|
|
21
|
-
mini_program: "mini_program";
|
|
22
28
|
}>;
|
|
23
29
|
userId: z.ZodOptional<z.ZodString>;
|
|
24
30
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
25
|
-
}, z.core.$
|
|
31
|
+
}, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
26
32
|
success: z.ZodLiteral<true>;
|
|
27
33
|
data: z.ZodObject<{
|
|
28
34
|
provider: z.ZodEnum<{
|
|
@@ -33,9 +39,6 @@ declare const paymentContract: {
|
|
|
33
39
|
tradeType: z.ZodEnum<{
|
|
34
40
|
jsapi: "jsapi";
|
|
35
41
|
h5: "h5";
|
|
36
|
-
app: "app";
|
|
37
|
-
native: "native";
|
|
38
|
-
mini_program: "mini_program";
|
|
39
42
|
}>;
|
|
40
43
|
clientParams: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
41
44
|
prepayId: z.ZodOptional<z.ZodString>;
|
|
@@ -62,10 +65,10 @@ declare const paymentContract: {
|
|
|
62
65
|
transactionId: z.ZodOptional<z.ZodString>;
|
|
63
66
|
status: z.ZodEnum<{
|
|
64
67
|
pending: "pending";
|
|
68
|
+
failed: "failed";
|
|
65
69
|
paid: "paid";
|
|
66
70
|
closed: "closed";
|
|
67
71
|
refunded: "refunded";
|
|
68
|
-
failed: "failed";
|
|
69
72
|
}>;
|
|
70
73
|
amount: z.ZodNumber;
|
|
71
74
|
paidAt: z.ZodOptional<z.ZodISODateTime>;
|
|
@@ -177,23 +180,64 @@ declare const paymentContract: {
|
|
|
177
180
|
}, z.core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
178
181
|
};
|
|
179
182
|
};
|
|
183
|
+
/**
|
|
184
|
+
* payment 领域公开 procedure 契约的完整类型。
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* import type { PaymentContract } from '@h-ai/api-contract'
|
|
188
|
+
* import { apiContract } from '@h-ai/api-contract'
|
|
189
|
+
*
|
|
190
|
+
* const contract: PaymentContract = apiContract.payment
|
|
191
|
+
* void contract
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
180
194
|
type PaymentContract = typeof paymentContract;
|
|
181
195
|
|
|
182
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* 支付渠道 Schema。
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* import { PaymentProviderSchema } from '@h-ai/api-contract'
|
|
201
|
+
*
|
|
202
|
+
* const value = PaymentProviderSchema.parse('wechat')
|
|
203
|
+
* void value
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
183
206
|
declare const PaymentProviderSchema: z.ZodEnum<{
|
|
184
207
|
wechat: "wechat";
|
|
185
208
|
alipay: "alipay";
|
|
186
209
|
stripe: "stripe";
|
|
187
210
|
}>;
|
|
188
|
-
/**
|
|
211
|
+
/**
|
|
212
|
+
* 完整实现的支付类型:微信 jsapi,支付宝/Stripe h5。
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* import { PaymentTradeTypeSchema } from '@h-ai/api-contract'
|
|
216
|
+
*
|
|
217
|
+
* const value = PaymentTradeTypeSchema.parse('jsapi')
|
|
218
|
+
* void value
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
189
221
|
declare const PaymentTradeTypeSchema: z.ZodEnum<{
|
|
190
222
|
jsapi: "jsapi";
|
|
191
223
|
h5: "h5";
|
|
192
|
-
app: "app";
|
|
193
|
-
native: "native";
|
|
194
|
-
mini_program: "mini_program";
|
|
195
224
|
}>;
|
|
196
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* 创建支付订单入参 Schema。
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* import { PaymentCreateOrderInputSchema } from '@h-ai/api-contract'
|
|
230
|
+
*
|
|
231
|
+
* const value = PaymentCreateOrderInputSchema.parse({
|
|
232
|
+
* provider: 'wechat',
|
|
233
|
+
* amount: 100,
|
|
234
|
+
* description: 'Example order',
|
|
235
|
+
* tradeType: 'jsapi',
|
|
236
|
+
* userId: 'example-openid'
|
|
237
|
+
* })
|
|
238
|
+
* void value
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
197
241
|
declare const PaymentCreateOrderInputSchema: z.ZodObject<{
|
|
198
242
|
provider: z.ZodEnum<{
|
|
199
243
|
wechat: "wechat";
|
|
@@ -205,14 +249,32 @@ declare const PaymentCreateOrderInputSchema: z.ZodObject<{
|
|
|
205
249
|
tradeType: z.ZodEnum<{
|
|
206
250
|
jsapi: "jsapi";
|
|
207
251
|
h5: "h5";
|
|
208
|
-
app: "app";
|
|
209
|
-
native: "native";
|
|
210
|
-
mini_program: "mini_program";
|
|
211
252
|
}>;
|
|
212
253
|
userId: z.ZodOptional<z.ZodString>;
|
|
213
254
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
214
|
-
}, z.core.$
|
|
215
|
-
/**
|
|
255
|
+
}, z.core.$strict>;
|
|
256
|
+
/**
|
|
257
|
+
* 创建支付订单业务数据 Schema。
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* import { PaymentCreateOrderDataSchema } from '@h-ai/api-contract'
|
|
261
|
+
*
|
|
262
|
+
* const value = PaymentCreateOrderDataSchema.parse({
|
|
263
|
+
* provider: 'wechat',
|
|
264
|
+
* tradeType: 'jsapi',
|
|
265
|
+
* prepayId: 'example-prepay',
|
|
266
|
+
* clientParams: {
|
|
267
|
+
* appId: 'wx-example',
|
|
268
|
+
* timeStamp: '1767225600',
|
|
269
|
+
* nonceStr: 'example-nonce',
|
|
270
|
+
* package: 'prepay_id=example-prepay',
|
|
271
|
+
* signType: 'RSA',
|
|
272
|
+
* paySign: 'example-only-signature'
|
|
273
|
+
* }
|
|
274
|
+
* })
|
|
275
|
+
* void value
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
216
278
|
declare const PaymentCreateOrderDataSchema: z.ZodObject<{
|
|
217
279
|
provider: z.ZodEnum<{
|
|
218
280
|
wechat: "wechat";
|
|
@@ -222,32 +284,67 @@ declare const PaymentCreateOrderDataSchema: z.ZodObject<{
|
|
|
222
284
|
tradeType: z.ZodEnum<{
|
|
223
285
|
jsapi: "jsapi";
|
|
224
286
|
h5: "h5";
|
|
225
|
-
app: "app";
|
|
226
|
-
native: "native";
|
|
227
|
-
mini_program: "mini_program";
|
|
228
287
|
}>;
|
|
229
288
|
clientParams: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
230
289
|
prepayId: z.ZodOptional<z.ZodString>;
|
|
231
290
|
}, z.core.$strip>;
|
|
232
|
-
/**
|
|
291
|
+
/**
|
|
292
|
+
* 查询支付订单入参 Schema。
|
|
293
|
+
* @example
|
|
294
|
+
* ```ts
|
|
295
|
+
* import { PaymentQueryOrderInputSchema } from '@h-ai/api-contract'
|
|
296
|
+
*
|
|
297
|
+
* const value = PaymentQueryOrderInputSchema.parse({
|
|
298
|
+
* orderNo: 'order_1'
|
|
299
|
+
* })
|
|
300
|
+
* void value
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
233
303
|
declare const PaymentQueryOrderInputSchema: z.ZodObject<{
|
|
234
304
|
orderNo: z.ZodString;
|
|
235
305
|
}, z.core.$strip>;
|
|
236
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* 支付订单业务数据 Schema。
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* import { PaymentOrderSchema } from '@h-ai/api-contract'
|
|
311
|
+
*
|
|
312
|
+
* const value = PaymentOrderSchema.parse({
|
|
313
|
+
* orderNo: 'order_1',
|
|
314
|
+
* status: 'pending',
|
|
315
|
+
* amount: 0
|
|
316
|
+
* })
|
|
317
|
+
* void value
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
237
320
|
declare const PaymentOrderSchema: z.ZodObject<{
|
|
238
321
|
orderNo: z.ZodString;
|
|
239
322
|
transactionId: z.ZodOptional<z.ZodString>;
|
|
240
323
|
status: z.ZodEnum<{
|
|
241
324
|
pending: "pending";
|
|
325
|
+
failed: "failed";
|
|
242
326
|
paid: "paid";
|
|
243
327
|
closed: "closed";
|
|
244
328
|
refunded: "refunded";
|
|
245
|
-
failed: "failed";
|
|
246
329
|
}>;
|
|
247
330
|
amount: z.ZodNumber;
|
|
248
331
|
paidAt: z.ZodOptional<z.ZodISODateTime>;
|
|
249
332
|
}, z.core.$strip>;
|
|
250
|
-
/**
|
|
333
|
+
/**
|
|
334
|
+
* 退款入参 Schema。
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
337
|
+
* import { PaymentRefundInputSchema } from '@h-ai/api-contract'
|
|
338
|
+
*
|
|
339
|
+
* const value = PaymentRefundInputSchema.parse({
|
|
340
|
+
* provider: 'wechat',
|
|
341
|
+
* orderNo: 'order_1',
|
|
342
|
+
* refundNo: 'refund_1',
|
|
343
|
+
* amount: 1
|
|
344
|
+
* })
|
|
345
|
+
* void value
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
251
348
|
declare const PaymentRefundInputSchema: z.ZodObject<{
|
|
252
349
|
provider: z.ZodEnum<{
|
|
253
350
|
wechat: "wechat";
|
|
@@ -259,7 +356,20 @@ declare const PaymentRefundInputSchema: z.ZodObject<{
|
|
|
259
356
|
amount: z.ZodNumber;
|
|
260
357
|
reason: z.ZodOptional<z.ZodString>;
|
|
261
358
|
}, z.core.$strip>;
|
|
262
|
-
/**
|
|
359
|
+
/**
|
|
360
|
+
* 退款业务数据 Schema。
|
|
361
|
+
* @example
|
|
362
|
+
* ```ts
|
|
363
|
+
* import { PaymentRefundDataSchema } from '@h-ai/api-contract'
|
|
364
|
+
*
|
|
365
|
+
* const value = PaymentRefundDataSchema.parse({
|
|
366
|
+
* refundNo: 'refund_1',
|
|
367
|
+
* refundId: 'example',
|
|
368
|
+
* status: 'processing'
|
|
369
|
+
* })
|
|
370
|
+
* void value
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
263
373
|
declare const PaymentRefundDataSchema: z.ZodObject<{
|
|
264
374
|
refundNo: z.ZodString;
|
|
265
375
|
refundId: z.ZodString;
|
|
@@ -269,17 +379,97 @@ declare const PaymentRefundDataSchema: z.ZodObject<{
|
|
|
269
379
|
processing: "processing";
|
|
270
380
|
}>;
|
|
271
381
|
}, z.core.$strip>;
|
|
272
|
-
/**
|
|
382
|
+
/**
|
|
383
|
+
* 微信/支付宝通知响应 Schema。
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* import { PaymentNotifyMessageSchema } from '@h-ai/api-contract'
|
|
387
|
+
*
|
|
388
|
+
* const value = PaymentNotifyMessageSchema.parse({
|
|
389
|
+
* code: 'example-1',
|
|
390
|
+
* message: 'example'
|
|
391
|
+
* })
|
|
392
|
+
* void value
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
273
395
|
declare const PaymentNotifyMessageSchema: z.ZodObject<{
|
|
274
396
|
code: z.ZodString;
|
|
275
397
|
message: z.ZodString;
|
|
276
398
|
}, z.core.$strip>;
|
|
277
|
-
/**
|
|
399
|
+
/**
|
|
400
|
+
* Stripe 通知响应 Schema。
|
|
401
|
+
* @example
|
|
402
|
+
* ```ts
|
|
403
|
+
* import { PaymentStripeNotifyDataSchema } from '@h-ai/api-contract'
|
|
404
|
+
*
|
|
405
|
+
* const value = PaymentStripeNotifyDataSchema.parse({
|
|
406
|
+
* received: true
|
|
407
|
+
* })
|
|
408
|
+
* void value
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
278
411
|
declare const PaymentStripeNotifyDataSchema: z.ZodObject<{
|
|
279
412
|
received: z.ZodBoolean;
|
|
280
413
|
}, z.core.$strip>;
|
|
414
|
+
/**
|
|
415
|
+
* 按渠道和已实现支付方式创建订单的请求。
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* import type { PaymentCreateOrderInput } from '@h-ai/api-contract'
|
|
419
|
+
* import { PaymentCreateOrderInputSchema } from '@h-ai/api-contract'
|
|
420
|
+
*
|
|
421
|
+
* const value: PaymentCreateOrderInput = PaymentCreateOrderInputSchema.parse({
|
|
422
|
+
* provider: 'wechat',
|
|
423
|
+
* amount: 100,
|
|
424
|
+
* description: 'Example order',
|
|
425
|
+
* tradeType: 'jsapi',
|
|
426
|
+
* userId: 'example-openid'
|
|
427
|
+
* })
|
|
428
|
+
* void value
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
281
431
|
type PaymentCreateOrderInput = z.infer<typeof PaymentCreateOrderInputSchema>;
|
|
432
|
+
/**
|
|
433
|
+
* 以 HaiResult 区分成功业务数据和公共错误的 PaymentCreateOrderOutput 响应。
|
|
434
|
+
* @example
|
|
435
|
+
* ```ts
|
|
436
|
+
* import type { PaymentCreateOrderOutput } from '@h-ai/api-contract'
|
|
437
|
+
* import { PaymentCreateOrderDataSchema } from '@h-ai/api-contract'
|
|
438
|
+
* import { ok } from '@h-ai/core'
|
|
439
|
+
*
|
|
440
|
+
* const response: PaymentCreateOrderOutput = ok(PaymentCreateOrderDataSchema.parse({
|
|
441
|
+
* provider: 'wechat',
|
|
442
|
+
* tradeType: 'jsapi',
|
|
443
|
+
* prepayId: 'example-prepay',
|
|
444
|
+
* clientParams: {
|
|
445
|
+
* appId: 'wx-example',
|
|
446
|
+
* timeStamp: '1767225600',
|
|
447
|
+
* nonceStr: 'example-nonce',
|
|
448
|
+
* package: 'prepay_id=example-prepay',
|
|
449
|
+
* signType: 'RSA',
|
|
450
|
+
* paySign: 'example-only-signature'
|
|
451
|
+
* }
|
|
452
|
+
* }))
|
|
453
|
+
* if (response.success) void response.data
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
282
456
|
type PaymentCreateOrderOutput = HaiResult<z.infer<typeof PaymentCreateOrderDataSchema>>;
|
|
457
|
+
/**
|
|
458
|
+
* 退款请求,金额单位与支付契约一致。
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* import type { PaymentRefundInput } from '@h-ai/api-contract'
|
|
462
|
+
* import { PaymentRefundInputSchema } from '@h-ai/api-contract'
|
|
463
|
+
*
|
|
464
|
+
* const value: PaymentRefundInput = PaymentRefundInputSchema.parse({
|
|
465
|
+
* provider: 'wechat',
|
|
466
|
+
* orderNo: 'order_1',
|
|
467
|
+
* refundNo: 'refund_1',
|
|
468
|
+
* amount: 1
|
|
469
|
+
* })
|
|
470
|
+
* void value
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
283
473
|
type PaymentRefundInput = z.infer<typeof PaymentRefundInputSchema>;
|
|
284
474
|
|
|
285
475
|
export { type PaymentContract, PaymentCreateOrderDataSchema, type PaymentCreateOrderInput, PaymentCreateOrderInputSchema, type PaymentCreateOrderOutput, PaymentNotifyMessageSchema, PaymentOrderSchema, PaymentProviderSchema, PaymentQueryOrderInputSchema, PaymentRefundDataSchema, type PaymentRefundInput, PaymentRefundInputSchema, PaymentStripeNotifyDataSchema, PaymentTradeTypeSchema, paymentContract };
|
package/dist/payment/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PaymentCreateOrderDataSchema, PaymentCreateOrderInputSchema, PaymentNotifyMessageSchema, PaymentOrderSchema, PaymentProviderSchema, PaymentQueryOrderInputSchema, PaymentRefundDataSchema, PaymentRefundInputSchema, PaymentStripeNotifyDataSchema, PaymentTradeTypeSchema, paymentContract } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { PaymentCreateOrderDataSchema, PaymentCreateOrderInputSchema, PaymentNotifyMessageSchema, PaymentOrderSchema, PaymentProviderSchema, PaymentQueryOrderInputSchema, PaymentRefundDataSchema, PaymentRefundInputSchema, PaymentStripeNotifyDataSchema, PaymentTradeTypeSchema, paymentContract } from '../chunk-R5GDWFYC.js';
|
|
2
|
+
import '../chunk-JKPLID6E.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|