@aws-amplify/core 6.0.1-console-preview.11cf989.0 → 6.0.1-console-preview.4ae78ed.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +2 -1
  2. package/lib/AwsClients/CognitoIdentity/getId.d.ts +2 -1
  3. package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -2
  4. package/lib/AwsClients/Pinpoint/putEvents.d.ts +3 -2
  5. package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -2
  6. package/lib/Cache/AsyncStorageCache.d.ts +1 -1
  7. package/lib/Cache/AsyncStorageCache.js +20 -22
  8. package/lib/Platform/types.d.ts +3 -2
  9. package/lib/Platform/types.js +3 -2
  10. package/lib/Platform/version.d.ts +1 -1
  11. package/lib/Platform/version.js +1 -1
  12. package/lib/Reachability/Reachability.native.d.ts +2 -2
  13. package/lib/clients/handlers/fetch.js +2 -1
  14. package/lib/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -1
  15. package/lib/clients/middleware/signing/signer/signatureV4/index.native.js +2 -1
  16. package/lib/clients/types/http.d.ts +17 -1
  17. package/lib/libraryUtils.d.ts +2 -1
  18. package/lib/libraryUtils.js +4 -1
  19. package/lib/parseAWSExports.js +24 -8
  20. package/lib/providers/kinesis/types/index.d.ts +1 -0
  21. package/lib/providers/kinesis/types/index.js +19 -0
  22. package/lib/providers/kinesis/types/kinesis.d.ts +9 -0
  23. package/lib/providers/kinesis/types/kinesis.js +4 -0
  24. package/lib/providers/kinesis-firehose/types/index.d.ts +1 -0
  25. package/lib/providers/kinesis-firehose/types/index.js +4 -0
  26. package/lib/providers/kinesis-firehose/types/kinesis-firehose.d.ts +9 -0
  27. package/lib/providers/kinesis-firehose/types/kinesis-firehose.js +4 -0
  28. package/lib/providers/personalize/types/index.d.ts +1 -0
  29. package/lib/providers/personalize/types/index.js +4 -0
  30. package/lib/providers/personalize/types/personalize.d.ts +8 -0
  31. package/lib/providers/personalize/types/personalize.js +4 -0
  32. package/lib/providers/pinpoint/apis/flushEvents.d.ts +2 -0
  33. package/lib/providers/pinpoint/apis/flushEvents.js +21 -0
  34. package/lib/providers/pinpoint/apis/index.d.ts +1 -0
  35. package/lib/providers/pinpoint/apis/index.js +3 -1
  36. package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -1
  37. package/lib/providers/pinpoint/utils/PinpointEventBuffer.d.ts +1 -0
  38. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +3 -0
  39. package/lib/singleton/API/types.d.ts +66 -29
  40. package/lib/singleton/Analytics/types.d.ts +4 -1
  41. package/lib/singleton/Auth/utils/index.js +1 -1
  42. package/lib/storage/DefaultStorage.native.d.ts +2 -2
  43. package/lib/storage/DefaultStorage.native.js +3 -24
  44. package/lib/tsconfig.tsbuildinfo +1 -1
  45. package/lib/utils/globalHelpers/index.native.d.ts +0 -1
  46. package/lib/utils/globalHelpers/index.native.js +2 -1
  47. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +2 -1
  48. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +2 -1
  49. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -2
  50. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +3 -2
  51. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -2
  52. package/lib-esm/Cache/AsyncStorageCache.d.ts +1 -1
  53. package/lib-esm/Cache/AsyncStorageCache.js +2 -1
  54. package/lib-esm/Platform/types.d.ts +3 -2
  55. package/lib-esm/Platform/types.js +3 -2
  56. package/lib-esm/Platform/version.d.ts +1 -1
  57. package/lib-esm/Platform/version.js +1 -1
  58. package/lib-esm/Reachability/Reachability.native.d.ts +2 -2
  59. package/lib-esm/clients/handlers/fetch.js +2 -1
  60. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.d.ts +0 -1
  61. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.native.js +2 -1
  62. package/lib-esm/clients/types/http.d.ts +17 -1
  63. package/lib-esm/libraryUtils.d.ts +2 -1
  64. package/lib-esm/libraryUtils.js +2 -0
  65. package/lib-esm/parseAWSExports.js +24 -8
  66. package/lib-esm/providers/kinesis/types/index.d.ts +1 -0
  67. package/lib-esm/providers/kinesis/types/index.js +3 -0
  68. package/lib-esm/providers/kinesis/types/kinesis.d.ts +9 -0
  69. package/lib-esm/providers/kinesis/types/kinesis.js +3 -0
  70. package/lib-esm/providers/kinesis-firehose/types/index.d.ts +1 -0
  71. package/lib-esm/providers/kinesis-firehose/types/index.js +3 -0
  72. package/lib-esm/providers/kinesis-firehose/types/kinesis-firehose.d.ts +9 -0
  73. package/lib-esm/providers/kinesis-firehose/types/kinesis-firehose.js +3 -0
  74. package/lib-esm/providers/personalize/types/index.d.ts +1 -0
  75. package/lib-esm/providers/personalize/types/index.js +3 -0
  76. package/lib-esm/providers/personalize/types/personalize.d.ts +8 -0
  77. package/lib-esm/providers/personalize/types/personalize.js +3 -0
  78. package/lib-esm/providers/pinpoint/apis/flushEvents.d.ts +2 -0
  79. package/lib-esm/providers/pinpoint/apis/flushEvents.js +17 -0
  80. package/lib-esm/providers/pinpoint/apis/index.d.ts +1 -0
  81. package/lib-esm/providers/pinpoint/apis/index.js +1 -0
  82. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -1
  83. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.d.ts +1 -0
  84. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +3 -0
  85. package/lib-esm/singleton/API/types.d.ts +66 -29
  86. package/lib-esm/singleton/Analytics/types.d.ts +4 -1
  87. package/lib-esm/singleton/Auth/utils/index.js +1 -1
  88. package/lib-esm/storage/DefaultStorage.native.d.ts +2 -2
  89. package/lib-esm/storage/DefaultStorage.native.js +3 -24
  90. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  91. package/lib-esm/utils/globalHelpers/index.native.d.ts +0 -1
  92. package/lib-esm/utils/globalHelpers/index.native.js +2 -1
  93. package/package.json +4 -10
  94. package/src/Cache/AsyncStorageCache.ts +2 -1
  95. package/src/Hub/index.ts +1 -0
  96. package/src/Platform/types.ts +3 -2
  97. package/src/Platform/version.ts +1 -1
  98. package/src/Reachability/Reachability.native.ts +4 -2
  99. package/src/Signer/DateUtils.ts +1 -1
  100. package/src/clients/handlers/fetch.ts +5 -1
  101. package/src/clients/middleware/signing/signer/signatureV4/index.native.ts +3 -1
  102. package/src/clients/types/http.ts +19 -1
  103. package/src/libraryUtils.ts +4 -1
  104. package/src/parseAWSExports.ts +38 -7
  105. package/src/providers/kinesis/types/index.ts +4 -0
  106. package/src/providers/kinesis/types/kinesis.ts +12 -0
  107. package/src/providers/kinesis-firehose/types/index.ts +4 -0
  108. package/src/providers/kinesis-firehose/types/kinesis-firehose.ts +12 -0
  109. package/src/providers/personalize/types/index.ts +4 -0
  110. package/src/providers/personalize/types/personalize.ts +11 -0
  111. package/src/providers/pinpoint/apis/flushEvents.ts +31 -0
  112. package/src/providers/pinpoint/apis/index.ts +1 -0
  113. package/src/providers/pinpoint/types/pinpoint.ts +1 -1
  114. package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +4 -0
  115. package/src/singleton/API/types.ts +77 -26
  116. package/src/singleton/Analytics/types.ts +7 -1
  117. package/src/singleton/Auth/utils/index.ts +1 -1
  118. package/src/storage/DefaultStorage.native.ts +6 -26
  119. package/src/utils/globalHelpers/index.native.ts +3 -1
  120. package/polyfills/URL/index.ts +0 -14
  121. package/polyfills/URL/tsconfig.json +0 -10
  122. package/polyfills/URL/webpack.config.js +0 -43
