@aws-amplify/core 6.0.1-console-preview.f7f118b.0 → 6.0.1-console-preview.8f82e46.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 (40) hide show
  1. package/lib/Platform/version.d.ts +1 -1
  2. package/lib/Platform/version.js +1 -1
  3. package/lib/ServiceWorker/ServiceWorker.js +69 -17
  4. package/lib/ServiceWorker/index.d.ts +0 -12
  5. package/lib/ServiceWorker/index.js +0 -12
  6. package/lib/index.d.ts +1 -0
  7. package/lib/index.js +4 -1
  8. package/lib/libraryUtils.d.ts +0 -1
  9. package/lib/libraryUtils.js +2 -5
  10. package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
  11. package/lib/singleton/Auth/types.d.ts +2 -2
  12. package/lib/storage/CookieStorage.js +8 -5
  13. package/lib/tsconfig.tsbuildinfo +1 -1
  14. package/lib-esm/Platform/version.d.ts +1 -1
  15. package/lib-esm/Platform/version.js +1 -1
  16. package/lib-esm/ServiceWorker/ServiceWorker.js +69 -17
  17. package/lib-esm/ServiceWorker/index.d.ts +0 -12
  18. package/lib-esm/ServiceWorker/index.js +0 -12
  19. package/lib-esm/index.d.ts +1 -0
  20. package/lib-esm/index.js +2 -0
  21. package/lib-esm/libraryUtils.d.ts +0 -1
  22. package/lib-esm/libraryUtils.js +0 -2
  23. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
  24. package/lib-esm/singleton/Auth/types.d.ts +2 -2
  25. package/lib-esm/storage/CookieStorage.js +5 -5
  26. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +5 -5
  28. package/src/Platform/version.ts +1 -1
  29. package/src/ServiceWorker/ServiceWorker.ts +20 -17
  30. package/src/ServiceWorker/index.ts +0 -12
  31. package/src/index.ts +3 -0
  32. package/src/libraryUtils.ts +0 -3
  33. package/src/providers/pinpoint/types/pinpoint.ts +1 -0
  34. package/src/singleton/Auth/types.ts +2 -2
  35. package/src/storage/CookieStorage.ts +5 -9
  36. package/lib/Amplify.d.ts +0 -29
  37. package/lib/Amplify.js +0 -118
  38. package/lib-esm/Amplify.d.ts +0 -29
  39. package/lib-esm/Amplify.js +0 -115
  40. package/src/Amplify.ts +0 -106
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/core",
3
- "version": "6.0.1-console-preview.f7f118b.0+f7f118b",
3
+ "version": "6.0.1-console-preview.8f82e46.0+8f82e46",
4
4
  "description": "Core category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -58,14 +58,14 @@
58
58
  "@aws-crypto/sha256-js": "5.0.0",
59
59
  "@aws-sdk/types": "3.398.0",
60
60
  "@smithy/util-hex-encoding": "2.0.0",
61
- "js-cookie": "^2.2.1",
61
+ "js-cookie": "^3.0.5",
62
62
  "rxjs": "^7.8.1",
63
63
  "tslib": "^2.5.0",
64
64
  "uuid": "^9.0.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@aws-amplify/react-native": "1.0.1-console-preview.f7f118b.0+f7f118b",
68
- "@types/js-cookie": "^2.2.7",
67
+ "@aws-amplify/react-native": "1.0.1-console-preview.8f82e46.0+8f82e46",
68
+ "@types/js-cookie": "3.0.2",
69
69
  "@types/uuid": "^9.0.0",
70
70
  "find": "^0.2.7",
71
71
  "genversion": "^2.2.0",
@@ -169,5 +169,5 @@
169
169
  "lib-esm"
170
170
  ]
171
171
  },
