@sayren/store-sdk 0.41.0 → 0.43.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.
Files changed (53) hide show
  1. package/dist/index.d.mts +72 -72
  2. package/dist/index.mjs +160 -160
  3. package/dist/server.mjs +1 -1
  4. package/dist/{webhook-headers-D974dE4T.mjs → webhook-headers-CTez3xDY.mjs} +81 -3
  5. package/package.json +1 -1
  6. package/src/client.ts +1 -1
  7. package/src/http.ts +1 -1
  8. package/src/oauth.ts +1 -1
  9. package/src/schemas/ai.ts +40 -33
  10. package/src/schemas/analytics.ts +1 -1
  11. package/src/schemas/api-log.ts +1 -1
  12. package/src/schemas/app-manifest.ts +1 -1
  13. package/src/schemas/apps.ts +19 -16
  14. package/src/schemas/audit.ts +7 -4
  15. package/src/schemas/auth.ts +1 -1
  16. package/src/schemas/category.ts +37 -32
  17. package/src/schemas/claim.ts +15 -12
  18. package/src/schemas/collection.ts +76 -65
  19. package/src/schemas/commerce-flow.ts +107 -86
  20. package/src/schemas/commerce-number.ts +1 -1
  21. package/src/schemas/common.ts +1 -1
  22. package/src/schemas/coupon.ts +88 -80
  23. package/src/schemas/currency-prices.ts +1 -1
  24. package/src/schemas/currency.ts +1 -1
  25. package/src/schemas/customer-delegation.ts +31 -28
  26. package/src/schemas/customer.ts +10 -7
  27. package/src/schemas/fulfillment.ts +1 -1
  28. package/src/schemas/inventory.ts +29 -24
  29. package/src/schemas/locale.ts +1 -1
  30. package/src/schemas/login.ts +18 -11
  31. package/src/schemas/market.ts +1 -1
  32. package/src/schemas/misc.ts +7 -4
  33. package/src/schemas/order.ts +70 -59
  34. package/src/schemas/payment.ts +108 -89
  35. package/src/schemas/plans.ts +1 -1
  36. package/src/schemas/points.ts +33 -28
  37. package/src/schemas/product-info.ts +13 -10
  38. package/src/schemas/product-localization.ts +1 -1
  39. package/src/schemas/product.ts +18 -15
  40. package/src/schemas/promotion.ts +1 -1
  41. package/src/schemas/refund-policy.ts +1 -1
  42. package/src/schemas/saved-option-set.ts +6 -6
  43. package/src/schemas/scope.ts +1 -1
  44. package/src/schemas/shipping-policy.ts +1 -1
  45. package/src/schemas/starter.ts +16 -13
  46. package/src/schemas/stay.ts +16 -13
  47. package/src/schemas/store.ts +130 -114
  48. package/src/schemas/storefront-hosting.ts +272 -220
  49. package/src/schemas/strict.ts +84 -0
  50. package/src/schemas/subscription.ts +1 -1
  51. package/src/schemas/telemetry.ts +1 -1
  52. package/src/schemas/upload.ts +16 -13
  53. package/src/schemas/webhook-event.ts +1 -1
