@aws-amplify/notifications 2.0.1-mjs-test.20ead30.0 → 2.0.1-mjs-test.6f5dab7.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.
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.dispatchEvent = void 0;
7
7
  const tslib_1 = require("tslib");
8
8
  const utils_1 = require("../utils");
9
- const flatten_1 = tslib_1.__importDefault(require("lodash/flatten"));
9
+ const flatten_js_1 = tslib_1.__importDefault(require("lodash/flatten.js"));
10
10
  const core_1 = require("@aws-amplify/core");
11
11
  const eventListeners_1 = require("../../../../eventListeners");
12
12
  const errors_1 = require("../../../errors");
@@ -42,7 +42,7 @@ async function dispatchEvent(input) {
42
42
  const key = `${utils_1.PINPOINT_KEY_PREFIX}${utils_1.STORAGE_KEY_SUFFIX}`;
43
43
  const cachedMessages = await core_1.defaultStorage.getItem(key);
44
44
  const messages = await (0, utils_1.processInAppMessages)(cachedMessages ? JSON.parse(cachedMessages) : [], input);
45
- const flattenedMessages = (0, flatten_1.default)(messages);
45
+ const flattenedMessages = (0, flatten_js_1.default)(messages);
46
46
  if (flattenedMessages.length > 0) {
47
47
  (0, eventListeners_1.notifyEventListeners)('messageReceived', (0, setConflictHandler_1.conflictHandler)(flattenedMessages));
48
48
  }
@@ -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_1 = tslib_1.__importDefault(require(\"lodash/flatten\"));\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 DispatchEventInput The input object that holds the event to be dispatched.\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 * @returns A promise that will resolve when the operation is complete.\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_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,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AAiB,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC,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;;"}
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 DispatchEventInput The input object that holds the event to be dispatched.\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 * @returns A promise that will resolve when the operation is complete.\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,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAC3E,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC/D,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC5C,MAAM,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,aAAa,CAAC,KAAK,EAAE;AACpC,IAAI,IAAI,OAAO,CAAC,mBAAmB,GAAG,CAAC;AACvC,IAAI,IAAI;AACR,QAAQ,MAAM,GAAG,GAAG,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAClF,QAAQ,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACxE,QAAQ,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,oBAAoB,EAAE,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;AAC1H,QAAQ,MAAM,iBAAiB,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACtE,QAAQ,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;AAC1C,YAAY,CAAC,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,EAAE,iBAAiB,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC,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;;"}
@@ -7,7 +7,7 @@ exports.extractMetadata = exports.extractContent = exports.interpretLayout = exp
7
7
  const tslib_1 = require("tslib");
8
8
  const core_1 = require("@aws-amplify/core");
9
9
  const utils_1 = require("@aws-amplify/core/internals/utils");
10
- const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
10
+ const isEmpty_js_1 = tslib_1.__importDefault(require("lodash/isEmpty.js"));
11
11
  const pinpoint_1 = require("@aws-amplify/core/internals/providers/pinpoint");
12
12
  const resolveConfig_1 = require("./resolveConfig");
13
13
  const resolveCredentials_1 = require("./resolveCredentials");
@@ -64,11 +64,11 @@ const matchesEventType = ({ CampaignId, Schedule }, { name: eventType }) => {
64
64
  exports.matchesEventType = matchesEventType;
65
65
  const matchesAttributes = ({ CampaignId, Schedule }, { attributes = {} }) => {
66
66
  const { Attributes } = Schedule?.EventFilter?.Dimensions ?? {};
67
- if ((0, isEmpty_1.default)(Attributes)) {
67
+ if ((0, isEmpty_js_1.default)(Attributes)) {
68
68
  // if message does not have attributes defined it does not matter what attributes are on the event
69
69
  return true;
70
70
  }
71
- if ((0, isEmpty_1.default)(attributes)) {
71
+ if ((0, isEmpty_js_1.default)(attributes)) {
72
72
  // if message does have attributes but the event does not then it always fails the check
73
73
  return false;
74
74
  }
@@ -83,11 +83,11 @@ const matchesAttributes = ({ CampaignId, Schedule }, { attributes = {} }) => {
83
83
  exports.matchesAttributes = matchesAttributes;
84
84
  const matchesMetrics = ({ CampaignId, Schedule }, { metrics = {} }) => {
85
85
  const { Metrics } = Schedule?.EventFilter?.Dimensions ?? {};
86
- if ((0, isEmpty_1.default)(Metrics)) {
86
+ if ((0, isEmpty_js_1.default)(Metrics)) {
87
87
  // if message does not have metrics defined it does not matter what metrics are on the event
88
88
  return true;
89
89
  }
90
- if ((0, isEmpty_1.default)(metrics)) {
90
+ if ((0, isEmpty_js_1.default)(metrics)) {
91
91
  // if message does have metrics but the event does not then it always fails the check
92
92
  return false;
93
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/utils/helpers.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.extractMetadata = exports.extractContent = exports.interpretLayout = exports.clearMemo = exports.isQuietTime = exports.isBeforeEndDate = exports.getComparator = exports.matchesMetrics = exports.matchesAttributes = exports.matchesEventType = exports.getStartOfDay = exports.recordAnalyticsEvent = exports.logger = void 0;\nconst tslib_1 = require(\"tslib\");\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst isEmpty_1 = tslib_1.__importDefault(require(\"lodash/isEmpty\"));\nconst pinpoint_1 = require(\"@aws-amplify/core/internals/providers/pinpoint\");\nconst resolveConfig_1 = require(\"./resolveConfig\");\nconst resolveCredentials_1 = require(\"./resolveCredentials\");\nconst constants_1 = require(\"./constants\");\nconst userAgent_1 = require(\"./userAgent\");\nconst DELIVERY_TYPE = 'IN_APP_MESSAGE';\nlet eventNameMemo = {};\nlet eventAttributesMemo = {};\nlet eventMetricsMemo = {};\nexports.logger = new core_1.ConsoleLogger('InAppMessaging.Pinpoint.Utils');\nconst recordAnalyticsEvent = (event, message) => {\n const { appId, region } = (0, resolveConfig_1.resolveConfig)();\n const { id, metadata } = message;\n (0, resolveCredentials_1.resolveCredentials)()\n .then(({ credentials, identityId }) => {\n (0, pinpoint_1.record)({\n appId,\n category: constants_1.CATEGORY,\n credentials,\n event: {\n name: event,\n attributes: {\n // only include campaign_id field if we have one\n ...(id && { campaign_id: id }),\n delivery_type: DELIVERY_TYPE,\n treatment_id: metadata?.treatmentId,\n },\n },\n identityId,\n region,\n userAgentValue: (0, userAgent_1.getInAppMessagingUserAgentString)(utils_1.InAppMessagingAction.NotifyMessageInteraction),\n });\n })\n .catch(e => {\n // An error occured while fetching credentials or persisting the event to the buffer\n exports.logger.warn('Failed to record event.', e);\n });\n};\nexports.recordAnalyticsEvent = recordAnalyticsEvent;\nconst getStartOfDay = () => {\n const now = new Date();\n now.setHours(0, 0, 0, 0);\n return now.toISOString();\n};\nexports.getStartOfDay = getStartOfDay;\nconst matchesEventType = ({ CampaignId, Schedule }, { name: eventType }) => {\n const { EventType } = Schedule?.EventFilter?.Dimensions ?? {};\n const memoKey = `${CampaignId}:${eventType}`;\n if (!eventNameMemo.hasOwnProperty(memoKey)) {\n eventNameMemo[memoKey] = !!EventType?.Values?.includes(eventType);\n }\n return eventNameMemo[memoKey];\n};\nexports.matchesEventType = matchesEventType;\nconst matchesAttributes = ({ CampaignId, Schedule }, { attributes = {} }) => {\n const { Attributes } = Schedule?.EventFilter?.Dimensions ?? {};\n if ((0, isEmpty_1.default)(Attributes)) {\n // if message does not have attributes defined it does not matter what attributes are on the event\n return true;\n }\n if ((0, isEmpty_1.default)(attributes)) {\n // if message does have attributes but the event does not then it always fails the check\n return false;\n }\n const memoKey = `${CampaignId}:${JSON.stringify(attributes)}`;\n if (!eventAttributesMemo.hasOwnProperty(memoKey)) {\n eventAttributesMemo[memoKey] =\n !Attributes ||\n Object.entries(Attributes).every(([key, { Values }]) => Values?.includes(attributes[key]));\n }\n return eventAttributesMemo[memoKey];\n};\nexports.matchesAttributes = matchesAttributes;\nconst matchesMetrics = ({ CampaignId, Schedule }, { metrics = {} }) => {\n const { Metrics } = Schedule?.EventFilter?.Dimensions ?? {};\n if ((0, isEmpty_1.default)(Metrics)) {\n // if message does not have metrics defined it does not matter what metrics are on the event\n return true;\n }\n if ((0, isEmpty_1.default)(metrics)) {\n // if message does have metrics but the event does not then it always fails the check\n return false;\n }\n const memoKey = `${CampaignId}:${JSON.stringify(metrics)}`;\n if (!eventMetricsMemo.hasOwnProperty(memoKey)) {\n eventMetricsMemo[memoKey] =\n !Metrics ||\n Object.entries(Metrics).every(([key, { ComparisonOperator, Value }]) => {\n const compare = (0, exports.getComparator)(ComparisonOperator);\n // if there is some unknown comparison operator, treat as a comparison failure\n return compare && !!Value ? compare(Value, metrics[key]) : false;\n });\n }\n return eventMetricsMemo[memoKey];\n};\nexports.matchesMetrics = matchesMetrics;\nconst getComparator = (operator) => {\n switch (operator) {\n case 'EQUAL':\n return (metricsVal, eventVal) => metricsVal === eventVal;\n case 'GREATER_THAN':\n return (metricsVal, eventVal) => metricsVal < eventVal;\n case 'GREATER_THAN_OR_EQUAL':\n return (metricsVal, eventVal) => metricsVal <= eventVal;\n case 'LESS_THAN':\n return (metricsVal, eventVal) => metricsVal > eventVal;\n case 'LESS_THAN_OR_EQUAL':\n return (metricsVal, eventVal) => metricsVal >= eventVal;\n default:\n return undefined;\n }\n};\nexports.getComparator = getComparator;\nconst isBeforeEndDate = ({ Schedule, }) => {\n if (!Schedule?.EndDate) {\n return true;\n }\n return new Date() < new Date(Schedule.EndDate);\n};\nexports.isBeforeEndDate = isBeforeEndDate;\nconst isQuietTime = (message) => {\n const { Schedule } = message;\n if (!Schedule?.QuietTime) {\n return false;\n }\n const pattern = /^[0-2]\\d:[0-5]\\d$/; // basic sanity check, not a fully featured HH:MM validation\n const { Start, End } = Schedule.QuietTime;\n if (!Start ||\n !End ||\n Start === End ||\n !pattern.test(Start) ||\n !pattern.test(End)) {\n return false;\n }\n const now = new Date();\n const start = new Date(now);\n const end = new Date(now);\n const [startHours, startMinutes] = Start.split(':');\n const [endHours, endMinutes] = End.split(':');\n start.setHours(Number.parseInt(startHours, 10), Number.parseInt(startMinutes, 10), 0, 0);\n end.setHours(Number.parseInt(endHours, 10), Number.parseInt(endMinutes, 10), 0, 0);\n // if quiet time includes midnight, bump the end time to the next day\n if (start > end) {\n end.setDate(end.getDate() + 1);\n }\n const isQuietTime = now >= start && now <= end;\n if (isQuietTime) {\n exports.logger.debug('message filtered due to quiet time', message);\n }\n return isQuietTime;\n};\nexports.isQuietTime = isQuietTime;\nconst clearMemo = () => {\n eventNameMemo = {};\n eventAttributesMemo = {};\n eventMetricsMemo = {};\n};\nexports.clearMemo = clearMemo;\n// in the pinpoint console when a message is created with a Modal or Full Screen layout,\n// it is assigned a layout value of MOBILE_FEED or OVERLAYS respectively in the message payload.\n// In the future, Pinpoint will be updating the layout values in the aforementioned scenario\n// to MODAL and FULL_SCREEN.\n//\n// This utility acts as a safeguard to ensure that:\n// - 1. the usage of MOBILE_FEED and OVERLAYS as values for message layouts are not leaked\n// outside the Pinpoint provider\n// - 2. Amplify correctly handles the legacy layout values from Pinpoint after they are updated\nconst interpretLayout = (layout) => {\n if (layout === 'MOBILE_FEED') {\n return 'MODAL';\n }\n if (layout === 'OVERLAYS') {\n return 'FULL_SCREEN';\n }\n // cast as PinpointInAppMessage['InAppMessage']['Layout'] allows `string` as a value\n return layout;\n};\nexports.interpretLayout = interpretLayout;\nconst extractContent = ({ InAppMessage: message, }) => {\n return (message?.Content?.map(content => {\n const { BackgroundColor, BodyConfig, HeaderConfig, ImageUrl, PrimaryBtn, SecondaryBtn, } = content;\n const defaultPrimaryButton = PrimaryBtn?.DefaultConfig;\n const defaultSecondaryButton = SecondaryBtn?.DefaultConfig;\n const extractedContent = {};\n if (BackgroundColor) {\n extractedContent.container = {\n style: {\n backgroundColor: BackgroundColor,\n },\n };\n }\n if (HeaderConfig) {\n extractedContent.header = {\n // Default to empty string in rare cases we don't have a Header value\n content: HeaderConfig.Header ?? '',\n style: {\n color: HeaderConfig.TextColor,\n textAlign: HeaderConfig.Alignment?.toLowerCase(),\n },\n };\n }\n if (BodyConfig) {\n extractedContent.body = {\n // Default to empty string in rare cases we don't have a Body value\n content: BodyConfig.Body ?? '',\n style: {\n color: BodyConfig.TextColor,\n textAlign: BodyConfig.Alignment?.toLowerCase(),\n },\n };\n }\n if (ImageUrl) {\n extractedContent.image = {\n src: ImageUrl,\n };\n }\n if (defaultPrimaryButton) {\n extractedContent.primaryButton = {\n // Default to empty string in rare cases we don't have a Text value\n title: defaultPrimaryButton.Text ?? '',\n action: defaultPrimaryButton.ButtonAction,\n url: defaultPrimaryButton.Link,\n style: {\n backgroundColor: defaultPrimaryButton.BackgroundColor,\n borderRadius: defaultPrimaryButton.BorderRadius,\n color: defaultPrimaryButton.TextColor,\n },\n };\n }\n if (defaultSecondaryButton) {\n extractedContent.secondaryButton = {\n // Default to empty string in rare cases we don't have a Text value\n title: defaultSecondaryButton.Text ?? '',\n action: defaultSecondaryButton.ButtonAction,\n url: defaultSecondaryButton.Link,\n style: {\n backgroundColor: defaultSecondaryButton.BackgroundColor,\n borderRadius: defaultSecondaryButton.BorderRadius,\n color: defaultSecondaryButton.TextColor,\n },\n };\n }\n return extractedContent;\n }) ?? []);\n};\nexports.extractContent = extractContent;\nconst extractMetadata = ({ InAppMessage, Priority, Schedule, TreatmentId, }) => ({\n customData: InAppMessage?.CustomConfig,\n endDate: Schedule?.EndDate,\n priority: Priority,\n treatmentId: TreatmentId,\n});\nexports.extractMetadata = extractMetadata;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;AACxU,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACrE,MAAM,UAAU,GAAG,OAAO,CAAC,gDAAgD,CAAC,CAAC;AAC7E,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACnD,MAAM,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,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E,sBAAsB,CAAC,YAAY;AACrE,oBAAoB,KAAK,EAAE,sBAAsB,CAAC,SAAS;AAC3D,iBAAiB;AACjB,aAAa,CAAC;AACd,SAAS;AACT,QAAQ,OAAO,gBAAgB,CAAC;AAChC,KAAK,CAAC,IAAI,EAAE,EAAE;AACd,CAAC,CAAC;AACF,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC;AACxC,MAAM,eAAe,GAAG,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;AACjF,IAAI,UAAU,EAAE,YAAY,EAAE,YAAY;AAC1C,IAAI,OAAO,EAAE,QAAQ,EAAE,OAAO;AAC9B,IAAI,QAAQ,EAAE,QAAQ;AACtB,IAAI,WAAW,EAAE,WAAW;AAC5B,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,eAAe,GAAG,eAAe;;"}
1
+ {"version":3,"file":"helpers.js","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/utils/helpers.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.extractMetadata = exports.extractContent = exports.interpretLayout = exports.clearMemo = exports.isQuietTime = exports.isBeforeEndDate = exports.getComparator = exports.matchesMetrics = exports.matchesAttributes = exports.matchesEventType = exports.getStartOfDay = exports.recordAnalyticsEvent = exports.logger = void 0;\nconst tslib_1 = require(\"tslib\");\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst isEmpty_js_1 = tslib_1.__importDefault(require(\"lodash/isEmpty.js\"));\nconst pinpoint_1 = require(\"@aws-amplify/core/internals/providers/pinpoint\");\nconst resolveConfig_1 = require(\"./resolveConfig\");\nconst resolveCredentials_1 = require(\"./resolveCredentials\");\nconst constants_1 = require(\"./constants\");\nconst userAgent_1 = require(\"./userAgent\");\nconst DELIVERY_TYPE = 'IN_APP_MESSAGE';\nlet eventNameMemo = {};\nlet eventAttributesMemo = {};\nlet eventMetricsMemo = {};\nexports.logger = new core_1.ConsoleLogger('InAppMessaging.Pinpoint.Utils');\nconst recordAnalyticsEvent = (event, message) => {\n const { appId, region } = (0, resolveConfig_1.resolveConfig)();\n const { id, metadata } = message;\n (0, resolveCredentials_1.resolveCredentials)()\n .then(({ credentials, identityId }) => {\n (0, pinpoint_1.record)({\n appId,\n category: constants_1.CATEGORY,\n credentials,\n event: {\n name: event,\n attributes: {\n // only include campaign_id field if we have one\n ...(id && { campaign_id: id }),\n delivery_type: DELIVERY_TYPE,\n treatment_id: metadata?.treatmentId,\n },\n },\n identityId,\n region,\n userAgentValue: (0, userAgent_1.getInAppMessagingUserAgentString)(utils_1.InAppMessagingAction.NotifyMessageInteraction),\n });\n })\n .catch(e => {\n // An error occured while fetching credentials or persisting the event to the buffer\n exports.logger.warn('Failed to record event.', e);\n });\n};\nexports.recordAnalyticsEvent = recordAnalyticsEvent;\nconst getStartOfDay = () => {\n const now = new Date();\n now.setHours(0, 0, 0, 0);\n return now.toISOString();\n};\nexports.getStartOfDay = getStartOfDay;\nconst matchesEventType = ({ CampaignId, Schedule }, { name: eventType }) => {\n const { EventType } = Schedule?.EventFilter?.Dimensions ?? {};\n const memoKey = `${CampaignId}:${eventType}`;\n if (!eventNameMemo.hasOwnProperty(memoKey)) {\n eventNameMemo[memoKey] = !!EventType?.Values?.includes(eventType);\n }\n return eventNameMemo[memoKey];\n};\nexports.matchesEventType = matchesEventType;\nconst matchesAttributes = ({ CampaignId, Schedule }, { attributes = {} }) => {\n const { Attributes } = Schedule?.EventFilter?.Dimensions ?? {};\n if ((0, isEmpty_js_1.default)(Attributes)) {\n // if message does not have attributes defined it does not matter what attributes are on the event\n return true;\n }\n if ((0, isEmpty_js_1.default)(attributes)) {\n // if message does have attributes but the event does not then it always fails the check\n return false;\n }\n const memoKey = `${CampaignId}:${JSON.stringify(attributes)}`;\n if (!eventAttributesMemo.hasOwnProperty(memoKey)) {\n eventAttributesMemo[memoKey] =\n !Attributes ||\n Object.entries(Attributes).every(([key, { Values }]) => Values?.includes(attributes[key]));\n }\n return eventAttributesMemo[memoKey];\n};\nexports.matchesAttributes = matchesAttributes;\nconst matchesMetrics = ({ CampaignId, Schedule }, { metrics = {} }) => {\n const { Metrics } = Schedule?.EventFilter?.Dimensions ?? {};\n if ((0, isEmpty_js_1.default)(Metrics)) {\n // if message does not have metrics defined it does not matter what metrics are on the event\n return true;\n }\n if ((0, isEmpty_js_1.default)(metrics)) {\n // if message does have metrics but the event does not then it always fails the check\n return false;\n }\n const memoKey = `${CampaignId}:${JSON.stringify(metrics)}`;\n if (!eventMetricsMemo.hasOwnProperty(memoKey)) {\n eventMetricsMemo[memoKey] =\n !Metrics ||\n Object.entries(Metrics).every(([key, { ComparisonOperator, Value }]) => {\n const compare = (0, exports.getComparator)(ComparisonOperator);\n // if there is some unknown comparison operator, treat as a comparison failure\n return compare && !!Value ? compare(Value, metrics[key]) : false;\n });\n }\n return eventMetricsMemo[memoKey];\n};\nexports.matchesMetrics = matchesMetrics;\nconst getComparator = (operator) => {\n switch (operator) {\n case 'EQUAL':\n return (metricsVal, eventVal) => metricsVal === eventVal;\n case 'GREATER_THAN':\n return (metricsVal, eventVal) => metricsVal < eventVal;\n case 'GREATER_THAN_OR_EQUAL':\n return (metricsVal, eventVal) => metricsVal <= eventVal;\n case 'LESS_THAN':\n return (metricsVal, eventVal) => metricsVal > eventVal;\n case 'LESS_THAN_OR_EQUAL':\n return (metricsVal, eventVal) => metricsVal >= eventVal;\n default:\n return undefined;\n }\n};\nexports.getComparator = getComparator;\nconst isBeforeEndDate = ({ Schedule, }) => {\n if (!Schedule?.EndDate) {\n return true;\n }\n return new Date() < new Date(Schedule.EndDate);\n};\nexports.isBeforeEndDate = isBeforeEndDate;\nconst isQuietTime = (message) => {\n const { Schedule } = message;\n if (!Schedule?.QuietTime) {\n return false;\n }\n const pattern = /^[0-2]\\d:[0-5]\\d$/; // basic sanity check, not a fully featured HH:MM validation\n const { Start, End } = Schedule.QuietTime;\n if (!Start ||\n !End ||\n Start === End ||\n !pattern.test(Start) ||\n !pattern.test(End)) {\n return false;\n }\n const now = new Date();\n const start = new Date(now);\n const end = new Date(now);\n const [startHours, startMinutes] = Start.split(':');\n const [endHours, endMinutes] = End.split(':');\n start.setHours(Number.parseInt(startHours, 10), Number.parseInt(startMinutes, 10), 0, 0);\n end.setHours(Number.parseInt(endHours, 10), Number.parseInt(endMinutes, 10), 0, 0);\n // if quiet time includes midnight, bump the end time to the next day\n if (start > end) {\n end.setDate(end.getDate() + 1);\n }\n const isQuietTime = now >= start && now <= end;\n if (isQuietTime) {\n exports.logger.debug('message filtered due to quiet time', message);\n }\n return isQuietTime;\n};\nexports.isQuietTime = isQuietTime;\nconst clearMemo = () => {\n eventNameMemo = {};\n eventAttributesMemo = {};\n eventMetricsMemo = {};\n};\nexports.clearMemo = clearMemo;\n// in the pinpoint console when a message is created with a Modal or Full Screen layout,\n// it is assigned a layout value of MOBILE_FEED or OVERLAYS respectively in the message payload.\n// In the future, Pinpoint will be updating the layout values in the aforementioned scenario\n// to MODAL and FULL_SCREEN.\n//\n// This utility acts as a safeguard to ensure that:\n// - 1. the usage of MOBILE_FEED and OVERLAYS as values for message layouts are not leaked\n// outside the Pinpoint provider\n// - 2. Amplify correctly handles the legacy layout values from Pinpoint after they are updated\nconst interpretLayout = (layout) => {\n if (layout === 'MOBILE_FEED') {\n return 'MODAL';\n }\n if (layout === 'OVERLAYS') {\n return 'FULL_SCREEN';\n }\n // cast as PinpointInAppMessage['InAppMessage']['Layout'] allows `string` as a value\n return layout;\n};\nexports.interpretLayout = interpretLayout;\nconst extractContent = ({ InAppMessage: message, }) => {\n return (message?.Content?.map(content => {\n const { BackgroundColor, BodyConfig, HeaderConfig, ImageUrl, PrimaryBtn, SecondaryBtn, } = content;\n const defaultPrimaryButton = PrimaryBtn?.DefaultConfig;\n const defaultSecondaryButton = SecondaryBtn?.DefaultConfig;\n const extractedContent = {};\n if (BackgroundColor) {\n extractedContent.container = {\n style: {\n backgroundColor: BackgroundColor,\n },\n };\n }\n if (HeaderConfig) {\n extractedContent.header = {\n // Default to empty string in rare cases we don't have a Header value\n content: HeaderConfig.Header ?? '',\n style: {\n color: HeaderConfig.TextColor,\n textAlign: HeaderConfig.Alignment?.toLowerCase(),\n },\n };\n }\n if (BodyConfig) {\n extractedContent.body = {\n // Default to empty string in rare cases we don't have a Body value\n content: BodyConfig.Body ?? '',\n style: {\n color: BodyConfig.TextColor,\n textAlign: BodyConfig.Alignment?.toLowerCase(),\n },\n };\n }\n if (ImageUrl) {\n extractedContent.image = {\n src: ImageUrl,\n };\n }\n if (defaultPrimaryButton) {\n extractedContent.primaryButton = {\n // Default to empty string in rare cases we don't have a Text value\n title: defaultPrimaryButton.Text ?? '',\n action: defaultPrimaryButton.ButtonAction,\n url: defaultPrimaryButton.Link,\n style: {\n backgroundColor: defaultPrimaryButton.BackgroundColor,\n borderRadius: defaultPrimaryButton.BorderRadius,\n color: defaultPrimaryButton.TextColor,\n },\n };\n }\n if (defaultSecondaryButton) {\n extractedContent.secondaryButton = {\n // Default to empty string in rare cases we don't have a Text value\n title: defaultSecondaryButton.Text ?? '',\n action: defaultSecondaryButton.ButtonAction,\n url: defaultSecondaryButton.Link,\n style: {\n backgroundColor: defaultSecondaryButton.BackgroundColor,\n borderRadius: defaultSecondaryButton.BorderRadius,\n color: defaultSecondaryButton.TextColor,\n },\n };\n }\n return extractedContent;\n }) ?? []);\n};\nexports.extractContent = extractContent;\nconst extractMetadata = ({ InAppMessage, Priority, Schedule, TreatmentId, }) => ({\n customData: InAppMessage?.CustomConfig,\n endDate: Schedule?.EndDate,\n priority: Priority,\n treatmentId: TreatmentId,\n});\nexports.extractMetadata = extractMetadata;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE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AQ,EAAE,OAAO;AAC9B,IAAI,QAAQ,EAAE,QAAQ;AACtB,IAAI,WAAW,EAAE,WAAW;AAC5B,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,eAAe,GAAG,eAAe;;"}
@@ -4,7 +4,7 @@ import '../../../errors/validation.mjs';
4
4
  import { assertServiceError } from '../../../errors/assertServiceError.mjs';
5
5
  import { PINPOINT_KEY_PREFIX, STORAGE_KEY_SUFFIX } from '../utils/constants.mjs';
6
6
  import { processInAppMessages } from '../utils/messageProcessingHelpers.mjs';
7
- import flatten from 'lodash/flatten';
7
+ import flatten from 'lodash/flatten.js';
8
8
  import { notifyEventListeners } from '../../../../eventListeners/eventListeners.mjs';
9
9
  import { conflictHandler } from './setConflictHandler.mjs';
10
10
  import { assertIsInitialized } from '../../../utils/statusHelpers.mjs';
@@ -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';\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 DispatchEventInput The input object that holds the event to be dispatched.\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 * @returns A promise that will resolve when the operation is complete.\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;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;;;;"}
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 DispatchEventInput The input object that holds the event to be dispatched.\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 * @returns A promise that will resolve when the operation is complete.\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;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;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { ConsoleLogger } from '@aws-amplify/core';
2
2
  import { InAppMessagingAction } from '@aws-amplify/core/internals/utils';
3
- import isEmpty from 'lodash/isEmpty';
3
+ import isEmpty from 'lodash/isEmpty.js';
4
4
  import { record } from '@aws-amplify/core/internals/providers/pinpoint';
5
5
  import { resolveConfig } from './resolveConfig.mjs';
6
6
  import { resolveCredentials } from './resolveCredentials.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/utils/helpers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { InAppMessagingAction } from '@aws-amplify/core/internals/utils';\nimport isEmpty from 'lodash/isEmpty';\nimport { record as recordCore } from '@aws-amplify/core/internals/providers/pinpoint';\nimport { resolveConfig } from './resolveConfig';\nimport { resolveCredentials } from './resolveCredentials';\nimport { CATEGORY } from './constants';\nimport { getInAppMessagingUserAgentString } from './userAgent';\nconst DELIVERY_TYPE = 'IN_APP_MESSAGE';\nlet eventNameMemo = {};\nlet eventAttributesMemo = {};\nlet eventMetricsMemo = {};\nexport const logger = new ConsoleLogger('InAppMessaging.Pinpoint.Utils');\nexport const recordAnalyticsEvent = (event, message) => {\n const { appId, region } = resolveConfig();\n const { id, metadata } = message;\n resolveCredentials()\n .then(({ credentials, identityId }) => {\n recordCore({\n appId,\n category: CATEGORY,\n credentials,\n event: {\n name: event,\n attributes: {\n // only include campaign_id field if we have one\n ...(id && { campaign_id: id }),\n delivery_type: DELIVERY_TYPE,\n treatment_id: metadata?.treatmentId,\n },\n },\n identityId,\n region,\n userAgentValue: getInAppMessagingUserAgentString(InAppMessagingAction.NotifyMessageInteraction),\n });\n })\n .catch(e => {\n // An error occured while fetching credentials or persisting the event to the buffer\n logger.warn('Failed to record event.', e);\n });\n};\nexport const getStartOfDay = () => {\n const now = new Date();\n now.setHours(0, 0, 0, 0);\n return now.toISOString();\n};\nexport const matchesEventType = ({ CampaignId, Schedule }, { name: eventType }) => {\n const { EventType } = Schedule?.EventFilter?.Dimensions ?? {};\n const memoKey = `${CampaignId}:${eventType}`;\n if (!eventNameMemo.hasOwnProperty(memoKey)) {\n eventNameMemo[memoKey] = !!EventType?.Values?.includes(eventType);\n }\n return eventNameMemo[memoKey];\n};\nexport const matchesAttributes = ({ CampaignId, Schedule }, { attributes = {} }) => {\n const { Attributes } = Schedule?.EventFilter?.Dimensions ?? {};\n if (isEmpty(Attributes)) {\n // if message does not have attributes defined it does not matter what attributes are on the event\n return true;\n }\n if (isEmpty(attributes)) {\n // if message does have attributes but the event does not then it always fails the check\n return false;\n }\n const memoKey = `${CampaignId}:${JSON.stringify(attributes)}`;\n if (!eventAttributesMemo.hasOwnProperty(memoKey)) {\n eventAttributesMemo[memoKey] =\n !Attributes ||\n Object.entries(Attributes).every(([key, { Values }]) => Values?.includes(attributes[key]));\n }\n return eventAttributesMemo[memoKey];\n};\nexport const matchesMetrics = ({ CampaignId, Schedule }, { metrics = {} }) => {\n const { Metrics } = Schedule?.EventFilter?.Dimensions ?? {};\n if (isEmpty(Metrics)) {\n // if message does not have metrics defined it does not matter what metrics are on the event\n return true;\n }\n if (isEmpty(metrics)) {\n // if message does have metrics but the event does not then it always fails the check\n return false;\n }\n const memoKey = `${CampaignId}:${JSON.stringify(metrics)}`;\n if (!eventMetricsMemo.hasOwnProperty(memoKey)) {\n eventMetricsMemo[memoKey] =\n !Metrics ||\n Object.entries(Metrics).every(([key, { ComparisonOperator, Value }]) => {\n const compare = getComparator(ComparisonOperator);\n // if there is some unknown comparison operator, treat as a comparison failure\n return compare && !!Value ? compare(Value, metrics[key]) : false;\n });\n }\n return eventMetricsMemo[memoKey];\n};\nexport const getComparator = (operator) => {\n switch (operator) {\n case 'EQUAL':\n return (metricsVal, eventVal) => metricsVal === eventVal;\n case 'GREATER_THAN':\n return (metricsVal, eventVal) => metricsVal < eventVal;\n case 'GREATER_THAN_OR_EQUAL':\n return (metricsVal, eventVal) => metricsVal <= eventVal;\n case 'LESS_THAN':\n return (metricsVal, eventVal) => metricsVal > eventVal;\n case 'LESS_THAN_OR_EQUAL':\n return (metricsVal, eventVal) => metricsVal >= eventVal;\n default:\n return undefined;\n }\n};\nexport const isBeforeEndDate = ({ Schedule, }) => {\n if (!Schedule?.EndDate) {\n return true;\n }\n return new Date() < new Date(Schedule.EndDate);\n};\nexport const isQuietTime = (message) => {\n const { Schedule } = message;\n if (!Schedule?.QuietTime) {\n return false;\n }\n const pattern = /^[0-2]\\d:[0-5]\\d$/; // basic sanity check, not a fully featured HH:MM validation\n const { Start, End } = Schedule.QuietTime;\n if (!Start ||\n !End ||\n Start === End ||\n !pattern.test(Start) ||\n !pattern.test(End)) {\n return false;\n }\n const now = new Date();\n const start = new Date(now);\n const end = new Date(now);\n const [startHours, startMinutes] = Start.split(':');\n const [endHours, endMinutes] = End.split(':');\n start.setHours(Number.parseInt(startHours, 10), Number.parseInt(startMinutes, 10), 0, 0);\n end.setHours(Number.parseInt(endHours, 10), Number.parseInt(endMinutes, 10), 0, 0);\n // if quiet time includes midnight, bump the end time to the next day\n if (start > end) {\n end.setDate(end.getDate() + 1);\n }\n const isQuietTime = now >= start && now <= end;\n if (isQuietTime) {\n logger.debug('message filtered due to quiet time', message);\n }\n return isQuietTime;\n};\nexport const clearMemo = () => {\n eventNameMemo = {};\n eventAttributesMemo = {};\n eventMetricsMemo = {};\n};\n// in the pinpoint console when a message is created with a Modal or Full Screen layout,\n// it is assigned a layout value of MOBILE_FEED or OVERLAYS respectively in the message payload.\n// In the future, Pinpoint will be updating the layout values in the aforementioned scenario\n// to MODAL and FULL_SCREEN.\n//\n// This utility acts as a safeguard to ensure that:\n// - 1. the usage of MOBILE_FEED and OVERLAYS as values for message layouts are not leaked\n// outside the Pinpoint provider\n// - 2. Amplify correctly handles the legacy layout values from Pinpoint after they are updated\nexport const interpretLayout = (layout) => {\n if (layout === 'MOBILE_FEED') {\n return 'MODAL';\n }\n if (layout === 'OVERLAYS') {\n return 'FULL_SCREEN';\n }\n // cast as PinpointInAppMessage['InAppMessage']['Layout'] allows `string` as a value\n return layout;\n};\nexport const extractContent = ({ InAppMessage: message, }) => {\n return (message?.Content?.map(content => {\n const { BackgroundColor, BodyConfig, HeaderConfig, ImageUrl, PrimaryBtn, SecondaryBtn, } = content;\n const defaultPrimaryButton = PrimaryBtn?.DefaultConfig;\n const defaultSecondaryButton = SecondaryBtn?.DefaultConfig;\n const extractedContent = {};\n if (BackgroundColor) {\n extractedContent.container = {\n style: {\n backgroundColor: BackgroundColor,\n },\n };\n }\n if (HeaderConfig) {\n extractedContent.header = {\n // Default to empty string in rare cases we don't have a Header value\n content: HeaderConfig.Header ?? '',\n style: {\n color: HeaderConfig.TextColor,\n textAlign: HeaderConfig.Alignment?.toLowerCase(),\n },\n };\n }\n if (BodyConfig) {\n extractedContent.body = {\n // Default to empty string in rare cases we don't have a Body value\n content: BodyConfig.Body ?? '',\n style: {\n color: BodyConfig.TextColor,\n textAlign: BodyConfig.Alignment?.toLowerCase(),\n },\n };\n }\n if (ImageUrl) {\n extractedContent.image = {\n src: ImageUrl,\n };\n }\n if (defaultPrimaryButton) {\n extractedContent.primaryButton = {\n // Default to empty string in rare cases we don't have a Text value\n title: defaultPrimaryButton.Text ?? '',\n action: defaultPrimaryButton.ButtonAction,\n url: defaultPrimaryButton.Link,\n style: {\n backgroundColor: defaultPrimaryButton.BackgroundColor,\n borderRadius: defaultPrimaryButton.BorderRadius,\n color: defaultPrimaryButton.TextColor,\n },\n };\n }\n if (defaultSecondaryButton) {\n extractedContent.secondaryButton = {\n // Default to empty string in rare cases we don't have a Text value\n title: defaultSecondaryButton.Text ?? '',\n action: defaultSecondaryButton.ButtonAction,\n url: defaultSecondaryButton.Link,\n style: {\n backgroundColor: defaultSecondaryButton.BackgroundColor,\n borderRadius: defaultSecondaryButton.BorderRadius,\n color: defaultSecondaryButton.TextColor,\n },\n };\n }\n return extractedContent;\n }) ?? []);\n};\nexport const extractMetadata = ({ InAppMessage, Priority, Schedule, TreatmentId, }) => ({\n customData: InAppMessage?.CustomConfig,\n endDate: Schedule?.EndDate,\n priority: Priority,\n treatmentId: TreatmentId,\n});\n"],"names":["recordCore"],"mappings":";;;;;;;;;AAAA;AACA;AASA,MA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AoB,KAAK,EAAE,oBAAoB,CAAC,SAAS;AACzD,iBAAiB;AACjB,aAAa,CAAC;AACd,SAAS;AACT,QAAQ,IAAI,sBAAsB,EAAE;AACpC,YAAY,gBAAgB,CAAC,eAAe,GAAG;AAC/C;AACA,gBAAgB,KAAK,EAAE,sBAAsB,CAAC,IAAI,IAAI,EAAE;AACxD,gBAAgB,MAAM,EAAE,sBAAsB,CAAC,YAAY;AAC3D,gBAAgB,GAAG,EAAE,sBAAsB,CAAC,IAAI;AAChD,gBAAgB,KAAK,EAAE;AACvB,oBAAoB,eAAe,EAAE,sBAAsB,CAAC,eAAe;AAC3E,oBAAoB,YAAY,EAAE,sBAAsB,CAAC,YAAY;AACrE,oBAAoB,KAAK,EAAE,sBAAsB,CAAC,SAAS;AAC3D,iBAAiB;AACjB,aAAa,CAAC;AACd,SAAS;AACT,QAAQ,OAAO,gBAAgB,CAAC;AAChC,KAAK,CAAC,IAAI,EAAE,EAAE;AACd,EAAE;AACU,MAAC,eAAe,GAAG,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;AACxF,IAAI,UAAU,EAAE,YAAY,EAAE,YAAY;AAC1C,IAAI,OAAO,EAAE,QAAQ,EAAE,OAAO;AAC9B,IAAI,QAAQ,EAAE,QAAQ;AACtB,IAAI,WAAW,EAAE,WAAW;AAC5B,CAAC;;;;"}
1
+ {"version":3,"file":"helpers.mjs","sources":["../../../../../../src/inAppMessaging/providers/pinpoint/utils/helpers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { InAppMessagingAction } from '@aws-amplify/core/internals/utils';\nimport isEmpty from 'lodash/isEmpty.js';\nimport { record as recordCore } from '@aws-amplify/core/internals/providers/pinpoint';\nimport { resolveConfig } from './resolveConfig';\nimport { resolveCredentials } from './resolveCredentials';\nimport { CATEGORY } from './constants';\nimport { getInAppMessagingUserAgentString } from './userAgent';\nconst DELIVERY_TYPE = 'IN_APP_MESSAGE';\nlet eventNameMemo = {};\nlet eventAttributesMemo = {};\nlet eventMetricsMemo = {};\nexport const logger = new ConsoleLogger('InAppMessaging.Pinpoint.Utils');\nexport const recordAnalyticsEvent = (event, message) => {\n const { appId, region } = resolveConfig();\n const { id, metadata } = message;\n resolveCredentials()\n .then(({ credentials, identityId }) => {\n recordCore({\n appId,\n category: CATEGORY,\n credentials,\n event: {\n name: event,\n attributes: {\n // only include campaign_id field if we have one\n ...(id && { campaign_id: id }),\n delivery_type: DELIVERY_TYPE,\n treatment_id: metadata?.treatmentId,\n },\n },\n identityId,\n region,\n userAgentValue: getInAppMessagingUserAgentString(InAppMessagingAction.NotifyMessageInteraction),\n });\n })\n .catch(e => {\n // An error occured while fetching credentials or persisting the event to the buffer\n logger.warn('Failed to record event.', e);\n });\n};\nexport const getStartOfDay = () => {\n const now = new Date();\n now.setHours(0, 0, 0, 0);\n return now.toISOString();\n};\nexport const matchesEventType = ({ CampaignId, Schedule }, { name: eventType }) => {\n const { EventType } = Schedule?.EventFilter?.Dimensions ?? {};\n const memoKey = `${CampaignId}:${eventType}`;\n if (!eventNameMemo.hasOwnProperty(memoKey)) {\n eventNameMemo[memoKey] = !!EventType?.Values?.includes(eventType);\n }\n return eventNameMemo[memoKey];\n};\nexport const matchesAttributes = ({ CampaignId, Schedule }, { attributes = {} }) => {\n const { Attributes } = Schedule?.EventFilter?.Dimensions ?? {};\n if (isEmpty(Attributes)) {\n // if message does not have attributes defined it does not matter what attributes are on the event\n return true;\n }\n if (isEmpty(attributes)) {\n // if message does have attributes but the event does not then it always fails the check\n return false;\n }\n const memoKey = `${CampaignId}:${JSON.stringify(attributes)}`;\n if (!eventAttributesMemo.hasOwnProperty(memoKey)) {\n eventAttributesMemo[memoKey] =\n !Attributes ||\n Object.entries(Attributes).every(([key, { Values }]) => Values?.includes(attributes[key]));\n }\n return eventAttributesMemo[memoKey];\n};\nexport const matchesMetrics = ({ CampaignId, Schedule }, { metrics = {} }) => {\n const { Metrics } = Schedule?.EventFilter?.Dimensions ?? {};\n if (isEmpty(Metrics)) {\n // if message does not have metrics defined it does not matter what metrics are on the event\n return true;\n }\n if (isEmpty(metrics)) {\n // if message does have metrics but the event does not then it always fails the check\n return false;\n }\n const memoKey = `${CampaignId}:${JSON.stringify(metrics)}`;\n if (!eventMetricsMemo.hasOwnProperty(memoKey)) {\n eventMetricsMemo[memoKey] =\n !Metrics ||\n Object.entries(Metrics).every(([key, { ComparisonOperator, Value }]) => {\n const compare = getComparator(ComparisonOperator);\n // if there is some unknown comparison operator, treat as a comparison failure\n return compare && !!Value ? compare(Value, metrics[key]) : false;\n });\n }\n return eventMetricsMemo[memoKey];\n};\nexport const getComparator = (operator) => {\n switch (operator) {\n case 'EQUAL':\n return (metricsVal, eventVal) => metricsVal === eventVal;\n case 'GREATER_THAN':\n return (metricsVal, eventVal) => metricsVal < eventVal;\n case 'GREATER_THAN_OR_EQUAL':\n return (metricsVal, eventVal) => metricsVal <= eventVal;\n case 'LESS_THAN':\n return (metricsVal, eventVal) => metricsVal > eventVal;\n case 'LESS_THAN_OR_EQUAL':\n return (metricsVal, eventVal) => metricsVal >= eventVal;\n default:\n return undefined;\n }\n};\nexport const isBeforeEndDate = ({ Schedule, }) => {\n if (!Schedule?.EndDate) {\n return true;\n }\n return new Date() < new Date(Schedule.EndDate);\n};\nexport const isQuietTime = (message) => {\n const { Schedule } = message;\n if (!Schedule?.QuietTime) {\n return false;\n }\n const pattern = /^[0-2]\\d:[0-5]\\d$/; // basic sanity check, not a fully featured HH:MM validation\n const { Start, End } = Schedule.QuietTime;\n if (!Start ||\n !End ||\n Start === End ||\n !pattern.test(Start) ||\n !pattern.test(End)) {\n return false;\n }\n const now = new Date();\n const start = new Date(now);\n const end = new Date(now);\n const [startHours, startMinutes] = Start.split(':');\n const [endHours, endMinutes] = End.split(':');\n start.setHours(Number.parseInt(startHours, 10), Number.parseInt(startMinutes, 10), 0, 0);\n end.setHours(Number.parseInt(endHours, 10), Number.parseInt(endMinutes, 10), 0, 0);\n // if quiet time includes midnight, bump the end time to the next day\n if (start > end) {\n end.setDate(end.getDate() + 1);\n }\n const isQuietTime = now >= start && now <= end;\n if (isQuietTime) {\n logger.debug('message filtered due to quiet time', message);\n }\n return isQuietTime;\n};\nexport const clearMemo = () => {\n eventNameMemo = {};\n eventAttributesMemo = {};\n eventMetricsMemo = {};\n};\n// in the pinpoint console when a message is created with a Modal or Full Screen layout,\n// it is assigned a layout value of MOBILE_FEED or OVERLAYS respectively in the message payload.\n// In the future, Pinpoint will be updating the layout values in the aforementioned scenario\n// to MODAL and FULL_SCREEN.\n//\n// This utility acts as a safeguard to ensure that:\n// - 1. the usage of MOBILE_FEED and OVERLAYS as values for message layouts are not leaked\n// outside the Pinpoint provider\n// - 2. Amplify correctly handles the legacy layout values from Pinpoint after they are updated\nexport const interpretLayout = (layout) => {\n if (layout === 'MOBILE_FEED') {\n return 'MODAL';\n }\n if (layout === 'OVERLAYS') {\n return 'FULL_SCREEN';\n }\n // cast as PinpointInAppMessage['InAppMessage']['Layout'] allows `string` as a value\n return layout;\n};\nexport const extractContent = ({ InAppMessage: message, }) => {\n return (message?.Content?.map(content => {\n const { BackgroundColor, BodyConfig, HeaderConfig, ImageUrl, PrimaryBtn, SecondaryBtn, } = content;\n const defaultPrimaryButton = PrimaryBtn?.DefaultConfig;\n const defaultSecondaryButton = SecondaryBtn?.DefaultConfig;\n const extractedContent = {};\n if (BackgroundColor) {\n extractedContent.container = {\n style: {\n backgroundColor: BackgroundColor,\n },\n };\n }\n if (HeaderConfig) {\n extractedContent.header = {\n // Default to empty string in rare cases we don't have a Header value\n content: HeaderConfig.Header ?? '',\n style: {\n color: HeaderConfig.TextColor,\n textAlign: HeaderConfig.Alignment?.toLowerCase(),\n },\n };\n }\n if (BodyConfig) {\n extractedContent.body = {\n // Default to empty string in rare cases we don't have a Body value\n content: BodyConfig.Body ?? '',\n style: {\n color: BodyConfig.TextColor,\n textAlign: BodyConfig.Alignment?.toLowerCase(),\n },\n };\n }\n if (ImageUrl) {\n extractedContent.image = {\n src: ImageUrl,\n };\n }\n if (defaultPrimaryButton) {\n extractedContent.primaryButton = {\n // Default to empty string in rare cases we don't have a Text value\n title: defaultPrimaryButton.Text ?? '',\n action: defaultPrimaryButton.ButtonAction,\n url: defaultPrimaryButton.Link,\n style: {\n backgroundColor: defaultPrimaryButton.BackgroundColor,\n borderRadius: defaultPrimaryButton.BorderRadius,\n color: defaultPrimaryButton.TextColor,\n },\n };\n }\n if (defaultSecondaryButton) {\n extractedContent.secondaryButton = {\n // Default to empty string in rare cases we don't have a Text value\n title: defaultSecondaryButton.Text ?? '',\n action: defaultSecondaryButton.ButtonAction,\n url: defaultSecondaryButton.Link,\n style: {\n backgroundColor: defaultSecondaryButton.BackgroundColor,\n borderRadius: defaultSecondaryButton.BorderRadius,\n color: defaultSecondaryButton.TextColor,\n },\n };\n }\n return extractedContent;\n }) ?? []);\n};\nexport const extractMetadata = ({ InAppMessage, Priority, Schedule, TreatmentId, }) => ({\n customData: InAppMessage?.CustomConfig,\n endDate: Schedule?.EndDate,\n priority: Priority,\n treatmentId: TreatmentId,\n});\n"],"names":["recordCore"],"mappings":";;;;;;;;;AAAA;AACA;AASA,MAAM,aAAa,GAAG,gBAAgB,CAAC;AACvC,IAAI,aAAa,GAAG,EAAE,CAAC;AACvB,IAAI,mBAAmB,GAAG,EAAE,CAAC;AAC7B,IAAI,gBAAgB,GAAG,EAAE,CAAC;AACd,MAAC,MAAM,GAAG,IAAI,aAAa,CAAC,+BAA+B,EAAE;AAC7D,MAAC,oBAAoB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK;AACxD,IAAI,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAC;AAC9C,IAAI,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;AACrC,IAAI,kBAAkB,EA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CAAC,YAAY;AACrE,oBAAoB,KAAK,EAAE,sBAAsB,CAAC,SAAS;AAC3D,iBAAiB;AACjB,aAAa,CAAC;AACd,SAAS;AACT,QAAQ,OAAO,gBAAgB,CAAC;AAChC,KAAK,CAAC,IAAI,EAAE,EAAE;AACd,EAAE;AACU,MAAC,eAAe,GAAG,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;AACxF,IAAI,UAAU,EAAE,YAAY,EAAE,YAAY;AAC1C,IAAI,OAAO,EAAE,QAAQ,EAAE,OAAO;AAC9B,IAAI,QAAQ,EAAE,QAAQ;AACtB,IAAI,WAAW,EAAE,WAAW;AAC5B,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/notifications",
3
- "version": "2.0.1-mjs-test.20ead30.0+20ead30",
3
+ "version": "2.0.1-mjs-test.6f5dab7.0+6f5dab7",
4
4
  "description": "Notifications category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -43,7 +43,6 @@
43
43
  },
44
44
  "exports": {
45
45
  ".": {
46
- "types": "./dist/esm/index.d.ts",
47
46
  "import": "./dist/esm/index.mjs",
48
47
  "require": "./dist/cjs/index.js",
49
48
  "react-native": "./src/index.ts"
@@ -96,11 +95,11 @@
96
95
  "tslib": "^2.5.0"
97
96
  },
98
97
  "peerDependencies": {
99
- "@aws-amplify/core": "6.0.1-mjs-test.20ead30.0+20ead30"
98
+ "@aws-amplify/core": "6.0.1-mjs-test.6f5dab7.0+6f5dab7"
100
99
  },
101
100
  "devDependencies": {
102
- "@aws-amplify/core": "6.0.1-mjs-test.20ead30.0+20ead30",
103
- "@aws-amplify/react-native": "1.0.1-mjs-test.20ead30.0+20ead30",
101
+ "@aws-amplify/core": "6.0.1-mjs-test.6f5dab7.0+6f5dab7",
102
+ "@aws-amplify/react-native": "1.0.1-mjs-test.6f5dab7.0+6f5dab7",
104
103
  "@rollup/plugin-typescript": "11.1.5",
105
104
  "rollup": "3.29.4",
106
105
  "typescript": "5.0.2"
@@ -145,5 +144,5 @@
145
144
  "dist"
146
145
  ]
147
146
  },
148
- "gitHead": "20ead30dfcde204f693f598b063bc05745404e03"
147
+ "gitHead": "6f5dab7f07d1781d39217d1e5a253c6a5165c8b2"
149
148
  }
@@ -7,7 +7,7 @@ import {
7
7
  processInAppMessages,
8
8
  } from '../utils';
9
9
  import { InAppMessage } from '../../../types';
10
- import flatten from 'lodash/flatten';
10
+ import flatten from 'lodash/flatten.js';
11
11
  import { defaultStorage } from '@aws-amplify/core';
12
12
  import { notifyEventListeners } from '../../../../eventListeners';
13
13
  import { assertServiceError } from '../../../errors';
@@ -4,7 +4,7 @@
4
4
  import { ConsoleLogger } from '@aws-amplify/core';
5
5
  import { InAppMessagingAction } from '@aws-amplify/core/internals/utils';
6
6
  import type { InAppMessageCampaign as PinpointInAppMessage } from '@aws-amplify/core/internals/aws-clients/pinpoint';
7
- import isEmpty from 'lodash/isEmpty';
7
+ import isEmpty from 'lodash/isEmpty.js';
8
8
  import {
9
9
  InAppMessage,
10
10
  InAppMessageAction,