@aws-amplify/notifications 2.0.21 → 2.0.22-unstable.1aafa48.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 (134) hide show
  1. package/dist/cjs/eventListeners/eventListeners.js +4 -7
  2. package/dist/cjs/eventListeners/eventListeners.js.map +1 -1
  3. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/clearMessages.js +1 -1
  4. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/clearMessages.js.map +1 -1
  5. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js +7 -7
  6. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js.map +1 -1
  7. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/identifyUser.js +3 -2
  8. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/identifyUser.js.map +1 -1
  9. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js +2 -2
  10. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js.map +1 -1
  11. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.js +1 -1
  12. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.js.map +1 -1
  13. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js +3 -27
  14. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js.map +1 -1
  15. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/syncMessages.js +1 -1
  16. package/dist/cjs/inAppMessaging/providers/pinpoint/apis/syncMessages.js.map +1 -1
  17. package/dist/cjs/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.js +50 -0
  18. package/dist/cjs/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.js.map +1 -0
  19. package/dist/cjs/inAppMessaging/providers/pinpoint/utils/helpers.js +8 -8
  20. package/dist/cjs/inAppMessaging/providers/pinpoint/utils/helpers.js.map +1 -1
  21. package/dist/cjs/inAppMessaging/providers/pinpoint/utils/index.js +4 -1
  22. package/dist/cjs/inAppMessaging/providers/pinpoint/utils/index.js.map +1 -1
  23. package/dist/cjs/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js +5 -6
  24. package/dist/cjs/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js.map +1 -1
  25. package/dist/cjs/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js +14 -5
  26. package/dist/cjs/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js.map +1 -1
  27. package/dist/cjs/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js +1 -1
  28. package/dist/cjs/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js.map +1 -1
  29. package/dist/esm/eventListeners/eventListeners.d.ts +2 -2
  30. package/dist/esm/eventListeners/eventListeners.mjs +4 -7
  31. package/dist/esm/eventListeners/eventListeners.mjs.map +1 -1
  32. package/dist/esm/eventListeners/types.d.ts +6 -5
  33. package/dist/esm/inAppMessaging/providers/pinpoint/apis/clearMessages.mjs +1 -1
  34. package/dist/esm/inAppMessaging/providers/pinpoint/apis/clearMessages.mjs.map +1 -1
  35. package/dist/esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.mjs +5 -4
  36. package/dist/esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.mjs.map +1 -1
  37. package/dist/esm/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -2
  38. package/dist/esm/inAppMessaging/providers/pinpoint/apis/identifyUser.mjs +3 -2
  39. package/dist/esm/inAppMessaging/providers/pinpoint/apis/identifyUser.mjs.map +1 -1
  40. package/dist/esm/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.mjs +2 -2
  41. package/dist/esm/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.mjs.map +1 -1
  42. package/dist/esm/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.d.ts +1 -1
  43. package/dist/esm/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.mjs +1 -1
  44. package/dist/esm/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.mjs.map +1 -1
  45. package/dist/esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.d.ts +1 -2
  46. package/dist/esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.mjs +7 -27
  47. package/dist/esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.mjs.map +1 -1
  48. package/dist/esm/inAppMessaging/providers/pinpoint/apis/syncMessages.mjs +1 -1
  49. package/dist/esm/inAppMessaging/providers/pinpoint/apis/syncMessages.mjs.map +1 -1
  50. package/dist/esm/inAppMessaging/providers/pinpoint/types/inputs.d.ts +3 -3
  51. package/dist/esm/inAppMessaging/providers/pinpoint/types/types.d.ts +4 -4
  52. package/dist/esm/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.d.ts +13 -0
  53. package/dist/esm/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.mjs +46 -0
  54. package/dist/esm/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.mjs.map +1 -0
  55. package/dist/esm/inAppMessaging/providers/pinpoint/utils/helpers.d.ts +1 -1
  56. package/dist/esm/inAppMessaging/providers/pinpoint/utils/helpers.mjs +8 -8
  57. package/dist/esm/inAppMessaging/providers/pinpoint/utils/helpers.mjs.map +1 -1
  58. package/dist/esm/inAppMessaging/providers/pinpoint/utils/index.d.ts +1 -0
  59. package/dist/esm/inAppMessaging/providers/pinpoint/utils/index.mjs +1 -0
  60. package/dist/esm/inAppMessaging/providers/pinpoint/utils/index.mjs.map +1 -1
  61. package/dist/esm/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.d.ts +1 -1
  62. package/dist/esm/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.mjs +5 -6
  63. package/dist/esm/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.mjs.map +1 -1
  64. package/dist/esm/inAppMessaging/providers/pinpoint/utils/userAgent.mjs.map +1 -1
  65. package/dist/esm/inAppMessaging/types/event.d.ts +2 -2
  66. package/dist/esm/inAppMessaging/types/inputs.d.ts +2 -2
  67. package/dist/esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.mjs +14 -5
  68. package/dist/esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.mjs.map +1 -1
  69. package/dist/esm/pushNotifications/providers/pinpoint/types/analytics.d.ts +2 -2
  70. package/dist/esm/pushNotifications/providers/pinpoint/types/inputs.d.ts +1 -1
  71. package/dist/esm/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.d.ts +1 -1
  72. package/dist/esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.mjs +1 -1
  73. package/dist/esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.mjs.map +1 -1
  74. package/dist/esm/pushNotifications/providers/pinpoint/utils/resolveConfig.mjs.map +1 -1
  75. package/dist/esm/pushNotifications/types/inputs.d.ts +2 -2
  76. package/dist/esm/pushNotifications/utils/resolveCredentials.mjs.map +1 -1
  77. package/package.json +104 -103
  78. package/src/eventListeners/eventListeners.ts +16 -9
  79. package/src/eventListeners/types.ts +7 -5
  80. package/src/inAppMessaging/errors/assertServiceError.ts +1 -0
  81. package/src/inAppMessaging/providers/pinpoint/apis/clearMessages.ts +3 -2
  82. package/src/inAppMessaging/providers/pinpoint/apis/dispatchEvent.ts +18 -11
  83. package/src/inAppMessaging/providers/pinpoint/apis/identifyUser.ts +5 -7
  84. package/src/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.ts +5 -3
  85. package/src/inAppMessaging/providers/pinpoint/apis/notifyMessageInteraction.ts +1 -0
  86. package/src/inAppMessaging/providers/pinpoint/apis/onMessageActionTaken.ts +2 -0
  87. package/src/inAppMessaging/providers/pinpoint/apis/onMessageDismissed.ts +2 -0
  88. package/src/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.ts +3 -1
  89. package/src/inAppMessaging/providers/pinpoint/apis/onMessageReceived.ts +2 -0
  90. package/src/inAppMessaging/providers/pinpoint/apis/setConflictHandler.ts +7 -34
  91. package/src/inAppMessaging/providers/pinpoint/apis/syncMessages.ts +12 -10
  92. package/src/inAppMessaging/providers/pinpoint/types/inputs.ts +8 -7
  93. package/src/inAppMessaging/providers/pinpoint/types/types.ts +4 -4
  94. package/src/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.ts +54 -0
  95. package/src/inAppMessaging/providers/pinpoint/utils/helpers.ts +19 -9
  96. package/src/inAppMessaging/providers/pinpoint/utils/index.ts +4 -0
  97. package/src/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.ts +19 -11
  98. package/src/inAppMessaging/providers/pinpoint/utils/resolveConfig.ts +2 -0
  99. package/src/inAppMessaging/providers/pinpoint/utils/resolveCredentials.ts +2 -0
  100. package/src/inAppMessaging/providers/pinpoint/utils/userAgent.ts +2 -2
  101. package/src/inAppMessaging/types/event.ts +2 -2
  102. package/src/inAppMessaging/types/inputs.ts +4 -3
  103. package/src/pushNotifications/errors/errorHelpers.ts +2 -0
  104. package/src/pushNotifications/providers/pinpoint/apis/getBadgeCount.native.ts +2 -0
  105. package/src/pushNotifications/providers/pinpoint/apis/getBadgeCount.ts +1 -0
  106. package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.ts +2 -0
  107. package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.ts +1 -0
  108. package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.ts +2 -0
  109. package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.ts +1 -0
  110. package/src/pushNotifications/providers/pinpoint/apis/identifyUser.native.ts +1 -0
  111. package/src/pushNotifications/providers/pinpoint/apis/identifyUser.ts +1 -0
  112. package/src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.ts +21 -12
  113. package/src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.ts +1 -0
  114. package/src/pushNotifications/providers/pinpoint/apis/onNotificationOpened.native.ts +1 -0
  115. package/src/pushNotifications/providers/pinpoint/apis/onNotificationOpened.ts +1 -0
  116. package/src/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.native.ts +1 -0
  117. package/src/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.ts +1 -0
  118. package/src/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.native.ts +1 -0
  119. package/src/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.ts +1 -0
  120. package/src/pushNotifications/providers/pinpoint/apis/onTokenReceived.native.ts +1 -0
  121. package/src/pushNotifications/providers/pinpoint/apis/onTokenReceived.ts +1 -0
  122. package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.native.ts +2 -0
  123. package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.ts +1 -0
  124. package/src/pushNotifications/providers/pinpoint/apis/setBadgeCount.native.ts +1 -0
  125. package/src/pushNotifications/providers/pinpoint/apis/setBadgeCount.ts +1 -0
  126. package/src/pushNotifications/providers/pinpoint/types/analytics.ts +2 -2
  127. package/src/pushNotifications/providers/pinpoint/types/inputs.ts +4 -3
  128. package/src/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.ts +5 -1
  129. package/src/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.ts +3 -1
  130. package/src/pushNotifications/providers/pinpoint/utils/getChannelType.ts +1 -0
  131. package/src/pushNotifications/providers/pinpoint/utils/resolveConfig.ts +3 -1
  132. package/src/pushNotifications/types/inputs.ts +4 -3
  133. package/src/pushNotifications/utils/getPushNotificationUserAgentString.ts +1 -1
  134. package/src/pushNotifications/utils/resolveCredentials.ts +3 -1
