@sayren/storefront-sdk 0.13.0 → 0.14.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.
@@ -1,4 +1,4 @@
1
- import { pt as ApiError, t as createStorefrontClient } from "../client-U1LJGfWn.mjs";
1
+ import { ft as ApiError, t as createStorefrontClient } from "../client-CUF2xGu8.mjs";
2
2
  //#region src/auth/index.ts
3
3
  /** 소셜 로그인 실패 — 구매자가 취소했거나(`access_denied`) state가 맞지 않는다 */
4
4
  var IdpCallbackError = class extends Error {
@@ -1,4 +1,152 @@
1
1
  import { z } from "zod";
2
+ //#region src/schemas/common.ts
3
+ const pageInfoSchema = z.object({
4
+ page: z.number().int(),
5
+ size: z.number().int(),
6
+ totalElements: z.number().int(),
7
+ totalPages: z.number().int()
8
+ });
9
+ function pageSchema(item) {
10
+ return pageInfoSchema.extend({ contents: z.array(item) });
11
+ }
12
+ const orderItemStatusSchema = z.enum([
13
+ "PAYMENT_WAITING",
14
+ "PAID",
15
+ "CONFIRMED",
16
+ "DISPATCHED",
17
+ "DELIVERING",
18
+ "DELIVERED",
19
+ "PURCHASE_DECIDED",
20
+ "CANCELED"
21
+ ]);
22
+ const claimStatusSchema = z.enum([
23
+ "REQUESTED",
24
+ "HELD",
25
+ "COLLECTING",
26
+ "COLLECTED",
27
+ "REDELIVERING",
28
+ "APPROVED",
29
+ "REJECTED",
30
+ "COMPLETED",
31
+ "WITHDRAWN"
32
+ ]);
33
+ /**
34
+ * 상품 유형 (이슈 #48). 응답에서는 문자열로 받는다(값이 추가될 수 있다). 현재 값은 `SHIPPING`(배송 상품)·
35
+ * `DOWNLOAD`(파일 다운로드)·`CODE`(코드 발급)·`SERVICE`(이용권·서비스)·`PICKUP`(방문 수령)이다.
36
+ * 이 필드 이전 서버의 응답에는 없어 `SHIPPING`으로 읽는다. 서버는 항상 싣는다.
37
+ */
38
+ const fulfillmentTypeField = () => z.string().optional().default("SHIPPING").describe("상품 유형. 현재 값은 `SHIPPING`(배송 상품)·`DOWNLOAD`(파일 다운로드)·`CODE`(코드 발급)·`SERVICE`(이용권·서비스)·`PICKUP`(방문 수령)이고 값이 추가될 수 있어 문자열로 받는다. 서버는 항상 싣는다");
39
+ /**
40
+ * 배송 필요 여부 (이슈 #48). false면 배송지를 받지 않는다. 이 필드 이전 서버의 응답에는 없어 true로 읽는다.
41
+ */
42
+ const requiresShippingField = (description) => z.boolean().optional().default(true).describe(`${description} 서버는 항상 싣는다`);
43
+ /** 배송이 필요한 상품 유형인가 — 배송 상품(`SHIPPING`)만 택배 배송이 있다. 모르는 값은 배송 상품으로 본다 */
44
+ function isShippingFulfillment(fulfillmentType) {
45
+ return fulfillmentType === void 0 || fulfillmentType === null || ![
46
+ "DOWNLOAD",
47
+ "CODE",
48
+ "SERVICE",
49
+ "PICKUP"
50
+ ].includes(fulfillmentType);
51
+ }
52
+ //#endregion
53
+ //#region src/schemas/coupon.ts
54
+ /**
55
+ * 스토어프론트 쿠폰 계약 (이슈 #47).
56
+ *
57
+ * 구매자는 주문서에서 쿠폰을 고르거나 코드를 입력한다. 금액 미리보기(`POST /checkout/{checkoutId}/pricing`)는
58
+ * 주문서를 바꾸지 않는 읽기 계산이고, **확정은 결제 시작(`coupons` 필드)만 한다** — 결제 시작이 쿠폰을 예약하고 그 금액으로
59
+ * 결제 금액을 정한다. 결제가 실패하거나 만료되면 예약이 풀려 같은 쿠폰을 다시 쓸 수 있다.
60
+ *
61
+ * 한 주문에 주문 쿠폰 1장, 주문상품 한 줄에 상품 쿠폰 1장까지다. 같은 쿠폰을 두 번 쓸 수 없다.
62
+ */
63
+ /** 적용할 쿠폰 한 장 — 발급 쿠폰 id 또는 코드 중 하나 */
64
+ const couponApplicationSchema = z.object({
65
+ issueId: z.string().min(1).optional().describe("내 쿠폰(발급 쿠폰) id — `GET /me/coupons`의 `issueId`"),
66
+ code: z.string().trim().min(1).max(30).optional().describe("쿠폰 코드. 대소문자를 구분하지 않는다"),
67
+ optionId: z.string().optional().describe("상품 쿠폰을 걸 주문서 항목의 `optionId`. 생략하면 할인이 가장 큰 항목에 건다. 주문 쿠폰에는 쓰지 않는다")
68
+ }).refine((value) => (value.issueId ? 1 : 0) + (value.code ? 1 : 0) === 1, { message: "issueId와 code 중 하나만 보내 주십시오" });
69
+ /** 한 번에 적용할 수 있는 쿠폰 수 */
70
+ const MAX_COUPONS_PER_CHECKOUT = 5;
71
+ const couponApplicationListSchema = z.array(couponApplicationSchema).max(5).describe("적용할 쿠폰. 주문 쿠폰 1장, 주문상품 한 줄에 상품 쿠폰 1장까지 함께 쓴다");
72
+ /** 쿠폰 혜택 — 응답 표시용. 값이 늘 수 있어 방식은 문자열이다 */
73
+ const couponBenefitViewSchema = z.object({
74
+ type: z.string().describe("할인 방식. 현재 값은 `RATE`(정률 %)·`AMOUNT`(정액 원)"),
75
+ value: z.number().int().describe("정률이면 %, 정액이면 원"),
76
+ maxDiscountAmount: z.number().int().nullable().describe("정률 할인의 최대 할인액. 없으면 null")
77
+ });
78
+ /** 쿠폰 한 장의 적용 결과 */
79
+ const couponResultSchema = z.object({
80
+ couponId: z.string(),
81
+ issueId: z.string().nullable().describe("발급 쿠폰 id. 코드로 적용했으면 null"),
82
+ code: z.string().nullable().describe("코드로 적용했으면 그 코드(대문자). 그 밖은 null"),
83
+ name: z.string(),
84
+ kind: z.string().describe("쿠폰 종류. 현재 값은 `ORDER`(주문 쿠폰)·`PRODUCT`(상품 쿠폰)"),
85
+ benefit: couponBenefitViewSchema,
86
+ applied: z.boolean(),
87
+ discountAmount: z.number().int().describe("이 쿠폰의 할인액. 적용하지 못했으면 0"),
88
+ rejectReason: z.string().nullable().describe("적용하지 못한 사유. `MIN_ORDER_AMOUNT`(최소 주문 금액 미달)·`NO_ELIGIBLE_ITEMS`(대상 상품 없음)·`NOT_STARTED`·`EXPIRED`·`MEMBER_ONLY`(회원 전용)·`STACK_LIMIT`(같은 종류 쿠폰이 이미 적용됨)·`DUPLICATE_COUPON`·`LINE_NOT_ELIGIBLE`·`NO_DISCOUNT`·`IN_USE`(다른 결제에서 쓰는 중)·`LIMIT_REACHED`(1인 사용 한도)·`EXHAUSTED`(총 사용 한도)·`INACTIVE`(중지된 쿠폰). 값이 늘 수 있다"),
89
+ optionId: z.string().nullable().describe("상품 쿠폰이 걸린 주문서 항목의 `optionId`. 그 밖은 null")
90
+ });
91
+ /** 쿠폰을 반영한 금액 — 결제 금액 = productAmount − couponDiscountAmount + deliveryFee − deliveryDiscountAmount */
92
+ const pricingAmountsSchema = z.object({
93
+ productAmount: z.number().int(),
94
+ deliveryFee: z.number().int(),
95
+ couponDiscountAmount: z.number().int(),
96
+ deliveryDiscountAmount: z.number().int(),
97
+ totalAmount: z.number().int().describe("결제 금액")
98
+ });
99
+ /** `POST /checkout/{checkoutId}/pricing` 요청 */
100
+ const checkoutPricingRequestSchema = z.object({
101
+ zipCode: z.string().regex(/^[0-9]{5}$/, "우편번호 5자리를 입력해 주십시오").optional().describe("배송지 우편번호. 주면 제주·도서산간 추가 배송비까지 반영한다"),
102
+ coupons: couponApplicationListSchema
103
+ });
104
+ /** 결제 금액의 하한 — 쿠폰 적용 뒤 결제 금액이 이보다 작으면 결제를 시작할 수 없다 */
105
+ const MIN_PAYMENT_AMOUNT = 100;
106
+ const checkoutPricingSchema = z.object({
107
+ amounts: pricingAmountsSchema,
108
+ coupons: z.array(couponResultSchema).describe("요청한 쿠폰마다 한 줄, 요청 순서대로"),
109
+ items: z.array(z.object({
110
+ optionId: z.string().nullable(),
111
+ couponDiscountAmount: z.number().int().describe("이 항목에 들어간 쿠폰 할인")
112
+ })).describe("주문서 항목별 쿠폰 할인 — 주문서 `items`와 같은 순서"),
113
+ payable: z.boolean().describe("이 금액으로 결제를 시작할 수 있는가 — 적용하지 못한 쿠폰이 있거나 결제 금액이 100원 미만이면 false")
114
+ });
115
+ /** `GET /checkout/{checkoutId}/coupons` 항목 — 이 주문서에 쓸 수 있는 내 쿠폰 */
116
+ const applicableCouponSchema = z.object({
117
+ issueId: z.string(),
118
+ couponId: z.string(),
119
+ name: z.string(),
120
+ description: z.string().nullable(),
121
+ kind: z.string(),
122
+ benefit: couponBenefitViewSchema,
123
+ minOrderAmount: z.number().int(),
124
+ validUntil: z.string().nullable().describe("유효 기간 끝(이 시각부터 못 쓴다). 없으면 null"),
125
+ applicable: z.boolean().describe("이 주문서에 혼자 적용하면 할인이 되는가"),
126
+ expectedDiscountAmount: z.number().int().describe("혼자 적용했을 때의 예상 할인액"),
127
+ rejectReason: z.string().nullable().describe("적용할 수 없는 사유(`couponResultSchema.rejectReason`과 같은 값)")
128
+ });
129
+ /** `GET /me/coupons` 항목 */
130
+ const myCouponSchema = z.object({
131
+ issueId: z.string(),
132
+ couponId: z.string(),
133
+ name: z.string(),
134
+ description: z.string().nullable(),
135
+ kind: z.string(),
136
+ benefit: couponBenefitViewSchema,
137
+ minOrderAmount: z.number().int(),
138
+ status: z.string().describe("상태. 현재 값은 `AVAILABLE`(사용 가능)·`RESERVED`(결제 중)·`USED`(사용함)·`EXPIRED`(기간 지남)이고 값이 늘 수 있다"),
139
+ validFrom: z.string(),
140
+ validUntil: z.string().nullable(),
141
+ usedOrderId: z.string().nullable(),
142
+ issuedAt: z.string()
143
+ });
144
+ const myCouponListQuerySchema = z.object({ status: z.enum([
145
+ "available",
146
+ "used",
147
+ "expired"
148
+ ]).optional().describe("`available`=사용 가능(결제 중 포함), `used`=사용함, `expired`=기간 지남. 생략하면 전부") });
149
+ //#endregion
2
150
  //#region src/schemas/checkout.ts
3
151
  const createCheckoutRequestSchema = z.object({
4
152
  cartItemIds: z.array(z.string()).min(1).optional(),
@@ -48,9 +196,19 @@ const checkoutSessionSchema = z.object({
48
196
  amounts: z.object({
49
197
  productAmount: z.number().int(),
50
198
  deliveryFee: z.number().int(),
51
- totalAmount: z.number().int()
199
+ totalAmount: z.number().int(),
200
+ couponDiscountAmount: z.number().int().optional().default(0).describe("쿠폰 할인(상품·주문 쿠폰). 주문서는 쿠폰 전이라 0이고, 결제 시작 응답은 적용한 쿠폰의 할인이다"),
201
+ deliveryDiscountAmount: z.number().int().optional().default(0).describe("배송비 쿠폰 할인. 쿠폰이 없으면 0")
52
202
  }),
53
203
  delivery: checkoutDeliverySchema.describe("배송비 내역. 배송지를 입력하면 금액이 바뀔 수 있다 — 최종 금액은 결제 시작 응답의 `amounts`다"),
204
+ requiresShipping: requiresShippingField("택배 배송이 필요한 상품이 있는가. false면 배송지를 받지 않는다 — 결제 시작에 `shippingAddress`를 보내지 않아도 된다."),
205
+ withdrawal: z.object({
206
+ required: z.boolean().describe("청약철회 제한 상품(제공이 시작되면 취소·반품할 수 없는 파일·코드·이용권)이 있는가. true면 `notice`를 결제 전에 보여 주고 동의를 받아 결제 시작에 `withdrawalAgreement: true`를 보낸다"),
207
+ notice: z.string().nullable().describe("구매자에게 보여 줄 고지 문구. `required`가 false면 null")
208
+ }).optional().default({
209
+ required: false,
210
+ notice: null
211
+ }).describe("청약철회 제한 고지(이슈 #48). 서버는 항상 싣는다"),
54
212
  expiresAt: z.string(),
55
213
  paymentOptions: z.lazy(() => paymentOptionListSchema).describe("이 주문서에서 고를 수 있는 결제 옵션, PG 우선순위순. 셀러가 켠 PG·결제수단·간편결제만 담긴다. 비어 있으면 지금 결제할 수 없다"),
56
214
  testPayment: z.boolean().describe("지금 결제하면 테스트 결제(샌드박스)인가. true면 실제로 돈이 나가지 않습니다 — 주문서에 테스트 결제 안내를 표시합니다. 결제 요청 시점에 스토어 결제 설정으로 다시 정해지니 최종 값은 결제 요청 응답의 `testPayment`입니다")
@@ -232,9 +390,11 @@ const cashReceiptField = cashReceiptRequestSchema.optional().describe("현금영
232
390
  const startPaymentRequestSchema = z.object({
233
391
  option: paymentOptionSchema,
234
392
  returnUrl: z.url().max(2048).describe("결제를 마치면 돌아올 스토어프론트 주소. 스토어 결제 도메인에 등록된 도메인이어야 한다"),
235
- shippingAddress: shippingAddressInputSchema,
393
+ shippingAddress: shippingAddressInputSchema.optional().describe("배송지. 주문서의 `requiresShipping`이 true면 필수이고 없으면 400 `SHIPPING_ADDRESS_REQUIRED`다. 배송이 필요 없는 주문(파일·코드·이용권·방문 수령만)은 보내지 않아도 된다. 보내면 형식을 검사한 뒤 버린다"),
236
394
  guest: guestInfoSchema.optional(),
237
- cashReceipt: cashReceiptField
395
+ withdrawalAgreement: z.boolean().optional().describe("청약철회 제한 동의. 주문서의 `withdrawal.required`가 true면 true여야 하고 아니면 400 `WITHDRAWAL_AGREEMENT_REQUIRED`다. 동의 시각이 주문에 남는다"),
396
+ cashReceipt: cashReceiptField,
397
+ coupons: couponApplicationListSchema.optional().describe("적용할 쿠폰(이슈 #47). 결제 시작이 쿠폰을 예약하고 할인한 금액으로 결제 금액을 정한다 — 응답의 `amounts`가 확정 금액이다. 적용하지 못하는 쿠폰이 하나라도 있으면 400 `COUPON_NOT_APPLICABLE`(`details`에 사유)이다. 결제가 실패하거나 만료되면 예약이 풀린다. 쿠폰을 바꾸려면 새로 결제를 시작한다(재시도는 같은 쿠폰을 쓴다)")
238
398
  });
239
399
  /**
240
400
  * 같은 결제에서 다른 결제 옵션으로 다시 시도. `returnUrl`을 생략하면 결제 시작 때의 복귀 주소를 쓴다.
@@ -307,4 +467,4 @@ const paymentMessageSchema = z.object({
307
467
  orderId: z.string().optional()
308
468
  });
309
469
  //#endregion
310
- export { startPaymentRequestSchema as A, paymentStartSchema as C, residentNumberLike as D, remoteAreaSchema as E, retryPaymentRequestSchema as O, paymentOptionSchema as S, pgProviderSchema as T, paymentFailureCategorySchema as _, cashReceiptAvailable as a, paymentOptionKey as b, cashReceiptTypeSchema as c, createCheckoutRequestSchema as d, deliveryQuoteRequestSchema as f, guestInfoSchema as g, easyPayProviderSchema as h, availablePaymentOptionSchema as i, shippingAddressInputSchema as k, checkoutDeliverySchema as l, easyPayProviderResponseSchema as m, PAYMENT_RESULT_VALUES as n, cashReceiptIdentityTypeOf as o, deliveryQuoteSchema as p, PAYMENT_STATUS_VALUES as r, cashReceiptRequestSchema as s, CASH_RECEIPT_METHODS as t, checkoutSessionSchema as u, paymentMessageSchema as v, paymentStatusSchema as w, paymentOptionListSchema as x, paymentMethodSchema as y };
470
+ export { startPaymentRequestSchema as A, myCouponListQuerySchema as B, paymentStartSchema as C, residentNumberLike as D, remoteAreaSchema as E, checkoutPricingSchema as F, isShippingFulfillment as G, pricingAmountsSchema as H, couponApplicationListSchema as I, pageSchema as J, orderItemStatusSchema as K, couponApplicationSchema as L, MIN_PAYMENT_AMOUNT as M, applicableCouponSchema as N, retryPaymentRequestSchema as O, checkoutPricingRequestSchema as P, couponBenefitViewSchema as R, paymentOptionSchema as S, pgProviderSchema as T, claimStatusSchema as U, myCouponSchema as V, fulfillmentTypeField as W, requiresShippingField as Y, paymentFailureCategorySchema as _, cashReceiptAvailable as a, paymentOptionKey as b, cashReceiptTypeSchema as c, createCheckoutRequestSchema as d, deliveryQuoteRequestSchema as f, guestInfoSchema as g, easyPayProviderSchema as h, availablePaymentOptionSchema as i, MAX_COUPONS_PER_CHECKOUT as j, shippingAddressInputSchema as k, checkoutDeliverySchema as l, easyPayProviderResponseSchema as m, PAYMENT_RESULT_VALUES as n, cashReceiptIdentityTypeOf as o, deliveryQuoteSchema as p, pageInfoSchema as q, PAYMENT_STATUS_VALUES as r, cashReceiptRequestSchema as s, CASH_RECEIPT_METHODS as t, checkoutSessionSchema as u, paymentMessageSchema as v, paymentStatusSchema as w, paymentOptionListSchema as x, paymentMethodSchema as y, couponResultSchema as z };
@@ -1,5 +1,5 @@
1
1
  import { a as ANALYTICS_VISITOR_HEADER, r as ANALYTICS_SESSION_HEADER } from "./analytics-CgD70OqH.mjs";
2
- import { A as startPaymentRequestSchema, C as paymentStartSchema, O as retryPaymentRequestSchema, d as createCheckoutRequestSchema, f as deliveryQuoteRequestSchema, m as easyPayProviderResponseSchema, p as deliveryQuoteSchema, u as checkoutSessionSchema, w as paymentStatusSchema, y as paymentMethodSchema } from "./checkout-Cm9YAC5l.mjs";
2
+ import { A as startPaymentRequestSchema, C as paymentStartSchema, F as checkoutPricingSchema, J as pageSchema, K as orderItemStatusSchema, N as applicableCouponSchema, O as retryPaymentRequestSchema, P as checkoutPricingRequestSchema, U as claimStatusSchema, V as myCouponSchema, W as fulfillmentTypeField, Y as requiresShippingField, d as createCheckoutRequestSchema, f as deliveryQuoteRequestSchema, m as easyPayProviderResponseSchema, p as deliveryQuoteSchema, u as checkoutSessionSchema, w as paymentStatusSchema, y as paymentMethodSchema } from "./checkout-wrCpR-P1.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/http.ts
5
5
  /** 표준 엔벨로프의 $.error 상세 */
@@ -246,6 +246,7 @@ const cartItemSchema = z.object({
246
246
  quantity: z.number().int(),
247
247
  unitPrice: z.number().int(),
248
248
  totalPrice: z.number().int(),
249
+ fulfillmentType: fulfillmentTypeField(),
249
250
  purchasable: z.boolean(),
250
251
  unpurchasableReason: z.enum([
251
252
  "SOLD_OUT",
@@ -258,7 +259,8 @@ const cartSchema = z.object({
258
259
  summary: z.object({
259
260
  productAmount: z.number().int(),
260
261
  deliveryFee: z.number().int(),
261
- totalAmount: z.number().int()
262
+ totalAmount: z.number().int(),
263
+ requiresShipping: requiresShippingField("구매 가능한 항목 중 택배 배송이 필요한 상품이 있는가. false면 배송비가 0이고 주문서가 배송지를 받지 않는다.")
262
264
  })
263
265
  });
264
266
  const addCartItemRequestSchema = z.object({
@@ -271,38 +273,6 @@ const updateCartItemRequestSchema = z.object({
271
273
  optionId: z.string().optional()
272
274
  }).refine((value) => Object.values(value).some((v) => v !== void 0), { message: "최소 1개 필드가 필요합니다" });
273
275
  //#endregion
274
- //#region src/schemas/common.ts
275
- const pageInfoSchema = z.object({
276
- page: z.number().int(),
277
- size: z.number().int(),
278
- totalElements: z.number().int(),
279
- totalPages: z.number().int()
280
- });
281
- function pageSchema(item) {
282
- return pageInfoSchema.extend({ contents: z.array(item) });
283
- }
284
- const orderItemStatusSchema = z.enum([
285
- "PAYMENT_WAITING",
286
- "PAID",
287
- "CONFIRMED",
288
- "DISPATCHED",
289
- "DELIVERING",
290
- "DELIVERED",
291
- "PURCHASE_DECIDED",
292
- "CANCELED"
293
- ]);
294
- const claimStatusSchema = z.enum([
295
- "REQUESTED",
296
- "HELD",
297
- "COLLECTING",
298
- "COLLECTED",
299
- "REDELIVERING",
300
- "APPROVED",
301
- "REJECTED",
302
- "COMPLETED",
303
- "WITHDRAWN"
304
- ]);
305
- //#endregion
306
276
  //#region src/schemas/catalog.ts
307
277
  const categoryNodeSchema = z.lazy(() => z.object({
308
278
  categoryId: z.string(),
@@ -318,6 +288,8 @@ const productCardSchema = z.object({
318
288
  discountedPrice: z.number().int().nullable().describe("즉시 할인 적용가. 원 단위. 할인이 없으면 null"),
319
289
  discountRate: z.number().int().nullable().describe("할인율(%). 할인이 없으면 null"),
320
290
  freeShipping: z.boolean(),
291
+ fulfillmentType: fulfillmentTypeField(),
292
+ requiresShipping: requiresShippingField("택배 배송이 필요한 상품인가. false면 배송비가 없고 주문서가 배송지를 받지 않는다."),
321
293
  averageRating: z.number(),
322
294
  reviewCount: z.number().int(),
323
295
  soldOut: z.boolean()
@@ -411,10 +383,12 @@ const createClaimRequestSchema = z.object({
411
383
  const createClaimResultSchema = z.object({
412
384
  claimId: z.string(),
413
385
  status: z.literal("REQUESTED"),
414
- expectedRefundAmount: z.number().int().nullable().describe("예상 환불액 — 수량 비율 상품 금액 − 반품 배송비. **배송비 환불은 여기 포함되지 않고 `deliveryFeeRefundAmount`로 따로 온다**(승인 시점의 배송 묶음 상태로 확정되기 때문이다). 교환은 환불이 없어 null이다"),
386
+ expectedRefundAmount: z.number().int().nullable().describe("예상 환불액 — 수량 비율 상품 실결제 금액(쿠폰 할인을 뺀 금액) − 반품 배송비 − 조건부 무료배송 미달 차감 − 쿠폰 조건 미달 차감(`couponChargeAmount`) + 되돌릴 쿠폰 차감. **배송비 환불은 여기 포함되지 않고 `deliveryFeeRefundAmount`로 따로 온다**(승인 시점의 배송 묶음 상태로 확정되기 때문이다). 교환은 환불이 없어 null이다"),
415
387
  claimDeliveryFee: z.number().int().describe("구매자가 부담하는 반품·교환 배송비. 원 단위"),
416
388
  quantity: z.number().int().describe("접수된 수량. 요청에서 생략하면 남은 수량 전체다"),
417
- deliveryFeeRefundAmount: z.number().int().describe("환불 예정 배송비. 배송 묶음이 모두 취소되거나 판매자 귀책일 때만 0보다 크다")
389
+ deliveryFeeRefundAmount: z.number().int().describe("환불 예정 배송비. 배송 묶음이 모두 취소되거나 판매자 귀책일 때만 0보다 크다"),
390
+ couponChargeAmount: z.number().int().optional().default(0).describe("쿠폰 조건 미달 차감 예상액. 이 취소·반품으로 남은 주문상품이 쿠폰 조건(최소 주문 금액 등)을 잃으면 남은 주문상품이 받던 쿠폰 할인을 환불액에서 뺀다. 예상 환불액에 이미 반영돼 있다. 서버는 항상 싣는다"),
391
+ couponChargeRefundAmount: z.number().int().optional().default(0).describe("되돌릴 쿠폰 차감 예상액 — 앞선 취소·반품에서 뺀 쿠폰 조건 미달 차감 중 이번에 돌려받을 몫이다. 예상 환불액에 이미 반영돼 있다. 서버는 항상 싣는다")
418
392
  });
419
393
  /**
420
394
  * 반품지 (이슈 #30) — 반품·교환 수거가 안내하는 주소다. 스토어 주소록의 기본 반품지이거나,
@@ -439,7 +413,7 @@ const myClaimSchema = z.object({
439
413
  productName: z.string(),
440
414
  quantity: z.number().int().describe("접수된 수량"),
441
415
  reason: z.string(),
442
- expectedRefundAmount: z.number().int().nullable().describe("예상 환불액 — 수량 비율 상품 금액 − 반품 배송비 − 조건부 무료배송 미달 차감. **배송비 환불은 포함되지 않고 `expectedDeliveryFeeRefundAmount`로 따로 온다.** 교환은 null이다"),
416
+ expectedRefundAmount: z.number().int().nullable().describe("예상 환불액 — 수량 비율 상품 실결제 금액 − 반품 배송비 − 조건부 무료배송 미달 차감 − 쿠폰 조건 미달 차감 + 되돌릴 쿠폰 차감. **배송비 환불은 포함되지 않고 `expectedDeliveryFeeRefundAmount`로 따로 온다.** 교환은 null이다"),
443
417
  expectedDeliveryFeeRefundAmount: z.number().int().nullable().describe("예상 배송비 환불액. 배송 묶음이 모두 취소되거나 판매자 귀책일 때만 0보다 크다. 이 필드가 생기기 전에 접수된 클레임은 null이다"),
444
418
  rejectReason: z.string().nullable(),
445
419
  returnAddress: claimReturnAddressSchema.nullable().describe("반품·교환 물건을 보낼 반품지(이슈 #30). 직접 보내는 수거 안내에 쓴다. 취소 클레임은 null"),
@@ -612,8 +586,38 @@ const myOrderItemSchema = z.object({
612
586
  quantity: z.number().int().describe("주문 수량"),
613
587
  canceledQuantity: z.number().int().describe("취소·반품으로 환불된 누적 수량. 부분 취소가 없었으면 0이다"),
614
588
  activeQuantity: z.number().int().describe("남은 수량 (`quantity` − `canceledQuantity`). 취소·반품·교환 요청 수량의 상한이다"),
615
- totalPrice: z.number().int(),
589
+ totalPrice: z.number().int().describe("주문상품 금액 (즉시할인 반영, 쿠폰 전)"),
590
+ couponDiscountAmount: z.number().int().optional().default(0).describe("이 주문상품에 배분된 쿠폰 할인. 실결제 금액은 `totalPrice − couponDiscountAmount`다. 쿠폰이 없으면 0. 서버는 항상 싣는다"),
616
591
  status: orderItemStatusSchema,
592
+ fulfillmentType: fulfillmentTypeField(),
593
+ withdrawalRestricted: z.boolean().optional().default(false).describe("청약철회 제한 주문상품인가(이슈 #48). 구매자가 결제 전에 동의했고 제공이 시작되면(다운로드·열람·이용 시작) 구매자 취소·반품을 받지 않는다. 서버는 항상 싣는다"),
594
+ fulfillment: z.object({
595
+ status: z.string().describe("제공 상태. `FULFILLED`(제공함)·`REVOKED`(환불 등으로 회수함). 값이 추가될 수 있어 문자열로 받는다"),
596
+ fulfilledAt: z.string().describe("제공 시각 (ISO 8601)"),
597
+ note: z.string().nullable().describe("셀러가 남긴 이용 안내. 없으면 null"),
598
+ codes: z.array(z.object({
599
+ codeId: z.string(),
600
+ hint: z.string().describe("가린 코드 — 끝 4자만 보인다(예: `****AB12`)"),
601
+ revealedAt: z.string().nullable().describe("처음 열람한 시각. 열람 전이면 null")
602
+ })).optional().default([]).describe("코드 발급 상품의 코드(가린 값). 평문은 `fulfillment/reveal`로 연다. 환불로 회수된 코드는 싣지 않는다. 서버는 항상 싣는다"),
603
+ download: z.object({
604
+ count: z.number().int().describe("지금까지 받은 횟수"),
605
+ limit: z.number().int().describe("받을 수 있는 횟수"),
606
+ expiresAt: z.string().nullable().describe("받을 수 있는 기한 (ISO 8601)"),
607
+ files: z.array(z.object({
608
+ assetId: z.string(),
609
+ fileName: z.string(),
610
+ sizeBytes: z.number().int().nullable()
611
+ }))
612
+ }).nullable().optional().default(null).describe("파일 다운로드 상품의 횟수·기한·파일 목록. 파일 주소는 `downloads`로 받는다. 다른 유형은 null. 서버는 항상 싣는다")
613
+ }).nullable().optional().default(null).describe("비실물 상품(이용권·방문 수령 등)의 제공 정보(이슈 #48). 제공 전이거나 배송 상품이면 null이다. 비실물의 `DELIVERED`는 제공 완료(방문 수령은 수령 완료)로 표시한다. 서버는 항상 싣는다"),
614
+ pickupLocation: z.object({
615
+ name: z.string().describe("수령 장소 이름"),
616
+ zipCode: z.string(),
617
+ address1: z.string(),
618
+ address2: z.string().nullable(),
619
+ phone: z.string().describe("수령 장소 연락처")
620
+ }).nullable().optional().default(null).describe("방문 수령 장소(이슈 #48). 방문 수령 상품(`fulfillmentType` = `PICKUP`)이고 셀러가 수령지를 지정했을 때만 있다. 상품의 현재 수령지다. 서버는 항상 싣는다"),
617
621
  claimStatus: z.string().nullable(),
618
622
  reviewWritten: z.boolean(),
619
623
  autoDecisionDate: z.string().nullable()
@@ -635,14 +639,24 @@ const myOrderSchema = z.object({
635
639
  orderId: z.string(),
636
640
  orderedAt: z.string(),
637
641
  items: z.array(myOrderItemSchema),
642
+ requiresShipping: requiresShippingField("택배 배송이 필요한 주문상품이 있는가. false면 `shippingAddress`는 주문자 이름·연락처만 있고 주소는 빈 문자열이다."),
638
643
  shippingAddress: orderShippingAddressSchema,
639
644
  payment: z.object({
640
645
  method: paymentMethodSchema.describe("실제 결제수단(PG가 보고한 수단, 모르면 주문서에서 고른 수단). 결제창에서 바뀔 수 있다(카드 결제창의 간편결제 탭 등)"),
641
646
  easyPayProvider: easyPayProviderResponseSchema.nullable().optional().default(null).describe("간편결제사. `method`가 `EASY_PAY`일 때만 값이 있고, PG가 알려 주지 않았으면 주문서에서 고른 간편결제사다. 그 밖의 결제수단과 간편결제 이전 주문은 null. 서버는 항상 싣는다. 현재 값은 `NAVERPAY`·`KAKAOPAY`·`TOSSPAY`·`PAYCO`이고 값이 추가될 수 있어 문자열로 받는다"),
642
- totalAmount: z.number().int(),
647
+ couponDiscountAmount: z.number().int().optional().default(0).describe("상품·주문 쿠폰 할인 합계. 쿠폰이 없으면 0. 서버는 항상 싣는다"),
648
+ deliveryDiscountAmount: z.number().int().optional().default(0).describe("배송비 쿠폰 할인. 쿠폰이 없으면 0. 서버는 항상 싣는다"),
649
+ discounts: z.array(z.object({
650
+ couponId: z.string(),
651
+ name: z.string().describe("주문 시점 쿠폰 이름"),
652
+ kind: z.string().describe("쿠폰 종류. 현재 값은 `ORDER`·`PRODUCT`·`DELIVERY`이고 값이 추가될 수 있어 문자열로 받는다"),
653
+ discountAmount: z.number().int()
654
+ })).optional().default([]).describe("주문이 받은 쿠폰. 쿠폰이 없으면 빈 배열. 서버는 항상 싣는다"),
655
+ totalAmount: z.number().int().describe("결제 금액 (쿠폰 할인 반영)"),
643
656
  paidAt: z.string().nullable(),
644
657
  receiptUrl: z.url().nullable()
645
658
  }),
659
+ withdrawalAgreedAt: z.string().nullable().optional().default(null).describe("청약철회 제한 안내에 동의한 시각(이슈 #48). 제한 상품이 없던 주문은 null. 서버는 항상 싣는다"),
646
660
  testPayment: z.boolean().describe("테스트 결제(샌드박스 결제) 주문인가. true면 실제로 돈이 나가지 않았습니다 — 주문 화면에 테스트 결제 배지를 표시합니다")
647
661
  });
648
662
  /**
@@ -674,6 +688,33 @@ const purchaseDecisionResultSchema = z.object({
674
688
  status: z.literal("PURCHASE_DECIDED"),
675
689
  decidedAt: z.string()
676
690
  });
691
+ /**
692
+ * 코드 열람 응답 (이슈 #48) — `POST /storefront/v1/me/order-items/{orderItemId}/fulfillment/reveal`(회원)·
693
+ * `POST /storefront/v1/guest/orders/{orderId}/order-items/{orderItemId}/fulfillment/reveal`(비회원).
694
+ * 평문 코드는 이 응답에만 있다. 화면에 보인 뒤 저장하지 않는다(응답은 `Cache-Control: no-store`).
695
+ * 첫 열람 시각은 청약철회 판단의 근거(제공 개시)로 남는다.
696
+ */
697
+ const fulfillmentRevealSchema = z.object({
698
+ orderItemId: z.string(),
699
+ codes: z.array(z.object({
700
+ codeId: z.string(),
701
+ code: z.string().describe("코드 평문"),
702
+ revealedAt: z.string().describe("처음 열람한 시각")
703
+ }))
704
+ });
705
+ /**
706
+ * 다운로드 요청 (이슈 #48) — `POST /storefront/v1/me/order-items/{orderItemId}/downloads`(회원)·
707
+ * `POST /storefront/v1/guest/orders/{orderId}/order-items/{orderItemId}/downloads`(비회원, 연락처·비밀번호를 함께 보낸다).
708
+ * 파일이 하나면 `assetId`를 생략할 수 있다.
709
+ */
710
+ const downloadRequestSchema = z.object({ assetId: z.string().min(1).max(64).optional().describe("받을 파일. 파일이 여러 개면 필수다") });
711
+ /** 다운로드 응답 — 수명 300초의 서명 주소. 받을 때마다 횟수가 하나 준다 */
712
+ const downloadLinkSchema = z.object({
713
+ url: z.url().describe("서명 주소. 300초 뒤 만료된다 — 받아서 바로 쓰고 저장하지 않는다"),
714
+ expiresAt: z.string().describe("서명 주소 만료 시각"),
715
+ fileName: z.string(),
716
+ remaining: z.number().int().describe("남은 다운로드 횟수")
717
+ });
677
718
  //#endregion
678
719
  //#region src/schemas/review.ts
679
720
  const publicReviewSchema = z.object({
@@ -857,7 +898,16 @@ get: () => http.request("GET", "/store", storefrontStoreSchema) },
857
898
  * 스토어가 결제 도메인을 등록했는데 그 안이 아니다. 등록하지 않았으면 https 주소는 모두 받는다
858
899
  * - 503 `PAYMENT_PROVIDER_UNAVAILABLE`: 고른 PG의 결제창을 준비하지 못했다(다른 옵션으로 다시 시도)
859
900
  */
860
- startPayment: (checkoutId, body) => http.request("POST", path`/checkout/${checkoutId}/payment`, paymentStartSchema, { body: startPaymentRequestSchema.parse(body) })
901
+ startPayment: (checkoutId, body) => http.request("POST", path`/checkout/${checkoutId}/payment`, paymentStartSchema, { body: startPaymentRequestSchema.parse(body) }),
902
+ /**
903
+ * `POST /checkout/{checkoutId}/pricing` — 쿠폰 금액 미리보기(이슈 #47). 주문서를 바꾸지 않고 쿠폰을 예약하지 않는다.
904
+ * 확정은 결제 시작의 `coupons`다. 코드 입력은 구매자당 분당 10회까지다(429 `TOO_MANY_REQUESTS`).
905
+ *
906
+ * 에러: 404 `COUPON_NOT_FOUND`(없는 코드·남의 쿠폰) · 409 `COUPONS_UNAVAILABLE`(지금 쿠폰을 쓸 수 없음)
907
+ */
908
+ pricing: (checkoutId, body) => http.request("POST", path`/checkout/${checkoutId}/pricing`, checkoutPricingSchema, { body: checkoutPricingRequestSchema.parse(body) }),
909
+ /** `GET /checkout/{checkoutId}/coupons` — 이 주문서에 쓸 수 있는 내 쿠폰과 예상 할인(회원 전용) */
910
+ applicableCoupons: (checkoutId) => http.request("GET", path`/checkout/${checkoutId}/coupons`, z.array(applicableCouponSchema))
861
911
  },
862
912
  payments: {
863
913
  /**
@@ -888,6 +938,27 @@ get: () => http.request("GET", "/store", storefrontStoreSchema) },
888
938
  */
889
939
  getGuestOrder: (orderId, body) => http.request("POST", path`/guest/orders/${orderId}`, myOrderSchema, { body }),
890
940
  getDelivery: (orderItemId) => http.request("GET", path`/me/order-items/${orderItemId}/delivery`, deliveryTrackingSchema),
941
+ /**
942
+ * 코드 열람 (이슈 #48) — 코드 발급 상품의 평문 코드. 처음 열람한 시각이 제공 개시 증거로 남는다.
943
+ *
944
+ * 에러: 404 `ORDER_ITEM_NOT_FOUND`(없거나 남의 주문상품) · 404 `FULFILLMENT_NOT_FOUND`(제공 전·회수됨·코드 상품 아님) ·
945
+ * 429 `TOO_MANY_REQUESTS`
946
+ */
947
+ revealCode: (orderItemId) => http.request("POST", path`/me/order-items/${orderItemId}/fulfillment/reveal`, fulfillmentRevealSchema),
948
+ /**
949
+ * 파일 다운로드 (이슈 #48) — 수명 300초의 서명 주소를 받는다. 받을 때마다 남은 횟수가 준다.
950
+ *
951
+ * 에러: 404 `FULFILLMENT_NOT_FOUND`(제공 전·회수됨·파일 상품 아님) · 409 `DOWNLOAD_LIMIT_REACHED`(횟수 소진) ·
952
+ * 409 `DOWNLOAD_EXPIRED`(기한 지남) · 400 `ASSET_REQUIRED`(파일이 여러 개인데 `assetId` 없음)
953
+ */
954
+ createDownload: (orderItemId, body = {}) => http.request("POST", path`/me/order-items/${orderItemId}/downloads`, downloadLinkSchema, { body: downloadRequestSchema.parse(body) }),
955
+ /** 비회원 다운로드 — 비회원 주문 조회와 같은 연락처·주문 조회 비밀번호로 확인한다 */
956
+ createGuestDownload: (orderId, orderItemId, body) => http.request("POST", path`/guest/orders/${orderId}/order-items/${orderItemId}/downloads`, downloadLinkSchema, { body }),
957
+ /**
958
+ * 비회원 코드 열람 — 비회원 주문 조회와 같은 연락처·주문 조회 비밀번호로 확인하고 같은 시도 한도를 쓴다.
959
+ * 틀리면 구분 없이 404 `ORDER_NOT_FOUND`다.
960
+ */
961
+ revealGuestCode: (orderId, orderItemId, body) => http.request("POST", path`/guest/orders/${orderId}/order-items/${orderItemId}/fulfillment/reveal`, fulfillmentRevealSchema, { body }),
891
962
  decidePurchase: (orderItemId) => http.requestVoid("POST", path`/me/order-items/${orderItemId}/purchase-decision`)
892
963
  },
893
964
  myClaims: {
@@ -917,12 +988,16 @@ get: () => http.request("GET", "/store", storefrontStoreSchema) },
917
988
  remove: (reviewId) => http.requestVoid("DELETE", path`/me/reviews/${reviewId}`)
918
989
  },
919
990
  inquiries: { listMine: (params) => http.request("GET", "/me/inquiries", pageSchema(publicInquirySchema), { query: params }) },
920
- me: { customerInquiries: {
921
- create: (body) => http.request("POST", "/me/customer-inquiries", customerInquirySchema, { body: createCustomerInquiryRequestSchema.parse(body) }),
922
- list: (params) => http.request("GET", "/me/customer-inquiries", pageSchema(customerInquirySchema), { query: params }),
923
- get: (inquiryId) => http.request("GET", path`/me/customer-inquiries/${inquiryId}`, customerInquirySchema)
924
- } }
991
+ me: {
992
+ /** `GET /me/coupons` — 내 쿠폰(이슈 #47). `status`로 사용 가능·사용함·기간 지남을 거른다 */
993
+ coupons: (params) => http.request("GET", "/me/coupons", z.array(myCouponSchema), { query: params }),
994
+ customerInquiries: {
995
+ create: (body) => http.request("POST", "/me/customer-inquiries", customerInquirySchema, { body: createCustomerInquiryRequestSchema.parse(body) }),
996
+ list: (params) => http.request("GET", "/me/customer-inquiries", pageSchema(customerInquirySchema), { query: params }),
997
+ get: (inquiryId) => http.request("GET", path`/me/customer-inquiries/${inquiryId}`, customerInquirySchema)
998
+ }
999
+ }
925
1000
  };
926
1001
  }
927
1002
  //#endregion
928
- export { updateCartItemRequestSchema as $, consentSourceSchema as A, categoryNodeSchema as B, createInquiryResultSchema as C, customerInquirySchema as D, customerInquiryCategorySchema as E, claimReturnAddressSchema as F, productSortSchema as G, productDetailSchema as H, claimTypeSchema as I, pageInfoSchema as J, claimStatusSchema as K, createClaimRequestSchema as L, consentUpdateRequestSchema as M, memberConsentsSchema as N, consentActionSchema as O, claimReasonSchema as P, cartSchema as Q, createClaimResultSchema as R, createInquiryRequestSchema as S, createCustomerInquiryRequestSchema as T, productFacetsSchema as U, productCardSchema as V, productPageSchema as W, addCartItemRequestSchema as X, pageSchema as Y, cartItemSchema as Z, memberAddressRequestSchema as _, publicReviewSchema as a, linkIdentityRequestSchema as at, updateProfileRequestSchema as b, updateReviewRequestSchema as c, signupRequestSchema as ct, deliveryTrackingSchema as d, withdrawRequestSchema as dt, anonymousSessionSchema as et, myOrderItemSchema as f, withdrawalBlockedDetailsSchema as ft, trackingStageResponseSchema as g, unwrapData as gt, purchaseDecisionResultSchema as h, toApiError as ht, createReviewResultSchema as i, idpTokenRequestSchema as it, consentStateSchema as j, consentKindSchema as k, updateReviewResultSchema as l, socialProviderSchema as lt, orderShippingAddressSchema as m, buildQuery as mt, storefrontStoreSchema as n, idpAuthorizeRequestSchema as nt, reviewPageSchema as o, loginRequestSchema as ot, myOrderSchema as p, ApiError as pt, orderItemStatusSchema as q, createReviewRequestSchema as r, idpAuthorizeResponseSchema as rt, reviewSummarySchema as s, memberIdentitiesSchema as st, createStorefrontClient as t, idpAgreementsSchema as tt, writableReviewSchema as u, tokenPairSchema as ut, memberAddressSchema as v, publicInquirySchema as w, wishlistAddResultSchema as x, memberSchema as y, myClaimSchema as z };
1003
+ export { anonymousSessionSchema as $, customerInquirySchema as A, createClaimRequestSchema as B, updateProfileRequestSchema as C, publicInquirySchema as D, createInquiryResultSchema as E, consentUpdateRequestSchema as F, productDetailSchema as G, myClaimSchema as H, memberConsentsSchema as I, productSortSchema as J, productFacetsSchema as K, claimReasonSchema as L, consentKindSchema as M, consentSourceSchema as N, createCustomerInquiryRequestSchema as O, consentStateSchema as P, updateCartItemRequestSchema as Q, claimReturnAddressSchema as R, memberSchema as S, createInquiryRequestSchema as T, categoryNodeSchema as U, createClaimResultSchema as V, productCardSchema as W, cartItemSchema as X, addCartItemRequestSchema as Y, cartSchema as Z, orderShippingAddressSchema as _, publicReviewSchema as a, loginRequestSchema as at, memberAddressRequestSchema as b, updateReviewRequestSchema as c, socialProviderSchema as ct, deliveryTrackingSchema as d, withdrawalBlockedDetailsSchema as dt, idpAgreementsSchema as et, downloadLinkSchema as f, ApiError as ft, myOrderSchema as g, myOrderItemSchema as h, unwrapData as ht, createReviewResultSchema as i, linkIdentityRequestSchema as it, consentActionSchema as j, customerInquiryCategorySchema as k, updateReviewResultSchema as l, tokenPairSchema as lt, fulfillmentRevealSchema as m, toApiError as mt, storefrontStoreSchema as n, idpAuthorizeResponseSchema as nt, reviewPageSchema as o, memberIdentitiesSchema as ot, downloadRequestSchema as p, buildQuery as pt, productPageSchema as q, createReviewRequestSchema as r, idpTokenRequestSchema as rt, reviewSummarySchema as s, signupRequestSchema as st, createStorefrontClient as t, idpAuthorizeRequestSchema as tt, writableReviewSchema as u, withdrawRequestSchema as ut, purchaseDecisionResultSchema as v, wishlistAddResultSchema as w, memberAddressSchema as x, trackingStageResponseSchema as y, claimTypeSchema as z };