@sayren/storefront-sdk 0.3.0 → 0.5.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 { a as AnonymousSession, c as TokenPair, o as LoginRequest, s as SignupRequest, t as ApiError } from "../http-DWaRhLfG.mjs";
1
+ import { a as AnonymousSession, c as TokenPair, l as WithdrawRequest, o as LoginRequest, s as SignupRequest, t as ApiError, u as WithdrawalBlockedDetails } from "../http-CxqZxTfE.mjs";
2
2
  //#region src/auth/index.d.ts
3
3
  export interface StorefrontAuthOptions {
4
4
  /** 예: https://api.sayren.app/storefront/v1 */
@@ -37,7 +37,13 @@ export declare function createStorefrontAuth(options: StorefrontAuthOptions): {
37
37
  * 액세스 토큰이 이미 만료됐으면(401) 서버에서 할 일이 없으므로 성공으로 본다.
38
38
  */
39
39
  signOut(accessToken: string): Promise<void>;
40
+ /**
41
+ * 구매자 탈퇴 — 계정·배송지·위시리스트·장바구니·적립금을 지우고 토큰을 모두 무효로 만든다. 되돌릴 수 없다.
42
+ * 주문·리뷰·문의 기록은 스토어가 보관한다. 진행 중인 주문이나 처리 중인 클레임이 있으면
43
+ * 409 `WITHDRAWAL_BLOCKED`(`error.details`: `WithdrawalBlockedDetails`)다. 앱은 성공 후 보관한 토큰을 지운다.
44
+ */
45
+ withdraw(accessToken: string, body: WithdrawRequest): Promise<void>;
40
46
  };
41
47
  export type StorefrontAuth = ReturnType<typeof createStorefrontAuth>;
42
48
  //#endregion
43
- export { type AnonymousSession, ApiError, type LoginRequest, type SignupRequest, type TokenPair };
49
+ export { type AnonymousSession, ApiError, type LoginRequest, type SignupRequest, type TokenPair, type WithdrawRequest, type WithdrawalBlockedDetails };
@@ -1,4 +1,4 @@
1
- import { t as createStorefrontClient, tt as ApiError } from "../client-Xb-2tNKT.mjs";
1
+ import { it as ApiError, t as createStorefrontClient } from "../client-D-w3LIU2.mjs";
2
2
  //#region src/auth/index.ts
3
3
  /**
4
4
  * 구매자 인증 — 화면은 스토어프런트가 그리고, 계정 저장과 인증 처리는 sayren이 한다.
@@ -51,6 +51,14 @@ function createStorefrontAuth(options) {
51
51
  if (error instanceof ApiError && error.status === 401) return;
52
52
  throw error;
53
53
  }
54
+ },
55
+ /**
56
+ * 구매자 탈퇴 — 계정·배송지·위시리스트·장바구니·적립금을 지우고 토큰을 모두 무효로 만든다. 되돌릴 수 없다.
57
+ * 주문·리뷰·문의 기록은 스토어가 보관한다. 진행 중인 주문이나 처리 중인 클레임이 있으면
58
+ * 409 `WITHDRAWAL_BLOCKED`(`error.details`: `WithdrawalBlockedDetails`)다. 앱은 성공 후 보관한 토큰을 지운다.
59
+ */
60
+ withdraw(accessToken, body) {
61
+ return client(accessToken).auth.withdraw(body);
54
62
  }
55
63
  };
56
64
  }
@@ -150,6 +150,21 @@ const anonymousSessionSchema = z.object({
150
150
  /** 이 시각까지 활동이 없으면 만료(ISO 8601). 쓸 때마다 늘어난다 */
151
151
  expiresAt: z.string()
152
152
  });
