@h-ai/api-contract 0.1.0-alpha.67 → 0.1.0-alpha.68

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.
@@ -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
- /** Payment 领域 oRPC contract。 */
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.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
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>;
@@ -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
- /** 支付渠道 Schema。 */
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
- /** 支付交易类型 Schema。 */
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
- /** 创建支付订单入参 Schema。 */
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.$strip>;
215
- /** 创建支付订单业务数据 Schema。 */
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,18 +284,39 @@ 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
- /** 查询支付订单入参 Schema。 */
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
- /** 支付订单业务数据 Schema。 */
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>;
@@ -247,7 +330,21 @@ declare const PaymentOrderSchema: z.ZodObject<{
247
330
  amount: z.ZodNumber;
248
331
  paidAt: z.ZodOptional<z.ZodISODateTime>;
249
332
  }, z.core.$strip>;
250
- /** 退款入参 Schema。 */
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
- /** 退款业务数据 Schema。 */
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
- /** 微信/支付宝通知响应 Schema。 */
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
- /** Stripe 通知响应 Schema。 */
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 };
@@ -1,4 +1,4 @@
1
- export { PaymentCreateOrderDataSchema, PaymentCreateOrderInputSchema, PaymentNotifyMessageSchema, PaymentOrderSchema, PaymentProviderSchema, PaymentQueryOrderInputSchema, PaymentRefundDataSchema, PaymentRefundInputSchema, PaymentStripeNotifyDataSchema, PaymentTradeTypeSchema, paymentContract } from '../chunk-JIQINMLG.js';
2
- import '../chunk-CUU2F6YD.js';
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