@applicaster/zapp-react-native-utils 16.0.0-rc.8 → 16.0.0-rc.81

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 (190) hide show
  1. package/actionsExecutor/ActionExecutor.ts +47 -11
  2. package/actionsExecutor/ActionExecutorContext.tsx +102 -315
  3. package/actionsExecutor/__tests__/feedDecorator.test.ts +61 -0
  4. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +25 -0
  5. package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
  6. package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
  7. package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
  8. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +133 -0
  9. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +76 -0
  10. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +212 -0
  11. package/actionsExecutor/actions/__tests__/showToast.test.ts +88 -0
  12. package/actionsExecutor/actions/appRestart.ts +24 -0
  13. package/actionsExecutor/actions/confirmDialog.ts +53 -0
  14. package/actionsExecutor/actions/dismissBottomSheet.ts +23 -0
  15. package/actionsExecutor/actions/goBack.ts +60 -0
  16. package/actionsExecutor/actions/goHome.ts +31 -0
  17. package/actionsExecutor/actions/index.ts +38 -0
  18. package/actionsExecutor/actions/localStorageRemove.ts +27 -0
  19. package/actionsExecutor/actions/localStorageSet.ts +28 -0
  20. package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
  21. package/actionsExecutor/actions/navigateToScreen.ts +137 -0
  22. package/actionsExecutor/actions/openBottomSheet.ts +325 -0
  23. package/actionsExecutor/actions/refreshComponent.ts +85 -0
  24. package/actionsExecutor/actions/screenSetVariable.ts +35 -0
  25. package/actionsExecutor/actions/screenToggleFlag.ts +38 -0
  26. package/actionsExecutor/actions/sendCloudEvent.ts +93 -0
  27. package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
  28. package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
  29. package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
  30. package/actionsExecutor/actions/showToast.ts +87 -0
  31. package/actionsExecutor/actions/switchLayout.ts +40 -0
  32. package/actionsExecutor/consts.ts +25 -0
  33. package/actionsExecutor/feedDecorator.ts +6 -6
  34. package/actionsExecutor/types.ts +59 -0
  35. package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -2
  36. package/analyticsUtils/PlayerAnalyticsManager.ts +12 -2
  37. package/analyticsUtils/__tests__/analyticsMapper.test.ts +35 -0
  38. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testACP_events.json +1 -1
  39. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testBlockUnlistedParams_rules.json +1 -1
  40. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_events.json +4 -0
  41. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEmptyRenameKeepsName_rules.json +6 -0
  42. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testEventRegex_events.json +3 -9
  43. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_events.json +18 -0
  44. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testIgnoreOrdering_rules.json +16 -0
  45. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_events.json +4 -0
  46. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexEventNoFallback_rules.json +6 -0
  47. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_events.json +4 -0
  48. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexMultiGroupRename_rules.json +6 -0
  49. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_events.json +4 -0
  50. package/analyticsUtils/__tests__/fixtures/analytics_mapper_testRegexNonNamedFullMatch_rules.json +6 -0
  51. package/analyticsUtils/__tests__/fixtures/index.js +20 -0
  52. package/analyticsUtils/analyticsMapper.ts +4 -1
  53. package/analyticsUtils/playerAnalyticsTracker.ts +26 -3
  54. package/appUtils/HooksManager/index.ts +12 -8
  55. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -1
  56. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +1 -1
  57. package/appUtils/contextKeysManager/__tests__/setKey/failure/invalidKey.test.ts +4 -4
  58. package/appUtils/contextKeysManager/index.ts +1 -1
  59. package/appUtils/contextKeysManager/utils/index.ts +38 -25
  60. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +143 -53
  61. package/appUtils/playerManager/OverlayObserver/__tests__/liveContent.test.ts +205 -0
  62. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +49 -0
  63. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +4 -0
  64. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +4 -0
  65. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +11 -0
  66. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -0
  67. package/appUtils/playerManager/OverlayObserver/utils.ts +54 -20
  68. package/appUtils/playerManager/__tests__/playerContent.test.ts +403 -0
  69. package/appUtils/playerManager/__tests__/playerFactory.test.ts +1 -1
  70. package/appUtils/playerManager/__tests__/playerNative.test.ts +38 -0
  71. package/appUtils/playerManager/__tests__/usePlayerContent.test.tsx +64 -0
  72. package/appUtils/playerManager/{conts.ts → const.ts} +20 -0
  73. package/appUtils/playerManager/index.ts +1 -1
  74. package/appUtils/playerManager/player.ts +115 -3
  75. package/appUtils/playerManager/playerFactory.ts +1 -1
  76. package/appUtils/playerManager/playerNative.ts +6 -4
  77. package/appUtils/playerManager/usePlayerContent.tsx +43 -0
  78. package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -1
  79. package/appUtils/playerManager/userLanguagePreference.ts +1 -1
  80. package/arrayUtils/__tests__/{anyThruthy.test.ts → anyTruthy.test.ts} +8 -0
  81. package/arrayUtils/__tests__/arrayUtils.test.ts +165 -108
  82. package/arrayUtils/__tests__/isEmptyArray.test.ts +11 -0
  83. package/arrayUtils/__tests__/isFilledArray.test.ts +12 -0
  84. package/arrayUtils/__tests__/isFirst.test.ts +17 -0
  85. package/arrayUtils/__tests__/isIndexInRange.test.ts +14 -0
  86. package/arrayUtils/__tests__/isLast.test.ts +31 -0
  87. package/arrayUtils/__tests__/makeListOf.test.ts +31 -0
  88. package/arrayUtils/__tests__/makeListOfIndexes.test.ts +20 -0
  89. package/arrayUtils/__tests__/reorderByIds.test.ts +50 -0
  90. package/arrayUtils/__tests__/sample.test.ts +61 -0
  91. package/arrayUtils/index.ts +136 -20
  92. package/bottomSheet/__tests__/scrollContext.test.tsx +35 -0
  93. package/bottomSheet/index.ts +17 -0
  94. package/cellUtils/index.ts +33 -8
  95. package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
  96. package/colorUtils/__tests__/isValidColor.test.ts +70 -0
  97. package/colorUtils/index.ts +50 -0
  98. package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
  99. package/configurationUtils/__tests__/modalBlocksParser.test.ts +260 -0
  100. package/configurationUtils/manifestKeyParser.ts +50 -10
  101. package/configurationUtils/modalBlocksParser.ts +296 -0
  102. package/entryActions/__tests__/buildEntryActions.test.ts +156 -0
  103. package/entryActions/aliasPresentation.ts +124 -0
  104. package/entryActions/buildEntryActions.ts +166 -0
  105. package/entryActions/index.ts +17 -0
  106. package/entryActions/types.ts +39 -0
  107. package/manifestUtils/__tests__/player.audioControls.test.js +158 -0
  108. package/manifestUtils/_internals/index.js +14 -3
  109. package/manifestUtils/defaultManifestConfigurations/generalContent.js +35 -0
  110. package/manifestUtils/defaultManifestConfigurations/player.js +349 -20
  111. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
  112. package/manifestUtils/fieldUtils/index.js +125 -0
  113. package/manifestUtils/index.js +3 -0
  114. package/manifestUtils/keys.js +9 -0
  115. package/manifestUtils/mobileAction/button/index.js +16 -0
  116. package/manifestUtils/mobileAction/container/index.js +3 -1
  117. package/manifestUtils/mobileAction/groups/defaults.js +3 -1
  118. package/manifestUtils/modalBlocks.js +304 -0
  119. package/manifestUtils/platformIsTV.js +1 -0
  120. package/modalState/ContentViewModel.ts +113 -0
  121. package/modalState/EditableCollection.ts +17 -0
  122. package/modalState/EditableCollectionRegistry.ts +51 -0
  123. package/modalState/ModalOrchestrator.ts +211 -0
  124. package/modalState/RemoteEditableCollection.ts +227 -0
  125. package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
  126. package/modalState/__tests__/ContentViewModel.test.ts +165 -0
  127. package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
  128. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +47 -0
  129. package/modalState/__tests__/RemoteEditableCollection.test.ts +326 -0
  130. package/modalState/__tests__/index.test.ts +30 -1
  131. package/modalState/__tests__/useBottomSheetContent.test.ts +349 -0
  132. package/modalState/index.ts +35 -83
  133. package/modalState/store.ts +102 -0
  134. package/modalState/types.ts +159 -0
  135. package/modalState/useBottomSheetContent.ts +104 -0
  136. package/numberUtils/__tests__/isMinusZero.test.ts +20 -0
  137. package/numberUtils/__tests__/isZero.test.ts +27 -0
  138. package/numberUtils/__tests__/requireNumber.test.ts +50 -0
  139. package/numberUtils/__tests__/toNumber.test.ts +27 -0
  140. package/numberUtils/__tests__/toNumberWithDefault.test.ts +64 -0
  141. package/numberUtils/__tests__/toNumberWithDefaultZero.test.ts +48 -0
  142. package/numberUtils/index.ts +27 -8
  143. package/package.json +2 -2
  144. package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
  145. package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
  146. package/pipesUtils/index.ts +1 -0
  147. package/pipesUtils/withPipesEndpoint.tsx +54 -0
  148. package/playerUtils/__tests__/contentDataKeys.test.ts +297 -0
  149. package/playerUtils/__tests__/resolvePlayerActions.test.ts +138 -0
  150. package/playerUtils/__tests__/resolvePlayerTitleSubtitle.test.ts +180 -0
  151. package/playerUtils/contentDataKeys.ts +134 -0
  152. package/playerUtils/index.ts +58 -15
  153. package/playerUtils/isAudioItem.ts +26 -0
  154. package/playerUtils/resolvePlayerActions.ts +71 -0
  155. package/playerUtils/resolvePlayerTitleSubtitle.ts +76 -0
  156. package/reactHooks/actions/index.ts +117 -2
  157. package/reactHooks/cell-click/index.ts +18 -10
  158. package/reactHooks/feed/__mocks__/useMarkPipesDataStale.ts +4 -0
  159. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +25 -0
  160. package/reactHooks/feed/index.ts +5 -1
  161. package/reactHooks/feed/useBatchLoading.ts +9 -1
  162. package/reactHooks/feed/{usePipesCacheReset.ts → useMarkPipesDataStale.ts} +12 -4
  163. package/reactHooks/index.ts +2 -0
  164. package/reactHooks/layout/index.ts +1 -1
  165. package/reactHooks/navigation/__mocks__/index.ts +4 -0
  166. package/reactHooks/navigation/__tests__/useIsScreenActive.test.ts +42 -0
  167. package/reactHooks/navigation/index.ts +1 -1
  168. package/reactHooks/navigation/useIsScreenActive.ts +29 -8
  169. package/reactHooks/state/useComponentScreenState.ts +1 -1
  170. package/reactHooks/usePluginConfiguration.ts +4 -1
  171. package/reactHooks/utils/__tests__/index.test.js +22 -2
  172. package/reactHooks/utils/index.ts +13 -2
  173. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +22 -4
  174. package/riverComponetsMeasurementProvider/index.tsx +12 -8
  175. package/stringUtils/__tests__/stringUtils.test.js +42 -0
  176. package/stringUtils/index.ts +2 -2
  177. package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
  178. package/uiActionsRegistrator/__tests__/subscribe.test.ts +107 -0
  179. package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
  180. package/uiActionsRegistrator/index.ts +25 -0
  181. package/uiActionsRegistrator/registry.ts +335 -0
  182. package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
  183. package/uiActionsRegistrator/usableActionItems.ts +66 -0
  184. package/zappFrameworkUtils/__tests__/localStorageHelper.test.ts +146 -0
  185. package/zappFrameworkUtils/localStorageHelper.ts +19 -15
  186. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +0 -56
  187. package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
  188. package/playerUtils/getPlayerActionButtons.ts +0 -17
  189. package/reactHooks/feed/__mocks__/usePipesCacheReset.ts +0 -1
  190. /package/reactHooks/actions/__tests__/{index.test.js → index.test.tsx} +0 -0
