@nextlyhq/storage-vercel-blob 0.0.2-alpha.72 → 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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BlobNotFoundError, del, head, list, put } from "@vercel/blob";
2
- // ../nextly/dist/nextly-error-DetCjZnO.mjs
2
+ // ../nextly/dist/nextly-error-BLaA7N-v.mjs
3
3
  function isDbError(err) {
4
4
  if (!err || typeof err !== "object") return false;
5
5
  const obj = err;
@@ -76,6 +76,8 @@ const NEXTLY_ERROR_STATUS = {
76
76
  SETUP_TOKEN_REQUIRED: 403,
77
77
  API_KEY_ROLE_ABOVE_CREATOR: 403,
78
78
  NOT_FOUND: 404,
79
+ ENTITY_REMOVED_FROM_CODE: 409,
80
+ ENTITY_NOT_MIGRATED: 409,
79
81
  METHOD_NOT_ALLOWED: 405,
80
82
  RANGE_NOT_SATISFIABLE: 416,
81
83
  CONFLICT: 409,
@@ -89,6 +91,7 @@ const NEXTLY_ERROR_STATUS = {
89
91
  DATABASE_BUSY: 503,
90
92
  EXTERNAL_SERVICE_ERROR: 502,
91
93
  SERVICE_UNAVAILABLE: 503,
94
+ CONFIGURATION_ERROR: 500,
92
95
  EXTERNAL_URL_BLOCKED: 400,
93
96
  EXTERNAL_REQUEST_FAILED: 502,
94
97
  FILENAME_INVALID: 400,
@@ -130,7 +133,7 @@ const NEXTLY_ERROR_STATUS = {
130
133
  NEXTLY_SCHEMA_RENAME_UNKNOWN_TARGET: 400,
131
134
  NEXTLY_PLUGIN_CLIENT_CONFIG_INVALID: 500,
132
135
  NEXTLY_PLUGIN_ADMIN_WIDGET_INVALID: 500,
133
- NEXTLY_ADMIN_COMPONENT_MAP_STALE: 500,
136
+ NEXTLY_PLUGIN_REMOVED_WIDGET_CHANNEL: 500,
134
137
  NEXTLY_PLUGIN_DOCUMENT_VIEW_INVALID: 500,
135
138
  PLUGIN_RESOLUTION_ERROR: 500,
136
139
  PLUGIN_DEPENDENCY_NOT_INSTALLED: 409,
@@ -430,9 +433,15 @@ var NextlyError = class NextlyError extends Error {
430
433
  * not about the caller's permissions.
431
434
  */
432
435
  static builtIn(opts) {
436
+ const done = {
437
+ change: "changed",
438
+ delete: "deleted",
439
+ assign: "assigned",
440
+ inherit: "inherited"
441
+ }[opts.change];
433
442
  return new NextlyError({
434
443
  code: "FORBIDDEN",
435
- publicMessage: `This ${opts.thing} is built in, so it can't be ${opts.change === "change" ? "changed" : "deleted"}.`,
444
+ publicMessage: `This ${opts.thing} is built in, so it can't be ${done}.`,
436
445
  logContext: opts.logContext
437
446
  });
438
447
  }
@@ -475,6 +484,57 @@ var NextlyError = class NextlyError extends Error {
475
484
  });
476
485
  }
477
486
  /**
487
+ * A write to an entry of a collection or Single removed from code: its
488
+ * registry row says the app's code defines it, and the running configuration
489
+ * no longer declares it. Its entries are read-only until it is retired or
490
+ * declared again, so the message names the entity, says what happened and
491
+ * gives both ways out. `publicData` carries the kind and the slug, which the
492
+ * caller named, so a client can mark the entity without parsing the sentence.
493
+ */
494
+ static removedFromCode(opts) {
495
+ const thing = opts.kind === "single" ? "Single" : "collection";
496
+ const its = opts.kind === "single" ? "it" : "its entries";
497
+ return new NextlyError({
498
+ code: "ENTITY_REMOVED_FROM_CODE",
499
+ 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.`,
500
+ publicData: {
501
+ kind: opts.kind,
502
+ slug: opts.slug
503
+ },
504
+ logContext: {
505
+ kind: opts.kind,
506
+ slug: opts.slug,
507
+ ...opts.logContext
508
+ }
509
+ });
510
+ }
511
+ /**
512
+ * A read or write of a collection or Single the database has not been
513
+ * migrated for: the column of one of its declared fields is missing, its
514
+ * table is missing, or this running instance never registered it (an
515
+ * entity a migration added after the instance started). The message names
516
+ * the entity, the field or the table, and `nextly migrate`; the driver's
517
+ * error stays on `cause`, for the log, so no SQL reaches the answer.
518
+ */
519
+ static notMigrated(opts) {
520
+ const { cause, logContext, ...publicData } = opts;
521
+ const entity = `${publicData.kind === "single" ? "Single" : "collection"} "${publicData.slug}"`;
522
+ const field = publicData.field === void 0 ? "a field" : `the field "${publicData.field}"`;
523
+ const table = publicData.table === void 0 ? "" : ` "${publicData.table}"`;
524
+ 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.`;
525
+ return new NextlyError({
526
+ code: "ENTITY_NOT_MIGRATED",
527
+ publicMessage,
528
+ publicData,
529
+ logMessage: "The database has not been migrated for this entity",
530
+ logContext: {
531
+ ...publicData,
532
+ ...logContext
533
+ },
534
+ cause
535
+ });
536
+ }
537
+ /**
478
538
  * An autosave where the collection or Single does not autosave: its owner
479
539
  * switched autosave off, or it keeps no drafts to autosave into. Forbidden,
480
540
  * and the message says so, since it is a setting and not a permission.
@@ -618,6 +678,19 @@ var NextlyError = class NextlyError extends Error {
618
678
  logContext: opts?.logContext
619
679
  });
620
680
  }
681
+ /**
682
+ * The app is set up so nextly cannot work: a missing `config`, or a Next.js
683
+ * or React outside the supported ranges. The public message stays generic;
684
+ * what to change goes in `logMessage`, for the operator.
685
+ */
686
+ static configuration(opts) {
687
+ return new NextlyError({
688
+ code: "CONFIGURATION_ERROR",
689
+ publicMessage: "Server configuration error.",
690
+ logMessage: opts.logMessage,
691
+ logContext: opts.logContext
692
+ });
693
+ }
621
694
  static serviceUnavailable(opts) {
622
695
  return new NextlyError({
623
696
  code: "SERVICE_UNAVAILABLE",
@@ -707,7 +780,7 @@ function ipv4ToInt(ip) {
707
780
  }
708
781
  return acc >>> 0;
709
782
  }
710
- // ../nextly/dist/validate-external-url-CfT2WjgH.mjs
783
+ // ../nextly/dist/validate-external-url-DpPuwVvV.mjs
711
784
  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)$/;
712
785
  /**
713
786
  * IPv4 CIDR ranges that must NEVER be the destination of an outbound