@nextlyhq/storage-s3 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.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DeleteObjectCommand, DeleteObjectsCommand, GetObjectCommand, HeadObjectCommand, ListObjectsV2Command, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
2
2
|
import { Upload } from "@aws-sdk/lib-storage";
|
|
3
3
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
4
|
-
// ../nextly/dist/nextly-error-
|
|
4
|
+
// ../nextly/dist/nextly-error-BLaA7N-v.mjs
|
|
5
5
|
function isDbError(err) {
|
|
6
6
|
if (!err || typeof err !== "object") return false;
|
|
7
7
|
const obj = err;
|
|
@@ -78,6 +78,8 @@ const NEXTLY_ERROR_STATUS = {
|
|
|
78
78
|
SETUP_TOKEN_REQUIRED: 403,
|
|
79
79
|
API_KEY_ROLE_ABOVE_CREATOR: 403,
|
|
80
80
|
NOT_FOUND: 404,
|
|
81
|
+
ENTITY_REMOVED_FROM_CODE: 409,
|
|
82
|
+
ENTITY_NOT_MIGRATED: 409,
|
|
81
83
|
METHOD_NOT_ALLOWED: 405,
|
|
82
84
|
RANGE_NOT_SATISFIABLE: 416,
|
|
83
85
|
CONFLICT: 409,
|
|
@@ -91,6 +93,7 @@ const NEXTLY_ERROR_STATUS = {
|
|
|
91
93
|
DATABASE_BUSY: 503,
|
|
92
94
|
EXTERNAL_SERVICE_ERROR: 502,
|
|
93
95
|
SERVICE_UNAVAILABLE: 503,
|
|
96
|
+
CONFIGURATION_ERROR: 500,
|
|
94
97
|
EXTERNAL_URL_BLOCKED: 400,
|
|
95
98
|
EXTERNAL_REQUEST_FAILED: 502,
|
|
96
99
|
FILENAME_INVALID: 400,
|
|
@@ -132,7 +135,7 @@ const NEXTLY_ERROR_STATUS = {
|
|
|
132
135
|
NEXTLY_SCHEMA_RENAME_UNKNOWN_TARGET: 400,
|
|
133
136
|
NEXTLY_PLUGIN_CLIENT_CONFIG_INVALID: 500,
|
|
134
137
|
NEXTLY_PLUGIN_ADMIN_WIDGET_INVALID: 500,
|
|
135
|
-
|
|
138
|
+
NEXTLY_PLUGIN_REMOVED_WIDGET_CHANNEL: 500,
|
|
136
139
|
NEXTLY_PLUGIN_DOCUMENT_VIEW_INVALID: 500,
|
|
137
140
|
PLUGIN_RESOLUTION_ERROR: 500,
|
|
138
141
|
PLUGIN_DEPENDENCY_NOT_INSTALLED: 409,
|
|
@@ -432,9 +435,15 @@ var NextlyError = class NextlyError extends Error {
|
|
|
432
435
|
* not about the caller's permissions.
|
|
433
436
|
*/
|
|
434
437
|
static builtIn(opts) {
|
|
438
|
+
const done = {
|
|
439
|
+
change: "changed",
|
|
440
|
+
delete: "deleted",
|
|
441
|
+
assign: "assigned",
|
|
442
|
+
inherit: "inherited"
|
|
443
|
+
}[opts.change];
|
|
435
444
|
return new NextlyError({
|
|
436
445
|
code: "FORBIDDEN",
|
|
437
|
-
publicMessage: `This ${opts.thing} is built in, so it can't be ${
|
|
446
|
+
publicMessage: `This ${opts.thing} is built in, so it can't be ${done}.`,
|
|
438
447
|
logContext: opts.logContext
|
|
439
448
|
});
|
|
440
449
|
}
|
|
@@ -477,6 +486,57 @@ var NextlyError = class NextlyError extends Error {
|
|
|
477
486
|
});
|
|
478
487
|
}
|
|
479
488
|
/**
|
|
489
|
+
* A write to an entry of a collection or Single removed from code: its
|
|
490
|
+
* registry row says the app's code defines it, and the running configuration
|
|
491
|
+
* no longer declares it. Its entries are read-only until it is retired or
|
|
492
|
+
* declared again, so the message names the entity, says what happened and
|
|
493
|
+
* gives both ways out. `publicData` carries the kind and the slug, which the
|
|
494
|
+
* caller named, so a client can mark the entity without parsing the sentence.
|
|
495
|
+
*/
|
|
496
|
+
static removedFromCode(opts) {
|
|
497
|
+
const thing = opts.kind === "single" ? "Single" : "collection";
|
|
498
|
+
const its = opts.kind === "single" ? "it" : "its entries";
|
|
499
|
+
return new NextlyError({
|
|
500
|
+
code: "ENTITY_REMOVED_FROM_CODE",
|
|
501
|
+
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.`,
|
|
502
|
+
publicData: {
|
|
503
|
+
kind: opts.kind,
|
|
504
|
+
slug: opts.slug
|
|
505
|
+
},
|
|
506
|
+
logContext: {
|
|
507
|
+
kind: opts.kind,
|
|
508
|
+
slug: opts.slug,
|
|
509
|
+
...opts.logContext
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* A read or write of a collection or Single the database has not been
|
|
515
|
+
* migrated for: the column of one of its declared fields is missing, its
|
|
516
|
+
* table is missing, or this running instance never registered it (an
|
|
517
|
+
* entity a migration added after the instance started). The message names
|
|
518
|
+
* the entity, the field or the table, and `nextly migrate`; the driver's
|
|
519
|
+
* error stays on `cause`, for the log, so no SQL reaches the answer.
|
|
520
|
+
*/
|
|
521
|
+
static notMigrated(opts) {
|
|
522
|
+
const { cause, logContext, ...publicData } = opts;
|
|
523
|
+
const entity = `${publicData.kind === "single" ? "Single" : "collection"} "${publicData.slug}"`;
|
|
524
|
+
const field = publicData.field === void 0 ? "a field" : `the field "${publicData.field}"`;
|
|
525
|
+
const table = publicData.table === void 0 ? "" : ` "${publicData.table}"`;
|
|
526
|
+
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.`;
|
|
527
|
+
return new NextlyError({
|
|
528
|
+
code: "ENTITY_NOT_MIGRATED",
|
|
529
|
+
publicMessage,
|
|
530
|
+
publicData,
|
|
531
|
+
logMessage: "The database has not been migrated for this entity",
|
|
532
|
+
logContext: {
|
|
533
|
+
...publicData,
|
|
534
|
+
...logContext
|
|
535
|
+
},
|
|
536
|
+
cause
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
480
540
|
* An autosave where the collection or Single does not autosave: its owner
|
|
481
541
|
* switched autosave off, or it keeps no drafts to autosave into. Forbidden,
|
|
482
542
|
* and the message says so, since it is a setting and not a permission.
|
|
@@ -620,6 +680,19 @@ var NextlyError = class NextlyError extends Error {
|
|
|
620
680
|
logContext: opts?.logContext
|
|
621
681
|
});
|
|
622
682
|
}
|
|
683
|
+
/**
|
|
684
|
+
* The app is set up so nextly cannot work: a missing `config`, or a Next.js
|
|
685
|
+
* or React outside the supported ranges. The public message stays generic;
|
|
686
|
+
* what to change goes in `logMessage`, for the operator.
|
|
687
|
+
*/
|
|
688
|
+
static configuration(opts) {
|
|
689
|
+
return new NextlyError({
|
|
690
|
+
code: "CONFIGURATION_ERROR",
|
|
691
|
+
publicMessage: "Server configuration error.",
|
|
692
|
+
logMessage: opts.logMessage,
|
|
693
|
+
logContext: opts.logContext
|
|
694
|
+
});
|
|
695
|
+
}
|
|
623
696
|
static serviceUnavailable(opts) {
|
|
624
697
|
return new NextlyError({
|
|
625
698
|
code: "SERVICE_UNAVAILABLE",
|
|
@@ -692,7 +765,7 @@ var NextlyError = class NextlyError extends Error {
|
|
|
692
765
|
return NextlyError.isCode(err, "RATE_LIMITED");
|
|
693
766
|
}
|
|
694
767
|
};
|
|
695
|
-
// ../nextly/dist/validate-external-url-
|
|
768
|
+
// ../nextly/dist/validate-external-url-DpPuwVvV.mjs
|
|
696
769
|
/** Default response body cap: reject anything larger before buffering it all. */
|
|
697
770
|
/**
|
|
698
771
|
* How many bytes a bounded external read may buffer, absent a caller's own cap.
|