@nextlyhq/storage-s3 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 CHANGED
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _aws_sdk_client_s3 = require("@aws-sdk/client-s3");
3
3
  let _aws_sdk_lib_storage = require("@aws-sdk/lib-storage");
4
4
  let _aws_sdk_s3_request_presigner = require("@aws-sdk/s3-request-presigner");
5
- // ../nextly/dist/nextly-error-CwDiSPDF.mjs
5
+ // ../nextly/dist/nextly-error-BLaA7N-v.mjs
6
6
  function isDbError(err) {
7
7
  if (!err || typeof err !== "object") return false;
8
8
  const obj = err;
@@ -79,6 +79,8 @@ const NEXTLY_ERROR_STATUS = {
79
79
  SETUP_TOKEN_REQUIRED: 403,
80
80
  API_KEY_ROLE_ABOVE_CREATOR: 403,
81
81
  NOT_FOUND: 404,
82
+ ENTITY_REMOVED_FROM_CODE: 409,
83
+ ENTITY_NOT_MIGRATED: 409,
82
84
  METHOD_NOT_ALLOWED: 405,
83
85
  RANGE_NOT_SATISFIABLE: 416,
84
86
  CONFLICT: 409,
@@ -92,6 +94,7 @@ const NEXTLY_ERROR_STATUS = {
92
94
  DATABASE_BUSY: 503,
93
95
  EXTERNAL_SERVICE_ERROR: 502,
94
96
  SERVICE_UNAVAILABLE: 503,
97
+ CONFIGURATION_ERROR: 500,
95
98
  EXTERNAL_URL_BLOCKED: 400,
96
99
  EXTERNAL_REQUEST_FAILED: 502,
97
100
  FILENAME_INVALID: 400,
@@ -133,7 +136,7 @@ const NEXTLY_ERROR_STATUS = {
133
136
  NEXTLY_SCHEMA_RENAME_UNKNOWN_TARGET: 400,
134
137
  NEXTLY_PLUGIN_CLIENT_CONFIG_INVALID: 500,
135
138
  NEXTLY_PLUGIN_ADMIN_WIDGET_INVALID: 500,
136
- NEXTLY_ADMIN_COMPONENT_MAP_STALE: 500,
139
+ NEXTLY_PLUGIN_REMOVED_WIDGET_CHANNEL: 500,
137
140
  NEXTLY_PLUGIN_DOCUMENT_VIEW_INVALID: 500,
138
141
  PLUGIN_RESOLUTION_ERROR: 500,
139
142
  PLUGIN_DEPENDENCY_NOT_INSTALLED: 409,
@@ -415,6 +418,61 @@ var NextlyError = class NextlyError extends Error {
415
418
  });
416
419
  }
417
420
  /**
421
+ * Something only a signed-in person can do, asked by a caller that is not
422
+ * one: an API key, or a request acting as no person. Forbidden, and the
423
+ * message says so, since it is about what kind of caller asked, not about
424
+ * the caller's permissions. `doing` completes "Only a signed-in person can".
425
+ */
426
+ static personOnly(opts) {
427
+ return new NextlyError({
428
+ code: "FORBIDDEN",
429
+ publicMessage: `Only a signed-in person can ${opts.doing}.`,
430
+ logContext: opts.logContext
431
+ });
432
+ }
433
+ /**
434
+ * A role or permission built into Nextly, which is never changed or
435
+ * deleted. Forbidden, and the message says so: it is a fact about the role,
436
+ * not about the caller's permissions.
437
+ */
438
+ static builtIn(opts) {
439
+ const done = {
440
+ change: "changed",
441
+ delete: "deleted",
442
+ assign: "assigned",
443
+ inherit: "inherited"
444
+ }[opts.change];
445
+ return new NextlyError({
446
+ code: "FORBIDDEN",
447
+ publicMessage: `This ${opts.thing} is built in, so it can't be ${done}.`,
448
+ logContext: opts.logContext
449
+ });
450
+ }
451
+ /**
452
+ * A request from a site not allowed to make it: its own `Origin` names a
453
+ * site the installation does not allow. Forbidden, and the message says so;
454
+ * the origin is the caller's own, so naming its kind tells them nothing.
455
+ */
456
+ static originRefused(opts) {
457
+ return new NextlyError({
458
+ code: "FORBIDDEN",
459
+ publicMessage: "This request came from a site that isn't allowed to make it.",
460
+ logContext: opts?.logContext
461
+ });
462
+ }
463
+ /**
464
+ * A Single deleted without `force`: Singles hold a site's lasting settings,
465
+ * so they are not deleted from here, only by an admin or CLI clean-up that
466
+ * passes `force`. Forbidden, and the message says so.
467
+ */
468
+ static singleNotDeletable(opts) {
469
+ return new NextlyError({
470
+ code: "FORBIDDEN",
471
+ publicMessage: "A Single can't be deleted from here.",
472
+ logContext: opts?.logContext
473
+ });
474
+ }
475
+ /**
418
476
  * A collection, Single or component defined in code, which is changed by
419
477
  * changing its code and not from here. Forbidden, and the message says so:
420
478
  * it is a fact about the thing, not about the caller's permissions, so it
@@ -429,6 +487,57 @@ var NextlyError = class NextlyError extends Error {
429
487
  });
430
488
  }
431
489
  /**
490
+ * A write to an entry of a collection or Single removed from code: its
491
+ * registry row says the app's code defines it, and the running configuration
492
+ * no longer declares it. Its entries are read-only until it is retired or
493
+ * declared again, so the message names the entity, says what happened and
494
+ * gives both ways out. `publicData` carries the kind and the slug, which the
495
+ * caller named, so a client can mark the entity without parsing the sentence.
496
+ */
497
+ static removedFromCode(opts) {
498
+ const thing = opts.kind === "single" ? "Single" : "collection";
499
+ const its = opts.kind === "single" ? "it" : "its entries";
500
+ return new NextlyError({
501
+ code: "ENTITY_REMOVED_FROM_CODE",
502
+ 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.`,
503
+ publicData: {
504
+ kind: opts.kind,
505
+ slug: opts.slug
506
+ },
507
+ logContext: {
508
+ kind: opts.kind,
509
+ slug: opts.slug,
510
+ ...opts.logContext
511
+ }
512
+ });
513
+ }
514
+ /**
515
+ * A read or write of a collection or Single the database has not been
516
+ * migrated for: the column of one of its declared fields is missing, its
517
+ * table is missing, or this running instance never registered it (an
518
+ * entity a migration added after the instance started). The message names
519
+ * the entity, the field or the table, and `nextly migrate`; the driver's
520
+ * error stays on `cause`, for the log, so no SQL reaches the answer.
521
+ */
522
+ static notMigrated(opts) {
523
+ const { cause, logContext, ...publicData } = opts;
524
+ const entity = `${publicData.kind === "single" ? "Single" : "collection"} "${publicData.slug}"`;
525
+ const field = publicData.field === void 0 ? "a field" : `the field "${publicData.field}"`;
526
+ const table = publicData.table === void 0 ? "" : ` "${publicData.table}"`;
527
+ 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.`;
528
+ return new NextlyError({
529
+ code: "ENTITY_NOT_MIGRATED",
530
+ publicMessage,
531
+ publicData,
532
+ logMessage: "The database has not been migrated for this entity",
533
+ logContext: {
534
+ ...publicData,
535
+ ...logContext
536
+ },
537
+ cause
538
+ });
539
+ }
540
+ /**
432
541
  * An autosave where the collection or Single does not autosave: its owner
433
542
  * switched autosave off, or it keeps no drafts to autosave into. Forbidden,
434
543
  * and the message says so, since it is a setting and not a permission.
@@ -572,6 +681,19 @@ var NextlyError = class NextlyError extends Error {
572
681
  logContext: opts?.logContext
573
682
  });
574
683
  }
684
+ /**
685
+ * The app is set up so nextly cannot work: a missing `config`, or a Next.js
686
+ * or React outside the supported ranges. The public message stays generic;
687
+ * what to change goes in `logMessage`, for the operator.
688
+ */
689
+ static configuration(opts) {
690
+ return new NextlyError({
691
+ code: "CONFIGURATION_ERROR",
692
+ publicMessage: "Server configuration error.",
693
+ logMessage: opts.logMessage,
694
+ logContext: opts.logContext
695
+ });
696
+ }
575
697
  static serviceUnavailable(opts) {
576
698
  return new NextlyError({
577
699
  code: "SERVICE_UNAVAILABLE",
@@ -644,7 +766,7 @@ var NextlyError = class NextlyError extends Error {
644
766
  return NextlyError.isCode(err, "RATE_LIMITED");
645
767
  }
646
768
  };
647
- // ../nextly/dist/validate-external-url-CnZrcJdP.mjs
769
+ // ../nextly/dist/validate-external-url-DpPuwVvV.mjs
648
770
  /** Default response body cap: reject anything larger before buffering it all. */
649
771
  /**
650
772
  * How many bytes a bounded external read may buffer, absent a caller's own cap.