@zeniai/client-epic-state 5.0.31-betaRD3 → 5.0.31

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 (50) hide show
  1. package/lib/coreEpics.js +1 -4
  2. package/lib/entity/tenant/clearAllEpic.d.ts +1 -2
  3. package/lib/entity/tenant/clearAllEpic.js +0 -2
  4. package/lib/entity/tenant/tenantPayload.d.ts +0 -2
  5. package/lib/entity/tenant/tenantReducer.d.ts +1 -60
  6. package/lib/entity/tenant/tenantReducer.js +4 -143
  7. package/lib/entity/tenant/tenantState.d.ts +0 -8
  8. package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +1 -1
  9. package/lib/epic.d.ts +1 -3
  10. package/lib/epic.js +1 -6
  11. package/lib/esm/coreEpics.js +1 -4
  12. package/lib/esm/entity/tenant/clearAllEpic.js +0 -2
  13. package/lib/esm/entity/tenant/tenantReducer.js +2 -139
  14. package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +1 -1
  15. package/lib/esm/epic.js +1 -6
  16. package/lib/esm/index.js +2 -5
  17. package/lib/esm/reducer.js +0 -3
  18. package/lib/index.d.ts +2 -6
  19. package/lib/index.js +30 -51
  20. package/lib/reducer.d.ts +0 -3
  21. package/lib/reducer.js +0 -3
  22. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  23. package/package.json +1 -1
  24. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +0 -19
  25. package/lib/entity/tenant/epic/deleteConnectionEpic.js +0 -29
  26. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +0 -19
  27. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +0 -31
  28. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +0 -19
  29. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +0 -33
  30. package/lib/esm/entity/tenant/epic/deleteConnectionEpic.js +0 -25
  31. package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +0 -27
  32. package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +0 -29
  33. package/lib/esm/view/featureNotificationView/epics/fetchRegisteredInterestsEpic.js +0 -23
  34. package/lib/esm/view/featureNotificationView/epics/notifyMeForFeatureEpic.js +0 -25
  35. package/lib/esm/view/featureNotificationView/featureNotificationViewPayload.js +0 -11
  36. package/lib/esm/view/featureNotificationView/featureNotificationViewReducer.js +0 -106
  37. package/lib/esm/view/featureNotificationView/featureNotificationViewSelector.js +0 -4
  38. package/lib/esm/view/featureNotificationView/featureNotificationViewState.js +0 -1
  39. package/lib/view/featureNotificationView/epics/fetchRegisteredInterestsEpic.d.ts +0 -16
  40. package/lib/view/featureNotificationView/epics/fetchRegisteredInterestsEpic.js +0 -27
  41. package/lib/view/featureNotificationView/epics/notifyMeForFeatureEpic.d.ts +0 -14
  42. package/lib/view/featureNotificationView/epics/notifyMeForFeatureEpic.js +0 -29
  43. package/lib/view/featureNotificationView/featureNotificationViewPayload.d.ts +0 -23
  44. package/lib/view/featureNotificationView/featureNotificationViewPayload.js +0 -15
  45. package/lib/view/featureNotificationView/featureNotificationViewReducer.d.ts +0 -19
  46. package/lib/view/featureNotificationView/featureNotificationViewReducer.js +0 -110
  47. package/lib/view/featureNotificationView/featureNotificationViewSelector.d.ts +0 -6
  48. package/lib/view/featureNotificationView/featureNotificationViewSelector.js +0 -11
  49. package/lib/view/featureNotificationView/featureNotificationViewState.d.ts +0 -26
  50. package/lib/view/featureNotificationView/featureNotificationViewState.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.31-betaRD3",
