@aws-amplify/core 6.0.1-console-preview.4432977.0 → 6.0.1-console-preview.67f944e.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 (133) hide show
  1. package/lib/AwsClients/Pinpoint/errorHelpers.d.ts +5 -0
  2. package/lib/AwsClients/Pinpoint/errorHelpers.js +17 -0
  3. package/lib/AwsClients/Pinpoint/putEvents.js +2 -6
  4. package/lib/Cache/AsyncStorageCache.js +3 -10
  5. package/lib/Cache/BrowserStorageCache.js +5 -18
  6. package/lib/Cache/InMemoryCache.js +3 -10
  7. package/lib/Cache/Utils/CacheList.js +5 -18
  8. package/lib/Cache/Utils/errorHelpers.d.ts +8 -0
  9. package/lib/Cache/Utils/errorHelpers.js +29 -0
  10. package/lib/Hub/index.js +2 -2
  11. package/lib/Hub/types/AuthTypes.d.ts +5 -0
  12. package/lib/I18n/errorHelpers.d.ts +5 -0
  13. package/lib/I18n/errorHelpers.js +17 -0
  14. package/lib/I18n/index.js +5 -18
  15. package/lib/Platform/version.d.ts +1 -1
  16. package/lib/Platform/version.js +1 -1
  17. package/lib/ServiceWorker/ServiceWorker.js +13 -35
  18. package/lib/ServiceWorker/errorHelpers.d.ts +7 -0
  19. package/lib/ServiceWorker/errorHelpers.js +25 -0
  20. package/lib/Util/Constants.d.ts +0 -6
  21. package/lib/Util/Constants.js +1 -7
  22. package/lib/adapterCore/error/AmplifyServerContextError.d.ts +1 -1
  23. package/lib/adapterCore/error/AmplifyServerContextError.js +2 -2
  24. package/lib/{Util/Errors.d.ts → errors/AmplifyError.d.ts} +2 -9
  25. package/lib/{Util/Errors.js → errors/AmplifyError.js} +1 -18
  26. package/lib/errors/PlatformNotSupportedError.d.ts +4 -0
  27. package/lib/errors/PlatformNotSupportedError.js +33 -0
  28. package/lib/errors/createAssertionFunction.d.ts +3 -0
  29. package/lib/errors/createAssertionFunction.js +22 -0
  30. package/lib/errors/index.d.ts +3 -0
  31. package/lib/errors/index.js +11 -0
  32. package/lib/index.d.ts +1 -1
  33. package/lib/libraryUtils.d.ts +3 -4
  34. package/lib/libraryUtils.js +9 -10
  35. package/lib/parseAWSExports.js +3 -1
  36. package/lib/providers/pinpoint/apis/record.js +2 -2
  37. package/lib/singleton/Auth/utils/errorHelpers.d.ts +8 -0
  38. package/lib/singleton/Auth/utils/errorHelpers.js +33 -0
  39. package/lib/singleton/Auth/utils/index.d.ts +1 -1
  40. package/lib/singleton/Auth/utils/index.js +9 -25
  41. package/lib/singleton/Geo/types.d.ts +17 -0
  42. package/lib/singleton/Geo/types.js +4 -0
  43. package/lib/singleton/types.d.ts +3 -1
  44. package/lib/storage/DefaultStorage.native.js +2 -2
  45. package/lib/storage/KeyValueStorage.js +5 -5
  46. package/lib/tsconfig.tsbuildinfo +1 -1
  47. package/lib/types/errors.d.ts +8 -3
  48. package/lib/types/errors.js +6 -0
  49. package/lib-esm/AwsClients/Pinpoint/errorHelpers.d.ts +5 -0
  50. package/lib-esm/AwsClients/Pinpoint/errorHelpers.js +14 -0
  51. package/lib-esm/AwsClients/Pinpoint/putEvents.js +2 -6
  52. package/lib-esm/Cache/AsyncStorageCache.js +3 -10
  53. package/lib-esm/Cache/BrowserStorageCache.js +5 -18
  54. package/lib-esm/Cache/InMemoryCache.js +3 -10
  55. package/lib-esm/Cache/Utils/CacheList.js +5 -18
  56. package/lib-esm/Cache/Utils/errorHelpers.d.ts +8 -0
  57. package/lib-esm/Cache/Utils/errorHelpers.js +26 -0
  58. package/lib-esm/Hub/index.js +1 -1
  59. package/lib-esm/Hub/types/AuthTypes.d.ts +5 -0
  60. package/lib-esm/I18n/errorHelpers.d.ts +5 -0
  61. package/lib-esm/I18n/errorHelpers.js +14 -0
  62. package/lib-esm/I18n/index.js +5 -18
  63. package/lib-esm/Platform/version.d.ts +1 -1
  64. package/lib-esm/Platform/version.js +1 -1
  65. package/lib-esm/ServiceWorker/ServiceWorker.js +8 -30
  66. package/lib-esm/ServiceWorker/errorHelpers.d.ts +7 -0
  67. package/lib-esm/ServiceWorker/errorHelpers.js +22 -0
  68. package/lib-esm/Util/Constants.d.ts +0 -6
  69. package/lib-esm/Util/Constants.js +0 -6
  70. package/lib-esm/adapterCore/error/AmplifyServerContextError.d.ts +1 -1
  71. package/lib-esm/adapterCore/error/AmplifyServerContextError.js +1 -1
  72. package/lib-esm/{Util/Errors.d.ts → errors/AmplifyError.d.ts} +2 -9
  73. package/lib-esm/{Util/Errors.js → errors/AmplifyError.js} +0 -15
  74. package/lib-esm/errors/PlatformNotSupportedError.d.ts +4 -0
  75. package/lib-esm/errors/PlatformNotSupportedError.js +30 -0
  76. package/lib-esm/errors/createAssertionFunction.d.ts +3 -0
  77. package/lib-esm/errors/createAssertionFunction.js +18 -0
  78. package/lib-esm/errors/index.d.ts +3 -0
  79. package/lib-esm/errors/index.js +5 -0
  80. package/lib-esm/index.d.ts +1 -1
  81. package/lib-esm/libraryUtils.d.ts +3 -4
  82. package/lib-esm/libraryUtils.js +3 -3
  83. package/lib-esm/parseAWSExports.js +3 -1
  84. package/lib-esm/providers/pinpoint/apis/record.js +1 -1
  85. package/lib-esm/singleton/Auth/utils/errorHelpers.d.ts +8 -0
  86. package/lib-esm/singleton/Auth/utils/errorHelpers.js +30 -0
  87. package/lib-esm/singleton/Auth/utils/index.d.ts +1 -1
  88. package/lib-esm/singleton/Auth/utils/index.js +7 -23
  89. package/lib-esm/singleton/Geo/types.d.ts +17 -0
  90. package/lib-esm/singleton/Geo/types.js +3 -0
  91. package/lib-esm/singleton/types.d.ts +3 -1
  92. package/lib-esm/storage/DefaultStorage.native.js +1 -1
  93. package/lib-esm/storage/KeyValueStorage.js +5 -5
  94. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  95. package/lib-esm/types/errors.d.ts +8 -3
  96. package/lib-esm/types/errors.js +5 -1
  97. package/package.json +2 -2
  98. package/src/AwsClients/Pinpoint/errorHelpers.ts +19 -0
  99. package/src/AwsClients/Pinpoint/putEvents.ts +2 -6
  100. package/src/Cache/AsyncStorageCache.ts +4 -10
  101. package/src/Cache/BrowserStorageCache.ts +5 -18
  102. package/src/Cache/InMemoryCache.ts +4 -11
  103. package/src/Cache/Utils/CacheList.ts +5 -18
  104. package/src/Cache/Utils/errorHelpers.ts +30 -0
  105. package/src/Hub/index.ts +1 -1
  106. package/src/Hub/types/AuthTypes.ts +3 -1
  107. package/src/I18n/errorHelpers.ts +18 -0
  108. package/src/I18n/index.ts +12 -24
  109. package/src/Platform/version.ts +1 -1
  110. package/src/ServiceWorker/ServiceWorker.ts +18 -30
  111. package/src/ServiceWorker/errorHelpers.ts +26 -0
  112. package/src/Util/Constants.ts +0 -6
  113. package/src/adapterCore/error/AmplifyServerContextError.ts +1 -1
  114. package/src/{Util/Errors.ts → errors/AmplifyError.ts} +2 -18
  115. package/src/errors/PlatformNotSupportedError.ts +14 -0
  116. package/src/errors/createAssertionFunction.ts +23 -0
  117. package/src/errors/index.ts +6 -0
  118. package/src/index.ts +1 -0
  119. package/src/libraryUtils.ts +11 -7
  120. package/src/parseAWSExports.ts +7 -1
  121. package/src/providers/pinpoint/apis/record.ts +1 -1
  122. package/src/singleton/Auth/utils/errorHelpers.ts +37 -0
  123. package/src/singleton/Auth/utils/index.ts +19 -26
  124. package/src/singleton/Geo/types.ts +20 -0
  125. package/src/singleton/types.ts +3 -0
  126. package/src/storage/DefaultStorage.native.ts +1 -1
  127. package/src/storage/KeyValueStorage.ts +5 -5
  128. package/src/types/errors.ts +14 -3
  129. package/lib/Util/errors/AssertError.d.ts +0 -2
  130. package/lib/Util/errors/AssertError.js +0 -11
  131. package/lib-esm/Util/errors/AssertError.d.ts +0 -2
  132. package/lib-esm/Util/errors/AssertError.js +0 -7
  133. package/src/Util/errors/AssertError.ts +0 -11
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var __extends = (this && this.__extends) || (function () {
5
+ var extendStatics = function (d, b) {
6
+ extendStatics = Object.setPrototypeOf ||
7
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
9
+ return extendStatics(d, b);
10
+ };
11
+ return function (d, b) {
12
+ if (typeof b !== "function" && b !== null)
13
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
14
+ extendStatics(d, b);
15
+ function __() { this.constructor = d; }
16
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
+ };
18
+ })();
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.PlatformNotSupportedError = void 0;
21
+ var types_1 = require("../types");
22
+ var AmplifyError_1 = require("./AmplifyError");
23
+ var PlatformNotSupportedError = /** @class */ (function (_super) {
24
+ __extends(PlatformNotSupportedError, _super);
25
+ function PlatformNotSupportedError() {
26
+ return _super.call(this, {
27
+ name: types_1.AmplifyErrorCode.PlatformNotSupported,
28
+ message: 'Function not supported on current platform',
29
+ }) || this;
30
+ }
31
+ return PlatformNotSupportedError;
32
+ }(AmplifyError_1.AmplifyError));
33
+ exports.PlatformNotSupportedError = PlatformNotSupportedError;
@@ -0,0 +1,3 @@
1
+ import { AmplifyErrorMap, AssertionFunction } from '../types';
2
+ import { AmplifyError } from './AmplifyError';
3
+ export declare const createAssertionFunction: (errorMap: AmplifyErrorMap, AssertionError?: typeof AmplifyError) => AssertionFunction;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.createAssertionFunction = void 0;
6
+ var AmplifyError_1 = require("./AmplifyError");
7
+ var createAssertionFunction = function (errorMap, AssertionError) {
8
+ if (AssertionError === void 0) { AssertionError = AmplifyError_1.AmplifyError; }
9
+ return function (assertion, name, additionalContext) {
10
+ var _a = errorMap[name], message = _a.message, recoverySuggestion = _a.recoverySuggestion;
11
+ if (!assertion) {
12
+ throw new AssertionError({
13
+ name: name,
14
+ message: additionalContext
15
+ ? "".concat(message, " ").concat(additionalContext)
16
+ : message,
17
+ recoverySuggestion: recoverySuggestion,
18
+ });
19
+ }
20
+ };
21
+ };
22
+ exports.createAssertionFunction = createAssertionFunction;
@@ -0,0 +1,3 @@
1
+ export { AmplifyError } from './AmplifyError';
2
+ export { createAssertionFunction } from './createAssertionFunction';
3
+ export { PlatformNotSupportedError } from './PlatformNotSupportedError';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.PlatformNotSupportedError = exports.createAssertionFunction = exports.AmplifyError = void 0;
6
+ var AmplifyError_1 = require("./AmplifyError");
7
+ Object.defineProperty(exports, "AmplifyError", { enumerable: true, get: function () { return AmplifyError_1.AmplifyError; } });
8
+ var createAssertionFunction_1 = require("./createAssertionFunction");
9
+ Object.defineProperty(exports, "createAssertionFunction", { enumerable: true, get: function () { return createAssertionFunction_1.createAssertionFunction; } });
10
+ var PlatformNotSupportedError_1 = require("./PlatformNotSupportedError");
11
+ Object.defineProperty(exports, "PlatformNotSupportedError", { enumerable: true, get: function () { return PlatformNotSupportedError_1.PlatformNotSupportedError; } });
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { Hub } from './Hub';
2
2
  export { HubCapsule, HubCallback, HubPayload } from './Hub/types';