@@ -12,6 +12,7 @@ export declare class PinpointEventBuffer {
12
12
  resume(): void;
13
13
  flush(): void;
14
14
  identityHasChanged(identityId: AuthSession['identityId']): boolean;
15
+ flushAll(): void;
15
16
  private _startLoop;
16
17
  private _sendBatch;
17
18
  private _putEvents;
@@ -113,6 +113,9 @@ var PinpointEventBuffer = /** @class */ (function () {
113
113
  PinpointEventBuffer.prototype.identityHasChanged = function (identityId) {
114
114
  return this._config.identityId !== identityId;
115
115
  };
116
+ PinpointEventBuffer.prototype.flushAll = function () {
117
+ this._putEvents(this._buffer.splice(0, this._buffer.length));
118
+ };
116
119
  PinpointEventBuffer.prototype._startLoop = function () {
117
120
  if (this._interval) {
118
121
  clearInterval(this._interval);
@@ -1,35 +1,72 @@
1
+ import { Headers } from '../../clients';
1
2
  export type LibraryAPIOptions = {
2
- AppSync: {
3
- query: string;
4
- variables?: object;
5
- authMode?: any;
6
- authToken?: string;
7
- /**
8
- * @deprecated This property should not be used
9
- */
10
- userAgentSuffix?: string;
3
+ GraphQL?: {
4
+ headers?: (options: {
5
+ query: string;
6
+ variables: Record<string, DocumentType>;
7
+ }) => Promise<Headers>;
11
8
  };
12
- customHeaders: Function;
9
+ REST?: {
10
+ headers?: (options: {
11
+ apiName: string;
12
+ }) => Promise<Headers>;
13
+ };
14
+ };
15
+ type APIGraphQLConfig = {
16
+ /**
17
+ * Required GraphQL endpoint, must be a valid URL string.
18
+ */
19
+ endpoint: string;
20
+ /**
21
+ * Optional region string used to sign the request. Required only if the auth mode is 'iam'.
22
+ */
23
+ region?: string;
24
+ /**
25
+ * Optional API key string. Required only if the auth mode is 'apiKey'.
26
+ */
27
+ apiKey?: string;
28
+ /**
29
+ * Custom domain endpoint for GraphQL API.
30
+ */
31
+ customEndpoint?: string;
32
+ /**
33
+ * Optional region string used to sign the request to `customEndpoint`. Effective only if `customEndpoint` is
34
+ * specified, and the auth mode is 'iam'.
35
+ */
36
+ customEndpointRegion?: string;
37
+ /**
38
+ * Default auth mode for all the API calls to given service.
39
+ */
40
+ defaultAuthMode: APIAuthMode;
41
+ };
42
+ type APIRestConfig = {
43
+ /**
44
+ * Required REST endpoint, must be a valid URL string.
45
+ */
46
+ endpoint: string;
47
+ /**
48
+ * Optional region string used to sign the request with IAM credentials. If Omitted, region will be extracted from
49
+ * the endpoint.
50
+ *
51
+ * @default 'us-east-1'
52
+ */
53
+ region?: string;
54
+ /**
55
+ * Optional service name string to sign the request with IAM credentials.
56
+ *
57
+ * @default 'execute-api'
58
+ */
59
+ service?: string;
13
60
  };
14
61
  export type APIConfig = {
15
- AppSync?: {
16
- defaultAuthMode: GraphQLAuthMode;
17
- region: string;
18
- endpoint: string;
19
- modelIntrospectionSchema?: any;
20
- };
62
+ REST?: Record<string, APIRestConfig>;
63
+ GraphQL?: APIGraphQLConfig;
21
64
  };
22
- export type GraphQLAuthMode = {
23
- type: 'apiKey';
24
- apiKey: string;
25
- } | {
26
- type: 'jwt';
27
- token?: 'id' | 'access';
28
- } | {
29
- type: 'iam';
30
- } | {
31
- type: 'lambda';
32
- } | {
33
- type: 'custom';
65
+ export type APIAuthMode = 'apiKey' | 'oidc' | 'userPool' | 'iam' | 'lambda' | 'none';
66
+ /**
67
+ * Type representing a plain JavaScript object that can be serialized to JSON.
68
+ */
69
+ export type DocumentType = null | boolean | number | string | DocumentType[] | {
70
+ [prop: string]: DocumentType;
34
71
  };
35
- export type GraphQLAuthModeKeys = 'apiKey' | 'jwt' | 'iam' | 'lambda' | 'custom';
72
+ export {};
@@ -1,2 +1,5 @@
1
1
  import { PinpointProviderConfig } from '../../providers/pinpoint/types';
2
- export type AnalyticsConfig = PinpointProviderConfig;
2
+ import { KinesisProviderConfig } from '../../providers/kinesis/types';
3
+ import { KinesisFirehoseProviderConfig } from '../../providers/kinesis-firehose/types';
4
+ import { PersonalizeProviderConfig } from '../../providers/personalize/types';
5
+ export type AnalyticsConfig = PinpointProviderConfig & KinesisProviderConfig & KinesisFirehoseProviderConfig & PersonalizeProviderConfig;
@@ -12,7 +12,7 @@ function assertTokenProviderConfig(cognitoConfig) {
12
12
  }
13
13
  else {
14
14
  assertionValid =
15
- !!cognitoConfig.userPoolClientId && !!cognitoConfig.userPoolClientId;
15
+ !!cognitoConfig.userPoolId && !!cognitoConfig.userPoolClientId;
16
16
  }
17
17
  return (0, errorHelpers_1.assert)(assertionValid, errorHelpers_1.AuthConfigurationErrorCode.AuthTokenConfigException);
18
18
  }
@@ -3,7 +3,8 @@ import { KeyValueStorageInterface } from '../types';
3
3
  * @internal
4
4
  */
5
5
  export declare class DefaultStorage implements KeyValueStorageInterface {
6
- private asyncStorage?;
6
+ private asyncStorage;
7
+ constructor();
7
8
  /**
8
9
  * This is used to set a specific item in storage
9
10
  * @param {string} key - the key for the item
@@ -29,5 +30,4 @@ export declare class DefaultStorage implements KeyValueStorageInterface {
29
30
  * @returns {string} nothing
30
31
  */
31
32
  clear(): Promise<void>;
32
- private assertModule;
33
33
  }
@@ -39,14 +39,14 @@ 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 errors_1 = require("../errors");
43
- var ASYNC_STORAGE_MODULE = '@react-native-async-storage/async-storage';
42
+ var react_native_1 = require("@aws-amplify/react-native");
44
43
  var MEMORY_KEY_PREFIX = '@MemoryStorage:';
45
44
  /**
46
45
  * @internal
47
46
  */
48
47
  var DefaultStorage = /** @class */ (function () {
49
48
  function DefaultStorage() {
49
+ this.asyncStorage = (0, react_native_1.loadAsyncStorage)();
50
50
  }
51
51
  /**
52
52
  * This is used to set a specific item in storage
@@ -55,7 +55,6 @@ var DefaultStorage = /** @class */ (function () {
55
55
  * @returns {string} value that was set
56
56
  */
57
57
  DefaultStorage.prototype.setItem = function (key, value) {
58
- this.assertModule(this.asyncStorage);
59
58
  return this.asyncStorage.setItem("".concat(MEMORY_KEY_PREFIX).concat(key), value);
60
59
  };
61
60
  /**
@@ -65,7 +64,6 @@ var DefaultStorage = /** @class */ (function () {
65
64
  * @returns {string} the data item
66
65
  */
67
66
  DefaultStorage.prototype.getItem = function (key) {
68
- this.assertModule(this.asyncStorage);
69
67
  return this.asyncStorage.getItem("".concat(MEMORY_KEY_PREFIX).concat(key));
70
68
  };
71
69
  /**
@@ -74,7 +72,6 @@ var DefaultStorage = /** @class */ (function () {
74
72
  * @returns {string} value - value that was deleted
75
73
  */
76
74
  DefaultStorage.prototype.removeItem = function (key) {
77
- this.assertModule(this.asyncStorage);
78
75
  return this.asyncStorage.removeItem("".concat(MEMORY_KEY_PREFIX).concat(key));
79
76
  };
80
77
  /**
@@ -86,9 +83,7 @@ var DefaultStorage = /** @class */ (function () {
86
83
  var allKeys;
87
84
  return __generator(this, function (_a) {
88
85
  switch (_a.label) {
89
- case 0:
90
- this.assertModule(this.asyncStorage);
91
- return [4 /*yield*/, this.asyncStorage.getAllKeys()];
86
+ case 0: return [4 /*yield*/, this.asyncStorage.getAllKeys()];
92
87
  case 1:
93
88
  allKeys = _a.sent();
94
89
  return [2 /*return*/, this.asyncStorage.multiRemove(allKeys.filter(function (key) { return key.startsWith(MEMORY_KEY_PREFIX); }))];
@@ -96,22 +91,6 @@ var DefaultStorage = /** @class */ (function () {
96
91
  });
97
92
  });
98
93
  };
99
- DefaultStorage.prototype.assertModule = function (asyncStorage) {
100
- if (!!asyncStorage) {
101
- return;
102
- }
103
- try {
104
- this.asyncStorage = require(ASYNC_STORAGE_MODULE)
105
- .default;
106
- }
107
- catch (err) {
108
- throw new errors_1.AmplifyError({
109
- name: 'NativeModuleException',
110
- message: "Unable to find ".concat(ASYNC_STORAGE_MODULE),
111
- recoverySuggestion: "Make sure to install ".concat(ASYNC_STORAGE_MODULE),
112
- });
113
- }
114
- };
115
94
  return DefaultStorage;
116
95
  }());
117
96
  exports.DefaultStorage = DefaultStorage;