Skip to content

Commit

Permalink
deprecate old poperties (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssanjay1 authored Jun 17, 2024
1 parent 111f928 commit 4b87220
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ describe("AttachmentsTest", () => {
blob,
);
const attachment = assertOkOrThrow(result);
const result2: Result<Blob, AttachmentsError> = await attachment.read();
const result2: Result<Blob, AttachmentsError> = await attachment
.fetchContents();
const attachmentContent = assertOkOrThrow(result2);
const attachmentContentText = await attachmentContent.text();
expect(JSON.parse(attachmentContentText)).toEqual({
Expand Down Expand Up @@ -93,7 +94,7 @@ describe("AttachmentsTest", () => {
);
const obj = assertOkOrThrow(result);
const result2: Result<AttachmentMetadata, AttachmentsError> | undefined =
await obj.attachment?.getMetadata();
await obj.attachment?.fetchMetadata();
const attachmentMetadata = assertOkOrThrow(result2!);

expect(attachmentMetadata.filename).toEqual("file1.txt");
Expand All @@ -111,7 +112,7 @@ describe("AttachmentsTest", () => {
);
const obj = assertOkOrThrow(result);
const result2: Result<AttachmentMetadata, AttachmentsError> | undefined =
await obj.attachment2?.getMetadata();
await obj.attachment2?.fetchMetadata();
const attachmentError = assertErrOrThrow(result2!);

expect(attachmentError).toBeDefined();
Expand All @@ -125,7 +126,7 @@ describe("AttachmentsTest", () => {
);
const obj = assertOkOrThrow(result);
const result2: Result<Blob, AttachmentsError> | undefined = await obj
.attachment?.read();
.attachment?.fetchContents();
const attachmentContent = assertOkOrThrow(result2!);

const attachmentContentText = await attachmentContent.text();
Expand All @@ -141,7 +142,7 @@ describe("AttachmentsTest", () => {
);
const obj = assertOkOrThrow(result);
const result2: Result<Blob, AttachmentsError> | undefined = await obj
.attachment2?.read();
.attachment2?.fetchContents();
const attachmentError = assertErrOrThrow(result2!);

expect(attachmentError).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@ export interface Attachment {
type: "Attachment";
attachmentRid: string | undefined;
/**
* @deprecated
* Get the metadata of an attachment.
*/
getMetadata(): Promise<Result<AttachmentMetadata, AttachmentsError>>;
/**
* @deprecated
* Read the content of an attachment.
*/
read(): Promise<Result<Blob, AttachmentsError>>;
/**
* Get the metadata of an attachment.
*/
fetchMetadata(): Promise<Result<AttachmentMetadata, AttachmentsError>>;
/**
* Read the content of an attachment.
*/
fetchContents(): Promise<Result<Blob, AttachmentsError>>;
}

export interface AttachmentMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ export const AttachmentProperty = (
read() {
return getAttachment(clientCtx, attachmentRid);
},
fetchMetadata() {
return getAttachmentMetadata(clientCtx, attachmentRid);
},
fetchContents() {
return getAttachment(clientCtx, attachmentRid);
},
};
};

0 comments on commit 4b87220

Please sign in to comment.