@sayren/store-sdk 0.1.0 → 0.2.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,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { PageParams } from "./common";
2
+ import { type PageParams, pageQueryShape } from "./common";
3
3
 
4
4
  export const productStatusSchema = z.enum(["SALE", "SUSPENDED", "OUT_OF_STOCK", "CLOSED"]);
5
5
 
@@ -234,12 +234,15 @@ export const productPatchRequestSchema = z
234
234
 
235
235
  export type ProductPatchRequest = z.infer<typeof productPatchRequestSchema>;
236
236
 
237
- export type ProductSort =
238
- | "createdAt.desc"
239
- | "createdAt.asc"
240
- | "salePrice.asc"
241
- | "salePrice.desc"
242
- | "updatedAt.desc";
237
+ export const productSortSchema = z.enum([
238
+ "createdAt.desc",
239
+ "createdAt.asc",
240
+ "salePrice.asc",
241
+ "salePrice.desc",
242
+ "updatedAt.desc",
243
+ ]);
244
+
245
+ export type ProductSort = z.infer<typeof productSortSchema>;
243
246
 
244
247
  export interface ProductListParams extends PageParams {
245
248
  status?: ProductStatus;
@@ -249,6 +252,26 @@ export interface ProductListParams extends PageParams {
249
252
  sort?: ProductSort;
250
253
  }
251
254
 
255
+ /** `GET /v1/products` 쿼리 — OpenAPI 문서용 형태(값은 쿼리 문자열) */
256
+ export const productListQuerySchema = z.object({
257
+ status: productStatusSchema.optional().describe("판매 상태 필터"),
258
+ categoryId: z.string().optional().describe("카테고리 필터 — 하위 카테고리의 상품도 포함"),
259
+ keyword: z.string().optional().describe("상품명 검색 (포함)"),
260
+ sellerCode: z
261
+ .string()
262
+ .optional()
263
+ .describe("판매자 상품코드 — 이 코드가 붙은 variant를 가진 상품"),
264
+ sort: productSortSchema.optional().describe("정렬 (기본 createdAt.desc)"),
265
+ ...pageQueryShape(),
266
+ });
267
+
268
+ /** `POST /v1/product-images` 응답 — 업로드된 이미지의 CDN 주소 */
269
+ export const productImageUploadResultSchema = z.object({
270
+ images: z.array(z.object({ url: z.url(), width: z.number().int(), height: z.number().int() })),
271
+ });
272
+
273
+ export type ProductImageUploadResult = z.infer<typeof productImageUploadResultSchema>;
274
+
252
275
  export const discountSchema = z.object({
253
276
  productId: z.string(),
254
277
  discountType: z.enum(["RATE", "AMOUNT"]),
@@ -14,7 +14,7 @@ export const scopeAccessSchema = z
14
14
  .describe("접근 수준. `r`=읽기, `rw`=읽기+쓰기(r을 함의)");
15
15
  export type ScopeAccess = z.infer<typeof scopeAccessSchema>;
16
16
 
17
- /** 리소스별로 부여 가능한 접근 수준. settlement는 쓰기 API가 없어 `r`만 존재한다 */
17
+ /** 리소스별로 부여 가능한 접근 수준. settlement·analytics는 쓰기 API가 없어 `r`만 존재한다 */
18
18
  export const STORE_SCOPE_RESOURCES = {
19
19
  product: ["r", "rw"],
20
20
  category: ["r", "rw"],
@@ -23,6 +23,7 @@ export const STORE_SCOPE_RESOURCES = {
23
23
  inquiry: ["r", "rw"],
24
24
  review: ["r", "rw"],
25
25
  settlement: ["r"],
26
+ analytics: ["r"],
26
27
  webhook: ["r", "rw"],
27
28
  store: ["r", "rw"],
28
29
  member: ["r", "rw"],
@@ -56,6 +57,7 @@ export const STORE_ROLE_SCOPES = {
56
57
  "inquiry:rw",
57
58
  "review:rw",
58
59
  "settlement:r",
60
+ "analytics:r",
59
61
  "webhook:rw",
60
62
  "store:rw",
61
63
  "member:rw",
@@ -67,6 +69,7 @@ export const STORE_ROLE_SCOPES = {
67
69
  "claim:rw",
68
70
  "inquiry:rw",
69
71
  "review:rw",
72
+ "analytics:r",
70
73
  "webhook:rw",
71
74
  "store:rw",
72
75
  "member:rw",
@@ -111,10 +111,28 @@ export const invitationSchema = z.object({
111
111
 
112
112
  export type Invitation = z.infer<typeof invitationSchema>;
113
113
 
114
+ /** `GET /v1/store/invitations` 쿼리 — OpenAPI 문서용 형태 */
115
+ export const invitationListQuerySchema = z.object({
116
+ status: invitationSchema.shape.status.optional().describe("초대 상태 필터"),
117
+ });
118
+
119
+ /** `PATCH /v1/store/members/{userId}` 응답 — 바뀐 역할 */
120
+ export const storeMemberRoleUpdatedSchema = z.object({
121
+ userId: z.string(),
122
+ role: z.enum(["ADMIN", "STAFF"]),
123
+ });
124
+
125
+ export type StoreMemberRoleUpdated = z.infer<typeof storeMemberRoleUpdatedSchema>;
126
+
114
127
  export const addressTypeSchema = z.enum(["SHIPPING", "RETURN"]);
115
128
 
116
129
  export type AddressType = z.infer<typeof addressTypeSchema>;
117
130
 
131
+ /** `GET /v1/seller-addresses` 쿼리 — OpenAPI 문서용 형태. 기본 주소 우선, 그다음 등록순이다 */
132
+ export const sellerAddressListQuerySchema = z.object({
133
+ type: addressTypeSchema.optional().describe("주소 유형 필터"),
134
+ });
135
+
118
136
  export const sellerAddressSchema = z.object({
119
137
  addressId: z.string(),
120
138
  type: addressTypeSchema,