@nextlyhq/storage-vercel-blob 0.0.2-alpha.65 → 0.0.2-alpha.67
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/README.md +5 -5
- package/dist/index.cjs +124 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +124 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { put, del, head, BlobNotFoundError, list } from '@vercel/blob';
|
|
|
2
2
|
|
|
3
3
|
// src/adapter.ts
|
|
4
4
|
|
|
5
|
-
// ../nextly/dist/chunk-
|
|
5
|
+
// ../nextly/dist/chunk-UF2PDDU4.mjs
|
|
6
6
|
function isDbError(err) {
|
|
7
7
|
if (!err || typeof err !== "object") return false;
|
|
8
8
|
const obj = err;
|
|
@@ -15,9 +15,18 @@ var NEXTLY_ERROR_STATUS = {
|
|
|
15
15
|
AUTH_INVALID_CREDENTIALS: 401,
|
|
16
16
|
TOKEN_EXPIRED: 401,
|
|
17
17
|
FORBIDDEN: 403,
|
|
18
|
+
// The password was right and the address is unverified. Distinct from
|
|
19
|
+
// AUTH_INVALID_CREDENTIALS so the login page can offer to resend the link;
|
|
20
|
+
// only a caller who proved the password ever receives it.
|
|
21
|
+
EMAIL_NOT_VERIFIED: 403,
|
|
18
22
|
// The schema builder is off in this environment (production by default).
|
|
19
23
|
// Separate from FORBIDDEN: the caller's permissions are not the problem.
|
|
20
24
|
BUILDER_DISABLED: 403,
|
|
25
|
+
// A cookie-authenticated write whose origin or CSRF token did not check
|
|
26
|
+
// out. Separate from FORBIDDEN for the same reason: the caller may hold
|
|
27
|
+
// every permission, and a client can recover by reloading, not by asking
|
|
28
|
+
// an administrator for access.
|
|
29
|
+
CSRF_FAILED: 403,
|
|
21
30
|
NOT_FOUND: 404,
|
|
22
31
|
CONFLICT: 409,
|
|
23
32
|
DUPLICATE: 409,
|
|
@@ -77,20 +86,33 @@ var NEXTLY_ERROR_STATUS = {
|
|
|
77
86
|
NEXTLY_CORE_DESTRUCTIVE_REFUSED: 409,
|
|
78
87
|
NEXTLY_MIGRATION_DRIFT: 409,
|
|
79
88
|
NEXTLY_MIGRATION_APPLY_FAILED: 500,
|
|
80
|
-
//
|
|
89
|
+
// A SQLite migration unit would leave a row referencing a row that does
|
|
90
|
+
// not exist, or could not switch foreign-key enforcement off to run.
|
|
91
|
+
NEXTLY_MIGRATION_FOREIGN_KEY_VIOLATION: 409,
|
|
92
|
+
// A migration unit marked to run outside a transaction failed part-way;
|
|
93
|
+
// the statements before the failing one stayed applied.
|
|
94
|
+
NEXTLY_MIGRATION_PARTIALLY_APPLIED: 500,
|
|
95
|
+
// Another run recorded the same migration applied, or rolled back, while
|
|
96
|
+
// this one was running it: this run's ledger write lost, and its work is
|
|
97
|
+
// rolled back wherever the transaction can undo it.
|
|
98
|
+
NEXTLY_MIGRATION_CONCURRENT_RUN: 409,
|
|
99
|
+
// `nextly migrate:resolve`, the recovery command.
|
|
81
100
|
NEXTLY_MIGRATION_FILE_MISSING: 404,
|
|
82
101
|
NEXTLY_MIGRATION_SNAPSHOT_MISSING: 404,
|
|
83
102
|
NEXTLY_MIGRATION_RESOLVE_DRIFT: 409,
|
|
84
103
|
NEXTLY_MIGRATION_RESOLVE_PRECONDITION: 409,
|
|
85
|
-
//
|
|
104
|
+
// The Builder's UI schema.
|
|
86
105
|
NEXTLY_UI_SCHEMA_INVALID: 400,
|
|
87
106
|
NEXTLY_SCHEMA_SLUG_COLLISION: 409,
|
|
88
107
|
NEXTLY_SCHEMA_RELATION_TARGET_MISSING: 400,
|
|
89
|
-
//
|
|
108
|
+
// A declared table's relation names a table or column the registry does
|
|
109
|
+
// not have once every table is registered.
|
|
110
|
+
NEXTLY_SCHEMA_RELATION_UNRESOLVED: 400,
|
|
111
|
+
// Plugin schema: `contributes.extend` and relations.
|
|
90
112
|
NEXTLY_SCHEMA_EXTEND_TARGET_UNKNOWN: 400,
|
|
91
113
|
NEXTLY_SCHEMA_EXTEND_FIELD_DUPLICATE: 409,
|
|
92
114
|
NEXTLY_SCHEMA_CROSS_PLUGIN_RELATION: 409,
|
|
93
|
-
// Plugin
|
|
115
|
+
// Plugin schema: the framework remap (`.rename()`).
|
|
94
116
|
NEXTLY_SCHEMA_RENAME_UNKNOWN_TARGET: 400,
|
|
95
117
|
// Plugin platform — a declared admin.clientConfig that cannot be delivered
|
|
96
118
|
// to the browser, refused at boot rather than serialized mangled.
|
|
@@ -100,11 +122,56 @@ var NEXTLY_ERROR_STATUS = {
|
|
|
100
122
|
// `/api/admin-meta/workspace` payload: a value `JSON.stringify` throws on
|
|
101
123
|
// fails that request for every admin, not just the widget's own card.
|
|
102
124
|
NEXTLY_PLUGIN_ADMIN_WIDGET_INVALID: 500,
|
|
125
|
+
// A plugin's document view cannot be routed: a malformed or reserved path,
|
|
126
|
+
// or one two declarations claim on the same document. Refused at boot.
|
|
127
|
+
NEXTLY_PLUGIN_DOCUMENT_VIEW_INVALID: 500,
|
|
103
128
|
// Plugin platform (P0) — boot-time plugin dependency/version resolution.
|
|
104
129
|
PLUGIN_RESOLUTION_ERROR: 500,
|
|
130
|
+
// Plugin schema lifecycle. All 409: each is a state
|
|
131
|
+
// the database and the config disagree about, which retrying cannot change
|
|
132
|
+
// and an operator command resolves.
|
|
133
|
+
PLUGIN_DEPENDENCY_NOT_INSTALLED: 409,
|
|
134
|
+
PLUGIN_HAS_DEPENDENTS: 409,
|
|
135
|
+
PLUGIN_UNINSTALL_IRREVERSIBLE: 409,
|
|
136
|
+
// A full uninstall that would drop tables, run without `--yes`.
|
|
137
|
+
PLUGIN_UNINSTALL_UNCONFIRMED: 409,
|
|
138
|
+
PLUGIN_SCHEMA_BEHIND: 409,
|
|
139
|
+
PLUGIN_SCHEMA_UNINSTALLED: 409,
|
|
140
|
+
// A configured plugin `nextly plugins install` has not recorded as
|
|
141
|
+
// installed, refused at a production boot.
|
|
142
|
+
PLUGIN_NOT_INSTALLED: 409,
|
|
143
|
+
PLUGIN_DISABLED: 409,
|
|
144
|
+
// An uninstall that began and did not finish: refused at boot, and when
|
|
145
|
+
// run again the other way (with or without `--keep-data`).
|
|
146
|
+
PLUGIN_UNINSTALL_UNFINISHED: 409,
|
|
147
|
+
PLUGIN_SCHEMA_VERSION_NOT_ADVANCED: 409,
|
|
148
|
+
// A generated plugin migration that would drop a table or column the
|
|
149
|
+
// plugin's earlier modules created: a rename comes out as a drop and an add.
|
|
150
|
+
PLUGIN_MIGRATION_DROPS_CREATED_SCHEMA: 409,
|
|
151
|
+
// A generated plugin migration that would add a NOT NULL column with no
|
|
152
|
+
// default to a table its earlier modules created: existing rows have no
|
|
153
|
+
// value for it.
|
|
154
|
+
PLUGIN_MIGRATION_ADDS_UNFILLABLE_COLUMN: 409,
|
|
155
|
+
// A plugin migration that changes the schema on a dialect with no
|
|
156
|
+
// statements for it: its author's SQL was never written.
|
|
157
|
+
PLUGIN_MIGRATION_SQL_MISSING: 409,
|
|
158
|
+
PLUGIN_MIGRATIONS_UNAVAILABLE: 409,
|
|
159
|
+
// A migration would drop or rename a table or column another owner holds
|
|
160
|
+
// (or, for a plugin, a table no owner row claims), or names a drop target
|
|
161
|
+
// the guard cannot read — refused for the same reason.
|
|
162
|
+
DROP_OF_FOREIGN_TABLE: 409,
|
|
163
|
+
// A plugin migration module whose content no longer matches its checksum.
|
|
164
|
+
MIGRATION_CHECKSUM_MISMATCH: 409,
|
|
105
165
|
// Plugin platform (P4) — contributes.routes collection (D25).
|
|
106
166
|
NEXTLY_ROUTE_COLLISION: 409,
|
|
107
167
|
NEXTLY_ROUTE_INVALID_PATH: 400,
|
|
168
|
+
// A root-mounted route declared where the request pipeline never reaches the
|
|
169
|
+
// root pass. 400 like an invalid path and not 409: nothing else claims the
|
|
170
|
+
// address, the declaration simply cannot be served from there.
|
|
171
|
+
NEXTLY_ROUTE_UNREACHABLE_ROOT: 400,
|
|
172
|
+
// A `mount` outside the declared union, which only an untyped caller can
|
|
173
|
+
// produce. 400 for the same reason: the declaration itself is unserveable.
|
|
174
|
+
NEXTLY_ROUTE_INVALID_MOUNT: 400,
|
|
108
175
|
// An email transport whose library is an optional peer dependency the host
|
|
109
176
|
// has not installed. 503 rather than 500: the request is not malformed and
|
|
110
177
|
// nothing is broken, the install simply cannot carry it out yet, and the
|
|
@@ -114,7 +181,16 @@ var NEXTLY_ERROR_STATUS = {
|
|
|
114
181
|
// has not installed. 503 rather than 500 for the same reason as the mail
|
|
115
182
|
// transport above: nothing is broken and the request is not malformed, the
|
|
116
183
|
// install simply cannot carry it out until one command is run.
|
|
117
|
-
NEXTLY_CONFIG_TOOLING_UNAVAILABLE: 503
|
|
184
|
+
NEXTLY_CONFIG_TOOLING_UNAVAILABLE: 503,
|
|
185
|
+
// `db.postgres.schema` names one schema and the adapter the application
|
|
186
|
+
// supplied writes to another. 500 like the other boot-time configuration
|
|
187
|
+
// refusals: no request caused it, and the fix is a change to the server's
|
|
188
|
+
// own configuration.
|
|
189
|
+
NEXTLY_POSTGRES_SCHEMA_MISMATCH: 500,
|
|
190
|
+
// `db.postgres.schema` names a schema other than `public`, which the schema
|
|
191
|
+
// push cannot yet create tables in. 500 for the same reason as the mismatch
|
|
192
|
+
// above: a boot-time refusal of the server's own configuration.
|
|
193
|
+
NEXTLY_POSTGRES_SCHEMA_UNSUPPORTED: 500
|
|
118
194
|
};
|
|
119
195
|
var CANONICAL_CODE_FOR_STATUS = [
|
|
120
196
|
"VALIDATION_ERROR",
|
|
@@ -267,6 +343,20 @@ var NextlyError = class _NextlyError extends Error {
|
|
|
267
343
|
logContext: opts?.logContext
|
|
268
344
|
});
|
|
269
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* The password was correct and the address is unverified. Thrown only once
|
|
348
|
+
* the password is proven, so only someone who holds it learns the address
|
|
349
|
+
* is unverified; every other refusal stays
|
|
350
|
+
* {@link NextlyError.invalidCredentials}.
|
|
351
|
+
*/
|
|
352
|
+
static emailNotVerified(opts) {
|
|
353
|
+
return new _NextlyError({
|
|
354
|
+
code: "EMAIL_NOT_VERIFIED",
|
|
355
|
+
publicMessage: "Verify your email address to sign in. Check your inbox for the link.",
|
|
356
|
+
logMessage: "Login refused: email not verified",
|
|
357
|
+
logContext: opts?.logContext
|
|
358
|
+
});
|
|
359
|
+
}
|
|
270
360
|
static authRequired(opts) {
|
|
271
361
|
return new _NextlyError({
|
|
272
362
|
code: "AUTH_REQUIRED",
|
|
@@ -304,6 +394,19 @@ var NextlyError = class _NextlyError extends Error {
|
|
|
304
394
|
logContext: opts?.logContext
|
|
305
395
|
});
|
|
306
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* A cookie-authenticated write refused because its origin or CSRF token did
|
|
399
|
+
* not check out. The public message names no detail of which check failed;
|
|
400
|
+
* that goes to the log through `logMessage`.
|
|
401
|
+
*/
|
|
402
|
+
static csrfFailed(opts) {
|
|
403
|
+
return new _NextlyError({
|
|
404
|
+
code: "CSRF_FAILED",
|
|
405
|
+
publicMessage: "This request could not be verified. Reload the page and try again.",
|
|
406
|
+
logMessage: opts?.logMessage,
|
|
407
|
+
logContext: opts?.logContext
|
|
408
|
+
});
|
|
409
|
+
}
|
|
307
410
|
/**
|
|
308
411
|
* A call the caller got wrong, where naming the mistake IS the value of the
|
|
309
412
|
* error.
|
|
@@ -442,7 +545,7 @@ var NextlyError = class _NextlyError extends Error {
|
|
|
442
545
|
}
|
|
443
546
|
};
|
|
444
547
|
|
|
445
|
-
// ../nextly/dist/chunk-
|
|
548
|
+
// ../nextly/dist/chunk-V6N5XUUA.mjs
|
|
446
549
|
var StorageReadTooLargeError = class extends NextlyError {
|
|
447
550
|
constructor(path, maxBytes, size) {
|
|
448
551
|
super({
|
|
@@ -460,7 +563,20 @@ var StorageReadTooLargeError = class extends NextlyError {
|
|
|
460
563
|
}
|
|
461
564
|
};
|
|
462
565
|
|
|
463
|
-
// ../nextly/dist/chunk-
|
|
566
|
+
// ../nextly/dist/chunk-FLULBGQB.mjs
|
|
567
|
+
function ipv4ToInt(ip) {
|
|
568
|
+
const parts = ip.split(".");
|
|
569
|
+
if (parts.length !== 4) return null;
|
|
570
|
+
let acc = 0;
|
|
571
|
+
for (const p of parts) {
|
|
572
|
+
const n = Number(p);
|
|
573
|
+
if (!Number.isInteger(n) || n < 0 || n > 255) return null;
|
|
574
|
+
acc = acc << 8 | n;
|
|
575
|
+
}
|
|
576
|
+
return acc >>> 0;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// ../nextly/dist/chunk-FKT4HLI3.mjs
|
|
464
580
|
var 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)$/;
|
|
465
581
|
var PRIVATE_IPV4_CIDRS = [
|
|
466
582
|
"0.0.0.0/8",
|
|
@@ -846,17 +962,6 @@ function errorCode(err) {
|
|
|
846
962
|
}
|
|
847
963
|
return void 0;
|
|
848
964
|
}
|
|
849
|
-
function ipv4ToInt(ip) {
|
|
850
|
-
const parts = ip.split(".");
|
|
851
|
-
if (parts.length !== 4) return null;
|
|
852
|
-
let acc = 0;
|
|
853
|
-
for (const p of parts) {
|
|
854
|
-
const n = Number(p);
|
|
855
|
-
if (!Number.isInteger(n) || n < 0 || n > 255) return null;
|
|
856
|
-
acc = acc << 8 | n;
|
|
857
|
-
}
|
|
858
|
-
return acc >>> 0;
|
|
859
|
-
}
|
|
860
965
|
function isIpv4InCidr(intIp, cidr) {
|
|
861
966
|
const [addr, prefixRaw] = cidr.split("/");
|
|
862
967
|
const intCidr = ipv4ToInt(addr);
|