@applicaster/zapp-react-native-utils 16.0.0-alpha.8901714553 → 16.0.0-alpha.9530606740

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 (60) hide show
  1. package/actionsExecutor/ActionExecutor.ts +8 -10
  2. package/actionsExecutor/ActionExecutorContext.tsx +41 -325
  3. package/actionsExecutor/actions/appRestart.ts +24 -0
  4. package/actionsExecutor/actions/confirmDialog.ts +53 -0
  5. package/actionsExecutor/actions/index.ts +30 -0
  6. package/actionsExecutor/actions/localStorageRemove.ts +27 -0
  7. package/actionsExecutor/actions/localStorageSet.ts +28 -0
  8. package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
  9. package/actionsExecutor/actions/navigateToScreen.ts +123 -0
  10. package/actionsExecutor/actions/openBottomSheet.ts +177 -0
  11. package/actionsExecutor/actions/refreshComponent.ts +79 -0
  12. package/actionsExecutor/actions/screenSetVariable.ts +35 -0
  13. package/actionsExecutor/actions/screenToggleFlag.ts +38 -0
  14. package/actionsExecutor/actions/sendCloudEvent.ts +88 -0
  15. package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
  16. package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
  17. package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
  18. package/actionsExecutor/actions/switchLayout.ts +40 -0
  19. package/actionsExecutor/types.ts +59 -0
  20. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -1
  21. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +1 -1
  22. package/appUtils/contextKeysManager/__tests__/setKey/failure/invalidKey.test.ts +4 -4
  23. package/appUtils/contextKeysManager/index.ts +1 -1
  24. package/cellUtils/index.ts +3 -5
  25. package/colorUtils/__tests__/isTransparentColor.test.ts +76 -0
  26. package/colorUtils/__tests__/isValidColor.test.ts +70 -0
  27. package/colorUtils/index.ts +50 -0
  28. package/manifestUtils/_internals/index.js +6 -0
  29. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +84 -0
  30. package/manifestUtils/fieldUtils/index.js +125 -0
  31. package/manifestUtils/keys.js +9 -0
  32. package/manifestUtils/mobileAction/button/index.js +16 -0
  33. package/manifestUtils/mobileAction/container/index.js +3 -1
  34. package/manifestUtils/mobileAction/groups/defaults.js +3 -1
  35. package/manifestUtils/platformIsTV.js +1 -0
  36. package/modalState/ContentViewModel.ts +59 -0
  37. package/modalState/ModalOrchestrator.ts +204 -0
  38. package/modalState/__tests__/ContentViewModel.test.ts +107 -0
  39. package/modalState/components/ActionItem.tsx +155 -0
  40. package/modalState/components/BottomSheetHeader.tsx +245 -0
  41. package/modalState/components/PrimaryButton.tsx +54 -0
  42. package/modalState/components/TrackItem.tsx +241 -0
  43. package/modalState/index.ts +25 -74
  44. package/modalState/store.ts +102 -0
  45. package/modalState/types.ts +55 -0
  46. package/package.json +2 -2
  47. package/pipesUtils/__tests__/buildUrlWithQuery.test.ts +33 -0
  48. package/pipesUtils/__tests__/withPipesEndpoint.test.tsx +56 -0
  49. package/pipesUtils/index.ts +1 -0
  50. package/pipesUtils/withPipesEndpoint.tsx +54 -0
  51. package/reactHooks/actions/index.ts +51 -1
  52. package/reactHooks/cell-click/index.ts +3 -3
  53. package/reactHooks/feed/__mocks__/useMarkPipesDataStale.ts +4 -0
  54. package/reactHooks/feed/index.ts +5 -1
  55. package/reactHooks/feed/useBatchLoading.ts +9 -1
  56. package/reactHooks/feed/{usePipesCacheReset.ts → useMarkPipesDataStale.ts} +12 -4
  57. package/reactHooks/utils/index.ts +3 -2
  58. package/riverComponetsMeasurementProvider/index.tsx +12 -8
  59. package/uiActionsRegistrator/index.ts +203 -0
  60. package/reactHooks/feed/__mocks__/usePipesCacheReset.ts +0 -1
