@aws-amplify/core 6.0.1-console-preview.8f82e46.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 (82) 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/errors/errorHelpers.d.ts +2 -0
  6. package/lib/errors/errorHelpers.js +20 -0
  7. package/lib/errors/index.d.ts +1 -0
  8. package/lib/errors/index.js +3 -1
  9. package/lib/index.d.ts +1 -0
  10. package/lib/index.js +4 -1
  11. package/lib/libraryUtils.d.ts +4 -5
  12. package/lib/libraryUtils.js +9 -12
  13. package/lib/parseAWSExports.js +27 -18
  14. package/lib/providers/pinpoint/apis/record.d.ts +1 -1
  15. package/lib/providers/pinpoint/apis/record.js +5 -21
  16. package/lib/providers/pinpoint/index.d.ts +2 -2
  17. package/lib/providers/pinpoint/index.js +4 -2
  18. package/lib/providers/pinpoint/types/errors.d.ts +9 -0
  19. package/lib/providers/pinpoint/types/errors.js +15 -0
  20. package/lib/providers/pinpoint/types/index.d.ts +1 -0
  21. package/lib/providers/pinpoint/types/index.js +3 -0
  22. package/lib/providers/pinpoint/types/pinpoint.d.ts +2 -2
  23. package/lib/providers/pinpoint/utils/index.d.ts +1 -0
  24. package/lib/providers/pinpoint/utils/index.js +3 -1
  25. package/lib/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
  26. package/lib/providers/pinpoint/utils/resolveEndpointId.js +85 -0
  27. package/lib/singleton/Notifications/PushNotification/types.d.ts +2 -0
  28. package/lib/singleton/Notifications/PushNotification/types.js +4 -0
  29. package/lib/singleton/Notifications/types.d.ts +3 -1
  30. package/lib/tsconfig.tsbuildinfo +1 -1
  31. package/lib/types/errors.d.ts +1 -0
  32. package/lib/types/errors.js +1 -0
  33. package/lib-esm/Platform/types.d.ts +18 -8
  34. package/lib-esm/Platform/types.js +10 -2
  35. package/lib-esm/Platform/version.d.ts +1 -1
  36. package/lib-esm/Platform/version.js +1 -1
  37. package/lib-esm/errors/errorHelpers.d.ts +2 -0
  38. package/lib-esm/errors/errorHelpers.js +17 -0
  39. package/lib-esm/errors/index.d.ts +1 -0
  40. package/lib-esm/errors/index.js +1 -0
  41. package/lib-esm/index.d.ts +1 -0
  42. package/lib-esm/index.js +2 -0
  43. package/lib-esm/libraryUtils.d.ts +4 -5
  44. package/lib-esm/libraryUtils.js +3 -4
  45. package/lib-esm/parseAWSExports.js +27 -18
  46. package/lib-esm/providers/pinpoint/apis/record.d.ts +1 -1
  47. package/lib-esm/providers/pinpoint/apis/record.js +6 -22
  48. package/lib-esm/providers/pinpoint/index.d.ts +2 -2
  49. package/lib-esm/providers/pinpoint/index.js +2 -1
  50. package/lib-esm/providers/pinpoint/types/errors.d.ts +9 -0
  51. package/lib-esm/providers/pinpoint/types/errors.js +12 -0
  52. package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
  53. package/lib-esm/providers/pinpoint/types/index.js +1 -0
  54. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +2 -2
  55. package/lib-esm/providers/pinpoint/utils/index.d.ts +1 -0
  56. package/lib-esm/providers/pinpoint/utils/index.js +1 -0
  57. package/lib-esm/providers/pinpoint/utils/resolveEndpointId.d.ts +8 -0
  58. package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +81 -0
  59. package/lib-esm/singleton/Notifications/PushNotification/types.d.ts +2 -0
  60. package/lib-esm/singleton/Notifications/PushNotification/types.js +3 -0
  61. package/lib-esm/singleton/Notifications/types.d.ts +3 -1
  62. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  63. package/lib-esm/types/errors.d.ts +1 -0
  64. package/lib-esm/types/errors.js +1 -0
  65. package/package.json +3 -3
  66. package/src/Platform/types.ts +20 -11
  67. package/src/Platform/version.ts +1 -1
  68. package/src/errors/errorHelpers.ts +20 -0
  69. package/src/errors/index.ts +1 -0
  70. package/src/index.ts +3 -0
  71. package/src/libraryUtils.ts +11 -8
  72. package/src/parseAWSExports.ts +19 -14
  73. package/src/providers/pinpoint/apis/record.ts +11 -25
  74. package/src/providers/pinpoint/index.ts +6 -2
  75. package/src/providers/pinpoint/types/errors.ts +12 -0
  76. package/src/providers/pinpoint/types/index.ts +1 -0
  77. package/src/providers/pinpoint/types/pinpoint.ts +2 -2
  78. package/src/providers/pinpoint/utils/index.ts +1 -0
  79. package/src/providers/pinpoint/utils/resolveEndpointId.ts +46 -0
  80. package/src/singleton/Notifications/PushNotification/types.ts +6 -0
  81. package/src/singleton/Notifications/types.ts +3 -1
  82. package/src/types/errors.ts +1 -0
