@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 +125 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +125 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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-
|
|
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
|
-
|
|
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,
|
|
@@ -412,6 +415,61 @@ var NextlyError = class NextlyError extends Error {
|
|
|
412
415
|
});
|
|
413
416
|
}
|
|
414
417
|
/**
|
|
418
|
+
* Something only a signed-in person can do, asked by a caller that is not
|
|
419
|
+
* one: an API key, or a request acting as no person. Forbidden, and the
|
|
420
|
+
* message says so, since it is about what kind of caller asked, not about
|
|
421
|
+
* the caller's permissions. `doing` completes "Only a signed-in person can".
|
|
422
|
+
*/
|
|
423
|
+
static personOnly(opts) {
|
|
424
|
+
return new NextlyError({
|
|
425
|
+
code: "FORBIDDEN",
|
|
426
|
+
publicMessage: `Only a signed-in person can ${opts.doing}.`,
|
|
427
|
+
logContext: opts.logContext
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* A role or permission built into Nextly, which is never changed or
|
|
432
|
+
* deleted. Forbidden, and the message says so: it is a fact about the role,
|
|
433
|
+
* not about the caller's permissions.
|
|
434
|
+
*/
|
|
435
|
+
static builtIn(opts) {
|
|
436
|
+
const done = {
|
|
437
|
+
change: "changed",
|
|
438
|
+
delete: "deleted",
|
|
439
|
+
assign: "assigned",
|
|
440
|
+
inherit: "inherited"
|
|
441
|
+
}[opts.change];
|
|
442
|
+
return new NextlyError({
|
|
443
|
+
code: "FORBIDDEN",
|
|
444
|
+
publicMessage: `This ${opts.thing} is built in, so it can't be ${done}.`,
|
|
445
|
+
logContext: opts.logContext
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* A request from a site not allowed to make it: its own `Origin` names a
|
|
450
|
+
* site the installation does not allow. Forbidden, and the message says so;
|
|
451
|
+
* the origin is the caller's own, so naming its kind tells them nothing.
|
|
452
|
+
*/
|
|
453
|
+
static originRefused(opts) {
|
|
454
|
+
return new NextlyError({
|
|
455
|
+
code: "FORBIDDEN",
|
|
456
|
+
publicMessage: "This request came from a site that isn't allowed to make it.",
|
|
457
|
+
logContext: opts?.logContext
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* A Single deleted without `force`: Singles hold a site's lasting settings,
|
|
462
|
+
* so they are not deleted from here, only by an admin or CLI clean-up that
|
|
463
|
+
* passes `force`. Forbidden, and the message says so.
|
|
464
|
+
*/
|
|
465
|
+
static singleNotDeletable(opts) {
|
|
466
|
+
return new NextlyError({
|
|
467
|
+
code: "FORBIDDEN",
|
|
468
|
+
publicMessage: "A Single can't be deleted from here.",
|
|
469
|
+
logContext: opts?.logContext
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
415
473
|
* A collection, Single or component defined in code, which is changed by
|
|
416
474
|
* changing its code and not from here. Forbidden, and the message says so:
|
|
417
475
|
* it is a fact about the thing, not about the caller's permissions, so it
|
|
@@ -426,6 +484,57 @@ var NextlyError = class NextlyError extends Error {
|
|
|
426
484
|
});
|
|
427
485
|
}
|
|
428
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
|
+
/**
|
|
429
538
|
* An autosave where the collection or Single does not autosave: its owner
|
|
430
539
|
* switched autosave off, or it keeps no drafts to autosave into. Forbidden,
|
|
431
540
|
* and the message says so, since it is a setting and not a permission.
|
|
@@ -569,6 +678,19 @@ var NextlyError = class NextlyError extends Error {
|
|
|
569
678
|
logContext: opts?.logContext
|
|
570
679
|
});
|
|
571
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
|
+
}
|
|
572
694
|
static serviceUnavailable(opts) {
|
|
573
695
|
return new NextlyError({
|
|
574
696
|
code: "SERVICE_UNAVAILABLE",
|
|
@@ -658,7 +780,7 @@ function ipv4ToInt(ip) {
|
|
|
658
780
|
}
|
|
659
781
|
return acc >>> 0;
|
|
660
782
|
}
|
|
661
|
-
// ../nextly/dist/validate-external-url-
|
|
783
|
+
// ../nextly/dist/validate-external-url-DpPuwVvV.mjs
|
|
662
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)$/;
|
|
663
785
|
/**
|
|
664
786
|
* IPv4 CIDR ranges that must NEVER be the destination of an outbound
|