@sayren/storefront-sdk 0.2.1 → 0.3.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.
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ //#region src/schemas/auth.d.ts
3
+ declare const tokenPairSchema: z.ZodObject<{
4
+ accessToken: z.ZodString;
5
+ refreshToken: z.ZodString;
6
+ expiresIn: z.ZodNumber;
7
+ }, z.core.$strip>;
8
+ type TokenPair = z.infer<typeof tokenPairSchema>;
9
+ declare const signupRequestSchema: z.ZodObject<{
10
+ email: z.ZodEmail;
11
+ password: z.ZodString;
12
+ name: z.ZodString;
13
+ phone: z.ZodOptional<z.ZodString>;
14
+ agreements: z.ZodObject<{
15
+ terms: z.ZodLiteral<true>;
16
+ privacy: z.ZodLiteral<true>;
17
+ marketing: z.ZodDefault<z.ZodBoolean>;
18
+ }, z.core.$strip>;
19
+ cartToken: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>;
21
+ type SignupRequest = z.infer<typeof signupRequestSchema>;
22
+ declare const loginRequestSchema: z.ZodObject<{
23
+ email: z.ZodEmail;
24
+ password: z.ZodString;
25
+ cartToken: z.ZodOptional<z.ZodString>;
26
+ }, z.core.$strip>;
27
+ type LoginRequest = z.infer<typeof loginRequestSchema>;
28
+ /**
29
+ * 비회원 익명 세션 — `POST /auth/anonymous` 응답. `cartToken`을 `X-Cart-Token` 헤더로 보내면 장바구니와
30
+ * 비회원 주문이 이 세션에 쌓인다. 구매자 계정이 아니므로 `/me/*`에는 쓸 수 없다.
31
+ * 마지막 활동 후 30일이 지나거나 로그인·가입으로 회원 장바구니에 병합되면 더는 쓸 수 없다.
32
+ */
33
+ declare const anonymousSessionSchema: z.ZodObject<{
34
+ cartToken: z.ZodString;
35
+ expiresAt: z.ZodString;
36
+ }, z.core.$strip>;
37
+ type AnonymousSession = z.infer<typeof anonymousSessionSchema>;
38
+ //#endregion
39
+ //#region src/http.d.ts
40
+ declare class ApiError extends Error {
41
+ readonly status: number;
42
+ readonly code: string;
43
+ readonly traceId?: string | undefined;
44
+ readonly body?: unknown | undefined;
45
+ /** 엔벨로프 `$.error.details` — 에러 코드별 보조 데이터. 없으면 undefined */
46
+ readonly details?: Record<string, unknown> | undefined;
47
+ constructor(status: number, code: string, message: string, traceId?: string | undefined, body?: unknown | undefined,
48
+ /** 엔벨로프 `$.error.details` — 에러 코드별 보조 데이터. 없으면 undefined */
49
+ details?: Record<string, unknown> | undefined);
50
+ }
51
+ type TokenSource = string | null | undefined | (() => string | null | undefined);
52
+ type Query = Record<string, string | number | boolean | undefined>;
53
+ declare function buildQuery(query?: Query): string;
54
+ //#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 };
package/dist/index.d.mts CHANGED
@@ -1,3 +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
2
  import { z } from "zod";
2
3
  //#region src/analytics-ids.d.ts
3
4
  /**
@@ -14,48 +15,6 @@ export declare function analyticsIdsFromCookie(cookieHeader: string | null | und
14
15
  sessionId?: string;
15
16
  };
16
17
  //#endregion
17
- //#region src/http.d.ts
18
- export declare class ApiError extends Error {
19
- readonly status: number;
20
- readonly code: string;
21
- readonly traceId?: string | undefined;
22
- readonly body?: unknown | undefined;
23
- /** 엔벨로프 `$.error.details` — 에러 코드별 보조 데이터. 없으면 undefined */
24
- readonly details?: Record<string, unknown> | undefined;
25
- constructor(status: number, code: string, message: string, traceId?: string | undefined, body?: unknown | undefined,
26
- /** 엔벨로프 `$.error.details` — 에러 코드별 보조 데이터. 없으면 undefined */
27
- details?: Record<string, unknown> | undefined);
28
- }
29
- type TokenSource = string | null | undefined | (() => string | null | undefined);
30
- type Query = Record<string, string | number | boolean | undefined>;
31
- export declare function buildQuery(query?: Query): string;
32
- //#endregion
33
- //#region src/schemas/auth.d.ts
34
- export declare const tokenPairSchema: z.ZodObject<{
35
- accessToken: z.ZodString;
36
- refreshToken: z.ZodString;
37
- expiresIn: z.ZodNumber;
38
- }, z.core.$strip>;
39
- export type TokenPair = z.infer<typeof tokenPairSchema>;
40
- export declare const signupRequestSchema: z.ZodObject<{
41
- email: z.ZodEmail;
42
- password: z.ZodString;
43
- name: z.ZodString;
44
- phone: z.ZodOptional<z.ZodString>;
45
- agreements: z.ZodObject<{
46
- terms: z.ZodLiteral<true>;
47
- privacy: z.ZodLiteral<true>;
48
- marketing: z.ZodDefault<z.ZodBoolean>;
49
- }, z.core.$strip>;
50
- }, z.core.$strip>;
51
- export type SignupRequest = z.infer<typeof signupRequestSchema>;
52
- export declare const loginRequestSchema: z.ZodObject<{
53
- email: z.ZodEmail;
54
- password: z.ZodString;
55
- cartToken: z.ZodOptional<z.ZodString>;
56
- }, z.core.$strip>;
57
- export type LoginRequest = z.infer<typeof loginRequestSchema>;
58
- //#endregion
59
18
  //#region src/schemas/cart.d.ts
60
19
  export declare const cartItemSchema: z.ZodObject<{
61
20
  cartItemId: z.ZodString;
@@ -721,6 +680,11 @@ export declare function createStorefrontClient(options: StorefrontClientOptions)
721
680
  joinedAt: string;
722
681
  } | null>;
723
682
  auth: {
683
+ /** 비회원 익명 세션 발급 — 응답의 cartToken을 `cartToken` 옵션(X-Cart-Token)으로 쓴다 */
684
+ anonymous: () => Promise<{
685
+ cartToken: string;
686
+ expiresAt: string;
687
+ }>;
724
688
  signup: (body: SignupRequest) => Promise<{
725
689
  accessToken: string;
726
690
  refreshToken: string;
@@ -1519,4 +1483,4 @@ export declare const deliveryTrackingSchema: z.ZodObject<{
1519
1483
  }, z.core.$strip>;
1520
1484
  export type DeliveryTracking = z.infer<typeof deliveryTrackingSchema>;
1521
1485
  //#endregion
1522
- export type { Query, SessionStorage, StorefrontClient, StorefrontClientOptions, StorefrontSession, StorefrontSessionOptions, TokenSource };
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 };