@applicaster/zapp-react-native-utils 16.0.0-alpha.1042942411 → 16.0.0-alpha.1052711356

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 (41) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +4 -0
  2. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +22 -0
  3. package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
  4. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +76 -0
  5. package/actionsExecutor/actions/__tests__/showToast.test.ts +63 -0
  6. package/actionsExecutor/actions/dismissBottomSheet.ts +22 -0
  7. package/actionsExecutor/actions/index.ts +4 -0
  8. package/actionsExecutor/actions/openBottomSheet.ts +318 -0
  9. package/actionsExecutor/actions/refreshComponent.ts +6 -0
  10. package/actionsExecutor/actions/sendCloudEvent.ts +8 -0
  11. package/actionsExecutor/actions/showToast.ts +7 -7
  12. package/arrayUtils/__tests__/{anyThruthy.test.ts → anyTruthy.test.ts} +8 -0
  13. package/arrayUtils/__tests__/arrayUtils.test.ts +165 -108
  14. package/arrayUtils/__tests__/isEmptyArray.test.ts +11 -0
  15. package/arrayUtils/__tests__/isFilledArray.test.ts +12 -0
  16. package/arrayUtils/__tests__/isFirst.test.ts +17 -0
  17. package/arrayUtils/__tests__/isIndexInRange.test.ts +14 -0
  18. package/arrayUtils/__tests__/isLast.test.ts +31 -0
  19. package/arrayUtils/__tests__/makeListOf.test.ts +31 -0
  20. package/arrayUtils/__tests__/makeListOfIndexes.test.ts +20 -0
  21. package/arrayUtils/__tests__/sample.test.ts +61 -0
  22. package/arrayUtils/index.ts +57 -20
  23. package/modalState/ContentViewModel.ts +111 -0
  24. package/modalState/EditableCollection.ts +17 -0
  25. package/modalState/EditableCollectionRegistry.ts +51 -0
  26. package/modalState/ModalOrchestrator.ts +198 -0
  27. package/modalState/RemoteEditableCollection.ts +189 -0
  28. package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
  29. package/modalState/__tests__/ContentViewModel.test.ts +165 -0
  30. package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
  31. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +28 -0
  32. package/modalState/__tests__/RemoteEditableCollection.test.ts +259 -0
  33. package/modalState/__tests__/useBottomSheetContent.test.ts +372 -0
  34. package/modalState/index.ts +30 -83
  35. package/modalState/store.ts +102 -0
  36. package/modalState/types.ts +110 -0
  37. package/modalState/useBottomSheetContent.ts +98 -0
  38. package/package.json +2 -2
  39. package/zappFrameworkUtils/__tests__/localStorageHelper.test.ts +146 -0
  40. package/zappFrameworkUtils/localStorageHelper.ts +9 -13
  41. /package/reactHooks/actions/__tests__/{index.test.js → index.test.tsx} +0 -0
