@magiclabs.ai/magicbook-client 0.7.21-canary → 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.cjs CHANGED
@@ -60,6 +60,8 @@ __export(src_exports, {
60
60
  reportingDataSchema: () => reportingDataSchema,
61
61
  sflyCanvasSchema: () => sflyCanvasSchema,
62
62
  snapCanvasSchema: () => snapCanvasSchema,
63
+ spreadSchema: () => spreadSchema,
64
+ spreadServerSchema: () => spreadServerSchema,
63
65
  states: () => states,
64
66
  statesToCloseWS: () => statesToCloseWS,
65
67
  statesToReport: () => statesToReport,
@@ -1649,7 +1651,7 @@ function getStyleIdBySlug(slug) {
1649
1651
  return slug;
1650
1652
  }
1651
1653
 
1652
- // ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
1654
+ // ../../node_modules/.pnpm/zod@3.24.1/node_modules/zod/lib/index.mjs
1653
1655
  var util;
1654
1656
  (function(util2) {
1655
1657
  util2.assertEqual = (val) => val;
@@ -1804,6 +1806,9 @@ var quotelessJson = (obj) => {
1804
1806
  return json.replace(/"([^"]+)":/g, "$1:");
1805
1807
  };
1806
1808
  var ZodError = class _ZodError extends Error {
1809
+ get errors() {
1810
+ return this.issues;
1811
+ }
1807
1812
  constructor(issues) {
1808
1813
  super();
1809
1814
  this.issues = [];
@@ -1822,9 +1827,6 @@ var ZodError = class _ZodError extends Error {
1822
1827
  this.name = "ZodError";
1823
1828
  this.issues = issues;
1824
1829
  }
1825
- get errors() {
1826
- return this.issues;
1827
- }
1828
1830
  format(_mapper) {
1829
1831
  const mapper = _mapper || function(issue) {
1830
1832
  return issue.message;
@@ -2035,8 +2037,11 @@ function addIssueToContext(ctx, issueData) {
2035
2037
  path: ctx.path,
2036
2038
  errorMaps: [
2037
2039
  ctx.common.contextualErrorMap,
2040
+ // contextual error map is first priority
2038
2041
  ctx.schemaErrorMap,
2042
+ // then schema-bound map if available
2039
2043
  overrideMap,
2044
+ // then global override map
2040
2045
  overrideMap === errorMap ? void 0 : errorMap
2041
2046
  // then global default map
2042
2047
  ].filter((x) => !!x)
@@ -2192,34 +2197,6 @@ function processCreateParams(params) {
2192
2197
  return { errorMap: customMap, description };
2193
2198
  }
2194
2199
  var ZodType = class {
2195
- constructor(def) {
2196
- this.spa = this.safeParseAsync;
2197
- this._def = def;
2198
- this.parse = this.parse.bind(this);
2199
- this.safeParse = this.safeParse.bind(this);
2200
- this.parseAsync = this.parseAsync.bind(this);
2201
- this.safeParseAsync = this.safeParseAsync.bind(this);
2202
- this.spa = this.spa.bind(this);
2203
- this.refine = this.refine.bind(this);
2204
- this.refinement = this.refinement.bind(this);
2205
- this.superRefine = this.superRefine.bind(this);
2206
- this.optional = this.optional.bind(this);
2207
- this.nullable = this.nullable.bind(this);
2208
- this.nullish = this.nullish.bind(this);
2209
- this.array = this.array.bind(this);
2210
- this.promise = this.promise.bind(this);
2211
- this.or = this.or.bind(this);
2212
- this.and = this.and.bind(this);
2213
- this.transform = this.transform.bind(this);
2214
- this.brand = this.brand.bind(this);
2215
- this.default = this.default.bind(this);
2216
- this.catch = this.catch.bind(this);
2217
- this.describe = this.describe.bind(this);
2218
- this.pipe = this.pipe.bind(this);
2219
- this.readonly = this.readonly.bind(this);
2220
- this.isNullable = this.isNullable.bind(this);
2221
- this.isOptional = this.isOptional.bind(this);
2222
- }
2223
2200
  get description() {
2224
2201
  return this._def.description;
2225
2202
  }
@@ -2283,6 +2260,43 @@ var ZodType = class {
2283
2260
  const result = this._parseSync({ data, path: ctx.path, parent: ctx });
2284
2261
  return handleResult(ctx, result);
2285
2262
  }
2263
+ "~validate"(data) {
2264
+ var _a, _b;
2265
+ const ctx = {
2266
+ common: {
2267
+ issues: [],
2268
+ async: !!this["~standard"].async
2269
+ },
2270
+ path: [],
2271
+ schemaErrorMap: this._def.errorMap,
2272
+ parent: null,
2273
+ data,
2274
+ parsedType: getParsedType(data)
2275
+ };
2276
+ if (!this["~standard"].async) {
2277
+ try {
2278
+ const result = this._parseSync({ data, path: [], parent: ctx });
2279
+ return isValid(result) ? {
2280
+ value: result.value
2281
+ } : {
2282
+ issues: ctx.common.issues
2283
+ };
2284
+ } catch (err) {
2285
+ 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")) {
2286
+ this["~standard"].async = true;
2287
+ }
2288
+ ctx.common = {
2289
+ issues: [],
2290
+ async: true
2291
+ };
2292
+ }
2293
+ }
2294
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
2295
+ value: result.value
2296
+ } : {
2297
+ issues: ctx.common.issues
2298
+ });
2299
+ }
2286
2300
  async parseAsync(data, params) {
2287
2301
  const result = await this.safeParseAsync(data, params);
2288
2302
  if (result.success)
@@ -2360,6 +2374,39 @@ var ZodType = class {
2360
2374
  superRefine(refinement) {
2361
2375
  return this._refinement(refinement);
2362
2376
  }
2377
+ constructor(def) {
2378
+ this.spa = this.safeParseAsync;
2379
+ this._def = def;
2380
+ this.parse = this.parse.bind(this);
2381
+ this.safeParse = this.safeParse.bind(this);
2382
+ this.parseAsync = this.parseAsync.bind(this);
2383
+ this.safeParseAsync = this.safeParseAsync.bind(this);
2384
+ this.spa = this.spa.bind(this);
2385
+ this.refine = this.refine.bind(this);
2386
+ this.refinement = this.refinement.bind(this);
2387
+ this.superRefine = this.superRefine.bind(this);
2388
+ this.optional = this.optional.bind(this);
2389
+ this.nullable = this.nullable.bind(this);
2390
+ this.nullish = this.nullish.bind(this);
2391
+ this.array = this.array.bind(this);
2392
+ this.promise = this.promise.bind(this);
2393
+ this.or = this.or.bind(this);
2394
+ this.and = this.and.bind(this);
2395
+ this.transform = this.transform.bind(this);
2396
+ this.brand = this.brand.bind(this);
2397
+ this.default = this.default.bind(this);
2398
+ this.catch = this.catch.bind(this);
2399
+ this.describe = this.describe.bind(this);
2400
+ this.pipe = this.pipe.bind(this);
2401
+ this.readonly = this.readonly.bind(this);
2402
+ this.isNullable = this.isNullable.bind(this);
2403
+ this.isOptional = this.isOptional.bind(this);
2404
+ this["~standard"] = {
2405
+ version: 1,
2406
+ vendor: "zod",
2407
+ validate: (data) => this["~validate"](data)
2408
+ };
2409
+ }
2363
2410
  optional() {
2364
2411
  return ZodOptional.create(this, this._def);
2365
2412
  }
@@ -2370,7 +2417,7 @@ var ZodType = class {
2370
2417
  return this.nullable().optional();
2371
2418
  }
2372
2419
  array() {
2373
- return ZodArray.create(this, this._def);
2420
+ return ZodArray.create(this);
2374
2421
  }
2375
2422
  promise() {
2376
2423
  return ZodPromise.create(this, this._def);
@@ -2436,16 +2483,20 @@ var ZodType = class {
2436
2483
  };
2437
2484
  var cuidRegex = /^c[^\s-]{8,}$/i;
2438
2485
  var cuid2Regex = /^[0-9a-z]+$/;
2439
- var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
2486
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
2440
2487
  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;
2441
2488
  var nanoidRegex = /^[a-z0-9_-]{21}$/i;
2489
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
2442
2490
  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)?)??$/;
2443
2491
  var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
2444
2492
  var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
2445
2493
  var emojiRegex;
2446
2494
  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])$/;
2447
- 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})))$/;
2495
+ 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])$/;
2496
+ 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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-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
2448
2498
  var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