@@ -1,4 +1,5 @@
1
1
  export declare enum AmplifyErrorCode {
2
+ NoEndpointId = "NoEndpointId",
2
3
  PlatformNotSupported = "PlatformNotSupported",
3
4
  Unknown = "Unknown"
4
5
  }
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  export var AmplifyErrorCode;
4
4
  (function (AmplifyErrorCode) {
5
+ AmplifyErrorCode["NoEndpointId"] = "NoEndpointId";
5
6
  AmplifyErrorCode["PlatformNotSupported"] = "PlatformNotSupported";
6
7
  AmplifyErrorCode["Unknown"] = "Unknown";
7
8
  })(AmplifyErrorCode || (AmplifyErrorCode = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/core",
3
- "version": "6.0.1-console-preview.8f82e46.0+8f82e46",
3
+ "version": "6.0.1-console-preview.8d88eef.0+8d88eef",
4
4
  "description": "Core category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -64,7 +64,7 @@
64
64
  "uuid": "^9.0.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@aws-amplify/react-native": "1.0.1-console-preview.8f82e46.0+8f82e46",
67
+ "@aws-amplify/react-native": "1.0.1-console-preview.8d88eef.0+8d88eef",
68
68
  "@types/js-cookie": "3.0.2",
69
69
  "@types/uuid": "^9.0.0",
70
70
  "find": "^0.2.7",
@@ -169,5 +169,5 @@
169
169
  "lib-esm"
170
170
  ]
171
171
  },
172
- "gitHead": "8f82e460c4cdb9e52e0ba7ed8aea90f627a27693"
172
+ "gitHead": "8d88eef4137cef4fbe03d7d3683b5bec59feb7b8"
173
173
  }
@@ -83,7 +83,14 @@ export enum DataStoreAction {
83
83
  GraphQl = '2',
84
84
  }
85
85
  export enum GeoAction {
86
- None = '0',
86
+ SearchByText = '0',
87
+ SearchByCoordinates = '1',
88
+ SearchForSuggestions = '2',
89
+ SearchByPlaceId = '3',
90
+ SaveGeofences = '4',
91
+ GetGeofence = '5',
92
+ ListGeofences = '6',
93
+ DeleteGeofences = '7',
87
94
  }