@@ -19,9 +19,11 @@ import {
19
19
  appRestartAction,
20
20
  confirmDialogAction,
21
21
  createNavigateToScreenAction,
22
+ dismissBottomSheetAction,
22
23
  localStorageRemoveAction,
23
24
  localStorageSetAction,
24
25
  localStorageToggleFlagAction,
26
+ openBottomSheetAction,
25
27
  refreshComponentAction,
26
28
  screenSetVariableAction,
27
29
  screenToggleFlagAction,
@@ -90,6 +92,8 @@ const prepareDefaultActions = (actionExecutor) => {
90
92
 
91
93
  actionExecutor.registerAction("screenSetVariable", screenSetVariableAction);
92
94
  actionExecutor.registerAction("screenToggleFlag", screenToggleFlagAction);
95
+ actionExecutor.registerAction("openBottomSheet", openBottomSheetAction);
96
+ actionExecutor.registerAction("dismissBottomSheet", dismissBottomSheetAction);
93
97
  actionExecutor.registerAction("showToast", showToastAction);
94
98
  };
95
99
 
@@ -0,0 +1,22 @@
1
+ import { dismissBottomSheetAction } from "../dismissBottomSheet";
2
+ import { dismissModal } from "../../../modalState";
3
+ import { ActionResult } from "../../ActionExecutor";
4
+
5
+ jest.mock("../../../modalState", () => ({
6
+ dismissModal: jest.fn(),
7
+ }));
8
+
9
+ describe("dismissBottomSheetAction", () => {
10
+ beforeEach(() => {
11
+ jest.clearAllMocks();
12
+ });
13
+
14
+ it("calls dismissModal and returns ActionResult.Success", async () => {
15
+ const result = await dismissBottomSheetAction({
16
+ type: "dismissBottomSheet",
17
+ });
18
+
19
+ expect(dismissModal).toHaveBeenCalledTimes(1);
20
+ expect(result).toBe(ActionResult.Success);
21
+ });
22
+ });
@@ -0,0 +1,88 @@
1
+ import { loadItemsFromSource } from "../openBottomSheet";
2
+
3
+ const mockCall = jest.fn();
4
+
5
+ jest.mock("@applicaster/zapp-pipes-v2-client", () => ({
6
+ RequestBuilder: jest.fn().mockImplementation(() => ({
7
+ setEntryContext: jest.fn().mockReturnThis(),
8
+ setScreenContext: jest.fn().mockReturnThis(),
9
+ setUrl: jest.fn().mockReturnThis(),
10
+ buildAxiosRequest: jest.fn().mockResolvedValue(undefined),
11
+ call: (...args: any[]) => mockCall(...args),
12
+ })),
13
+ PipesClientResponseHelper: jest.fn().mockImplementation(() => ({
14
+ error: null,
15
+ })),
16
+ }));
17
+
18
+ describe("loadItemsFromSource", () => {
19
+ beforeEach(() => {
20
+ jest.clearAllMocks();
21
+ });
22
+
23
+ it("returns items plus role and behavior from feed.extensions", async () => {
24
+ mockCall.mockResolvedValueOnce({
25
+ response: {
26
+ entry: [{ id: "a", title: "Playlist A", media_group: [] }],
27
+ extensions: {
28
+ role: "collection_selector",
29
+ behavior: {
30
+ select_mode: "multi",
31
+ current_selection: ["a"],
32
+ selector: "extensions.tag",
33
+ },
34
+ },
35
+ },
36
+ });
37
+
38
+ const result = await loadItemsFromSource("https://example.com/feed");
39
+
40
+ expect(result.role).toBe("collection_selector");
41
+
42
+ expect(result.behavior).toEqual({
43
+ selectMode: "multi",
44
+ currentSelection: ["a"],
45
+ selector: "extensions.tag",
46
+ });
47
+
48
+ expect(result.items).toHaveLength(1);
49
+ expect(result.items[0].isSelected).toBe(true);
50
+ expect(result.items[0].title).toBe("Playlist A");
51
+ });
52
+
53
+ it("returns undefined role/behavior when feed has no extensions", async () => {
54
+ mockCall.mockResolvedValueOnce({
55
+ response: {
56
+ entry: [{ id: "1", title: "Plain", media_group: [] }],
57
+ },
58
+ });
59
+
60
+ const result = await loadItemsFromSource("https://example.com/plain");
61
+
62
+ expect(result.role).toBeUndefined();
63
+ expect(result.behavior).toBeUndefined();
64
+ expect(result.items).toHaveLength(1);
65
+ });
66
+
67
+ it("preserves events in dynamic_collection_options", async () => {
68
+ mockCall.mockResolvedValueOnce({
69
+ response: {
70
+ entry: [],
71
+ extensions: {
72
+ dynamic_collection_options: {
73
+ operations: "add,remove",
74
+ events: {
75
+ add: [{ type: "showTextInput", options: {} }],
76
+ },
77
+ },
78
+ },
79
+ },
80
+ });
81
+
82
+ const result = await loadItemsFromSource("https://example.com/feed");
83
+
84
+ expect(result.dynamicCollection?.events).toEqual({
85
+ add: [{ type: "showTextInput", options: {} }],
86
+ });
87
+ });
88
+ });
@@ -0,0 +1,76 @@
1
+ import { openBottomSheetAction } from "../openBottomSheet";
2
+ import { ActionResult } from "../../ActionExecutor";
3
+ import { openBottomSheetModal } from "../../../modalState/store";
4
+ import { modalOrchestrator } from "../../../modalState/ModalOrchestrator";
5
+
6
+ jest.mock("../../../modalState/store", () => ({
7
+ openBottomSheetModal: jest.fn(),
8
+ }));
9
+
10
+ jest.mock("../../../modalState/ModalOrchestrator", () => ({
11
+ modalOrchestrator: {
12
+ open: jest.fn(),
13
+ },
14
+ isPresentSubMenuAction: jest.requireActual("../../../modalState/types")
15
+ .isPresentSubMenuAction,
16
+ }));
17
+
18
+ describe("openBottomSheetAction custom content", () => {
19
+ beforeEach(() => {
20
+ jest.clearAllMocks();
21
+ });
22
+
23
+ it("opens default sheet with contentComponent body props", async () => {
24
+ const CustomContent = function CustomContent() {
25
+ return null;
26
+ };
27
+
28
+ const result = await openBottomSheetAction({
29
+ type: "openBottomSheet",
30
+ options: {
31
+ header: { title: "Create Playlist" },
32
+ content: {
33
+ component: CustomContent,
34
+ props: {
35
+ inputLabel: "Name your playlist",
36
+ buttonLabel: "Create",
37
+ defaultValue: "",
38
+ submitAction: { type: "sendCloudEvent", options: {} },
39
+ },
40
+ },
41
+ },
42
+ } as any);
43
+
44
+ expect(result).toBe(ActionResult.Success);
45
+ expect(openBottomSheetModal).toHaveBeenCalledTimes(1);
46
+ expect(modalOrchestrator.open).not.toHaveBeenCalled();
47
+
48
+ const args = (openBottomSheetModal as jest.Mock).mock.calls[0][0];
49
+ // Default ModalComponent provides the standard header
50
+ expect(args.ModalBottomSheetContent).toBeUndefined();
51
+
52
+ expect(args.modalBottomSheetContentProps).toMatchObject({
53
+ title: "Create Playlist",
54
+ contentComponent: CustomContent,
55
+ contentComponentProps: {
56
+ inputLabel: "Name your playlist",
57
+ buttonLabel: "Create",
58
+ defaultValue: "",
59
+ },
60
+ });
61
+ });
62
+
63
+ it("returns Error when neither list data nor content.component is provided", async () => {
64
+ const result = await openBottomSheetAction({
65
+ type: "openBottomSheet",
66
+ options: {
67
+ header: { title: "Empty" },
68
+ content: {},
69
+ },
70
+ } as any);
71
+
72
+ expect(result).toBe(ActionResult.Error);
73
+ expect(openBottomSheetModal).not.toHaveBeenCalled();
74
+ expect(modalOrchestrator.open).not.toHaveBeenCalled();
75
+ });
76
+ });
@@ -0,0 +1,63 @@
1
+ import { showToastAction } from "../showToast";
2
+ import { postEvent } from "../../../reactHooks/useSubscriberFor";
3
+ import { ActionResult } from "../../ActionExecutor";
4
+
5
+ jest.mock("../../../reactHooks/useSubscriberFor", () => ({
6
+ postEvent: jest.fn(),
7
+ }));
8
+
9
+ describe("showToastAction", () => {
10
+ beforeEach(() => {
11
+ jest.clearAllMocks();
12
+ });
13
+
14
+ it("calls postEvent with showToast payload and returns ActionResult.Success", async () => {
15
+ const action = {
16
+ type: "showToast",
17
+ options: {
18
+ id: "toast-1",
19
+ message: "Added to queue",
20
+ extraMessage: "Extra info",
21
+ timeout: 3000,
22
+ },
23
+ };
24
+
25
+ const result = await showToastAction(action);
26
+
27
+ expect(postEvent).toHaveBeenCalledTimes(1);
28
+
29
+ expect(postEvent).toHaveBeenCalledWith("showToast", [
30
+ {
31
+ id: "toast-1",
32
+ message: "Added to queue",
33
+ extraMessage: "Extra info",
34
+ style: undefined,
35
+ timeout: 3000,
36
+ },
37
+ ]);
38
+
39
+ expect(result).toBe(ActionResult.Success);
40
+ });
41
+
42
+ it("handles missing or empty options without throwing", async () => {
43
+ const action = {
44
+ type: "showToast",
45
+ };
46
+
47
+ const result = await showToastAction(action);
48
+
49
+ expect(postEvent).toHaveBeenCalledTimes(1);
50
+
51
+ expect(postEvent).toHaveBeenCalledWith("showToast", [
52
+ {
53
+ id: undefined,
54
+ message: undefined,
55
+ extraMessage: undefined,
56
+ style: undefined,
57
+ timeout: undefined,
58
+ },
59
+ ]);
60
+
61
+ expect(result).toBe(ActionResult.Success);
62
+ });
63
+ });
@@ -0,0 +1,22 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { dismissModal } from "../../modalState";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler } from "../types";
5
+ import { createLogger } from "../../logger";
6
+
7
+ const { log_info } = createLogger({
8
+ subsystem: "ActionExecutorContext",
9
+ category: "General",
10
+ });
11
+
12
+ /**
13
+ * Dismisses the active bottom sheet / modal.
14
+ */
15
+ export const dismissBottomSheetAction: ActionHandler<
16
+ any
17
+ > = async (): Promise<ActionResult> => {
18
+ log_info("handleAction: dismissBottomSheet");
19
+ dismissModal();
20
+
21
+ return ActionResult.Success;
22
+ };
@@ -28,3 +28,7 @@ export { screenToggleFlagAction } from "./screenToggleFlag";
28
28
  export { createNavigateToScreenAction } from "./navigateToScreen";