3
3
  export { TokenProvider, AuthTokens, FetchAuthSessionOptions, AWSCredentialsAndIdentityIdProvider, AWSCredentialsAndIdentityId, Identity, OAuthConfig, CognitoUserPoolConfig, } from './singleton/Auth/types';
4
- export { AuthConfig, AuthUserPoolConfig, AuthUserPoolAndIdentityPoolConfig, StorageAccessLevel, StorageConfig, GetCredentialsOptions, ResourcesConfig, LibraryOptions, AnalyticsConfig, } from './singleton/types';
4
+ export { AuthConfig, AuthUserPoolConfig, AuthUserPoolAndIdentityPoolConfig, StorageAccessLevel, StorageConfig, GetCredentialsOptions, ResourcesConfig, LibraryOptions, AnalyticsConfig, GeoConfig, } from './singleton/types';
5
5
  export { Amplify, fetchAuthSession, AmplifyClass as AmplifyClassV6, clearCredentials, } from './singleton';
6
6
  export { getCredentialsForIdentity, getId, GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput, } from './AwsClients/CognitoIdentity';
7
7
  export { UserProfile } from './types';
@@ -2,7 +2,7 @@ export { isBrowser, filenameToContentType, generateRandomString, isEmpty, isStri
2
2
  export { parseAWSExports } from './parseAWSExports';
3
3
  export { LegacyConfig } from './singleton/types';
4
4
  export { JWT, StrictUnion, CognitoIdentityPoolConfig, JwtPayload, } from './singleton/Auth/types';
5
- export { decodeJWT, assertTokenProviderConfig, assertIdentityPooIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
5
+ export { decodeJWT, assertTokenProviderConfig, assertIdentityPoolIdConfig, assertOAuthConfig, } from './singleton/Auth/utils';
6
6
  export { isTokenExpired } from './singleton/Auth';
7
7
  export { GraphQLAuthModeKeys } from './singleton/API/types';
8
8
  export { Signer } from './Signer';
@@ -15,9 +15,8 @@ export declare const Constants: {
15
15
  };
16
16
  export { ServiceWorker } from './ServiceWorker';
17
17
  export { AWS_CLOUDWATCH_CATEGORY, BackgroundManagerNotOpenError, BackgroundProcessManager, BackgroundProcessManagerState, DateUtils, Mutex, NO_CREDS_ERROR_STRING, NonRetryableError, RETRY_ERROR_CODES, Reachability, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, urlSafeDecode, urlSafeEncode, } from './Util';
18
- export { asserts } from './Util/errors/AssertError';
19
- export { invalidParameter, missingConfig, AmplifyError, AmplifyErrorString, } from './Util/Errors';
20
- export { ErrorParams, AmplifyErrorMap, ServiceError } from './types';
18
+ export { AmplifyError, PlatformNotSupportedError, createAssertionFunction, } from './errors';
19
+ export { AmplifyErrorCode, AmplifyErrorMap, AmplifyErrorParams, AssertionFunction, ServiceError, } from './types';
21
20
  export { INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, } from './Util/Constants';
22
21
  export { fetchAuthSession } from './singleton/apis/internal/fetchAuthSession';
23
22
  export { AMPLIFY_SYMBOL } from './Hub';
@@ -2,8 +2,8 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.Reachability = exports.RETRY_ERROR_CODES = exports.NonRetryableError = exports.NO_CREDS_ERROR_STRING = exports.Mutex = exports.DateUtils = exports.BackgroundProcessManagerState = exports.BackgroundProcessManager = exports.BackgroundManagerNotOpenError = exports.AWS_CLOUDWATCH_CATEGORY = exports.ServiceWorker = exports.Constants = exports.StorageAction = exports.PushNotificationAction = exports.PubSubAction = exports.PredictionsAction = exports.InAppMessagingAction = exports.InteractionsAction = exports.GeoAction = exports.Framework = exports.DataStoreAction = exports.Category = exports.AnalyticsAction = exports.AuthAction = exports.ApiAction = exports.getAmplifyUserAgent = exports.getAmplifyUserAgentObject = exports.Platform = exports.ClientDevice = exports.Logger = exports.ConsoleLogger = exports.Signer = exports.isTokenExpired = exports.assertOAuthConfig = exports.assertIdentityPooIdConfig = exports.assertTokenProviderConfig = exports.decodeJWT = exports.parseAWSExports = exports.transferKeyToUpperCase = exports.transferKeyToLowerCase = exports.sortByField = exports.objectLessAttributes = exports.makeQuerablePromise = exports.isWebWorker = exports.isTextFile = exports.isStrictObject = exports.isEmpty = exports.generateRandomString = exports.filenameToContentType = exports.isBrowser = void 0;
6
- exports.AMPLIFY_SYMBOL = exports.fetchAuthSession = exports.USER_AGENT_HEADER = exports.INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER = exports.AmplifyErrorString = exports.AmplifyError = exports.missingConfig = exports.invalidParameter = exports.asserts = exports.urlSafeEncode = exports.urlSafeDecode = exports.retry = exports.jitteredExponentialRetry = exports.jitteredBackoff = exports.isNonRetryableError = void 0;
5
+ exports.Reachability = exports.RETRY_ERROR_CODES = exports.NonRetryableError = exports.NO_CREDS_ERROR_STRING = exports.Mutex = exports.DateUtils = exports.BackgroundProcessManagerState = exports.BackgroundProcessManager = exports.BackgroundManagerNotOpenError = exports.AWS_CLOUDWATCH_CATEGORY = exports.ServiceWorker = exports.Constants = exports.StorageAction = exports.PushNotificationAction = exports.PubSubAction = exports.PredictionsAction = exports.InAppMessagingAction = exports.InteractionsAction = exports.GeoAction = exports.Framework = exports.DataStoreAction = exports.Category = exports.AnalyticsAction = exports.AuthAction = exports.ApiAction = exports.getAmplifyUserAgent = exports.getAmplifyUserAgentObject = exports.Platform = exports.ClientDevice = exports.Logger = exports.ConsoleLogger = exports.Signer = exports.isTokenExpired = exports.assertOAuthConfig = exports.assertIdentityPoolIdConfig = exports.assertTokenProviderConfig = exports.decodeJWT = exports.parseAWSExports = exports.transferKeyToUpperCase = exports.transferKeyToLowerCase = exports.sortByField = exports.objectLessAttributes = exports.makeQuerablePromise = exports.isWebWorker = exports.isTextFile = exports.isStrictObject = exports.isEmpty = exports.generateRandomString = exports.filenameToContentType = exports.isBrowser = void 0;
6
+ exports.AMPLIFY_SYMBOL = exports.fetchAuthSession = exports.USER_AGENT_HEADER = exports.INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER = exports.AmplifyErrorCode = exports.createAssertionFunction = exports.PlatformNotSupportedError = exports.AmplifyError = exports.urlSafeEncode = exports.urlSafeDecode = exports.retry = exports.jitteredExponentialRetry = exports.jitteredBackoff = exports.isNonRetryableError = void 0;
7
7
  /*
8
8
  This file maps top-level exports from `@aws-amplify/core/internals/utils`. These are intended to be internal
9
9
  utils for use throughout the library.
@@ -28,7 +28,7 @@ Object.defineProperty(exports, "parseAWSExports", { enumerable: true, get: funct
28
28
  var utils_1 = require("./singleton/Auth/utils");
29
29
  Object.defineProperty(exports, "decodeJWT", { enumerable: true, get: function () { return utils_1.decodeJWT; } });
30
30
  Object.defineProperty(exports, "assertTokenProviderConfig", { enumerable: true, get: function () { return utils_1.assertTokenProviderConfig; } });
31
- Object.defineProperty(exports, "assertIdentityPooIdConfig", { enumerable: true, get: function () { return utils_1.assertIdentityPooIdConfig; } });
31
+ Object.defineProperty(exports, "assertIdentityPoolIdConfig", { enumerable: true, get: function () { return utils_1.assertIdentityPoolIdConfig; } });
32
32
  Object.defineProperty(exports, "assertOAuthConfig", { enumerable: true, get: function () { return utils_1.assertOAuthConfig; } });
33
33
  var Auth_1 = require("./singleton/Auth");
34
34
  Object.defineProperty(exports, "isTokenExpired", { enumerable: true, get: function () { return Auth_1.isTokenExpired; } });
@@ -84,13 +84,12 @@ Object.defineProperty(exports, "jitteredExponentialRetry", { enumerable: true, g
84
84
  Object.defineProperty(exports, "retry", { enumerable: true, get: function () { return Util_1.retry; } });
85
85
  Object.defineProperty(exports, "urlSafeDecode", { enumerable: true, get: function () { return Util_1.urlSafeDecode; } });
86
86
  Object.defineProperty(exports, "urlSafeEncode", { enumerable: true, get: function () { return Util_1.urlSafeEncode; } });
87
- var AssertError_1 = require("./Util/errors/AssertError");
88
- Object.defineProperty(exports, "asserts", { enumerable: true, get: function () { return AssertError_1.asserts; } });
89
- var Errors_1 = require("./Util/Errors");
90
- Object.defineProperty(exports, "invalidParameter", { enumerable: true, get: function () { return Errors_1.invalidParameter; } });
91
- Object.defineProperty(exports, "missingConfig", { enumerable: true, get: function () { return Errors_1.missingConfig; } });
92
- Object.defineProperty(exports, "AmplifyError", { enumerable: true, get: function () { return Errors_1.AmplifyError; } });
93
- Object.defineProperty(exports, "AmplifyErrorString", { enumerable: true, get: function () { return Errors_1.AmplifyErrorString; } });
87
+ var errors_1 = require("./errors");
88
+ Object.defineProperty(exports, "AmplifyError", { enumerable: true, get: function () { return errors_1.AmplifyError; } });
89
+ Object.defineProperty(exports, "PlatformNotSupportedError", { enumerable: true, get: function () { return errors_1.PlatformNotSupportedError; } });
90
+ Object.defineProperty(exports, "createAssertionFunction", { enumerable: true, get: function () { return errors_1.createAssertionFunction; } });
91
+ var types_2 = require("./types");
92
+ Object.defineProperty(exports, "AmplifyErrorCode", { enumerable: true, get: function () { return types_2.AmplifyErrorCode; } });
94
93
  var Constants_1 = require("./Util/Constants");
95
94
  Object.defineProperty(exports, "INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER", { enumerable: true, get: function () { return Constants_1.INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER; } });
96
95
  Object.defineProperty(exports, "USER_AGENT_HEADER", { enumerable: true, get: function () { return Constants_1.USER_AGENT_HEADER; } });
@@ -75,7 +75,9 @@ var parseAWSExports = function (config) {
75
75
  if (geo) {
76
76
  var amazon_location_service = geo.amazon_location_service;
77
77
  amplifyConfig.Geo = amazon_location_service
78
- ? { AmazonLocationService: amazon_location_service }
78
+ ? {
79
+ LocationService: __assign(__assign({}, amazon_location_service), { searchIndices: amazon_location_service.search_indices, region: amazon_location_service.region }),
80
+ }
79
81
  : __assign({}, geo);
80
82
  }
81
83
  return amplifyConfig;
@@ -44,7 +44,7 @@ var utils_1 = require("../utils");
44
44
  var constants_1 = require("../utils/constants");
45
45
  var updateEndpoint_1 = require("./updateEndpoint");
46
46
  var getEventBuffer_1 = require("../utils/getEventBuffer");
47
- var libraryUtils_1 = require("../../../libraryUtils");
47
+ var errors_1 = require("../../../errors");
48
48
  // TODO(v6) Refactor when we add support for session tracking & `autoTrack`
49
49
  var session;
50
50
  /**
@@ -90,7 +90,7 @@ var record = function (_a) {
90
90
  _b.label = 4;
91
91
  case 4:
92
92
  if (!endpointId) {
93
- throw new libraryUtils_1.AmplifyError({
93
+ throw new errors_1.AmplifyError({
94
94
  name: 'ENDPOINT_NOT_CREATED',
95
95
  message: 'Endpoint was not created.',
96
96
  });
@@ -0,0 +1,8 @@
1
+ import { AssertionFunction } from '../../../types';
2
+ export declare enum AuthConfigurationErrorCode {
3
+ AuthTokenConfigException = "AuthTokenConfigException",
4
+ AuthUserPoolAndIdentityPoolException = "AuthUserPoolAndIdentityPoolException",
5
+ InvalidIdentityPoolIdException = "InvalidIdentityPoolIdException",
6
+ OAuthNotConfigureException = "OAuthNotConfigureException"
7
+ }
8
+ export declare const assert: AssertionFunction<AuthConfigurationErrorCode>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var _a;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.assert = exports.AuthConfigurationErrorCode = void 0;
7
+ var errors_1 = require("../../../errors");
8
+ var AuthConfigurationErrorCode;
9
+ (function (AuthConfigurationErrorCode) {
10
+ AuthConfigurationErrorCode["AuthTokenConfigException"] = "AuthTokenConfigException";
11
+ AuthConfigurationErrorCode["AuthUserPoolAndIdentityPoolException"] = "AuthUserPoolAndIdentityPoolException";
12
+ AuthConfigurationErrorCode["InvalidIdentityPoolIdException"] = "InvalidIdentityPoolIdException";
13
+ AuthConfigurationErrorCode["OAuthNotConfigureException"] = "OAuthNotConfigureException";
14
+ })(AuthConfigurationErrorCode = exports.AuthConfigurationErrorCode || (exports.AuthConfigurationErrorCode = {}));
15
+ var authConfigurationErrorMap = (_a = {},
16
+ _a[AuthConfigurationErrorCode.AuthTokenConfigException] = {
17
+ message: 'Auth Token Provider not configured.',
18
+ recoverySuggestion: 'Make sure to call Amplify.configure in your app.',
19
+ },
20
+ _a[AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException] = {
21
+ message: 'Auth UserPool or IdentityPool not configured.',
22
+ recoverySuggestion: 'Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId.',
23
+ },
24
+ _a[AuthConfigurationErrorCode.InvalidIdentityPoolIdException] = {
25
+ message: 'Invalid identity pool id provided.',
26
+ recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',
27
+ },
28
+ _a[AuthConfigurationErrorCode.OAuthNotConfigureException] = {
29
+ message: 'oauth param not configured.',
30
+ recoverySuggestion: 'Make sure to call Amplify.configure with oauth parameter in your app.',
31
+ },
32
+ _a);
33
+ exports.assert = (0, errors_1.createAssertionFunction)(authConfigurationErrorMap);
@@ -1,5 +1,5 @@
1
1
  import { JWT, CognitoUserPoolWithOAuthConfig, CognitoUserPoolConfig, CognitoUserPoolAndIdentityPoolConfig, CognitoIdentityPoolConfig, StrictUnion } from '../types';
2
2
  export declare function assertTokenProviderConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoUserPoolAndIdentityPoolConfig | CognitoUserPoolConfig;
3
3
  export declare function assertOAuthConfig(cognitoConfig?: CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig): asserts cognitoConfig is CognitoUserPoolWithOAuthConfig;
4
- export declare function assertIdentityPooIdConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoIdentityPoolConfig;
4
+ export declare function assertIdentityPoolIdConfig(cognitoConfig?: StrictUnion<CognitoUserPoolConfig | CognitoUserPoolAndIdentityPoolConfig | CognitoIdentityPoolConfig>): asserts cognitoConfig is CognitoIdentityPoolConfig;
5
5
  export declare function decodeJWT(token: string): JWT;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeJWT = exports.assertIdentityPooIdConfig = exports.assertOAuthConfig = exports.assertTokenProviderConfig = void 0;
3
+ exports.decodeJWT = exports.assertIdentityPoolIdConfig = exports.assertOAuthConfig = exports.assertTokenProviderConfig = void 0;
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
- var AssertError_1 = require("../../../Util/errors/AssertError");
6
+ var errorHelpers_1 = require("./errorHelpers");
7
7
  function assertTokenProviderConfig(cognitoConfig) {
8
8
  var assertionValid = true; // assume valid until otherwise proveed
9
9
  if (!cognitoConfig) {
@@ -13,11 +13,7 @@ function assertTokenProviderConfig(cognitoConfig) {
13
13
  assertionValid =
14
14
  !!cognitoConfig.userPoolClientId && !!cognitoConfig.userPoolClientId;
15
15
  }
16
- return (0, AssertError_1.asserts)(assertionValid, {
17
- name: 'AuthTokenConfigException',
18
- message: 'Auth Token Provider not configured',
19
- recoverySuggestion: 'Make sure to call Amplify.configure in your app',
20
- });
16
+ return (0, errorHelpers_1.assert)(assertionValid, errorHelpers_1.AuthConfigurationErrorCode.AuthTokenConfigException);
21
17
  }
22
18
  exports.assertTokenProviderConfig = assertTokenProviderConfig;
23
19
  function assertOAuthConfig(cognitoConfig) {
@@ -26,29 +22,17 @@ function assertOAuthConfig(cognitoConfig) {
26
22
  !!((_d = (_c = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _c === void 0 ? void 0 : _c.oauth) === null || _d === void 0 ? void 0 : _d.redirectSignOut) &&
27
23
  !!((_f = (_e = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _e === void 0 ? void 0 : _e.oauth) === null || _f === void 0 ? void 0 : _f.redirectSignIn) &&
28
24
  !!((_h = (_g = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _g === void 0 ? void 0 : _g.oauth) === null || _h === void 0 ? void 0 : _h.responseType);
29
- return (0, AssertError_1.asserts)(validOAuthConfig, {
30
- name: 'OAuthNotConfigureException',
31
- message: 'oauth param not configured',
32
- recoverySuggestion: 'Make sure to call Amplify.configure with oauth parameter in your app',
33
- });
25
+ return (0, errorHelpers_1.assert)(validOAuthConfig, errorHelpers_1.AuthConfigurationErrorCode.OAuthNotConfigureException);
34
26
  }
35
27
  exports.assertOAuthConfig = assertOAuthConfig;
36
- function assertIdentityPooIdConfig(cognitoConfig) {
28
+ function assertIdentityPoolIdConfig(cognitoConfig) {
37
29
  var validConfig = !!(cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.identityPoolId);
38
- return (0, AssertError_1.asserts)(validConfig, {
39
- name: 'InvalidIdentityPoolIdException',
40
- message: 'Invalid identity pool id provided.',
41
- recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',
42
- });
30
+ return (0, errorHelpers_1.assert)(validConfig, errorHelpers_1.AuthConfigurationErrorCode.InvalidIdentityPoolIdException);
43
31
  }
44
- exports.assertIdentityPooIdConfig = assertIdentityPooIdConfig;
45
- function assertUserPoolAndIdentityPooConfig(authConfig) {
32
+ exports.assertIdentityPoolIdConfig = assertIdentityPoolIdConfig;
33
+ function assertUserPoolAndIdentityPoolConfig(authConfig) {
46
34
  var validConfig = !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.Cognito.identityPoolId) && !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.Cognito.userPoolId);
47
- return (0, AssertError_1.asserts)(validConfig, {
48
- name: 'AuthUserPoolAndIdentityPoolException',
49
- message: 'Auth UserPool and IdentityPool not configured',
50
- recoverySuggestion: 'Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId',
51
- });
35
+ return (0, errorHelpers_1.assert)(validConfig, errorHelpers_1.AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException);
52
36
  }
53
37
  function decodeJWT(token) {
54
38
  var tokenSplitted = token.split('.');
@@ -0,0 +1,17 @@
1
+ export interface GeoConfig {
2
+ LocationService?: {
3
+ region: string;
4
+ maps?: {
5
+ items: {};
6
+ default: string;
7
+ };
8
+ searchIndices?: {
9
+ items: string[];
10
+ default: string;
11
+ };
12
+ geofenceCollections?: {
13
+ items: string[];
14
+ default: string;
15
+ };
16
+ };
17
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,7 @@
1
1
  import { APIConfig, LibraryAPIOptions } from './API/types';
2
2
  import { AnalyticsConfig } from './Analytics/types';
3
3
  import { AuthConfig, LibraryAuthOptions, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, CognitoIdentityPoolConfig } from './Auth/types';
4
+ import { GeoConfig } from './Geo/types';
4
5
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
5
6
  export type LegacyConfig = {
6
7
  /**
@@ -13,6 +14,7 @@ export type ResourcesConfig = {
13
14
  Analytics?: AnalyticsConfig;
14
15
  Auth?: AuthConfig;
15
16
  Storage?: StorageConfig;
17
+ Geo?: GeoConfig;
16
18
  };
17
19
  export type LibraryOptions = {
18
20
  API?: LibraryAPIOptions;
@@ -20,4 +22,4 @@ export type LibraryOptions = {
20
22
  Storage?: LibraryStorageOptions;
21
23
  ssr?: boolean;
22
24
  };
23
- export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, };
25
+ export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, GeoConfig, };
@@ -39,7 +39,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
39
39
  };
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.DefaultStorage = void 0;
42
- var libraryUtils_1 = require("../libraryUtils");
42
+ var errors_1 = require("../errors");
43
43
  var ASYNC_STORAGE_MODULE = '@react-native-async-storage/async-storage';
44
44
  var MEMORY_KEY_PREFIX = '@MemoryStorage:';
45
45
  /**
@@ -105,7 +105,7 @@ var DefaultStorage = /** @class */ (function () {
105
105
  .default;
106
106
  }
107
107
  catch (err) {
108
- throw new libraryUtils_1.AmplifyError({
108
+ throw new errors_1.AmplifyError({
109
109
  name: 'NativeModuleException',
110
110
  message: "Unable to find ".concat(ASYNC_STORAGE_MODULE),
111
111
  recoverySuggestion: "Make sure to install ".concat(ASYNC_STORAGE_MODULE),
@@ -39,7 +39,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
39
39
  };
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.KeyValueStorage = void 0;
42
- var Errors_1 = require("../Util/Errors");
42
+ var errors_1 = require("../errors");
43
43
  /**
44
44
  * @internal
45
45
  */
@@ -57,7 +57,7 @@ var KeyValueStorage = /** @class */ (function () {
57
57
  return __awaiter(this, void 0, void 0, function () {
58
58
  return __generator(this, function (_a) {
59
59
  if (!this.storage)
60
- throw Errors_1.PlatformNotSupportedError;
60
+ throw new errors_1.PlatformNotSupportedError();
61
61
  this.storage.setItem(key, value);
62
62
  return [2 /*return*/];
63
63
  });
@@ -73,7 +73,7 @@ var KeyValueStorage = /** @class */ (function () {
73
73
  return __awaiter(this, void 0, void 0, function () {
74
74
  return __generator(this, function (_a) {
75
75
  if (!this.storage)
76
- throw Errors_1.PlatformNotSupportedError;
76
+ throw new errors_1.PlatformNotSupportedError();
77
77
  return [2 /*return*/, this.storage.getItem(key)];
78
78
  });
79
79
  });
@@ -87,7 +87,7 @@ var KeyValueStorage = /** @class */ (function () {
87
87
  return __awaiter(this, void 0, void 0, function () {
88
88
  return __generator(this, function (_a) {
89
89
  if (!this.storage)
90
- throw Errors_1.PlatformNotSupportedError;
90
+ throw new errors_1.PlatformNotSupportedError();
91
91
  this.storage.removeItem(key);
92
92
  return [2 /*return*/];
93
93
  });
@@ -101,7 +101,7 @@ var KeyValueStorage = /** @class */ (function () {
101
101
  return __awaiter(this, void 0, void 0, function () {
102
102
  return __generator(this, function (_a) {
103
103
  if (!this.storage)
104
- throw Errors_1.PlatformNotSupportedError;
104
+ throw new errors_1.PlatformNotSupportedError();
105
105
  this.storage.clear();
106
106
  return [2 /*return*/];
107
107
  });