Skip to content

Commit

Permalink
Revert "fix(storage): omit subPathStrategy when prefix is defined (#1…
Browse files Browse the repository at this point in the history
…3614)

Revert "fix(storage): omit subPathStrategy when prefix is defined (#13606)"

This reverts commit d3b9546.
  • Loading branch information
israx authored Jul 18, 2024
1 parent d3b9546 commit 60885b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
16 changes: 6 additions & 10 deletions packages/storage/src/providers/s3/apis/internal/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ import {
resolveS3ConfigAndInput,
validateStorageOperationInputWithPrefix,
} from '../../utils';
import {
ListAllOptionsWithPath,
ListPaginateOptionsWithPath,
ResolvedS3Config,
} from '../../types/options';
import { ResolvedS3Config } from '../../types/options';
import {
ListObjectsV2Input,
ListObjectsV2Output,
Expand All @@ -34,6 +30,7 @@ import { getStorageUserAgentValue } from '../../utils/userAgent';
import { logger } from '../../../../utils';
import { DEFAULT_DELIMITER, STORAGE_INPUT_PREFIX } from '../../utils/constants';
import { CommonPrefix } from '../../utils/client/types';
import { StorageSubpathStrategy } from '../../../../types';

const MAX_PAGE_SIZE = 1000;

Expand Down Expand Up @@ -79,13 +76,12 @@ export const list = async (
} ${anyOptions?.nextToken ? `nextToken: ${anyOptions?.nextToken}` : ''}.`,
);
}

const listParams = {
Bucket: bucket,
Prefix: isInputWithPrefix ? `${generatedPrefix}${objectKey}` : objectKey,
MaxKeys: options?.listAll ? undefined : options?.pageSize,
ContinuationToken: options?.listAll ? undefined : options?.nextToken,
Delimiter: getDelimiter(options),
Delimiter: getDelimiter(options.subpathStrategy),
};
logger.debug(`listing items from "${listParams.Prefix}"`);

Expand Down Expand Up @@ -267,9 +263,9 @@ const mapCommonPrefixesToExcludedSubpaths = (
};

const getDelimiter = (
options?: ListAllOptionsWithPath | ListPaginateOptionsWithPath,
subpathStrategy?: StorageSubpathStrategy,
): string | undefined => {
if (options?.subpathStrategy?.strategy === 'exclude') {
return options?.subpathStrategy?.delimiter ?? DEFAULT_DELIMITER;
if (subpathStrategy?.strategy === 'exclude') {
return subpathStrategy?.delimiter ?? DEFAULT_DELIMITER;
}
};
14 changes: 6 additions & 8 deletions packages/storage/src/providers/s3/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,17 @@ export type RemoveOptions = WriteOptions & CommonOptions;
* @deprecated Use {@link ListAllOptionsWithPath} instead.
* Input options type with prefix for S3 list all API.
*/
export type ListAllOptionsWithPrefix = Omit<
StorageListAllOptions & ReadOptions & CommonOptions,
'subpathStrategy'
>;
export type ListAllOptionsWithPrefix = StorageListAllOptions &
ReadOptions &
CommonOptions;

/**
* @deprecated Use {@link ListPaginateOptionsWithPath} instead.
* Input options type with prefix for S3 list API to paginate items.
*/
export type ListPaginateOptionsWithPrefix = Omit<
StorageListPaginateOptions & ReadOptions & CommonOptions,
'subpathStrategy'
>;
export type ListPaginateOptionsWithPrefix = StorageListPaginateOptions &
ReadOptions &
CommonOptions;

/**
* Input options type with path for S3 list all API.
Expand Down
10 changes: 2 additions & 8 deletions packages/storage/src/providers/s3/types/outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ export type GetPropertiesWithPathOutput = ItemBase & StorageItemWithPath;
* @deprecated Use {@link ListAllWithPathOutput} instead.
* Output type for S3 list API. Lists all bucket objects.
*/
export type ListAllOutput = Omit<
StorageListOutput<ListOutputItem>,
'excludedSubpaths'
>;
export type ListAllOutput = StorageListOutput<ListOutputItem>;

/**
* Output type with path for S3 list API. Lists all bucket objects.
Expand All @@ -108,10 +105,7 @@ export type ListAllWithPathOutput = StorageListOutput<ListOutputItemWithPath>;
* @deprecated Use {@link ListPaginateWithPathOutput} instead.
* Output type for S3 list API. Lists bucket objects with pagination.
*/
export type ListPaginateOutput = Omit<
StorageListOutput<ListOutputItem>,
'excludedSubpaths'
> & {
export type ListPaginateOutput = StorageListOutput<ListOutputItem> & {
nextToken?: string;
};

Expand Down

0 comments on commit 60885b7

Please sign in to comment.