@nextlyhq/storage-vercel-blob 0.0.2-alpha.71 → 0.0.2-alpha.73

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.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _vercel_blob = require("@vercel/blob");
3
- // ../nextly/dist/nextly-error-CwDiSPDF.mjs
3
+ // ../nextly/dist/nextly-error-BLaA7N-v.mjs
4
4
  function isDbError(err) {
5
5
  if (!err || typeof err !== "object") return false;
6
6
  const obj = err;
@@ -77,6 +77,8 @@ const NEXTLY_ERROR_STATUS = {
77
77
  SETUP_TOKEN_REQUIRED: 403,
78
78
  API_KEY_ROLE_ABOVE_CREATOR: 403,
79
79
  NOT_FOUND: 404,
80
+ ENTITY_REMOVED_FROM_CODE: 409,
81
+ ENTITY_NOT_MIGRATED: 409,
80
82
  METHOD_NOT_ALLOWED: 405,
81
83
  RANGE_NOT_SATISFIABLE: 416,
82
84
  CONFLICT: 409,
@@ -90,6 +92,7 @@ const NEXTLY_ERROR_STATUS = {
90
92
  DATABASE_BUSY: 503,
91
93
  EXTERNAL_SERVICE_ERROR: 502,
92
94
  SERVICE_UNAVAILABLE: 503,
95
+ CONFIGURATION_ERROR: 500,
93
96
  EXTERNAL_URL_BLOCKED: 400,
94
97
  EXTERNAL_REQUEST_FAILED: 502,
95
98
  FILENAME_INVALID: 400,
@@ -131,7 +134,7 @@ const NEXTLY_ERROR_STATUS = {
131
134
  NEXTLY_SCHEMA_RENAME_UNKNOWN_TARGET: 400,
132
135
  NEXTLY_PLUGIN_CLIENT_CONFIG_INVALID: 500,
133
136
  NEXTLY_PLUGIN_ADMIN_WIDGET_INVALID: 500,
134
- NEXTLY_ADMIN_COMPONENT_MAP_STALE: 500,
137
+ NEXTLY_PLUGIN_REMOVED_WIDGET_CHANNEL: 500,
135
138
  NEXTLY_PLUGIN_DOCUMENT_VIEW_INVALID: 500,
136
139
  PLUGIN_RESOLUTION_ERROR: 500,
137
140
  PLUGIN_DEPENDENCY_NOT_INSTALLED: 409,
@@ -413,6 +416,61 @@ var NextlyError = class NextlyError extends Error {
413
416
  });
414
417
  }
415
418
  /**
419
+ * Something only a signed-in person can do, asked by a caller that is not
420
+ * one: an API key, or a request acting as no person. Forbidden, and the
421
+ * message says so, since it is about what kind of caller asked, not about
422
+ * the caller's permissions. `doing` completes "Only a signed-in person can".
423
+ */
424
+ static personOnly(opts) {
425
+ return new NextlyError({
426
+ code: "FORBIDDEN",
427
+ publicMessage: `Only a signed-in person can ${opts.doing}.`,
428
+ logContext: opts.logContext
429
+ });
430
+ }
431
+ /**
432
+ * A role or permission built into Nextly, which is never changed or
433
+ * deleted. Forbidden, and the message says so: it is a fact about the role,
434
+ * not about the caller's permissions.
435
+ */
436
+ static builtIn(opts) {
437
+ const done = {
438
+ change: "changed",
439
+ delete: "deleted",
440
+ assign: "assigned",
441
+ inherit: "inherited"
442
+ }[opts.change];
443
+ return new NextlyError({
444
+ code: "FORBIDDEN",
445
+ publicMessage: `This ${opts.thing} is built in, so it can't be ${done}.`,
446
+ logContext: opts.logContext
447
+ });
448
+ }
449
+ /**
450
+ * A request from a site not allowed to make it: its own `Origin` names a
451
+ * site the installation does not allow. Forbidden, and the message says so;
452
+ * the origin is the caller's own, so naming its kind tells them nothing.
453
+ */
454
+ static originRefused(opts) {
455
+ return new NextlyError({
456
+ code: "FORBIDDEN",
457
+ publicMessage: "This request came from a site that isn't allowed to make it.",
458
+ logContext: opts?.logContext
459
+ });
460
+ }
461
+ /**
462
+ * A Single deleted without `force`: Singles hold a site's lasting settings,
463
+ * so they are not deleted from here, only by an admin or CLI clean-up that
464
+ * passes `force`. Forbidden, and the message says so.
465
+ */
466
+ static singleNotDeletable(opts) {
467
+ return new NextlyError({
468
+ code: "FORBIDDEN",
469
+ publicMessage: "A Single can't be deleted from here.",
470
+ logContext: opts?.logContext
471
+ });
472
+ }
473
+ /**
416
474
  * A collection, Single or component defined in code, which is changed by
417
475
  * changing its code and not from here. Forbidden, and the message says so:
418
476
  * it is a fact about the thing, not about the caller's permissions, so it
@@ -427,6 +485,57 @@ var NextlyError = class NextlyError extends Error {
427
485
  });
428
486
  }
429
487
  /**
488
+ * A write to an entry of a collection or Single removed from code: its
489
+ * registry row says the app's code defines it, and the running configuration
490
+ * no longer declares it. Its entries are read-only until it is retired or
491
+ * declared again, so the message names the entity, says what happened and
492
+ * gives both ways out. `publicData` carries the kind and the slug, which the
493
+ * caller named, so a client can mark the entity without parsing the sentence.
494
+ */
495
+ static removedFromCode(opts) {
496
+ const thing = opts.kind === "single" ? "Single" : "collection";
497
+ const its = opts.kind === "single" ? "it" : "its entries";
498
+ return new NextlyError({
499
+ code: "ENTITY_REMOVED_FROM_CODE",
500
+ publicMessage: `The ${thing} "${opts.slug}" was removed from code, so ${its} can't be changed. To retire it, run \`nextly migrate:create\` and then \`nextly migrate\`. To keep it, declare it again in nextly.config.ts.`,
501
+ publicData: {
502
+ kind: opts.kind,
503
+ slug: opts.slug
504
+ },
505
+ logContext: {
506
+ kind: opts.kind,
507
+ slug: opts.slug,
508
+ ...opts.logContext
509
+ }
510
+ });
511
+ }
512
+ /**
513
+ * A read or write of a collection or Single the database has not been
514
+ * migrated for: the column of one of its declared fields is missing, its
515
+ * table is missing, or this running instance never registered it (an
516
+ * entity a migration added after the instance started). The message names
517
+ * the entity, the field or the table, and `nextly migrate`; the driver's
518
+ * error stays on `cause`, for the log, so no SQL reaches the answer.
519
+ */
520
+ static notMigrated(opts) {
521
+ const { cause, logContext, ...publicData } = opts;
522
+ const entity = `${publicData.kind === "single" ? "Single" : "collection"} "${publicData.slug}"`;
523
+ const field = publicData.field === void 0 ? "a field" : `the field "${publicData.field}"`;
524
+ const table = publicData.table === void 0 ? "" : ` "${publicData.table}"`;
525
+ const publicMessage = publicData.reason === "column" ? `The database has not been migrated for ${field} of the ${entity}. Run \`nextly migrate\`.` : publicData.reason === "table" ? `The database has not been migrated for the ${entity}: its table${table} does not exist. Run \`nextly migrate\`.` : `The ${entity}${publicData.table === void 0 ? "" : ` (table "${publicData.table}")`} is not registered in this running instance. Run \`nextly migrate\`, then restart the server.`;
526
+ return new NextlyError({
527
+ code: "ENTITY_NOT_MIGRATED",
528
+ publicMessage,
529
+ publicData,
530
+ logMessage: "The database has not been migrated for this entity",
531
+ logContext: {
532
+ ...publicData,
533
+ ...logContext
534
+ },
535
+ cause
536
+ });
537
+ }
538
+ /**
430
539
  * An autosave where the collection or Single does not autosave: its owner
431
540
  * switched autosave off, or it keeps no drafts to autosave into. Forbidden,
432
541
  * and the message says so, since it is a setting and not a permission.
@@ -570,6 +679,19 @@ var NextlyError = class NextlyError extends Error {
570
679
  logContext: opts?.logContext
571
680
  });
572
681
  }
682
+ /**
683
+ * The app is set up so nextly cannot work: a missing `config`, or a Next.js
684
+ * or React outside the supported ranges. The public message stays generic;
685
+ * what to change goes in `logMessage`, for the operator.
686
+ */
687
+ static configuration(opts) {
688
+ return new NextlyError({
689
+ code: "CONFIGURATION_ERROR",
690
+ publicMessage: "Server configuration error.",
691
+ logMessage: opts.logMessage,
692
+ logContext: opts.logContext
693
+ });
694
+ }
573
695
  static serviceUnavailable(opts) {
574
696
  return new NextlyError({
575
697
  code: "SERVICE_UNAVAILABLE",
@@ -659,7 +781,7 @@ function ipv4ToInt(ip) {
659
781
  }
660
782
  return acc >>> 0;
661
783
  }
662
- // ../nextly/dist/validate-external-url-CnZrcJdP.mjs
784
+ // ../nextly/dist/validate-external-url-DpPuwVvV.mjs
663
785
  const IPV4_RE = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
664
786
  /**
665
787
  * IPv4 CIDR ranges that must NEVER be the destination of an outbound