29
29
 
30
30
  export { showToastAction } from "./showToast";
31
+
32
+ export { openBottomSheetAction } from "./openBottomSheet";
33
+
34
+ export { dismissBottomSheetAction } from "./dismissBottomSheet";
@@ -0,0 +1,318 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import {
3
+ PipesClientResponseHelper,
4
+ RequestBuilder,
5
+ } from "@applicaster/zapp-pipes-v2-client";
6
+ import { modalOrchestrator } from "../../modalState/ModalOrchestrator";
7
+ import { openBottomSheetModal } from "../../modalState/store";
8
+ import {
9
+ DynamicCollectionOptions,
10
+ isPresentSubMenuAction,
11
+ Menu,
12
+ MenuItem,
13
+ Operation,
14
+ SelectionBehavior,
15
+ } from "../../modalState/types";
16
+ import { actionExecutor, ActionResult } from "../ActionExecutor";
17
+ import { createLogger } from "../../logger";
18
+
19
+ const { log_info, log_error } = createLogger({
20
+ subsystem: "ActionExecutorContext",
21
+ category: "General",
22
+ });
23
+
24
+ export type LoadedSheetContent = {
25
+ items: MenuItem[];
26
+ role?: string;
27
+ behavior?: SelectionBehavior;
28
+ dynamicCollection?: DynamicCollectionOptions;
29
+ };
30
+
31
+ /**
32
+ * Parse a raw `dynamic_collection_options` block (feed or inline content) into
33
+ * the typed `DynamicCollectionOptions`. `operations` accepts either a CSV
34
+ * string (feed) or an array (already parsed).
35
+ */
36
+ export function parseDynamicCollectionOptions(
37
+ raw:
38
+ | {
39
+ operations?: string | string[];
40
+ postUrl?: string;
41
+ provider?: string;
42
+ events?: Record<string, any[]>;
43
+ }
44
+ | undefined
45
+ ): DynamicCollectionOptions | undefined {
46
+ if (!raw) {
47
+ return undefined;
48
+ }
49
+
50
+ const operations = Array.isArray(raw.operations)
51
+ ? (raw.operations as Operation[])
52
+ : ((raw.operations || "").split(",").filter(Boolean) as Operation[]);
53
+
54
+ return {
55
+ operations,
56
+ postUrl: raw.postUrl,
57
+ provider: raw.provider,
58
+ events: raw.events,
59
+ };
60
+ }
61
+
62
+ /**
63
+ * Converts a ZappEntry from a pipes feed into a MenuItem.
64
+ * - Icon: first src found in the image media_group.
65
+ * - Primary action: taken from tap_actions.actions[0].
66
+ * - isSelected: true when entry.id is in currentSelection.
67
+ */
68
+ export function entryToMenuItem(
69
+ entry: ZappEntry,
70
+ currentSelection: string[] = []
71
+ ): MenuItem {
72
+ const imageGroup = entry.media_group?.find((g) => g.type === "image");
73
+
74
+ const firstImage = Array.isArray(imageGroup?.media_item)
75
+ ? imageGroup.media_item[0]
76
+ : imageGroup?.media_item;
77
+
78
+ // Primary action — first tap_action on the entry
79
+ const tapActions = entry.extensions?.tap_actions?.actions || [];
80
+ const primaryAction = tapActions.length > 0 ? tapActions[0] : undefined;
81
+
82
+ let summary = entry.summary as string;
83
+
84
+ // TODO: remove just a small logic for debugging
85
+
86
+ if (
87
+ !summary &&
88
+ entry.extensions &&
89
+ typeof entry.extensions.item_count === "number"
90
+ ) {
91
+ const count = entry.extensions.item_count;
92
+ summary = `${count} ${count === 1 ? "Item" : "Items"}`;
93
+ }
94
+
95
+ return {
96
+ id: entry.id as string,
97
+ title: entry.title as string,
98
+ summary,
99
+ icon: firstImage?.src,
100
+ isSelected: currentSelection.includes(String(entry.id)),
101
+ action: primaryAction,
102
+ entryActions: entry.extensions?.entry_action || [],
103
+ };
104
+ }
105
+
106
+ function parseCurrentSelection(rawSelection: unknown): string[] {
107
+ if (Array.isArray(rawSelection)) {
108
+ return (rawSelection as any[]).map(String);
109
+ }
110
+
111
+ if (rawSelection !== undefined && rawSelection !== null) {
112
+ return [String(rawSelection)];
113
+ }
114
+
115
+ return [];
116
+ }
117
+
118
+ function parseBehaviorFromFeed(
119
+ feed: ZappFeed | undefined,
120
+ currentSelection: string[]
121
+ ): SelectionBehavior | undefined {
122
+ const raw = feed?.extensions?.behavior;
123
+
124
+ if (!raw && currentSelection.length === 0) {
125
+ return undefined;
126
+ }
127
+
128
+ return {
129
+ selectMode: raw?.select_mode,
130
+ currentSelection,
131
+ selector: raw?.selector,
132
+ };
133
+ }
134
+
135
+ function parseBehaviorFromContentOptions(
136
+ content: Record<string, any> | undefined
137
+ ): SelectionBehavior | undefined {
138
+ const raw = content?.behavior ?? content?.extensions?.behavior;
139
+
140
+ if (!raw) {
141
+ return undefined;
142
+ }
143
+
144
+ return {
145
+ selectMode: raw.selectMode ?? raw.select_mode,
146
+ currentSelection: parseCurrentSelection(
147
+ raw.currentSelection ?? raw.current_selection
148
+ ),
149
+ selector: raw.selector,
150
+ };
151
+ }
152
+
153
+ // Exported so MultiLevelBottomSheetContent can lazy-load sub-levels
154
+ export async function loadItemsFromSource(
155
+ source: string,
156
+ context?: Record<string, any>
157
+ ): Promise<LoadedSheetContent> {
158
+ const requestBuilder = new RequestBuilder()
159
+ .setEntryContext(context?.entry || {})
160
+ .setScreenContext(context?.screenData || {})
161
+ .setUrl(source);
162
+
163
+ await requestBuilder.buildAxiosRequest();
164
+
165
+ const responseData = await requestBuilder.call<ZappFeed>();
166
+
167
+ const responseHelper = new PipesClientResponseHelper(responseData);
168
+
169
+ if (responseHelper.error) {
170
+ throw responseHelper.error;
171
+ }
172
+
173
+ const feed = responseData?.response as ZappFeed;
174
+
175
+ const currentSelection = parseCurrentSelection(
176
+ feed?.extensions?.behavior?.current_selection
177
+ );
178
+
179
+ const items = (feed?.entry || []).map((entry) =>
180
+ entryToMenuItem(entry, currentSelection)
181
+ );
182
+
183
+ const dynamicCollectionOptions = feed?.extensions?.dynamic_collection_options;
184
+
185
+ const dynamicCollection = parseDynamicCollectionOptions(
186
+ dynamicCollectionOptions
187
+ );
188
+
189
+ return {
190
+ items,
191
+ role: feed?.extensions?.role,
192
+ behavior: parseBehaviorFromFeed(feed, currentSelection),
193
+ dynamicCollection,
194
+ };
195
+ }
196
+
197
+ export async function openBottomSheetAction(
198
+ action: ActionType,
199
+ context?: Record<string, any>
200
+ ): Promise<ActionResult> {
201
+ try {
202
+ const { content, header } = action.options || {};
203
+
204
+ // Custom body component — keep default ModalComponent so standard header
205
+ // (dismiss x) is used; content.component is body-only (e.g. TextInputContent).
206
+ if (content?.component) {
207
+ log_info("openBottomSheet: using custom content component");
208
+
209
+ openBottomSheetModal({
210
+ modalBottomSheetContentProps: {
211
+ title: header?.title,
212
+ summary: header?.subtitle,
213
+ items: [],
214
+ onPress: () => {},
215
+ contentComponent: content.component,
216
+ contentComponentProps: content.props || {},
217
+ },
218
+ });
219
+
220
+ return ActionResult.Success;
221
+ }
222
+
223
+ const inlineItems: ZappEntry[] = content?.items;
224
+ const itemsUrl: string = content?.itemsUrl;
225
+
226
+ let items: MenuItem[];
227
+ let role: string | undefined;
228
+ let behavior: SelectionBehavior | undefined;
229
+
230
+ let dynamicCollection: DynamicCollectionOptions | undefined;
231
+
232
+ if (Array.isArray(inlineItems) && inlineItems.length > 0) {
233
+ log_info("openBottomSheet: using inline items from action options", {
234
+ count: inlineItems.length,
235
+ });
236
+
237
+ items = inlineItems.map((entry) => entryToMenuItem(entry));
238
+ role = content?.role ?? content?.extensions?.role;
239
+ behavior = parseBehaviorFromContentOptions(content);
240
+
241
+ dynamicCollection = parseDynamicCollectionOptions(
242
+ content?.dynamicCollection ??
243
+ content?.extensions?.dynamic_collection_options
244
+ );
245
+ } else if (itemsUrl) {
246
+ log_info(`openBottomSheet: loading items from source: ${itemsUrl}`);
247
+
248
+ const loaded = await loadItemsFromSource(itemsUrl, context);
249
+ items = loaded.items;
250
+ role = loaded.role ?? content?.role ?? content?.extensions?.role;
251
+ behavior = loaded.behavior ?? parseBehaviorFromContentOptions(content);
252
+ dynamicCollection = loaded.dynamicCollection;
253
+
254
+ log_info(
255
+ `openBottomSheet: loaded ${items.length} items from source: ${itemsUrl}`
256
+ );
257
+ } else {
258
+ log_error(
259
+ "openBottomSheet: no itemsUrl, items, or content.component provided in action options"
260
+ );
261
+
262
+ return ActionResult.Error;
263
+ }
264
+
265
+ const menu: Menu = {
266
+ header: header
267
+ ? {
268
+ title: header.title,
269
+ subtitle: header.subtitle,
270
+ icon: header.icon,
271
+ }
272
+ : undefined,
273
+ content: {
274
+ title: content?.title ?? "",
275
+ items,
276
+ itemsUrl, // stored so the component can reload after an action
277
+ role,
278
+ behavior,
279
+ dynamicCollection,
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
+ if (!item.action || isPresentSubMenuAction(item.action)) {
294
+ // Submenu navigation is handled internally by the orchestrator
295
+ return;
296
+ }
297
+
298
+ await actionExecutor.handleAction(
299
+ item.action as ActionType,
300
+ {
301
+ ...context,
302
+ entry: item as any,
303
+ } as any
304
+ );
305
+ };
306
+
307
+ modalOrchestrator.open(menu, onItemPress);
308
+
309
+ return ActionResult.Success;
310
+ } catch (error) {
311
+ log_error("openBottomSheet: failed to open bottom sheet", {
312
+ error,
313
+ action,
314
+ });
315
+
316
+ return ActionResult.Error;
317
+ }
318
+ }
@@ -57,6 +57,12 @@ export const refreshComponentAction: ActionHandler = async (
57
57
  }) || source;
