@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.cjs +77 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +77 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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-
|
|
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
|
-
|
|
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,
|
|
@@ -431,9 +434,15 @@ var NextlyError = class NextlyError extends Error {
|
|
|
431
434
|
* not about the caller's permissions.
|
|
432
435
|
*/
|
|
433
436
|
static builtIn(opts) {
|
|
437
|
+
const done = {
|
|
438
|
+
change: "changed",
|
|
439
|
+
delete: "deleted",
|
|
440
|
+
assign: "assigned",
|
|
441
|
+
inherit: "inherited"
|
|
442
|
+
}[opts.change];
|
|
434
443
|
return new NextlyError({
|
|
435
444
|
code: "FORBIDDEN",
|
|
436
|
-
publicMessage: `This ${opts.thing} is built in, so it can't be ${
|
|
445
|
+
publicMessage: `This ${opts.thing} is built in, so it can't be ${done}.`,
|
|
437
446
|
logContext: opts.logContext
|
|
438
447
|
});
|
|
439
448
|
}
|
|
@@ -476,6 +485,57 @@ var NextlyError = class NextlyError extends Error {
|
|
|
476
485
|
});
|
|
477
486
|
}
|
|
478
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
|
+
/**
|
|
479
539
|
* An autosave where the collection or Single does not autosave: its owner
|
|
480
540
|
* switched autosave off, or it keeps no drafts to autosave into. Forbidden,
|
|
481
541
|
* and the message says so, since it is a setting and not a permission.
|
|
@@ -619,6 +679,19 @@ var NextlyError = class NextlyError extends Error {
|
|
|
619
679
|
logContext: opts?.logContext
|
|
620
680
|
});
|
|
621
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
|
+
}
|
|
622
695
|
static serviceUnavailable(opts) {
|
|
623
696
|
return new NextlyError({
|
|
624
697
|
code: "SERVICE_UNAVAILABLE",
|
|
@@ -708,7 +781,7 @@ function ipv4ToInt(ip) {
|
|
|
708
781
|
}
|
|
709
782
|
return acc >>> 0;
|
|
710
783
|
}
|
|
711
|
-
// ../nextly/dist/validate-external-url-
|
|
784
|
+
// ../nextly/dist/validate-external-url-DpPuwVvV.mjs
|
|
712
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)$/;
|
|
713
786
|
/**
|
|
714
787
|
* IPv4 CIDR ranges that must NEVER be the destination of an outbound
|