@magiclabs.ai/magicbook-client 0.7.21 → 0.7.22-canary

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/index.js CHANGED
@@ -1577,7 +1577,7 @@ function getStyleIdBySlug(slug) {
1577
1577
  return slug;
1578
1578
  }
1579
1579
 
1580
- // ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
1580
+ // ../../node_modules/.pnpm/zod@3.24.1/node_modules/zod/lib/index.mjs
1581
1581
  var util;
1582
1582
  (function(util2) {
1583
1583
  util2.assertEqual = (val) => val;
@@ -1732,6 +1732,9 @@ var quotelessJson = (obj) => {
1732
1732
  return json.replace(/"([^"]+)":/g, "$1:");
1733
1733
  };
1734
1734
  var ZodError = class _ZodError extends Error {
1735
+ get errors() {
1736
+ return this.issues;
1737
+ }
1735
1738
  constructor(issues) {
1736
1739
  super();
1737
1740
  this.issues = [];
@@ -1750,9 +1753,6 @@ var ZodError = class _ZodError extends Error {
1750
1753
  this.name = "ZodError";
1751
1754
  this.issues = issues;
1752
1755
  }
1753
- get errors() {
1754
- return this.issues;
1755
- }
1756
1756
  format(_mapper) {
1757
1757
  const mapper = _mapper || function(issue) {
1758
1758
  return issue.message;
@@ -1963,8 +1963,11 @@ function addIssueToContext(ctx, issueData) {
1963
1963
  path: ctx.path,
1964
1964
  errorMaps: [
1965
1965
  ctx.common.contextualErrorMap,
1966
+ // contextual error map is first priority
1966
1967
  ctx.schemaErrorMap,
1968
+ // then schema-bound map if available
1967
1969
  overrideMap,
1970
+ // then global override map
1968
1971
  overrideMap === errorMap ? void 0 : errorMap
1969
1972
  // then global default map
1970
1973
  ].filter((x) => !!x)
@@ -2120,34 +2123,6 @@ function processCreateParams(params) {
2120
2123
  return { errorMap: customMap, description };
2121
2124
  }
2122
2125
  var ZodType = class {
2123
- constructor(def) {
2124
- this.spa = this.safeParseAsync;
2125
- this._def = def;
2126
- this.parse = this.parse.bind(this);
2127
- this.safeParse = this.safeParse.bind(this);
2128
- this.parseAsync = this.parseAsync.bind(this);
2129
- this.safeParseAsync = this.safeParseAsync.bind(this);
2130
- this.spa = this.spa.bind(this);
2131
- this.refine = this.refine.bind(this);
2132
- this.refinement = this.refinement.bind(this);
2133
- this.superRefine = this.superRefine.bind(this);
2134
- this.optional = this.optional.bind(this);
2135
- this.nullable = this.nullable.bind(this);
2136
- this.nullish = this.nullish.bind(this);
2137
- this.array = this.array.bind(this);
2138
- this.promise = this.promise.bind(this);
2139
- this.or = this.or.bind(this);
2140
- this.and = this.and.bind(this);
2141
- this.transform = this.transform.bind(this);
2142
- this.brand = this.brand.bind(this);
2143
- this.default = this.default.bind(this);
2144
- this.catch = this.catch.bind(this);
2145
- this.describe = this.describe.bind(this);
2146
- this.pipe = this.pipe.bind(this);
2147
- this.readonly = this.readonly.bind(this);
2148
- this.isNullable = this.isNullable.bind(this);
2149
- this.isOptional = this.isOptional.bind(this);
2150
- }
2151
2126
  get description() {
2152
2127
  return this._def.description;
2153
2128
  }
@@ -2211,6 +2186,43 @@ var ZodType = class {
2211
2186
  const result = this._parseSync({ data, path: ctx.path, parent: ctx });
2212
2187
  return handleResult(ctx, result);
2213
2188
  }
2189
+ "~validate"(data) {
2190
+ var _a, _b;
2191
+ const ctx = {
2192
+ common: {
2193
+ issues: [],
2194
+ async: !!this["~standard"].async
2195
+ },
2196
+ path: [],
2197
+ schemaErrorMap: this._def.errorMap,
2198
+ parent: null,
2199
+ data,
2200
+ parsedType: getParsedType(data)
2201
+ };
2202
+ if (!this["~standard"].async) {
2203
+ try {
2204
+ const result = this._parseSync({ data, path: [], parent: ctx });
2205
+ return isValid(result) ? {
2206
+ value: result.value
2207
+ } : {
2208
+ issues: ctx.common.issues
2209
+ };
2210
+ } catch (err) {
2211
+ if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
2212
+ this["~standard"].async = true;
2213
+ }
2214
+ ctx.common = {
2215
+ issues: [],
2216
+ async: true
2217
+ };
2218
+ }
2219
+ }
2220
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
2221
+ value: result.value
2222
+ } : {
2223
+ issues: ctx.common.issues
2224
+ });
2225
+ }
2214
2226
  async parseAsync(data, params) {
2215
2227
  const result = await this.safeParseAsync(data, params);
2216
2228
  if (result.success)
@@ -2288,6 +2300,39 @@ var ZodType = class {
2288
2300
  superRefine(refinement) {
2289
2301
  return this._refinement(refinement);
2290
2302
  }
2303
+ constructor(def) {
2304
+ this.spa = this.safeParseAsync;
2305
+ this._def = def;
2306
+ this.parse = this.parse.bind(this);
2307
+ this.safeParse = this.safeParse.bind(this);
2308
+ this.parseAsync = this.parseAsync.bind(this);
2309
+ this.safeParseAsync = this.safeParseAsync.bind(this);
2310
+ this.spa = this.spa.bind(this);
2311
+ this.refine = this.refine.bind(this);
2312
+ this.refinement = this.refinement.bind(this);
2313
+ this.superRefine = this.superRefine.bind(this);
2314
+ this.optional = this.optional.bind(this);
2315
+ this.nullable = this.nullable.bind(this);
2316
+ this.nullish = this.nullish.bind(this);
2317
+ this.array = this.array.bind(this);
2318
+ this.promise = this.promise.bind(this);
2319
+ this.or = this.or.bind(this);
2320
+ this.and = this.and.bind(this);
2321
+ this.transform = this.transform.bind(this);
2322
+ this.brand = this.brand.bind(this);
2323
+ this.default = this.default.bind(this);
2324
+ this.catch = this.catch.bind(this);
2325
+ this.describe = this.describe.bind(this);
2326
+ this.pipe = this.pipe.bind(this);
2327
+ this.readonly = this.readonly.bind(this);
2328
+ this.isNullable = this.isNullable.bind(this);
2329
+ this.isOptional = this.isOptional.bind(this);
2330
+ this["~standard"] = {
2331
+ version: 1,
2332
+ vendor: "zod",
2333
+ validate: (data) => this["~validate"](data)
2334
+ };
2335
+ }
2291
2336
  optional() {
2292
2337
  return ZodOptional.create(this, this._def);
2293
2338
  }
@@ -2298,7 +2343,7 @@ var ZodType = class {
2298
2343
  return this.nullable().optional();
2299
2344
  }
2300
2345
  array() {
2301
- return ZodArray.create(this, this._def);
2346
+ return ZodArray.create(this);
2302
2347
  }
2303
2348
  promise() {
2304
2349
  return ZodPromise.create(this, this._def);
@@ -2364,16 +2409,20 @@ var ZodType = class {
2364
2409
  };
2365
2410
  var cuidRegex = /^c[^\s-]{8,}$/i;
2366
2411
  var cuid2Regex = /^[0-9a-z]+$/;
2367
- var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
2412
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
2368
2413
  var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
2369
2414
  var nanoidRegex = /^[a-z0-9_-]{21}$/i;
2415
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
2370
2416
  var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
2371
2417
  var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
2372
2418
  var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
2373
2419
  var emojiRegex;
2374
2420
  var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
2375
- var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
2421
+ var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
2422
+ var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
2423
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
2376
2424
  var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
2425
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
2377
2426
  var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
2378
2427
  var dateRegex = new RegExp(`^${dateRegexSource}$`);
2379
2428
  function timeRegexSource(args) {
@@ -2406,6 +2455,33 @@ function isValidIP(ip, version) {
2406
2455
  }
2407
2456
  return false;
2408
2457
  }
2458
+ function isValidJWT(jwt, alg) {
2459
+ if (!jwtRegex.test(jwt))
2460
+ return false;
2461
+ try {
2462
+ const [header] = jwt.split(".");
2463
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
2464
+ const decoded = JSON.parse(atob(base64));
2465
+ if (typeof decoded !== "object" || decoded === null)
2466
+ return false;
2467
+ if (!decoded.typ || !decoded.alg)
2468
+ return false;
2469
+ if (alg && decoded.alg !== alg)
2470
+ return false;
2471
+ return true;
2472
+ } catch (_a) {
2473
+ return false;
2474
+ }
2475
+ }
2476
+ function isValidCidr(ip, version) {
2477
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
2478
+ return true;
2479
+ }
2480
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
2481
+ return true;
2482
+ }
2483
+ return false;
2484
+ }
2409
2485
  var ZodString = class _ZodString extends ZodType {
2410
2486
  _parse(input) {
2411
2487
  if (this._def.coerce) {
@@ -2662,6 +2738,26 @@ var ZodString = class _ZodString extends ZodType {
2662
2738
  });
2663
2739
  status.dirty();
2664
2740
  }
2741
+ } else if (check.kind === "jwt") {
2742
+ if (!isValidJWT(input.data, check.alg)) {
2743
+ ctx = this._getOrReturnCtx(input, ctx);
2744
+ addIssueToContext(ctx, {
2745
+ validation: "jwt",
2746
+ code: ZodIssueCode.invalid_string,
2747
+ message: check.message
2748
+ });
2749
+ status.dirty();
2750
+ }
2751
+ } else if (check.kind === "cidr") {
2752
+ if (!isValidCidr(input.data, check.version)) {
2753
+ ctx = this._getOrReturnCtx(input, ctx);
2754
+ addIssueToContext(ctx, {
2755
+ validation: "cidr",
2756
+ code: ZodIssueCode.invalid_string,
2757
+ message: check.message
2758
+ });
2759
+ status.dirty();
2760
+ }
2665
2761
  } else if (check.kind === "base64") {
2666
2762
  if (!base64Regex.test(input.data)) {
2667
2763
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2672,6 +2768,16 @@ var ZodString = class _ZodString extends ZodType {
2672
2768
  });
2673
2769
  status.dirty();
2674
2770
  }
2771
+ } else if (check.kind === "base64url") {
2772
+ if (!base64urlRegex.test(input.data)) {
2773
+ ctx = this._getOrReturnCtx(input, ctx);
2774
+ addIssueToContext(ctx, {
2775
+ validation: "base64url",
2776
+ code: ZodIssueCode.invalid_string,
2777
+ message: check.message
2778
+ });
2779
+ status.dirty();
2780
+ }
2675
2781
  } else {
2676
2782
  util.assertNever(check);
2677
2783
  }
@@ -2718,9 +2824,21 @@ var ZodString = class _ZodString extends ZodType {
2718
2824
  base64(message) {
2719
2825
  return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2720
2826
  }
2827
+ base64url(message) {
2828
+ return this._addCheck({
2829
+ kind: "base64url",
2830
+ ...errorUtil.errToObj(message)
2831
+ });
2832
+ }
2833
+ jwt(options) {
2834
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
2835
+ }
2721
2836
  ip(options) {
2722
2837
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2723
2838
  }
2839
+ cidr(options) {
2840
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
2841
+ }
2724
2842
  datetime(options) {
2725
2843
  var _a, _b;
2726
2844
  if (typeof options === "string") {
@@ -2811,8 +2929,7 @@ var ZodString = class _ZodString extends ZodType {
2811
2929
  });
2812
2930
  }
2813
2931
  /**
2814
- * @deprecated Use z.string().min(1) instead.
2815
- * @see {@link ZodString.min}
2932
+ * Equivalent to `.min(1)`
2816
2933
  */
2817
2934
  nonempty(message) {
2818
2935
  return this.min(1, errorUtil.errToObj(message));
@@ -2874,9 +2991,15 @@ var ZodString = class _ZodString extends ZodType {
2874
2991
  get isIP() {
2875
2992
  return !!this._def.checks.find((ch) => ch.kind === "ip");
2876
2993
  }
2994
+ get isCIDR() {
2995
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
2996
+ }
2877
2997
  get isBase64() {
2878
2998
  return !!this._def.checks.find((ch) => ch.kind === "base64");
2879
2999
  }
3000
+ get isBase64url() {
3001
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
3002
+ }
2880
3003
  get minLength() {
2881
3004
  let min = null;
2882
3005
  for (const ch of this._def.checks) {
@@ -3154,17 +3277,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
3154
3277
  }
3155
3278
  _parse(input) {
3156
3279
  if (this._def.coerce) {
3157
- input.data = BigInt(input.data);
3280
+ try {
3281
+ input.data = BigInt(input.data);
3282
+ } catch (_a) {
3283
+ return this._getInvalidInput(input);
3284
+ }
3158
3285
  }
3159
3286
  const parsedType = this._getType(input);
3160
3287
  if (parsedType !== ZodParsedType.bigint) {
3161
- const ctx2 = this._getOrReturnCtx(input);
3162
- addIssueToContext(ctx2, {
3163
- code: ZodIssueCode.invalid_type,
3164
- expected: ZodParsedType.bigint,
3165
- received: ctx2.parsedType
3166
- });
3167
- return INVALID;
3288
+ return this._getInvalidInput(input);
3168
3289
  }
3169
3290
  let ctx = void 0;
3170
3291
  const status = new ParseStatus();
@@ -3211,6 +3332,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
3211
3332
  }
3212
3333
  return { status: status.value, value: input.data };
3213
3334
  }
3335
+ _getInvalidInput(input) {
3336
+ const ctx = this._getOrReturnCtx(input);
3337
+ addIssueToContext(ctx, {
3338
+ code: ZodIssueCode.invalid_type,
3339
+ expected: ZodParsedType.bigint,
3340
+ received: ctx.parsedType
3341
+ });
3342
+ return INVALID;
3343
+ }
3214
3344
  gte(value, message) {
3215
3345
  return this.setLimit("min", value, true, errorUtil.toString(message));
3216
3346
  }
@@ -6292,6 +6422,14 @@ var SpreadsEndpoints = class {
6292
6422
  return spreadServerSchema.parse(res);
6293
6423
  });
6294
6424
  }
6425
+ render(spreadId, bookId, size = 512) {
6426
+ return handleAsyncFunction(async () => {
6427
+ const res = await this.engineAPI.fetcher.call({
6428
+ path: `/v1/spreads/${spreadId}/book/${bookId}/render/${size}`
6429
+ });
6430
+ return spreadServerSchema.parse(res);
6431
+ });
6432
+ }
6295
6433
  update(spreadId, bookId, spread) {
6296
6434
  return handleAsyncFunction(async () => {
6297
6435
  const res = await this.engineAPI.fetcher.call({
@@ -6525,6 +6663,8 @@ export {
6525
6663
  reportingDataSchema,
6526
6664
  sflyCanvasSchema,
6527
6665
  snapCanvasSchema,
6666
+ spreadSchema,
6667
+ spreadServerSchema,
6528
6668
  states,
6529
6669
  statesToCloseWS,
6530
6670
  statesToReport,