58
58
  }
59
59
 
60
+ if (!dataSource) {
61
+ log_info("handleAction: refreshComponent skipped: no dataSource found");
62
+
63
+ return ActionResult.Success;
64
+ }
65
+
60
66
  log_info(`handleAction: refreshComponent for dataSource:${dataSource}`, {
61
67
  source,
62
68
  inflatedUrl: dataSource,
@@ -62,10 +62,18 @@ export const sendCloudEventAction: ActionHandler<
62
62
  subject: options.subject || String((entry as ZappEntry)?.id || ""),
63
63
  });
64
64
 
65
+ console.log(
66
+ "[sendCloudEvent] sending event to URL:",
67
+ options.url,
68
+ cloudEvent
69
+ );
70
+
65
71
  log_info("handleAction: sendCloudEvent event", { cloudEvent });
66
72
 
67
73
  const { error, code } = await sendCloudEvent(cloudEvent, options.url);
68
74
 
75
+ console.log("[sendCloudEvent] result code:", code, "error:", error);
76
+
69
77
  if (error) {
70
78
  log_error("sendCloudEvent: error sending cloud event", { error });
71
79
 
@@ -7,8 +7,8 @@ import { postEvent } from "../../reactHooks/useSubscriberFor";
7
7
  * Options for showToast action.
8
8
  */
9
9
  export interface ShowToastActionOptions {
10
- id: string;
11
- message: string;
10
+ id?: string;
11
+ message?: string;
12
12
  extraMessage?: string;
13
13
  style?: any;
14
14
  timeout?: number;
@@ -19,11 +19,11 @@ export const showToastAction: ActionHandler<ShowToastActionOptions> = async (
19
19
  ): Promise<ActionResult> => {
20
20
  postEvent("showToast", [
21
21
  {
22
- id: action.options.id,
23
- message: action.options.message,
24
- extraMessage: action.options.extraMessage,
25
- style: action.options.style,
26
- timeout: action.options.timeout,
22
+ id: action?.options?.id,
23
+ message: action?.options?.message,
24
+ extraMessage: action?.options?.extraMessage,
25
+ style: action?.options?.style,
26
+ timeout: action?.options?.timeout,
27
27
  },
28
28
  ]);
29
29
 
@@ -21,4 +21,12 @@ describe("anyTruthy", () => {
21
21
  expect(anyTruthy([true])).toBe(true);
22
22
  expect(anyTruthy([false])).toBe(false);
23
23
  });
24
+
25
+ it("should return true when the first value is true", () => {
26
+ expect(anyTruthy([true, false, false])).toBe(true);
27
+ });
28
+
29
+ it("should return true when only the last value is true", () => {
30
+ expect(anyTruthy([false, false, true])).toBe(true);
31
+ });
24
32
  });