@aws-amplify/core 6.0.1-console-preview.5a31ca1.0 → 6.0.1-console-preview.8d88eef.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Platform/types.d.ts +18 -8
- package/lib/Platform/types.js +10 -2
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/ServiceWorker/ServiceWorker.js +69 -17
- package/lib/ServiceWorker/index.d.ts +0 -12
- package/lib/ServiceWorker/index.js +0 -12
- package/lib/errors/errorHelpers.d.ts +2 -0
- package/lib/errors/errorHelpers.js +20 -0
- package/lib/errors/index.d.ts +1 -0
- package/lib/errors/index.js +3 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -1
- package/lib/libraryUtils.d.ts +4 -6
- package/lib/libraryUtils.js +9 -15
- package/lib/parseAWSExports.js +27 -18
- package/lib/providers/pinpoint/apis/record.d.ts +1 -1
- package/lib/providers/pinpoint/apis/record.js +5 -21
- package/lib/providers/pinpoint/index.d.ts +2 -2
- package/lib/providers/pinpoint/index.js +4 -2
- package/lib/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib/providers/pinpoint/types/errors.js +15 -0
- package/lib/providers/pinpoint/types/index.d.ts +1 -0
- package/lib/providers/pinpoint/types/index.js +3 -0
- package/lib/providers/pinpoint/types/pinpoint.d.ts +3 -3
- package/lib/providers/pinpoint/utils/index.d.ts +1 -0
- package/lib/providers/pinpoint/utils/index.js +3 -1
- package/lib/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
- package/lib/providers/pinpoint/utils/resolveEndpointId.js +85 -0
- package/lib/singleton/Auth/types.d.ts +2 -2
- package/lib/singleton/Notifications/PushNotification/types.d.ts +2 -0
- package/lib/singleton/Notifications/PushNotification/types.js +4 -0
- package/lib/singleton/Notifications/types.d.ts +3 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/errors.d.ts +1 -0
- package/lib/types/errors.js +1 -0
- package/lib-esm/Platform/types.d.ts +18 -8
- package/lib-esm/Platform/types.js +10 -2
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/ServiceWorker/ServiceWorker.js +69 -17
- package/lib-esm/ServiceWorker/index.d.ts +0 -12
- package/lib-esm/ServiceWorker/index.js +0 -12
- package/lib-esm/errors/errorHelpers.d.ts +2 -0
- package/lib-esm/errors/errorHelpers.js +17 -0
- package/lib-esm/errors/index.d.ts +1 -0
- package/lib-esm/errors/index.js +1 -0
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +4 -0
- package/lib-esm/libraryUtils.d.ts +4 -6
- package/lib-esm/libraryUtils.js +3 -6
- package/lib-esm/parseAWSExports.js +27 -18
- package/lib-esm/providers/pinpoint/apis/record.d.ts +1 -1
- package/lib-esm/providers/pinpoint/apis/record.js +6 -22
- package/lib-esm/providers/pinpoint/index.d.ts +2 -2
- package/lib-esm/providers/pinpoint/index.js +2 -1
- package/lib-esm/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib-esm/providers/pinpoint/types/errors.js +12 -0
- package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/types/index.js +1 -0
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +3 -3
- package/lib-esm/providers/pinpoint/utils/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/utils/index.js +1 -0
- package/lib-esm/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
- package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +81 -0
- package/lib-esm/singleton/Auth/types.d.ts +2 -2
- package/lib-esm/singleton/Notifications/PushNotification/types.d.ts +2 -0
- package/lib-esm/singleton/Notifications/PushNotification/types.js +3 -0
- package/lib-esm/singleton/Notifications/types.d.ts +3 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/errors.d.ts +1 -0
- package/lib-esm/types/errors.js +1 -0
- package/package.json +3 -3
- package/src/Platform/types.ts +20 -11
- package/src/Platform/version.ts +1 -1
- package/src/ServiceWorker/ServiceWorker.ts +20 -17
- package/src/ServiceWorker/index.ts +0 -12
- package/src/errors/errorHelpers.ts +20 -0
- package/src/errors/index.ts +1 -0
- package/src/index.ts +6 -0
- package/src/libraryUtils.ts +11 -11
- package/src/parseAWSExports.ts +19 -14
- package/src/providers/pinpoint/apis/record.ts +11 -25
- package/src/providers/pinpoint/index.ts +6 -2
- package/src/providers/pinpoint/types/errors.ts +12 -0
- package/src/providers/pinpoint/types/index.ts +1 -0
- package/src/providers/pinpoint/types/pinpoint.ts +3 -2
- package/src/providers/pinpoint/utils/index.ts +1 -0
- package/src/providers/pinpoint/utils/resolveEndpointId.ts +46 -0
- package/src/singleton/Auth/types.ts +2 -2
- package/src/singleton/Notifications/PushNotification/types.ts +6 -0
- package/src/singleton/Notifications/types.ts +3 -1
- package/src/types/errors.ts +1 -0
- package/lib/Amplify.d.ts +0 -29
- package/lib/Amplify.js +0 -118
- package/lib-esm/Amplify.d.ts +0 -29
- package/lib-esm/Amplify.js +0 -115
- package/src/Amplify.ts +0 -106
package/lib-esm/types/errors.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
export var AmplifyErrorCode;
|
|
4
4
|
(function (AmplifyErrorCode) {
|
|
5
|
+
AmplifyErrorCode["NoEndpointId"] = "NoEndpointId";
|
|
5
6
|
AmplifyErrorCode["PlatformNotSupported"] = "PlatformNotSupported";
|
|
6
7
|
AmplifyErrorCode["Unknown"] = "Unknown";
|
|
7
8
|
})(AmplifyErrorCode || (AmplifyErrorCode = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/core",
|
|
3
|
-
"version": "6.0.1-console-preview.
|
|
3
|
+
"version": "6.0.1-console-preview.8d88eef.0+8d88eef",
|
|
4
4
|
"description": "Core category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"uuid": "^9.0.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@aws-amplify/react-native": "1.0.1-console-preview.
|
|
67
|
+
"@aws-amplify/react-native": "1.0.1-console-preview.8d88eef.0+8d88eef",
|
|
68
68
|
"@types/js-cookie": "3.0.2",
|
|
69
69
|
"@types/uuid": "^9.0.0",
|
|
70
70
|
"find": "^0.2.7",
|
|
@@ -169,5 +169,5 @@
|
|
|
169
169
|
"lib-esm"
|
|
170
170
|
]
|
|
171
171
|
},
|
|
172
|
-
"gitHead": "
|
|
172
|
+
"gitHead": "8d88eef4137cef4fbe03d7d3683b5bec59feb7b8"
|
|
173
173
|
}
|
package/src/Platform/types.ts
CHANGED
|
@@ -83,7 +83,14 @@ export enum DataStoreAction {
|
|
|
83
83
|
GraphQl = '2',
|
|
84
84
|
}
|
|
85
85
|
export enum GeoAction {
|
|
86
|
-
|
|
86
|
+
SearchByText = '0',
|
|
87
|
+
SearchByCoordinates = '1',
|
|
88
|
+
SearchForSuggestions = '2',
|
|
89
|
+
SearchByPlaceId = '3',
|
|
90
|
+
SaveGeofences = '4',
|
|
91
|
+
GetGeofence = '5',
|
|
92
|
+
ListGeofences = '6',
|
|
93
|
+
DeleteGeofences = '7',
|
|
87
94
|
}
|
|
88
95
|
export enum InAppMessagingAction {
|
|
89
96
|
SyncMessages = '1',
|
|
@@ -102,7 +109,8 @@ export enum PubSubAction {
|
|
|
102
109
|
Subscribe = '1',
|
|
103
110
|
}
|
|
104
111
|
export enum PushNotificationAction {
|
|
105
|
-
|
|
112
|
+
InitializePushNotifications = '1',
|
|
113
|
+
IdentifyUser = '2',
|
|
106
114
|
}
|
|
107
115
|
export enum StorageAction {
|
|
108
116
|
UploadData = '1',
|
|
@@ -166,31 +174,32 @@ export type CustomUserAgentStateMap = Record<string, CategoryUserAgentStateMap>;
|
|
|
166
174
|
|
|
167
175
|
export type AdditionalDetails = [string, string?][];
|
|
168
176
|
|
|
169
|
-
type StorageUserAgentInput = {
|
|
177
|
+
export type StorageUserAgentInput = {
|
|
170
178
|
category: Category.Storage;
|
|
171
179
|
apis: StorageAction[];
|
|
180
|
+
additionalDetails: AdditionalDetails;
|
|
172
181
|
};
|
|
173
182
|
|
|
174
|
-
type AuthUserAgentInput = {
|
|
183
|
+
export type AuthUserAgentInput = {
|
|
175
184
|
category: Category.Auth;
|
|
176
185
|
apis: AuthAction[];
|
|
186
|
+
additionalDetails: AdditionalDetails;
|
|
177
187
|
};
|
|
178
188
|
|
|
179
|
-
type InAppMessagingUserAgentInput = {
|
|
189
|
+
export type InAppMessagingUserAgentInput = {
|
|
180
190
|
category: Category.InAppMessaging;
|
|
181
191
|
apis: InAppMessagingAction[];
|
|
192
|
+
additionalDetails: AdditionalDetails;
|
|
182
193
|
};
|
|
183
194
|
|
|
184
|
-
type GeoUserAgentInput = {
|
|
195
|
+
export type GeoUserAgentInput = {
|
|
185
196
|
category: Category.Geo;
|
|
186
197
|
apis: GeoAction[];
|
|
198
|
+
additionalDetails: AdditionalDetails;
|
|
187
199
|
};
|
|
188
200
|
|
|
189
|
-
export type SetCustomUserAgentInput =
|
|
201
|
+
export type SetCustomUserAgentInput =
|
|
190
202
|
| StorageUserAgentInput
|
|
191
203
|
| AuthUserAgentInput
|
|
192
204
|
| InAppMessagingUserAgentInput
|
|
193
|
-
| GeoUserAgentInput
|
|
194
|
-
) & {
|
|
195
|
-
additionalDetails: AdditionalDetails;
|
|
196
|
-
};
|
|
205
|
+
| GeoUserAgentInput;
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.0.1-console-preview.
|
|
2
|
+
export const version = '6.0.1-console-preview.8d88eef.0+8d88eef';
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import { ConsoleLogger as Logger } from '../Logger';
|
|
5
5
|
import { isBrowser } from '../utils';
|
|
6
|
-
import { Amplify } from '../Amplify';
|
|
7
6
|
import { AmplifyError } from '../errors';
|
|
8
7
|
import { assert, ServiceWorkerErrorCode } from './errorHelpers';
|
|
8
|
+
import { record } from '../providers/pinpoint';
|
|
9
|
+
import { Amplify, fetchAuthSession } from '../singleton';
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* Provides a means to registering a service worker in the browser
|
|
11
13
|
* and communicating with it via postMessage events.
|
|
@@ -205,15 +207,25 @@ export class ServiceWorkerClass {
|
|
|
205
207
|
* https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state
|
|
206
208
|
**/
|
|
207
209
|
_setupListeners() {
|
|
208
|
-
this.serviceWorker.addEventListener('statechange', event => {
|
|
210
|
+
this.serviceWorker.addEventListener('statechange', async event => {
|
|
209
211
|
const currentState = this.serviceWorker.state;
|
|
210
212
|
this._logger.debug(`ServiceWorker statechange: ${currentState}`);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
|
|
214
|
+
const { appId, region } = Amplify.getConfig().Analytics?.Pinpoint ?? {};
|
|
215
|
+
const { credentials } = await fetchAuthSession();
|
|
216
|
+
|
|
217
|
+
if (appId && region && credentials) {
|
|
218
|
+
// Pinpoint is configured, record an event
|
|
219
|
+
record({
|
|
220
|
+
appId,
|
|
221
|
+
region,
|
|
222
|
+
category: 'Core',
|
|
223
|
+
credentials,
|
|
224
|
+
event: {
|
|
225
|
+
name: 'ServiceWorker',
|
|
226
|
+
attributes: {
|
|
227
|
+
state: currentState,
|
|
228
|
+
},
|
|
217
229
|
},
|
|
218
230
|
});
|
|
219
231
|
}
|
|
@@ -223,12 +235,3 @@ export class ServiceWorkerClass {
|
|
|
223
235
|
});
|
|
224
236
|
}
|
|
225
237
|
}
|
|
226
|
-
|
|
227
|
-
type AmplifyWithAnalytics = {
|
|
228
|
-
Analytics: {
|
|
229
|
-
record: Function;
|
|
230
|
-
};
|
|
231
|
-
};
|
|
232
|
-
function isAmplifyWithAnalytics(amplify: any): amplify is AmplifyWithAnalytics {
|
|
233
|
-
return amplify.Analytics && typeof amplify.Analytics.record === 'function';
|
|
234
|
-
}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
/**
|
|
4
|
-
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
7
|
-
* the License. A copy of the License is located at
|
|
8
|
-
*
|
|
9
|
-
* http://aws.amazon.com/apache2.0/
|
|
10
|
-
*
|
|
11
|
-
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
12
|
-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
13
|
-
* and limitations under the License.
|
|
14
|
-
*/
|
|
15
3
|
|
|
16
4
|
export { ServiceWorkerClass as ServiceWorker } from './ServiceWorker';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { createAssertionFunction } from './createAssertionFunction';
|
|
5
|
+
import { AmplifyErrorCode, AmplifyErrorMap, AssertionFunction } from '../types';
|
|
6
|
+
|
|
7
|
+
const amplifyErrorMap: AmplifyErrorMap<AmplifyErrorCode> = {
|
|
8
|
+
[AmplifyErrorCode.NoEndpointId]: {
|
|
9
|
+
message: 'Endpoint ID was not found and was unable to be created.',
|
|
10
|
+
},
|
|
11
|
+
[AmplifyErrorCode.PlatformNotSupported]: {
|
|
12
|
+
message: 'Function not supported on current platform.',
|
|
13
|
+
},
|
|
14
|
+
[AmplifyErrorCode.Unknown]: {
|
|
15
|
+
message: 'An unknown error occurred.',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const assert: AssertionFunction<AmplifyErrorCode> =
|
|
20
|
+
createAssertionFunction(amplifyErrorMap);
|
package/src/errors/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/libraryUtils.ts
CHANGED
|
@@ -40,12 +40,9 @@ export {
|
|
|
40
40
|
JwtPayload,
|
|
41
41
|
AuthStandardAttributeKey,
|
|
42
42
|
AuthVerifiableAttributeKey,
|
|
43
|
-
AWSCredentials
|
|
43
|
+
AWSCredentials,
|
|
44
44
|
} from './singleton/Auth/types';
|
|
45
45
|
|
|
46
|
-
// Logging utilities
|
|
47
|
-
export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
|
|
48
|
-
|
|
49
46
|
// Platform & user-agent utilities
|
|
50
47
|
export {
|
|
51
48
|
Platform,
|
|
@@ -68,16 +65,14 @@ export {
|
|
|
68
65
|
PushNotificationAction,
|
|
69
66
|
StorageAction,
|
|
70
67
|
SetCustomUserAgentInput,
|
|
68
|
+
StorageUserAgentInput,
|
|
69
|
+
AuthUserAgentInput,
|
|
70
|
+
InAppMessagingUserAgentInput,
|
|
71
|
+
GeoUserAgentInput,
|
|
71
72
|
} from './Platform/types';
|
|
72
73
|
export { setCustomUserAgent } from './Platform/customUserAgent';
|
|
73
74
|
|
|
74
|
-
//
|
|
75
|
-
export { ServiceWorker } from './ServiceWorker';
|
|
76
|
-
|
|
77
|
-
// Other utilities & constants
|
|
78
|
-
export { BackgroundProcessManager } from './BackgroundProcessManager';
|
|
79
|
-
export { Mutex } from './Mutex';
|
|
80
|
-
export { Reachability } from './Reachability';
|
|
75
|
+
// Error handling
|
|
81
76
|
export {
|
|
82
77
|
AmplifyError,
|
|
83
78
|
PlatformNotSupportedError,
|
|
@@ -90,6 +85,11 @@ export {
|
|
|
90
85
|
AssertionFunction,
|
|
91
86
|
ServiceError,
|
|
92
87
|
} from './types';
|
|
88
|
+
|
|
89
|
+
// Other utilities & constants
|
|
90
|
+
export { BackgroundProcessManager } from './BackgroundProcessManager';
|
|
91
|
+
export { Mutex } from './Mutex';
|
|
92
|
+
export { Reachability } from './Reachability';
|
|
93
93
|
export {
|
|
94
94
|
INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER,
|
|
95
95
|
USER_AGENT_HEADER,
|
package/src/parseAWSExports.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { ConsoleLogger as Logger } from './Logger';
|
|
4
|
-
import {
|
|
5
|
-
OAuthConfig,
|
|
6
|
-
AuthStandardAttributeKey,
|
|
7
|
-
AuthConfigUserAttributes,
|
|
8
|
-
} from './singleton/Auth/types';
|
|
4
|
+
import { OAuthConfig, AuthConfigUserAttributes } from './singleton/Auth/types';
|
|
9
5
|
import { ResourcesConfig } from './singleton/types';
|
|
10
6
|
|
|
11
7
|
const logger = new Logger('parseAWSExports');
|
|
@@ -70,15 +66,24 @@ export const parseAWSExports = (
|
|
|
70
66
|
}
|
|
71
67
|
|
|
72
68
|
// Notifications
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
const { InAppMessaging, Push } = Notifications ?? {};
|
|
70
|
+
if (InAppMessaging?.AWSPinpoint || Push?.AWSPinpoint) {
|
|
71
|
+
amplifyConfig.Notifications = {};
|
|
72
|
+
if (InAppMessaging?.AWSPinpoint) {
|
|
73
|
+
const { appId, region } = InAppMessaging.AWSPinpoint;
|
|
74
|
+
amplifyConfig.Notifications.InAppMessaging = {
|
|
75
|
+
Pinpoint: {
|
|
76
|
+
appId,
|
|
77
|
+
region,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (Push?.AWSPinpoint) {
|
|
82
|
+
const { appId, region } = Push.AWSPinpoint;
|
|
83
|
+
amplifyConfig.Notifications.PushNotification = {
|
|
84
|
+
Pinpoint: {
|
|
85
|
+
appId,
|
|
86
|
+
region,
|
|
82
87
|
},
|
|
83
88
|
};
|
|
84
89
|
}
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
import { amplifyUuid } from '../../../utils/amplifyUuid';
|
|
5
5
|
import { PinpointRecordInput, PinpointSession } from '../types';
|
|
6
|
-
import {
|
|
6
|
+
import { resolveEndpointId } from '../utils';
|
|
7
7
|
import {
|
|
8
8
|
BUFFER_SIZE,
|
|
9
9
|
FLUSH_INTERVAL,
|
|
10
10
|
FLUSH_SIZE,
|
|
11
11
|
RESEND_LIMIT,
|
|
12
12
|
} from '../utils/constants';
|
|
13
|
-
import { updateEndpoint } from './updateEndpoint';
|
|
14
13
|
import { getEventBuffer } from '../utils/getEventBuffer';
|
|
15
|
-
import { AmplifyError } from '../../../errors';
|
|
16
14
|
|
|
17
15
|
// TODO(v6) Refactor when we add support for session tracking & `autoTrack`
|
|
18
16
|
let session: PinpointSession;
|
|
@@ -23,6 +21,7 @@ let session: PinpointSession;
|
|
|
23
21
|
export const record = async ({
|
|
24
22
|
appId,
|
|
25
23
|
category,
|
|
24
|
+
channelType,
|
|
26
25
|
credentials,
|
|
27
26
|
event,
|
|
28
27
|
identityId,
|
|
@@ -31,7 +30,6 @@ export const record = async ({
|
|
|
31
30
|
}: PinpointRecordInput): Promise<void> => {
|
|
32
31
|
const timestampISOString = new Date().toISOString();
|
|
33
32
|
const eventId = amplifyUuid();
|
|
34
|
-
let endpointId = await getEndpointId(appId, category);
|
|
35
33
|
|
|
36
34
|
// Prepare event buffer if required
|
|
37
35
|
const buffer = getEventBuffer({
|
|
@@ -46,27 +44,15 @@ export const record = async ({
|
|
|
46
44
|
userAgentValue,
|
|
47
45
|
});
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
userAgentValue,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
endpointId = await getEndpointId(appId, category);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!endpointId) {
|
|
65
|
-
throw new AmplifyError({
|
|
66
|
-
name: 'ENDPOINT_NOT_CREATED',
|
|
67
|
-
message: 'Endpoint was not created.',
|
|
68
|
-
});
|
|
69
|
-
}
|
|
47
|
+
const endpointId = await resolveEndpointId({
|
|
48
|
+
appId,
|
|
49
|
+
category,
|
|
50
|
+
channelType,
|
|
51
|
+
credentials,
|
|
52
|
+
identityId,
|
|
53
|
+
region,
|
|
54
|
+
userAgentValue,
|
|
55
|
+
});
|
|
70
56
|
|
|
71
57
|
// Generate session if required
|
|
72
58
|
if (!session) {
|
|
@@ -2,5 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export * from './apis';
|
|
5
|
-
export {
|
|
6
|
-
|
|
5
|
+
export {
|
|
6
|
+
PinpointAnalyticsEvent,
|
|
7
|
+
PinpointServiceOptions,
|
|
8
|
+
UpdateEndpointException,
|
|
9
|
+
} from './types';
|
|
10
|
+
export { resolveEndpointId } from './utils';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export enum UpdateEndpointException {
|
|
5
|
+
BadRequestException = 'BadRequestException',
|
|
6
|
+
ForbiddenException = 'ForbiddenException',
|
|
7
|
+
InternalServerErrorException = 'InternalServerErrorException',
|
|
8
|
+
MethodNotAllowedException = 'MethodNotAllowedException',
|
|
9
|
+
NotFoundException = 'NotFoundException',
|
|
10
|
+
PayloadTooLargeException = 'PayloadTooLargeException',
|
|
11
|
+
TooManyRequestsException = 'TooManyRequestsException',
|
|
12
|
+
}
|
|
@@ -6,10 +6,11 @@ import { UserProfile } from '../../../types';
|
|
|
6
6
|
|
|
7
7
|
export type SupportedCategory =
|
|
8
8
|
| 'Analytics'
|
|
9
|
+
| 'Core'
|
|
9
10
|
| 'InAppMessaging'
|
|
10
11
|
| 'PushNotification';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
|
|
13
14
|
|
|
14
15
|
export type PinpointProviderConfig = {
|
|
15
16
|
Pinpoint?: {
|
|
@@ -39,6 +40,7 @@ export type PinpointAnalyticsEvent = {
|
|
|
39
40
|
type PinpointCommonParameters = {
|
|
40
41
|
appId: string;
|
|
41
42
|
category: SupportedCategory;
|
|
43
|
+
channelType?: SupportedChannelType;
|
|
42
44
|
credentials: Required<AuthSession>['credentials'];
|
|
43
45
|
identityId?: AuthSession['identityId'];
|
|
44
46
|
region: string;
|
|
@@ -47,7 +49,6 @@ type PinpointCommonParameters = {
|
|
|
47
49
|
|
|
48
50
|
export type PinpointUpdateEndpointInput = PinpointCommonParameters &
|
|
49
51
|
PinpointServiceOptions & {
|
|
50
|
-
channelType?: SupportedChannelType;
|
|
51
52
|
userId?: string;
|
|
52
53
|
userProfile?: UserProfile;
|
|
53
54
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { assert } from '../../../errors';
|
|
5
|
+
import { AmplifyErrorCode } from '../../../types';
|
|
6
|
+
import { updateEndpoint } from '../apis';
|
|
7
|
+
import { PinpointUpdateEndpointInput } from '../types';
|
|
8
|
+
import { getEndpointId } from './getEndpointId';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolves an endpoint id from cache or prepare via updateEndpoint if one does not already exist,
|
|
12
|
+
* which will generate and cache an endpoint id between calls.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export const resolveEndpointId = async ({
|
|
17
|
+
address,
|
|
18
|
+
appId,
|
|
19
|
+
category,
|
|
20
|
+
channelType,
|
|
21
|
+
credentials,
|
|
22
|
+
identityId,
|
|
23
|
+
region,
|
|
24
|
+
userAgentValue,
|
|
25
|
+
}: PinpointUpdateEndpointInput) => {
|
|
26
|
+
let endpointId = await getEndpointId(appId, category);
|
|
27
|
+
|
|
28
|
+
if (!endpointId) {
|
|
29
|
+
await updateEndpoint({
|
|
30
|
+
address,
|
|
31
|
+
appId,
|
|
32
|
+
category,
|
|
33
|
+
channelType,
|
|
34
|
+
credentials,
|
|
35
|
+
identityId,
|
|
36
|
+
region,
|
|
37
|
+
userAgentValue,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
endpointId = await getEndpointId(appId, category);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
assert(!!endpointId, AmplifyErrorCode.NoEndpointId);
|
|
44
|
+
|
|
45
|
+
return endpointId;
|
|
46
|
+
};
|
|
@@ -113,12 +113,12 @@ export type AuthIdentityPoolConfig = {
|
|
|
113
113
|
Cognito: CognitoIdentityPoolConfig & {
|
|
114
114
|
userPoolClientId?: never;
|
|
115
115
|
userPoolId?: never;
|
|
116
|
+
userPoolEndpoint?: never;
|
|
116
117
|
loginWith?: never;
|
|
117
118
|
signUpVerificationMethod?: never;
|
|
118
119
|
userAttributes?: never;
|
|
119
120
|
mfa?: never;
|
|
120
121
|
passwordFormat?: never;
|
|
121
|
-
endpoint?: never;
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
|
|
@@ -137,6 +137,7 @@ export type AuthUserPoolConfig = {
|
|
|
137
137
|
export type CognitoUserPoolConfig = {
|
|
138
138
|
userPoolClientId: string;
|
|
139
139
|
userPoolId: string;
|
|
140
|
+
userPoolEndpoint?: string;
|
|
140
141
|
signUpVerificationMethod?: 'code' | 'link';
|
|
141
142
|
loginWith?: {
|
|
142
143
|
oauth?: OAuthConfig;
|
|
@@ -157,7 +158,6 @@ export type CognitoUserPoolConfig = {
|
|
|
157
158
|
requireNumbers?: boolean;
|
|
158
159
|
requireSpecialCharacters?: boolean;
|
|
159
160
|
};
|
|
160
|
-
endpoint?: string;
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
export type OAuthConfig = {
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { InAppMessagingConfig } from './InAppMessaging/types';
|
|
5
|
+
import { PushNotificationConfig } from './PushNotification/types';
|
|
5
6
|
|
|
6
7
|
export type NotificationsConfig = {
|
|
7
|
-
InAppMessaging
|
|
8
|
+
InAppMessaging?: InAppMessagingConfig;
|
|
9
|
+
PushNotification?: PushNotificationConfig;
|
|
8
10
|
};
|
package/src/types/errors.ts
CHANGED
package/lib/Amplify.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ConsoleLogger as LoggerClass } from './Logger';
|
|
2
|
-
export declare class AmplifyClass {
|
|
3
|
-
private _components;
|
|
4
|
-
private _config;
|
|
5
|
-
private _modules;
|
|
6
|
-
Auth: null;
|
|
7
|
-
Analytics: null;
|
|
8
|
-
API: null;
|
|
9
|
-
Credentials: null;
|
|
10
|
-
Storage: null;
|
|
11
|
-
I18n: null;
|
|
12
|
-
Cache: null;
|
|
13
|
-
PubSub: null;
|
|
14
|
-
Interactions: null;
|
|
15
|
-
Pushnotification: null;
|
|
16
|
-
UI: null;
|
|
17
|
-
XR: null;
|
|
18
|
-
Predictions: null;
|
|
19
|
-
DataStore: null;
|
|
20
|
-
Geo: null;
|
|
21
|
-
Notifications: null;
|
|
22
|
-
Logger: typeof LoggerClass;
|
|
23
|
-
ServiceWorker: null;
|
|
24
|
-
get config(): any;
|
|
25
|
-
register(comp: any): void;
|
|
26
|
-
configure(config?: any): {};
|
|
27
|
-
addPluggable(pluggable: any): void;
|
|
28
|
-
}
|
|
29
|
-
export declare const Amplify: AmplifyClass;
|