153
+ /**
154
+ * 구매자 탈퇴 — `POST /auth/withdraw`. 본인 확인으로 비밀번호를 다시 받는다.
155
+ * 진행 중인 주문(결제 대기~배송 중)·클레임·결제가 있으면 409 `WITHDRAWAL_BLOCKED`, 비밀번호가 틀리면
156
+ * 403 `PASSWORD_MISMATCH`다(로그인과 같은 5회 잠금).
157
+ */
158
+ const withdrawRequestSchema = z.object({ password: z.string().min(1) });
159
+ /** `WITHDRAWAL_BLOCKED`의 `error.details` — 탈퇴를 막는 항목 수 */
160
+ const withdrawalBlockedDetailsSchema = z.object({
161
+ /** 결제 대기~배송 중인 주문 상품 */
162
+ inProgressOrderItems: z.number().int(),
163
+ /** 처리 중인 취소·반품·교환 */
164
+ openClaims: z.number().int(),
165
+ /** 승인 중이거나 결제창이 열려 있을 수 있는 결제(결제창은 만료되면 풀린다) */
166
+ pendingPayments: z.number().int()
167
+ });
153
168
  //#endregion
154
169
  //#region src/schemas/cart.ts
155
170
  const cartItemSchema = z.object({
@@ -627,6 +642,23 @@ const updateReviewRequestSchema = z.object({
627
642
  images: z.array(z.url()).max(5).optional()
628
643
  }).refine((value) => Object.values(value).some((v) => v !== void 0), { message: "최소 1개 필드가 필요합니다" });
629
644
  //#endregion
645
+ //#region src/schemas/store.ts
646
+ /**
647
+ * 스토어 공개 설정 — `GET /store`. 스토어프런트가 화면을 그릴 때 읽는 값만 담는다.
648
+ */
649
+ const storefrontStoreSchema = z.object({
650
+ storeCode: z.string(),
651
+ name: z.string(),
652
+ logoUrl: z.string().nullable(),
653
+ customerCenterPhone: z.string().nullable(),
654
+ businessHours: z.string().nullable(),
655
+ /**
656
+ * 비회원 주문 허용. false면 로그인하지 않은 구매자의 주문서 생성·결제 요청이 403 `GUEST_CHECKOUT_DISABLED`다.
657
+ * 장바구니 담기는 된다 — 주문 버튼을 로그인 안내로 바꾸면 된다
658
+ */
659
+ guestCheckout: z.boolean()
660
+ });
661
+ //#endregion
630
662
  //#region src/client.ts
631
663
  const productPageSchema = pageSchema(productCardSchema).extend({ facets: productFacetsSchema.optional() });
632
664
  const reviewPageSchema = pageSchema(publicReviewSchema).extend({ summary: reviewSummarySchema.optional() });
@@ -679,8 +711,13 @@ function createStorefrontClient(options) {
679
711
  signup: (body) => http.request("POST", "/auth/signup", tokenPairSchema, { body: signupRequestSchema.parse(body) }),
680
712
  login: (body) => http.request("POST", "/auth/login", tokenPairSchema, { body: loginRequestSchema.parse(body) }),
681
713
  refresh: (refreshToken) => http.request("POST", "/auth/token/refresh", tokenPairSchema, { body: { refreshToken } }),
682
- logout: () => http.requestVoid("POST", "/auth/logout")
714
+ logout: () => http.requestVoid("POST", "/auth/logout"),
715
+ /** 구매자 탈퇴 — 로그인 상태(accessToken)에서 비밀번호로 본인 확인. 성공하면 토큰은 모두 무효 */
716
+ withdraw: (body) => http.requestVoid("POST", "/auth/withdraw", { body: withdrawRequestSchema.parse(body) })
683
717
  },
718
+ store: {
719
+ /** 스토어 공개 설정 — 이름·고객센터·비회원 주문 허용 여부 */
720
+ get: () => http.request("GET", "/store", storefrontStoreSchema) },
684
721
  catalog: {
685
722
  listCategories: () => http.request("GET", "/categories", z.array(categoryNodeSchema)),
686
723
  searchProducts: (params) => http.request("GET", "/products", productPageSchema, { query: params }),
@@ -773,4 +810,4 @@ getStatus: (paymentId) => http.request("GET", path`/payments/${paymentId}`, paym
773
810
  };
774
811
  }
775
812
  //#endregion
776
- export { signupRequestSchema as $, PAYMENT_STATUS_VALUES as A, requestPaymentRequestSchema as B, createClaimRequestSchema as C, orderItemStatusSchema as D, claimStatusSchema as E, guestInfoSchema as F, productFacetsSchema as G, categoryNodeSchema as H, paymentMethodSchema as I, cartItemSchema as J, productSortSchema as K, paymentParamsSchema as L, confirmPaymentRequestSchema as M, confirmPaymentResultSchema as N, pageInfoSchema as O, createCheckoutRequestSchema as P, loginRequestSchema as Q, paymentStatusSchema as R, claimTypeSchema as S, myClaimSchema as T, productCardSchema as U, shippingAddressInputSchema as V, productDetailSchema as W, updateCartItemRequestSchema as X, cartSchema as Y, anonymousSessionSchema as Z, publicInquirySchema as _, reviewSummarySchema as a, customerInquirySchema as b, deliveryTrackingSchema as c, orderShippingAddressSchema as d, tokenPairSchema as et, memberAddressRequestSchema as f, createInquiryRequestSchema as g, updateProfileRequestSchema as h, publicReviewSchema as i, unwrapData as it, checkoutSessionSchema as j, pageSchema as k, myOrderItemSchema as l, memberSchema as m, createReviewRequestSchema as n, buildQuery as nt, updateReviewRequestSchema as o, memberAddressSchema as p, addCartItemRequestSchema as q, createReviewResultSchema as r, toApiError as rt, writableReviewSchema as s, createStorefrontClient as t, ApiError as tt, myOrderSchema as u, createCustomerInquiryRequestSchema as v, createClaimResultSchema as w, claimReasonSchema as x, customerInquiryCategorySchema as y, pgParamsSchema as z };
813
+ export { loginRequestSchema as $, pageSchema as A, pgParamsSchema as B, claimTypeSchema as C, claimStatusSchema as D, myClaimSchema as E, createCheckoutRequestSchema as F, productDetailSchema as G, shippingAddressInputSchema as H, guestInfoSchema as I, addCartItemRequestSchema as J, productFacetsSchema as K, paymentMethodSchema as L, checkoutSessionSchema as M, confirmPaymentRequestSchema as N, orderItemStatusSchema as O, confirmPaymentResultSchema as P, anonymousSessionSchema as Q, paymentParamsSchema as R, claimReasonSchema as S, createClaimResultSchema as T, categoryNodeSchema as U, requestPaymentRequestSchema as V, productCardSchema as W, cartSchema as X, cartItemSchema as Y, updateCartItemRequestSchema as Z, createInquiryRequestSchema as _, publicReviewSchema as a, buildQuery as at, customerInquiryCategorySchema as b, writableReviewSchema as c, myOrderSchema as d, signupRequestSchema as et, orderShippingAddressSchema as f, updateProfileRequestSchema as g, memberSchema as h, createReviewResultSchema as i, ApiError as it, PAYMENT_STATUS_VALUES as j, pageInfoSchema as k, deliveryTrackingSchema as l, memberAddressSchema as m, storefrontStoreSchema as n, withdrawRequestSchema as nt, reviewSummarySchema as o, toApiError as ot, memberAddressRequestSchema as p, productSortSchema as q, createReviewRequestSchema as r, withdrawalBlockedDetailsSchema as rt, updateReviewRequestSchema as s, unwrapData as st, createStorefrontClient as t, tokenPairSchema as tt, myOrderItemSchema as u, publicInquirySchema as v, createClaimRequestSchema as w, customerInquirySchema as x, createCustomerInquiryRequestSchema as y, paymentStatusSchema as z };
@@ -35,6 +35,22 @@ declare const anonymousSessionSchema: z.ZodObject<{
35
35
  expiresAt: z.ZodString;
36
36
  }, z.core.$strip>;
37
37
  type AnonymousSession = z.infer<typeof anonymousSessionSchema>;
38
+ /**
39
+ * 구매자 탈퇴 — `POST /auth/withdraw`. 본인 확인으로 비밀번호를 다시 받는다.
40
+ * 진행 중인 주문(결제 대기~배송 중)·클레임·결제가 있으면 409 `WITHDRAWAL_BLOCKED`, 비밀번호가 틀리면
41
+ * 403 `PASSWORD_MISMATCH`다(로그인과 같은 5회 잠금).
42
+ */
43
+ declare const withdrawRequestSchema: z.ZodObject<{
44
+ password: z.ZodString;
45
+ }, z.core.$strip>;
46
+ type WithdrawRequest = z.infer<typeof withdrawRequestSchema>;
47
+ /** `WITHDRAWAL_BLOCKED`의 `error.details` — 탈퇴를 막는 항목 수 */
48
+ declare const withdrawalBlockedDetailsSchema: z.ZodObject<{
49
+ inProgressOrderItems: z.ZodNumber;
50
+ openClaims: z.ZodNumber;
51
+ pendingPayments: z.ZodNumber;
52
+ }, z.core.$strip>;
53
+ type WithdrawalBlockedDetails = z.infer<typeof withdrawalBlockedDetailsSchema>;
38
54
  //#endregion
39
55
  //#region src/http.d.ts
40
56
  declare class ApiError extends Error {
@@ -52,4 +68,4 @@ type TokenSource = string | null | undefined | (() => string | null | undefined)
52
68
  type Query = Record<string, string | number | boolean | undefined>;
53
69
  declare function buildQuery(query?: Query): string;
54
70
  //#endregion
55
- export { AnonymousSession as a, TokenPair as c, signupRequestSchema as d, tokenPairSchema as f, buildQuery as i, anonymousSessionSchema as l, Query as n, LoginRequest as o, TokenSource as r, SignupRequest as s, ApiError as t, loginRequestSchema as u };
71
+ export { AnonymousSession as a, TokenPair as c, anonymousSessionSchema as d, loginRequestSchema as f, withdrawalBlockedDetailsSchema as g, withdrawRequestSchema as h, buildQuery as i, WithdrawRequest as l, tokenPairSchema as m, Query as n, LoginRequest as o, signupRequestSchema as p, TokenSource as r, SignupRequest as s, ApiError as t, WithdrawalBlockedDetails as u };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as AnonymousSession, c as TokenPair, d as signupRequestSchema, f as tokenPairSchema, i as buildQuery, l as anonymousSessionSchema, n as Query, o as LoginRequest, r as TokenSource, s as SignupRequest, t as ApiError, u as loginRequestSchema } from "./http-DWaRhLfG.mjs";
1
+ import { a as AnonymousSession, c as TokenPair, d as anonymousSessionSchema, f as loginRequestSchema, g as withdrawalBlockedDetailsSchema, h as withdrawRequestSchema, i as buildQuery, l as WithdrawRequest, m as tokenPairSchema, n as Query, o as LoginRequest, p as signupRequestSchema, r as TokenSource, s as SignupRequest, t as ApiError, u as WithdrawalBlockedDetails } from "./http-CxqZxTfE.mjs";
2
2
  import { z } from "zod";
3
3
  //#region src/analytics-ids.d.ts
4
4
  /**
@@ -701,6 +701,19 @@ export declare function createStorefrontClient(options: StorefrontClientOptions)
701
701
  expiresIn: number;
702
702
  }>;
703
703
  logout: () => Promise<void>;
704
+ /** 구매자 탈퇴 — 로그인 상태(accessToken)에서 비밀번호로 본인 확인. 성공하면 토큰은 모두 무효 */
705
+ withdraw: (body: WithdrawRequest) => Promise<void>;
706
+ };
707
+ store: {
708
+ /** 스토어 공개 설정 — 이름·고객센터·비회원 주문 허용 여부 */
709
+ get: () => Promise<{
710
+ storeCode: string;
711
+ name: string;
712
+ logoUrl: string | null;
713
+ customerCenterPhone: string | null;
714
+ businessHours: string | null;
715
+ guestCheckout: boolean;
716
+ }>;
704
717
  };
705
718
  catalog: {
706
719
  listCategories: () => Promise<CategoryNode[]>;
@@ -1483,4 +1496,18 @@ export declare const deliveryTrackingSchema: z.ZodObject<{
1483
1496
  }, z.core.$strip>;
1484
1497
  export type DeliveryTracking = z.infer<typeof deliveryTrackingSchema>;
1485
1498
  //#endregion
1486
- export { AnonymousSession, ApiError, LoginRequest, type Query, type SessionStorage, SignupRequest, type StorefrontClient, type StorefrontClientOptions, type StorefrontSession, type StorefrontSessionOptions, TokenPair, type TokenSource, anonymousSessionSchema, buildQuery, loginRequestSchema, signupRequestSchema, tokenPairSchema };
1499
+ //#region src/schemas/store.d.ts
1500
+ /**
1501
+ * 스토어 공개 설정 — `GET /store`. 스토어프런트가 화면을 그릴 때 읽는 값만 담는다.
1502
+ */
1503
+ export declare const storefrontStoreSchema: z.ZodObject<{
1504
+ storeCode: z.ZodString;
1505
+ name: z.ZodString;
1506
+ logoUrl: z.ZodNullable<z.ZodString>;
1507
+ customerCenterPhone: z.ZodNullable<z.ZodString>;
1508
+ businessHours: z.ZodNullable<z.ZodString>;
1509
+ guestCheckout: z.ZodBoolean;
1510
+ }, z.core.$strip>;
1511
+ export type StorefrontStore = z.infer<typeof storefrontStoreSchema>;
1512
+ //#endregion
1513
+ export { AnonymousSession, ApiError, LoginRequest, type Query, type SessionStorage, SignupRequest, type StorefrontClient, type StorefrontClientOptions, type StorefrontSession, type StorefrontSessionOptions, TokenPair, type TokenSource, WithdrawRequest, WithdrawalBlockedDetails, anonymousSessionSchema, buildQuery, loginRequestSchema, signupRequestSchema, tokenPairSchema, withdrawRequestSchema, withdrawalBlockedDetailsSchema };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as ANALYTICS_VISITOR_HEADER, c as analyticsClientEventSchema, i as ANALYTICS_VISITOR_COOKIE, l as analyticsIdSchema, n as ANALYTICS_SESSION_COOKIE, o as analyticsBatchSchema, r as ANALYTICS_SESSION_HEADER, s as analyticsClientEventNameSchema, t as ANALYTICS_MAX_BATCH_BYTES, u as analyticsServerEventNameSchema } from "./analytics-CgD70OqH.mjs";
2
2
  import { t as analyticsIdsFromCookie } from "./analytics-ids-COElZiI3.mjs";
3
- import { $ as signupRequestSchema, A as PAYMENT_STATUS_VALUES, B as requestPaymentRequestSchema, C as createClaimRequestSchema, D as orderItemStatusSchema, E as claimStatusSchema, F as guestInfoSchema, G as productFacetsSchema, H as categoryNodeSchema, I as paymentMethodSchema, J as cartItemSchema, K as productSortSchema, L as paymentParamsSchema, M as confirmPaymentRequestSchema, N as confirmPaymentResultSchema, O as pageInfoSchema, P as createCheckoutRequestSchema, Q as loginRequestSchema, R as paymentStatusSchema, S as claimTypeSchema, T as myClaimSchema, U as productCardSchema, V as shippingAddressInputSchema, W as productDetailSchema, X as updateCartItemRequestSchema, Y as cartSchema, Z as anonymousSessionSchema, _ as publicInquirySchema, a as reviewSummarySchema, b as customerInquirySchema, c as deliveryTrackingSchema, d as orderShippingAddressSchema, et as tokenPairSchema, f as memberAddressRequestSchema, g as createInquiryRequestSchema, h as updateProfileRequestSchema, i as publicReviewSchema, it as unwrapData, j as checkoutSessionSchema, k as pageSchema, l as myOrderItemSchema, m as memberSchema, n as createReviewRequestSchema, nt as buildQuery, o as updateReviewRequestSchema, p as memberAddressSchema, q as addCartItemRequestSchema, r as createReviewResultSchema, rt as toApiError, s as writableReviewSchema, t as createStorefrontClient, tt as ApiError, u as myOrderSchema, v as createCustomerInquiryRequestSchema, w as createClaimResultSchema, x as claimReasonSchema, y as customerInquiryCategorySchema, z as pgParamsSchema } from "./client-Xb-2tNKT.mjs";
3
+ import { $ as loginRequestSchema, A as pageSchema, B as pgParamsSchema, C as claimTypeSchema, D as claimStatusSchema, E as myClaimSchema, F as createCheckoutRequestSchema, G as productDetailSchema, H as shippingAddressInputSchema, I as guestInfoSchema, J as addCartItemRequestSchema, K as productFacetsSchema, L as paymentMethodSchema, M as checkoutSessionSchema, N as confirmPaymentRequestSchema, O as orderItemStatusSchema, P as confirmPaymentResultSchema, Q as anonymousSessionSchema, R as paymentParamsSchema, S as claimReasonSchema, T as createClaimResultSchema, U as categoryNodeSchema, V as requestPaymentRequestSchema, W as productCardSchema, X as cartSchema, Y as cartItemSchema, Z as updateCartItemRequestSchema, _ as createInquiryRequestSchema, a as publicReviewSchema, at as buildQuery, b as customerInquiryCategorySchema, c as writableReviewSchema, d as myOrderSchema, et as signupRequestSchema, f as orderShippingAddressSchema, g as updateProfileRequestSchema, h as memberSchema, i as createReviewResultSchema, it as ApiError, j as PAYMENT_STATUS_VALUES, k as pageInfoSchema, l as deliveryTrackingSchema, m as memberAddressSchema, n as storefrontStoreSchema, nt as withdrawRequestSchema, o as reviewSummarySchema, ot as toApiError, p as memberAddressRequestSchema, q as productSortSchema, r as createReviewRequestSchema, rt as withdrawalBlockedDetailsSchema, s as updateReviewRequestSchema, st as unwrapData, t as createStorefrontClient, tt as tokenPairSchema, u as myOrderItemSchema, v as publicInquirySchema, w as createClaimRequestSchema, x as customerInquirySchema, y as createCustomerInquiryRequestSchema, z as paymentStatusSchema } from "./client-D-w3LIU2.mjs";
4
4
  //#region src/session.ts
5
5
  /** 세션 키 상수 — SDK가 소유한다. store-sdk와 겹치지 않는 별도 네임스페이스. */
6
6
  const STOREFRONT_SESSION_KEYS = {
@@ -124,4 +124,4 @@ function createStorefrontSession(options) {
124
124
  };
125
125
  }
126
126
  //#endregion
127
- export { ANALYTICS_MAX_BATCH_BYTES, ANALYTICS_SESSION_COOKIE, ANALYTICS_SESSION_HEADER, ANALYTICS_VISITOR_COOKIE, ANALYTICS_VISITOR_HEADER, ApiError, PAYMENT_STATUS_VALUES, STOREFRONT_SESSION_KEYS, addCartItemRequestSchema, analyticsBatchSchema, analyticsClientEventNameSchema, analyticsClientEventSchema, analyticsIdSchema, analyticsIdsFromCookie, analyticsServerEventNameSchema, anonymousSessionSchema, buildQuery, cartItemSchema, cartSchema, categoryNodeSchema, checkoutSessionSchema, claimReasonSchema, claimStatusSchema, claimTypeSchema, confirmPaymentRequestSchema, confirmPaymentResultSchema, createCheckoutRequestSchema, createClaimRequestSchema, createClaimResultSchema, createCustomerInquiryRequestSchema, createInquiryRequestSchema, createReviewRequestSchema, createReviewResultSchema, createStorefrontClient, createStorefrontSession, customerInquiryCategorySchema, customerInquirySchema, deliveryTrackingSchema, guestInfoSchema, loginRequestSchema, memberAddressRequestSchema, memberAddressSchema, memberSchema, myClaimSchema, myOrderItemSchema, myOrderSchema, orderItemStatusSchema, orderShippingAddressSchema, pageInfoSchema, pageSchema, paymentMethodSchema, paymentParamsSchema, paymentStatusSchema, pgParamsSchema, productCardSchema, productDetailSchema, productFacetsSchema, productSortSchema, publicInquirySchema, publicReviewSchema, requestPaymentRequestSchema, reviewSummarySchema, shippingAddressInputSchema, signupRequestSchema, tokenPairSchema, updateCartItemRequestSchema, updateProfileRequestSchema, updateReviewRequestSchema, writableReviewSchema };
127
+ export { ANALYTICS_MAX_BATCH_BYTES, ANALYTICS_SESSION_COOKIE, ANALYTICS_SESSION_HEADER, ANALYTICS_VISITOR_COOKIE, ANALYTICS_VISITOR_HEADER, ApiError, PAYMENT_STATUS_VALUES, STOREFRONT_SESSION_KEYS, addCartItemRequestSchema, analyticsBatchSchema, analyticsClientEventNameSchema, analyticsClientEventSchema, analyticsIdSchema, analyticsIdsFromCookie, analyticsServerEventNameSchema, anonymousSessionSchema, buildQuery, cartItemSchema, cartSchema, categoryNodeSchema, checkoutSessionSchema, claimReasonSchema, claimStatusSchema, claimTypeSchema, confirmPaymentRequestSchema, confirmPaymentResultSchema, createCheckoutRequestSchema, createClaimRequestSchema, createClaimResultSchema, createCustomerInquiryRequestSchema, createInquiryRequestSchema, createReviewRequestSchema, createReviewResultSchema, createStorefrontClient, createStorefrontSession, customerInquiryCategorySchema, customerInquirySchema, deliveryTrackingSchema, guestInfoSchema, loginRequestSchema, memberAddressRequestSchema, memberAddressSchema, memberSchema, myClaimSchema, myOrderItemSchema, myOrderSchema, orderItemStatusSchema, orderShippingAddressSchema, pageInfoSchema, pageSchema, paymentMethodSchema, paymentParamsSchema, paymentStatusSchema, pgParamsSchema, productCardSchema, productDetailSchema, productFacetsSchema, productSortSchema, publicInquirySchema, publicReviewSchema, requestPaymentRequestSchema, reviewSummarySchema, shippingAddressInputSchema, signupRequestSchema, storefrontStoreSchema, tokenPairSchema, updateCartItemRequestSchema, updateProfileRequestSchema, updateReviewRequestSchema, withdrawRequestSchema, withdrawalBlockedDetailsSchema, writableReviewSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sayren/storefront-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "main": "./dist/index.mjs",
5
5
  "types": "./dist/index.d.mts",
6
6
  "exports": {
package/src/auth/index.ts CHANGED
@@ -1,10 +1,23 @@
1
1
  import { createStorefrontClient } from "../client";
2
2
  import { ApiError } from "../http";
3
- import type { AnonymousSession, LoginRequest, SignupRequest, TokenPair } from "../schemas/auth";
3
+ import type {
4
+ AnonymousSession,
5
+ LoginRequest,
6
+ SignupRequest,
7
+ TokenPair,
8
+ WithdrawRequest,
9
+ } from "../schemas/auth";
4
10
 
5
11
  /** 실패는 모두 이 클래스다 — 메인 엔트리의 `ApiError`와 같은 클래스라 어느 쪽으로 `instanceof`해도 된다 */
6
12
  export { ApiError } from "../http";
7
- export type { AnonymousSession, LoginRequest, SignupRequest, TokenPair } from "../schemas/auth";
13
+ export type {
14
+ AnonymousSession,
15
+ LoginRequest,
16
+ SignupRequest,
17
+ TokenPair,
18
+ WithdrawalBlockedDetails,
19
+ WithdrawRequest,
20
+ } from "../schemas/auth";
8
21
 
9
22
  export interface StorefrontAuthOptions {
10
23
  /** 예: https://api.sayren.app/storefront/v1 */
@@ -68,6 +81,14 @@ export function createStorefrontAuth(options: StorefrontAuthOptions) {
68
81
  throw error;
69
82
  }
70
83
  },
84
+ /**
85
+ * 구매자 탈퇴 — 계정·배송지·위시리스트·장바구니·적립금을 지우고 토큰을 모두 무효로 만든다. 되돌릴 수 없다.
86
+ * 주문·리뷰·문의 기록은 스토어가 보관한다. 진행 중인 주문이나 처리 중인 클레임이 있으면
87
+ * 409 `WITHDRAWAL_BLOCKED`(`error.details`: `WithdrawalBlockedDetails`)다. 앱은 성공 후 보관한 토큰을 지운다.
88
+ */
89
+ withdraw(accessToken: string, body: WithdrawRequest): Promise<void> {
90
+ return client(accessToken).auth.withdraw(body);
91
+ },
71
92
  };
72
93
  }
73
94
 
package/src/client.ts CHANGED
@@ -7,6 +7,8 @@ import {
7
7
  loginRequestSchema,
8
8
  signupRequestSchema,
9
9
  tokenPairSchema,
10
+ type WithdrawRequest,
11
+ withdrawRequestSchema,
10
12
  } from "./schemas/auth";
11
13
  import {
12
14
  type AddCartItemRequest,
@@ -71,6 +73,7 @@ import {
71
73
  updateReviewRequestSchema,
72
74
  writableReviewSchema,
73
75
  } from "./schemas/review";
76
+ import { storefrontStoreSchema } from "./schemas/store";
74
77
  import type { StorefrontSession } from "./session";
75
78
 
76
79
  export interface StorefrontClientOptions {
@@ -181,6 +184,14 @@ export function createStorefrontClient(options: StorefrontClientOptions) {
181
184
  refresh: (refreshToken: string) =>
182
185
  http.request("POST", "/auth/token/refresh", tokenPairSchema, { body: { refreshToken } }),
183
186
  logout: () => http.requestVoid("POST", "/auth/logout"),
187
+ /** 구매자 탈퇴 — 로그인 상태(accessToken)에서 비밀번호로 본인 확인. 성공하면 토큰은 모두 무효 */
188
+ withdraw: (body: WithdrawRequest) =>
189
+ http.requestVoid("POST", "/auth/withdraw", { body: withdrawRequestSchema.parse(body) }),
190
+ },
191
+
192
+ store: {
193
+ /** 스토어 공개 설정 — 이름·고객센터·비회원 주문 허용 여부 */
194
+ get: () => http.request("GET", "/store", storefrontStoreSchema),
184
195
  },
185
196
 
186
197
  catalog: {
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ export * from "./schemas/inquiry";
15
15
  export * from "./schemas/member";
16
16
  export * from "./schemas/order";
17
17
  export * from "./schemas/review";
18
+ export * from "./schemas/store";
18
19
  export {
19
20
  createStorefrontSession,
20
21
  type SessionStorage,
@@ -54,3 +54,26 @@ export const anonymousSessionSchema = z.object({
54
54
  });
55
55
 
56
56
  export type AnonymousSession = z.infer<typeof anonymousSessionSchema>;
57
+
58
+ /**
59
+ * 구매자 탈퇴 — `POST /auth/withdraw`. 본인 확인으로 비밀번호를 다시 받는다.
60
+ * 진행 중인 주문(결제 대기~배송 중)·클레임·결제가 있으면 409 `WITHDRAWAL_BLOCKED`, 비밀번호가 틀리면
61
+ * 403 `PASSWORD_MISMATCH`다(로그인과 같은 5회 잠금).
62
+ */
63
+ export const withdrawRequestSchema = z.object({
64
+ password: z.string().min(1),
65
+ });
66
+
67
+ export type WithdrawRequest = z.infer<typeof withdrawRequestSchema>;
68
+
69
+ /** `WITHDRAWAL_BLOCKED`의 `error.details` — 탈퇴를 막는 항목 수 */
70
+ export const withdrawalBlockedDetailsSchema = z.object({
71
+ /** 결제 대기~배송 중인 주문 상품 */
72
+ inProgressOrderItems: z.number().int(),
73
+ /** 처리 중인 취소·반품·교환 */
74
+ openClaims: z.number().int(),
75
+ /** 승인 중이거나 결제창이 열려 있을 수 있는 결제(결제창은 만료되면 풀린다) */
76
+ pendingPayments: z.number().int(),
77
+ });
78
+
79
+ export type WithdrawalBlockedDetails = z.infer<typeof withdrawalBlockedDetailsSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * 스토어 공개 설정 — `GET /store`. 스토어프런트가 화면을 그릴 때 읽는 값만 담는다.
5
+ */
6
+ export const storefrontStoreSchema = z.object({
7
+ storeCode: z.string(),
8
+ name: z.string(),
9
+ logoUrl: z.string().nullable(),
10
+ customerCenterPhone: z.string().nullable(),
11
+ businessHours: z.string().nullable(),
12
+ /**
13
+ * 비회원 주문 허용. false면 로그인하지 않은 구매자의 주문서 생성·결제 요청이 403 `GUEST_CHECKOUT_DISABLED`다.
14
+ * 장바구니 담기는 된다 — 주문 버튼을 로그인 안내로 바꾸면 된다
15
+ */
16
+ guestCheckout: z.boolean(),
17
+ });
18
+
19
+ export type StorefrontStore = z.infer<typeof storefrontStoreSchema>;