@nextlyhq/storage-vercel-blob 0.0.2-alpha.66 → 0.0.2-alpha.68
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 +118 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +118 -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-NY7DNPQY.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,8 +122,46 @@ 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,
|
|
@@ -121,7 +181,16 @@ var NEXTLY_ERROR_STATUS = {
|
|
|
121
181
|
// has not installed. 503 rather than 500 for the same reason as the mail
|
|
122
182
|
// transport above: nothing is broken and the request is not malformed, the
|
|
123
183
|
// install simply cannot carry it out until one command is run.
|
|
124
|
-
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
|
|
125
194
|
};
|
|
126
195
|
var CANONICAL_CODE_FOR_STATUS = [
|
|
127
196
|
"VALIDATION_ERROR",
|
|
@@ -274,6 +343,20 @@ var NextlyError = class _NextlyError extends Error {
|
|
|
274
343
|
logContext: opts?.logContext
|
|
275
344
|
});
|
|
276
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
|
+
}
|
|
277
360
|
static authRequired(opts) {
|
|
278
361
|
return new _NextlyError({
|
|
279
362
|
code: "AUTH_REQUIRED",
|
|
@@ -311,6 +394,19 @@ var NextlyError = class _NextlyError extends Error {
|
|
|
311
394
|
logContext: opts?.logContext
|
|
312
395
|
});
|
|
313
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
|
+
}
|
|
314
410
|
/**
|
|
315
411
|
* A call the caller got wrong, where naming the mistake IS the value of the
|
|
316
412
|
* error.
|
|
@@ -342,6 +438,7 @@ var NextlyError = class _NextlyError extends Error {
|
|
|
342
438
|
return new _NextlyError({
|
|
343
439
|
code: "CONFLICT",
|
|
344
440
|
publicMessage: opts?.message ?? "The resource has changed since you last loaded it. Please refresh and try again.",
|
|
441
|
+
publicData: opts?.data,
|
|
345
442
|
cause: opts?.cause,
|
|
346
443
|
logContext: { reason: opts?.reason, ...opts?.logContext }
|
|
347
444
|
});
|
|
@@ -449,7 +546,7 @@ var NextlyError = class _NextlyError extends Error {
|
|
|
449
546
|
}
|
|
450
547
|
};
|
|
451
548
|
|
|
452
|
-
// ../nextly/dist/chunk-
|
|
549
|
+
// ../nextly/dist/chunk-RCQ3Z2YP.mjs
|
|
453
550
|
var StorageReadTooLargeError = class extends NextlyError {
|
|
454
551
|
constructor(path, maxBytes, size) {
|
|
455
552
|
super({
|
|
@@ -467,7 +564,20 @@ var StorageReadTooLargeError = class extends NextlyError {
|
|
|
467
564
|
}
|
|
468
565
|
};
|
|
469
566
|
|
|
470
|
-
// ../nextly/dist/chunk-
|
|
567
|
+
// ../nextly/dist/chunk-FLULBGQB.mjs
|
|
568
|
+
function ipv4ToInt(ip) {
|
|
569
|
+
const parts = ip.split(".");
|
|
570
|
+
if (parts.length !== 4) return null;
|
|
571
|
+
let acc = 0;
|
|
572
|
+
for (const p of parts) {
|
|
573
|
+
const n = Number(p);
|
|
574
|
+
if (!Number.isInteger(n) || n < 0 || n > 255) return null;
|
|
575
|
+
acc = acc << 8 | n;
|
|
576
|
+
}
|
|
577
|
+
return acc >>> 0;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// ../nextly/dist/chunk-W4ZTBBDW.mjs
|
|
471
581
|
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)$/;
|
|
472
582
|
var PRIVATE_IPV4_CIDRS = [
|
|
473
583
|
"0.0.0.0/8",
|
|
@@ -853,17 +963,6 @@ function errorCode(err) {
|
|
|
853
963
|
}
|
|
854
964
|
return void 0;
|
|
855
965
|
}
|
|
856
|
-
function ipv4ToInt(ip) {
|
|
857
|
-
const parts = ip.split(".");
|
|
858
|
-
if (parts.length !== 4) return null;
|
|
859
|
-
let acc = 0;
|
|
860
|
-
for (const p of parts) {
|
|
861
|
-
const n = Number(p);
|
|
862
|
-
if (!Number.isInteger(n) || n < 0 || n > 255) return null;
|
|
863
|
-
acc = acc << 8 | n;
|
|
864
|
-
}
|
|
865
|
-
return acc >>> 0;
|
|
866
|
-
}
|
|
867
966
|
function isIpv4InCidr(intIp, cidr) {
|
|
868
967
|
const [addr, prefixRaw] = cidr.split("/");
|
|
869
968
|
const intCidr = ipv4ToInt(addr);
|