@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.
Files changed (98) hide show
  1. package/lib/Platform/types.d.ts +18 -8
  2. package/lib/Platform/types.js +10 -2
  3. package/lib/Platform/version.d.ts +1 -1
  4. package/lib/Platform/version.js +1 -1
  5. package/lib/ServiceWorker/ServiceWorker.js +69 -17
  6. package/lib/ServiceWorker/index.d.ts +0 -12
  7. package/lib/ServiceWorker/index.js +0 -12
  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 +2 -0
  13. package/lib/index.js +7 -1
  14. package/lib/libraryUtils.d.ts +4 -6
  15. package/lib/libraryUtils.js +9 -15
  16. package/lib/parseAWSExports.js +27 -18
  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 +3 -3
  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/Auth/types.d.ts +2 -2
  31. package/lib/singleton/Notifications/PushNotification/types.d.ts +2 -0
  32. package/lib/singleton/Notifications/PushNotification/types.js +4 -0
  33. package/lib/singleton/Notifications/types.d.ts +3 -1
  34. package/lib/tsconfig.tsbuildinfo +1 -1
  35. package/lib/types/errors.d.ts +1 -0
  36. package/lib/types/errors.js +1 -0
  37. package/lib-esm/Platform/types.d.ts +18 -8
  38. package/lib-esm/Platform/types.js +10 -2
  39. package/lib-esm/Platform/version.d.ts +1 -1
  40. package/lib-esm/Platform/version.js +1 -1
  41. package/lib-esm/ServiceWorker/ServiceWorker.js +69 -17
  42. package/lib-esm/ServiceWorker/index.d.ts +0 -12
  43. package/lib-esm/ServiceWorker/index.js +0 -12
  44. package/lib-esm/errors/errorHelpers.d.ts +2 -0
  45. package/lib-esm/errors/errorHelpers.js +17 -0
  46. package/lib-esm/errors/index.d.ts +1 -0
  47. package/lib-esm/errors/index.js +1 -0
  48. package/lib-esm/index.d.ts +2 -0
  49. package/lib-esm/index.js +4 -0
  50. package/lib-esm/libraryUtils.d.ts +4 -6
  51. package/lib-esm/libraryUtils.js +3 -6
  52. package/lib-esm/parseAWSExports.js +27 -18
  53. package/lib-esm/providers/pinpoint/apis/record.d.ts +1 -1
  54. package/lib-esm/providers/pinpoint/apis/record.js +6 -22
  55. package/lib-esm/providers/pinpoint/index.d.ts +2 -2
  56. package/lib-esm/providers/pinpoint/index.js +2 -1
  57. package/lib-esm/providers/pinpoint/types/errors.d.ts +9 -0
  58. package/lib-esm/providers/pinpoint/types/errors.js +12 -0
  59. package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
  60. package/lib-esm/providers/pinpoint/types/index.js +1 -0
  61. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +3 -3
  62. package/lib-esm/providers/pinpoint/utils/index.d.ts +1 -0
  63. package/lib-esm/providers/pinpoint/utils/index.js +1 -0
  64. package/lib-esm/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
  65. package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +81 -0
  66. package/lib-esm/singleton/Auth/types.d.ts +2 -2
  67. package/lib-esm/singleton/Notifications/PushNotification/types.d.ts +2 -0
  68. package/lib-esm/singleton/Notifications/PushNotification/types.js +3 -0
  69. package/lib-esm/singleton/Notifications/types.d.ts +3 -1
  70. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  71. package/lib-esm/types/errors.d.ts +1 -0
  72. package/lib-esm/types/errors.js +1 -0
  73. package/package.json +3 -3
  74. package/src/Platform/types.ts +20 -11
  75. package/src/Platform/version.ts +1 -1
  76. package/src/ServiceWorker/ServiceWorker.ts +20 -17
  77. package/src/ServiceWorker/index.ts +0 -12
  78. package/src/errors/errorHelpers.ts +20 -0
  79. package/src/errors/index.ts +1 -0
  80. package/src/index.ts +6 -0
  81. package/src/libraryUtils.ts +11 -11
  82. package/src/parseAWSExports.ts +19 -14
  83. package/src/providers/pinpoint/apis/record.ts +11 -25
  84. package/src/providers/pinpoint/index.ts +6 -2
  85. package/src/providers/pinpoint/types/errors.ts +12 -0
  86. package/src/providers/pinpoint/types/index.ts +1 -0
  87. package/src/providers/pinpoint/types/pinpoint.ts +3 -2
  88. package/src/providers/pinpoint/utils/index.ts +1 -0
  89. package/src/providers/pinpoint/utils/resolveEndpointId.ts +46 -0
  90. package/src/singleton/Auth/types.ts +2 -2
  91. package/src/singleton/Notifications/PushNotification/types.ts +6 -0
  92. package/src/singleton/Notifications/types.ts +3 -1
  93. package/src/types/errors.ts +1 -0
  94. package/lib/Amplify.d.ts +0 -29
  95. package/lib/Amplify.js +0 -118
  96. package/lib-esm/Amplify.d.ts +0 -29
  97. package/lib-esm/Amplify.js +0 -115
  98. package/src/Amplify.ts +0 -106
