Skip to content

Commit

Permalink
fix(storage): internals list function not able to decide which output…
Browse files Browse the repository at this point in the history
… types to use (#13915)

chore: add function overloading to list
  • Loading branch information
Samaritan1011001 authored Oct 14, 2024
1 parent cf90847 commit 2cc870c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
21 changes: 17 additions & 4 deletions packages/storage/src/internals/apis/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@
import { Amplify } from '@aws-amplify/core';

import { list as listInternal } from '../../providers/s3/apis/internal/list';
import { ListInput } from '../types/inputs';
import { ListPaginateWithPathInput } from '../../providers/s3';
import { ListAllInput, ListInput, ListPaginateInput } from '../types/inputs';
import {
ListAllWithPathOutput,
ListPaginateWithPathOutput,
} from '../../providers/s3';
import { ListOutput } from '../types/outputs';

/**
* @internal
*/
export function list(input: ListAllInput): Promise<ListAllWithPathOutput>;
/**
* @internal
*/
export function list(
input: ListPaginateInput,
): Promise<ListPaginateWithPathOutput>;
/**
* @internal
*/
Expand All @@ -21,8 +34,8 @@ export function list(input: ListInput): Promise<ListOutput> {
listAll: input.options?.listAll,

// Pagination options
nextToken: (input as ListPaginateWithPathInput).options?.nextToken,
pageSize: (input as ListPaginateWithPathInput).options?.pageSize,
nextToken: (input as ListPaginateInput).options?.nextToken,
pageSize: (input as ListPaginateInput).options?.pageSize,
// Advanced options
locationCredentialsProvider: input.options?.locationCredentialsProvider,
},
Expand Down
2 changes: 2 additions & 0 deletions packages/storage/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export {
GetUrlInput,
CopyInput,
ListInput,
ListAllInput,
ListPaginateInput,
RemoveInput,
UploadDataInput,
DownloadDataInput,
Expand Down
19 changes: 17 additions & 2 deletions packages/storage/src/internals/types/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,28 @@ export interface GetDataAccessInput {
/**
* @internal
*/
export type ListInput = ExtendInputWithAdvancedOptions<
ListAllWithPathInput | ListPaginateWithPathInput,
export type ListAllInput = ExtendInputWithAdvancedOptions<
ListAllWithPathInput,
{
locationCredentialsProvider?: CredentialsProvider;
}
>;

/**
* @internal
*/
export type ListPaginateInput = ExtendInputWithAdvancedOptions<
ListPaginateWithPathInput,
{
locationCredentialsProvider?: CredentialsProvider;
}
>;

/**
* @internal
*/
export type ListInput = ListAllInput | ListPaginateInput;

/**
* @internal
*/
Expand Down

0 comments on commit 2cc870c

Please sign in to comment.