88
95
  export enum InAppMessagingAction {
89
96
  SyncMessages = '1',
@@ -102,7 +109,8 @@ export enum PubSubAction {
102
109
  Subscribe = '1',
103
110
  }
104
111
  export enum PushNotificationAction {
105
- None = '0',
112
+ InitializePushNotifications = '1',
113
+ IdentifyUser = '2',
106
114
  }
107
115
  export enum StorageAction {
108
116
  UploadData = '1',
@@ -166,31 +174,32 @@ export type CustomUserAgentStateMap = Record<string, CategoryUserAgentStateMap>;
166
174
 
167
175
  export type AdditionalDetails = [string, string?][];
168
176
 
169
- type StorageUserAgentInput = {
177
+ export type StorageUserAgentInput = {
170
178
  category: Category.Storage;
171
179
  apis: StorageAction[];
180
+ additionalDetails: AdditionalDetails;
172
181
  };
173
182
 
174
- type AuthUserAgentInput = {
183
+ export type AuthUserAgentInput = {
175
184
  category: Category.Auth;
176
185
  apis: AuthAction[];
186
+ additionalDetails: AdditionalDetails;
177
187
  };
178
188
 
179
- type InAppMessagingUserAgentInput = {
189
+ export type InAppMessagingUserAgentInput = {
180
190
  category: Category.InAppMessaging;
181
191
  apis: InAppMessagingAction[];
192
+ additionalDetails: AdditionalDetails;
182
193
  };
183
194
 
184
- type GeoUserAgentInput = {
195
+ export type GeoUserAgentInput = {
185
196
  category: Category.Geo;
186
197
  apis: GeoAction[];
198
+ additionalDetails: AdditionalDetails;
187
199
  };
188
200
 
189
- export type SetCustomUserAgentInput = (
201
+ export type SetCustomUserAgentInput =
190
202
  | StorageUserAgentInput
191
203
  | AuthUserAgentInput
192
204
  | InAppMessagingUserAgentInput
193
- | GeoUserAgentInput
194
- ) & {
195
- additionalDetails: AdditionalDetails;
196
- };
205
+ | GeoUserAgentInput;
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '6.0.1-console-preview.8f82e46.0+8f82e46';
2
+ export const version = '6.0.1-console-preview.8d88eef.0+8d88eef';
@@ -0,0 +1,20 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { createAssertionFunction } from './createAssertionFunction';
5
+ import { AmplifyErrorCode, AmplifyErrorMap, AssertionFunction } from '../types';
6
+
7
+ const amplifyErrorMap: AmplifyErrorMap<AmplifyErrorCode> = {
8
+ [AmplifyErrorCode.NoEndpointId]: {
9
+ message: 'Endpoint ID was not found and was unable to be created.',
10
+ },
11
+ [AmplifyErrorCode.PlatformNotSupported]: {
12
+ message: 'Function not supported on current platform.',
13
+ },
14
+ [AmplifyErrorCode.Unknown]: {
15
+ message: 'An unknown error occurred.',
16
+ },
17
+ };
18
+
19
+ export const assert: AssertionFunction<AmplifyErrorCode> =
20
+ createAssertionFunction(amplifyErrorMap);
@@ -4,3 +4,4 @@
4
4
  export { AmplifyError } from './AmplifyError';
5
5
  export { createAssertionFunction } from './createAssertionFunction';
6
6
  export { PlatformNotSupportedError } from './PlatformNotSupportedError';
7
+ export { assert } from './errorHelpers';
package/src/index.ts CHANGED
@@ -66,5 +66,8 @@ export { Cache } from './Cache';
66
66
  // Internationalization utilities
67
67
  export { I18n } from './I18n';
68
68
 
69
+ // Logging utilities
70
+ export { ConsoleLogger } from './Logger';
71
+
69
72
  // Service worker
70
73
  export { ServiceWorker } from './ServiceWorker';
@@ -40,12 +40,9 @@ export {
40
40
  JwtPayload,
41
41
  AuthStandardAttributeKey,
42
42
  AuthVerifiableAttributeKey,
43
- AWSCredentials
43
+ AWSCredentials,
44
44
  } from './singleton/Auth/types';
45
45
 
46
- // Logging utilities
47
- export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
48
-
49
46
  // Platform & user-agent utilities
50
47
  export {
51
48
  Platform,
@@ -68,13 +65,14 @@ export {
68
65
  PushNotificationAction,
69
66
  StorageAction,
70
67
  SetCustomUserAgentInput,
68
+ StorageUserAgentInput,
69
+ AuthUserAgentInput,
70
+ InAppMessagingUserAgentInput,
71
+ GeoUserAgentInput,
71
72
  } from './Platform/types';
72
73
  export { setCustomUserAgent } from './Platform/customUserAgent';
73
74
 
74
- // Other utilities & constants
75
- export { BackgroundProcessManager } from './BackgroundProcessManager';
76
- export { Mutex } from './Mutex';
77
- export { Reachability } from './Reachability';
75
+ // Error handling
78
76
  export {
79
77
  AmplifyError,
80
78
  PlatformNotSupportedError,
@@ -87,6 +85,11 @@ export {
87
85
  AssertionFunction,
88
86
  ServiceError,
89
87
  } from './types';
88
+
89
+ // Other utilities & constants
90
+ export { BackgroundProcessManager } from './BackgroundProcessManager';
91
+ export { Mutex } from './Mutex';
92
+ export { Reachability } from './Reachability';
90
93
  export {
91
94
  INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER,
92
95
  USER_AGENT_HEADER,
@@ -1,11 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { ConsoleLogger as Logger } from './Logger';
4
- import {
5
- OAuthConfig,
6
- AuthStandardAttributeKey,
7
- AuthConfigUserAttributes,
8
- } from './singleton/Auth/types';
4
+ import { OAuthConfig, AuthConfigUserAttributes } from './singleton/Auth/types';
9
5
  import { ResourcesConfig } from './singleton/types';
10
6
 
11
7
  const logger = new Logger('parseAWSExports');
@@ -70,15 +66,24 @@ export const parseAWSExports = (
70
66
  }
71
67
 
72
68
  // Notifications
73
- if (Notifications) {
74
- if (Notifications.InAppMessaging?.AWSPinpoint) {
75
- const { appId, region } = Notifications.InAppMessaging.AWSPinpoint;
76
- amplifyConfig.Notifications = {
77
- InAppMessaging: {
78
- Pinpoint: {
79
- appId,
80
- region,
81
- },
69
+ const { InAppMessaging, Push } = Notifications ?? {};
70
+ if (InAppMessaging?.AWSPinpoint || Push?.AWSPinpoint) {
71
+ amplifyConfig.Notifications = {};
72
+ if (InAppMessaging?.AWSPinpoint) {
73
+ const { appId, region } = InAppMessaging.AWSPinpoint;
74
+ amplifyConfig.Notifications.InAppMessaging = {
75
+ Pinpoint: {
76
+ appId,
77
+ region,
78
+ },
79
+ };
80
+ }
81
+ if (Push?.AWSPinpoint) {
82
+ const { appId, region } = Push.AWSPinpoint;
83
+ amplifyConfig.Notifications.PushNotification = {
84
+ Pinpoint: {
85
+ appId,
86
+ region,
82
87
  },
83
88
  };
84
89
  }
@@ -3,16 +3,14 @@
3
3
 
4
4
  import { amplifyUuid } from '../../../utils/amplifyUuid';
5
5
  import { PinpointRecordInput, PinpointSession } from '../types';
6
- import { getEndpointId } from '../utils';
6
+ import { resolveEndpointId } from '../utils';
7
7
  import {
8
8
  BUFFER_SIZE,
9
9
  FLUSH_INTERVAL,
10
10
  FLUSH_SIZE,
11
11
  RESEND_LIMIT,
12
12
  } from '../utils/constants';
13
- import { updateEndpoint } from './updateEndpoint';
14
13
  import { getEventBuffer } from '../utils/getEventBuffer';
15
- import { AmplifyError } from '../../../errors';
16
14
 
17
15
  // TODO(v6) Refactor when we add support for session tracking & `autoTrack`
18
16
  let session: PinpointSession;
@@ -23,6 +21,7 @@ let session: PinpointSession;
23
21
  export const record = async ({
24
22
  appId,
25
23
  category,
24
+ channelType,
26
25
  credentials,
27
26
  event,
28
27
  identityId,
@@ -31,7 +30,6 @@ export const record = async ({
31
30
  }: PinpointRecordInput): Promise<void> => {
32
31
  const timestampISOString = new Date().toISOString();
33
32
  const eventId = amplifyUuid();
34
- let endpointId = await getEndpointId(appId, category);
35
33
 
36
34
  // Prepare event buffer if required
37
35
  const buffer = getEventBuffer({
@@ -46,27 +44,15 @@ export const record = async ({
46
44
  userAgentValue,
47
45
  });
48
46
 
49
- // Prepare a Pinpoint endpoint via updateEndpoint if one does not already exist, which will generate and cache an
50
- // endpoint ID between calls
51
- if (!endpointId) {
52
- await updateEndpoint({
53
- appId,
54
- category,
55
- credentials,
56
- identityId,
57
- region,
58
- userAgentValue,
59
- });
60
-
61
- endpointId = await getEndpointId(appId, category);
62
- }
63
-
64
- if (!endpointId) {
65
- throw new AmplifyError({
66
- name: 'ENDPOINT_NOT_CREATED',
67
- message: 'Endpoint was not created.',
68
- });
69
- }
47
+ const endpointId = await resolveEndpointId({
48
+ appId,
49
+ category,
50
+ channelType,
51
+ credentials,
52
+ identityId,
53
+ region,
54
+ userAgentValue,
55
+ });
70
56
 
71
57
  // Generate session if required
72
58
  if (!session) {
@@ -2,5 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export * from './apis';
5
- export { PinpointAnalyticsEvent, PinpointServiceOptions } from './types';
6
- export { getEndpointId } from './utils';
5
+ export {
6
+ PinpointAnalyticsEvent,
7
+ PinpointServiceOptions,
8
+ UpdateEndpointException,
9
+ } from './types';
10
+ export { resolveEndpointId } from './utils';
@@ -0,0 +1,12 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum UpdateEndpointException {
5
+ BadRequestException = 'BadRequestException',
6
+ ForbiddenException = 'ForbiddenException',
7
+ InternalServerErrorException = 'InternalServerErrorException',
8
+ MethodNotAllowedException = 'MethodNotAllowedException',
9
+ NotFoundException = 'NotFoundException',
10
+ PayloadTooLargeException = 'PayloadTooLargeException',
11
+ TooManyRequestsException = 'TooManyRequestsException',
12
+ }
@@ -1,4 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ export { UpdateEndpointException } from './errors';
4
5
  export * from './pinpoint';
@@ -10,7 +10,7 @@ export type SupportedCategory =
10
10
  | 'InAppMessaging'
11
11
  | 'PushNotification';
12
12
 
13
- export type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
13
+ type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
14
14
 
15
15
  export type PinpointProviderConfig = {
16
16
  Pinpoint?: {
@@ -40,6 +40,7 @@ export type PinpointAnalyticsEvent = {
40
40
  type PinpointCommonParameters = {
41
41
  appId: string;
42
42
  category: SupportedCategory;
43
+ channelType?: SupportedChannelType;
43
44
  credentials: Required<AuthSession>['credentials'];
44
45
  identityId?: AuthSession['identityId'];
45
46
  region: string;
@@ -48,7 +49,6 @@ type PinpointCommonParameters = {
48
49
 
49
50
  export type PinpointUpdateEndpointInput = PinpointCommonParameters &
50
51
  PinpointServiceOptions & {
51
- channelType?: SupportedChannelType;
52
52
  userId?: string;
53
53
  userProfile?: UserProfile;
54
54
  };
@@ -4,3 +4,4 @@
4
4
  export { cacheEndpointId } from './cacheEndpointId';
5
5
  export { getCacheKey } from './getCacheKey';
6
6
  export { getEndpointId } from './getEndpointId';
7
+ export { resolveEndpointId } from './resolveEndpointId';
@@ -0,0 +1,46 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { assert } from '../../../errors';
5
+ import { AmplifyErrorCode } from '../../../types';
6
+ import { updateEndpoint } from '../apis';
7
+ import { PinpointUpdateEndpointInput } from '../types';
8
+ import { getEndpointId } from './getEndpointId';
9
+
10
+ /**
11
+ * Resolves an endpoint id from cache or prepare via updateEndpoint if one does not already exist,
12
+ * which will generate and cache an endpoint id between calls.
13
+ *
14
+ * @internal
15
+ */
16
+ export const resolveEndpointId = async ({
17
+ address,
18
+ appId,
19
+ category,
20
+ channelType,
21
+ credentials,
22
+ identityId,
23
+ region,
24
+ userAgentValue,
25
+ }: PinpointUpdateEndpointInput) => {
26
+ let endpointId = await getEndpointId(appId, category);
27
+
28
+ if (!endpointId) {
29
+ await updateEndpoint({
30
+ address,
31
+ appId,
32
+ category,
33
+ channelType,
34
+ credentials,
35
+ identityId,
36
+ region,
37
+ userAgentValue,
38
+ });
39
+
40
+ endpointId = await getEndpointId(appId, category);
41
+ }
42
+
43
+ assert(!!endpointId, AmplifyErrorCode.NoEndpointId);
44
+
45
+ return endpointId;
46
+ };
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { PinpointProviderConfig } from '../../../providers/pinpoint/types';
5
+
6
+ export type PushNotificationConfig = PinpointProviderConfig;
@@ -2,7 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { InAppMessagingConfig } from './InAppMessaging/types';
5
+ import { PushNotificationConfig } from './PushNotification/types';
5
6
 
6
7
  export type NotificationsConfig = {
7
- InAppMessaging: InAppMessagingConfig;
8
+ InAppMessaging?: InAppMessagingConfig;
9
+ PushNotification?: PushNotificationConfig;
8
10
  };
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export enum AmplifyErrorCode {
5
+ NoEndpointId = 'NoEndpointId',
5
6
  PlatformNotSupported = 'PlatformNotSupported',
6
7
  Unknown = 'Unknown',
7
8
  }