3
+ "version": "5.0.31",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -1,19 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { RootState } from '../../../reducer';
3
- import { ZeniAPI } from '../../../zeniAPI';
4
- import { deleteConnection, deleteConnectionFailure, deleteConnectionSuccess } from '../tenantReducer';
5
- export type ActionType = ReturnType<typeof deleteConnection> | ReturnType<typeof deleteConnectionSuccess> | ReturnType<typeof deleteConnectionFailure>;
6
- export declare const deleteConnectionEpic: (actions$: ActionsObservable<ActionType>, _: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
7
- payload: {
8
- tenantId: string;
9
- connectionId: string;
10
- connectionType: "analytics" | "crm";
11
- };
12
- type: "tenant/deleteConnectionSuccess";
13
- } | {
14
- payload: {
15
- tenantId: string;
16
- status: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
17
- };
18
- type: "tenant/deleteConnectionFailure";
19
- }>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteConnectionEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../responsePayload");
7
- const tenantReducer_1 = require("../tenantReducer");
8
- const deleteConnectionEpic = (actions$, _, zeniAPI) => actions$.pipe((0, operators_1.filter)(tenantReducer_1.deleteConnection.match), (0, operators_1.switchMap)((action) => zeniAPI
9
- .deleteAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${action.payload.connectionId}`, undefined, Object.assign({ 'zeni-tenant-id': action.payload.tenantId }))
10
- .pipe((0, operators_1.mergeMap)((response) => {
11
- if ((0, responsePayload_1.isSuccessStatus)(response)) {
12
- return (0, rxjs_1.from)([
13
- (0, tenantReducer_1.deleteConnectionSuccess)(action.payload.tenantId, action.payload.connectionId, action.payload.connectionType),
14
- ]);
15
- }
16
- const status = response.status ??
17
- (0, responsePayload_1.createZeniAPIStatus)('Failed to delete connection. Please try again.');
18
- return (0, rxjs_1.from)([
19
- (0, tenantReducer_1.deleteConnectionFailure)(action.payload.tenantId, status),
20
- ]);
21
- }), (0, operators_1.catchError)((error) => {
22
- const message = error instanceof Error
23
- ? error.message
24
- : 'Unexpected error deleting connection.';
25
- return (0, rxjs_1.from)([
26
- (0, tenantReducer_1.deleteConnectionFailure)(action.payload.tenantId, (0, responsePayload_1.createZeniAPIStatus)(message)),
27
- ]);
28
- }))));
29
- exports.deleteConnectionEpic = deleteConnectionEpic;
@@ -1,19 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { RootState } from '../../../reducer';
3
- import { ZeniAPI } from '../../../zeniAPI';
4
- import { saveAPIKeyConnection, saveAPIKeyConnectionFailure, saveAPIKeyConnectionSuccess } from '../tenantReducer';
5
- export type ActionType = ReturnType<typeof saveAPIKeyConnection> | ReturnType<typeof saveAPIKeyConnectionSuccess> | ReturnType<typeof saveAPIKeyConnectionFailure>;
6
- export declare const saveAPIKeyConnectionEpic: (actions$: ActionsObservable<ActionType>, _: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
7
- payload: {
8
- tenantId: string;
9
- connectionType: "analytics" | "crm";
10
- connectionPayload: import("../tenantPayload").ConnectionDataPayload;
11
- };
12
- type: "tenant/saveAPIKeyConnectionSuccess";
13
- } | {
14
- payload: {
15
- tenantId: string;
16
- status: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
17
- };
18
- type: "tenant/saveAPIKeyConnectionFailure";
19
- }>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.saveAPIKeyConnectionEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../responsePayload");
7
- const tenantReducer_1 = require("../tenantReducer");
8
- const saveAPIKeyConnectionEpic = (actions$, _, zeniAPI) => actions$.pipe((0, operators_1.filter)(tenantReducer_1.saveAPIKeyConnection.match), (0, operators_1.switchMap)((action) => zeniAPI
9
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${action.payload.connectionId}`, {
10
- api_key: action.payload.credentials.api_key,
11
- connection_name: action.payload.connectionName,
12
- connection_type: action.payload.connectionType,
13
- site: action.payload.credentials.site,
14
- }, Object.assign({ 'zeni-tenant-id': action.payload.tenantId }))
15
- .pipe((0, operators_1.mergeMap)((response) => {
16
- if ((0, responsePayload_1.isSuccessResponse)(response)) {
17
- return (0, rxjs_1.from)([
18
- (0, tenantReducer_1.saveAPIKeyConnectionSuccess)(action.payload.tenantId, action.payload.connectionType, response.data // eslint-disable-line @typescript-eslint/no-non-null-assertion
19
- ),
20
- ]);
21
- }
22
- const status = response.status ??
23
- (0, responsePayload_1.createZeniAPIStatus)('Failed to save connection. Please try again.');
24
- return (0, rxjs_1.from)([(0, tenantReducer_1.saveAPIKeyConnectionFailure)(action.payload.tenantId, status)]);
25
- }), (0, operators_1.catchError)((error) => {
26
- const message = error instanceof Error ? error.message : 'Unexpected error saving connection.';
27
- return (0, rxjs_1.from)([
28
- (0, tenantReducer_1.saveAPIKeyConnectionFailure)(action.payload.tenantId, (0, responsePayload_1.createZeniAPIStatus)(message)),
29
- ]);
30
- }))));
31
- exports.saveAPIKeyConnectionEpic = saveAPIKeyConnectionEpic;
@@ -1,19 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { RootState } from '../../../reducer';
3
- import { ZeniAPI } from '../../../zeniAPI';
4
- import { saveOAuthConnection, saveOAuthConnectionFailure, saveOAuthConnectionSuccess } from '../tenantReducer';
5
- export type ActionType = ReturnType<typeof saveOAuthConnection> | ReturnType<typeof saveOAuthConnectionSuccess> | ReturnType<typeof saveOAuthConnectionFailure>;
6
- export declare const saveOAuthConnectionEpic: (actions$: ActionsObservable<ActionType>, _: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
7
- payload: {
8
- tenantId: string;
9
- connectionType: "analytics" | "crm";
10
- connectionPayload: import("../tenantPayload").ConnectionDataPayload;
11
- };
12
- type: "tenant/saveOAuthConnectionSuccess";
13
- } | {
14
- payload: {
15
- tenantId: string;
16
- status: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
17
- };
18
- type: "tenant/saveOAuthConnectionFailure";
19
- }>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.saveOAuthConnectionEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../responsePayload");
7
- const tenantReducer_1 = require("../tenantReducer");
8
- const saveOAuthConnectionEpic = (actions$, _, zeniAPI) => actions$.pipe((0, operators_1.filter)(tenantReducer_1.saveOAuthConnection.match), (0, operators_1.switchMap)((action) => zeniAPI
9
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${action.payload.connectionId}`, {
10
- authorization_code: action.payload.credentials.authorization_code,
11
- client_id: action.payload.credentials.client_id,
12
- client_secret: action.payload.credentials.client_secret,
13
- connection_name: action.payload.connectionName,
14
- connection_type: action.payload.connectionType,
15
- redirect_uri: action.payload.credentials.redirect_uri,
16
- }, Object.assign({ 'zeni-tenant-id': action.payload.tenantId }))
17
- .pipe((0, operators_1.mergeMap)((response) => {
18
- if ((0, responsePayload_1.isSuccessResponse)(response)) {
19
- return (0, rxjs_1.from)([
20
- (0, tenantReducer_1.saveOAuthConnectionSuccess)(action.payload.tenantId, action.payload.connectionType, response.data // eslint-disable-line @typescript-eslint/no-non-null-assertion
21
- ),
22
- ]);
23
- }
24
- const status = response.status ??
25
- (0, responsePayload_1.createZeniAPIStatus)('Failed to save connection. Please try again.');
26
- return (0, rxjs_1.from)([(0, tenantReducer_1.saveOAuthConnectionFailure)(action.payload.tenantId, status)]);
27
- }), (0, operators_1.catchError)((error) => {
28
- const message = error instanceof Error ? error.message : 'Unexpected error saving connection.';
29
- return (0, rxjs_1.from)([
30
- (0, tenantReducer_1.saveOAuthConnectionFailure)(action.payload.tenantId, (0, responsePayload_1.createZeniAPIStatus)(message)),
31
- ]);
32
- }))));
33
- exports.saveOAuthConnectionEpic = saveOAuthConnectionEpic;
@@ -1,25 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessStatus, } from '../../../responsePayload';
4
- import { deleteConnection, deleteConnectionFailure, deleteConnectionSuccess, } from '../tenantReducer';
5
- export const deleteConnectionEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(deleteConnection.match), switchMap((action) => zeniAPI
6
- .deleteAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${action.payload.connectionId}`, undefined, Object.assign({ 'zeni-tenant-id': action.payload.tenantId }))
7
- .pipe(mergeMap((response) => {
8
- if (isSuccessStatus(response)) {
9
- return from([
10
- deleteConnectionSuccess(action.payload.tenantId, action.payload.connectionId, action.payload.connectionType),
11
- ]);
12
- }
13
- const status = response.status ??
14
- createZeniAPIStatus('Failed to delete connection. Please try again.');
15
- return from([
16
- deleteConnectionFailure(action.payload.tenantId, status),
17
- ]);
18
- }), catchError((error) => {
19
- const message = error instanceof Error
20
- ? error.message
21
- : 'Unexpected error deleting connection.';
22
- return from([
23
- deleteConnectionFailure(action.payload.tenantId, createZeniAPIStatus(message)),
24
- ]);
25
- }))));
@@ -1,27 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
4
- import { saveAPIKeyConnection, saveAPIKeyConnectionFailure, saveAPIKeyConnectionSuccess, } from '../tenantReducer';
5
- export const saveAPIKeyConnectionEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(saveAPIKeyConnection.match), switchMap((action) => zeniAPI
6
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${action.payload.connectionId}`, {
7
- api_key: action.payload.credentials.api_key,
8
- connection_name: action.payload.connectionName,
9
- connection_type: action.payload.connectionType,
10
- site: action.payload.credentials.site,
11
- }, Object.assign({ 'zeni-tenant-id': action.payload.tenantId }))
12
- .pipe(mergeMap((response) => {
13
- if (isSuccessResponse(response)) {
14
- return from([
15
- saveAPIKeyConnectionSuccess(action.payload.tenantId, action.payload.connectionType, response.data // eslint-disable-line @typescript-eslint/no-non-null-assertion
16
- ),
17
- ]);
18
- }
19
- const status = response.status ??
20
- createZeniAPIStatus('Failed to save connection. Please try again.');
21
- return from([saveAPIKeyConnectionFailure(action.payload.tenantId, status)]);
22
- }), catchError((error) => {
23
- const message = error instanceof Error ? error.message : 'Unexpected error saving connection.';
24
- return from([
25
- saveAPIKeyConnectionFailure(action.payload.tenantId, createZeniAPIStatus(message)),
26
- ]);
27
- }))));
@@ -1,29 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
4
- import { saveOAuthConnection, saveOAuthConnectionFailure, saveOAuthConnectionSuccess, } from '../tenantReducer';
5
- export const saveOAuthConnectionEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(saveOAuthConnection.match), switchMap((action) => zeniAPI
6
- .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${action.payload.connectionId}`, {
7
- authorization_code: action.payload.credentials.authorization_code,
8
- client_id: action.payload.credentials.client_id,
9
- client_secret: action.payload.credentials.client_secret,
10
- connection_name: action.payload.connectionName,
11
- connection_type: action.payload.connectionType,
12
- redirect_uri: action.payload.credentials.redirect_uri,
13
- }, Object.assign({ 'zeni-tenant-id': action.payload.tenantId }))
14
- .pipe(mergeMap((response) => {
15
- if (isSuccessResponse(response)) {
16
- return from([
17
- saveOAuthConnectionSuccess(action.payload.tenantId, action.payload.connectionType, response.data // eslint-disable-line @typescript-eslint/no-non-null-assertion
18
- ),
19
- ]);
20
- }
21
- const status = response.status ??
22
- createZeniAPIStatus('Failed to save connection. Please try again.');
23
- return from([saveOAuthConnectionFailure(action.payload.tenantId, status)]);
24
- }), catchError((error) => {
25
- const message = error instanceof Error ? error.message : 'Unexpected error saving connection.';
26
- return from([
27
- saveOAuthConnectionFailure(action.payload.tenantId, createZeniAPIStatus(message)),
28
- ]);
29
- }))));
@@ -1,23 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
4
- import { toFeatureInterest, } from '../featureNotificationViewPayload';
5
- import { fetchRegisteredInterests, fetchRegisteredInterestsFailure, fetchRegisteredInterestsSuccess, } from '../featureNotificationViewReducer';
6
- export const fetchRegisteredInterestsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchRegisteredInterests.match), switchMap((action) => zeniAPI
7
- .getJSON(`${zeniAPI.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/feature-interests?feature=${encodeURIComponent(action.payload.feature)}`)
8
- .pipe(mergeMap((response) => {
9
- if (isSuccessResponse(response) && response.data != null) {
10
- const interests = response.data.feature_interests.map(toFeatureInterest);
11
- return from([fetchRegisteredInterestsSuccess(interests)]);
12
- }
13
- const status = response.status ??
14
- createZeniAPIStatus('Failed to fetch registered interests. Please try again.');
15
- return from([fetchRegisteredInterestsFailure(status)]);
16
- }), catchError((error) => {
17
- const message = error instanceof Error
18
- ? error.message
19
- : 'Unexpected error fetching registered interests.';
20
- return from([
21
- fetchRegisteredInterestsFailure(createZeniAPIStatus(message)),
22
- ]);
23
- }))));
@@ -1,25 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
4
- import { notifyMeForFeature, notifyMeForFeatureFailure, notifyMeForFeatureSuccess, } from '../featureNotificationViewReducer';
5
- export const notifyMeForFeatureEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(notifyMeForFeature.match), switchMap((action) => zeniAPI
6
- .postAndGetJSON(`${zeniAPI.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/feature-interests`, {
7
- additional_info: action.payload.additionalInfo,
8
- email: action.payload.email,
9
- feature: action.payload.feature,
10
- })
11
- .pipe(mergeMap((response) => {
12
- if (isSuccessResponse(response) && response.data != null) {
13
- return from([notifyMeForFeatureSuccess(response.data)]);
14
- }
15
- const status = response.status ??
16
- createZeniAPIStatus('Failed to register interest. Please try again.');
17
- return from([notifyMeForFeatureFailure(status)]);
18
- }), catchError((error) => {
19
- const message = error instanceof Error
20
- ? error.message
21
- : 'Unexpected error registering interest.';
22
- return from([
23
- notifyMeForFeatureFailure(createZeniAPIStatus(message)),
24
- ]);
25
- }))));
@@ -1,11 +0,0 @@
1
- import { date } from '../../zeniDayJS';
2
- export const toFeatureInterest = (payload) => ({
3
- interestId: payload.interest_id,
4
- feature: payload.feature,
5
- notified: payload.notified,
6
- createTime: date(payload.create_time),
7
- updateTime: date(payload.update_time),
8
- additionalInfo: payload.additional_info ?? undefined,
9
- email: payload.email ?? undefined,
10
- notifiedTime: payload.notified_time != null ? date(payload.notified_time) : undefined,
11
- });
@@ -1,106 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
- import { toFeatureInterest, } from './featureNotificationViewPayload';
3
- export const initialState = {
4
- fetchRegisteredInterestsState: {
5
- fetchState: 'Not-Started',
6
- error: undefined,
7
- },
8
- notifyMeForFeatureState: {
9
- fetchState: 'Not-Started',
10
- error: undefined,
11
- },
12
- registeredInterests: [],
13
- };
14
- const featureNotificationView = createSlice({
15
- name: 'featureNotificationView',
16
- initialState,
17
- reducers: {
18
- notifyMeForFeature: {
19
- prepare(feature, additionalInfo, email) {
20
- return { payload: { feature, additionalInfo, email } };
21
- },
22
- reducer(draft,
23
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
- _action) {
25
- draft.notifyMeForFeatureState = {
26
- fetchState: 'In-Progress',
27
- error: undefined,
28
- };
29
- },
30
- },
31
- notifyMeForFeatureSuccess: {
32
- prepare(payload) {
33
- return { payload };
34
- },
35
- reducer(draft, action) {
36
- draft.notifyMeForFeatureState = {
37
- fetchState: 'Completed',
38
- error: undefined,
39
- };
40
- const interest = toFeatureInterest(action.payload);
41
- // Idempotent: if a row for this (feature, additional_info) already
42
- // exists in the slice, replace it; otherwise append.
43
- const existingIndex = draft.registeredInterests.findIndex((r) => r.feature === interest.feature &&
44
- r.additionalInfo === interest.additionalInfo);
45
- if (existingIndex >= 0) {
46
- draft.registeredInterests[existingIndex] = interest;
47
- }
48
- else {
49
- draft.registeredInterests.push(interest);
50
- }
51
- },
52
- },
53
- notifyMeForFeatureFailure: {
54
- prepare(status) {
55
- return { payload: { status } };
56
- },
57
- reducer(draft, action) {
58
- draft.notifyMeForFeatureState = {
59
- fetchState: 'Error',
60
- error: action.payload.status,
61
- };
62
- },
63
- },
64
- fetchRegisteredInterests: {
65
- prepare(feature) {
66
- return { payload: { feature } };
67
- },
68
- reducer(draft,
69
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
70
- _action) {
71
- draft.fetchRegisteredInterestsState = {
72
- fetchState: 'In-Progress',
73
- error: undefined,
74
- };
75
- },
76
- },
77
- fetchRegisteredInterestsSuccess: {
78
- prepare(interests) {
79
- return { payload: { interests } };
80
- },
81
- reducer(draft, action) {
82
- draft.fetchRegisteredInterestsState = {
83
- fetchState: 'Completed',
84
- error: undefined,
85
- };
86
- draft.registeredInterests = action.payload.interests;
87
- },
88
- },
89
- fetchRegisteredInterestsFailure: {
90
- prepare(status) {
91
- return { payload: { status } };
92
- },
93
- reducer(draft, action) {
94
- draft.fetchRegisteredInterestsState = {
95
- fetchState: 'Error',
96
- error: action.payload.status,
97
- };
98
- },
99
- },
100
- clearFeatureNotificationView(draft) {
101
- Object.assign(draft, initialState);
102
- },
103
- },
104
- });
105
- export const { clearFeatureNotificationView, fetchRegisteredInterests, fetchRegisteredInterestsFailure, fetchRegisteredInterestsSuccess, notifyMeForFeature, notifyMeForFeatureFailure, notifyMeForFeatureSuccess, } = featureNotificationView.actions;
106
- export default featureNotificationView.reducer;
@@ -1,4 +0,0 @@
1
- export const getFeatureNotificationView = (state) => state.featureNotificationViewState;
2
- export const getRegisteredInterests = (state) => state.featureNotificationViewState.registeredInterests;
3
- export const getRegisteredInterestsByFeature = (state, feature) => state.featureNotificationViewState.registeredInterests.filter((interest) => interest.feature === feature);
4
- export const isFeatureInterestRegistered = (state, feature, additionalInfo) => state.featureNotificationViewState.registeredInterests.some((interest) => interest.feature === feature && interest.additionalInfo === additionalInfo);
@@ -1,16 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { RootState } from '../../../reducer';
3
- import { ZeniAPI } from '../../../zeniAPI';
4
- import { fetchRegisteredInterests, fetchRegisteredInterestsFailure, fetchRegisteredInterestsSuccess } from '../featureNotificationViewReducer';
5
- export type ActionType = ReturnType<typeof fetchRegisteredInterests> | ReturnType<typeof fetchRegisteredInterestsSuccess> | ReturnType<typeof fetchRegisteredInterestsFailure>;
6
- export declare const fetchRegisteredInterestsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
7
- payload: {
8
- interests: import("../featureNotificationViewState").FeatureInterest[];
9
- };
10
- type: "featureNotificationView/fetchRegisteredInterestsSuccess";
11
- } | {
12
- payload: {
13
- status: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
14
- };
15
- type: "featureNotificationView/fetchRegisteredInterestsFailure";
16
- }>;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchRegisteredInterestsEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../responsePayload");
7
- const featureNotificationViewPayload_1 = require("../featureNotificationViewPayload");
8
- const featureNotificationViewReducer_1 = require("../featureNotificationViewReducer");
9
- const fetchRegisteredInterestsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(featureNotificationViewReducer_1.fetchRegisteredInterests.match), (0, operators_1.switchMap)((action) => zeniAPI
10
- .getJSON(`${zeniAPI.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/feature-interests?feature=${encodeURIComponent(action.payload.feature)}`)
11
- .pipe((0, operators_1.mergeMap)((response) => {
12
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
13
- const interests = response.data.feature_interests.map(featureNotificationViewPayload_1.toFeatureInterest);
14
- return (0, rxjs_1.from)([(0, featureNotificationViewReducer_1.fetchRegisteredInterestsSuccess)(interests)]);
15
- }
16
- const status = response.status ??
17
- (0, responsePayload_1.createZeniAPIStatus)('Failed to fetch registered interests. Please try again.');
18
- return (0, rxjs_1.from)([(0, featureNotificationViewReducer_1.fetchRegisteredInterestsFailure)(status)]);
19
- }), (0, operators_1.catchError)((error) => {
20
- const message = error instanceof Error
21
- ? error.message
22
- : 'Unexpected error fetching registered interests.';
23
- return (0, rxjs_1.from)([
24
- (0, featureNotificationViewReducer_1.fetchRegisteredInterestsFailure)((0, responsePayload_1.createZeniAPIStatus)(message)),
25
- ]);
26
- }))));
27
- exports.fetchRegisteredInterestsEpic = fetchRegisteredInterestsEpic;
@@ -1,14 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { RootState } from '../../../reducer';
3
- import { ZeniAPI } from '../../../zeniAPI';
4
- import { notifyMeForFeature, notifyMeForFeatureFailure, notifyMeForFeatureSuccess } from '../featureNotificationViewReducer';
5
- export type ActionType = ReturnType<typeof notifyMeForFeature> | ReturnType<typeof notifyMeForFeatureSuccess> | ReturnType<typeof notifyMeForFeatureFailure>;
6
- export declare const notifyMeForFeatureEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
7
- payload: import("../featureNotificationViewPayload").FeatureInterestDataPayload;
8
- type: "featureNotificationView/notifyMeForFeatureSuccess";
9
- } | {
10
- payload: {
11
- status: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
12
- };
13
- type: "featureNotificationView/notifyMeForFeatureFailure";
14
- }>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.notifyMeForFeatureEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../responsePayload");
7
- const featureNotificationViewReducer_1 = require("../featureNotificationViewReducer");
8
- const notifyMeForFeatureEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(featureNotificationViewReducer_1.notifyMeForFeature.match), (0, operators_1.switchMap)((action) => zeniAPI
9
- .postAndGetJSON(`${zeniAPI.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/feature-interests`, {
10
- additional_info: action.payload.additionalInfo,
11
- email: action.payload.email,
12
- feature: action.payload.feature,
13
- })
14
- .pipe((0, operators_1.mergeMap)((response) => {
15
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
16
- return (0, rxjs_1.from)([(0, featureNotificationViewReducer_1.notifyMeForFeatureSuccess)(response.data)]);
17
- }
18
- const status = response.status ??
19
- (0, responsePayload_1.createZeniAPIStatus)('Failed to register interest. Please try again.');
20
- return (0, rxjs_1.from)([(0, featureNotificationViewReducer_1.notifyMeForFeatureFailure)(status)]);
21
- }), (0, operators_1.catchError)((error) => {
22
- const message = error instanceof Error
23
- ? error.message
24
- : 'Unexpected error registering interest.';
25
- return (0, rxjs_1.from)([
26
- (0, featureNotificationViewReducer_1.notifyMeForFeatureFailure)((0, responsePayload_1.createZeniAPIStatus)(message)),
27
- ]);
28
- }))));
29
- exports.notifyMeForFeatureEpic = notifyMeForFeatureEpic;
@@ -1,23 +0,0 @@
1
- import { ZeniAPIResponse } from '../../responsePayload';
2
- import { FeatureInterest } from './featureNotificationViewState';
3
- /**
4
- * Backend payload shapes for the FeatureInterest API exposed by
5
- * `@repo:notifications`. snake_case is preserved here verbatim; the
6
- * `toFeatureInterest` mapper converts to the camelCase state shape.
7
- */
8
- export interface FeatureInterestDataPayload {
9
- create_time: string;
10
- feature: string;
11
- interest_id: string;
12
- notified: boolean;
13
- update_time: string;
14
- additional_info?: string | null;
15
- email?: string | null;
16
- notified_time?: string | null;
17
- }
18
- export interface FeatureInterestListPayload {
19
- feature_interests: FeatureInterestDataPayload[];
20
- }
21
- export type FeatureInterestResponse = ZeniAPIResponse<FeatureInterestDataPayload>;
22
- export type FeatureInterestListResponse = ZeniAPIResponse<FeatureInterestListPayload>;
23
- export declare const toFeatureInterest: (payload: FeatureInterestDataPayload) => FeatureInterest;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toFeatureInterest = void 0;
4
- const zeniDayJS_1 = require("../../zeniDayJS");
5
- const toFeatureInterest = (payload) => ({
6
- interestId: payload.interest_id,
7
- feature: payload.feature,
8
- notified: payload.notified,
9
- createTime: (0, zeniDayJS_1.date)(payload.create_time),
10
- updateTime: (0, zeniDayJS_1.date)(payload.update_time),
11
- additionalInfo: payload.additional_info ?? undefined,
12
- email: payload.email ?? undefined,
13
- notifiedTime: payload.notified_time != null ? (0, zeniDayJS_1.date)(payload.notified_time) : undefined,
14
- });
15
- exports.toFeatureInterest = toFeatureInterest;
@@ -1,19 +0,0 @@
1
- import { ZeniAPIStatus } from '../../responsePayload';
2
- import { FeatureInterestDataPayload } from './featureNotificationViewPayload';
3
- import { FeatureInterest, FeatureNotificationViewState } from './featureNotificationViewState';
4
- export declare const initialState: FeatureNotificationViewState;
5
- export declare const clearFeatureNotificationView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"featureNotificationView/clearFeatureNotificationView">, fetchRegisteredInterests: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[feature: string], {
6
- feature: string;
7
- }, "featureNotificationView/fetchRegisteredInterests", never, never>, fetchRegisteredInterestsFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[status: ZeniAPIStatus<Record<string, unknown>>], {
8
- status: ZeniAPIStatus<Record<string, unknown>>;
9
- }, "featureNotificationView/fetchRegisteredInterestsFailure", never, never>, fetchRegisteredInterestsSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[interests: FeatureInterest[]], {
10
- interests: FeatureInterest[];
11
- }, "featureNotificationView/fetchRegisteredInterestsSuccess", never, never>, notifyMeForFeature: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[feature: string, additionalInfo: string, email: string], {
12
- feature: string;
13
- additionalInfo: string;
14
- email: string;
15
- }, "featureNotificationView/notifyMeForFeature", never, never>, notifyMeForFeatureFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[status: ZeniAPIStatus<Record<string, unknown>>], {
16
- status: ZeniAPIStatus<Record<string, unknown>>;
17
- }, "featureNotificationView/notifyMeForFeatureFailure", never, never>, notifyMeForFeatureSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: FeatureInterestDataPayload], FeatureInterestDataPayload, "featureNotificationView/notifyMeForFeatureSuccess", never, never>;
18
- declare const _default: import("redux").Reducer<FeatureNotificationViewState>;
19
- export default _default;