@@ -0,0 +1,325 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import {
3
+ PipesClientResponseHelper,
4
+ RequestBuilder,
5
+ } from "@applicaster/zapp-pipes-v2-client";
6
+ import uuidv4 from "uuid/v4";
7
+ import { modalOrchestrator } from "../../modalState/ModalOrchestrator";
8
+ import { openBottomSheetModal } from "../../modalState/store";
9
+ import {
10
+ DynamicCollectionOptions,
11
+ getMenuItemActions,
12
+ isPresentSubMenuAction,
13
+ Menu,
14
+ MenuItem,
15
+ Operation,
16
+ SelectionBehavior,
17
+ } from "../../modalState/types";
18
+ import { actionExecutor, ActionResult } from "../ActionExecutor";
19
+ import { createLogger } from "../../logger";
20
+
21
+ const { log_info, log_error } = createLogger({
22
+ subsystem: "ActionExecutorContext",
23
+ category: "General",
24
+ });
25
+
26
+ export type LoadedSheetContent = {
27
+ items: MenuItem[];
28
+ role?: string;
29
+ behavior?: SelectionBehavior;
30
+ dynamicCollection?: DynamicCollectionOptions;
31
+ };
32
+
33
+ /**
34
+ * Parse a raw `dynamic_collection_options` block (feed or inline content) into
35
+ * the typed `DynamicCollectionOptions`. `operations` accepts either a CSV
36
+ * string (feed) or an array (already parsed).
37
+ */
38
+ export function parseDynamicCollectionOptions(
39
+ raw:
40
+ | {
41
+ operations?: string | string[];
42
+ postUrl?: string;
43
+ provider?: string;
44
+ events?: Record<string, any[]>;
45
+ }
46
+ | undefined
47
+ ): DynamicCollectionOptions | undefined {
48
+ if (!raw) {
49
+ return undefined;
50
+ }
51
+
52
+ const operations = Array.isArray(raw.operations)
53
+ ? (raw.operations as Operation[])
54
+ : ((raw.operations || "").split(",").filter(Boolean) as Operation[]);
55
+
56
+ return {
57
+ operations,
58
+ postUrl: raw.postUrl,
59
+ provider: raw.provider,
60
+ events: raw.events,
61
+ };
62
+ }
63
+
64
+ /**
65
+ * Converts a ZappEntry from a pipes feed into a MenuItem.
66
+ * - Icon: first src found in the image media_group.
67
+ * - Primary action: taken from tap_actions.actions[0].
68
+ * - isSelected: true when entry.id is in currentSelection.
69
+ */
70
+ export function entryToMenuItem(
71
+ entry: ZappEntry,
72
+ currentSelection: string[] = []
73
+ ): MenuItem {
74
+ const imageGroup = entry.media_group?.find((g) => g.type === "image");
75
+
76
+ const firstImage = Array.isArray(imageGroup?.media_item)
77
+ ? imageGroup.media_item[0]
78
+ : imageGroup?.media_item;
79
+
80
+ // Primary action — first tap_action on the entry
81
+ const tapActions = entry.extensions?.tap_actions?.actions || [];
82
+ const primaryAction = tapActions.length > 0 ? tapActions[0] : undefined;
83
+
84
+ const summary = entry.summary as string;
85
+
86
+ const itemId = String(entry.id ?? entry.title ?? uuidv4());
87
+
88
+ return {
89
+ id: itemId,
90
+ title: entry.title as string,
91
+ summary,
92
+ icon: firstImage?.src,
93
+ isSelected: currentSelection.includes(itemId),
94
+ action: primaryAction,
95
+ actions: tapActions,
96
+ entryActions: entry.extensions?.entry_action || [],
97
+ };
98
+ }
99
+
100
+ function parseCurrentSelection(rawSelection: unknown): string[] {
101
+ if (Array.isArray(rawSelection)) {
102
+ return (rawSelection as any[]).map(String);
103
+ }
104
+
105
+ if (rawSelection !== undefined && rawSelection !== null) {
106
+ return [String(rawSelection)];
107
+ }
108
+
109
+ return [];
110
+ }
111
+
112
+ function parseBehaviorFromFeed(
113
+ feed: ZappFeed | undefined,
114
+ currentSelection: string[]
115
+ ): SelectionBehavior | undefined {
116
+ const raw = feed?.extensions?.behavior;
117
+
118
+ if (!raw && currentSelection.length === 0) {
119
+ return undefined;
120
+ }
121
+
122
+ return {
123
+ selectMode: raw?.select_mode,
124
+ currentSelection,
125
+ selector: raw?.selector,
126
+ };
127
+ }
128
+
129
+ function parseBehaviorFromContentOptions(
130
+ content: Record<string, any> | undefined
131
+ ): SelectionBehavior | undefined {
132
+ const raw = content?.behavior ?? content?.extensions?.behavior;
133
+
134
+ if (!raw) {
135
+ return undefined;
136
+ }
137
+
138
+ return {
139
+ selectMode: raw.selectMode ?? raw.select_mode,
140
+ currentSelection: parseCurrentSelection(
141
+ raw.currentSelection ?? raw.current_selection
142
+ ),
143
+ selector: raw.selector,
144
+ };
145
+ }
146
+
147
+ // Exported so MultiLevelBottomSheetContent can lazy-load sub-levels
148
+ export async function loadItemsFromSource(
149
+ source: string,
150
+ context?: Record<string, any>
151
+ ): Promise<LoadedSheetContent> {
152
+ const requestBuilder = new RequestBuilder()
153
+ .setEntryContext(context?.entry || {})
154
+ .setScreenContext(context?.screenData || {})
155
+ .setUrl(source);
156
+
157
+ await requestBuilder.buildAxiosRequest();
158
+
159
+ const responseData = await requestBuilder.call<ZappFeed>();
160
+
161
+ const responseHelper = new PipesClientResponseHelper(responseData);
162
+
163
+ if (responseHelper.error) {
164
+ throw responseHelper.error;
165
+ }
166
+
167
+ const feed = responseData?.response as ZappFeed;
168
+
169
+ const currentSelection = parseCurrentSelection(
170
+ feed?.extensions?.behavior?.current_selection
171
+ );
172
+
173
+ const items = (feed?.entry || []).map((entry) =>
174
+ entryToMenuItem(entry, currentSelection)
175
+ );
176
+
177
+ const dynamicCollectionOptions = feed?.extensions?.dynamic_collection_options;
178
+
179
+ const dynamicCollection = parseDynamicCollectionOptions(
180
+ dynamicCollectionOptions
181
+ );
182
+
183
+ return {
184
+ items,
185
+ role: feed?.extensions?.role,
186
+ behavior: parseBehaviorFromFeed(feed, currentSelection),
187
+ dynamicCollection,
188
+ };
189
+ }
190
+
191
+ export async function openBottomSheetAction(
192
+ action: ActionType,
193
+ context?: Record<string, any>
194
+ ): Promise<ActionResult> {
195
+ try {
196
+ const { content, header, themePluginId, styleOverrides } =
197
+ action.options || {};
198
+
199
+ // Custom body component — keep default ModalComponent so standard header
200
+ // (dismiss x) is used; content.component is body-only (e.g. TextInputContent).
201
+ if (content?.component) {
202
+ log_info("openBottomSheet: using custom content component");
203
+
204
+ openBottomSheetModal({
205
+ modalBottomSheetContentProps: {
206
+ title: header?.title,
207
+ summary: header?.subtitle,
208
+ items: [],
209
+ onPress: () => {},
210
+ contentComponent: content.component,
211
+ contentComponentProps: content.props || {},
212
+ },
213
+ });
214
+
215
+ return ActionResult.Success;
216
+ }
217
+
218
+ const inlineItems: ZappEntry[] = content?.items;
219
+ const itemsUrl: string = content?.itemsUrl;
220
+
221
+ let items: MenuItem[];
222
+ let role: string | undefined;
223
+ let behavior: SelectionBehavior | undefined;
224
+
225
+ let dynamicCollection: DynamicCollectionOptions | undefined;
226
+
227
+ if (Array.isArray(inlineItems) && inlineItems.length > 0) {
228
+ log_info("openBottomSheet: using inline items from action options", {
229
+ count: inlineItems.length,
230
+ });
231
+
232
+ role = content?.role ?? content?.extensions?.role;
233
+ behavior = parseBehaviorFromContentOptions(content);
234
+
235
+ items = inlineItems.map((entry) =>
236
+ entryToMenuItem(entry, behavior?.currentSelection ?? [])
237
+ );
238
+
239
+ dynamicCollection = parseDynamicCollectionOptions(
240
+ content?.dynamicCollection ??
241
+ content?.extensions?.dynamic_collection_options
242
+ );
243
+ } else if (itemsUrl) {
244
+ log_info(`openBottomSheet: loading items from source: ${itemsUrl}`);
245
+
246
+ const loaded = await loadItemsFromSource(itemsUrl, context);
247
+ items = loaded.items;
248
+ role = loaded.role ?? content?.role ?? content?.extensions?.role;
249
+ behavior = loaded.behavior ?? parseBehaviorFromContentOptions(content);
250
+ dynamicCollection = loaded.dynamicCollection;
251
+
252
+ log_info(
253
+ `openBottomSheet: loaded ${items.length} items from source: ${itemsUrl}`
254
+ );
255
+ } else {
256
+ log_error(
257
+ "openBottomSheet: no itemsUrl, items, or content.component provided in action options"
258
+ );
259
+
260
+ return ActionResult.Error;
261
+ }
262
+
263
+ const menu: Menu = {
264
+ header: header
265
+ ? {
266
+ title: header.title,
267
+ subtitle: header.subtitle,
268
+ icon: header.icon,
269
+ }
270
+ : undefined,
271
+ content: {
272
+ title: content?.title ?? "",
273
+ items,
274
+ itemsUrl, // stored so the component can reload after an action
275
+ role,
276
+ behavior,
277
+ dynamicCollection,
278
+ themePluginId,
279
+ styleOverrides: styleOverrides ?? content?.styleOverrides,
280
+ },
281
+ };
282
+
283
+ /**
284
+ * Called when the user taps a menu item.
285
+ *
286
+ * - PresentSubMenuAction → handled by the orchestrator (pushes sub-menu)
287
+ * - Any other Action type → forwarded to the action executor, keeping the
288
+ * original execution context so screen/entry data is available to handlers.
289
+ * The pressed item is also added as `entry` so downstream actions can
290
+ * reference it.
291
+ */
292
+ const onItemPress = async (item: MenuItem): Promise<void> => {
293
+ const actions = getMenuItemActions(item);
294
+
295
+ const executableActions = actions.filter(
296
+ (action) => !isPresentSubMenuAction(action)
297
+ );
298
+
299
+ if (executableActions.length > 0) {
300
+ await actionExecutor.handleActions(
301
+ executableActions as ActionType[],
302
+ {
303
+ ...context,
304
+ entry: item as any,
305
+ } as any
306
+ );
307
+ }
308
+ };
309
+
310
+ if (action.options?.replace) {
311
+ modalOrchestrator.replace(menu, onItemPress);
312
+ } else {
313
+ modalOrchestrator.open(menu, onItemPress);
314
+ }
315
+
316
+ return ActionResult.Success;
317
+ } catch (error) {
318
+ log_error("openBottomSheet: failed to open bottom sheet", {
319
+ error,
320
+ action,
321
+ });
322
+
323
+ return ActionResult.Error;
324
+ }
325
+ }
@@ -0,0 +1,85 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
3
+ import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
4
+ import {
5
+ getInflatedDataSourceUrl,
6
+ getSearchContext,
7
+ } from "../../reactHooks/feed/useInflatedUrl";
8
+ import { ActionResult } from "../ActionExecutor";
9
+ import { ActionHandler, ActionExecutionContext } from "../types";
10
+ import { createLogger } from "../../logger";
11
+
12
+ const { log_info } = createLogger({
13
+ subsystem: "ActionExecutorContext",
14
+ category: "General",
15
+ });
16
+
17
+ /** Prefer component data.source, otherwise direct UIComponentContext parent. */
18
+ function getComponentFeedData(component) {
19
+ if (component?.data?.source) {
20
+ return component.data;
21
+ }
22
+
23
+ if (component?.parent?.data?.source) {
24
+ return component.parent.data;
25
+ }
26
+
27
+ return null;
28
+ }
29
+
30
+ /**
31
+ * Refreshes a component's data by reloading its data source.
32
+ * Supports URL inflation with context variables.
33
+ */
34
+ export const refreshComponentAction: ActionHandler = async (
35
+ _action,
36
+ context?: ActionExecutionContext
37
+ ): Promise<ActionResult> => {
38
+ const dispatch = appStore.getDispatch();
39
+
40
+ const componentData = getComponentFeedData(context?.component);
41
+
42
+ const source = componentData?.source;
43
+ const mapping = componentData?.mapping;
44
+
45
+ let dataSource = source;
46
+
47
+ if (source && mapping) {
48
+ dataSource =
49
+ getInflatedDataSourceUrl({
50
+ source,
51
+ contexts: {
52
+ entry: context?.screenEntry,
53
+ screen: context?.screenData,
54
+ search: getSearchContext(null, mapping),
55
+ },
56
+ mapping,
57
+ }) || source;
58
+ }
59
+
60
+ if (!dataSource) {
61
+ log_info("handleAction: refreshComponent skipped: no dataSource found");
62
+
63
+ return ActionResult.Success;
64
+ }
65
+
66
+ log_info(`handleAction: refreshComponent for dataSource:${dataSource}`, {
67
+ source,
68
+ inflatedUrl: dataSource,
69
+ mapping,
70
+ entryContextId: context?.entryContext?.id,
71
+ entryId: context?.entry?.id,
72
+ });
73
+
74
+ // TODO: In theory we should wait callback to complete, before completing the action, but now it's not needed
75
+ // TODO: handle focused item removal
76
+ dispatch(
77
+ loadPipesData(dataSource, {
78
+ silentRefresh: false,
79
+ clearCache: true,
80
+ riverId: context?.screenData?.id,
81
+ })
82
+ );
83
+
84
+ return ActionResult.Success;
85
+ };
@@ -0,0 +1,35 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { screenSetVariable } from "../ScreenActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+
6
+ /**
7
+ * Options for screenSetVariable action.
8
+ */
9
+ export interface ScreenSetVariableOptions {
10
+ /** The key/namespace for storing the variable */
11
+ key: string;
12
+
13
+ /** Path to extract the value from entry */
14
+ selector?: string;
15
+ }
16
+
17
+ /**
18
+ * Sets a variable in screen state storage.
19
+ * The value is extracted from the entry using the selector option.
20
+ */
21
+ export const screenSetVariableAction: ActionHandler<
22
+ ScreenSetVariableOptions
23
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
24
+ const route = context?.screenRoute;
25
+ const screenStateStore = context?.screenStateStore;
26
+
27
+ await screenSetVariable(
28
+ route,
29
+ screenStateStore,
30
+ { entry: context?.entry, options: action.options },
31
+ action
32
+ );
33
+
34
+ return ActionResult.Success;
35
+ };
@@ -0,0 +1,38 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { screenToggleFlag } from "../ScreenActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+
6
+ /**
7
+ * Options for screenToggleFlag action.
8
+ */
9
+ export interface ScreenToggleFlagOptions {
10
+ /** The key/namespace for storing the flag */
11
+ key: string;
12
+
13
+ /** Path to extract the tag from entry (e.g., "extensions.tag") */
14
+ selector?: string;
15
+
16
+ /** Maximum number of items that can be selected */
17
+ max_items?: number;
18
+ }
19
+
20
+ /**
21
+ * Toggles a flag in screen state storage (adds or removes an item from a collection).
22
+ * Useful for screen-level multi-select functionality.
23
+ */
24
+ export const screenToggleFlagAction: ActionHandler<
25
+ ScreenToggleFlagOptions
26
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
27
+ const screenRoute = context?.screenRoute;
28
+ const screenStateStore = context?.screenStateStore;
29
+
30
+ await screenToggleFlag(
31
+ screenRoute,
32
+ screenStateStore,
33
+ { entry: context?.entry, options: action.options },
34
+ action
35
+ );
36
+
37
+ return ActionResult.Success;
38
+ };
@@ -0,0 +1,93 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { createCloudEvent, sendCloudEvent } from "../../cloudEventsUtils";
3
+ import {
4
+ EntryResolver,
5
+ resolveObjectValues,
6
+ } from "../../appUtils/contextKeysManager/contextResolver";
7
+ import { ActionResult } from "../ActionExecutor";
8
+ import { ActionHandler, ActionExecutionContext } from "../types";
9
+ import { createLogger } from "../../logger";
10
+
11
+ const { log_info, log_error } = createLogger({
12
+ subsystem: "ActionExecutorContext",
13
+ category: "General",
14
+ });
15
+
16
+ /**
17
+ * Options for the sendCloudEvent action.
18
+ */
19
+ export interface SendCloudEventOptions {
20
+ /** The cloud event type (defaults to "com.applicaster.selector.action.v1") */
21
+ type?: string;
22
+
23
+ /** The event data payload */
24
+ data?: Record<string, any>;
25
+
26
+ /** The event subject (defaults to entry.id) */
27
+ subject?: string;
28
+
29
+ /** The URL endpoint to send the event to */
30
+ url: string;
31
+
32
+ /** Whether to inflate data with context variables */
33
+ inflateData?: boolean;
34
+ }
35
+
36
+ /**
37
+ * Sends a cloud event to a remote endpoint.
38
+ * Supports data inflation using context variables from entry and screen.
39
+ */
40
+ export const sendCloudEventAction: ActionHandler<
41
+ SendCloudEventOptions
42
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
43
+ try {
44
+ const options = action.options as SendCloudEventOptions;
45
+
46
+ const entry = context?.entry || {};
47
+ const entryResolver = new EntryResolver(entry as ZappEntry);
48
+ const screenData = context?.screenStateStore?.getState?.()?.data || {};
49
+ const screenResolver = new EntryResolver(screenData as ZappEntry);
50
+
51
+ const data =
52
+ options?.data && options.inflateData
53
+ ? await resolveObjectValues(options.data, {
54
+ entry: entryResolver,
55
+ screen: screenResolver,
56
+ })
57
+ : options?.data || entry;
58
+
59
+ const cloudEvent = await createCloudEvent({
60
+ type: options.type || "com.applicaster.selector.action.v1",
61
+ data,
62
+ subject: options.subject || String((entry as ZappEntry)?.id || ""),
63
+ });
64
+
65
+ log_info("handleAction: sending sendCloudEvent to URL", {
66
+ url: options.url,
67
+ cloudEvent,
68
+ });
69
+
70
+ const { error, code } = await sendCloudEvent(cloudEvent, options.url);
71
+
72
+ log_info("handleAction: sendCloudEvent result", { code, error });
73
+
74
+ if (error) {
75
+ log_error("sendCloudEvent: error sending cloud event", { error });
76
+
77
+ return ActionResult.Error;
78
+ }
79
+
80
+ if (code && code >= 200 && code < 300 && !error) {
81
+ log_info("sendCloudEvent: cloud event sent successfully");
82
+
83
+ return ActionResult.Success;
84
+ }
85
+ } catch (error) {
86
+ log_error("sendCloudEvent: error sending cloud event", {
87
+ action,
88
+ error,
89
+ });
90
+ }
91
+
92
+ return ActionResult.Error;
93
+ };
@@ -0,0 +1,19 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
3
+ import { batchRemoveFromStorage } from "../../zappFrameworkUtils/localStorageHelper";
4
+ import { ActionResult } from "../ActionExecutor";
5
+ import { ActionHandler } from "../types";
6
+ import { StorageRemoveOptions } from "./localStorageRemove";
7
+
8
+ /**
9
+ * Removes values from session storage organized by namespaces.
10
+ */
11
+ export const sessionStorageRemoveAction: ActionHandler<
12
+ StorageRemoveOptions
13
+ > = async (action): Promise<ActionResult> => {
14
+ const namespaces = action.options.content;
15
+ await batchRemoveFromStorage(namespaces, sessionStorage);
16
+ // TODO: Add support for ownershipKey and ownershipNamespace
17
+
18
+ return ActionResult.Success;
19
+ };
@@ -0,0 +1,20 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
3
+ import { batchSave } from "../../zappFrameworkUtils/localStorageHelper";
4
+ import { ActionResult } from "../ActionExecutor";
5
+ import { ActionHandler } from "../types";
6
+ import { StorageSetOptions } from "./localStorageSet";
7
+
8
+ /**
9
+ * Saves values to session storage organized by namespaces.
10
+ * The values persist only for the current app session.
11
+ */
12
+ export const sessionStorageSetAction: ActionHandler<StorageSetOptions> = async (
13
+ action
14
+ ): Promise<ActionResult> => {
15
+ const namespaces = (action.options as StorageSetOptions).content;
16
+ await batchSave(namespaces, sessionStorage);
17
+ // TODO: Add support for ownershipKey and ownershipNamespace
18
+
19
+ return ActionResult.Success;
20
+ };
@@ -0,0 +1,15 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { sessionStorageToggleFlag } from "../StorageActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+ import { StorageToggleFlagOptions } from "./localStorageToggleFlag";
6
+
7
+ /**
8
+ * Toggles a flag in session storage (adds or removes an item from a collection).
9
+ * Values persist only for the current app session.
10
+ */
11
+ export const sessionStorageToggleFlagAction: ActionHandler<
12
+ StorageToggleFlagOptions
13
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
14
+ return await sessionStorageToggleFlag(context, action);
15
+ };