@remit/mailbox-service 0.0.106 → 0.0.107

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/mailbox-service",
3
- "version": "0.0.106",
3
+ "version": "0.0.107",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -70,6 +70,14 @@ describe("loadOutboxAttachmentContents", () => {
70
70
  );
71
71
  });
72
72
 
73
+ it("gives each file the content-id its reservation handed out", async () => {
74
+ const deps = await setup([row("shot")], ["shot"]);
75
+
76
+ const [content] = await loadOutboxAttachmentContents(deps, OWNER, NOW);
77
+
78
+ assert.equal(content.cid, "shot@remit");
79
+ });
80
+
73
81
  it("leaves out a reservation that lapsed without its bytes", async () => {
74
82
  const deps = await setup(
75
83
  [
@@ -6,8 +6,12 @@ export interface OutboxAttachmentContent {
6
6
  filename: string;
7
7
  contentType: string;
8
8
  content: Buffer;
9
+ cid: string;
9
10
  }
10
11
 
12
+ export const outboxAttachmentContentId = (outboxAttachmentId: string): string =>
13
+ `${outboxAttachmentId}@remit`;
14
+
11
15
  /**
12
16
  * A file on a message that cannot be put into it. Carries the file's name so
13
17
  * whoever settles the message can tell the sender which file to fix.
@@ -93,6 +97,7 @@ export const loadOutboxAttachmentContents = async (
93
97
  filename: item.filename,
94
98
  contentType: item.contentType,
95
99
  content,
100
+ cid: outboxAttachmentContentId(item.outboxAttachmentId),
96
101
  };
97
102
  }),
98
103
  );
@@ -224,6 +224,23 @@ describe("reserving room on a draft", () => {
224
224
  assert.ok(row?.storageKey.endsWith(result.reservation.outboxAttachmentId));
225
225
  });
226
226
 
227
+ it("names the content-id a body can refer to the file by", async () => {
228
+ const { service } = build();
229
+
230
+ const result = await mint(service, {
231
+ filename: "shot.png",
232
+ contentType: "image/png",
233
+ sizeBytes: 64,
234
+ });
235
+
236
+ assert.equal(result.outcome, "Minted");
237
+ if (result.outcome !== "Minted") return;
238
+ assert.equal(
239
+ result.reservation.contentId,
240
+ `${result.reservation.outboxAttachmentId}@remit`,
241
+ );
242
+ });
243
+
227
244
  it("refuses a declared size over the cap", async () => {
228
245
  const { service } = build();
229
246
 
@@ -16,6 +16,7 @@ import {
16
16
  import {
17
17
  loadOutboxAttachmentContents,
18
18
  type OutboxAttachmentContent,
19
+ outboxAttachmentContentId,
19
20
  } from "./outbox-attachment-content.js";
20
21
  import {
21
22
  normalizeAttachmentContentType,
@@ -45,6 +46,7 @@ export interface OutboxAttachmentReservation {
45
46
  filename: string;
46
47
  contentType: string;
47
48
  sizeBytes: number;
49
+ contentId: string;
48
50
  uploadUrl: string;
49
51
  uploadExpiresAt: number;
50
52
  }
@@ -271,6 +273,7 @@ export class OutboxAttachmentService {
271
273
  filename: reserved.item.filename,
272
274
  contentType: reserved.item.contentType,
273
275
  sizeBytes: reserved.item.sizeBytes,
276
+ contentId: outboxAttachmentContentId(reserved.item.outboxAttachmentId),
274
277
  uploadUrl: target.uploadUrl,
275
278
  uploadExpiresAt: reservationExpiresAt,
276
279
  },