Skip to content

Commit fcba0bb

Browse files
authored
release(required): Amplify JS release (#13629)
2 parents 4c7e6ed + b473ce3 commit fcba0bb

File tree

8 files changed

+208
-24
lines changed

8 files changed

+208
-24
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
/packages/core/src/clients/internal @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
2828
/packages/core/src/Hub @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
2929
/packages/adapter-nextjs @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
30+
/packages/rtn-web-browser @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
3031
/packages/storage/src/providers/s3/apis/internal @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
3132
/packages/storage/src/providers/s3/apis/server @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF
3233
/packages/api-rest/src/apis/server.ts @ukhan-amazon @haverchuck @cshfang @jimblanc @HuiSF

packages/rtn-web-browser/src/apis/openAuthSessionAsync.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,34 +61,44 @@ const openAuthSessionAndroid = async (url: string, redirectUrls: string[]) => {
6161

6262
return redirectUrl;
6363
} finally {
64-
appStateListener?.remove();
65-
redirectListener?.remove();
66-
appStateListener = undefined;
67-
redirectListener = undefined;
64+
removeAppStateListener();
65+
removeRedirectListener();
6866
}
6967
};
7068

7169
const getAppStatePromise = (): Promise<null> =>
7270
new Promise(resolve => {
73-
appStateListener = AppState.addEventListener('change', nextAppState => {
74-
// if current state is null, the change is from initialization
75-
if (AppState.currentState === null) {
76-
return;
77-
}
71+
// remove any stray listeners before creating new ones
72+
removeAppStateListener();
7873

79-
if (nextAppState === 'active') {
80-
appStateListener?.remove();
81-
appStateListener = undefined;
74+
let previousState = AppState.currentState;
75+
appStateListener = AppState.addEventListener('change', nextAppState => {
76+
if (previousState !== 'active' && nextAppState === 'active') {
77+
removeAppStateListener();
8278
resolve(null);
8379
}
80+
previousState = nextAppState;
8481
});
8582
});
8683

8784
const getRedirectPromise = (redirectUrls: string[]): Promise<string> =>
8885
new Promise(resolve => {
86+
// remove any stray listeners before creating new ones
87+
removeRedirectListener();
88+
8989
redirectListener = Linking.addEventListener('url', event => {
9090
if (redirectUrls.some(url => event.url.startsWith(url))) {
9191
resolve(event.url);
9292
}
9393
});
9494
});
95+
96+
const removeAppStateListener = () => {
97+
appStateListener?.remove();
98+
appStateListener = undefined;
99+
};
100+
101+
const removeRedirectListener = () => {
102+
redirectListener?.remove();
103+
redirectListener = undefined;
104+
};
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
/* eslint-disable unused-imports/no-unused-vars */
5+
6+
import { StorageAccessLevel } from '@aws-amplify/core';
7+
8+
import {
9+
ListAllInput,
10+
ListAllOutput,
11+
ListAllWithPathInput,
12+
ListAllWithPathOutput,
13+
ListOutputItem,
14+
ListOutputItemWithPath,
15+
ListPaginateInput,
16+
ListPaginateOutput,
17+
ListPaginateWithPathInput,
18+
ListPaginateWithPathOutput,
19+
} from '../../../../src/providers/s3/types';
20+
import { StorageSubpathStrategy } from '../../../../src/types';
21+
22+
import { Equal, Expect } from './utils';
23+
24+
interface Input {
25+
targetIdentityId?: string;
26+
prefix?: string;
27+
path: string;
28+
subpathStrategy?: StorageSubpathStrategy;
29+
nextToken: string;
30+
pageSize: number;
31+
useAccelerateEndpoint: boolean;
32+
accessLevel: StorageAccessLevel;
33+
listAll: boolean;
34+
}
35+
36+
interface Output {
37+
listOutputItems: ListOutputItem[];
38+
listOutputItemsWithPath: ListOutputItemWithPath[];
39+
excludedSubpaths: string[];
40+
nextToken: string;
41+
}
42+
43+
describe('List API input types', () => {
44+
test('should compile', () => {
45+
function handleTest({
46+
targetIdentityId,
47+
prefix,
48+
path,
49+
subpathStrategy,
50+
nextToken,
51+
pageSize,
52+
useAccelerateEndpoint,
53+
accessLevel,
54+
}: Input) {
55+
const listPaginateInput: ListPaginateInput = {
56+
prefix,
57+
options: {
58+
accessLevel: 'protected',
59+
targetIdentityId,
60+
// @ts-expect-error subpathStrategy is not part of this input
61+
subpathStrategy,
62+
},
63+
};
64+
65+
const listAllInput: ListAllInput = {
66+
prefix,
67+
options: {
68+
listAll: true,
69+
accessLevel: 'protected',
70+
targetIdentityId,
71+
// @ts-expect-error subpathStrategy is not part of this input
72+
subpathStrategy,
73+
},
74+
};
75+
76+
const listPaginateWithPathInput: ListPaginateWithPathInput = {
77+
path,
78+
options: {
79+
subpathStrategy,
80+
useAccelerateEndpoint,
81+
pageSize,
82+
nextToken,
83+
},
84+
};
85+
86+
const listAllWithPathInput: ListAllWithPathInput = {
87+
path,
88+
options: {
89+
listAll: true,
90+
subpathStrategy,
91+
useAccelerateEndpoint,
92+
// @ts-expect-error pageSize is not part of this input
93+
pageSize,
94+
},
95+
};
96+
97+
type Tests = [
98+
Expect<Equal<typeof listPaginateInput, ListPaginateInput>>,
99+
Expect<Equal<typeof listAllInput, ListAllInput>>,
100+
Expect<
101+
Equal<typeof listPaginateWithPathInput, ListPaginateWithPathInput>
102+
>,
103+
Expect<Equal<typeof listAllWithPathInput, ListAllWithPathInput>>,
104+
];
105+
type Result = Expect<Equal<Tests, [true, true, true, true]>>;
106+
}
107+
});
108+
});
109+
110+
describe('List API ouput types', () => {
111+
test('should compile', () => {
112+
function handleTest({
113+
listOutputItems,
114+
nextToken,
115+
excludedSubpaths,
116+
listOutputItemsWithPath,
117+
}: Output) {
118+
const listPaginateOutput: ListPaginateOutput = {
119+
items: listOutputItems,
120+
nextToken,
121+
// @ts-expect-error excludeSubpaths is not part of this output
122+
excludedSubpaths,
123+
};
124+
125+
const listAllOutput: ListAllOutput = {
126+
items: listOutputItems,
127+
// @ts-expect-error excludeSubpaths is not part of this output
128+
excludedSubpaths,
129+
};
130+
131+
const listPaginateWithPathOutput: ListPaginateWithPathOutput = {
132+
items: listOutputItemsWithPath,
133+
nextToken,
134+
excludedSubpaths,
135+
};
136+
137+
const listAllWithPathOutput: ListAllWithPathOutput = {
138+
items: listOutputItemsWithPath,
139+
excludedSubpaths,
140+
};
141+
142+
type Tests = [
143+
Expect<Equal<typeof listPaginateOutput, ListPaginateOutput>>,
144+
Expect<Equal<typeof listAllOutput, ListAllOutput>>,
145+
Expect<
146+
Equal<typeof listPaginateWithPathOutput, ListPaginateWithPathOutput>
147+
>,
148+
Expect<Equal<typeof listAllWithPathOutput, ListAllWithPathOutput>>,
149+
];
150+
151+
type Result = Expect<Equal<Tests, [true, true, true, true]>>;
152+
}
153+
});
154+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
export type Expect<T extends true> = T;
5+
6+
export type Equal<X, Y> = X extends Y ? true : false;

packages/storage/src/providers/s3/apis/internal/list.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ import {
2020
resolveS3ConfigAndInput,
2121
validateStorageOperationInputWithPrefix,
2222
} from '../../utils';
23-
import { ResolvedS3Config } from '../../types/options';
23+
import {
24+
ListAllOptionsWithPath,
25+
ListPaginateOptionsWithPath,
26+
ResolvedS3Config,
27+
} from '../../types/options';
2428
import {
2529
ListObjectsV2Input,
2630
ListObjectsV2Output,
@@ -30,7 +34,6 @@ import { getStorageUserAgentValue } from '../../utils/userAgent';
3034
import { logger } from '../../../../utils';
3135
import { DEFAULT_DELIMITER, STORAGE_INPUT_PREFIX } from '../../utils/constants';
3236
import { CommonPrefix } from '../../utils/client/types';
33-
import { StorageSubpathStrategy } from '../../../../types';
3437

3538
const MAX_PAGE_SIZE = 1000;
3639

@@ -76,12 +79,13 @@ export const list = async (
7679
} ${anyOptions?.nextToken ? `nextToken: ${anyOptions?.nextToken}` : ''}.`,
7780
);
7881
}
82+
7983
const listParams = {
8084
Bucket: bucket,
8185
Prefix: isInputWithPrefix ? `${generatedPrefix}${objectKey}` : objectKey,
8286
MaxKeys: options?.listAll ? undefined : options?.pageSize,
8387
ContinuationToken: options?.listAll ? undefined : options?.nextToken,
84-
Delimiter: getDelimiter(options.subpathStrategy),
88+
Delimiter: getDelimiter(options),
8589
};
8690
logger.debug(`listing items from "${listParams.Prefix}"`);
8791

@@ -263,9 +267,9 @@ const mapCommonPrefixesToExcludedSubpaths = (
263267
};
264268

265269
const getDelimiter = (
266-
subpathStrategy?: StorageSubpathStrategy,
270+
options?: ListAllOptionsWithPath | ListPaginateOptionsWithPath,
267271
): string | undefined => {
268-
if (subpathStrategy?.strategy === 'exclude') {
269-
return subpathStrategy?.delimiter ?? DEFAULT_DELIMITER;
272+
if (options?.subpathStrategy?.strategy === 'exclude') {
273+
return options?.subpathStrategy?.delimiter ?? DEFAULT_DELIMITER;
270274
}
271275
};

packages/storage/src/providers/s3/types/options.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { TransferProgressEvent } from '../../../types';
88
import {
99
StorageListAllOptions,
1010
StorageListPaginateOptions,
11+
StorageSubpathStrategy,
1112
} from '../../../types/options';
1213

1314
interface CommonOptions {
@@ -89,7 +90,9 @@ export type ListAllOptionsWithPath = Omit<
8990
StorageListAllOptions,
9091
'accessLevel'
9192
> &
92-
CommonOptions;
93+
CommonOptions & {
94+
subpathStrategy?: StorageSubpathStrategy;
95+
};
9396

9497
/**
9598
* Input options type with path for S3 list API to paginate items.
@@ -98,7 +101,9 @@ export type ListPaginateOptionsWithPath = Omit<
98101
StorageListPaginateOptions,
99102
'accessLevel'
100103
> &
101-
CommonOptions;
104+
CommonOptions & {
105+
subpathStrategy?: StorageSubpathStrategy;
106+
};
102107

103108
/**
104109
* Input options type for S3 getUrl API.

packages/storage/src/providers/s3/types/outputs.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ export type GetPropertiesWithPathOutput = ItemBase & StorageItemWithPath;
9494
* @deprecated Use {@link ListAllWithPathOutput} instead.
9595
* Output type for S3 list API. Lists all bucket objects.
9696
*/
97-
export type ListAllOutput = StorageListOutput<ListOutputItem>;
97+
export type ListAllOutput = Omit<
98+
StorageListOutput<ListOutputItem>,
99+
'excludedSubpaths'
100+
>;
98101

99102
/**
100103
* Output type with path for S3 list API. Lists all bucket objects.
@@ -105,7 +108,10 @@ export type ListAllWithPathOutput = StorageListOutput<ListOutputItemWithPath>;
105108
* @deprecated Use {@link ListPaginateWithPathOutput} instead.
106109
* Output type for S3 list API. Lists bucket objects with pagination.
107110
*/
108-
export type ListPaginateOutput = StorageListOutput<ListOutputItem> & {
111+
export type ListPaginateOutput = Omit<
112+
StorageListOutput<ListOutputItem>,
113+
'excludedSubpaths'
114+
> & {
109115
nextToken?: string;
110116
};
111117

packages/storage/src/types/options.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ export interface StorageOptions {
1010

1111
export type StorageListAllOptions = StorageOptions & {
1212
listAll: true;
13-
subpathStrategy?: StorageSubpathStrategy;
1413
};
1514

1615
export type StorageListPaginateOptions = StorageOptions & {
1716
listAll?: false;
1817
pageSize?: number;
1918
nextToken?: string;
20-
subpathStrategy?: StorageSubpathStrategy;
2119
};
2220

2321
export type StorageRemoveOptions = StorageOptions;

0 commit comments

Comments
 (0)