@sayren/store-sdk 0.2.0 → 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.
- package/dist/index.d.mts +34 -0
- package/dist/index.mjs +28 -1
- package/package.json +1 -1
- package/src/client.ts +10 -0
- package/src/schemas/store.ts +53 -0
package/dist/index.d.mts
CHANGED
|
@@ -3320,6 +3320,21 @@ export declare const STORE_CODE_PATTERN: RegExp;
|
|
|
3320
3320
|
export declare const RESERVED_STORE_CODES: readonly string[];
|
|
3321
3321
|
export declare function isReservedStoreCode(code: string): boolean;
|
|
3322
3322
|
export declare const storeCodeSchema: z.ZodString;
|
|
3323
|
+
/** `https://shop.example.com`처럼 경로·쿼리 없는 http(s) 오리진인가 */
|
|
3324
|
+
export declare function isWebOrigin(value: string): boolean;
|
|
3325
|
+
/** 방문 분석을 보낼 수 있는 스토어프런트 오리진 — 스킴·호스트(·포트)만. 서버가 소문자·끝 슬래시 제거로 정규화한다 */
|
|
3326
|
+
export declare const analyticsOriginSchema: z.ZodString;
|
|
3327
|
+
/** 허용 오리진 상한 */
|
|
3328
|
+
export declare const MAX_ANALYTICS_ALLOWED_ORIGINS = 20;
|
|
3329
|
+
/** `PATCH /v1/store` 본문 — 바꿀 필드만 보낸다 */
|
|
3330
|
+
export declare const updateStoreRequestSchema: z.ZodObject<{
|
|
3331
|
+
name: z.ZodOptional<z.ZodString>;
|
|
3332
|
+
logoUrl: z.ZodOptional<z.ZodURL>;
|
|
3333
|
+
customerCenterPhone: z.ZodOptional<z.ZodString>;
|
|
3334
|
+
businessHours: z.ZodOptional<z.ZodString>;
|
|
3335
|
+
analyticsAllowedOrigins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3336
|
+
}, z.core.$strip>;
|
|
3337
|
+
export type UpdateStoreRequest = z.infer<typeof updateStoreRequestSchema>;
|
|
3323
3338
|
export declare const storeSchema: z.ZodObject<{
|
|
3324
3339
|
storeId: z.ZodString;
|
|
3325
3340
|
name: z.ZodString;
|
|
@@ -3333,6 +3348,7 @@ export declare const storeSchema: z.ZodObject<{
|
|
|
3333
3348
|
logoUrl: z.ZodNullable<z.ZodURL>;
|
|
3334
3349
|
businessNumber: z.ZodNullable<z.ZodString>;
|
|
3335
3350
|
customerCenterPhone: z.ZodNullable<z.ZodString>;
|
|
3351
|
+
analyticsAllowedOrigins: z.ZodArray<z.ZodString>;
|
|
3336
3352
|
memberCount: z.ZodNumber;
|
|
3337
3353
|
createdAt: z.ZodString;
|
|
3338
3354
|
}, z.core.$strip>;
|
|
@@ -5706,6 +5722,24 @@ export declare function createStoreClient(options: StoreClientOptions): {
|
|
|
5706
5722
|
logoUrl: string | null;
|
|
5707
5723
|
businessNumber: string | null;
|
|
5708
5724
|
customerCenterPhone: string | null;
|
|
5725
|
+
analyticsAllowedOrigins: string[];
|
|
5726
|
+
memberCount: number;
|
|
5727
|
+
createdAt: string;
|
|
5728
|
+
}>;
|
|
5729
|
+
/**
|
|
5730
|
+
* `PATCH /v1/store` — 스코프 `store:rw`. 바꿀 필드만 보낸다. `analyticsAllowedOrigins`는 방문 분석 수집을 받을
|
|
5731
|
+
* 스토어프런트 오리진 목록이다(빈 배열이면 모든 오리진 허용).
|
|
5732
|
+
*/
|
|
5733
|
+
update: (body: UpdateStoreRequest) => Promise<{
|
|
5734
|
+
storeId: string;
|
|
5735
|
+
name: string;
|
|
5736
|
+
storeCode: string;
|
|
5737
|
+
storefrontUrl: string;
|
|
5738
|
+
status: "ACTIVE" | "SUSPENDED" | "CLOSED";
|
|
5739
|
+
logoUrl: string | null;
|
|
5740
|
+
businessNumber: string | null;
|
|
5741
|
+
customerCenterPhone: string | null;
|
|
5742
|
+
analyticsAllowedOrigins: string[];
|
|
5709
5743
|
memberCount: number;
|
|
5710
5744
|
createdAt: string;
|
|
5711
5745
|
}>;
|
package/dist/index.mjs
CHANGED
|
@@ -1710,6 +1710,27 @@ function isReservedStoreCode(code) {
|
|
|
1710
1710
|
return RESERVED_STORE_CODES.includes(code.toLowerCase());
|
|
1711
1711
|
}
|
|
1712
1712
|
const storeCodeSchema = z.string().regex(STORE_CODE_PATTERN, "소문자·숫자·하이픈 3~30자여야 하고 하이픈으로 시작하거나 끝날 수 없어요").refine((code) => !isReservedStoreCode(code), "플랫폼이 쓰는 이름이라 스토어 코드로 쓸 수 없어요");
|
|
1713
|
+
/** `https://shop.example.com`처럼 경로·쿼리 없는 http(s) 오리진인가 */
|
|
1714
|
+
function isWebOrigin(value) {
|
|
1715
|
+
try {
|
|
1716
|
+
const url = new URL(value);
|
|
1717
|
+
return (url.protocol === "https:" || url.protocol === "http:") && !url.username && !url.password && url.pathname === "/" && !url.search && !url.hash && !value.includes("*");
|
|
1718
|
+
} catch {
|
|
1719
|
+
return false;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
/** 방문 분석을 보낼 수 있는 스토어프런트 오리진 — 스킴·호스트(·포트)만. 서버가 소문자·끝 슬래시 제거로 정규화한다 */
|
|
1723
|
+
const analyticsOriginSchema = z.string().trim().max(255).refine(isWebOrigin, "https://shop.example.com 형식(경로 없이)으로 입력해 주세요").describe("스토어프런트 오리진. 예: `https://shop.example.com`");
|
|
1724
|
+
/** 허용 오리진 상한 */
|
|
1725
|
+
const MAX_ANALYTICS_ALLOWED_ORIGINS = 20;
|
|
1726
|
+
/** `PATCH /v1/store` 본문 — 바꿀 필드만 보낸다 */
|
|
1727
|
+
const updateStoreRequestSchema = z.object({
|
|
1728
|
+
name: z.string().min(2).max(50).optional(),
|
|
1729
|
+
logoUrl: z.url().optional(),
|
|
1730
|
+
customerCenterPhone: z.string().optional(),
|
|
1731
|
+
businessHours: z.string().max(100).optional(),
|
|
1732
|
+
analyticsAllowedOrigins: z.array(analyticsOriginSchema).max(20).optional().describe("방문 분석 수집을 받을 스토어프런트 오리진(최대 20개). 비우면 모든 오리진에서 받는다. 넣으면 목록에 없는 오리진의 수집 요청은 403 `ORIGIN_NOT_ALLOWED`이고, 페이지 URL이 목록 밖인 이벤트는 버린다")
|
|
1733
|
+
}).refine((value) => Object.values(value).some((v) => v !== void 0), { message: "최소 1개 필드가 필요합니다" });
|
|
1713
1734
|
const storeSchema = z.object({
|
|
1714
1735
|
storeId: z.string(),
|
|
1715
1736
|
name: z.string(),
|
|
@@ -1723,6 +1744,7 @@ const storeSchema = z.object({
|
|
|
1723
1744
|
logoUrl: z.url().nullable(),
|
|
1724
1745
|
businessNumber: z.string().nullable(),
|
|
1725
1746
|
customerCenterPhone: z.string().nullable(),
|
|
1747
|
+
analyticsAllowedOrigins: z.array(z.string()).describe("방문 분석 수집을 받는 스토어프런트 오리진. 비어 있으면 모든 오리진에서 받는다"),
|
|
1726
1748
|
memberCount: z.number().int(),
|
|
1727
1749
|
createdAt: z.string()
|
|
1728
1750
|
});
|
|
@@ -2212,6 +2234,11 @@ get: (params) => storeHttp.request("GET", "/sales-report", salesReportSchema, {
|
|
|
2212
2234
|
},
|
|
2213
2235
|
store: {
|
|
2214
2236
|
get: () => storeHttp.request("GET", "/store", storeSchema),
|
|
2237
|
+
/**
|
|
2238
|
+
* `PATCH /v1/store` — 스코프 `store:rw`. 바꿀 필드만 보낸다. `analyticsAllowedOrigins`는 방문 분석 수집을 받을
|
|
2239
|
+
* 스토어프런트 오리진 목록이다(빈 배열이면 모든 오리진 허용).
|
|
2240
|
+
*/
|
|
2241
|
+
update: (body) => storeHttp.request("PATCH", "/store", storeSchema, { body: updateStoreRequestSchema.parse(body) }),
|
|
2215
2242
|
listMembers: () => storeHttp.request("GET", "/store/members", z.array(storeMemberSchema)),
|
|
2216
2243
|
listInvitations: () => storeHttp.request("GET", "/store/invitations", z.array(invitationSchema))
|
|
2217
2244
|
}
|
|
@@ -2594,4 +2621,4 @@ function createStoreSession(options) {
|
|
|
2594
2621
|
};
|
|
2595
2622
|
}
|
|
2596
2623
|
//#endregion
|
|
2597
|
-
export { ApiError, MAX_OPTION_GROUPS, MAX_VALUES_PER_GROUP, MAX_VARIANTS, PAYMENT_ROUTING_EXCLUSION_CODES, PORTONE_CHANNEL_NAME_MAX_LENGTH, PORTONE_MAX_CHANNELS, PORTONE_MIN_CHANNELS, RESERVED_STORE_CODES, STORE_CODE_PATTERN, STORE_ROLE_SCOPES, STORE_SCOPE_RESOURCES, STORE_SESSION_KEYS, TOSS_WIDGET_CLIENT_KEY_PATTERN, TOSS_WIDGET_KEY_MESSAGE, TOSS_WIDGET_SECRET_KEY_PATTERN, VARIANT_STOCK_EXCLUSIVE_MESSAGE, WEBHOOK_DEFAULT_TOLERANCE_SEC, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_EVENT_TYPE_HEADER, WEBHOOK_HEADERS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_USER_AGENT, addressChangeRequestListSchema, addressTypeSchema, analyticsChannelSchema, analyticsFunnelStepSchema, analyticsOverviewSchema, analyticsProductRowSchema, analyticsProductSortSchema, analyticsProductsQuerySchema, analyticsProductsSchema, analyticsRangeQuerySchema, analyticsSourceGroupBySchema, analyticsSourceRowSchema, analyticsSourcesQuerySchema, analyticsSourcesSchema, analyticsTotalsSchema, apiClientListQuerySchema, apiClientSchema, apiClientSecretRotatedSchema, apiClientStatusSchema, apiClientTypeSchema, apiLogErrorSchema, apiLogListQuerySchema, apiLogPageSchema, apiLogPrincipalSchema, apiLogPrincipalTypeSchema, apiLogSchema, apiLogStatusFilterSchema, apiLogSummarySchema, apiTokenCreateRequestSchema, apiTokenCreatedSchema, apiTokenSchema, approveClaimResultSchema, buildAuthorizeUrl, buildQuery, bulkResultSchema, cancelBySellerRequestSchema, cancelBySellerResultSchema, carrierSchema, categoryAttributeSchema, categoryCreateRequestSchema, categoryDeleteQuerySchema, categoryDeleteStrategySchema, categoryListQuerySchema, categoryPatchRequestSchema, categoryProductSortSchema, categorySchema, categorySearchResultSchema, categoryTreeNodeSchema, categoryWithPathSchema, changeTypeSchema, claimDetailSchema, claimHoldResultSchema, claimListQuerySchema, claimReasonSchema, claimSchema, claimStatusSchema, claimTypeSchema, claimWebhookEventDataSchema, claimWebhookEventSchema, clientCredentialsTokenResponseSchema, createPkcePair, createStoreClient, createStoreSession, customerInquiryCategorySchema, customerInquiryListQuerySchema, deliveryInfoSchema, deliveryMethodSchema, deliveryStatusSchema, deliveryTypeSchema, discountRequestSchema, discountSchema, dispatchRequestSchema, effectivePaymentRoutingModeSchema, eventTypeSchema, exchangeAuthorizationCode, exchangeStoreTokenViaOAuth, holdOrderItemRequestSchema, inquiryListQuerySchema, inquirySchema, inquiryWebhookEventDataSchema, inquiryWebhookEventSchema, invitationListQuerySchema, invitationSchema, isReservedStoreCode, isStoreScope, liveGateConditionCodeSchema, liveGateConditionSchema, liveGateErrorDetailsSchema, liveGateSchema, maskedSecretSchema, myAccountSchema, myStoreSchema, oauthClientRegistrationRequestSchema, oauthClientRegistrationResponseSchema, oauthTokenResponseSchema, optionGroupRequestSchema, optionGroupSchema, optionModelRequestSchema, optionModelSchema, optionValueRequestSchema, optionValueSchema, orderItemListQuerySchema, orderItemMemoResultSchema, orderItemPageSchema, orderItemSchema, orderItemStatusSchema, orderListQuerySchema, orderSchema, orderSummaryPageSchema, orderSummarySchema, orderWebhookEventDataSchema, orderWebhookEventSchema, pageInfoSchema, pageQueryShape, pageSchema, paymentAttemptRecordSchema, paymentAttemptStatusSchema, paymentCredentialSetSchema, paymentListQuerySchema, paymentProviderSchema, paymentProviderVerificationSchema, paymentRecordDetailSchema, paymentRecordPageSchema, paymentRecordSchema, paymentRecordStatusSchema, paymentRefundRecordSchema, paymentRoutingModeSchema, paymentSettingsSchema, pgEnvironmentSchema, pgPaymentMethodSchema, pgProviderSchema, pgVerificationResultSchema, portOneChannelSchema, portOneCredentialsInputSchema, productCreateRequestSchema, productImageUploadResultSchema, productListQuerySchema, productOutOfStockWebhookEventDataSchema, productOutOfStockWebhookEventSchema, productPatchRequestSchema, productSchema, productSortSchema, productStatusSchema, productSummarySchema, productVariantRequestSchema, productVariantSchema, purchaseDecisionExtendResultSchema, purchaseDecisionRequestResultSchema, refreshUserToken, rejectClaimRequestSchema, reviewListQuerySchema, reviewReportResultSchema, reviewSchema, reviewSortSchema, reviewWebhookEventDataSchema, reviewWebhookEventSchema, salesReportGroupBySchema, salesReportQuerySchema, salesReportRowSchema, salesReportSchema, salesTotalsSchema, scopeAccessSchema, sellerAddressListQuerySchema, sellerAddressRequestSchema, sellerAddressSchema, sellerCustomerInquirySchema, settlementDetailQuerySchema, settlementDetailSchema, settlementListQuerySchema, settlementStatusSchema, settlementSummarySchema, settlementWithDetailsSchema, shippingAddressSchema, storeCodeSchema, storeMemberRoleUpdatedSchema, storeMemberSchema, storeRoleSchema, storeSchema, storeScopeResourceSchema, storeTokenResponseSchema, tossPaymentsCredentialsInputSchema, trackingUpdateResultSchema, updatePaymentProviderRequestSchema, updatePaymentSettingsRequestSchema, uploadRequestSchema, uploadTicketSchema, upsertPortOneProviderRequestSchema, upsertTossPaymentsProviderRequestSchema, userTokenResponseSchema, variantStockRequestSchema, variantStockSchema, verifyPaymentProviderRequestSchema, webhookCreatedSchema, webhookDeliveryErrorCodeSchema, webhookDeliveryListQuerySchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEventSchema, webhookRedeliverFailedResultSchema, webhookRequestSchema, webhookSchema, webhookSecretRotatedSchema, webhookStatusSchema, webhookTestRequestSchema, webhookTestResultSchema };
|
|
2624
|
+
export { ApiError, MAX_ANALYTICS_ALLOWED_ORIGINS, MAX_OPTION_GROUPS, MAX_VALUES_PER_GROUP, MAX_VARIANTS, PAYMENT_ROUTING_EXCLUSION_CODES, PORTONE_CHANNEL_NAME_MAX_LENGTH, PORTONE_MAX_CHANNELS, PORTONE_MIN_CHANNELS, RESERVED_STORE_CODES, STORE_CODE_PATTERN, STORE_ROLE_SCOPES, STORE_SCOPE_RESOURCES, STORE_SESSION_KEYS, TOSS_WIDGET_CLIENT_KEY_PATTERN, TOSS_WIDGET_KEY_MESSAGE, TOSS_WIDGET_SECRET_KEY_PATTERN, VARIANT_STOCK_EXCLUSIVE_MESSAGE, WEBHOOK_DEFAULT_TOLERANCE_SEC, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_EVENT_TYPE_HEADER, WEBHOOK_HEADERS, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_USER_AGENT, addressChangeRequestListSchema, addressTypeSchema, analyticsChannelSchema, analyticsFunnelStepSchema, analyticsOriginSchema, analyticsOverviewSchema, analyticsProductRowSchema, analyticsProductSortSchema, analyticsProductsQuerySchema, analyticsProductsSchema, analyticsRangeQuerySchema, analyticsSourceGroupBySchema, analyticsSourceRowSchema, analyticsSourcesQuerySchema, analyticsSourcesSchema, analyticsTotalsSchema, apiClientListQuerySchema, apiClientSchema, apiClientSecretRotatedSchema, apiClientStatusSchema, apiClientTypeSchema, apiLogErrorSchema, apiLogListQuerySchema, apiLogPageSchema, apiLogPrincipalSchema, apiLogPrincipalTypeSchema, apiLogSchema, apiLogStatusFilterSchema, apiLogSummarySchema, apiTokenCreateRequestSchema, apiTokenCreatedSchema, apiTokenSchema, approveClaimResultSchema, buildAuthorizeUrl, buildQuery, bulkResultSchema, cancelBySellerRequestSchema, cancelBySellerResultSchema, carrierSchema, categoryAttributeSchema, categoryCreateRequestSchema, categoryDeleteQuerySchema, categoryDeleteStrategySchema, categoryListQuerySchema, categoryPatchRequestSchema, categoryProductSortSchema, categorySchema, categorySearchResultSchema, categoryTreeNodeSchema, categoryWithPathSchema, changeTypeSchema, claimDetailSchema, claimHoldResultSchema, claimListQuerySchema, claimReasonSchema, claimSchema, claimStatusSchema, claimTypeSchema, claimWebhookEventDataSchema, claimWebhookEventSchema, clientCredentialsTokenResponseSchema, createPkcePair, createStoreClient, createStoreSession, customerInquiryCategorySchema, customerInquiryListQuerySchema, deliveryInfoSchema, deliveryMethodSchema, deliveryStatusSchema, deliveryTypeSchema, discountRequestSchema, discountSchema, dispatchRequestSchema, effectivePaymentRoutingModeSchema, eventTypeSchema, exchangeAuthorizationCode, exchangeStoreTokenViaOAuth, holdOrderItemRequestSchema, inquiryListQuerySchema, inquirySchema, inquiryWebhookEventDataSchema, inquiryWebhookEventSchema, invitationListQuerySchema, invitationSchema, isReservedStoreCode, isStoreScope, isWebOrigin, liveGateConditionCodeSchema, liveGateConditionSchema, liveGateErrorDetailsSchema, liveGateSchema, maskedSecretSchema, myAccountSchema, myStoreSchema, oauthClientRegistrationRequestSchema, oauthClientRegistrationResponseSchema, oauthTokenResponseSchema, optionGroupRequestSchema, optionGroupSchema, optionModelRequestSchema, optionModelSchema, optionValueRequestSchema, optionValueSchema, orderItemListQuerySchema, orderItemMemoResultSchema, orderItemPageSchema, orderItemSchema, orderItemStatusSchema, orderListQuerySchema, orderSchema, orderSummaryPageSchema, orderSummarySchema, orderWebhookEventDataSchema, orderWebhookEventSchema, pageInfoSchema, pageQueryShape, pageSchema, paymentAttemptRecordSchema, paymentAttemptStatusSchema, paymentCredentialSetSchema, paymentListQuerySchema, paymentProviderSchema, paymentProviderVerificationSchema, paymentRecordDetailSchema, paymentRecordPageSchema, paymentRecordSchema, paymentRecordStatusSchema, paymentRefundRecordSchema, paymentRoutingModeSchema, paymentSettingsSchema, pgEnvironmentSchema, pgPaymentMethodSchema, pgProviderSchema, pgVerificationResultSchema, portOneChannelSchema, portOneCredentialsInputSchema, productCreateRequestSchema, productImageUploadResultSchema, productListQuerySchema, productOutOfStockWebhookEventDataSchema, productOutOfStockWebhookEventSchema, productPatchRequestSchema, productSchema, productSortSchema, productStatusSchema, productSummarySchema, productVariantRequestSchema, productVariantSchema, purchaseDecisionExtendResultSchema, purchaseDecisionRequestResultSchema, refreshUserToken, rejectClaimRequestSchema, reviewListQuerySchema, reviewReportResultSchema, reviewSchema, reviewSortSchema, reviewWebhookEventDataSchema, reviewWebhookEventSchema, salesReportGroupBySchema, salesReportQuerySchema, salesReportRowSchema, salesReportSchema, salesTotalsSchema, scopeAccessSchema, sellerAddressListQuerySchema, sellerAddressRequestSchema, sellerAddressSchema, sellerCustomerInquirySchema, settlementDetailQuerySchema, settlementDetailSchema, settlementListQuerySchema, settlementStatusSchema, settlementSummarySchema, settlementWithDetailsSchema, shippingAddressSchema, storeCodeSchema, storeMemberRoleUpdatedSchema, storeMemberSchema, storeRoleSchema, storeSchema, storeScopeResourceSchema, storeTokenResponseSchema, tossPaymentsCredentialsInputSchema, trackingUpdateResultSchema, updatePaymentProviderRequestSchema, updatePaymentSettingsRequestSchema, updateStoreRequestSchema, uploadRequestSchema, uploadTicketSchema, upsertPortOneProviderRequestSchema, upsertTossPaymentsProviderRequestSchema, userTokenResponseSchema, variantStockRequestSchema, variantStockSchema, verifyPaymentProviderRequestSchema, webhookCreatedSchema, webhookDeliveryErrorCodeSchema, webhookDeliveryListQuerySchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEventSchema, webhookRedeliverFailedResultSchema, webhookRequestSchema, webhookSchema, webhookSecretRotatedSchema, webhookStatusSchema, webhookTestRequestSchema, webhookTestResultSchema };
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -144,6 +144,8 @@ import {
|
|
|
144
144
|
sellerAddressSchema,
|
|
145
145
|
storeMemberSchema,
|
|
146
146
|
storeSchema,
|
|
147
|
+
type UpdateStoreRequest,
|
|
148
|
+
updateStoreRequestSchema,
|
|
147
149
|
} from "./schemas/store";
|
|
148
150
|
import { type UploadRequest, uploadRequestSchema, uploadTicketSchema } from "./schemas/upload";
|
|
149
151
|
import type { AuthorizeOptions, StoreSession } from "./session";
|
|
@@ -869,6 +871,14 @@ export function createStoreClient(options: StoreClientOptions) {
|
|
|
869
871
|
|
|
870
872
|
store: {
|
|
871
873
|
get: () => storeHttp.request("GET", "/store", storeSchema),
|
|
874
|
+
/**
|
|
875
|
+
* `PATCH /v1/store` — 스코프 `store:rw`. 바꿀 필드만 보낸다. `analyticsAllowedOrigins`는 방문 분석 수집을 받을
|
|
876
|
+
* 스토어프런트 오리진 목록이다(빈 배열이면 모든 오리진 허용).
|
|
877
|
+
*/
|
|
878
|
+
update: (body: UpdateStoreRequest) =>
|
|
879
|
+
storeHttp.request("PATCH", "/store", storeSchema, {
|
|
880
|
+
body: updateStoreRequestSchema.parse(body),
|
|
881
|
+
}),
|
|
872
882
|
listMembers: () => storeHttp.request("GET", "/store/members", z.array(storeMemberSchema)),
|
|
873
883
|
listInvitations: () =>
|
|
874
884
|
storeHttp.request("GET", "/store/invitations", z.array(invitationSchema)),
|
package/src/schemas/store.ts
CHANGED
|
@@ -73,6 +73,56 @@ export const storeCodeSchema = z
|
|
|
73
73
|
"플랫폼이 쓰는 이름이라 스토어 코드로 쓸 수 없어요",
|
|
74
74
|
);
|
|
75
75
|
|
|
76
|
+
/** `https://shop.example.com`처럼 경로·쿼리 없는 http(s) 오리진인가 */
|
|
77
|
+
export function isWebOrigin(value: string): boolean {
|
|
78
|
+
try {
|
|
79
|
+
const url = new URL(value);
|
|
80
|
+
return (
|
|
81
|
+
(url.protocol === "https:" || url.protocol === "http:") &&
|
|
82
|
+
!url.username &&
|
|
83
|
+
!url.password &&
|
|
84
|
+
url.pathname === "/" &&
|
|
85
|
+
!url.search &&
|
|
86
|
+
!url.hash &&
|
|
87
|
+
!value.includes("*")
|
|
88
|
+
);
|
|
89
|
+
} catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** 방문 분석을 보낼 수 있는 스토어프런트 오리진 — 스킴·호스트(·포트)만. 서버가 소문자·끝 슬래시 제거로 정규화한다 */
|
|
95
|
+
export const analyticsOriginSchema = z
|
|
96
|
+
.string()
|
|
97
|
+
.trim()
|
|
98
|
+
.max(255)
|
|
99
|
+
.refine(isWebOrigin, "https://shop.example.com 형식(경로 없이)으로 입력해 주세요")
|
|
100
|
+
.describe("스토어프런트 오리진. 예: `https://shop.example.com`");
|
|
101
|
+
|
|
102
|
+
/** 허용 오리진 상한 */
|
|
103
|
+
export const MAX_ANALYTICS_ALLOWED_ORIGINS = 20;
|
|
104
|
+
|
|
105
|
+
/** `PATCH /v1/store` 본문 — 바꿀 필드만 보낸다 */
|
|
106
|
+
export const updateStoreRequestSchema = z
|
|
107
|
+
.object({
|
|
108
|
+
name: z.string().min(2).max(50).optional(),
|
|
109
|
+
logoUrl: z.url().optional(),
|
|
110
|
+
customerCenterPhone: z.string().optional(),
|
|
111
|
+
businessHours: z.string().max(100).optional(),
|
|
112
|
+
analyticsAllowedOrigins: z
|
|
113
|
+
.array(analyticsOriginSchema)
|
|
114
|
+
.max(MAX_ANALYTICS_ALLOWED_ORIGINS)
|
|
115
|
+
.optional()
|
|
116
|
+
.describe(
|
|
117
|
+
"방문 분석 수집을 받을 스토어프런트 오리진(최대 20개). 비우면 모든 오리진에서 받는다. " +
|
|
118
|
+
"넣으면 목록에 없는 오리진의 수집 요청은 403 `ORIGIN_NOT_ALLOWED`이고, 페이지 URL이 목록 밖인 이벤트는 버린다",
|
|
119
|
+
),
|
|
120
|
+
})
|
|
121
|
+
.refine((value) => Object.values(value).some((v) => v !== undefined), {
|
|
122
|
+
message: "최소 1개 필드가 필요합니다",
|
|
123
|
+
});
|
|
124
|
+
export type UpdateStoreRequest = z.infer<typeof updateStoreRequestSchema>;
|
|
125
|
+
|
|
76
126
|
export const storeSchema = z.object({
|
|
77
127
|
storeId: z.string(),
|
|
78
128
|
name: z.string(),
|
|
@@ -82,6 +132,9 @@ export const storeSchema = z.object({
|
|
|
82
132
|
logoUrl: z.url().nullable(),
|
|
83
133
|
businessNumber: z.string().nullable(),
|
|
84
134
|
customerCenterPhone: z.string().nullable(),
|
|
135
|
+
analyticsAllowedOrigins: z
|
|
136
|
+
.array(z.string())
|
|
137
|
+
.describe("방문 분석 수집을 받는 스토어프런트 오리진. 비어 있으면 모든 오리진에서 받는다"),
|
|
85
138
|
memberCount: z.number().int(),
|
|
86
139
|
createdAt: z.string(),
|
|
87
140
|
});
|