@@ -1,4 +1,5 @@
1
1
  import { createLogger } from "../logger";
2
+ import type { ActionExecutionContext, ActionHandler } from "./types";
2
3
 
3
4
  export enum ActionResult {
4
5
  Success = "success",
@@ -12,12 +13,12 @@ const { log_error, log_debug, log_info } = createLogger({
12
13
  });
13
14
 
14
15
  class ActionExecutor {
15
- private registeredActions: Record<string, any> = {};
16
- // TODO: Remove context
16
+ private registeredActions: Record<string, ActionHandler> = {};
17
17
 
18
+ // TODO: Remove context
18
19
  handleAction = async (
19
20
  action: ActionType,
20
- context?: Record<string, any>
21
+ context?: ActionExecutionContext
21
22
  ): Promise<ActionResult> => {
22
23
  const handler = this.registeredActions[action.type];
23
24
  const entry = context?.entry as ZappEntry;
@@ -52,7 +53,7 @@ class ActionExecutor {
52
53
 
53
54
  handleActions = async (
54
55
  actionTypes: ActionType[],
55
- context?: Record<string, any>
56
+ context?: ActionExecutionContext
56
57
  ): Promise<ActionResult> => {
57
58
  for (const action of actionTypes) {
58
59
  // TODO: Handle action result error
@@ -70,7 +71,7 @@ class ActionExecutor {
70
71
 
71
72
  handleEntryActions = async (
72
73
  entry: ZappEntry,
73
- context?: Record<string, any>
74
+ context?: ActionExecutionContext
74
75
  ): Promise<ActionResult> => {
75
76
  const tapActions = entry.extensions?.tap_actions?.actions;
76
77
 
@@ -98,12 +99,9 @@ class ActionExecutor {
98
99
  delete this.registeredActions[actionType];
99
100
  };
100
101
 
101
- registerAction = (
102
+ registerAction = <TOptions = Record<string, any>>(
102
103
  type: string,
103
- handler: (
104
- action: ActionType,
105
- context?: Record<string, any>
106
- ) => Promise<ActionResult>
104
+ handler: ActionHandler<TOptions>
107
105
  ) => {
108
106
  if (this.registeredActions[type]) {
109
107
  log_error(`registerAction: action type: ${type} already registered`);
@@ -5,39 +5,33 @@ import {
5
5
  actionExecutor as _actionExecutor,
6
6
  ActionResult,
7
7
  } from "./ActionExecutor";
8
- import {
9
- batchRemoveAllFromNamespaceForStorage,
10
- batchSave,
11
- } from "../zappFrameworkUtils/localStorageHelper";
8
+ import { ActionExecutionContext, ActionHandler } from "./types";
9
+ import { batchRemoveAllFromNamespaceForStorage } from "../zappFrameworkUtils/localStorageHelper";
12
10
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
13
11
 
14
- import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
15
- import { QUICK_BRICK_EVENTS } from "@applicaster/zapp-react-native-bridge/QuickBrick";
16
- import { showConfirmationDialog } from "../alertUtils";
17
- import { createCloudEvent, sendCloudEvent } from "../cloudEventsUtils";
18
- import { createLogger } from "../logger";
19
- import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "@applicaster/quick-brick-core/App/remoteContextReloader/consts";
20
- import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
21
- import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
22
- import {
23
- EntryResolver,
24
- resolveObjectValues,
25
- } from "../appUtils/contextKeysManager/contextResolver";
26
12
  import { useNavigation, useRivers } from "../reactHooks";
27
- import {
28
- getInflatedDataSourceUrl,
29
- getSearchContext,
30
- } from "../reactHooks/feed/useInflatedUrl";
31
-
32
13
  import { useContentTypes } from "@applicaster/zapp-react-native-redux/hooks";
33
14
  import { useSubscriberFor } from "../reactHooks/useSubscriberFor";
34
15
  import { APP_EVENTS } from "../appUtils/events";
35
- import {
36
- localStorageToggleFlag,
37
- sessionStorageToggleFlag,
38
- } from "./StorageActions";
16
+ import { createLogger } from "../logger";
39
17
 
40
- import { screenSetVariable, screenToggleFlag } from "./ScreenActions";
18
+ import {
19
+ appRestartAction,
20
+ confirmDialogAction,
21
+ createNavigateToScreenAction,
22
+ localStorageRemoveAction,
23
+ localStorageSetAction,
24
+ localStorageToggleFlagAction,
25
+ openBottomSheetAction,
26
+ refreshComponentAction,
27
+ screenSetVariableAction,
28
+ screenToggleFlagAction,
29
+ sendCloudEventAction,
30
+ sessionStorageRemoveAction,
31
+ sessionStorageSetAction,
32
+ sessionStorageToggleFlagAction,
33
+ switchLayoutAction,
34
+ } from "./actions";
41
35
 
42
36
  export const { log_error, log_info, log_debug } = createLogger({
43
37
  subsystem: "ActionExecutorContext",
@@ -45,25 +39,22 @@ export const { log_error, log_info, log_debug } = createLogger({
45
39
  });
46
40
 
47
41
  export type ActionExecutorContextType = {
48
- registerAction: (
42
+ registerAction: <TOptions = Record<string, any>>(
49
43
  type: string,
50
- handler: (
51
- action: ActionType,
52
- context?: Record<string, any>
53
- ) => Promise<ActionResult>
44
+ handler: ActionHandler<TOptions>
54
45
  ) => void;
55
46
  unregisterAction: (type: string) => void;
56
47
  handleAction: (
57
48
  action: ActionType,
58
- context?: Record<string, any>
49
+ context?: ActionExecutionContext
59
50
  ) => Promise<ActionResult>;
60
51
  handleActions: (
61
52
  actions: ActionType[],
62
- context: Record<string, any>
53
+ context?: ActionExecutionContext
63
54
  ) => Promise<ActionResult>;
64
55
  handleEntryActions: (
65
56
  entry: ZappEntry,
66
- context?: Record<string, any>
57
+ context?: ActionExecutionContext
67
58
  ) => Promise<ActionResult>;
68
59
  };
69
60
 
@@ -71,235 +62,35 @@ type Props = {
71
62
  children: React.ReactNode;
72
63
  };
73
64
 
74
- function findParentComponent(
75
- childId: string,
76
- parent: ZappRiver | ZappUIComponent
77
- ): ZappRiver | ZappUIComponent | null {
78
- for (const child of parent.ui_components) {
79
- if (child.id === childId) return parent;
80
-
81
- if (child.ui_components) {
82
- const found = findParentComponent(childId, child);
83
- if (found) return found;
84
- }
85
- }
86
-
87
- return null;
88
- }
89
-
90
65
  const prepareDefaultActions = (actionExecutor) => {
91
- actionExecutor.registerAction("localStorageSet", async (action) => {
92
- const namespaces = action.options.content;
93
- await batchSave(namespaces, localStorage);
94
- // TODO: Add support for ownershipKey and ownershipNamespace
95
-
96
- return ActionResult.Success;
97
- });
98
-
99
- actionExecutor.registerAction("sessionStorageSet", async (action) => {
100
- const namespaces = action.options.content;
101
- await batchSave(namespaces, sessionStorage);
102
- // TODO: Add support for ownershipKey and ownershipNamespace
103
-
104
- return ActionResult.Success;
105
- });
66
+ actionExecutor.registerAction("localStorageSet", localStorageSetAction);
67
+ actionExecutor.registerAction("sessionStorageSet", sessionStorageSetAction);
68
+ actionExecutor.registerAction("localStorageRemove", localStorageRemoveAction);
106
69
 
107
70
  actionExecutor.registerAction(
108
- "refreshComponent",
109
- async (_action, context) => {
110
- const dispatch = appStore.getDispatch();
111
-
112
- const parentComponent = findParentComponent(
113
- context?.component?.id,
114
- context?.screenData
115
- );
116
-
117
- const componentSource = context?.component?.data?.source;
118
-
119
- const componentData = componentSource
120
- ? context.component.data
121
- : parentComponent?.data;
122
-
123
- const source = componentData?.source;
124
- const mapping = componentData?.mapping;
125
-
126
- let dataSource = source;
127
-
128
- if (source && mapping) {
129
- dataSource =
130
- getInflatedDataSourceUrl({
131
- source,
132
- contexts: {
133
- entry: context?.screenEntry,
134
- screen: context?.screenData,
135
- search: getSearchContext(null, mapping),
136
- },
137
- mapping,
138
- }) || source;
139
- }
140
-
141
- log_info(`handleAction: refreshComponent for dataSource:${dataSource}`, {
142
- source,
143
- inflatedUrl: dataSource,
144
- mapping,
145
- entryContextId: context?.entryContext?.id,
146
- entryId: context?.entry?.id,
147
- });
148
-
149
- // TODO: In theory we should wait callback to complete, before completing the action, but now it's not needed
150
- // TODO: handle focused item removal
151
- dispatch(
152
- loadPipesData(dataSource, {
153
- silentRefresh: false,
154
- clearCache: true,
155
- riverId: context?.screenData?.id,
156
- })
157
- );
158
-
159
- return ActionResult.Success;
160
- }
71
+ "sessionStorageRemove",
72
+ sessionStorageRemoveAction
161
73
  );
162
74
 
163
- actionExecutor.registerAction("switchLayout", async (action) => {
164
- log_info("handleAction: switchLayout event");
165
-
166
- await localStorage.setItem(
167
- ACTIVE_LAYOUT_ID_STORAGE_KEY,
168
- action.options.layoutId
169
- );
170
-
171
- QuickBrickManager.sendQuickBrickEvent(QUICK_BRICK_EVENTS.FORCE_APP_RELOAD);
172
-
173
- return ActionResult.Success;
174
- });
175
-
176
- actionExecutor.registerAction("appRestart", async () => {
177
- log_info(`handleAction: ${QUICK_BRICK_EVENTS.FORCE_APP_RELOAD} event`);
178
-
179
- QuickBrickManager.sendQuickBrickEvent(QUICK_BRICK_EVENTS.FORCE_APP_RELOAD);
180
-
181
- return ActionResult.Success;
182
- });
183
-
184
- actionExecutor.registerAction("confirmDialog", async (action) => {
185
- log_info("handleAction: confirmDialog event");
186
-
187
- return new Promise<ActionResult>((resolve) => {
188
- showConfirmationDialog({
189
- ...action.options,
190
- confirmCompletion: () => resolve(ActionResult.Success),
191
- cancelCompletion: () => resolve(ActionResult.Cancel),
192
- });
193
- });
194
- });
195
-
196
- actionExecutor.registerAction("sendCloudEvent", async (action, context) => {
197
- try {
198
- const options = action.options;
199
-
200
- const entry = context?.entry || {};
201
- const entryResolver = new EntryResolver(entry);
202
- const screenData = context?.screenStateStore?.getState().data || {};
203
- const screenResolver = new EntryResolver(screenData || {});
204
-
205
- const data =
206
- options?.data && options.inflateData
207
- ? await resolveObjectValues(options.data, {
208
- entry: entryResolver,
209
- screen: screenResolver,
210
- })
211
- : options?.data || entry;
212
-
213
- const cloudEvent = await createCloudEvent({
214
- type: options.type || "com.applicaster.selector.action.v1",
215
- data,
216
- subject: options.subject || entry?.id,
217
- });
218
-
219
- log_info("handleAction: sendCloudEvent event", { cloudEvent });
220
-
221
- const { error, code } = await sendCloudEvent(cloudEvent, options.url);
222
-
223
- if (error) {
224
- log_error("sendCloudEvent: error sending cloud event", { error });
225
-
226
- return ActionResult.Error;
227
- }
228
-
229
- if (code && code >= 200 && code < 300 && !error) {
230
- log_info("sendCloudEvent: cloud event sent successfully");
231
-
232
- return ActionResult.Success;
233
- }
234
- } catch (error) {
235
- log_error("sendCloudEvent: error sending cloud event", {
236
- action,
237
- error,
238
- });
239
- }
240
-
241
- return ActionResult.Error;
242
- });
75
+ actionExecutor.registerAction("refreshComponent", refreshComponentAction);
76
+ actionExecutor.registerAction("switchLayout", switchLayoutAction);
77
+ actionExecutor.registerAction("appRestart", appRestartAction);
78
+ actionExecutor.registerAction("confirmDialog", confirmDialogAction);
79
+ actionExecutor.registerAction("sendCloudEvent", sendCloudEventAction);
243
80
 
244
81
  actionExecutor.registerAction(
245
82
  "sessionStorageToggleFlag",
246
- async (
247
- action: ActionType,
248
- context?: Record<string, any>
249
- ): Promise<ActionResult> => {
250
- return await sessionStorageToggleFlag(context, action);
251
- }
83
+ sessionStorageToggleFlagAction
252
84
  );
253
85
 
254
86
  actionExecutor.registerAction(
255
87
  "localStorageToggleFlag",
256
- async (
257
- action: ActionType,
258
- context?: Record<string, any>
259
- ): Promise<ActionResult> => {
260
- return await localStorageToggleFlag(context, action);
261
- }
262
- );
263
-
264
- actionExecutor.registerAction(
265
- "screenSetVariable",
266
- async (
267
- action: ActionType,
268
- context?: Record<string, any>
269
- ): Promise<ActionResult> => {
270
- const route = context?.screenRoute;
271
- const screenStateStore = context?.screenStateStore;
272
-
273
- await screenSetVariable(
274
- route,
275
- screenStateStore,
276
- { entry: context?.entry, options: action.options },
277
- action
278
- );
279
-
280
- return Promise.resolve(ActionResult.Success);
281
- }
88
+ localStorageToggleFlagAction
282
89
  );
283
90
 
284
- actionExecutor.registerAction(
285
- "screenToggleFlag",
286
- async (
287
- action: ActionType,
288
- context?: Record<string, any>
289
- ): Promise<ActionResult> => {
290
- const screenRoute = context?.screenRoute;
291
- const screenStateStore = context?.screenStateStore;
292
-
293
- await screenToggleFlag(
294
- screenRoute,
295
- screenStateStore,
296
- { entry: context?.entry, options: action.options },
297
- action
298
- );
299
-
300
- return Promise.resolve(ActionResult.Success);
301
- }
302
- );
91
+ actionExecutor.registerAction("screenSetVariable", screenSetVariableAction);
92
+ actionExecutor.registerAction("screenToggleFlag", screenToggleFlagAction);
93
+ actionExecutor.registerAction("openBottomSheet", openBottomSheetAction);
303
94
  };
304
95
 
305
96
  export const ActionExecutorContext =
@@ -340,82 +131,7 @@ export function withActionExecutor(Component) {
340
131
  useEffect(() => {
341
132
  return _actionExecutor.registerAction(
342
133
  "navigateToScreen",
343
-
344
- async (action: ActionType, context?: Record<string, any>) => {
345
- const screenType = action.options?.typeMapping;
346
-
347
- if (!screenType) {
348
- log_error("navigateToScreen: typeMapping option is missing");
349
-
350
- return ActionResult.Error;
351
- }
352
-
353
- const navigationAction = action.options?.navigationAction;
354
- const entrySource = action.options?.entry;
355
-
356
- const entry = entrySource
357
- ? entrySource === "@{entry/}"
358
- ? context?.entry
359
- : entrySource
360
- : null;
361
-
362
- if (entry) {
363
- if (typeof entry !== "object") {
364
- log_error(
365
- `navigateToScreen: entry option is not an object, entry: ${entry}`
366
- );
367
-
368
- return ActionResult.Error;
369
- }
370
-
371
- log_info(
372
- `navigateToScreen: navigating to screen type: ${screenType} with entry id: ${entry.id}`
373
- );
374
-
375
- const overriddenEntry = {
376
- ...entry,
377
- type: {
378
- value: screenType,
379
- },
380
- };
381
-
382
- if (navigationAction === "push") {
383
- navigator.push(overriddenEntry);
384
- } else {
385
- navigator.replace(overriddenEntry);
386
- }
387
-
388
- return ActionResult.Success;
389
- }
390
-
391
- const screenId = contentTypes?.[screenType]?.screen_id || null;
392
-
393
- if (!screenId) {
394
- log_error(
395
- `navigateToScreen: can not resolve screen type mapping: ${screenType}`
396
- );
397
-
398
- return ActionResult.Error;
399
- }
400
-
401
- const river = rivers[screenId];
402
-
403
- if (!river) {
404
- log_error("navigateToScreen: can not resolve river");
405
-
406
- return ActionResult.Error;
407
- }
408
-
409
- context?.callback?.({ success: false, error: null, abort: true });
410
-
411
- if (navigationAction === "push") {
412
- navigator.push(river);
413
- } else {
414
- navigator.replace(river);
415
- }
416
-
417
- return ActionResult.Success;
418
- }
134
+ createNavigateToScreenAction(navigator, rivers, contentTypes)
419
135
  );
420
136
  }, [navigator, rivers, contentTypes]);
421
137
 
@@ -0,0 +1,24 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
3
+ import { QUICK_BRICK_EVENTS } from "@applicaster/zapp-react-native-bridge/QuickBrick";
4
+ import { ActionResult } from "../ActionExecutor";
5
+ import { ActionHandler } from "../types";
6
+ import { createLogger } from "../../logger";
7
+
8
+ const { log_info } = createLogger({
9
+ subsystem: "ActionExecutorContext",
10
+ category: "General",
11
+ });
12
+
13
+ /**
14
+ * Restarts the application by triggering a force reload event.
15
+ * This action does not require any options or context.
16
+ */
17
+ export const appRestartAction: ActionHandler =
18
+ async (): Promise<ActionResult> => {
19
+ log_info(`handleAction: ${QUICK_BRICK_EVENTS.FORCE_APP_RELOAD} event`);
20
+
21
+ QuickBrickManager.sendQuickBrickEvent(QUICK_BRICK_EVENTS.FORCE_APP_RELOAD);
22
+
23
+ return ActionResult.Success;
24
+ };
@@ -0,0 +1,53 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { showConfirmationDialog } from "../../alertUtils";
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
+ * Options for the confirmDialog action.
14
+ */
15
+ export interface ConfirmDialogOptions {
16
+ /** Dialog title (required) */
17
+ title: string;
18
+
19
+ /** Dialog message */
20
+ message?: string;
21
+
22
+ /** Confirm button text */
23
+ okButtonText?: string;
24
+
25
+ /** Cancel button text */
26
+ cancelButtonText?: string;
27
+
28
+ /** Callback when confirmed (deprecated - use action result) */
29
+ confirmCompletion?: () => void;
30
+
31
+ /** Callback when cancelled (deprecated - use action result) */
32
+ cancelCompletion?: () => void;
33
+ }
34
+
35
+ /**
36
+ * Shows a confirmation dialog to the user.
37
+ * Resolves to Success if user confirms, Cancel if user dismisses.
38
+ */
39
+ export const confirmDialogAction: ActionHandler<ConfirmDialogOptions> = async (
40
+ action
41
+ ): Promise<ActionResult> => {
42
+ log_info("handleAction: confirmDialog event");
43
+
44
+ const options = action.options as ConfirmDialogOptions;
45
+
46
+ return new Promise<ActionResult>((resolve) => {
47
+ showConfirmationDialog({
48
+ ...options,
49
+ confirmCompletion: () => resolve(ActionResult.Success),
50
+ cancelCompletion: () => resolve(ActionResult.Cancel),
51
+ });
52
+ });
53
+ };
@@ -0,0 +1,30 @@
1
+ // Export action handlers
2
+ export { localStorageSetAction } from "./localStorageSet";
3
+
4
+ export { sessionStorageSetAction } from "./sessionStorageSet";
5
+
6
+ export { localStorageRemoveAction } from "./localStorageRemove";
7
+
8
+ export { sessionStorageRemoveAction } from "./sessionStorageRemove";
9
+
10
+ export { refreshComponentAction } from "./refreshComponent";
11
+
12
+ export { switchLayoutAction } from "./switchLayout";
13
+
14
+ export { appRestartAction } from "./appRestart";
15
+
16
+ export { confirmDialogAction } from "./confirmDialog";
17
+
18
+ export { sendCloudEventAction } from "./sendCloudEvent";
19
+
20
+ export { sessionStorageToggleFlagAction } from "./sessionStorageToggleFlag";
21
+
22
+ export { localStorageToggleFlagAction } from "./localStorageToggleFlag";
23
+
24
+ export { screenSetVariableAction } from "./screenSetVariable";
25
+
26
+ export { screenToggleFlagAction } from "./screenToggleFlag";
27
+
28
+ export { createNavigateToScreenAction } from "./navigateToScreen";
29
+
30
+ export { openBottomSheetAction } from "./openBottomSheet";
@@ -0,0 +1,27 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
3
+ import { batchRemoveFromStorage } from "../../zappFrameworkUtils/localStorageHelper";
4
+ import { ActionResult } from "../ActionExecutor";
5
+ import { ActionHandler } from "../types";
6
+ import { StorageValuesToRemove } from "../../zappFrameworkUtils/types";
7
+
8
+ /**
9
+ * Options for localStorage/sessionStorage remove actions.
10
+ */
11
+ export interface StorageRemoveOptions {
12
+ /** The keys to remove, organized by namespace */
13
+ content: StorageValuesToRemove;
14
+ }
15
+
16
+ /**
17
+ * Removes values from local storage organized by namespaces.
18
+ */
19
+ export const localStorageRemoveAction: ActionHandler<
20
+ StorageRemoveOptions
21
+ > = async (action): Promise<ActionResult> => {
22
+ const namespaces = action.options.content;
23
+ await batchRemoveFromStorage(namespaces, localStorage);
24
+ // TODO: Add support for ownershipKey and ownershipNamespace
25
+
26
+ return ActionResult.Success;
27
+ };
@@ -0,0 +1,28 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
3
+ import { batchSave } from "../../zappFrameworkUtils/localStorageHelper";
4
+ import { ActionResult } from "../ActionExecutor";
5
+ import { ActionHandler } from "../types";
6
+ import { StorageValuesToAdd } from "../../zappFrameworkUtils/types";
7
+
8
+ /**
9
+ * Options for localStorage/sessionStorage set actions.
10
+ */
11
+ export interface StorageSetOptions {
12
+ /** The values to save, organized by namespace */
13
+ content: StorageValuesToAdd;
14
+ }
15
+
16
+ /**
17
+ * Saves values to local storage organized by namespaces.
18
+ * The values persist across app sessions.
19
+ */
20
+ export const localStorageSetAction: ActionHandler<StorageSetOptions> = async (
21
+ action
22
+ ): Promise<ActionResult> => {
23
+ const namespaces = action.options.content;
24
+ await batchSave(namespaces, localStorage);
25
+ // TODO: Add support for ownershipKey and ownershipNamespace
26
+
27
+ return ActionResult.Success;
28
+ };
@@ -0,0 +1,28 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { localStorageToggleFlag } from "../StorageActions";
3
+ import { ActionResult } from "../ActionExecutor";
4
+ import { ActionHandler, ActionExecutionContext } from "../types";
5
+
6
+ /**
7
+ * Options for storage toggle flag actions (localStorage/sessionStorage).
8
+ */
9
+ export interface StorageToggleFlagOptions {
10
+ /** The key/namespace for storing the flag */
11
+ key: string;
12
+
13
+ /** Path to extract the tag from entry */
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 local storage (adds or removes an item from a collection).
22
+ * Used for features like favorites, watchlists, etc.
23
+ */
24
+ export const localStorageToggleFlagAction: ActionHandler<
25
+ StorageToggleFlagOptions
26
+ > = async (action, context?: ActionExecutionContext): Promise<ActionResult> => {
27
+ return await localStorageToggleFlag(context, action);
28
+ };