@@ -1,4 +1,5 @@
1
1
  export declare enum AmplifyErrorCode {
2
+ NoEndpointId = "NoEndpointId",
2
3
  PlatformNotSupported = "PlatformNotSupported",
3
4
  Unknown = "Unknown"
4
5
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.AmplifyErrorCode = void 0;
6
6
  var AmplifyErrorCode;
7
7
  (function (AmplifyErrorCode) {
8
+ AmplifyErrorCode["NoEndpointId"] = "NoEndpointId";
8
9
  AmplifyErrorCode["PlatformNotSupported"] = "PlatformNotSupported";
9
10
  AmplifyErrorCode["Unknown"] = "Unknown";
10
11
  })(AmplifyErrorCode = exports.AmplifyErrorCode || (exports.AmplifyErrorCode = {}));
@@ -73,7 +73,14 @@ export declare enum DataStoreAction {
73
73
  GraphQl = "2"
74
74
  }
75
75
  export declare enum GeoAction {
76
- None = "0"
76
+ SearchByText = "0",
77
+ SearchByCoordinates = "1",
78
+ SearchForSuggestions = "2",
79
+ SearchByPlaceId = "3",
80
+ SaveGeofences = "4",
81
+ GetGeofence = "5",
82
+ ListGeofences = "6",
83
+ DeleteGeofences = "7"
77
84
  }
78
85
  export declare enum InAppMessagingAction {
79
86
  SyncMessages = "1",
@@ -92,7 +99,8 @@ export declare enum PubSubAction {
92
99
  Subscribe = "1"
93
100
  }
94
101
  export declare enum PushNotificationAction {
95
- None = "0"
102
+ InitializePushNotifications = "1",
103
+ IdentifyUser = "2"
96
104
  }
97
105
  export declare enum StorageAction {
98
106
  UploadData = "1",
@@ -139,23 +147,25 @@ export type CategoryUserAgentStateMap = Record<string, {
139
147
  }>;
140
148
  export type CustomUserAgentStateMap = Record<string, CategoryUserAgentStateMap>;
141
149
  export type AdditionalDetails = [string, string?][];
142
- type StorageUserAgentInput = {
150
+ export type StorageUserAgentInput = {
143
151
  category: Category.Storage;
144
152
  apis: StorageAction[];
153
+ additionalDetails: AdditionalDetails;
145
154
  };
146
- type AuthUserAgentInput = {
155
+ export type AuthUserAgentInput = {
147
156
  category: Category.Auth;
148
157
  apis: AuthAction[];
158
+ additionalDetails: AdditionalDetails;
149
159
  };
150
- type InAppMessagingUserAgentInput = {
160
+ export type InAppMessagingUserAgentInput = {
151
161
  category: Category.InAppMessaging;
152
162
  apis: InAppMessagingAction[];
163
+ additionalDetails: AdditionalDetails;
153
164
  };
154
- type GeoUserAgentInput = {
165
+ export type GeoUserAgentInput = {
155
166
  category: Category.Geo;
156
167
  apis: GeoAction[];
157
- };
158
- export type SetCustomUserAgentInput = (StorageUserAgentInput | AuthUserAgentInput | InAppMessagingUserAgentInput | GeoUserAgentInput) & {
159
168
  additionalDetails: AdditionalDetails;
160
169
  };
170
+ export type SetCustomUserAgentInput = StorageUserAgentInput | AuthUserAgentInput | InAppMessagingUserAgentInput | GeoUserAgentInput;
161
171
  export {};
@@ -85,7 +85,14 @@ export var DataStoreAction;
85
85
  })(DataStoreAction || (DataStoreAction = {}));
86
86
  export var GeoAction;
87
87
  (function (GeoAction) {
88
- GeoAction["None"] = "0";
88
+ GeoAction["SearchByText"] = "0";
89
+ GeoAction["SearchByCoordinates"] = "1";
90
+ GeoAction["SearchForSuggestions"] = "2";
91
+ GeoAction["SearchByPlaceId"] = "3";
92
+ GeoAction["SaveGeofences"] = "4";
93
+ GeoAction["GetGeofence"] = "5";
94
+ GeoAction["ListGeofences"] = "6";
95
+ GeoAction["DeleteGeofences"] = "7";
89
96
  })(GeoAction || (GeoAction = {}));
90
97
  export var InAppMessagingAction;
91
98
  (function (InAppMessagingAction) {
@@ -109,7 +116,8 @@ export var PubSubAction;
109
116
  })(PubSubAction || (PubSubAction = {}));
110
117
  export var PushNotificationAction;
111
118
  (function (PushNotificationAction) {
112
- PushNotificationAction["None"] = "0";
119
+ PushNotificationAction["InitializePushNotifications"] = "1";
120
+ PushNotificationAction["IdentifyUser"] = "2";
113
121
  })(PushNotificationAction || (PushNotificationAction = {}));
114
122
  export var StorageAction;
115
123
  (function (StorageAction) {
@@ -1 +1 @@
1
- export declare const version = "6.0.1-console-preview.5a31ca1.0+5a31ca1";
1
+ export declare const version = "6.0.1-console-preview.8d88eef.0+8d88eef";
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export var version = '6.0.1-console-preview.5a31ca1.0+5a31ca1';
2
+ export var version = '6.0.1-console-preview.8d88eef.0+8d88eef';
@@ -1,10 +1,47 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
3
39
  import { ConsoleLogger as Logger } from '../Logger';
4
40
  import { isBrowser } from '../utils';
5
- import { Amplify } from '../Amplify';
6
41
  import { AmplifyError } from '../errors';
7
42
  import { assert, ServiceWorkerErrorCode } from './errorHelpers';
43
+ import { record } from '../providers/pinpoint';
44
+ import { Amplify, fetchAuthSession } from '../singleton';
8
45
  /**
9
46
  * Provides a means to registering a service worker in the browser
10
47
  * and communicating with it via postMessage events.
@@ -173,19 +210,37 @@ var ServiceWorkerClass = /** @class */ (function () {
173
210
  **/
174
211
  ServiceWorkerClass.prototype._setupListeners = function () {
175
212
  var _this = this;
176
- this.serviceWorker.addEventListener('statechange', function (event) {
177
- var currentState = _this.serviceWorker.state;
178
- _this._logger.debug("ServiceWorker statechange: ".concat(currentState));
179
- Amplify.Analytics;
180
- if (isAmplifyWithAnalytics(Amplify)) {
181
- Amplify.Analytics.record({
182
- name: 'ServiceWorker',
183
- attributes: {
184
- state: currentState,
185
- },
186
- });
187
- }
188
- });
213
+ this.serviceWorker.addEventListener('statechange', function (event) { return __awaiter(_this, void 0, void 0, function () {
214
+ var currentState, _a, appId, region, credentials;
215
+ var _b, _c;
216
+ return __generator(this, function (_d) {
217
+ switch (_d.label) {
218
+ case 0:
219
+ currentState = this.serviceWorker.state;
220
+ this._logger.debug("ServiceWorker statechange: ".concat(currentState));
221
+ _a = (_c = (_b = Amplify.getConfig().Analytics) === null || _b === void 0 ? void 0 : _b.Pinpoint) !== null && _c !== void 0 ? _c : {}, appId = _a.appId, region = _a.region;
222
+ return [4 /*yield*/, fetchAuthSession()];
223
+ case 1:
224
+ credentials = (_d.sent()).credentials;
225
+ if (appId && region && credentials) {
226
+ // Pinpoint is configured, record an event
227
+ record({
228
+ appId: appId,
229
+ region: region,
230
+ category: 'Core',
231
+ credentials: credentials,
232
+ event: {
233
+ name: 'ServiceWorker',
234
+ attributes: {
235
+ state: currentState,
236
+ },
237
+ },
238
+ });
239
+ }
240
+ return [2 /*return*/];
241
+ }
242
+ });
243
+ }); });
189
244
  this.serviceWorker.addEventListener('message', function (event) {
190
245
  _this._logger.debug("ServiceWorker message event: ".concat(event));
191
246
  });
@@ -193,6 +248,3 @@ var ServiceWorkerClass = /** @class */ (function () {
193
248
  return ServiceWorkerClass;
194
249
  }());
195
250
  export { ServiceWorkerClass };
196
- function isAmplifyWithAnalytics(amplify) {
197
- return amplify.Analytics && typeof amplify.Analytics.record === 'function';
198
- }
@@ -1,13 +1 @@
1
- /**
2
- * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
- * the License. A copy of the License is located at
6
- *
7
- * http://aws.amazon.com/apache2.0/
8
- *
9
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
- * and limitations under the License.
12
- */
13
1
  export { ServiceWorkerClass as ServiceWorker } from './ServiceWorker';
@@ -1,15 +1,3 @@
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
  export { ServiceWorkerClass as ServiceWorker } from './ServiceWorker';
@@ -0,0 +1,2 @@
1
+ import { AmplifyErrorCode, AssertionFunction } from '../types';
2
+ export declare const assert: AssertionFunction<AmplifyErrorCode>;
@@ -0,0 +1,17 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ var _a;
4
+ import { createAssertionFunction } from './createAssertionFunction';
5
+ import { AmplifyErrorCode } from '../types';
6
+ var amplifyErrorMap = (_a = {},
7
+ _a[AmplifyErrorCode.NoEndpointId] = {
8
+ message: 'Endpoint ID was not found and was unable to be created.',
9
+ },
10
+ _a[AmplifyErrorCode.PlatformNotSupported] = {
11
+ message: 'Function not supported on current platform.',
12
+ },
13
+ _a[AmplifyErrorCode.Unknown] = {
14
+ message: 'An unknown error occurred.',
15
+ },
16
+ _a);
17
+ export var assert = createAssertionFunction(amplifyErrorMap);
@@ -1,3 +1,4 @@
1
1
  export { AmplifyError } from './AmplifyError';
2
2
  export { createAssertionFunction } from './createAssertionFunction';
3
3
  export { PlatformNotSupportedError } from './PlatformNotSupportedError';
4
+ export { assert } from './errorHelpers';
@@ -3,3 +3,4 @@
3
3
  export { AmplifyError } from './AmplifyError';
4
4
  export { createAssertionFunction } from './createAssertionFunction';
5
5
  export { PlatformNotSupportedError } from './PlatformNotSupportedError';
6
+ export { assert } from './errorHelpers';
@@ -9,3 +9,5 @@ export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, }
9
9
  export { KeyValueStorageInterface } from './types';
10
10
  export { Cache } from './Cache';
11
11
  export { I18n } from './I18n';
12
+ export { ConsoleLogger } from './Logger';
13
+ export { ServiceWorker } from './ServiceWorker';
package/lib-esm/index.js CHANGED
@@ -14,3 +14,7 @@ export { CookieStorage, defaultStorage, sessionStorage, sharedInMemoryStorage, }
14
14
  export { Cache } from './Cache';
15
15
  // Internationalization utilities
16
16
  export { I18n } from './I18n';
17
+ // Logging utilities
18
+ export { ConsoleLogger } from './Logger';
19
+ // Service worker
20
+ export { ServiceWorker } from './ServiceWorker';
@@ -7,17 +7,15 @@ export { decodeJWT, assertTokenProviderConfig, assertIdentityPoolIdConfig, asser
7
7
  export { isTokenExpired } from './singleton/Auth';
8
8
  export { GraphQLAuthMode, DocumentType } from './singleton/API/types';
9
9
  export { Signer } from './Signer';
10
- export { JWT, StrictUnion, CognitoIdentityPoolConfig, JwtPayload, AuthStandardAttributeKey, AuthVerifiableAttributeKey, AWSCredentials } from './singleton/Auth/types';
11
- export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
10
+ export { JWT, StrictUnion, CognitoIdentityPoolConfig, JwtPayload, AuthStandardAttributeKey, AuthVerifiableAttributeKey, AWSCredentials, } from './singleton/Auth/types';
12
11
  export { Platform, getAmplifyUserAgentObject, getAmplifyUserAgent, } from './Platform';
13
- export { ApiAction, AuthAction, AnalyticsAction, Category, CustomUserAgentDetails, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, SetCustomUserAgentInput, } from './Platform/types';
12
+ export { ApiAction, AuthAction, AnalyticsAction, Category, CustomUserAgentDetails, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, SetCustomUserAgentInput, StorageUserAgentInput, AuthUserAgentInput, InAppMessagingUserAgentInput, GeoUserAgentInput, } from './Platform/types';
14
13
  export { setCustomUserAgent } from './Platform/customUserAgent';
15
- export { ServiceWorker } from './ServiceWorker';
14
+ export { AmplifyError, PlatformNotSupportedError, createAssertionFunction, } from './errors';
15
+ export { AmplifyErrorCode, AmplifyErrorMap, AmplifyErrorParams, AssertionFunction, ServiceError, } from './types';
16
16
  export { BackgroundProcessManager } from './BackgroundProcessManager';
17
17
  export { Mutex } from './Mutex';
18
18
  export { Reachability } from './Reachability';
19
- export { AmplifyError, PlatformNotSupportedError, createAssertionFunction, } from './errors';
20
- export { AmplifyErrorCode, AmplifyErrorMap, AmplifyErrorParams, AssertionFunction, ServiceError, } from './types';
21
19
  export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './constants';
22
20
  export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
23
21
  export { AMPLIFY_SYMBOL } from './Hub';
@@ -13,20 +13,17 @@ export { AmplifyUrl, AmplifyUrlSearchParams } from './utils/amplifyUrl';
13
13
  export { decodeJWT, assertTokenProviderConfig, assertIdentityPoolIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
14
14
  export { isTokenExpired } from './singleton/Auth';
15
15
  export { Signer } from './Signer';
16
- // Logging utilities
17
- export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
18
16
  // Platform & user-agent utilities
19
17
  export { Platform, getAmplifyUserAgentObject, getAmplifyUserAgent, } from './Platform';
20
18
  export { ApiAction, AuthAction, AnalyticsAction, Category, DataStoreAction, Framework, GeoAction, InteractionsAction, InAppMessagingAction, PredictionsAction, PubSubAction, PushNotificationAction, StorageAction, } from './Platform/types';
21
19
  export { setCustomUserAgent } from './Platform/customUserAgent';
22
- // Service worker
23
- export { ServiceWorker } from './ServiceWorker';
20
+ // Error handling
21
+ export { AmplifyError, PlatformNotSupportedError, createAssertionFunction, } from './errors';
22
+ export { AmplifyErrorCode, } from './types';
24
23
  // Other utilities & constants
25
24
  export { BackgroundProcessManager } from './BackgroundProcessManager';
26
25
  export { Mutex } from './Mutex';
27
26
  export { Reachability } from './Reachability';
28
- export { AmplifyError, PlatformNotSupportedError, createAssertionFunction, } from './errors';
29
- export { AmplifyErrorCode, } from './types';
30
27
  export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './constants';
31
28
  export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
32
29
  export { AMPLIFY_SYMBOL } from './Hub';
@@ -55,7 +55,7 @@ var authTypeMapping = {
55
55
  * @returns A {@link ResourcesConfig} object.
56
56
  */
57
57
  export var parseAWSExports = function (config) {
58
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
58
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
59
59
  if (config === void 0) { config = {}; }
60
60
  var aws_appsync_apiKey = config.aws_appsync_apiKey, aws_appsync_authenticationType = config.aws_appsync_authenticationType, aws_appsync_graphqlEndpoint = config.aws_appsync_graphqlEndpoint, aws_appsync_region = config.aws_appsync_region, aws_cognito_identity_pool_id = config.aws_cognito_identity_pool_id, aws_cognito_sign_up_verification_method = config.aws_cognito_sign_up_verification_method, aws_cognito_mfa_configuration = config.aws_cognito_mfa_configuration, aws_cognito_mfa_types = config.aws_cognito_mfa_types, aws_cognito_password_protection_settings = config.aws_cognito_password_protection_settings, aws_cognito_verification_mechanisms = config.aws_cognito_verification_mechanisms, aws_cognito_signup_attributes = config.aws_cognito_signup_attributes, aws_cognito_username_attributes = config.aws_cognito_username_attributes, aws_mandatory_sign_in = config.aws_mandatory_sign_in, aws_mobile_analytics_app_id = config.aws_mobile_analytics_app_id, aws_mobile_analytics_app_region = config.aws_mobile_analytics_app_region, aws_user_files_s3_bucket = config.aws_user_files_s3_bucket, aws_user_files_s3_bucket_region = config.aws_user_files_s3_bucket_region, aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing = config.aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing, aws_user_pools_id = config.aws_user_pools_id, aws_user_pools_web_client_id = config.aws_user_pools_web_client_id, geo = config.geo, oauth = config.oauth, aws_cloud_logic_custom = config.aws_cloud_logic_custom, Notifications = config.Notifications;
61
61
  var amplifyConfig = {};
@@ -69,15 +69,24 @@ export var parseAWSExports = function (config) {
69
69
  };
70
70
  }
71
71
  // Notifications
72
- if (Notifications) {
73
- if ((_a = Notifications.InAppMessaging) === null || _a === void 0 ? void 0 : _a.AWSPinpoint) {
74
- var _p = Notifications.InAppMessaging.AWSPinpoint, appId = _p.appId, region = _p.region;
75
- amplifyConfig.Notifications = {
76
- InAppMessaging: {
77
- Pinpoint: {
78
- appId: appId,
79
- region: region,
80
- },
72
+ var _o = Notifications !== null && Notifications !== void 0 ? Notifications : {}, InAppMessaging = _o.InAppMessaging, Push = _o.Push;
73
+ if ((InAppMessaging === null || InAppMessaging === void 0 ? void 0 : InAppMessaging.AWSPinpoint) || (Push === null || Push === void 0 ? void 0 : Push.AWSPinpoint)) {
74
+ amplifyConfig.Notifications = {};
75
+ if (InAppMessaging === null || InAppMessaging === void 0 ? void 0 : InAppMessaging.AWSPinpoint) {
76
+ var _p = InAppMessaging.AWSPinpoint, appId = _p.appId, region = _p.region;
77
+ amplifyConfig.Notifications.InAppMessaging = {
78
+ Pinpoint: {
79
+ appId: appId,
80
+ region: region,
81
+ },
82
+ };
83
+ }
84
+ if (Push === null || Push === void 0 ? void 0 : Push.AWSPinpoint) {
85
+ var _q = Push.AWSPinpoint, appId = _q.appId, region = _q.region;
86
+ amplifyConfig.Notifications.PushNotification = {
87
+ Pinpoint: {
88
+ appId: appId,
89
+ region: region,
81
90
  },
82
91
  };
83
92
  }
@@ -102,17 +111,17 @@ export var parseAWSExports = function (config) {
102
111
  ? {
103
112
  status: aws_cognito_mfa_configuration &&
104
113
  aws_cognito_mfa_configuration.toLowerCase(),
105
- totpEnabled: (_b = aws_cognito_mfa_types === null || aws_cognito_mfa_types === void 0 ? void 0 : aws_cognito_mfa_types.includes('TOTP')) !== null && _b !== void 0 ? _b : false,
106
- smsEnabled: (_c = aws_cognito_mfa_types === null || aws_cognito_mfa_types === void 0 ? void 0 : aws_cognito_mfa_types.includes('SMS')) !== null && _c !== void 0 ? _c : false,
114
+ totpEnabled: (_a = aws_cognito_mfa_types === null || aws_cognito_mfa_types === void 0 ? void 0 : aws_cognito_mfa_types.includes('TOTP')) !== null && _a !== void 0 ? _a : false,
115
+ smsEnabled: (_b = aws_cognito_mfa_types === null || aws_cognito_mfa_types === void 0 ? void 0 : aws_cognito_mfa_types.includes('SMS')) !== null && _b !== void 0 ? _b : false,
107
116
  }
108
117
  : undefined;
109
118
  var passwordFormatConfig = aws_cognito_password_protection_settings
110
119
  ? {
111
120
  minLength: aws_cognito_password_protection_settings.passwordPolicyMinLength,
112
- requireLowercase: (_e = (_d = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _d === void 0 ? void 0 : _d.includes('REQUIRES_LOWERCASE')) !== null && _e !== void 0 ? _e : false,
113
- requireUppercase: (_g = (_f = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _f === void 0 ? void 0 : _f.includes('REQUIRES_UPPERCASE')) !== null && _g !== void 0 ? _g : false,
114
- requireNumbers: (_j = (_h = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _h === void 0 ? void 0 : _h.includes('REQUIRES_NUMBERS')) !== null && _j !== void 0 ? _j : false,
115
- requireSpecialCharacters: (_l = (_k = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _k === void 0 ? void 0 : _k.includes('REQUIRES_SYMBOLS')) !== null && _l !== void 0 ? _l : false,
121
+ requireLowercase: (_d = (_c = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _c === void 0 ? void 0 : _c.includes('REQUIRES_LOWERCASE')) !== null && _d !== void 0 ? _d : false,
122
+ requireUppercase: (_f = (_e = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _e === void 0 ? void 0 : _e.includes('REQUIRES_UPPERCASE')) !== null && _f !== void 0 ? _f : false,
123
+ requireNumbers: (_h = (_g = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _g === void 0 ? void 0 : _g.includes('REQUIRES_NUMBERS')) !== null && _h !== void 0 ? _h : false,
124
+ requireSpecialCharacters: (_k = (_j = aws_cognito_password_protection_settings.passwordPolicyCharacters) === null || _j === void 0 ? void 0 : _j.includes('REQUIRES_SYMBOLS')) !== null && _k !== void 0 ? _k : false,
116
125
  }
117
126
  : undefined;
118
127
  var mergedUserAttributes = Array.from(new Set(__spreadArray(__spreadArray([], __read((aws_cognito_verification_mechanisms !== null && aws_cognito_verification_mechanisms !== void 0 ? aws_cognito_verification_mechanisms : [])), false), __read((aws_cognito_signup_attributes !== null && aws_cognito_signup_attributes !== void 0 ? aws_cognito_signup_attributes : [])), false)));
@@ -124,8 +133,8 @@ export var parseAWSExports = function (config) {
124
133
  },
125
134
  _a);
126
135
  });
127
- var loginWithEmailEnabled = (_m = aws_cognito_username_attributes === null || aws_cognito_username_attributes === void 0 ? void 0 : aws_cognito_username_attributes.includes('EMAIL')) !== null && _m !== void 0 ? _m : false;
128
- var loginWithPhoneEnabled = (_o = aws_cognito_username_attributes === null || aws_cognito_username_attributes === void 0 ? void 0 : aws_cognito_username_attributes.includes('PHONE_NUMBER')) !== null && _o !== void 0 ? _o : false;
136
+ var loginWithEmailEnabled = (_l = aws_cognito_username_attributes === null || aws_cognito_username_attributes === void 0 ? void 0 : aws_cognito_username_attributes.includes('EMAIL')) !== null && _l !== void 0 ? _l : false;
137
+ var loginWithPhoneEnabled = (_m = aws_cognito_username_attributes === null || aws_cognito_username_attributes === void 0 ? void 0 : aws_cognito_username_attributes.includes('PHONE_NUMBER')) !== null && _m !== void 0 ? _m : false;
129
138
  if (aws_cognito_identity_pool_id || aws_user_pools_id) {
130
139
  amplifyConfig.Auth = {
131
140
  Cognito: {
@@ -2,4 +2,4 @@ import { PinpointRecordInput } from '../types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare const record: ({ appId, category, credentials, event, identityId, region, userAgentValue, }: PinpointRecordInput) => Promise<void>;
5
+ export declare const record: ({ appId, category, channelType, credentials, event, identityId, region, userAgentValue, }: PinpointRecordInput) => Promise<void>;
@@ -37,28 +37,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  }
38
38
  };
39
39
  import { amplifyUuid } from '../../../utils/amplifyUuid';
40
- import { getEndpointId } from '../utils';
40
+ import { resolveEndpointId } from '../utils';
41
41
  import { BUFFER_SIZE, FLUSH_INTERVAL, FLUSH_SIZE, RESEND_LIMIT, } from '../utils/constants';
42
- import { updateEndpoint } from './updateEndpoint';
43
42
  import { getEventBuffer } from '../utils/getEventBuffer';
44
- import { AmplifyError } from '../../../errors';
45
43
  // TODO(v6) Refactor when we add support for session tracking & `autoTrack`
46
44
  var session;
47
45
  /**
48
46
  * @internal
49
47
  */
50
48
  export var record = function (_a) {
51
- var appId = _a.appId, category = _a.category, credentials = _a.credentials, event = _a.event, identityId = _a.identityId, region = _a.region, userAgentValue = _a.userAgentValue;
49
+ var appId = _a.appId, category = _a.category, channelType = _a.channelType, credentials = _a.credentials, event = _a.event, identityId = _a.identityId, region = _a.region, userAgentValue = _a.userAgentValue;
52
50
  return __awaiter(void 0, void 0, void 0, function () {
53
- var timestampISOString, eventId, endpointId, buffer, sessionId;
51
+ var timestampISOString, eventId, buffer, endpointId, sessionId;
54
52
  return __generator(this, function (_b) {
55
53
  switch (_b.label) {
56
54
  case 0:
57
55
  timestampISOString = new Date().toISOString();
58
56
  eventId = amplifyUuid();
59
- return [4 /*yield*/, getEndpointId(appId, category)];
60
- case 1:
61
- endpointId = _b.sent();
62
57
  buffer = getEventBuffer({
63
58
  appId: appId,
64
59
  bufferSize: BUFFER_SIZE,
@@ -70,28 +65,17 @@ export var record = function (_a) {
70
65
  resendLimit: RESEND_LIMIT,
71
66
  userAgentValue: userAgentValue,
72
67
  });
73
- if (!!endpointId) return [3 /*break*/, 4];
74
- return [4 /*yield*/, updateEndpoint({
68
+ return [4 /*yield*/, resolveEndpointId({
75
69
  appId: appId,
76
70
  category: category,
71
+ channelType: channelType,
77
72
  credentials: credentials,
78
73
  identityId: identityId,
79
74
  region: region,
80
75
  userAgentValue: userAgentValue,
81
76
  })];
82
- case 2:
83
- _b.sent();
84
- return [4 /*yield*/, getEndpointId(appId, category)];
85
- case 3:
77
+ case 1:
86
78
  endpointId = _b.sent();
87
- _b.label = 4;
88
- case 4:
89
- if (!endpointId) {
90
- throw new AmplifyError({
91
- name: 'ENDPOINT_NOT_CREATED',
92
- message: 'Endpoint was not created.',
93
- });
94
- }
95
79
  // Generate session if required
96
80
  if (!session) {
97
81
  sessionId = amplifyUuid();
@@ -1,3 +1,3 @@
1
1
  export * from './apis';
2
- export { PinpointAnalyticsEvent, PinpointServiceOptions } from './types';
3
- export { getEndpointId } from './utils';
2
+ export { PinpointAnalyticsEvent, PinpointServiceOptions, UpdateEndpointException, } from './types';
3
+ export { resolveEndpointId } from './utils';
@@ -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
  export * from './apis';
4
- export { getEndpointId } from './utils';
4
+ export { UpdateEndpointException, } from './types';
5
+ export { resolveEndpointId } from './utils';
@@ -0,0 +1,9 @@
1
+ export declare enum UpdateEndpointException {
2
+ BadRequestException = "BadRequestException",
3
+ ForbiddenException = "ForbiddenException",
4
+ InternalServerErrorException = "InternalServerErrorException",
5
+ MethodNotAllowedException = "MethodNotAllowedException",
6
+ NotFoundException = "NotFoundException",
7
+ PayloadTooLargeException = "PayloadTooLargeException",
8
+ TooManyRequestsException = "TooManyRequestsException"
9
+ }
@@ -0,0 +1,12 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export var UpdateEndpointException;
4
+ (function (UpdateEndpointException) {
5
+ UpdateEndpointException["BadRequestException"] = "BadRequestException";
6
+ UpdateEndpointException["ForbiddenException"] = "ForbiddenException";
7
+ UpdateEndpointException["InternalServerErrorException"] = "InternalServerErrorException";
8
+ UpdateEndpointException["MethodNotAllowedException"] = "MethodNotAllowedException";
9
+ UpdateEndpointException["NotFoundException"] = "NotFoundException";
10
+ UpdateEndpointException["PayloadTooLargeException"] = "PayloadTooLargeException";
11
+ UpdateEndpointException["TooManyRequestsException"] = "TooManyRequestsException";
12
+ })(UpdateEndpointException || (UpdateEndpointException = {}));
@@ -1 +1,2 @@
1
+ export { UpdateEndpointException } from './errors';
1
2
  export * from './pinpoint';
@@ -1,3 +1,4 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ export { UpdateEndpointException } from './errors';
3
4
  export * from './pinpoint';
@@ -1,7 +1,7 @@
1
1
  import { AuthSession } from '../../../singleton/Auth/types';
2
2
  import { UserProfile } from '../../../types';
3
- export type SupportedCategory = 'Analytics' | 'InAppMessaging' | 'PushNotification';
4
- export type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
3
+ export type SupportedCategory = 'Analytics' | 'Core' | 'InAppMessaging' | 'PushNotification';
4
+ type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
5
5
  export type PinpointProviderConfig = {
6
6
  Pinpoint?: {
7
7
  appId: string;
@@ -25,13 +25,13 @@ export type PinpointAnalyticsEvent = {
25
25
  type PinpointCommonParameters = {
26
26
  appId: string;
27
27
  category: SupportedCategory;
28
+ channelType?: SupportedChannelType;
28
29
  credentials: Required<AuthSession>['credentials'];
29
30
  identityId?: AuthSession['identityId'];
30
31
  region: string;
31
32
  userAgentValue?: string;
32
33
  };
33
34
  export type PinpointUpdateEndpointInput = PinpointCommonParameters & PinpointServiceOptions & {
34
- channelType?: SupportedChannelType;
35
35
  userId?: string;
36
36
  userProfile?: UserProfile;
37
37
  };
@@ -1,3 +1,4 @@
1
1
  export { cacheEndpointId } from './cacheEndpointId';
2
2
  export { getCacheKey } from './getCacheKey';
3
3
  export { getEndpointId } from './getEndpointId';
4
+ export { resolveEndpointId } from './resolveEndpointId';
@@ -3,3 +3,4 @@
3
3
  export { cacheEndpointId } from './cacheEndpointId';
4
4
  export { getCacheKey } from './getCacheKey';
5
5
  export { getEndpointId } from './getEndpointId';
6
+ export { resolveEndpointId } from './resolveEndpointId';
@@ -0,0 +1,8 @@
1
+ import { PinpointUpdateEndpointInput } from '../types';
2
+ /**
3
+ * Resolves an endpoint id from cache or prepare via updateEndpoint if one does not already exist,
4
+ * which will generate and cache an endpoint id between calls.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare const resolveEndpointId: ({ address, appId, category, channelType, credentials, identityId, region, userAgentValue, }: PinpointUpdateEndpointInput) => Promise<string>;