@sayren/storefront-sdk 0.14.0 → 0.16.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,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { easyPayProviderResponseSchema, paymentMethodSchema } from "./checkout";
3
- import { fulfillmentTypeField, orderItemStatusSchema, requiresShippingField } from "./common";
3
+ import { orderItemStatusSchema } from "./common";
4
+ import { myOrderItemFulfillmentSnapshotSchema } from "./fulfillment";
4
5
 
5
6
  export const myOrderItemSchema = z.object({
6
7
  orderItemId: z.string(),
@@ -30,77 +31,25 @@ export const myOrderItemSchema = z.object({
30
31
  "이 주문상품에 배분된 쿠폰 할인. 실결제 금액은 `totalPrice − couponDiscountAmount`다. 쿠폰이 없으면 0. 서버는 항상 싣는다",
31
32
  ),
32
33
  status: orderItemStatusSchema,
33
- fulfillmentType: fulfillmentTypeField(),
34
- withdrawalRestricted: z
35
- .boolean()
36
- .optional()
37
- .default(false)
38
- .describe(
39
- "청약철회 제한 주문상품인가(이슈 #48). 구매자가 결제 전에 동의했고 제공이 시작되면(다운로드·열람·이용 시작) 구매자 취소·반품을 받지 않는다. 서버는 항상 싣는다",
40
- ),
34
+ fulfillmentSnapshot: myOrderItemFulfillmentSnapshotSchema.describe(
35
+ "주문 시점 이행 스냅샷(이슈 #57). `type`이 주문 시점 상품 유형이다. 배송 없는 상품(`MANUAL`)이면 `DELIVERED`는 제공 완료다",
36
+ ),
41
37
  fulfillment: z
42
38
  .object({
43
39
  status: z
44
40
  .string()
45
41
  .describe(
46
- "제공 상태. `FULFILLED`(제공함)·`REVOKED`(환불 등으로 회수함). 값이 추가될 수 있어 문자열로 받는다",
42
+ "제공 상태. `FULFILLED`(제공함)·`REVOKED`(전량 취소·환불로 회수함). 값이 추가될 수 있어 문자열로 받는다",
47
43
  ),
48
44
  fulfilledAt: z.string().describe("제공 시각 (ISO 8601)"),
49
- note: z.string().nullable().describe("셀러가 남긴 이용 안내. 없으면 null"),
50
- codes: z
51
- .array(
52
- z.object({
53
- codeId: z.string(),
54
- hint: z.string().describe("가린 코드 — 끝 4자만 보인다(예: `****AB12`)"),
55
- revealedAt: z.string().nullable().describe("처음 열람한 시각. 열람 전이면 null"),
56
- }),
57
- )
58
- .optional()
59
- .default([])
60
- .describe(
61
- "코드 발급 상품의 코드(가린 값). 평문은 `fulfillment/reveal`로 연다. 환불로 회수된 코드는 싣지 않는다. 서버는 항상 싣는다",
62
- ),
63
- download: z
64
- .object({
65
- count: z.number().int().describe("지금까지 받은 횟수"),
66
- limit: z.number().int().describe("받을 수 있는 횟수"),
67
- expiresAt: z.string().nullable().describe("받을 수 있는 기한 (ISO 8601)"),
68
- files: z.array(
69
- z.object({
70
- assetId: z.string(),
71
- fileName: z.string(),
72
- sizeBytes: z.number().int().nullable(),
73
- }),
74
- ),
75
- })
76
- .nullable()
77
- .optional()
78
- .default(null)
79
- .describe(
80
- "파일 다운로드 상품의 횟수·기한·파일 목록. 파일 주소는 `downloads`로 받는다. 다른 유형은 null. 서버는 항상 싣는다",
81
- ),
45
+ note: z.string().nullable().describe("판매자가 제공 처리 때 남긴 이용 안내. 없으면 null"),
82
46
  })
83
47
  .nullable()
84
48
  .optional()
85
49
  .default(null)
86
50
  .describe(
87
- "비실물 상품(이용권·방문 수령 등)의 제공 정보(이슈 #48). 제공 전이거나 배송 상품이면 null이다. " +
88
- "비실물의 `DELIVERED`는 제공 완료(방문 수령은 수령 완료)로 표시한다. 서버는 항상 싣는다",
89
- ),
90
- pickupLocation: z
91
- .object({
92
- name: z.string().describe("수령 장소 이름"),
93
- zipCode: z.string(),
94
- address1: z.string(),
95
- address2: z.string().nullable(),
96
- phone: z.string().describe("수령 장소 연락처"),
97
- })
98
- .nullable()
99
- .optional()
100
- .default(null)
101
- .describe(
102
- "방문 수령 장소(이슈 #48). 방문 수령 상품(`fulfillmentType` = `PICKUP`)이고 셀러가 수령지를 지정했을 때만 있다. " +
103
- "상품의 현재 수령지다. 서버는 항상 싣는다",
51
+ "배송 없는 상품의 제공 기록(이슈 #48). 제공 전이거나 배송 상품이면 null이다. " +
52
+ "배송 없는 상품의 `DELIVERED`는 제공 완료로 표시한다. 서버는 항상 싣는다",
104
53
  ),
105
54
  claimStatus: z.string().nullable(),
106
55
  reviewWritten: z.boolean(),
@@ -132,9 +81,11 @@ export const myOrderSchema = z.object({
132
81
  orderId: z.string(),
133
82
  orderedAt: z.string(),
134
83
  items: z.array(myOrderItemSchema),
135
- requiresShipping: requiresShippingField(
136
- "택배 배송이 필요한 주문상품이 있는가. false면 `shippingAddress`는 주문자 이름·연락처만 있고 주소는 빈 문자열이다.",
137
- ),
84
+ requiresShipping: z
85
+ .boolean()
86
+ .describe(
87
+ "택배 배송이 필요한 주문상품이 있는가. false면 `shippingAddress`는 주문자 이름·연락처만 있고 주소는 빈 문자열이다",
88
+ ),
138
89
  shippingAddress: orderShippingAddressSchema,
139
90
  payment: z.object({
140
91
  method: paymentMethodSchema.describe(
@@ -181,14 +132,6 @@ export const myOrderSchema = z.object({
181
132
  paidAt: z.string().nullable(),
182
133
  receiptUrl: z.url().nullable(),
183
134
  }),
184
- withdrawalAgreedAt: z
185
- .string()
186
- .nullable()
187
- .optional()
188
- .default(null)
189
- .describe(
190
- "청약철회 제한 안내에 동의한 시각(이슈 #48). 제한 상품이 없던 주문은 null. 서버는 항상 싣는다",
191
- ),
192
135
  testPayment: z
193
136
  .boolean()
194
137
  .describe(
@@ -255,43 +198,3 @@ export const purchaseDecisionResultSchema = z.object({
255
198
  });
256
199
 
257
200
  export type PurchaseDecisionResult = z.infer<typeof purchaseDecisionResultSchema>;
258
-
259
- /**
260
- * 코드 열람 응답 (이슈 #48) — `POST /storefront/v1/me/order-items/{orderItemId}/fulfillment/reveal`(회원)·
261
- * `POST /storefront/v1/guest/orders/{orderId}/order-items/{orderItemId}/fulfillment/reveal`(비회원).
262
- * 평문 코드는 이 응답에만 있다. 화면에 보인 뒤 저장하지 않는다(응답은 `Cache-Control: no-store`).
263
- * 첫 열람 시각은 청약철회 판단의 근거(제공 개시)로 남는다.
264
- */
265
- export const fulfillmentRevealSchema = z.object({
266
- orderItemId: z.string(),
267
- codes: z.array(
268
- z.object({
269
- codeId: z.string(),
270
- code: z.string().describe("코드 평문"),
271
- revealedAt: z.string().describe("처음 열람한 시각"),
272
- }),
273
- ),
274
- });
275
-
276
- export type FulfillmentReveal = z.infer<typeof fulfillmentRevealSchema>;
277
-
278
- /**
279
- * 다운로드 요청 (이슈 #48) — `POST /storefront/v1/me/order-items/{orderItemId}/downloads`(회원)·
280
- * `POST /storefront/v1/guest/orders/{orderId}/order-items/{orderItemId}/downloads`(비회원, 연락처·비밀번호를 함께 보낸다).
281
- * 파일이 하나면 `assetId`를 생략할 수 있다.
282
- */
283
- export const downloadRequestSchema = z.object({
284
- assetId: z.string().min(1).max(64).optional().describe("받을 파일. 파일이 여러 개면 필수다"),
285
- });
286
-
287
- export type DownloadRequest = z.infer<typeof downloadRequestSchema>;
288
-
289
- /** 다운로드 응답 — 수명 300초의 서명 주소. 받을 때마다 횟수가 하나 준다 */
290
- export const downloadLinkSchema = z.object({
291
- url: z.url().describe("서명 주소. 300초 뒤 만료된다 — 받아서 바로 쓰고 저장하지 않는다"),
292
- expiresAt: z.string().describe("서명 주소 만료 시각"),
293
- fileName: z.string(),
294
- remaining: z.number().int().describe("남은 다운로드 횟수"),
295
- });
296
-
297
- export type DownloadLink = z.infer<typeof downloadLinkSchema>;