172
- "gitHead": "f7f118b047bb772ef12531eab78e059a6a1442f1"
172
+ "gitHead": "8f82e460c4cdb9e52e0ba7ed8aea90f627a27693"
173
173
  }
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '6.0.1-console-preview.f7f118b.0+f7f118b';
2
+ export const version = '6.0.1-console-preview.8f82e46.0+8f82e46';
@@ -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
- Amplify.Analytics;
212
- if (isAmplifyWithAnalytics(Amplify)) {
213
- (Amplify as AmplifyWithAnalytics).Analytics.record({
214
- name: 'ServiceWorker',
215
- attributes: {
216
- state: currentState,
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';
package/src/index.ts CHANGED
@@ -65,3 +65,6 @@ export { Cache } from './Cache';
65
65
 
66
66
  // Internationalization utilities
67
67
  export { I18n } from './I18n';
68
+
69
+ // Service worker
70
+ export { ServiceWorker } from './ServiceWorker';
@@ -71,9 +71,6 @@ export {
71
71
  } from './Platform/types';
72
72
  export { setCustomUserAgent } from './Platform/customUserAgent';
73
73
 
74
- // Service worker
75
- export { ServiceWorker } from './ServiceWorker';
76
-
77
74
  // Other utilities & constants
78
75
  export { BackgroundProcessManager } from './BackgroundProcessManager';
79
76
  export { Mutex } from './Mutex';
@@ -6,6 +6,7 @@ import { UserProfile } from '../../../types';
6
6
 
7
7
  export type SupportedCategory =
8
8
  | 'Analytics'
9
+ | 'Core'
9
10
  | 'InAppMessaging'
10
11
  | 'PushNotification';
11
12
 
@@ -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 = {
@@ -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
 
4
- import {
5
- get as getJsCookie,
6
- remove as removeJsCookie,
7
- set as setJsCookie,
8
- } from 'js-cookie';
4
+ import JsCookie from 'js-cookie';
9
5
  import {
10
6
  CookieStorageData,
11
7
  KeyValueStorageInterface,
@@ -42,20 +38,20 @@ export class CookieStorage implements KeyValueStorageInterface {
42
38
  }
43
39
 
44
40
  async setItem(key: string, value: string) {
45
- setJsCookie(key, value, this.getData());
41
+ JsCookie.set(key, value, this.getData());
46
42
  }
47
43
 
48
44
  async getItem(key: string) {
49
- const item = getJsCookie(key);
45
+ const item = JsCookie.get(key);
50
46
  return item ?? null;
51
47
  }
52
48
 
53
49
  async removeItem(key: string) {
54
- removeJsCookie(key, this.getData());
50
+ JsCookie.remove(key, this.getData());
55
51
  }
56
52
 
57
53
  async clear() {
58
- const cookie = getJsCookie();
54
+ const cookie = JsCookie.get();
59
55
  const promises = Object.keys(cookie).map(key => this.removeItem(key));
60
56
  await Promise.all(promises);
61
57
  }
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;
package/lib/Amplify.js DELETED
@@ -1,118 +0,0 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.Amplify = exports.AmplifyClass = void 0;
20
- // @ts-nocheck
21
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
- // SPDX-License-Identifier: Apache-2.0
23
- var Logger_1 = require("./Logger");
24
- var logger = new Logger_1.ConsoleLogger('Amplify');
25
- var AmplifyClass = /** @class */ (function () {
26
- function AmplifyClass() {
27
- // Everything that is `register`ed is tracked here
28
- this._components = [];
29
- this._config = {};
30
- // All modules (with `getModuleName()`) are stored here for dependency injection
31
- this._modules = {};
32
- // for backward compatibility to avoid breaking change
33
- // if someone is using like Amplify.Auth
34
- this.Auth = null;
35
- this.Analytics = null;
36
- this.API = null;
37
- this.Credentials = null;
38
- this.Storage = null;
39
- this.I18n = null;
40
- this.Cache = null;
41
- this.PubSub = null;
42
- this.Interactions = null;
43
- this.Pushnotification = null;
44
- this.UI = null;
45
- this.XR = null;
46
- this.Predictions = null;
47
- this.DataStore = null;
48
- this.Geo = null;
49
- this.Notifications = null;
50
- this.Logger = Logger_1.ConsoleLogger;
51
- this.ServiceWorker = null;
52
- }
53
- Object.defineProperty(AmplifyClass.prototype, "config", {
54
- // TODO: update "any" when types are determined
55
- get: function () {
56
- return Object.assign({}, this._config);
57
- },
58
- enumerable: false,
59
- configurable: true
60
- });
61
- AmplifyClass.prototype.register = function (comp) {
62
- logger.debug('component registered in amplify', comp);
63
- this._components.push(comp);
64
- if (typeof comp.getModuleName === 'function') {
65
- this._modules[comp.getModuleName()] = comp;
66
- this[comp.getModuleName()] = comp;
67
- }
68
- else {
69
- logger.debug('no getModuleName method for component', comp);
70
- }
71
- // Finally configure this new component(category) loaded
72
- // With the new modularization changes in Amplify V3, all the Amplify
73
- // component are not loaded/registered right away but when they are
74
- // imported (and hence instantiated) in the client's app. This ensures
75
- // that all new components imported get correctly configured with the
76
- // configuration that Amplify.configure() was called with.
77
- comp.configure(this._config);
78
- };
79
- AmplifyClass.prototype.configure = function (config) {
80
- var _this = this;
81
- if (!config)
82
- return this._config;
83
- this._config = Object.assign(this._config, config);
84
- logger.debug('amplify config', this._config);
85
- // Dependency Injection via property-setting.
86
- // This avoids introducing a public method/interface/setter that's difficult to remove later.
87
- // Plus, it reduces `if` statements within the `constructor` and `configure` of each module
88
- Object.entries(this._modules).forEach(function (_a) {
89
- var _b = __read(_a, 2), Name = _b[0], comp = _b[1];
90
- // e.g. Auth.*
91
- Object.keys(comp).forEach(function (property) {
92
- // e.g. Auth["Credentials"] = this._modules["Credentials"] when set
93
- if (_this._modules[property]) {
94
- comp[property] = _this._modules[property];
95
- }
96
- });
97
- });
98
- this._components.map(function (comp) {
99
- comp.configure(_this._config);
100
- });
101
- return this._config;
102
- };
103
- AmplifyClass.prototype.addPluggable = function (pluggable) {
104
- if (pluggable &&
105
- pluggable['getCategory'] &&
106
- typeof pluggable['getCategory'] === 'function') {
107
- this._components.map(function (comp) {
108
- if (comp['addPluggable'] &&
109
- typeof comp['addPluggable'] === 'function') {
110
- comp.addPluggable(pluggable);
111
- }
112
- });
113
- }
114
- };
115
- return AmplifyClass;
116
- }());
117
- exports.AmplifyClass = AmplifyClass;
118
- exports.Amplify = new AmplifyClass();
@@ -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;
@@ -1,115 +0,0 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
- }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- // @ts-nocheck
18
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
19
- // SPDX-License-Identifier: Apache-2.0
20
- import { ConsoleLogger as LoggerClass } from './Logger';
21
- var logger = new LoggerClass('Amplify');
22
- var AmplifyClass = /** @class */ (function () {
23
- function AmplifyClass() {
24
- // Everything that is `register`ed is tracked here
25
- this._components = [];
26
- this._config = {};
27
- // All modules (with `getModuleName()`) are stored here for dependency injection
28
- this._modules = {};
29
- // for backward compatibility to avoid breaking change
30
- // if someone is using like Amplify.Auth
31
- this.Auth = null;
32
- this.Analytics = null;
33
- this.API = null;
34
- this.Credentials = null;
35
- this.Storage = null;
36
- this.I18n = null;
37
- this.Cache = null;
38
- this.PubSub = null;
39
- this.Interactions = null;
40
- this.Pushnotification = null;
41
- this.UI = null;
42
- this.XR = null;
43
- this.Predictions = null;
44
- this.DataStore = null;
45
- this.Geo = null;
46
- this.Notifications = null;
47
- this.Logger = LoggerClass;
48
- this.ServiceWorker = null;
49
- }
50
- Object.defineProperty(AmplifyClass.prototype, "config", {
51
- // TODO: update "any" when types are determined
52
- get: function () {
53
- return Object.assign({}, this._config);
54
- },
55
- enumerable: false,
56
- configurable: true
57
- });
58
- AmplifyClass.prototype.register = function (comp) {
59
- logger.debug('component registered in amplify', comp);
60
- this._components.push(comp);
61
- if (typeof comp.getModuleName === 'function') {
62
- this._modules[comp.getModuleName()] = comp;
63
- this[comp.getModuleName()] = comp;
64
- }
65
- else {
66
- logger.debug('no getModuleName method for component', comp);
67
- }
68
- // Finally configure this new component(category) loaded
69
- // With the new modularization changes in Amplify V3, all the Amplify
70
- // component are not loaded/registered right away but when they are
71
- // imported (and hence instantiated) in the client's app. This ensures
72
- // that all new components imported get correctly configured with the
73
- // configuration that Amplify.configure() was called with.
74
- comp.configure(this._config);
75
- };
76
- AmplifyClass.prototype.configure = function (config) {
77
- var _this = this;
78
- if (!config)
79
- return this._config;
80
- this._config = Object.assign(this._config, config);
81
- logger.debug('amplify config', this._config);
82
- // Dependency Injection via property-setting.
83
- // This avoids introducing a public method/interface/setter that's difficult to remove later.
84
- // Plus, it reduces `if` statements within the `constructor` and `configure` of each module
85
- Object.entries(this._modules).forEach(function (_a) {
86
- var _b = __read(_a, 2), Name = _b[0], comp = _b[1];
87
- // e.g. Auth.*
88
- Object.keys(comp).forEach(function (property) {
89
- // e.g. Auth["Credentials"] = this._modules["Credentials"] when set
90
- if (_this._modules[property]) {
91
- comp[property] = _this._modules[property];
92
- }
93
- });
94
- });
95
- this._components.map(function (comp) {
96
- comp.configure(_this._config);
97
- });
98
- return this._config;
99
- };
100
- AmplifyClass.prototype.addPluggable = function (pluggable) {
101
- if (pluggable &&
102
- pluggable['getCategory'] &&
103
- typeof pluggable['getCategory'] === 'function') {
104
- this._components.map(function (comp) {
105
- if (comp['addPluggable'] &&
106
- typeof comp['addPluggable'] === 'function') {
107
- comp.addPluggable(pluggable);
108
- }
109
- });
110
- }
111
- };
112
- return AmplifyClass;
113
- }());
114
- export { AmplifyClass };
115
- export var Amplify = new AmplifyClass();
package/src/Amplify.ts DELETED
@@ -1,106 +0,0 @@
1
- // @ts-nocheck
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
4
- import { ConsoleLogger as LoggerClass } from './Logger';
5
-
6
- const logger = new LoggerClass('Amplify');
7
-
8
- export class AmplifyClass {
9
- // Everything that is `register`ed is tracked here
10
- private _components:any[] = [];
11
- private _config = {};
12
-
13
- // All modules (with `getModuleName()`) are stored here for dependency injection
14
- private _modules = {};
15
-
16
- // for backward compatibility to avoid breaking change
17
- // if someone is using like Amplify.Auth
18
- Auth = null;
19
- Analytics = null;
20
- API = null;
21
- Credentials = null;
22
- Storage = null;
23
- I18n = null;
24
- Cache = null;
25
- PubSub = null;
26
- Interactions = null;
27
- Pushnotification = null;
28
- UI = null;
29
- XR = null;
30
- Predictions = null;
31
- DataStore = null;
32
- Geo = null;
33
- Notifications = null;
34
-
35
- Logger = LoggerClass;
36
- ServiceWorker = null;
37
-
38
- // TODO: update "any" when types are determined
39
- public get config(): any {
40
- return Object.assign({}, this._config);
41
- }
42
-
43
- register(comp:any) {
44
- logger.debug('component registered in amplify', comp);
45
- this._components.push(comp);
46
- if (typeof comp.getModuleName === 'function') {
47
- this._modules[comp.getModuleName()] = comp;
48
- this[comp.getModuleName()] = comp;
49
- } else {
50
- logger.debug('no getModuleName method for component', comp);
51
- }
52
-
53
- // Finally configure this new component(category) loaded
54
- // With the new modularization changes in Amplify V3, all the Amplify
55
- // component are not loaded/registered right away but when they are
56
- // imported (and hence instantiated) in the client's app. This ensures
57
- // that all new components imported get correctly configured with the
58
- // configuration that Amplify.configure() was called with.
59
- comp.configure(this._config);
60
- }
61
-
62
- configure(config?) {
63
- if (!config) return this._config;
64
-
65
- this._config = Object.assign(this._config, config);
66
- logger.debug('amplify config', this._config);
67
-
68
- // Dependency Injection via property-setting.
69
- // This avoids introducing a public method/interface/setter that's difficult to remove later.
70
- // Plus, it reduces `if` statements within the `constructor` and `configure` of each module
71
- Object.entries(this._modules).forEach(([Name, comp]:[any, any]) => {
72
- // e.g. Auth.*
73
- Object.keys(comp).forEach(property => {
74
- // e.g. Auth["Credentials"] = this._modules["Credentials"] when set
75
- if (this._modules[property]) {
76
- comp[property] = this._modules[property];
77
- }
78
- });
79
- });
80
-
81
- this._components.map(comp => {
82
- comp.configure(this._config);
83
- });
84
-
85
- return this._config;
86
- }
87
-
88
- addPluggable(pluggable) {
89
- if (
90
- pluggable &&
91
- pluggable['getCategory'] &&
92
- typeof pluggable['getCategory'] === 'function'
93
- ) {
94
- this._components.map(comp => {
95
- if (
96
- comp['addPluggable'] &&
97
- typeof comp['addPluggable'] === 'function'
98
- ) {
99
- comp.addPluggable(pluggable);
100
- }
101
- });
102
- }
103
- }
104
- }
105
-
106
- export const Amplify = new AmplifyClass();