@sayren/store-sdk 0.19.0 → 0.21.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sayren/store-sdk",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "main": "./dist/index.mjs",
5
5
  "types": "./dist/index.d.mts",
6
6
  "exports": {
package/src/client.ts CHANGED
@@ -103,21 +103,6 @@ import {
103
103
  type WithdrawCustomerRequest,
104
104
  withdrawCustomerRequestSchema,
105
105
  } from "./schemas/customer";
106
- import {
107
- type DigitalAssetAttachRequest,
108
- digitalAssetAttachRequestSchema,
109
- digitalAssetPreviewSchema,
110
- digitalAssetSchema,
111
- } from "./schemas/digital-asset";
112
- import {
113
- type FulfillmentCodeUploadRequest,
114
- fulfillmentCodeBatchSchema,
115
- type fulfillmentCodeListQuerySchema,
116
- fulfillmentCodePageSchema,
117
- fulfillmentCodeRevealSchema,
118
- fulfillmentCodeSchema,
119
- fulfillmentCodeUploadRequestSchema,
120
- } from "./schemas/fulfillment-code";
121
106
  import {
122
107
  type LoginProvider,
123
108
  loginProviderTestSchema,
@@ -160,7 +145,6 @@ import {
160
145
  dispatchRequestSchema,
161
146
  type FulfillRequest,
162
147
  fulfillBulkRequestSchema,
163
- fulfillmentMailResendSchema,
164
148
  fulfillRequestSchema,
165
149
  type HoldOrderItemRequest,
166
150
  holdOrderItemRequestSchema,
@@ -219,6 +203,15 @@ import {
219
203
  variantStockRequestSchema,
220
204
  variantStockSchema,
221
205
  } from "./schemas/product";
206
+ import {
207
+ type SavedOptionSetFromProductRequestInput,
208
+ type SavedOptionSetListParams,
209
+ type SavedOptionSetRequestInput,
210
+ savedOptionSetFromProductRequestSchema,
211
+ savedOptionSetFromProductResultSchema,
212
+ savedOptionSetRequestSchema,
213
+ savedOptionSetSchema,
214
+ } from "./schemas/saved-option-set";
222
215
  import {
223
216
  type AddressType,
224
217
  type Invitation,
@@ -239,26 +232,51 @@ import {
239
232
  import {
240
233
  type ChangeStorefrontSlugRequest,
241
234
  type ChangeStorefrontTemplateRequest,
235
+ type CreateStorefrontEditPreviewLinkRequest,
242
236
  type CreateStorefrontPreviewLinkRequest,
243
237
  type CreateStorefrontSiteRequest,
238
+ type CreateStorefrontVersionRequest,
244
239
  changeStorefrontSlugRequestSchema,
245
240
  changeStorefrontTemplateRequestSchema,
241
+ createStorefrontEditPreviewLinkRequestSchema,
246
242
  createStorefrontPreviewLinkRequestSchema,
247
243
  createStorefrontSiteRequestSchema,
244
+ createStorefrontVersionRequestSchema,
245
+ type DeleteStorefrontFileRequest,
248
246
  type DisableStorefrontHostingRequest,
247
+ deleteStorefrontFileRequestSchema,
249
248
  disableStorefrontHostingRequestSchema,
249
+ type MoveStorefrontFileRequest,
250
+ moveStorefrontFileRequestSchema,
250
251
  type PublishStorefrontVersionRequest,
251
252
  publishStorefrontVersionRequestSchema,
252
253
  type RollbackStorefrontRequest,
254
+ type RunStorefrontCheckRequest,
253
255
  rollbackStorefrontRequestSchema,
256
+ runStorefrontCheckRequestSchema,
257
+ type SearchStorefrontFilesRequest,
254
258
  type SetStorefrontVisibilityRequest,
259
+ searchStorefrontFilesRequestSchema,
255
260
  setStorefrontVisibilityRequestSchema,
261
+ storefrontBuildSchema,
262
+ storefrontCheckSchema,
263
+ storefrontEditingSchema,
264
+ storefrontFileContentSchema,
265
+ storefrontFileDeleteResultSchema,
266
+ storefrontFileListSchema,
267
+ storefrontFileMoveResultSchema,
268
+ storefrontFileSearchResultSchema,
269
+ storefrontFileWriteResultSchema,
256
270
  storefrontHostingSchema,
257
271
  storefrontPreviewLinkSchema,
258
272
  storefrontSiteSchema,
259
273
  storefrontSlugAvailabilitySchema,
260
274
  storefrontTemplateSchema,
275
+ storefrontVerifyReportSchema,
276
+ storefrontVersionCreatedSchema,
261
277
  storefrontVersionSchema,
278
+ type WriteStorefrontFilesRequest,
279
+ writeStorefrontFilesRequestSchema,
262
280
  } from "./schemas/storefront-hosting";
263
281
  import {
264
282
  type UploadPurpose,
@@ -497,7 +515,7 @@ export function createStoreClient(options: StoreClientOptions) {
497
515
  const put = await fetchFn(ticket.uploadUrl, {
498
516
  method: "PUT",
499
517
  // 발급 응답의 헤더를 함께 싣는다 — 판매 파일(이슈 #48)은 비공개 헤더가 빠지면 공개 객체가 된다
500
- headers: { ...ticket.headers, "content-type": file.type || "application/octet-stream" },
518
+ headers: { "content-type": file.type || "application/octet-stream" },
501
519
  body: file,
502
520
  });
503
521
  if (!put.ok) {
@@ -560,75 +578,38 @@ export function createStoreClient(options: StoreClientOptions) {
560
578
  }),
561
579
  removeDiscount: (productId: string) =>
562
580
  storeHttp.requestVoid("DELETE", path`/products/${productId}/discount`),
563
- /**
564
- * 코드 일괄 업로드 (이슈 #48) — 코드 발급·자동 제공 상품의 코드 풀에 올린다. `codes`와 `csv` 중 하나만 보낸다.
565
- * 받은 코드 수만큼 재고가 는다. 에러: 409 `NOT_CODE_PRODUCT`·`CODE_POOL_NOT_USED`·`CODE_UPLOAD_CONFLICT`, 400 `TOO_MANY_CODES`
566
- */
567
- uploadCodes: (
568
- productId: string,
569
- body: FulfillmentCodeUploadRequest,
570
- idempotencyKey?: string,
571
- ) =>
572
- storeHttp.request("POST", path`/products/${productId}/codes`, fulfillmentCodeBatchSchema, {
573
- body: fulfillmentCodeUploadRequestSchema.parse(body),
574
- headers: idempotency(idempotencyKey),
575
- }),
576
- /** 코드 목록 — 가린 값(`hint`)만 싣는다. `available`은 필터와 무관한 판매 가능 코드 수다 */
577
- listCodes: (
578
- productId: string,
579
- params?: PageParams & Omit<z.input<typeof fulfillmentCodeListQuerySchema>, "page" | "size">,
580
- ) =>
581
- storeHttp.request("GET", path`/products/${productId}/codes`, fulfillmentCodePageSchema, {
582
- query: params as Query,
583
- }),
584
- /** 판매 가능 코드 폐기 — 재고가 1 준다. 배정된 코드는 409 `CODE_NOT_AVAILABLE` */
585
- voidCode: (productId: string, codeId: string) =>
586
- storeHttp.request(
587
- "POST",
588
- path`/products/${productId}/codes/${codeId}/void`,
589
- fulfillmentCodeSchema,
590
- ),
591
- /**
592
- * 판매 파일 연결 (이슈 #48) — `uploads.create({ purpose: "digital-asset" })`로 받은 `key`에 파일을 올린 뒤 연결한다.
593
- * 이후 주문부터 이 파일을 준다. 에러: 400 `INVALID_ASSET_KEY`, 409 `NOT_DOWNLOAD_PRODUCT`·`ASSET_ALREADY_ATTACHED`
594
- */
595
- attachDigitalAsset: (productId: string, body: DigitalAssetAttachRequest) =>
596
- storeHttp.request("POST", path`/products/${productId}/digital-assets`, digitalAssetSchema, {
597
- body: digitalAssetAttachRequestSchema.parse(body),
598
- }),
599
- /** 판매 파일 목록 — 해제한 파일도 싣는다. 객체 키·주소는 없다 */
600
- listDigitalAssets: (productId: string) =>
601
- storeHttp.request(
602
- "GET",
603
- path`/products/${productId}/digital-assets`,
604
- z.array(digitalAssetSchema),
605
- ),
606
- /** 판매 파일 해제 — 새 주문에 주지 않는다. 이미 산 구매자는 계속 받는다 */
607
- removeDigitalAsset: (productId: string, assetId: string) =>
608
- storeHttp.request(
609
- "DELETE",
610
- path`/products/${productId}/digital-assets/${assetId}`,
611
- digitalAssetSchema,
612
- ),
613
- /** 판매 파일 확인 주소 — 수명 300초의 서명 주소 */
614
- previewDigitalAsset: (productId: string, assetId: string) =>
615
- storeHttp.request(
616
- "POST",
617
- path`/products/${productId}/digital-assets/${assetId}/preview-url`,
618
- digitalAssetPreviewSchema,
619
- ),
620
581
  },
621
582
 
622
- fulfillmentCodes: {
623
- /**
624
- * 코드 평문 열람 — 콘솔에서 로그인한 OWNER·ADMIN만 된다(403 `INSUFFICIENT_ROLE`). 열람 기록과 감사 로그가 남는다.
625
- * 평문은 화면에 보인 뒤 저장하지 않는다
626
- */
627
- reveal: (codeId: string) =>
583
+ /**
584
+ * 저장 옵션 (이슈 #59) — 자주 쓰는 옵션 구성. 불러오기는 복사라 저장 옵션을 고쳐도 불러온 상품은 바뀌지 않는다.
585
+ * 권한은 상품과 같다(`product:r`·`product:rw`).
586
+ */
587
+ savedOptionSets: {
588
+ list: (params?: SavedOptionSetListParams) =>
589
+ storeHttp.request("GET", "/saved-option-sets", pageSchema(savedOptionSetSchema), {
590
+ query: params as Query,
591
+ }),
592
+ get: (optionSetId: string) =>
593
+ storeHttp.request("GET", path`/saved-option-sets/${optionSetId}`, savedOptionSetSchema),
594
+ /** 이름이 겹치면 409 `OPTION_SET_NAME_TAKEN`, 스토어당 200개를 넘으면 409 `OPTION_SET_LIMIT_EXCEEDED` */
595
+ create: (body: SavedOptionSetRequestInput) =>
596
+ storeHttp.request("POST", "/saved-option-sets", savedOptionSetSchema, {
597
+ body: savedOptionSetRequestSchema.parse(body),
598
+ }),
599
+ /** 통째로 바꾼다. 불러온 상품은 바뀌지 않는다 */
600
+ update: (optionSetId: string, body: SavedOptionSetRequestInput) =>
601
+ storeHttp.request("PUT", path`/saved-option-sets/${optionSetId}`, savedOptionSetSchema, {
602
+ body: savedOptionSetRequestSchema.parse(body),
603
+ }),
604
+ remove: (optionSetId: string) =>
605
+ storeHttp.requestVoid("DELETE", path`/saved-option-sets/${optionSetId}`),
606
+ /** 상품의 현재 옵션을 저장 옵션으로 만든다(또는 `replaceOptionSetId`를 덮어쓴다) */
607
+ saveFromProduct: (body: SavedOptionSetFromProductRequestInput) =>
628
608
  storeHttp.request(
629
609
  "POST",
630
- path`/fulfillment-codes/${codeId}/reveal`,
631
- fulfillmentCodeRevealSchema,
610
+ "/saved-option-sets/from-product",
611
+ savedOptionSetFromProductResultSchema,
612
+ { body: savedOptionSetFromProductRequestSchema.parse(body) },
632
613
  ),
633
614
  },
634
615
 
@@ -756,17 +737,7 @@ export function createStoreClient(options: StoreClientOptions) {
756
737
  headers: idempotency(idempotencyKey),
757
738
  }),
758
739
  /**
759
- * 제공 안내 메일 재발송 (이슈 #48) — 제공된 주문상품의 안내 메일을 다시 보낸다. 주문상품당 하루 3회(429).
760
- * 코드·파일 주소는 메일에 없다
761
- */
762
- resendFulfillmentMail: (orderItemId: string) =>
763
- storeHttp.request(
764
- "POST",
765
- path`/order-items/${orderItemId}/fulfillment/mail`,
766
- fulfillmentMailResendSchema,
767
- ),
768
- /**
769
- * 제공 처리 (이슈 #48) — 수동 제공 비실물 주문상품(이용권·방문 수령)을 `PAID`·`CONFIRMED`에서 제공 완료(`DELIVERED`)로
740
+ * 제공 처리 (이슈 #48) — 배송 없는 주문상품(`MANUAL`)을 `PAID`·`CONFIRMED`에서 제공 완료(`DELIVERED`)로
770
741
  * 바꾼다. `note`는 구매자 주문 상세에 이용 안내로 실린다. 배송 상품은 409 `SHIPPING_REQUIRED`
771
742
  */
772
743
  fulfill: (orderItemId: string, body: FulfillRequest = {}, idempotencyKey?: string) =>
@@ -1423,6 +1394,107 @@ export function createStoreClient(options: StoreClientOptions) {
1423
1394
  storeHttp.request("POST", "/storefront/site/disable", storefrontSiteSchema, {
1424
1395
  body: disableStorefrontHostingRequestSchema.parse(body),
1425
1396
  }),
1397
+
1398
+ // ─── 편집 (M2b) — 조회 `storefront:r`, 쓰기 `storefront:rw`. 에이전트도 승인 없이 된다 ───
1399
+
1400
+ /** `GET /v1/storefront/site/editing` — 편집 환경 상태(열린 환경·동시 상한·미리보기 인증서) */
1401
+ getEditing: () =>
1402
+ storeHttp.request("GET", "/storefront/site/editing", storefrontEditingSchema),
1403
+ /**
1404
+ * `POST /v1/storefront/site/editing` — 편집 환경을 연다(이미 열려 있으면 그대로). 플랫폼 동시 상한에 걸리면 409
1405
+ * `EDIT_CAPACITY_FULL`(`details.retryAfterSeconds`). 띄우는 데 보통 30초가 걸린다(`session.status: STARTING`)
1406
+ */
1407
+ startEditing: () =>
1408
+ storeHttp.request("POST", "/storefront/site/editing", storefrontEditingSchema, {
1409
+ body: {},
1410
+ }),
1411
+ /** `DELETE /v1/storefront/site/editing` — 편집 환경을 닫는다(작업 트리는 보존된다) */
1412
+ stopEditing: () =>
1413
+ storeHttp.request("DELETE", "/storefront/site/editing", storefrontEditingSchema),
1414
+ /**
1415
+ * `POST /v1/storefront/site/editing/preview-link` — 편집 미리보기(dev 서버) 5분짜리 링크.
1416
+ * 콘솔에서 로그인한 OWNER·ADMIN만 받는다(에이전트 불가)
1417
+ */
1418
+ createEditPreviewLink: (body: CreateStorefrontEditPreviewLinkRequest = {}) =>
1419
+ storeHttp.request(
1420
+ "POST",
1421
+ "/storefront/site/editing/preview-link",
1422
+ storefrontPreviewLinkSchema,
1423
+ { body: createStorefrontEditPreviewLinkRequestSchema.parse(body) },
1424
+ ),
1425
+ /** `GET /v1/storefront/site/files?prefix=` — 작업 트리 파일 목록 */
1426
+ listFiles: (params: { prefix?: string } = {}) =>
1427
+ storeHttp.request("GET", "/storefront/site/files", storefrontFileListSchema, {
1428
+ query: params as Query,
1429
+ }),
1430
+ /** `GET /v1/storefront/site/files/content?path=` — 파일 하나 읽기 */
1431
+ readFile: (filePath: string) =>
1432
+ storeHttp.request("GET", "/storefront/site/files/content", storefrontFileContentSchema, {
1433
+ query: { path: filePath },
1434
+ }),
1435
+ /**
1436
+ * `POST /v1/storefront/site/files/batch` — 여러 파일 쓰기(해시 조건). 조건이 하나라도 어긋나면 아무것도 쓰지 않고 409
1437
+ * `FILE_CHANGED`(`details.conflicts`). 편집 환경이 없으면 연다
1438
+ */
1439
+ writeFiles: (body: WriteStorefrontFilesRequest) =>
1440
+ storeHttp.request("POST", "/storefront/site/files/batch", storefrontFileWriteResultSchema, {
1441
+ body: writeStorefrontFilesRequestSchema.parse(body),
1442
+ }),
1443
+ /** `POST /v1/storefront/site/files/delete` */
1444
+ deleteFile: (body: DeleteStorefrontFileRequest) =>
1445
+ storeHttp.request(
1446
+ "POST",
1447
+ "/storefront/site/files/delete",
1448
+ storefrontFileDeleteResultSchema,
1449
+ {
1450
+ body: deleteStorefrontFileRequestSchema.parse(body),
1451
+ },
1452
+ ),
1453
+ /** `POST /v1/storefront/site/files/move` */
1454
+ moveFile: (body: MoveStorefrontFileRequest) =>
1455
+ storeHttp.request("POST", "/storefront/site/files/move", storefrontFileMoveResultSchema, {
1456
+ body: moveStorefrontFileRequestSchema.parse(body),
1457
+ }),
1458
+ /** `POST /v1/storefront/site/files/search` — 내용 검색 */
1459
+ searchFiles: (body: SearchStorefrontFilesRequest) =>
1460
+ storeHttp.request(
1461
+ "POST",
1462
+ "/storefront/site/files/search",
1463
+ storefrontFileSearchResultSchema,
1464
+ { body: searchStorefrontFilesRequestSchema.parse(body) },
1465
+ ),
1466
+ /**
1467
+ * `POST /v1/storefront/site/checks` (202) — 타입 검사·lint·test 하나를 시작한다. 결과는 `getCheck`로 끝날 때까지 조회한다
1468
+ * (`STOREFRONT_CHECK_TERMINAL_STATUSES`)
1469
+ */
1470
+ runCheck: (body: RunStorefrontCheckRequest) =>
1471
+ storeHttp.request("POST", "/storefront/site/checks", storefrontCheckSchema, {
1472
+ body: runStorefrontCheckRequestSchema.parse(body),
1473
+ }),
1474
+ /** `GET /v1/storefront/site/checks/{checkId}` — 검사 상태·종료 코드·출력 꼬리 */
1475
+ getCheck: (checkId: string) =>
1476
+ storeHttp.request("GET", path`/storefront/site/checks/${checkId}`, storefrontCheckSchema),
1477
+ /** `POST /v1/storefront/site/verify` — 작업 트리 규칙 검증(`verify_storefront`와 같은 보고서) */
1478
+ verify: () =>
1479
+ storeHttp.request("POST", "/storefront/site/verify", storefrontVerifyReportSchema, {
1480
+ body: {},
1481
+ }),
1482
+ /**
1483
+ * `POST /v1/storefront/site/versions` (201) — 지금 작업 트리로 버전을 만든다(빌드 시작). 버전은 `BUILDING`, 빌드가
1484
+ * 끝나면 `READY` 또는 `FAILED`다
1485
+ */
1486
+ createVersion: (body: CreateStorefrontVersionRequest = {}) =>
1487
+ storeHttp.request("POST", "/storefront/site/versions", storefrontVersionCreatedSchema, {
1488
+ body: createStorefrontVersionRequestSchema.parse(body),
1489
+ }),
1490
+ /** `GET /v1/storefront/site/builds?limit=` — 빌드 목록(최신 먼저) */
1491
+ listBuilds: (params: { limit?: number } = {}) =>
1492
+ storeHttp.request("GET", "/storefront/site/builds", z.array(storefrontBuildSchema), {
1493
+ query: params as Query,
1494
+ }),
1495
+ /** `GET /v1/storefront/site/builds/{buildId}` — 빌드 상태·실패 단계·로그 꼬리·규칙 결과 */
1496
+ getBuild: (buildId: string) =>
1497
+ storeHttp.request("GET", path`/storefront/site/builds/${buildId}`, storefrontBuildSchema),
1426
1498
  },
1427
1499
 
1428
1500
  store: {
package/src/index.ts CHANGED
@@ -27,9 +27,7 @@ export * from "./schemas/claim";
27
27
  export * from "./schemas/common";
28
28
  export * from "./schemas/coupon";
29
29
  export * from "./schemas/customer";
30
- export * from "./schemas/digital-asset";
31
30
  export * from "./schemas/fulfillment";
32
- export * from "./schemas/fulfillment-code";
33
31
  export * from "./schemas/login";
34
32
  export * from "./schemas/misc";
35
33
  export * from "./schemas/order";
@@ -37,6 +35,7 @@ export * from "./schemas/payment";
37
35
  export * from "./schemas/product";
38
36
  export * from "./schemas/promotion";
39
37
  export * from "./schemas/refund-policy";
38
+ export * from "./schemas/saved-option-set";
40
39
  export * from "./schemas/scope";
41
40
  export * from "./schemas/shipping-policy";
42
41
  export * from "./schemas/store";
@@ -90,7 +90,7 @@ export const claimSchema = z.object({
90
90
  .optional()
91
91
  .default("SHIPPING")
92
92
  .describe(
93
- "클레임 대상 주문상품의 상품 유형(이슈 #48). 수거가 없는 비실물(`DOWNLOAD`·`CODE`·`SERVICE`) 반품은 수거 등록 없이 " +
93
+ "클레임 대상 주문상품의 상품 유형(이슈 #48). 배송 없는 상품(`MANUAL`) 반품은 수거 등록 없이 " +
94
94
  "접수·보류에서 바로 승인한다. 값이 추가될 수 있어 문자열로 받는다. 서버는 항상 싣는다",
95
95
  ),
96
96
  requestedAt: z.string(),