@sayren/store-sdk 0.19.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/dist/index.d.mts +1070 -1237
- package/dist/index.mjs +482 -498
- package/package.json +1 -1
- package/src/client.ts +128 -98
- package/src/index.ts +0 -2
- package/src/schemas/claim.ts +1 -1
- package/src/schemas/fulfillment.ts +26 -275
- package/src/schemas/misc.ts +1 -1
- package/src/schemas/order.ts +10 -61
- package/src/schemas/store.ts +2 -30
- package/src/schemas/storefront-hosting.ts +561 -3
- package/src/schemas/upload.ts +2 -48
- package/src/schemas/webhook-event.ts +9 -13
- package/src/schemas/digital-asset.ts +0 -65
- package/src/schemas/fulfillment-code.ts +0 -143
package/package.json
CHANGED
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,
|
|
@@ -239,26 +223,51 @@ import {
|
|
|
239
223
|
import {
|
|
240
224
|
type ChangeStorefrontSlugRequest,
|
|
241
225
|
type ChangeStorefrontTemplateRequest,
|
|
226
|
+
type CreateStorefrontEditPreviewLinkRequest,
|
|
242
227
|
type CreateStorefrontPreviewLinkRequest,
|
|
243
228
|
type CreateStorefrontSiteRequest,
|
|
229
|
+
type CreateStorefrontVersionRequest,
|
|
244
230
|
changeStorefrontSlugRequestSchema,
|
|
245
231
|
changeStorefrontTemplateRequestSchema,
|
|
232
|
+
createStorefrontEditPreviewLinkRequestSchema,
|
|
246
233
|
createStorefrontPreviewLinkRequestSchema,
|
|
247
234
|
createStorefrontSiteRequestSchema,
|
|
235
|
+
createStorefrontVersionRequestSchema,
|
|
236
|
+
type DeleteStorefrontFileRequest,
|
|
248
237
|
type DisableStorefrontHostingRequest,
|
|
238
|
+
deleteStorefrontFileRequestSchema,
|
|
249
239
|
disableStorefrontHostingRequestSchema,
|
|
240
|
+
type MoveStorefrontFileRequest,
|
|
241
|
+
moveStorefrontFileRequestSchema,
|
|
250
242
|
type PublishStorefrontVersionRequest,
|
|
251
243
|
publishStorefrontVersionRequestSchema,
|
|
252
244
|
type RollbackStorefrontRequest,
|
|
245
|
+
type RunStorefrontCheckRequest,
|
|
253
246
|
rollbackStorefrontRequestSchema,
|
|
247
|
+
runStorefrontCheckRequestSchema,
|
|
248
|
+
type SearchStorefrontFilesRequest,
|
|
254
249
|
type SetStorefrontVisibilityRequest,
|
|
250
|
+
searchStorefrontFilesRequestSchema,
|
|
255
251
|
setStorefrontVisibilityRequestSchema,
|
|
252
|
+
storefrontBuildSchema,
|
|
253
|
+
storefrontCheckSchema,
|
|
254
|
+
storefrontEditingSchema,
|
|
255
|
+
storefrontFileContentSchema,
|
|
256
|
+
storefrontFileDeleteResultSchema,
|
|
257
|
+
storefrontFileListSchema,
|
|
258
|
+
storefrontFileMoveResultSchema,
|
|
259
|
+
storefrontFileSearchResultSchema,
|
|
260
|
+
storefrontFileWriteResultSchema,
|
|
256
261
|
storefrontHostingSchema,
|
|
257
262
|
storefrontPreviewLinkSchema,
|
|
258
263
|
storefrontSiteSchema,
|
|
259
264
|
storefrontSlugAvailabilitySchema,
|
|
260
265
|
storefrontTemplateSchema,
|
|
266
|
+
storefrontVerifyReportSchema,
|
|
267
|
+
storefrontVersionCreatedSchema,
|
|
261
268
|
storefrontVersionSchema,
|
|
269
|
+
type WriteStorefrontFilesRequest,
|
|
270
|
+
writeStorefrontFilesRequestSchema,
|
|
262
271
|
} from "./schemas/storefront-hosting";
|
|
263
272
|
import {
|
|
264
273
|
type UploadPurpose,
|
|
@@ -497,7 +506,7 @@ export function createStoreClient(options: StoreClientOptions) {
|
|
|
497
506
|
const put = await fetchFn(ticket.uploadUrl, {
|
|
498
507
|
method: "PUT",
|
|
499
508
|
// 발급 응답의 헤더를 함께 싣는다 — 판매 파일(이슈 #48)은 비공개 헤더가 빠지면 공개 객체가 된다
|
|
500
|
-
headers: {
|
|
509
|
+
headers: { "content-type": file.type || "application/octet-stream" },
|
|
501
510
|
body: file,
|
|
502
511
|
});
|
|
503
512
|
if (!put.ok) {
|
|
@@ -560,76 +569,6 @@ export function createStoreClient(options: StoreClientOptions) {
|
|
|
560
569
|
}),
|
|
561
570
|
removeDiscount: (productId: string) =>
|
|
562
571
|
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
|
-
},
|
|
621
|
-
|
|
622
|
-
fulfillmentCodes: {
|
|
623
|
-
/**
|
|
624
|
-
* 코드 평문 열람 — 콘솔에서 로그인한 OWNER·ADMIN만 된다(403 `INSUFFICIENT_ROLE`). 열람 기록과 감사 로그가 남는다.
|
|
625
|
-
* 평문은 화면에 보인 뒤 저장하지 않는다
|
|
626
|
-
*/
|
|
627
|
-
reveal: (codeId: string) =>
|
|
628
|
-
storeHttp.request(
|
|
629
|
-
"POST",
|
|
630
|
-
path`/fulfillment-codes/${codeId}/reveal`,
|
|
631
|
-
fulfillmentCodeRevealSchema,
|
|
632
|
-
),
|
|
633
572
|
},
|
|
634
573
|
|
|
635
574
|
categories: {
|
|
@@ -756,17 +695,7 @@ export function createStoreClient(options: StoreClientOptions) {
|
|
|
756
695
|
headers: idempotency(idempotencyKey),
|
|
757
696
|
}),
|
|
758
697
|
/**
|
|
759
|
-
* 제공
|
|
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`)로
|
|
698
|
+
* 제공 처리 (이슈 #48) — 배송 없는 주문상품(`MANUAL`)을 `PAID`·`CONFIRMED`에서 제공 완료(`DELIVERED`)로
|
|
770
699
|
* 바꾼다. `note`는 구매자 주문 상세에 이용 안내로 실린다. 배송 상품은 409 `SHIPPING_REQUIRED`
|
|
771
700
|
*/
|
|
772
701
|
fulfill: (orderItemId: string, body: FulfillRequest = {}, idempotencyKey?: string) =>
|
|
@@ -1423,6 +1352,107 @@ export function createStoreClient(options: StoreClientOptions) {
|
|
|
1423
1352
|
storeHttp.request("POST", "/storefront/site/disable", storefrontSiteSchema, {
|
|
1424
1353
|
body: disableStorefrontHostingRequestSchema.parse(body),
|
|
1425
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),
|
|
1426
1456
|
},
|
|
1427
1457
|
|
|
1428
1458
|
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";
|
package/src/schemas/claim.ts
CHANGED
|
@@ -90,7 +90,7 @@ export const claimSchema = z.object({
|
|
|
90
90
|
.optional()
|
|
91
91
|
.default("SHIPPING")
|
|
92
92
|
.describe(
|
|
93
|
-
"클레임 대상 주문상품의 상품 유형(이슈 #48).
|
|
93
|
+
"클레임 대상 주문상품의 상품 유형(이슈 #48). 배송 없는 상품(`MANUAL`) 반품은 수거 등록 없이 " +
|
|
94
94
|
"접수·보류에서 바로 승인한다. 값이 추가될 수 있어 문자열로 받는다. 서버는 항상 싣는다",
|
|
95
95
|
),
|
|
96
96
|
requestedAt: z.string(),
|