@@ -2,7 +2,7 @@ import { UserProfile } from '@aws-amplify/core';
2
2
  import { PushNotificationServiceOptions } from './options';
3
3
  import { PushNotificationPermissions } from './module';
4
4
  import { OnPushNotificationMessageHandler, OnTokenReceivedHandler } from './pushNotifications';
5
- export type PushNotificationIdentifyUserInput<ServiceOptions extends PushNotificationServiceOptions = PushNotificationServiceOptions> = {
5
+ export interface PushNotificationIdentifyUserInput<ServiceOptions extends PushNotificationServiceOptions = PushNotificationServiceOptions> {
6
6
  /**
7
7
  * A User ID associated to the current device.
8
8
  */
@@ -15,7 +15,7 @@ export type PushNotificationIdentifyUserInput<ServiceOptions extends PushNotific
15
15
  * Options to be passed to the API.
16
16
  */
17
17
  options?: ServiceOptions;
18
- };
18
+ }
19
19
  export type PushNotificationRequestPermissionsInput = PushNotificationPermissions;
20
20
  export type PushNotificationSetBadgeCountInput = number;
21
21
  export type PushNotificationOnNotificationOpenedInput = OnPushNotificationMessageHandler;
@@ -1 +1 @@
1
- {"version":3,"file":"resolveCredentials.mjs","sources":["../../../../src/pushNotifications/utils/resolveCredentials.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { fetchAuthSession } from '@aws-amplify/core';\nimport { assert, PushNotificationValidationErrorCode, } from '../errors/errorHelpers';\n/**\n * @internal\n */\nexport const resolveCredentials = async () => {\n const { credentials, identityId } = await fetchAuthSession();\n assert(!!credentials, PushNotificationValidationErrorCode.NoCredentials);\n return { credentials, identityId };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,YAAY;AAC9C,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;AACjE,IAAI,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,mCAAmC,CAAC,aAAa,CAAC,CAAC;AAC7E,IAAI,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AACvC;;;;"}
1
+ {"version":3,"file":"resolveCredentials.mjs","sources":["../../../../src/pushNotifications/utils/resolveCredentials.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { fetchAuthSession } from '@aws-amplify/core';\nimport { PushNotificationValidationErrorCode, assert, } from '../errors/errorHelpers';\n/**\n * @internal\n */\nexport const resolveCredentials = async () => {\n const { credentials, identityId } = await fetchAuthSession();\n assert(!!credentials, PushNotificationValidationErrorCode.NoCredentials);\n return { credentials, identityId };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,YAAY;AAC9C,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;AACjE,IAAI,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,mCAAmC,CAAC,aAAa,CAAC,CAAC;AAC7E,IAAI,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AACvC;;;;"}
package/package.json CHANGED
@@ -1,105 +1,106 @@
1
1
  {
2
- "name": "@aws-amplify/notifications",
3
- "version": "2.0.21",
4
- "description": "Notifications category of aws-amplify",
5
- "main": "./dist/cjs/index.js",
6
- "module": "./dist/esm/index.mjs",
7
- "react-native": "./src/index.ts",
8
- "typings": "./dist/esm/index.d.ts",
9
- "sideEffects": false,
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "scripts": {
14
- "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
15
- "test:watch": "tslint 'src/**/*.ts' && jest -w 1 --watch",
16
- "build-with-test": "npm run clean && npm run build",
17
- "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
18
- "build:esm-cjs": "rollup -c rollup.config.mjs",
19
- "build:watch": "npm run build:esm-cjs -- --watch",
20
- "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
21
- "clean": "npm run clean:size && rimraf dist lib lib-esm",
22
- "clean:size": "rimraf dual-publish-tmp tmp*",
23
- "format": "echo \"Not implemented\"",
24
- "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
25
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 88.21"
26
- },
27
- "typesVersions": {
28
- ">=4.2": {
29
- "in-app-messaging": [
30
- "./dist/esm/inAppMessaging/index.d.ts"
31
- ],
32
- "push-notifications": [
33
- "./dist/esm/pushNotifications/providers/index.d.ts"
34
- ],
35
- "in-app-messaging/pinpoint": [
36
- "./dist/esm/inAppMessaging/providers/pinpoint/index.d.ts"
37
- ],
38
- "push-notifications/pinpoint": [
39
- "./dist/esm/pushNotifications/providers/pinpoint/index.d.ts"
40
- ]
41
- }
42
- },
43
- "exports": {
44
- ".": {
45
- "import": "./dist/esm/index.mjs",
46
- "require": "./dist/cjs/index.js",
47
- "react-native": "./src/index.ts"
48
- },
49
- "./in-app-messaging": {
50
- "types": "./dist/esm/inAppMessaging/index.d.ts",
51
- "import": "./dist/esm/inAppMessaging/index.mjs",
52
- "require": "./dist/cjs/inAppMessaging/index.js",
53
- "react-native": "./src/inAppMessaging/index.ts"
54
- },
55
- "./push-notifications": {
56
- "types": "./dist/esm/pushNotifications/index.d.ts",
57
- "import": "./dist/esm/pushNotifications/index.mjs",
58
- "require": "./dist/cjs/pushNotifications/index.js",
59
- "react-native": "./src/pushNotifications/index.ts"
60
- },
61
- "./in-app-messaging/pinpoint": {
62
- "types": "./dist/esm/inAppMessaging/providers/pinpoint/index.d.ts",
63
- "import": "./dist/esm/inAppMessaging/providers/pinpoint/index.mjs",
64
- "require": "./dist/cjs/inAppMessaging/providers/pinpoint/index.js",
65
- "react-native": "./src/inAppMessaging/providers/pinpoint/index.ts"
66
- },
67
- "./push-notifications/pinpoint": {
68
- "types": "./dist/esm/pushNotifications/providers/pinpoint/index.d.ts",
69
- "import": "./dist/esm/pushNotifications/providers/pinpoint/index.mjs",
70
- "require": "./dist/cjs/pushNotifications/providers/pinpoint/index.js",
71
- "react-native": "./src/pushNotifications/providers/pinpoint/index.ts"
72
- },
73
- "./package.json": "./package.json"
74
- },
75
- "repository": {
76
- "type": "git",
77
- "url": "https://github.com/aws-amplify/amplify-js.git"
78
- },
79
- "author": "Amazon Web Services",
80
- "license": "Apache-2.0",
81
- "bugs": {
82
- "url": "https://github.com/aws/aws-amplify/issues"
83
- },
84
- "homepage": "https://docs.amplify.aws/",
85
- "files": [
86
- "dist/cjs",
87
- "dist/esm",
88
- "src",
89
- "in-app-messaging",
90
- "push-notifications"
91
- ],
92
- "dependencies": {
93
- "lodash": "^4.17.21",
94
- "tslib": "^2.5.0"
95
- },
96
- "peerDependencies": {
97
- "@aws-amplify/core": "^6.0.0"
98
- },
99
- "devDependencies": {
100
- "@aws-amplify/core": "6.0.21",
101
- "@aws-amplify/react-native": "1.0.22",
102
- "typescript": "5.0.2"
103
- },
104
- "gitHead": "00f4046bc984c931c1a2a95d806e418e093d77d0"
2
+ "name": "@aws-amplify/notifications",
3
+ "version": "2.0.22-unstable.1aafa48.0+1aafa48",
4
+ "description": "Notifications category of aws-amplify",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.mjs",
7
+ "react-native": "./src/index.ts",
8
+ "typings": "./dist/esm/index.d.ts",
9
+ "sideEffects": false,
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
15
+ "test:watch": "tslint 'src/**/*.ts' && jest -w 1 --watch",
16
+ "build-with-test": "npm run clean && npm run build",
17
+ "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
18
+ "build:esm-cjs": "rollup -c rollup.config.mjs",
19
+ "build:watch": "npm run build:esm-cjs -- --watch",
20
+ "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
21
+ "clean": "npm run clean:size && rimraf dist lib lib-esm",
22
+ "clean:size": "rimraf dual-publish-tmp tmp*",
23
+ "format": "echo \"Not implemented\"",
24
+ "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
25
+ "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
26
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 88.21"
27
+ },
28
+ "typesVersions": {
29
+ ">=4.2": {
30
+ "in-app-messaging": [
31
+ "./dist/esm/inAppMessaging/index.d.ts"
32
+ ],
33
+ "push-notifications": [
34
+ "./dist/esm/pushNotifications/providers/index.d.ts"
35
+ ],
36
+ "in-app-messaging/pinpoint": [
37
+ "./dist/esm/inAppMessaging/providers/pinpoint/index.d.ts"
38
+ ],
39
+ "push-notifications/pinpoint": [
40
+ "./dist/esm/pushNotifications/providers/pinpoint/index.d.ts"
41
+ ]
42
+ }
43
+ },
44
+ "exports": {
45
+ ".": {
46
+ "import": "./dist/esm/index.mjs",
47
+ "require": "./dist/cjs/index.js",
48
+ "react-native": "./src/index.ts"
49
+ },
50
+ "./in-app-messaging": {
51
+ "types": "./dist/esm/inAppMessaging/index.d.ts",
52
+ "import": "./dist/esm/inAppMessaging/index.mjs",
53
+ "require": "./dist/cjs/inAppMessaging/index.js",
54
+ "react-native": "./src/inAppMessaging/index.ts"
55
+ },
56
+ "./push-notifications": {
57
+ "types": "./dist/esm/pushNotifications/index.d.ts",
58
+ "import": "./dist/esm/pushNotifications/index.mjs",
59
+ "require": "./dist/cjs/pushNotifications/index.js",
60
+ "react-native": "./src/pushNotifications/index.ts"
61
+ },
62
+ "./in-app-messaging/pinpoint": {
63
+ "types": "./dist/esm/inAppMessaging/providers/pinpoint/index.d.ts",
64
+ "import": "./dist/esm/inAppMessaging/providers/pinpoint/index.mjs",
65
+ "require": "./dist/cjs/inAppMessaging/providers/pinpoint/index.js",
66
+ "react-native": "./src/inAppMessaging/providers/pinpoint/index.ts"
67
+ },
68
+ "./push-notifications/pinpoint": {
69
+ "types": "./dist/esm/pushNotifications/providers/pinpoint/index.d.ts",
70
+ "import": "./dist/esm/pushNotifications/providers/pinpoint/index.mjs",
71
+ "require": "./dist/cjs/pushNotifications/providers/pinpoint/index.js",
72
+ "react-native": "./src/pushNotifications/providers/pinpoint/index.ts"
73
+ },
74
+ "./package.json": "./package.json"
75
+ },
76
+ "repository": {
77
+ "type": "git",
78
+ "url": "https://github.com/aws-amplify/amplify-js.git"
79
+ },
80
+ "author": "Amazon Web Services",
81
+ "license": "Apache-2.0",
82
+ "bugs": {
83
+ "url": "https://github.com/aws/aws-amplify/issues"
84
+ },
85
+ "homepage": "https://docs.amplify.aws/",
86
+ "files": [
87
+ "dist/cjs",
88
+ "dist/esm",
89
+ "src",
90
+ "in-app-messaging",
91
+ "push-notifications"
92
+ ],
93
+ "dependencies": {
94
+ "lodash": "^4.17.21",
95
+ "tslib": "^2.5.0"
96
+ },
97
+ "peerDependencies": {
98
+ "@aws-amplify/core": "6.0.22-unstable.1aafa48.0+1aafa48"
99
+ },
100
+ "devDependencies": {
101
+ "@aws-amplify/core": "6.0.22-unstable.1aafa48.0+1aafa48",
102
+ "@aws-amplify/react-native": "1.0.23-unstable.1aafa48.0+1aafa48",
103
+ "typescript": "5.0.2"
104
+ },
105
+ "gitHead": "1aafa4837c45b96d7c8fca5ddacf973097fac19e"
105
106
  }
@@ -1,9 +1,17 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { EventListener, EventListenerRemover, EventType } from './types';
4
+ import {
5
+ EventListener,
6
+ EventListenerHandler,
7
+ EventListenerRemover,
8
+ EventType,
9
+ } from './types';
5
10
 
6
- const eventListeners: Record<string, Set<EventListener<Function>>> = {};
11
+ const eventListeners: Record<
12
+ string,
13
+ Set<EventListener<EventListenerHandler>>
14
+ > = {};
7
15
 
8
16
  export const notifyEventListeners = (type: EventType, ...args: any[]): void => {
9
17
  eventListeners[type]?.forEach(listener => {
@@ -17,15 +25,11 @@ export const notifyEventListenersAndAwaitHandlers = (
17
25
  ): Promise<void[]> =>
18
26
  Promise.all<void>(
19
27
  Array.from(eventListeners[type] ?? []).map(async listener => {
20
- try {
21
- await listener.handleEvent(...args);
22
- } catch (err) {
23
- throw err;
24
- }
28
+ await listener.handleEvent(...args);
25
29
  }),
26
30
  );
27
31
 
28
- export const addEventListener = <EventHandler extends Function>(
32
+ export const addEventListener = <EventHandler extends EventListenerHandler>(
29
33
  type: EventType,
30
34
  handler: EventHandler,
31
35
  ): EventListenerRemover => {
@@ -40,7 +44,10 @@ export const addEventListener = <EventHandler extends Function>(
40
44
  },
41
45
  };
42
46
  eventListeners[type].add(listener);
47
+
43
48
  return {
44
- remove: () => listener.remove(),
49
+ remove: () => {
50
+ listener.remove();
51
+ },
45
52
  };
46
53
  };
@@ -4,13 +4,15 @@
4
4
  import { InAppMessageInteractionEvent } from '../inAppMessaging/types';
5
5
  import { PushNotificationEvent } from '../pushNotifications/types';
6
6
 
7
- export interface EventListener<EventHandler extends Function> {
7
+ export type EventListenerHandler = (...args: any[]) => unknown;
8
+
9
+ export interface EventListener<EventHandler extends EventListenerHandler> {
8
10
  handleEvent: EventHandler;
9
- remove: () => void;
11
+ remove(): void;
10
12
  }
11
13
 
12
14
  export type EventType = InAppMessageInteractionEvent | PushNotificationEvent;
13
15
 
14
- export type EventListenerRemover = {
15
- remove: () => void;
16
- };
16
+ export interface EventListenerRemover {
17
+ remove(): void;
18
+ }
@@ -5,6 +5,7 @@ import {
5
5
  AmplifyErrorCode,
6
6
  ServiceError,
7
7
  } from '@aws-amplify/core/internals/utils';
8
+
8
9
  import { InAppMessagingError } from './InAppMessagingError';
9
10
 
10
11
  export function assertServiceError(
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { defaultStorage } from '@aws-amplify/core';
5
- import { STORAGE_KEY_SUFFIX, PINPOINT_KEY_PREFIX } from '../utils';
6
5
 
6
+ import { PINPOINT_KEY_PREFIX, STORAGE_KEY_SUFFIX } from '../utils';
7
7
  import { InAppMessagingValidationErrorCode } from '../../../errors';
8
8
  import { assertIsInitialized } from '../../../utils';
9
9
 
@@ -22,5 +22,6 @@ import { assertIsInitialized } from '../../../utils';
22
22
  export async function clearMessages(): Promise<void> {
23
23
  assertIsInitialized();
24
24
  const key = `${PINPOINT_KEY_PREFIX}${STORAGE_KEY_SUFFIX}`;
25
- return await defaultStorage.removeItem(key);
25
+
26
+ await defaultStorage.removeItem(key);
26
27
  }
@@ -1,20 +1,26 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import flatten from 'lodash/flatten.js';
5
+ import { defaultStorage } from '@aws-amplify/core';
6
+
7
+ import { notifyEventListeners } from '../../../../eventListeners';
8
+ import {
9
+ InAppMessagingValidationErrorCode,
10
+ assertServiceError,
11
+ } from '../../../errors';
12
+ import { InAppMessage } from '../../../types';
13
+ import { assertIsInitialized } from '../../../utils';
14
+ import { DispatchEventInput } from '../types';
4
15
  import {
5
16
  PINPOINT_KEY_PREFIX,
6
17
  STORAGE_KEY_SUFFIX,
18
+ getConflictHandler,
7
19
  processInAppMessages,
8
20
  } from '../utils';
9
- import { InAppMessage } from '../../../types';
10
- import flatten from 'lodash/flatten.js';
11
- import { defaultStorage } from '@aws-amplify/core';
12
- import { notifyEventListeners } from '../../../../eventListeners';
13
- import { assertServiceError } from '../../../errors';
14
- import { DispatchEventInput } from '../types';
21
+
15
22
  import { syncMessages } from './syncMessages';
16
- import { conflictHandler, setConflictHandler } from './setConflictHandler';
17
- import { assertIsInitialized } from '../../../utils';
23
+ import { setConflictHandler } from './setConflictHandler';
18
24
 
19
25
  /**
20
26
  * Triggers an In-App message to be displayed. Use this after your campaigns have been synced to the device using
@@ -27,13 +33,13 @@ import { assertIsInitialized } from '../../../utils';
27
33
  * your own logic for resolving message conflicts.
28
34
  *
29
35
  * @param input The input object that holds the event to be dispatched.
30
- *
36
+ *
31
37
  * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
32
38
  * configuration is incorrect, or if In App messaging hasn't been initialized.
33
39
  * @throws service exceptions - Thrown when the underlying Pinpoint service returns an error.
34
- *
40
+ *
35
41
  * @returns A promise that will resolve when the operation is complete.
36
- *
42
+ *
37
43
  * @example
38
44
  * ```ts
39
45
  * // Sync message before disptaching an event
@@ -54,6 +60,7 @@ export async function dispatchEvent(input: DispatchEventInput): Promise<void> {
54
60
  );
55
61
  const flattenedMessages = flatten(messages);
56
62
  if (flattenedMessages.length > 0) {
63
+ const conflictHandler = getConflictHandler();
57
64
  notifyEventListeners(
58
65
  'messageReceived',
59
66
  conflictHandler(flattenedMessages),
@@ -3,9 +3,10 @@
3
3
 
4
4
  import { InAppMessagingAction } from '@aws-amplify/core/internals/utils';
5
5
  import {
6
- updateEndpoint,
7
6
  UpdateEndpointException,
7
+ updateEndpoint,
8
8
  } from '@aws-amplify/core/internals/providers/pinpoint';
9
+
9
10
  import { InAppMessagingValidationErrorCode } from '../../../errors';
10
11
  import {
11
12
  CATEGORY,
@@ -22,7 +23,7 @@ import { assertIsInitialized } from '../../../utils';
22
23
  * profile and activities or actions in your application. Activity can be tracked across devices & platforms by using
23
24
  * the same `userId`.
24
25
  *
25
- * @param {IdentifyUserParameters} params The input object used to construct requests sent to Pinpoint's UpdateEndpoint
26
+ * @param input The input object that conforms to {@link IdentifyUserInput} used to construct requests sent to Pinpoint's UpdateEndpoint
26
27
  * API.
27
28
  * @throws service: {@link UpdateEndpointException} - Thrown when the underlying Pinpoint service returns an error.
28
29
  * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
@@ -66,11 +67,8 @@ import { assertIsInitialized } from '../../../utils';
66
67
  * },
67
68
  * });
68
69
  */
69
- export const identifyUser = async ({
70
- userId,
71
- userProfile,
72
- options,
73
- }: IdentifyUserInput): Promise<void> => {
70
+ export const identifyUser = async (input: IdentifyUserInput): Promise<void> => {
71
+ const { userId, userProfile, options } = input;
74
72
  assertIsInitialized();
75
73
  const { credentials, identityId } = await resolveCredentials();
76
74
  const { appId, region } = resolveConfig();
@@ -2,14 +2,16 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { sessionListener } from '@aws-amplify/core/internals/utils';
5
+ import { Hub, HubCapsule } from '@aws-amplify/core';
6
+
5
7
  import { InAppMessage, InAppMessagingEvent } from '../../../types';
6
8
  import { addEventListener } from '../../../../eventListeners';
7
9
  import { recordAnalyticsEvent } from '../utils/helpers';
8
10
  import { PinpointMessageEvent } from '../types';
9
- import { Hub, HubCapsule } from '@aws-amplify/core';
10
- import { dispatchEvent } from './dispatchEvent';
11
11
  import { incrementMessageCounts, sessionStateChangeHandler } from '../utils';
12
- import { isInitialized, initialize } from '../../../utils';
12
+ import { initialize, isInitialized } from '../../../utils';
13
+
14
+ import { dispatchEvent } from './dispatchEvent';
13
15
 
14
16
  /**
15
17
  * Initialize and set up in-app messaging category. This API needs to be called to enable other InAppMessaging APIs.
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { notifyEventListeners } from '../../../../eventListeners';
5
+ import { InAppMessagingValidationErrorCode } from '../../../errors';
5
6
  import { assertIsInitialized } from '../../../utils';
6
7
  import { NotifyMessageInteractionInput } from '../types/inputs';
7
8
 
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { addEventListener } from '../../../../eventListeners';
5
+ import { InAppMessagingValidationErrorCode } from '../../../errors';
5
6
  import { assertIsInitialized } from '../../../utils';
6
7
  import { OnMessageActionTakenInput } from '../types/inputs';
7
8
  import { OnMessageActionTakenOutput } from '../types/outputs';
@@ -25,5 +26,6 @@ export function onMessageActionTaken(
25
26
  input: OnMessageActionTakenInput,
26
27
  ): OnMessageActionTakenOutput {
27
28
  assertIsInitialized();
29
+
28
30
  return addEventListener('messageActionTaken', input);
29
31
  }
@@ -5,6 +5,7 @@ import { addEventListener } from '../../../../eventListeners';
5
5
  import { OnMessageDismissedOutput } from '../types/outputs';
6
6
  import { OnMessageDismissedInput } from '../types/inputs';
7
7
  import { assertIsInitialized } from '../../../utils';
8
+ import { InAppMessagingValidationErrorCode } from '../../../errors';
8
9
 
9
10
  /**
10
11
  * Registers a callback that will be invoked on `messageDismissed` events.
@@ -25,5 +26,6 @@ export function onMessageDismissed(
25
26
  input: OnMessageDismissedInput,
26
27
  ): OnMessageDismissedOutput {
27
28
  assertIsInitialized();
29
+
28
30
  return addEventListener('messageDismissed', input);
29
31
  }
@@ -5,6 +5,7 @@ import { addEventListener } from '../../../../eventListeners';
5
5
  import { OnMessageDisplayedOutput } from '../types/outputs';
6
6
  import { OnMessageDisplayedInput } from '../types/inputs';
7
7
  import { assertIsInitialized } from '../../../utils';
8
+ import { InAppMessagingValidationErrorCode } from '../../../errors';
8
9
 
9
10
  /**
10
11
  * Registers a callback that will be invoked on `messageDisplayed` events.
@@ -12,7 +13,7 @@ import { assertIsInitialized } from '../../../utils';
12
13
  * @param {OnMessageDisplayedInput} input - The input object that holds the callback handler.
13
14
  * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
14
15
  * configuration is incorrect, or if In App messaging hasn't been initialized.
15
- * @returns {OnMessageDismissedOutput} - An object that holds a remove method to stop listening to events.
16
+ * @returns {OnMessageDisplayedOutput} - An object that holds a remove method to stop listening to events.
16
17
  * @example
17
18
  * ```ts
18
19
  * onMessageDisplayed((message) => {
@@ -25,5 +26,6 @@ export function onMessageDisplayed(
25
26
  input: OnMessageDisplayedInput,
26
27
  ): OnMessageDisplayedOutput {
27
28
  assertIsInitialized();
29
+
28
30
  return addEventListener('messageDisplayed', input);
29
31
  }
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { addEventListener } from '../../../../eventListeners';
5
+ import { InAppMessagingValidationErrorCode } from '../../../errors';
5
6
  import { assertIsInitialized } from '../../../utils';
6
7
  import { OnMessageReceivedInput } from '../types/inputs';
7
8
  import { OnMessageReceivedOutput } from '../types/outputs';
@@ -25,5 +26,6 @@ export function onMessageReceived(
25
26
  input: OnMessageReceivedInput,
26
27
  ): OnMessageReceivedOutput {
27
28
  assertIsInitialized();
29
+
28
30
  return addEventListener('messageReceived', input);
29
31
  }
@@ -1,12 +1,10 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { InAppMessage } from '../../../types';
4
+ import { InAppMessagingValidationErrorCode } from '../../../errors';
5
5
  import { assertIsInitialized } from '../../../utils';
6
- import { InAppMessageConflictHandler, SetConflictHandlerInput } from '../types';
7
-
8
- export let conflictHandler: InAppMessageConflictHandler =
9
- defaultConflictHandler;
6
+ import { SetConflictHandlerInput } from '../types';
7
+ import { setConflictHandler as setConflictHandlerInteral } from '../utils';
10
8
 
11
9
  /**
12
10
  * Set a conflict handler that will be used to resolve conflicts that may emerge
@@ -15,12 +13,12 @@ export let conflictHandler: InAppMessageConflictHandler =
15
13
  * @remark
16
14
  * The conflict handler is not persisted across app restarts and so must be set again before dispatching an event for
17
15
  * any custom handling to take effect.
18
- *
16
+ *
19
17
  * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
20
18
  * configuration is incorrect, or if In App messaging hasn't been initialized.
21
- *
19
+ *
22
20
  * @param input The input object that holds the conflict handler to be used.
23
- *
21
+ *
24
22
  * @example
25
23
  * ```ts
26
24
  * // Sync messages before dispatching an event
@@ -42,30 +40,5 @@ export let conflictHandler: InAppMessageConflictHandler =
42
40
  */
43
41
  export function setConflictHandler(input: SetConflictHandlerInput): void {
44
42
  assertIsInitialized();
45
- conflictHandler = input;
46
- }
47
-
48
- function defaultConflictHandler(messages: InAppMessage[]): InAppMessage {
49
- // default behavior is to return the message closest to expiry
50
- // this function assumes that messages processed by providers already filters out expired messages
51
- const sorted = messages.sort((a, b) => {
52
- const endDateA = a.metadata?.endDate;
53
- const endDateB = b.metadata?.endDate;
54
- // if both message end dates are falsy or have the same date string, treat them as equal
55
- if (endDateA === endDateB) {
56
- return 0;
57
- }
58
- // if only message A has an end date, treat it as closer to expiry
59
- if (endDateA && !endDateB) {
60
- return -1;
61
- }
62
- // if only message B has an end date, treat it as closer to expiry
63
- if (!endDateA && endDateB) {
64
- return 1;
65
- }
66
- // otherwise, compare them
67
- return new Date(endDateA) < new Date(endDateB) ? -1 : 1;
68
- });
69
- // always return the top sorted
70
- return sorted[0];
43
+ setConflictHandlerInteral(input);
71
44
  }
@@ -5,19 +5,20 @@ import { InAppMessagingAction } from '@aws-amplify/core/internals/utils';
5
5
  import { resolveEndpointId } from '@aws-amplify/core/internals/providers/pinpoint';
6
6
  import { defaultStorage } from '@aws-amplify/core';
7
7
  import {
8
- resolveConfig,
9
- resolveCredentials,
10
- getInAppMessagingUserAgentString,
11
- STORAGE_KEY_SUFFIX,
12
- PINPOINT_KEY_PREFIX,
13
- CATEGORY,
14
- CHANNEL_TYPE,
15
- } from '../utils';
16
- import {
17
- getInAppMessages,
18
8
  GetInAppMessagesInput,
19
9
  GetInAppMessagesOutput,
10
+ getInAppMessages,
20
11
  } from '@aws-amplify/core/internals/aws-clients/pinpoint';
12
+
13
+ import {
14
+ CATEGORY,
15
+ CHANNEL_TYPE,
16
+ PINPOINT_KEY_PREFIX,
17
+ STORAGE_KEY_SUFFIX,
18
+ getInAppMessagingUserAgentString,
19
+ resolveConfig,
20
+ resolveCredentials,
21
+ } from '../utils';
21
22
  import {
22
23
  InAppMessagingValidationErrorCode,
23
24
  assertServiceError,
@@ -80,6 +81,7 @@ async function fetchInAppMessages() {
80
81
  );
81
82
  const { InAppMessageCampaigns: messages } =
82
83
  response.InAppMessagesResponse ?? {};
84
+
83
85
  return messages;
84
86
  } catch (error) {
85
87
  assertServiceError(error);