@@ -0,0 +1,84 @@
1
+ import * as z from "zod";
2
+
3
+ /**
4
+ * 관리 API 요청 본문을 모르는 키까지 거르는 스키마로 바꾼다(이슈 #193, 2026-10-24). `z.object`는 모르는 키를 조용히 버려서
5
+ * 오타·잘못된 자리의 필드(예: 옵션 값에 둔 추가금)가 400 없이 사라지고 기본값으로 저장됐다. 원본은 응답 스키마와 하위 스키마를
6
+ * 공유하므로 고치지 않고, 안쪽 객체까지 `catchall: never`로 복제한다. `z.looseObject`처럼 catchall을 정한 객체는 그대로 둔다.
7
+ * 설명·예시(전역 등록부의 메타)는 복제본에 옮겨 OpenAPI 문서가 같다
8
+ */
9
+ export function strictRequest<T extends z.ZodType>(schema: T): T {
10
+ return strictOf(schema, new Map()) as T;
11
+ }
12
+
13
+ // biome-ignore lint/suspicious/noExplicitAny: zod 내부 정의(def)를 형태별로 다시 짜는 곳이라 형태 하나로 묶을 수 없다
14
+ type Def = any;
15
+
16
+ function strictOf(schema: z.ZodType, seen: Map<z.ZodType, z.ZodType>): z.ZodType {
17
+ const done = seen.get(schema);
18
+ if (done) return done;
19
+ const def: Def = schema._zod.def;
20
+ const clone = (patch: Def): z.ZodType => {
21
+ const next = schema.clone({ ...def, ...patch });
22
+ const meta = z.globalRegistry.get(schema);
23
+ if (meta) z.globalRegistry.add(next, meta);
24
+ return next;
25
+ };
26
+ let next: z.ZodType;
27
+ switch (def.type) {
28
+ case "object":
29
+ next = clone({
30
+ shape: Object.fromEntries(
31
+ Object.entries(def.shape as Record<string, z.ZodType>).map(([key, value]) => [
32
+ key,
33
+ strictOf(value, seen),
34
+ ]),
35
+ ),
36
+ catchall: def.catchall ?? z.never(),
37
+ });
38
+ break;
39
+ case "array":
40
+ next = clone({ element: strictOf(def.element, seen) });
41
+ break;
42
+ case "optional":
43
+ case "nullable":
44
+ case "default":
45
+ case "prefault":
46
+ case "nonoptional":
47
+ case "readonly":
48
+ case "catch":
49
+ next = clone({ innerType: strictOf(def.innerType, seen) });
50
+ break;
51
+ case "union":
52
+ next = clone({ options: def.options.map((option: z.ZodType) => strictOf(option, seen)) });
53
+ break;
54
+ case "intersection":
55
+ next = clone({ left: strictOf(def.left, seen), right: strictOf(def.right, seen) });
56
+ break;
57
+ case "pipe":
58
+ next = clone({ in: strictOf(def.in, seen) });
59
+ break;
60
+ case "record":
61
+ next = clone({ valueType: strictOf(def.valueType, seen) });
62
+ break;
63
+ case "tuple":
64
+ next = clone({
65
+ items: def.items.map((item: z.ZodType) => strictOf(item, seen)),
66
+ rest: def.rest ? strictOf(def.rest, seen) : def.rest,
67
+ });
68
+ break;
69
+ case "lazy": {
70
+ let inner: z.ZodType | undefined;
71
+ next = clone({
72
+ getter: () => {
73
+ inner ??= strictOf(def.getter(), seen);
74
+ return inner;
75
+ },
76
+ });
77
+ break;
78
+ }
79
+ default:
80
+ next = schema;
81
+ }
82
+ seen.set(schema, next);
83
+ return next;
84
+ }
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
 
3
3
  /**
4
4
  * 요금제·구독 — `GET /v1/store/subscription`(스코프 `store:r`). 구독 단위는 상점이다.
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
 
3
3
  /**
4
4
  * MCP 도구 호출 계측 (`POST /v1/telemetry/mcp`, 이슈 #34).
@@ -1,4 +1,5 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
+ import { strictRequest } from "./strict";
2
3
 
3
4
  /**
4
5
  * 업로드 용도. 허용 확장자와 크기 상한이 용도별로 다르다.
@@ -100,18 +101,20 @@ export function uploadRejection(
100
101
  * 끝나면 `url`이 공개 주소가 된다. 서버가 객체 키를 정하므로 요청은 파일명만 보낸다
101
102
  * (확장자만 쓰이고 이름 자체는 저장되지 않는다).
102
103
  */
103
- export const uploadRequestSchema = z.object({
104
- filename: z.string().min(1).max(255),
105
- purpose: uploadPurposeSchema
106
- .default("description")
107
- .describe("업로드 용도. 허용 확장자와 크기 상한이 용도별로 다르다"),
108
- size: z
109
- .number()
110
- .int()
111
- .positive()
112
- .optional()
113
- .describe("파일 바이트 크기. 주면 용도별 상한을 발급 전에 검사한다"),
114
- });
104
+ export const uploadRequestSchema = strictRequest(
105
+ z.object({
106
+ filename: z.string().min(1).max(255),
107
+ purpose: uploadPurposeSchema
108
+ .default("description")
109
+ .describe("업로드 용도. 허용 확장자와 크기 상한이 용도별로 다르다"),
110
+ size: z
111
+ .number()
112
+ .int()
113
+ .positive()
114
+ .optional()
115
+ .describe("파일 바이트 크기. 주면 용도별 상한을 발급 전에 검사한다"),
116
+ }),
117
+ );
115
118
 
116
119
  export type UploadRequest = z.infer<typeof uploadRequestSchema>;
117
120
 
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  import { claimStatusSchema, claimTypeSchema } from "./claim";
3
3
  import { orderItemStatusSchema } from "./common";
4
4
  import { orderItemFulfillmentSnapshotResponseSchema } from "./fulfillment";