2499
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
2449
2500
  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])))`;
2450
2501
  var dateRegex = new RegExp(`^${dateRegexSource}$`);
2451
2502
  function timeRegexSource(args) {
@@ -2478,6 +2529,33 @@ function isValidIP(ip, version) {
2478
2529
  }
2479
2530
  return false;
2480
2531
  }
2532
+ function isValidJWT(jwt, alg) {
2533
+ if (!jwtRegex.test(jwt))
2534
+ return false;
2535
+ try {
2536
+ const [header] = jwt.split(".");
2537
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
2538
+ const decoded = JSON.parse(atob(base64));
2539
+ if (typeof decoded !== "object" || decoded === null)
2540
+ return false;
2541
+ if (!decoded.typ || !decoded.alg)
2542
+ return false;
2543
+ if (alg && decoded.alg !== alg)
2544
+ return false;
2545
+ return true;
2546
+ } catch (_a) {
2547
+ return false;
2548
+ }
2549
+ }
2550
+ function isValidCidr(ip, version) {
2551
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
2552
+ return true;
2553
+ }
2554
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
2555
+ return true;
2556
+ }
2557
+ return false;
2558
+ }
2481
2559
  var ZodString = class _ZodString extends ZodType {
2482
2560
  _parse(input) {
2483
2561
  if (this._def.coerce) {
@@ -2734,6 +2812,26 @@ var ZodString = class _ZodString extends ZodType {
2734
2812
  });
2735
2813
  status.dirty();
2736
2814
  }
2815
+ } else if (check.kind === "jwt") {
2816
+ if (!isValidJWT(input.data, check.alg)) {
2817
+ ctx = this._getOrReturnCtx(input, ctx);
2818
+ addIssueToContext(ctx, {
2819
+ validation: "jwt",
2820
+ code: ZodIssueCode.invalid_string,
2821
+ message: check.message
2822
+ });
2823
+ status.dirty();
2824
+ }
2825
+ } else if (check.kind === "cidr") {
2826
+ if (!isValidCidr(input.data, check.version)) {
2827
+ ctx = this._getOrReturnCtx(input, ctx);
2828
+ addIssueToContext(ctx, {
2829
+ validation: "cidr",
2830
+ code: ZodIssueCode.invalid_string,
2831
+ message: check.message
2832
+ });
2833
+ status.dirty();
2834
+ }
2737
2835
  } else if (check.kind === "base64") {
2738
2836
  if (!base64Regex.test(input.data)) {
2739
2837
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2744,6 +2842,16 @@ var ZodString = class _ZodString extends ZodType {
2744
2842
  });
2745
2843
  status.dirty();
2746
2844
  }
2845
+ } else if (check.kind === "base64url") {
2846
+ if (!base64urlRegex.test(input.data)) {
2847
+ ctx = this._getOrReturnCtx(input, ctx);
2848
+ addIssueToContext(ctx, {
2849
+ validation: "base64url",
2850
+ code: ZodIssueCode.invalid_string,
2851
+ message: check.message
2852
+ });
2853
+ status.dirty();
2854
+ }
2747
2855
  } else {
2748
2856
  util.assertNever(check);
2749
2857
  }
@@ -2790,9 +2898,21 @@ var ZodString = class _ZodString extends ZodType {
2790
2898
  base64(message) {
2791
2899
  return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2792
2900
  }
2901
+ base64url(message) {
2902
+ return this._addCheck({
2903
+ kind: "base64url",
2904
+ ...errorUtil.errToObj(message)
2905
+ });
2906
+ }
2907
+ jwt(options) {
2908
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
2909
+ }
2793
2910
  ip(options) {
2794
2911
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2795
2912
  }
2913
+ cidr(options) {
2914
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
2915
+ }
2796
2916
  datetime(options) {
2797
2917
  var _a, _b;
2798
2918
  if (typeof options === "string") {
@@ -2883,8 +3003,7 @@ var ZodString = class _ZodString extends ZodType {
2883
3003
  });
2884
3004
  }
2885
3005
  /**
2886
- * @deprecated Use z.string().min(1) instead.
2887
- * @see {@link ZodString.min}
3006
+ * Equivalent to `.min(1)`
2888
3007
  */
2889
3008
  nonempty(message) {
2890
3009
  return this.min(1, errorUtil.errToObj(message));
@@ -2946,9 +3065,15 @@ var ZodString = class _ZodString extends ZodType {
2946
3065
  get isIP() {
2947
3066
  return !!this._def.checks.find((ch) => ch.kind === "ip");
2948
3067
  }
3068
+ get isCIDR() {
3069
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
3070
+ }
2949
3071
  get isBase64() {
2950
3072
  return !!this._def.checks.find((ch) => ch.kind === "base64");
2951
3073
  }
3074
+ get isBase64url() {
3075
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
3076
+ }
2952
3077
  get minLength() {
2953
3078
  let min = null;
2954
3079
  for (const ch of this._def.checks) {
@@ -3226,17 +3351,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
3226
3351
  }
3227
3352
  _parse(input) {
3228
3353
  if (this._def.coerce) {
3229
- input.data = BigInt(input.data);
3354
+ try {
3355
+ input.data = BigInt(input.data);
3356
+ } catch (_a) {
3357
+ return this._getInvalidInput(input);
3358
+ }
3230
3359
  }
3231
3360
  const parsedType = this._getType(input);
3232
3361
  if (parsedType !== ZodParsedType.bigint) {
3233
- const ctx2 = this._getOrReturnCtx(input);
3234
- addIssueToContext(ctx2, {
3235
- code: ZodIssueCode.invalid_type,
3236
- expected: ZodParsedType.bigint,
3237
- received: ctx2.parsedType
3238
- });
3239
- return INVALID;
3362
+ return this._getInvalidInput(input);
3240
3363
  }
3241
3364
  let ctx = void 0;
3242
3365
  const status = new ParseStatus();
@@ -3283,6 +3406,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
3283
3406
  }
3284
3407
  return { status: status.value, value: input.data };
3285
3408
  }
3409
+ _getInvalidInput(input) {
3410
+ const ctx = this._getOrReturnCtx(input);
3411
+ addIssueToContext(ctx, {
3412
+ code: ZodIssueCode.invalid_type,
3413
+ expected: ZodParsedType.bigint,
3414
+ received: ctx.parsedType
3415
+ });
3416
+ return INVALID;
3417
+ }
3286
3418
  gte(value, message) {
3287
3419
  return this.setLimit("min", value, true, errorUtil.toString(message));
3288
3420
  }
@@ -6364,6 +6496,14 @@ var SpreadsEndpoints = class {
6364
6496
  return spreadServerSchema.parse(res);
6365
6497
  });
6366
6498
  }
6499
+ render(spreadId, bookId, size = 512) {
6500
+ return handleAsyncFunction(async () => {
6501
+ const res = await this.engineAPI.fetcher.call({
6502
+ path: `/v1/spreads/${spreadId}/book/${bookId}/render/${size}`
6503
+ });
6504
+ return spreadServerSchema.parse(res);
6505
+ });
6506
+ }
6367
6507
  update(spreadId, bookId, spread) {
6368
6508
  return handleAsyncFunction(async () => {
6369
6509
  const res = await this.engineAPI.fetcher.call({
@@ -6598,6 +6738,8 @@ var MagicBookClient = class {
6598
6738
  reportingDataSchema,
6599
6739
  sflyCanvasSchema,
6600
6740
  snapCanvasSchema,
6741
+ spreadSchema,
6742
+ spreadServerSchema,
6601
6743
  states,
6602
6744
  statesToCloseWS,
6603
6745
  statesToReport,