@aws-amplify/core 6.0.1-console-preview.8f82e46.0 → 6.0.1-console-preview.b278dcb.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.
Files changed (122) hide show
  1. package/lib/Cache/StorageCacheCommon.js +1 -4
  2. package/lib/I18n/I18n.js +1 -6
  3. package/lib/Platform/types.d.ts +18 -8
  4. package/lib/Platform/types.js +10 -2
  5. package/lib/Platform/version.d.ts +1 -1
  6. package/lib/Platform/version.js +1 -1
  7. package/lib/Reachability/Reachability.js +6 -1
  8. package/lib/errors/errorHelpers.d.ts +2 -0
  9. package/lib/errors/errorHelpers.js +20 -0
  10. package/lib/errors/index.d.ts +1 -0
  11. package/lib/errors/index.js +3 -1
  12. package/lib/index.d.ts +3 -1
  13. package/lib/index.js +4 -1
  14. package/lib/libraryUtils.d.ts +6 -5
  15. package/lib/libraryUtils.js +12 -12
  16. package/lib/parseAWSExports.js +34 -19
  17. package/lib/providers/pinpoint/apis/record.d.ts +1 -1
  18. package/lib/providers/pinpoint/apis/record.js +5 -21
  19. package/lib/providers/pinpoint/index.d.ts +2 -2
  20. package/lib/providers/pinpoint/index.js +4 -2
  21. package/lib/providers/pinpoint/types/errors.d.ts +9 -0
  22. package/lib/providers/pinpoint/types/errors.js +15 -0
  23. package/lib/providers/pinpoint/types/index.d.ts +1 -0
  24. package/lib/providers/pinpoint/types/index.js +3 -0
  25. package/lib/providers/pinpoint/types/pinpoint.d.ts +2 -2
  26. package/lib/providers/pinpoint/utils/index.d.ts +1 -0
  27. package/lib/providers/pinpoint/utils/index.js +3 -1
  28. package/lib/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
  29. package/lib/providers/pinpoint/utils/resolveEndpointId.js +85 -0
  30. package/lib/singleton/Interactions/types.d.ts +21 -0
  31. package/lib/singleton/Interactions/types.js +4 -0
  32. package/lib/singleton/Notifications/PushNotification/types.d.ts +2 -0
  33. package/lib/singleton/Notifications/PushNotification/types.js +4 -0
  34. package/lib/singleton/Notifications/types.d.ts +3 -1
  35. package/lib/singleton/types.d.ts +3 -5
  36. package/lib/tsconfig.tsbuildinfo +1 -1
  37. package/lib/types/errors.d.ts +1 -0
  38. package/lib/types/errors.js +1 -0
  39. package/lib/utils/deepFreeze.js +1 -1
  40. package/lib/utils/sessionListener/SessionListener.d.ts +10 -0
  41. package/lib/utils/sessionListener/SessionListener.js +55 -0
  42. package/lib/utils/sessionListener/SessionListener.native.d.ts +10 -0
  43. package/lib/utils/sessionListener/SessionListener.native.js +54 -0
  44. package/lib/utils/sessionListener/index.d.ts +2 -0
  45. package/lib/utils/sessionListener/index.js +7 -0
  46. package/lib/utils/sessionListener/types.d.ts +6 -0
  47. package/lib/utils/sessionListener/types.js +4 -0
  48. package/lib-esm/Cache/StorageCacheCommon.js +1 -4
  49. package/lib-esm/I18n/I18n.js +1 -6
  50. package/lib-esm/Platform/types.d.ts +18 -8
  51. package/lib-esm/Platform/types.js +10 -2
  52. package/lib-esm/Platform/version.d.ts +1 -1
  53. package/lib-esm/Platform/version.js +1 -1
  54. package/lib-esm/Reachability/Reachability.js +7 -2
  55. package/lib-esm/errors/errorHelpers.d.ts +2 -0
  56. package/lib-esm/errors/errorHelpers.js +17 -0
  57. package/lib-esm/errors/index.d.ts +1 -0
  58. package/lib-esm/errors/index.js +1 -0
  59. package/lib-esm/index.d.ts +3 -1
  60. package/lib-esm/index.js +2 -0
  61. package/lib-esm/libraryUtils.d.ts +6 -5
  62. package/lib-esm/libraryUtils.js +5 -4
  63. package/lib-esm/parseAWSExports.js +34 -19
  64. package/lib-esm/providers/pinpoint/apis/record.d.ts +1 -1
  65. package/lib-esm/providers/pinpoint/apis/record.js +6 -22
  66. package/lib-esm/providers/pinpoint/index.d.ts +2 -2
  67. package/lib-esm/providers/pinpoint/index.js +2 -1
  68. package/lib-esm/providers/pinpoint/types/errors.d.ts +9 -0
  69. package/lib-esm/providers/pinpoint/types/errors.js +12 -0
  70. package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
  71. package/lib-esm/providers/pinpoint/types/index.js +1 -0
  72. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +2 -2
  73. package/lib-esm/providers/pinpoint/utils/index.d.ts +1 -0
  74. package/lib-esm/providers/pinpoint/utils/index.js +1 -0
  75. package/lib-esm/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
  76. package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +81 -0
  77. package/lib-esm/singleton/Interactions/types.d.ts +21 -0
  78. package/lib-esm/singleton/Interactions/types.js +3 -0
  79. package/lib-esm/singleton/Notifications/PushNotification/types.d.ts +2 -0
  80. package/lib-esm/singleton/Notifications/PushNotification/types.js +3 -0
  81. package/lib-esm/singleton/Notifications/types.d.ts +3 -1
  82. package/lib-esm/singleton/types.d.ts +3 -5
  83. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  84. package/lib-esm/types/errors.d.ts +1 -0
  85. package/lib-esm/types/errors.js +1 -0
  86. package/lib-esm/utils/deepFreeze.js +1 -1
  87. package/lib-esm/utils/sessionListener/SessionListener.d.ts +10 -0
  88. package/lib-esm/utils/sessionListener/SessionListener.js +52 -0
  89. package/lib-esm/utils/sessionListener/SessionListener.native.d.ts +10 -0
  90. package/lib-esm/utils/sessionListener/SessionListener.native.js +51 -0
  91. package/lib-esm/utils/sessionListener/index.d.ts +2 -0
  92. package/lib-esm/utils/sessionListener/index.js +4 -0
  93. package/lib-esm/utils/sessionListener/types.d.ts +6 -0
  94. package/lib-esm/utils/sessionListener/types.js +3 -0
  95. package/package.json +4 -4
  96. package/src/Cache/StorageCacheCommon.ts +0 -4
  97. package/src/I18n/I18n.ts +1 -6
  98. package/src/Platform/types.ts +20 -11
  99. package/src/Platform/version.ts +1 -1
  100. package/src/Reachability/Reachability.ts +8 -2
  101. package/src/errors/errorHelpers.ts +20 -0
  102. package/src/errors/index.ts +1 -0
  103. package/src/index.ts +4 -1
  104. package/src/libraryUtils.ts +15 -8
  105. package/src/parseAWSExports.ts +28 -14
  106. package/src/providers/pinpoint/apis/record.ts +11 -25
  107. package/src/providers/pinpoint/index.ts +6 -2
  108. package/src/providers/pinpoint/types/errors.ts +12 -0
  109. package/src/providers/pinpoint/types/index.ts +1 -0
  110. package/src/providers/pinpoint/types/pinpoint.ts +2 -2
  111. package/src/providers/pinpoint/utils/index.ts +1 -0
  112. package/src/providers/pinpoint/utils/resolveEndpointId.ts +46 -0
  113. package/src/singleton/Interactions/types.ts +29 -0
  114. package/src/singleton/Notifications/PushNotification/types.ts +6 -0
  115. package/src/singleton/Notifications/types.ts +3 -1
  116. package/src/singleton/types.ts +3 -7
  117. package/src/types/errors.ts +1 -0
  118. package/src/utils/deepFreeze.ts +1 -1
  119. package/src/utils/sessionListener/SessionListener.native.ts +70 -0
  120. package/src/utils/sessionListener/SessionListener.ts +74 -0
  121. package/src/utils/sessionListener/index.ts +6 -0
  122. package/src/utils/sessionListener/types.ts +11 -0
