@sayren/store-sdk 0.18.0 → 0.20.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.18.0",
3
+ "version": "0.20.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,
@@ -236,6 +220,55 @@ import {
236
220
  updateMemberRoleRequestSchema,
237
221
  updateStoreRequestSchema,
238
222
  } from "./schemas/store";
223
+ import {
224
+ type ChangeStorefrontSlugRequest,
225
+ type ChangeStorefrontTemplateRequest,
226
+ type CreateStorefrontEditPreviewLinkRequest,
227
+ type CreateStorefrontPreviewLinkRequest,
228
+ type CreateStorefrontSiteRequest,
229
+ type CreateStorefrontVersionRequest,
230
+ changeStorefrontSlugRequestSchema,
231
+ changeStorefrontTemplateRequestSchema,
232
+ createStorefrontEditPreviewLinkRequestSchema,
233
+ createStorefrontPreviewLinkRequestSchema,
234
+ createStorefrontSiteRequestSchema,
235
+ createStorefrontVersionRequestSchema,
236
+ type DeleteStorefrontFileRequest,
237
+ type DisableStorefrontHostingRequest,
238
+ deleteStorefrontFileRequestSchema,
239
+ disableStorefrontHostingRequestSchema,
240
+ type MoveStorefrontFileRequest,
241
+ moveStorefrontFileRequestSchema,
242
+ type PublishStorefrontVersionRequest,
243
+ publishStorefrontVersionRequestSchema,
244
+ type RollbackStorefrontRequest,
245
+ type RunStorefrontCheckRequest,
246
+ rollbackStorefrontRequestSchema,
247
+ runStorefrontCheckRequestSchema,
248
+ type SearchStorefrontFilesRequest,
249
+ type SetStorefrontVisibilityRequest,
250
+ searchStorefrontFilesRequestSchema,
251
+ setStorefrontVisibilityRequestSchema,
252
+ storefrontBuildSchema,
253
+ storefrontCheckSchema,
254
+ storefrontEditingSchema,
255
+ storefrontFileContentSchema,
256
+ storefrontFileDeleteResultSchema,
257
+ storefrontFileListSchema,
258
+ storefrontFileMoveResultSchema,
259
+ storefrontFileSearchResultSchema,
260
+ storefrontFileWriteResultSchema,
261
+ storefrontHostingSchema,
262
+ storefrontPreviewLinkSchema,
263
+ storefrontSiteSchema,
264
+ storefrontSlugAvailabilitySchema,
265
+ storefrontTemplateSchema,
266
+ storefrontVerifyReportSchema,
267
+ storefrontVersionCreatedSchema,
268
+ storefrontVersionSchema,
269
+ type WriteStorefrontFilesRequest,
270
+ writeStorefrontFilesRequestSchema,
271
+ } from "./schemas/storefront-hosting";
239
272
  import {
240
273
  type UploadPurpose,
241
274
  type UploadRequest,
@@ -473,7 +506,7 @@ export function createStoreClient(options: StoreClientOptions) {
473
506
  const put = await fetchFn(ticket.uploadUrl, {
474
507
  method: "PUT",
475
508
  // 발급 응답의 헤더를 함께 싣는다 — 판매 파일(이슈 #48)은 비공개 헤더가 빠지면 공개 객체가 된다
476
- headers: { ...ticket.headers, "content-type": file.type || "application/octet-stream" },
509
+ headers: { "content-type": file.type || "application/octet-stream" },
477
510
  body: file,
478
511
  });
479
512
  if (!put.ok) {
@@ -536,76 +569,6 @@ export function createStoreClient(options: StoreClientOptions) {
536
569
  }),
537
570
  removeDiscount: (productId: string) =>
538
571
  storeHttp.requestVoid("DELETE", path`/products/${productId}/discount`),
539
- /**
540
- * 코드 일괄 업로드 (이슈 #48) — 코드 발급·자동 제공 상품의 코드 풀에 올린다. `codes`와 `csv` 중 하나만 보낸다.
541
- * 받은 코드 수만큼 재고가 는다. 에러: 409 `NOT_CODE_PRODUCT`·`CODE_POOL_NOT_USED`·`CODE_UPLOAD_CONFLICT`, 400 `TOO_MANY_CODES`
542
- */
543
- uploadCodes: (
544
- productId: string,
545
- body: FulfillmentCodeUploadRequest,
546
- idempotencyKey?: string,
547
- ) =>
548
- storeHttp.request("POST", path`/products/${productId}/codes`, fulfillmentCodeBatchSchema, {
549
- body: fulfillmentCodeUploadRequestSchema.parse(body),
550
- headers: idempotency(idempotencyKey),
551
- }),
552
- /** 코드 목록 — 가린 값(`hint`)만 싣는다. `available`은 필터와 무관한 판매 가능 코드 수다 */
553
- listCodes: (
554
- productId: string,
555
- params?: PageParams & Omit<z.input<typeof fulfillmentCodeListQuerySchema>, "page" | "size">,
556
- ) =>
557
- storeHttp.request("GET", path`/products/${productId}/codes`, fulfillmentCodePageSchema, {
558
- query: params as Query,
559
- }),
560
- /** 판매 가능 코드 폐기 — 재고가 1 준다. 배정된 코드는 409 `CODE_NOT_AVAILABLE` */
561
- voidCode: (productId: string, codeId: string) =>
562
- storeHttp.request(
563
- "POST",
564
- path`/products/${productId}/codes/${codeId}/void`,
565
- fulfillmentCodeSchema,
566
- ),
567
- /**
568
- * 판매 파일 연결 (이슈 #48) — `uploads.create({ purpose: "digital-asset" })`로 받은 `key`에 파일을 올린 뒤 연결한다.
569
- * 이후 주문부터 이 파일을 준다. 에러: 400 `INVALID_ASSET_KEY`, 409 `NOT_DOWNLOAD_PRODUCT`·`ASSET_ALREADY_ATTACHED`
570
- */
571
- attachDigitalAsset: (productId: string, body: DigitalAssetAttachRequest) =>
572
- storeHttp.request("POST", path`/products/${productId}/digital-assets`, digitalAssetSchema, {
573
- body: digitalAssetAttachRequestSchema.parse(body),
574
- }),
575
- /** 판매 파일 목록 — 해제한 파일도 싣는다. 객체 키·주소는 없다 */
576
- listDigitalAssets: (productId: string) =>
577
- storeHttp.request(
578
- "GET",
579
- path`/products/${productId}/digital-assets`,
580
- z.array(digitalAssetSchema),
581
- ),
582
- /** 판매 파일 해제 — 새 주문에 주지 않는다. 이미 산 구매자는 계속 받는다 */
583
- removeDigitalAsset: (productId: string, assetId: string) =>
584
- storeHttp.request(
585
- "DELETE",
586
- path`/products/${productId}/digital-assets/${assetId}`,
587
- digitalAssetSchema,
588
- ),
589
- /** 판매 파일 확인 주소 — 수명 300초의 서명 주소 */
590
- previewDigitalAsset: (productId: string, assetId: string) =>
591
- storeHttp.request(
592
- "POST",
593
- path`/products/${productId}/digital-assets/${assetId}/preview-url`,
594
- digitalAssetPreviewSchema,
595
- ),
596
- },
597
-
598
- fulfillmentCodes: {
599
- /**
600
- * 코드 평문 열람 — 콘솔에서 로그인한 OWNER·ADMIN만 된다(403 `INSUFFICIENT_ROLE`). 열람 기록과 감사 로그가 남는다.
601
- * 평문은 화면에 보인 뒤 저장하지 않는다
602
- */
603
- reveal: (codeId: string) =>
604
- storeHttp.request(
605
- "POST",
606
- path`/fulfillment-codes/${codeId}/reveal`,
607
- fulfillmentCodeRevealSchema,
608
- ),
609
572
  },
610
573
 
611
574
  categories: {
@@ -732,17 +695,7 @@ export function createStoreClient(options: StoreClientOptions) {
732
695
  headers: idempotency(idempotencyKey),
733
696
  }),
734
697
  /**
735
- * 제공 안내 메일 재발송 (이슈 #48) — 제공된 주문상품의 안내 메일을 다시 보낸다. 주문상품당 하루 3회(429).
736
- * 코드·파일 주소는 메일에 없다
737
- */
738
- resendFulfillmentMail: (orderItemId: string) =>
739
- storeHttp.request(
740
- "POST",
741
- path`/order-items/${orderItemId}/fulfillment/mail`,
742
- fulfillmentMailResendSchema,
743
- ),
744
- /**
745
- * 제공 처리 (이슈 #48) — 수동 제공 비실물 주문상품(이용권·방문 수령)을 `PAID`·`CONFIRMED`에서 제공 완료(`DELIVERED`)로
698
+ * 제공 처리 (이슈 #48) — 배송 없는 주문상품(`MANUAL`)을 `PAID`·`CONFIRMED`에서 제공 완료(`DELIVERED`)로
746
699
  * 바꾼다. `note`는 구매자 주문 상세에 이용 안내로 실린다. 배송 상품은 409 `SHIPPING_REQUIRED`
747
700
  */
748
701
  fulfill: (orderItemId: string, body: FulfillRequest = {}, idempotencyKey?: string) =>
@@ -1329,6 +1282,179 @@ export function createStoreClient(options: StoreClientOptions) {
1329
1282
  storeHttp.requestVoid("POST", path`/seller-addresses/${addressId}/default`),
1330
1283
  },
1331
1284
 
1285
+ /**
1286
+ * 스토어프론트 호스팅 (이슈 #53) — 조회 `storefront:r`, 쓰기 `storefront:rw`(OWNER·ADMIN).
1287
+ * 쓰기 응답은 바뀐 사이트다. Cloudflare 반영은 커밋 뒤라 `provisioning.status`가 잠시 `PENDING`일 수 있다.
1288
+ * 에이전트 토큰의 발행·되돌리기·템플릿 변경·공개 전환·슬러그 변경·끄기는 승인 대기(`ApprovalPendingError`)다.
1289
+ */
1290
+ storefront: {
1291
+ /** `GET /v1/storefront/templates` — 템플릿 카탈로그 */
1292
+ listTemplates: () =>
1293
+ storeHttp.request("GET", "/storefront/templates", z.array(storefrontTemplateSchema)),
1294
+ /** `GET /v1/storefront/site` — 스위치 상태와 현재 사이트(없으면 `site: null`) */
1295
+ get: () => storeHttp.request("GET", "/storefront/site", storefrontHostingSchema),
1296
+ /** `GET /v1/storefront/slug-availability?slug=` — 슬러그를 쓸 수 있는가 */
1297
+ checkSlug: (slug: string) =>
1298
+ storeHttp.request(
1299
+ "GET",
1300
+ "/storefront/slug-availability",
1301
+ storefrontSlugAvailabilitySchema,
1302
+ {
1303
+ query: { slug },
1304
+ },
1305
+ ),
1306
+ /** `POST /v1/storefront/site` (201) — 템플릿으로 사이트를 만들고 v1을 발행한다. 공개 상태는 오픈 준비 중이다 */
1307
+ create: (body: CreateStorefrontSiteRequest) =>
1308
+ storeHttp.request("POST", "/storefront/site", storefrontSiteSchema, {
1309
+ body: createStorefrontSiteRequestSchema.parse(body),
1310
+ }),
1311
+ /** `POST /v1/storefront/site/template` — 템플릿을 바꾼다. 새 버전을 만들고 기본으로 곧바로 발행한다 */
1312
+ changeTemplate: (body: ChangeStorefrontTemplateRequest) =>
1313
+ storeHttp.request("POST", "/storefront/site/template", storefrontSiteSchema, {
1314
+ body: changeStorefrontTemplateRequestSchema.parse(body),
1315
+ }),
1316
+ /** `GET /v1/storefront/site/versions` — 버전 목록(최신 먼저) */
1317
+ listVersions: () =>
1318
+ storeHttp.request("GET", "/storefront/site/versions", z.array(storefrontVersionSchema)),
1319
+ /** `POST /v1/storefront/site/versions/{versionId}/publish` — 그 버전을 발행한다(이미 발행돼 있으면 그대로 200) */
1320
+ publish: (versionId: string, body: PublishStorefrontVersionRequest = {}) =>
1321
+ storeHttp.request(
1322
+ "POST",
1323
+ path`/storefront/site/versions/${versionId}/publish`,
1324
+ storefrontSiteSchema,
1325
+ { body: publishStorefrontVersionRequestSchema.parse(body) },
1326
+ ),
1327
+ /** `POST /v1/storefront/site/rollback` — 이전 발행 버전으로 되돌린다(재빌드 없음) */
1328
+ rollback: (body: RollbackStorefrontRequest = {}) =>
1329
+ storeHttp.request("POST", "/storefront/site/rollback", storefrontSiteSchema, {
1330
+ body: rollbackStorefrontRequestSchema.parse(body),
1331
+ }),
1332
+ /** `PUT /v1/storefront/site/slug` — 슬러그를 바꾼다. 옛 슬러그는 90일 보류되고 새 주소로 301한다 */
1333
+ changeSlug: (body: ChangeStorefrontSlugRequest) =>
1334
+ storeHttp.request("PUT", "/storefront/site/slug", storefrontSiteSchema, {
1335
+ body: changeStorefrontSlugRequestSchema.parse(body),
1336
+ }),
1337
+ /** `PUT /v1/storefront/site/visibility` — 오픈 준비 중 ↔ 공개 */
1338
+ setVisibility: (body: SetStorefrontVisibilityRequest) =>
1339
+ storeHttp.request("PUT", "/storefront/site/visibility", storefrontSiteSchema, {
1340
+ body: setStorefrontVisibilityRequestSchema.parse(body),
1341
+ }),
1342
+ /**
1343
+ * `POST /v1/storefront/site/preview-link` — 오픈 준비 중인 사이트를 구성원이 볼 수 있는 5분짜리 링크.
1344
+ * 콘솔에서 로그인한 OWNER·ADMIN만 받는다
1345
+ */
1346
+ createPreviewLink: (body: CreateStorefrontPreviewLinkRequest = {}) =>
1347
+ storeHttp.request("POST", "/storefront/site/preview-link", storefrontPreviewLinkSchema, {
1348
+ body: createStorefrontPreviewLinkRequestSchema.parse(body),
1349
+ }),
1350
+ /** `POST /v1/storefront/site/disable` — 호스팅을 끈다(사이트 `CLOSED`, 슬러그 90일 보류). 다시 만들 수 있다 */
1351
+ disable: (body: DisableStorefrontHostingRequest) =>
1352
+ storeHttp.request("POST", "/storefront/site/disable", storefrontSiteSchema, {
1353
+ body: disableStorefrontHostingRequestSchema.parse(body),
1354
+ }),
1355
+
1356
+ // ─── 편집 (M2b) — 조회 `storefront:r`, 쓰기 `storefront:rw`. 에이전트도 승인 없이 된다 ───
1357
+
1358
+ /** `GET /v1/storefront/site/editing` — 편집 환경 상태(열린 환경·동시 상한·미리보기 인증서) */
1359
+ getEditing: () =>
1360
+ storeHttp.request("GET", "/storefront/site/editing", storefrontEditingSchema),
1361
+ /**
1362
+ * `POST /v1/storefront/site/editing` — 편집 환경을 연다(이미 열려 있으면 그대로). 플랫폼 동시 상한에 걸리면 409
1363
+ * `EDIT_CAPACITY_FULL`(`details.retryAfterSeconds`). 띄우는 데 보통 30초가 걸린다(`session.status: STARTING`)
1364
+ */
1365
+ startEditing: () =>
1366
+ storeHttp.request("POST", "/storefront/site/editing", storefrontEditingSchema, {
1367
+ body: {},
1368
+ }),
1369
+ /** `DELETE /v1/storefront/site/editing` — 편집 환경을 닫는다(작업 트리는 보존된다) */
1370
+ stopEditing: () =>
1371
+ storeHttp.request("DELETE", "/storefront/site/editing", storefrontEditingSchema),
1372
+ /**
1373
+ * `POST /v1/storefront/site/editing/preview-link` — 편집 미리보기(dev 서버) 5분짜리 링크.
1374
+ * 콘솔에서 로그인한 OWNER·ADMIN만 받는다(에이전트 불가)
1375
+ */
1376
+ createEditPreviewLink: (body: CreateStorefrontEditPreviewLinkRequest = {}) =>
1377
+ storeHttp.request(
1378
+ "POST",
1379
+ "/storefront/site/editing/preview-link",
1380
+ storefrontPreviewLinkSchema,
1381
+ { body: createStorefrontEditPreviewLinkRequestSchema.parse(body) },
1382
+ ),
1383
+ /** `GET /v1/storefront/site/files?prefix=` — 작업 트리 파일 목록 */
1384
+ listFiles: (params: { prefix?: string } = {}) =>
1385
+ storeHttp.request("GET", "/storefront/site/files", storefrontFileListSchema, {
1386
+ query: params as Query,
1387
+ }),
1388
+ /** `GET /v1/storefront/site/files/content?path=` — 파일 하나 읽기 */
1389
+ readFile: (filePath: string) =>
1390
+ storeHttp.request("GET", "/storefront/site/files/content", storefrontFileContentSchema, {
1391
+ query: { path: filePath },
1392
+ }),
1393
+ /**
1394
+ * `POST /v1/storefront/site/files/batch` — 여러 파일 쓰기(해시 조건). 조건이 하나라도 어긋나면 아무것도 쓰지 않고 409
1395
+ * `FILE_CHANGED`(`details.conflicts`). 편집 환경이 없으면 연다
1396
+ */
1397
+ writeFiles: (body: WriteStorefrontFilesRequest) =>
1398
+ storeHttp.request("POST", "/storefront/site/files/batch", storefrontFileWriteResultSchema, {
1399
+ body: writeStorefrontFilesRequestSchema.parse(body),
1400
+ }),
1401
+ /** `POST /v1/storefront/site/files/delete` */
1402
+ deleteFile: (body: DeleteStorefrontFileRequest) =>
1403
+ storeHttp.request(
1404
+ "POST",
1405
+ "/storefront/site/files/delete",
1406
+ storefrontFileDeleteResultSchema,
1407
+ {
1408
+ body: deleteStorefrontFileRequestSchema.parse(body),
1409
+ },
1410
+ ),
1411
+ /** `POST /v1/storefront/site/files/move` */
1412
+ moveFile: (body: MoveStorefrontFileRequest) =>
1413
+ storeHttp.request("POST", "/storefront/site/files/move", storefrontFileMoveResultSchema, {
1414
+ body: moveStorefrontFileRequestSchema.parse(body),
1415
+ }),
1416
+ /** `POST /v1/storefront/site/files/search` — 내용 검색 */
1417
+ searchFiles: (body: SearchStorefrontFilesRequest) =>
1418
+ storeHttp.request(
1419
+ "POST",
1420
+ "/storefront/site/files/search",
1421
+ storefrontFileSearchResultSchema,
1422
+ { body: searchStorefrontFilesRequestSchema.parse(body) },
1423
+ ),
1424
+ /**
1425
+ * `POST /v1/storefront/site/checks` (202) — 타입 검사·lint·test 하나를 시작한다. 결과는 `getCheck`로 끝날 때까지 조회한다
1426
+ * (`STOREFRONT_CHECK_TERMINAL_STATUSES`)
1427
+ */
1428
+ runCheck: (body: RunStorefrontCheckRequest) =>
1429
+ storeHttp.request("POST", "/storefront/site/checks", storefrontCheckSchema, {
1430
+ body: runStorefrontCheckRequestSchema.parse(body),
1431
+ }),
1432
+ /** `GET /v1/storefront/site/checks/{checkId}` — 검사 상태·종료 코드·출력 꼬리 */
1433
+ getCheck: (checkId: string) =>
1434
+ storeHttp.request("GET", path`/storefront/site/checks/${checkId}`, storefrontCheckSchema),
1435
+ /** `POST /v1/storefront/site/verify` — 작업 트리 규칙 검증(`verify_storefront`와 같은 보고서) */
1436
+ verify: () =>
1437
+ storeHttp.request("POST", "/storefront/site/verify", storefrontVerifyReportSchema, {
1438
+ body: {},
1439
+ }),
1440
+ /**
1441
+ * `POST /v1/storefront/site/versions` (201) — 지금 작업 트리로 버전을 만든다(빌드 시작). 버전은 `BUILDING`, 빌드가
1442
+ * 끝나면 `READY` 또는 `FAILED`다
1443
+ */
1444
+ createVersion: (body: CreateStorefrontVersionRequest = {}) =>
1445
+ storeHttp.request("POST", "/storefront/site/versions", storefrontVersionCreatedSchema, {
1446
+ body: createStorefrontVersionRequestSchema.parse(body),
1447
+ }),
1448
+ /** `GET /v1/storefront/site/builds?limit=` — 빌드 목록(최신 먼저) */
1449
+ listBuilds: (params: { limit?: number } = {}) =>
1450
+ storeHttp.request("GET", "/storefront/site/builds", z.array(storefrontBuildSchema), {
1451
+ query: params as Query,
1452
+ }),
1453
+ /** `GET /v1/storefront/site/builds/{buildId}` — 빌드 상태·실패 단계·로그 꼬리·규칙 결과 */
1454
+ getBuild: (buildId: string) =>
1455
+ storeHttp.request("GET", path`/storefront/site/builds/${buildId}`, storefrontBuildSchema),
1456
+ },
1457
+
1332
1458
  store: {
1333
1459
  get: () => storeHttp.request("GET", "/store", storeSchema),
1334
1460
  /**
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";
@@ -40,6 +38,7 @@ export * from "./schemas/refund-policy";
40
38
  export * from "./schemas/scope";
41
39
  export * from "./schemas/shipping-policy";
42
40
  export * from "./schemas/store";
41
+ export * from "./schemas/storefront-hosting";
43
42
  export * from "./schemas/telemetry";
44
43
  export * from "./schemas/upload";
45
44
  export * from "./schemas/webhook-event";
@@ -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(),