@aws-amplify/notifications 2.0.18-unstable.b758843.0 → 2.0.18
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.
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js +4 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js +4 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.d.ts +4 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.mjs +4 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.d.ts +4 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.mjs +4 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.mjs.map +1 -1
- package/package.json +103 -103
- package/src/inAppMessaging/providers/pinpoint/apis/dispatchEvent.ts +4 -1
- package/src/inAppMessaging/providers/pinpoint/apis/setConflictHandler.ts +4 -1
|
@@ -22,11 +22,14 @@ const utils_2 = require("../../../utils");
|
|
|
22
22
|
* To change this behavior, you can use the {@link setConflictHandler} API to provide
|
|
23
23
|
* your own logic for resolving message conflicts.
|
|
24
24
|
*
|
|
25
|
-
* @param
|
|
25
|
+
* @param input The input object that holds the event to be dispatched.
|
|
26
|
+
*
|
|
26
27
|
* @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
|
|
27
28
|
* configuration is incorrect, or if In App messaging hasn't been initialized.
|
|
28
29
|
* @throws service exceptions - Thrown when the underlying Pinpoint service returns an error.
|
|
30
|
+
*
|
|
29
31
|
* @returns A promise that will resolve when the operation is complete.
|
|
32
|
+
*
|
|
30
33
|
* @example
|
|
31
34
|
* ```ts
|
|
32
35
|
* // Sync message before disptaching an event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatchEvent.js","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/apis/dispatchEvent.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.dispatchEvent = void 0;\nconst tslib_1 = require(\"tslib\");\nconst utils_1 = require(\"../utils\");\nconst flatten_js_1 = tslib_1.__importDefault(require(\"lodash/flatten.js\"));\nconst core_1 = require(\"@aws-amplify/core\");\nconst eventListeners_1 = require(\"../../../../eventListeners\");\nconst errors_1 = require(\"../../../errors\");\nconst setConflictHandler_1 = require(\"./setConflictHandler\");\nconst utils_2 = require(\"../../../utils\");\n/**\n * Triggers an In-App message to be displayed. Use this after your campaigns have been synced to the device using\n * {@link syncMessages}. Based on the messages synced and the event passed to this API, it triggers the display\n * of the In-App message that meets the criteria.\n *\n * @remark\n * If an event would trigger multiple messages, the message closest to expiry will be chosen by default.\n * To change this behavior, you can use the {@link setConflictHandler} API to provide\n * your own logic for resolving message conflicts.\n *\n * @param
|
|
1
|
+
{"version":3,"file":"dispatchEvent.js","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/apis/dispatchEvent.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.dispatchEvent = void 0;\nconst tslib_1 = require(\"tslib\");\nconst utils_1 = require(\"../utils\");\nconst flatten_js_1 = tslib_1.__importDefault(require(\"lodash/flatten.js\"));\nconst core_1 = require(\"@aws-amplify/core\");\nconst eventListeners_1 = require(\"../../../../eventListeners\");\nconst errors_1 = require(\"../../../errors\");\nconst setConflictHandler_1 = require(\"./setConflictHandler\");\nconst utils_2 = require(\"../../../utils\");\n/**\n * Triggers an In-App message to be displayed. Use this after your campaigns have been synced to the device using\n * {@link syncMessages}. Based on the messages synced and the event passed to this API, it triggers the display\n * of the In-App message that meets the criteria.\n *\n * @remark\n * If an event would trigger multiple messages, the message closest to expiry will be chosen by default.\n * To change this behavior, you can use the {@link setConflictHandler} API to provide\n * your own logic for resolving message conflicts.\n *\n * @param input The input object that holds the event to be dispatched.\n *\n * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library\n * configuration is incorrect, or if In App messaging hasn't been initialized.\n * @throws service exceptions - Thrown when the underlying Pinpoint service returns an error.\n *\n * @returns A promise that will resolve when the operation is complete.\n *\n * @example\n * ```ts\n * // Sync message before disptaching an event\n * await syncMessages();\n *\n * // Dispatch an event\n * await dispatchEvent({ name: 'test_event' });\n * ```\n */\nasync function dispatchEvent(input) {\n (0, utils_2.assertIsInitialized)();\n try {\n const key = `${utils_1.PINPOINT_KEY_PREFIX}${utils_1.STORAGE_KEY_SUFFIX}`;\n const cachedMessages = await core_1.defaultStorage.getItem(key);\n const messages = await (0, utils_1.processInAppMessages)(cachedMessages ? JSON.parse(cachedMessages) : [], input);\n const flattenedMessages = (0, flatten_js_1.default)(messages);\n if (flattenedMessages.length > 0) {\n (0, eventListeners_1.notifyEventListeners)('messageReceived', (0, setConflictHandler_1.conflictHandler)(flattenedMessages));\n }\n }\n catch (error) {\n (0, errors_1.assertServiceError)(error);\n throw error;\n }\n}\nexports.dispatchEvent = dispatchEvent;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,Y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AAC,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAC;AACxI,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,IAAI,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAChD,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
|
|
@@ -13,9 +13,12 @@ exports.conflictHandler = defaultConflictHandler;
|
|
|
13
13
|
* @remark
|
|
14
14
|
* The conflict handler is not persisted across app restarts and so must be set again before dispatching an event for
|
|
15
15
|
* any custom handling to take effect.
|
|
16
|
+
*
|
|
16
17
|
* @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
|
|
17
18
|
* configuration is incorrect, or if In App messaging hasn't been initialized.
|
|
18
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* @param input The input object that holds the conflict handler to be used.
|
|
21
|
+
*
|
|
19
22
|
* @example
|
|
20
23
|
* ```ts
|
|
21
24
|
* // Sync messages before dispatching an event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setConflictHandler.js","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/apis/setConflictHandler.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.setConflictHandler = exports.conflictHandler = void 0;\nconst utils_1 = require(\"../../../utils\");\nexports.conflictHandler = defaultConflictHandler;\n/**\n * Set a conflict handler that will be used to resolve conflicts that may emerge\n * when matching events with synced messages.\n *\n * @remark\n * The conflict handler is not persisted across app restarts and so must be set again before dispatching an event for\n * any custom handling to take effect.\n * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library\n * configuration is incorrect, or if In App messaging hasn't been initialized.\n * @param
|
|
1
|
+
{"version":3,"file":"setConflictHandler.js","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/apis/setConflictHandler.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.setConflictHandler = exports.conflictHandler = void 0;\nconst utils_1 = require(\"../../../utils\");\nexports.conflictHandler = defaultConflictHandler;\n/**\n * Set a conflict handler that will be used to resolve conflicts that may emerge\n * when matching events with synced messages.\n *\n * @remark\n * The conflict handler is not persisted across app restarts and so must be set again before dispatching an event for\n * any custom handling to take effect.\n *\n * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library\n * configuration is incorrect, or if In App messaging hasn't been initialized.\n *\n * @param input The input object that holds the conflict handler to be used.\n *\n * @example\n * ```ts\n * // Sync messages before dispatching an event\n * await syncMessages();\n *\n * // Example custom conflict handler\n * const myConflictHandler = (messages) => {\n * \t\t// Return a random message\n * \t\tconst randomIndex = Math.floor(Math.random() * messages.length);\n * \t\treturn messages[randomIndex];\n * };\n *\n * // Set the conflict handler\n * setConflictHandler(myConflictHandler);\n *\n * // Dispatch an event\n * await dispatchEvent({ name: 'test_event' });\n * ```\n */\nfunction setConflictHandler(input) {\n (0, utils_1.assertIsInitialized)();\n exports.conflictHandler = input;\n}\nexports.setConflictHandler = setConflictHandler;\nfunction defaultConflictHandler(messages) {\n // default behavior is to return the message closest to expiry\n // this function assumes that messages processed by providers already filters out expired messages\n const sorted = messages.sort((a, b) => {\n const endDateA = a.metadata?.endDate;\n const endDateB = b.metadata?.endDate;\n // if both message end dates are falsy or have the same date string, treat them as equal\n if (endDateA === endDateB) {\n return 0;\n }\n // if only message A has an end date, treat it as closer to expiry\n if (endDateA && !endDateB) {\n return -1;\n }\n // if only message B has an end date, treat it as closer to expiry\n if (!endDateA && endDateB) {\n return 1;\n }\n // otherwise, compare them\n return new Date(endDateA) < new Date(endDateB) ? -1 : 1;\n });\n // always return the top sorted\n return s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S;AACT;AACA,QAAQ,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAChE,KAAK,CAAC,CAAC;AACP;AACA,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACrB;;"}
|
|
@@ -9,11 +9,14 @@ import { DispatchEventInput } from '../types';
|
|
|
9
9
|
* To change this behavior, you can use the {@link setConflictHandler} API to provide
|
|
10
10
|
* your own logic for resolving message conflicts.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
12
|
+
* @param input The input object that holds the event to be dispatched.
|
|
13
|
+
*
|
|
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
16
|
* @throws service exceptions - Thrown when the underlying Pinpoint service returns an error.
|
|
17
|
+
*
|
|
16
18
|
* @returns A promise that will resolve when the operation is complete.
|
|
19
|
+
*
|
|
17
20
|
* @example
|
|
18
21
|
* ```ts
|
|
19
22
|
* // Sync message before disptaching an event
|
|
@@ -21,11 +21,14 @@ import { assertIsInitialized } from '../../../utils/statusHelpers.mjs';
|
|
|
21
21
|
* To change this behavior, you can use the {@link setConflictHandler} API to provide
|
|
22
22
|
* your own logic for resolving message conflicts.
|
|
23
23
|
*
|
|
24
|
-
* @param
|
|
24
|
+
* @param input The input object that holds the event to be dispatched.
|
|
25
|
+
*
|
|
25
26
|
* @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
|
|
26
27
|
* configuration is incorrect, or if In App messaging hasn't been initialized.
|
|
27
28
|
* @throws service exceptions - Thrown when the underlying Pinpoint service returns an error.
|
|
29
|
+
*
|
|
28
30
|
* @returns A promise that will resolve when the operation is complete.
|
|
31
|
+
*
|
|
29
32
|
* @example
|
|
30
33
|
* ```ts
|
|
31
34
|
* // Sync message before disptaching an event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatchEvent.mjs","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/apis/dispatchEvent.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PINPOINT_KEY_PREFIX, STORAGE_KEY_SUFFIX, processInAppMessages, } from '../utils';\nimport flatten from 'lodash/flatten.js';\nimport { defaultStorage } from '@aws-amplify/core';\nimport { notifyEventListeners } from '../../../../eventListeners';\nimport { assertServiceError } from '../../../errors';\nimport { conflictHandler } from './setConflictHandler';\nimport { assertIsInitialized } from '../../../utils';\n/**\n * Triggers an In-App message to be displayed. Use this after your campaigns have been synced to the device using\n * {@link syncMessages}. Based on the messages synced and the event passed to this API, it triggers the display\n * of the In-App message that meets the criteria.\n *\n * @remark\n * If an event would trigger multiple messages, the message closest to expiry will be chosen by default.\n * To change this behavior, you can use the {@link setConflictHandler} API to provide\n * your own logic for resolving message conflicts.\n *\n * @param
|
|
1
|
+
{"version":3,"file":"dispatchEvent.mjs","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/apis/dispatchEvent.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PINPOINT_KEY_PREFIX, STORAGE_KEY_SUFFIX, processInAppMessages, } from '../utils';\nimport flatten from 'lodash/flatten.js';\nimport { defaultStorage } from '@aws-amplify/core';\nimport { notifyEventListeners } from '../../../../eventListeners';\nimport { assertServiceError } from '../../../errors';\nimport { conflictHandler } from './setConflictHandler';\nimport { assertIsInitialized } from '../../../utils';\n/**\n * Triggers an In-App message to be displayed. Use this after your campaigns have been synced to the device using\n * {@link syncMessages}. Based on the messages synced and the event passed to this API, it triggers the display\n * of the In-App message that meets the criteria.\n *\n * @remark\n * If an event would trigger multiple messages, the message closest to expiry will be chosen by default.\n * To change this behavior, you can use the {@link setConflictHandler} API to provide\n * your own logic for resolving message conflicts.\n *\n * @param input The input object that holds the event to be dispatched.\n *\n * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library\n * configuration is incorrect, or if In App messaging hasn't been initialized.\n * @throws service exceptions - Thrown when the underlying Pinpoint service returns an error.\n *\n * @returns A promise that will resolve when the operation is complete.\n *\n * @example\n * ```ts\n * // Sync message before disptaching an event\n * await syncMessages();\n *\n * // Dispatch an event\n * await dispatchEvent({ name: 'test_event' });\n * ```\n */\nexport async function dispatchEvent(input) {\n assertIsInitialized();\n try {\n const key = `${PINPOINT_KEY_PREFIX}${STORAGE_KEY_SUFFIX}`;\n const cachedMessages = await defaultStorage.getItem(key);\n const messages = await processInAppMessages(cachedMessages ? JSON.parse(cachedMessages) : [], input);\n const flattenedMessages = flatten(messages);\n if (flattenedMessages.length > 0) {\n notifyEventListeners('messageReceived', conflictHandler(flattenedMessages));\n }\n }\n catch (error) {\n assertServiceError(error);\n throw error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,aAAa,CAAC,KAAK,EAAE;AAC3C,IAAI,mBAAmB,EAAE,CAAC;AAC1B,IAAI,IAAI;AACR,QAAQ,MAAM,GAAG,GAAG,CAAC,EAAE,mBAAmB,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAClE,QAAQ,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACjE,QAAQ,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;AAC7G,QAAQ,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACpD,QAAQ,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;AAC1C,YAAY,oBAAoB,CAAC,iBAAiB,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACxF,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAClC,QAAQ,MAAM,KAAK,CAAC;AACpB,KAAK;AACL;;;;"}
|
|
@@ -7,9 +7,12 @@ export declare let conflictHandler: InAppMessageConflictHandler;
|
|
|
7
7
|
* @remark
|
|
8
8
|
* The conflict handler is not persisted across app restarts and so must be set again before dispatching an event for
|
|
9
9
|
* any custom handling to take effect.
|
|
10
|
+
*
|
|
10
11
|
* @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
|
|
11
12
|
* configuration is incorrect, or if In App messaging hasn't been initialized.
|
|
12
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* @param input The input object that holds the conflict handler to be used.
|
|
15
|
+
*
|
|
13
16
|
* @example
|
|
14
17
|
* ```ts
|
|
15
18
|
* // Sync messages before dispatching an event
|
|
@@ -10,9 +10,12 @@ let conflictHandler = defaultConflictHandler;
|
|
|
10
10
|
* @remark
|
|
11
11
|
* The conflict handler is not persisted across app restarts and so must be set again before dispatching an event for
|
|
12
12
|
* any custom handling to take effect.
|
|
13
|
+
*
|
|
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
|
-
*
|
|
16
|
+
*
|
|
17
|
+
* @param input The input object that holds the conflict handler to be used.
|
|
18
|
+
*
|
|
16
19
|
* @example
|
|
17
20
|
* ```ts
|
|
18
21
|
* // Sync messages before dispatching an event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setConflictHandler.mjs","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/apis/setConflictHandler.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertIsInitialized } from '../../../utils';\nexport let conflictHandler = defaultConflictHandler;\n/**\n * Set a conflict handler that will be used to resolve conflicts that may emerge\n * when matching events with synced messages.\n *\n * @remark\n * The conflict handler is not persisted across app restarts and so must be set again before dispatching an event for\n * any custom handling to take effect.\n * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library\n * configuration is incorrect, or if In App messaging hasn't been initialized.\n * @param
|
|
1
|
+
{"version":3,"file":"setConflictHandler.mjs","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/apis/setConflictHandler.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertIsInitialized } from '../../../utils';\nexport let conflictHandler = defaultConflictHandler;\n/**\n * Set a conflict handler that will be used to resolve conflicts that may emerge\n * when matching events with synced messages.\n *\n * @remark\n * The conflict handler is not persisted across app restarts and so must be set again before dispatching an event for\n * any custom handling to take effect.\n *\n * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library\n * configuration is incorrect, or if In App messaging hasn't been initialized.\n *\n * @param input The input object that holds the conflict handler to be used.\n *\n * @example\n * ```ts\n * // Sync messages before dispatching an event\n * await syncMessages();\n *\n * // Example custom conflict handler\n * const myConflictHandler = (messages) => {\n * \t\t// Return a random message\n * \t\tconst randomIndex = Math.floor(Math.random() * messages.length);\n * \t\treturn messages[randomIndex];\n * };\n *\n * // Set the conflict handler\n * setConflictHandler(myConflictHandler);\n *\n * // Dispatch an event\n * await dispatchEvent({ name: 'test_event' });\n * ```\n */\nexport function setConflictHandler(input) {\n assertIsInitialized();\n conflictHandler = input;\n}\nfunction defaultConflictHandler(messages) {\n // default behavior is to return the message closest to expiry\n // this function assumes that messages processed by providers already filters out expired messages\n const sorted = messages.sort((a, b) => {\n const endDateA = a.metadata?.endDate;\n const endDateB = b.metadata?.endDate;\n // if both message end dates are falsy or have the same date string, treat them as equal\n if (endDateA === endDateB) {\n return 0;\n }\n // if only message A has an end date, treat it as closer to expiry\n if (endDateA && !endDateB) {\n return -1;\n }\n // if only message B has an end date, treat it as closer to expiry\n if (!endDateA && endDateB) {\n return 1;\n }\n // otherwise, compare them\n return new Date(endDateA) < new Date(endDateB) ? -1 : 1;\n });\n // always return the top sorted\n return sorted[0];\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEU,IAAC,eAAe,GAAG,uBAAuB;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,KAAK,EAAE;AAC1C,IAAI,mBAAmB,EAAE,CAAC;AAC1B,IAAI,eAAe,GAAG,KAAK,CAAC;AAC5B,CAAC;AACD,SAAS,sBAAsB,CAAC,QAAQ,EAAE;AAC1C;AACA;AACA,IAAI,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK;AAC3C,QAAQ,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC;AAC7C,QAAQ,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC;AAC7C;AACA,QAAQ,IAAI,QAAQ,KAAK,QAAQ,EAAE;AACnC,YAAY,OAAO,CAAC,CAAC;AACrB,SAAS;AACT;AACA,QAAQ,IAAI,QAAQ,IAAI,CAAC,QAAQ,EAAE;AACnC,YAAY,OAAO,CAAC,CAAC,CAAC;AACtB,SAAS;AACT;AACA,QAAQ,IAAI,CAAC,QAAQ,IAAI,QAAQ,EAAE;AACnC,YAAY,OAAO,CAAC,CAAC;AACrB,SAAS;AACT;AACA,QAAQ,OAAO,IAAI,IAAI,CAAC,QAAQ,CAA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
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
2
|
+
"name": "@aws-amplify/notifications",
|
|
3
|
+
"version": "2.0.18",
|
|
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.18",
|
|
101
|
+
"@aws-amplify/react-native": "1.0.18",
|
|
102
|
+
"typescript": "5.0.2"
|
|
103
|
+
},
|
|
104
|
+
"gitHead": "27ee4e14d5ba091a827ca49e9e04f15e26bb1445"
|
|
105
105
|
}
|
|
@@ -26,11 +26,14 @@ import { assertIsInitialized } from '../../../utils';
|
|
|
26
26
|
* To change this behavior, you can use the {@link setConflictHandler} API to provide
|
|
27
27
|
* your own logic for resolving message conflicts.
|
|
28
28
|
*
|
|
29
|
-
* @param
|
|
29
|
+
* @param input The input object that holds the event to be dispatched.
|
|
30
|
+
*
|
|
30
31
|
* @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
|
|
31
32
|
* configuration is incorrect, or if In App messaging hasn't been initialized.
|
|
32
33
|
* @throws service exceptions - Thrown when the underlying Pinpoint service returns an error.
|
|
34
|
+
*
|
|
33
35
|
* @returns A promise that will resolve when the operation is complete.
|
|
36
|
+
*
|
|
34
37
|
* @example
|
|
35
38
|
* ```ts
|
|
36
39
|
* // Sync message before disptaching an event
|
|
@@ -15,9 +15,12 @@ export let conflictHandler: InAppMessageConflictHandler =
|
|
|
15
15
|
* @remark
|
|
16
16
|
* The conflict handler is not persisted across app restarts and so must be set again before dispatching an event for
|
|
17
17
|
* any custom handling to take effect.
|
|
18
|
+
*
|
|
18
19
|
* @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
|
|
19
20
|
* configuration is incorrect, or if In App messaging hasn't been initialized.
|
|
20
|
-
*
|
|
21
|
+
*
|
|
22
|
+
* @param input The input object that holds the conflict handler to be used.
|
|
23
|
+
*
|
|
21
24
|
* @example
|
|
22
25
|
* ```ts
|
|
23
26
|
* // Sync messages before dispatching an event
|