feat: add lastModifiedAt to UrlReader methods

Signed-off-by: Andrew Thauer <athauer@wealthsimple.com>
This commit is contained in:
Andrew Thauer
2023-03-13 16:06:08 -04:00
parent 80698c1de8
commit c1ee073a82
27 changed files with 477 additions and 27 deletions
@@ -359,11 +359,13 @@ export type ReadTreeResponseDirOptions = {
export type ReadTreeResponseFile = {
path: string;
content(): Promise<Buffer>;
lastModifiedAt?: Date;
};
// @public
export type ReadUrlOptions = {
etag?: string;
lastModifiedAfter?: Date;
signal?: AbortSignal;
};
@@ -372,6 +374,7 @@ export type ReadUrlResponse = {
buffer(): Promise<Buffer>;
stream?(): Readable;
etag?: string;
lastModifiedAt?: Date;
};
// @public (undocumented)
@@ -420,6 +423,7 @@ export type SearchResponse = {
export type SearchResponseFile = {
url: string;
content(): Promise<Buffer>;
lastModifiedAt?: Date;
};
// @public (undocumented)
@@ -64,6 +64,26 @@ export type ReadUrlOptions = {
*/
etag?: string;
/**
* A date which can be provided to check whether a
* {@link UrlReaderService.readUrl} response has changed since the lastModifiedAt.
*
* @remarks
*
* In the {@link UrlReaderService.readUrl} response, an lastModifiedAt is returned
* along with data. The lastModifiedAt date represents the last time the data
* was modified.
*
* When an lastModifiedAfter is given in ReadUrlOptions, {@link UrlReaderService.readUrl}
* will compare the lastModifiedAfter against the lastModifiedAt of the target. If
* the data has not been modified since this date, the {@link UrlReaderService.readUrl}
* will throw a {@link @backstage/errors#NotModifiedError} indicating that the
* response does not contain any new data. If they do not match,
* {@link UrlReaderService.readUrl} will return the rest of the response along with new
* lastModifiedAt date.
*/
lastModifiedAfter?: Date;
/**
* An abort signal to pass down to the underlying request.
*
@@ -102,6 +122,11 @@ export type ReadUrlResponse = {
* Can be used to compare and cache responses when doing subsequent calls.
*/
etag?: string;
/**
* Last modified date of the file contents.
*/
lastModifiedAt?: Date;
};
/**
@@ -213,8 +238,20 @@ export type ReadTreeResponse = {
* @public
*/
export type ReadTreeResponseFile = {
/**
* The filepath of the data.
*/
path: string;
/**
* The binary contents of the file.
*/
content(): Promise<Buffer>;
/**
* The last modified timestamp of the data.
*/
lastModifiedAt?: Date;
};
/**
@@ -278,4 +315,9 @@ export type SearchResponseFile = {
* The binary contents of the file.
*/
content(): Promise<Buffer>;
/**
* The last modified timestamp of the data.
*/
lastModifiedAt?: Date;
};