Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecated directory. prefix should be used instead #1370

Merged
merged 4 commits into from Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/bucket.ts
Expand Up @@ -113,7 +113,7 @@ export interface EnableLoggingOptions {
export interface GetFilesOptions {
autoPaginate?: boolean;
delimiter?: string;
directory?: string;
directory?: string; //deprecated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the recommended approach to declare deprecation in an interface? I don't see another example in the project that deprecates this way, and want to confirm.

endOffset?: string;
includeTrailingDelimiter?: boolean;
prefix?: string;
Expand Down Expand Up @@ -2195,8 +2195,8 @@ class Bucket extends ServiceObject {
* names, aside from the prefix, contain delimiter will have their name
* truncated after the delimiter, returned in `apiResponse.prefixes`.
* Duplicate prefixes are omitted.
* @property {string} [directory] Filter results based on a directory name, or
* more technically, a "prefix".
* @deprecated @property {string} [directory] Filter results based on a directory name, or
* more technically, a "prefix". Deprecated. Use prefix instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a note that directory uses delimiter='/' in case folks get confused.

Recommend including an example of using prefix and delimiter below to reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Frank, this example includes prefix and delimiter. Are you looking for something different?

* @property {string} [endOffset] Filter results to objects whose names are
* lexicographically before endOffset. If startOffset is also set, the objects
* listed have names between startOffset (inclusive) and endOffset (exclusive).
Expand Down Expand Up @@ -2235,8 +2235,8 @@ class Bucket extends ServiceObject {
* names, aside from the prefix, contain delimiter will have their name
* truncated after the delimiter, returned in `apiResponse.prefixes`.
* Duplicate prefixes are omitted.
* @param {string} [query.directory] Filter results based on a directory name, or
* more technically, a "prefix".
* @deprecated @param {string} [query.directory] Filter results based on a directory name, or
* more technically, a "prefix". Deprecated. Use query.prefix instead.
* @param {string} [query.endOffset] Filter results to objects whose names are
* lexicographically before endOffset. If startOffset is also set, the objects
* listed have names between startOffset (inclusive) and endOffset (exclusive).
Expand Down
2 changes: 2 additions & 0 deletions system-test/storage.ts
Expand Up @@ -3150,6 +3150,7 @@ describe('storage', () => {
});

it('should get files from a directory', done => {
//Note: Directory is deprecated.
bucket.getFiles({directory: DIRECTORY_NAME}, (err, files) => {
assert.ifError(err);
assert.strictEqual(files!.length, 3);
Expand All @@ -3158,6 +3159,7 @@ describe('storage', () => {
});

it('should get files from a directory as a stream', done => {
//Note: Directory is deprecated.
let numFilesEmitted = 0;

bucket
Expand Down
2 changes: 2 additions & 0 deletions test/bucket.ts
Expand Up @@ -1478,6 +1478,7 @@ describe('Bucket', () => {
});

it('should allow setting a directory', done => {
//Note: Directory is deprecated.
const directory = 'directory-name';
bucket.request = (reqOpts: DecorateRequestOptions) => {
assert.strictEqual(reqOpts.qs.prefix, `${directory}/`);
Expand All @@ -1488,6 +1489,7 @@ describe('Bucket', () => {
});

it('should strip excess slashes from a directory', done => {
//Note: Directory is deprecated.
const directory = 'directory-name///';
bucket.request = (reqOpts: DecorateRequestOptions) => {
assert.strictEqual(reqOpts.qs.prefix, 'directory-name/');
Expand Down