@@ -1,4 +1,5 @@
1
1
  export declare enum AmplifyErrorCode {
2
+ NoEndpointId = "NoEndpointId",
2
3
  PlatformNotSupported = "PlatformNotSupported",
3
4
  Unknown = "Unknown"
4
5
  }
@@ -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 = {}));
@@ -18,7 +18,7 @@ export var deepFreeze = function (object) {
18
18
  for (var propNames_1 = __values(propNames), propNames_1_1 = propNames_1.next(); !propNames_1_1.done; propNames_1_1 = propNames_1.next()) {
19
19
  var name_1 = propNames_1_1.value;
20
20
  var value = object[name_1];
21
- if ((value && typeof value === "object") || typeof value === "function") {
21
+ if ((value && typeof value === 'object') || typeof value === 'function') {
22
22
  deepFreeze(value);
23
23
  }
24
24
  }
@@ -0,0 +1,10 @@
1
+ import { SessionStateChangeListener, SessionListenerInterface } from './types';
2
+ export declare class SessionListener implements SessionListenerInterface {
3
+ private listenerActive;
4
+ constructor();
5
+ addStateChangeListener(listener: SessionStateChangeListener, notifyOnAdd?: boolean): void;
6
+ removeStateChangeListener(handler: SessionStateChangeListener): void;
7
+ private handleVisibilityChange;
8
+ private notifyHandlers;
9
+ private getSessionState;
10
+ }
@@ -0,0 +1,52 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { isBrowser } from '../isBrowser';
4
+ var stateChangeListeners = new Set();
5
+ var SessionListener = /** @class */ (function () {
6
+ function SessionListener() {
7
+ this.listenerActive = false;
8
+ this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
9
+ // Setup state listeners
10
+ if (isBrowser()) {
11
+ document.addEventListener('visibilitychange', this.handleVisibilityChange, false);
12
+ this.listenerActive = true;
13
+ }
14
+ }
15
+ SessionListener.prototype.addStateChangeListener = function (listener, notifyOnAdd) {
16
+ if (notifyOnAdd === void 0) { notifyOnAdd = false; }
17
+ // No-op if document listener is not active
18
+ if (!this.listenerActive) {
19
+ return;
20
+ }
21
+ stateChangeListeners.add(listener);
22
+ // Notify new handlers of the current status on add
23
+ if (notifyOnAdd) {
24
+ listener(this.getSessionState());
25
+ }
26
+ };
27
+ SessionListener.prototype.removeStateChangeListener = function (handler) {
28
+ // No-op if document listener is not active
29
+ if (!this.listenerActive) {
30
+ return;
31
+ }
32
+ stateChangeListeners.delete(handler);
33
+ };
34
+ SessionListener.prototype.handleVisibilityChange = function () {
35
+ this.notifyHandlers();
36
+ };
37
+ SessionListener.prototype.notifyHandlers = function () {
38
+ var sessionState = this.getSessionState();
39
+ stateChangeListeners.forEach(function (listener) {
40
+ listener(sessionState);
41
+ });
42
+ };
43
+ SessionListener.prototype.getSessionState = function () {
44
+ if (isBrowser() && document.visibilityState !== 'hidden') {
45
+ return 'started';
46
+ }
47
+ // If, for any reason, document is undefined the session will never start
48
+ return 'ended';
49
+ };
50
+ return SessionListener;
51
+ }());
52
+ export { SessionListener };
@@ -0,0 +1,10 @@
1
+ import { SessionStateChangeListener, SessionListenerInterface } from './types';
2
+ export declare class SessionListener implements SessionListenerInterface {
3
+ private currentAppState?;
4
+ constructor();
5
+ addStateChangeListener(listener: SessionStateChangeListener, notifyOnAdd?: boolean): void;
6
+ removeStateChangeListener(handler: SessionStateChangeListener): void;
7
+ private handleStateChange;
8
+ private notifyHandlers;
9
+ private getSessionState;
10
+ }
@@ -0,0 +1,51 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { loadAppState } from '@aws-amplify/react-native';
4
+ var stateChangeListeners = new Set();
5
+ var isActive = function (appState) { return appState === 'active'; };
6
+ var isInactive = function (appState) {
7
+ return appState === 'inactive' || appState === 'background';
8
+ };
9
+ var SessionListener = /** @class */ (function () {
10
+ function SessionListener() {
11
+ this.handleStateChange = this.handleStateChange.bind(this);
12
+ // Setup state listeners
13
+ loadAppState().addEventListener('change', this.handleStateChange);
14
+ }
15
+ SessionListener.prototype.addStateChangeListener = function (listener, notifyOnAdd) {
16
+ if (notifyOnAdd === void 0) { notifyOnAdd = false; }
17
+ stateChangeListeners.add(listener);
18
+ // Notify new handlers of the current state on add if the current state has been determined
19
+ if (notifyOnAdd && this.currentAppState !== undefined) {
20
+ listener(this.getSessionState());
21
+ }
22
+ };
23
+ SessionListener.prototype.removeStateChangeListener = function (handler) {
24
+ stateChangeListeners.delete(handler);
25
+ };
26
+ SessionListener.prototype.handleStateChange = function (nextAppState) {
27
+ if ((this.currentAppState === undefined ||
28
+ isInactive(this.currentAppState)) &&
29
+ isActive(nextAppState)) {
30
+ this.notifyHandlers('started');
31
+ }
32
+ else if (isActive(this.currentAppState) && isInactive(nextAppState)) {
33
+ this.notifyHandlers('ended');
34
+ }
35
+ this.currentAppState = nextAppState;
36
+ };
37
+ SessionListener.prototype.notifyHandlers = function (state) {
38
+ stateChangeListeners.forEach(function (listener) {
39
+ listener(state);
40
+ });
41
+ };
42
+ SessionListener.prototype.getSessionState = function () {
43
+ if (isActive(this.currentAppState)) {
44
+ return 'started';
45
+ }
46
+ // Consider any other app state as ended
47
+ return 'ended';
48
+ };
49
+ return SessionListener;
50
+ }());
51
+ export { SessionListener };
@@ -0,0 +1,2 @@
1
+ import { SessionListener } from './SessionListener';
2
+ export declare const sessionListener: SessionListener;
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { SessionListener } from './SessionListener';
4
+ export var sessionListener = new SessionListener();
@@ -0,0 +1,6 @@
1
+ export type SessionState = 'started' | 'ended';
2
+ export type SessionStateChangeListener = (state: SessionState) => void;
3
+ export interface SessionListenerInterface {
4
+ addStateChangeListener: (listener: SessionStateChangeListener) => void;
5
+ removeStateChangeListener: (listener: SessionStateChangeListener) => void;
6
+ }
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/core",
3
- "version": "6.0.1-console-preview.8f82e46.0+8f82e46",
3
+ "version": "6.0.1-console-preview.b278dcb.0+b278dcb",
4
4
  "description": "Core category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -55,7 +55,7 @@
55
55
  "server"
56
56
  ],
57
57
  "dependencies": {
58
- "@aws-crypto/sha256-js": "5.0.0",
58
+ "@aws-crypto/sha256-js": "5.2.0",
59
59
  "@aws-sdk/types": "3.398.0",
60
60
  "@smithy/util-hex-encoding": "2.0.0",
61
61
  "js-cookie": "^3.0.5",
@@ -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.8f82e46.0+8f82e46",
67
+ "@aws-amplify/react-native": "1.0.1-console-preview.b278dcb.0+b278dcb",
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": "8f82e460c4cdb9e52e0ba7ed8aea90f627a27693"
172
+ "gitHead": "b278dcb6dd7334e53d92d22386a22fba3c4a6089"
173
173
  }
@@ -1,7 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { Amplify } from '../singleton';
5
4
  import { ConsoleLogger as Logger } from '../Logger';
6
5
  import { KeyValueStorageInterface } from '../types';
7
6
  import { currentSizeKey, defaultConfig } from './constants';
@@ -31,11 +30,8 @@ export abstract class StorageCacheCommon {
31
30
  config?: CacheConfig;
32
31
  keyValueStorage: KeyValueStorageInterface;
33
32
  }) {
34
- const globalCacheConfig = Amplify.getConfig().Cache ?? {};
35
-
36
33
  this.config = {
37
34
  ...defaultConfig,
38
- ...globalCacheConfig,
39
35
  ...config,
40
36
  };
41
37
  this.keyValueStorage = keyValueStorage;
package/src/I18n/I18n.ts CHANGED
@@ -37,12 +37,7 @@ export class I18n {
37
37
  * Sets the default language from the configuration when required.
38
38
  */
39
39
  setDefaultLanguage() {
40
- if (!this._lang) {
41
- const i18nConfig = Amplify.getConfig().I18n;
42
- this._lang = i18nConfig?.language;
43
- }
44
-
45
- // Default to window language if not set in config
40
+ // Default to window language if not set in instance
46
41
  if (
47
42
  !this._lang &&
48
43
  typeof window !== 'undefined' &&
@@ -83,7 +83,14 @@ export enum DataStoreAction {
83
83
  GraphQl = '2',
84
84
  }
85
85
  export enum GeoAction {
86
- None = '0',
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
- None = '0',
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;
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '6.0.1-console-preview.8f82e46.0+8f82e46';
2
+ export const version = '6.0.1-console-preview.b278dcb.0+b278dcb';
@@ -1,7 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { CompletionObserver, Observable } from 'rxjs';
4
+ import { CompletionObserver, Observable, from } from 'rxjs';
5
5
  import { isWebWorker } from '../libraryUtils';
6
6
  import { NetworkStatus } from './types';
7
7
 
@@ -9,7 +9,13 @@ export class Reachability {
9
9
  private static _observers: Array<CompletionObserver<NetworkStatus>> = [];
10
10
 
11
11
  networkMonitor(_?: unknown): Observable<NetworkStatus> {
12
- const globalObj = isWebWorker() ? self : window;
12
+ const globalObj = isWebWorker()
13
+ ? self
14
+ : typeof window !== 'undefined' && window;
15
+
16
+ if (!globalObj) {
17
+ return from([{ online: true }]);
18
+ }
13
19
 
14
20
  return new Observable(observer => {
15
21
  observer.next({ online: globalObj.navigator.onLine });
@@ -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);
@@ -4,3 +4,4 @@
4
4
  export { AmplifyError } from './AmplifyError';
5
5
  export { createAssertionFunction } from './createAssertionFunction';
6
6
  export { PlatformNotSupportedError } from './PlatformNotSupportedError';
7
+ export { assert } from './errorHelpers';
package/src/index.ts CHANGED
@@ -24,7 +24,6 @@ export {
24
24
  AuthUserPoolConfig,
25
25
  AuthUserPoolAndIdentityPoolConfig,
26
26
  APIConfig,
27
- CacheConfig,
28
27
  StorageAccessLevel,
29
28
  StorageConfig,
30
29
  GetCredentialsOptions,
@@ -62,9 +61,13 @@ export { KeyValueStorageInterface } from './types';
62
61
 
63
62
  // Cache exports
64
63
  export { Cache } from './Cache';
64
+ export { CacheConfig } from './Cache/types';
65
65
 
66
66
  // Internationalization utilities
67
67
  export { I18n } from './I18n';
68
68
 
69
+ // Logging utilities
70
+ export { ConsoleLogger } from './Logger';
71
+
69
72
  // Service worker
70
73
  export { ServiceWorker } from './ServiceWorker';
@@ -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,13 +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
- // Other utilities & constants
75
- export { BackgroundProcessManager } from './BackgroundProcessManager';
76
- export { Mutex } from './Mutex';
77
- export { Reachability } from './Reachability';
75
+ // Error handling
78
76
  export {
79
77
  AmplifyError,
80
78
  PlatformNotSupportedError,
@@ -87,6 +85,11 @@ export {
87
85
  AssertionFunction,
88
86
  ServiceError,
89
87
  } from './types';
88
+
89
+ // Other utilities & constants
90
+ export { BackgroundProcessManager } from './BackgroundProcessManager';
91
+ export { Mutex } from './Mutex';
92
+ export { Reachability } from './Reachability';
90
93
  export {
91
94
  INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER,
92
95
  USER_AGENT_HEADER,
@@ -98,3 +101,7 @@ export { getCrypto } from './utils/globalHelpers';
98
101
 
99
102
  // Hub
100
103
  export { HubInternal } from './Hub';
104
+
105
+ // Session listener
106
+ export { sessionListener } from './utils/sessionListener';
107
+ export { SessionState } from './utils/sessionListener/types';
@@ -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');
@@ -36,6 +32,8 @@ export const parseAWSExports = (
36
32
  aws_appsync_authenticationType,
37
33
  aws_appsync_graphqlEndpoint,
38
34
  aws_appsync_region,
35
+ aws_bots,
36
+ aws_bots_config,
39
37
  aws_cognito_identity_pool_id,
40
38
  aws_cognito_sign_up_verification_method,
41
39
  aws_cognito_mfa_configuration,
@@ -70,20 +68,36 @@ export const parseAWSExports = (
70
68
  }
71
69
 
72
70
  // Notifications
73
- if (Notifications) {
74
- if (Notifications.InAppMessaging?.AWSPinpoint) {
75
- const { appId, region } = Notifications.InAppMessaging.AWSPinpoint;
76
- amplifyConfig.Notifications = {
77
- InAppMessaging: {
78
- Pinpoint: {
79
- appId,
80
- region,
81
- },
71
+ const { InAppMessaging, Push } = Notifications ?? {};
72
+ if (InAppMessaging?.AWSPinpoint || Push?.AWSPinpoint) {
73
+ amplifyConfig.Notifications = {};
74
+ if (InAppMessaging?.AWSPinpoint) {
75
+ const { appId, region } = InAppMessaging.AWSPinpoint;
76
+ amplifyConfig.Notifications.InAppMessaging = {
77
+ Pinpoint: {
78
+ appId,
79
+ region,
80
+ },
81
+ };
82
+ }
83
+ if (Push?.AWSPinpoint) {
84
+ const { appId, region } = Push.AWSPinpoint;
85
+ amplifyConfig.Notifications.PushNotification = {
86
+ Pinpoint: {
87
+ appId,
88
+ region,
82
89
  },
83
90
  };
84
91
  }
85
92
  }
86
93
 
94
+ // Interactions
95
+ if (Array.isArray(aws_bots_config)) {
96
+ amplifyConfig.Interactions = {
97
+ LexV1: Object.fromEntries(aws_bots_config.map(bot => [bot.name, bot])),
98
+ };
99
+ }
100
+
87
101
  // API
88
102
  if (aws_appsync_graphqlEndpoint) {
89
103
  const defaultAuthMode = authTypeMapping[aws_appsync_authenticationType];
@@ -3,16 +3,14 @@
3
3
 
4
4
  import { amplifyUuid } from '../../../utils/amplifyUuid';
5
5
  import { PinpointRecordInput, PinpointSession } from '../types';
6
- import { getEndpointId } from '../utils';
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
- // Prepare a Pinpoint endpoint via updateEndpoint if one does not already exist, which will generate and cache an
50
- // endpoint ID between calls
51
- if (!endpointId) {
52
- await updateEndpoint({
53
- appId,
54
- category,
55
- credentials,
56
- identityId,
57
- region,
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 { PinpointAnalyticsEvent, PinpointServiceOptions } from './types';
6
- export { getEndpointId } from './utils';
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
+ }
@@ -1,4 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ export { UpdateEndpointException } from './errors';
4
5
  export * from './pinpoint';
@@ -10,7 +10,7 @@ export type SupportedCategory =
10
10
  | 'InAppMessaging'
11
11
  | 'PushNotification';
12
12
 
13
- export type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
13
+ type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
14
14
 
15
15
  export type PinpointProviderConfig = {
16
16
  Pinpoint?: {
@@ -40,6 +40,7 @@ export type PinpointAnalyticsEvent = {
40
40
  type PinpointCommonParameters = {
41
41
  appId: string;
42
42
  category: SupportedCategory;
43
+ channelType?: SupportedChannelType;
43
44
  credentials: Required<AuthSession>['credentials'];
44
45
  identityId?: AuthSession['identityId'];
45
46
  region: string;
@@ -48,7 +49,6 @@ type PinpointCommonParameters = {
48
49
 
49
50
  export type PinpointUpdateEndpointInput = PinpointCommonParameters &
50
51
  PinpointServiceOptions & {
51
- channelType?: SupportedChannelType;
52
52
  userId?: string;
53
53
  userProfile?: UserProfile;
54
54
  };
@@ -4,3 +4,4 @@
4
4
  export { cacheEndpointId } from './cacheEndpointId';
5
5
  export { getCacheKey } from './getCacheKey';
6
6
  export { getEndpointId } from './getEndpointId';
7
+ export { resolveEndpointId } from './resolveEndpointId';