@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.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-CwDiSPDF.mjs
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
- NEXTLY_ADMIN_COMPONENT_MAP_STALE: 500,
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,
@@ -414,6 +417,61 @@ var NextlyError = class NextlyError extends Error {
414
417
  });
415
418
  }
416
419
  /**
420
+ * Something only a signed-in person can do, asked by a caller that is not
421
+ * one: an API key, or a request acting as no person. Forbidden, and the
422
+ * message says so, since it is about what kind of caller asked, not about
423
+ * the caller's permissions. `doing` completes "Only a signed-in person can".
424
+ */
425
+ static personOnly(opts) {
426
+ return new NextlyError({
427
+ code: "FORBIDDEN",
428
+ publicMessage: `Only a signed-in person can ${opts.doing}.`,
429
+ logContext: opts.logContext
430
+ });
431
+ }
432
+ /**
433
+ * A role or permission built into Nextly, which is never changed or
434
+ * deleted. Forbidden, and the message says so: it is a fact about the role,
435
+ * not about the caller's permissions.
436
+ */
437
+ static builtIn(opts) {
438
+ const done = {
439
+ change: "changed",
440
+ delete: "deleted",
441
+ assign: "assigned",
442
+ inherit: "inherited"
443
+ }[opts.change];
444
+ return new NextlyError({
445
+ code: "FORBIDDEN",
446
+ publicMessage: `This ${opts.thing} is built in, so it can't be ${done}.`,
447
+ logContext: opts.logContext
448
+ });
449
+ }
450
+ /**
451
+ * A request from a site not allowed to make it: its own `Origin` names a
452
+ * site the installation does not allow. Forbidden, and the message says so;
453
+ * the origin is the caller's own, so naming its kind tells them nothing.
454
+ */
455
+ static originRefused(opts) {
456
+ return new NextlyError({
457
+ code: "FORBIDDEN",
458
+ publicMessage: "This request came from a site that isn't allowed to make it.",
459
+ logContext: opts?.logContext
460
+ });
461
+ }
462
+ /**
463
+ * A Single deleted without `force`: Singles hold a site's lasting settings,
464
+ * so they are not deleted from here, only by an admin or CLI clean-up that
465
+ * passes `force`. Forbidden, and the message says so.
466
+ */
467
+ static singleNotDeletable(opts) {
468
+ return new NextlyError({
469
+ code: "FORBIDDEN",
470
+ publicMessage: "A Single can't be deleted from here.",
471
+ logContext: opts?.logContext
472
+ });
473
+ }
474
+ /**
417
475
  * A collection, Single or component defined in code, which is changed by
418
476
  * changing its code and not from here. Forbidden, and the message says so:
419
477
  * it is a fact about the thing, not about the caller's permissions, so it
@@ -428,6 +486,57 @@ var NextlyError = class NextlyError extends Error {
428
486
  });
429
487
  }
430
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
+ /**
431
540
  * An autosave where the collection or Single does not autosave: its owner
432
541
  * switched autosave off, or it keeps no drafts to autosave into. Forbidden,
433
542
  * and the message says so, since it is a setting and not a permission.
@@ -571,6 +680,19 @@ var NextlyError = class NextlyError extends Error {
571
680
  logContext: opts?.logContext
572
681
  });
573
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
+ }
574
696
  static serviceUnavailable(opts) {
575
697
  return new NextlyError({
576
698
  code: "SERVICE_UNAVAILABLE",
@@ -643,7 +765,7 @@ var NextlyError = class NextlyError extends Error {
643
765
  return NextlyError.isCode(err, "RATE_LIMITED");
644
766
  }
645
767
  };
646
- // ../nextly/dist/validate-external-url-CnZrcJdP.mjs
768
+ // ../nextly/dist/validate-external-url-DpPuwVvV.mjs
647
769
  /** Default response body cap: reject anything larger before buffering it all. */
648
770
  /**
649
771
  * How many bytes a bounded external read may buffer, absent a caller's own cap.