@replyke/core 5.1.4 → 5.1.5-beta.1
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.
- package/dist/cjs/context/index.d.ts +1 -0
- package/dist/cjs/context/index.js +3 -1
- package/dist/cjs/context/index.js.map +1 -1
- package/dist/cjs/context/replyke-context.d.ts +1 -0
- package/dist/cjs/context/replyke-context.js +3 -2
- package/dist/cjs/context/replyke-context.js.map +1 -1
- package/dist/cjs/context/replyke-store-context.d.ts +12 -0
- package/dist/cjs/context/replyke-store-context.js +20 -0
- package/dist/cjs/context/replyke-store-context.js.map +1 -0
- package/dist/cjs/hooks/app-notifications-redux/index.d.ts +4 -0
- package/dist/cjs/hooks/app-notifications-redux/index.js +14 -0
- package/dist/cjs/hooks/app-notifications-redux/index.js.map +1 -0
- package/dist/cjs/hooks/app-notifications-redux/useAppNotificationsActionsRedux.d.ts +12 -0
- package/dist/cjs/hooks/app-notifications-redux/useAppNotificationsActionsRedux.js +208 -0
- package/dist/cjs/hooks/app-notifications-redux/useAppNotificationsActionsRedux.js.map +1 -0
- package/dist/cjs/hooks/app-notifications-redux/useAppNotificationsDataRedux.d.ts +7 -0
- package/dist/cjs/hooks/app-notifications-redux/useAppNotificationsDataRedux.js +83 -0
- package/dist/cjs/hooks/app-notifications-redux/useAppNotificationsDataRedux.js.map +1 -0
- package/dist/cjs/hooks/app-notifications-redux/useAppNotificationsRedux.d.ts +7 -0
- package/dist/cjs/hooks/app-notifications-redux/useAppNotificationsRedux.js +30 -0
- package/dist/cjs/hooks/app-notifications-redux/useAppNotificationsRedux.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -1
- package/dist/cjs/index.js +9 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/store/api/appNotificationsApi.d.ts +1687 -0
- package/dist/cjs/store/api/appNotificationsApi.js +169 -0
- package/dist/cjs/store/api/appNotificationsApi.js.map +1 -0
- package/dist/cjs/store/api/baseApi.d.ts +1 -0
- package/dist/cjs/store/api/baseApi.js +34 -0
- package/dist/cjs/store/api/baseApi.js.map +1 -0
- package/dist/cjs/store/api/index.d.ts +2 -0
- package/dist/cjs/store/api/index.js +27 -0
- package/dist/cjs/store/api/index.js.map +1 -0
- package/dist/cjs/store/index.d.ts +13 -0
- package/dist/cjs/store/index.js +49 -0
- package/dist/cjs/store/index.js.map +1 -0
- package/dist/cjs/store/middleware.d.ts +4 -0
- package/dist/cjs/store/middleware.js +44 -0
- package/dist/cjs/store/middleware.js.map +1 -0
- package/dist/cjs/store/rootReducer.d.ts +8 -0
- package/dist/cjs/store/rootReducer.js +15 -0
- package/dist/cjs/store/rootReducer.js.map +1 -0
- package/dist/cjs/store/slices/appNotificationsSlice.d.ts +57 -0
- package/dist/cjs/store/slices/appNotificationsSlice.js +127 -0
- package/dist/cjs/store/slices/appNotificationsSlice.js.map +1 -0
- package/dist/cjs/store/slices/index.d.ts +1 -0
- package/dist/cjs/store/slices/index.js +23 -0
- package/dist/cjs/store/slices/index.js.map +1 -0
- package/dist/cjs/store/types/index.d.ts +8 -0
- package/dist/cjs/store/types/index.js +3 -0
- package/dist/cjs/store/types/index.js.map +1 -0
- package/dist/esm/context/index.d.ts +1 -0
- package/dist/esm/context/index.js +1 -0
- package/dist/esm/context/index.js.map +1 -1
- package/dist/esm/context/replyke-context.d.ts +1 -0
- package/dist/esm/context/replyke-context.js +3 -2
- package/dist/esm/context/replyke-context.js.map +1 -1
- package/dist/esm/context/replyke-store-context.d.ts +12 -0
- package/dist/esm/context/replyke-store-context.js +16 -0
- package/dist/esm/context/replyke-store-context.js.map +1 -0
- package/dist/esm/hooks/app-notifications-redux/index.d.ts +4 -0
- package/dist/esm/hooks/app-notifications-redux/index.js +5 -0
- package/dist/esm/hooks/app-notifications-redux/index.js.map +1 -0
- package/dist/esm/hooks/app-notifications-redux/useAppNotificationsActionsRedux.d.ts +12 -0
- package/dist/esm/hooks/app-notifications-redux/useAppNotificationsActionsRedux.js +202 -0
- package/dist/esm/hooks/app-notifications-redux/useAppNotificationsActionsRedux.js.map +1 -0
- package/dist/esm/hooks/app-notifications-redux/useAppNotificationsDataRedux.d.ts +7 -0
- package/dist/esm/hooks/app-notifications-redux/useAppNotificationsDataRedux.js +78 -0
- package/dist/esm/hooks/app-notifications-redux/useAppNotificationsDataRedux.js.map +1 -0
- package/dist/esm/hooks/app-notifications-redux/useAppNotificationsRedux.d.ts +7 -0
- package/dist/esm/hooks/app-notifications-redux/useAppNotificationsRedux.js +27 -0
- package/dist/esm/hooks/app-notifications-redux/useAppNotificationsRedux.js.map +1 -0
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.js +7 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/store/api/appNotificationsApi.d.ts +1687 -0
- package/dist/esm/store/api/appNotificationsApi.js +166 -0
- package/dist/esm/store/api/appNotificationsApi.js.map +1 -0
- package/dist/esm/store/api/baseApi.d.ts +1 -0
- package/dist/esm/store/api/baseApi.js +31 -0
- package/dist/esm/store/api/baseApi.js.map +1 -0
- package/dist/esm/store/api/index.d.ts +2 -0
- package/dist/esm/store/api/index.js +9 -0
- package/dist/esm/store/api/index.js.map +1 -0
- package/dist/esm/store/index.d.ts +13 -0
- package/dist/esm/store/index.js +32 -0
- package/dist/esm/store/index.js.map +1 -0
- package/dist/esm/store/middleware.d.ts +4 -0
- package/dist/esm/store/middleware.js +39 -0
- package/dist/esm/store/middleware.js.map +1 -0
- package/dist/esm/store/rootReducer.d.ts +8 -0
- package/dist/esm/store/rootReducer.js +12 -0
- package/dist/esm/store/rootReducer.js.map +1 -0
- package/dist/esm/store/slices/appNotificationsSlice.d.ts +57 -0
- package/dist/esm/store/slices/appNotificationsSlice.js +116 -0
- package/dist/esm/store/slices/appNotificationsSlice.js.map +1 -0
- package/dist/esm/store/slices/index.d.ts +1 -0
- package/dist/esm/store/slices/index.js +7 -0
- package/dist/esm/store/slices/index.js.map +1 -0
- package/dist/esm/store/types/index.d.ts +8 -0
- package/dist/esm/store/types/index.js +2 -0
- package/dist/esm/store/types/index.js.map +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
57
|
+
var _a;
|
|
58
|
+
import { baseApi } from "./baseApi";
|
|
59
|
+
// Extended API with app notifications endpoints
|
|
60
|
+
export var appNotificationsApi = baseApi.injectEndpoints({
|
|
61
|
+
endpoints: function (builder) { return ({
|
|
62
|
+
// Fetch paginated app notifications
|
|
63
|
+
fetchAppNotifications: builder.query({
|
|
64
|
+
query: function (_a) {
|
|
65
|
+
var projectId = _a.projectId, page = _a.page, limit = _a.limit;
|
|
66
|
+
return ({
|
|
67
|
+
url: "/".concat(projectId, "/app-notifications"),
|
|
68
|
+
method: 'GET',
|
|
69
|
+
params: {
|
|
70
|
+
page: page,
|
|
71
|
+
limit: limit,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
providesTags: function (result, error, _a) {
|
|
76
|
+
var _b;
|
|
77
|
+
var projectId = _a.projectId;
|
|
78
|
+
return __spreadArray([
|
|
79
|
+
{ type: 'AppNotification', id: "".concat(projectId, "-LIST") }
|
|
80
|
+
], ((_b = result === null || result === void 0 ? void 0 : result.map(function (_a) {
|
|
81
|
+
var id = _a.id;
|
|
82
|
+
return ({ type: 'AppNotification', id: id });
|
|
83
|
+
})) !== null && _b !== void 0 ? _b : []), true);
|
|
84
|
+
},
|
|
85
|
+
// Transform response to ensure dates are properly parsed
|
|
86
|
+
transformResponse: function (response) {
|
|
87
|
+
return response.map(function (notification) { return (__assign(__assign({}, notification), { createdAt: new Date(notification.createdAt) })); });
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
// Mark a notification as read
|
|
91
|
+
markNotificationAsRead: builder.mutation({
|
|
92
|
+
query: function (_a) {
|
|
93
|
+
var projectId = _a.projectId, notificationId = _a.notificationId;
|
|
94
|
+
return ({
|
|
95
|
+
url: "/".concat(projectId, "/app-notifications/").concat(notificationId, "/mark-as-read"),
|
|
96
|
+
method: 'PATCH',
|
|
97
|
+
body: {},
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
// Optimistically update the cache
|
|
101
|
+
onQueryStarted: function (_a, _b) {
|
|
102
|
+
return __awaiter(this, arguments, void 0, function (_c, _d) {
|
|
103
|
+
var patches, _e;
|
|
104
|
+
var projectId = _c.projectId, notificationId = _c.notificationId;
|
|
105
|
+
var dispatch = _d.dispatch, queryFulfilled = _d.queryFulfilled;
|
|
106
|
+
return __generator(this, function (_f) {
|
|
107
|
+
switch (_f.label) {
|
|
108
|
+
case 0:
|
|
109
|
+
patches = [];
|
|
110
|
+
dispatch(appNotificationsApi.util.updateQueryData('fetchAppNotifications',
|
|
111
|
+
// We need to find all queries for this projectId - this is a simplified approach
|
|
112
|
+
{ projectId: projectId, page: 1, limit: 10 }, // This should be more dynamic in practice
|
|
113
|
+
function (draft) {
|
|
114
|
+
var notification = draft.find(function (n) { return n.id === notificationId; });
|
|
115
|
+
if (notification) {
|
|
116
|
+
notification.isRead = true;
|
|
117
|
+
}
|
|
118
|
+
}));
|
|
119
|
+
_f.label = 1;
|
|
120
|
+
case 1:
|
|
121
|
+
_f.trys.push([1, 3, , 4]);
|
|
122
|
+
return [4 /*yield*/, queryFulfilled];
|
|
123
|
+
case 2:
|
|
124
|
+
_f.sent();
|
|
125
|
+
return [3 /*break*/, 4];
|
|
126
|
+
case 3:
|
|
127
|
+
_e = _f.sent();
|
|
128
|
+
// Revert optimistic update on failure
|
|
129
|
+
patches.forEach(function (patch) { return patch.undo(); });
|
|
130
|
+
return [3 /*break*/, 4];
|
|
131
|
+
case 4: return [2 /*return*/];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
invalidatesTags: function (result, error, _a) {
|
|
137
|
+
var projectId = _a.projectId, notificationId = _a.notificationId;
|
|
138
|
+
return [
|
|
139
|
+
{ type: 'AppNotification', id: notificationId },
|
|
140
|
+
{ type: 'AppNotification', id: "".concat(projectId, "-LIST") },
|
|
141
|
+
];
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
// Count unread notifications
|
|
145
|
+
countUnreadNotifications: builder.query({
|
|
146
|
+
query: function (_a) {
|
|
147
|
+
var projectId = _a.projectId;
|
|
148
|
+
return ({
|
|
149
|
+
url: "/".concat(projectId, "/app-notifications/count"),
|
|
150
|
+
method: 'GET',
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
providesTags: function (result, error, _a) {
|
|
154
|
+
var projectId = _a.projectId;
|
|
155
|
+
return [
|
|
156
|
+
{ type: 'AppNotification', id: "".concat(projectId, "-COUNT") },
|
|
157
|
+
];
|
|
158
|
+
},
|
|
159
|
+
}),
|
|
160
|
+
}); },
|
|
161
|
+
});
|
|
162
|
+
// Export hooks for use in components
|
|
163
|
+
export var useFetchAppNotificationsQuery = appNotificationsApi.useFetchAppNotificationsQuery, useLazyFetchAppNotificationsQuery = appNotificationsApi.useLazyFetchAppNotificationsQuery, useMarkNotificationAsReadMutation = appNotificationsApi.useMarkNotificationAsReadMutation, useCountUnreadNotificationsQuery = appNotificationsApi.useCountUnreadNotificationsQuery, useLazyCountUnreadNotificationsQuery = appNotificationsApi.useLazyCountUnreadNotificationsQuery;
|
|
164
|
+
// Export for manual cache management
|
|
165
|
+
export var fetchAppNotifications = (_a = appNotificationsApi.endpoints, _a.fetchAppNotifications), markNotificationAsRead = _a.markNotificationAsRead, countUnreadNotifications = _a.countUnreadNotifications;
|
|
166
|
+
//# sourceMappingURL=appNotificationsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appNotificationsApi.js","sourceRoot":"","sources":["../../../../src/store/api/appNotificationsApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBpC,gDAAgD;AAChD,MAAM,CAAC,IAAM,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IACzD,SAAS,EAAE,UAAC,OAAO,IAAK,OAAA,CAAC;QACvB,oCAAoC;QACpC,qBAAqB,EAAE,OAAO,CAAC,KAAK,CAAwD;YAC1F,KAAK,EAAE,UAAC,EAA0B;oBAAxB,SAAS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EAAE,KAAK,EAAE,EAAa;oBAAX,SAAS,eAAA;gBAAO,OAAA;oBAC9C,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,EAAE,UAAG,SAAS,WAAQ,EAAE;iBACtD;YAF+C,CAE/C;SACF,CAAC;KACH,CAAC,EAzEsB,CAyEtB;CACH,CAAC,CAAC;AAEH,qCAAqC;AACrC,MAAM,CACJ,IAAA,6BAA6B,GAK3B,mBAAmB,8BALQ,EAC7B,iCAAiC,GAI/B,mBAAmB,kCAJY,EACjC,iCAAiC,GAG/B,mBAAmB,kCAHY,EACjC,gCAAgC,GAE9B,mBAAmB,iCAFW,EAChC,oCAAoC,GAClC,mBAAmB,qCADe,CACd;AAExB,qCAAqC;AACrC,MAAM,CACJ,IAAA,qBAAqB,IADV,KAIT,mBAAmB,CAAC,SAAS,2BAHV,EACrB,sBAAsB,4BAAA,EACtB,wBAAwB,8BAAA,CACQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const baseApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, {}, "api", "AppNotification", typeof import("@reduxjs/toolkit/query").coreModuleName | typeof import("@reduxjs/toolkit/dist/query/react").reactHooksModuleName>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
|
|
3
|
+
// Base query that uses the current project context and auth
|
|
4
|
+
var createBaseQuery = function () {
|
|
5
|
+
return fetchBaseQuery({
|
|
6
|
+
baseUrl: process.env.REACT_APP_API_BASE_URL || 'https://api.replyke.com',
|
|
7
|
+
credentials: 'include', // Equivalent to withCredentials: true
|
|
8
|
+
prepareHeaders: function (headers) {
|
|
9
|
+
// Headers are prepared but don't need auth tokens since we use credentials: 'include'
|
|
10
|
+
// This matches the existing pattern in the Context-based hooks
|
|
11
|
+
return headers;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
// Create the base API slice
|
|
16
|
+
export var baseApi = createApi({
|
|
17
|
+
reducerPath: 'api',
|
|
18
|
+
baseQuery: createBaseQuery(),
|
|
19
|
+
tagTypes: [
|
|
20
|
+
'AppNotification',
|
|
21
|
+
// Future tag types:
|
|
22
|
+
// 'Entity',
|
|
23
|
+
// 'Comment',
|
|
24
|
+
// 'List',
|
|
25
|
+
// 'User',
|
|
26
|
+
],
|
|
27
|
+
endpoints: function () { return ({}); }, // Endpoints will be injected by feature APIs
|
|
28
|
+
});
|
|
29
|
+
// Export hooks for use in components (will be populated by injected endpoints)
|
|
30
|
+
export var _b = _a = baseApi;
|
|
31
|
+
//# sourceMappingURL=baseApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseApi.js","sourceRoot":"","sources":["../../../../src/store/api/baseApi.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEzE,4DAA4D;AAC5D,IAAM,eAAe,GAAG;IACtB,OAAO,cAAc,CAAC;QACpB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,yBAAyB;QACxE,WAAW,EAAE,SAAS,EAAE,sCAAsC;QAC9D,cAAc,EAAE,UAAC,OAAO;YACtB,sFAAsF;YACtF,+DAA+D;YAC/D,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,4BAA4B;AAC5B,MAAM,CAAC,IAAM,OAAO,GAAG,SAAS,CAAC;IAC/B,WAAW,EAAE,KAAK;IAClB,SAAS,EAAE,eAAe,EAAE;IAC5B,QAAQ,EAAE;QACR,iBAAiB;QACjB,oBAAoB;QACpB,YAAY;QACZ,cAAc;QACd,UAAU;QACV,UAAU;KACX;IACD,SAAS,EAAE,cAAM,OAAA,CAAC,EAAE,CAAC,EAAJ,CAAI,EAAE,6CAA6C;CACrE,CAAC,CAAC;AAEH,+EAA+E;AAC/E,MAAM,UAAO,KAAK,OAAO,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Export the base API
|
|
2
|
+
export { baseApi } from "./baseApi";
|
|
3
|
+
// Export app notifications API
|
|
4
|
+
export * from "./appNotificationsApi";
|
|
5
|
+
// Future API exports will go here:
|
|
6
|
+
// export * from "./entitiesApi";
|
|
7
|
+
// export * from "./listsApi";
|
|
8
|
+
// export * from "./commentsApi";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/store/api/index.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,+BAA+B;AAC/B,cAAc,uBAAuB,CAAC;AAEtC,mCAAmC;AACnC,iCAAiC;AACjC,+BAA+B;AAC/B,iCAAiC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
2
|
+
api: import("@reduxjs/toolkit/query").CombinedState<{}, "AppNotification", "api">;
|
|
3
|
+
appNotifications: import("./slices").AppNotificationsState;
|
|
4
|
+
}, import("@reduxjs/toolkit").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("@reduxjs/toolkit").StoreEnhancer<{
|
|
5
|
+
dispatch: import("@reduxjs/toolkit").ThunkDispatch<{
|
|
6
|
+
api: import("@reduxjs/toolkit/query").CombinedState<{}, "AppNotification", "api">;
|
|
7
|
+
appNotifications: import("./slices").AppNotificationsState;
|
|
8
|
+
}, undefined, import("@reduxjs/toolkit").UnknownAction>;
|
|
9
|
+
}>, import("@reduxjs/toolkit").StoreEnhancer]>>;
|
|
10
|
+
export type { RootState, AppDispatch, AppStore, AppThunk } from "./types";
|
|
11
|
+
export { store as replykeStore };
|
|
12
|
+
export { rootReducer } from "./rootReducer";
|
|
13
|
+
export * from "./types";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { configureStore } from "@reduxjs/toolkit";
|
|
2
|
+
import { rootReducer } from "./rootReducer";
|
|
3
|
+
import { customMiddleware } from "./middleware";
|
|
4
|
+
import { baseApi } from "./api/baseApi";
|
|
5
|
+
// Configure the Redux store
|
|
6
|
+
export var store = configureStore({
|
|
7
|
+
reducer: rootReducer,
|
|
8
|
+
middleware: function (getDefaultMiddleware) {
|
|
9
|
+
return getDefaultMiddleware({
|
|
10
|
+
serializableCheck: {
|
|
11
|
+
// Ignore these action types for serializable check
|
|
12
|
+
ignoredActions: ['persist/PERSIST', 'persist/REHYDRATE'],
|
|
13
|
+
// Ignore these field paths in all actions
|
|
14
|
+
ignoredActionsPaths: ['meta.arg', 'payload.timestamp'],
|
|
15
|
+
// Ignore these paths in the state
|
|
16
|
+
ignoredPaths: ['items.dates'],
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
// Add RTK Query middleware
|
|
20
|
+
.concat(baseApi.middleware)
|
|
21
|
+
// Add custom middleware
|
|
22
|
+
.concat(customMiddleware);
|
|
23
|
+
},
|
|
24
|
+
// Enable Redux DevTools in development
|
|
25
|
+
devTools: process.env.NODE_ENV !== 'production',
|
|
26
|
+
});
|
|
27
|
+
// Export store for provider
|
|
28
|
+
export { store as replykeStore };
|
|
29
|
+
// Export for advanced users who need direct access
|
|
30
|
+
export { rootReducer } from "./rootReducer";
|
|
31
|
+
export * from "./types";
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,4BAA4B;AAC5B,MAAM,CAAC,IAAM,KAAK,GAAG,cAAc,CAAC;IAClC,OAAO,EAAE,WAAW;IACpB,UAAU,EAAE,UAAC,oBAAoB;QAC/B,OAAA,oBAAoB,CAAC;YACnB,iBAAiB,EAAE;gBACjB,mDAAmD;gBACnD,cAAc,EAAE,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;gBACxD,0CAA0C;gBAC1C,mBAAmB,EAAE,CAAC,UAAU,EAAE,mBAAmB,CAAC;gBACtD,kCAAkC;gBAClC,YAAY,EAAE,CAAC,aAAa,CAAC;aAC9B;SACF,CAAC;YACA,2BAA2B;aAC1B,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;YAC3B,wBAAwB;aACvB,MAAM,CAAC,gBAAgB,CAAC;IAb3B,CAa2B;IAE7B,uCAAuC;IACvC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;CAChD,CAAC,CAAC;AAKH,4BAA4B;AAC5B,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,CAAC;AAEjC,mDAAmD;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Middleware } from "@reduxjs/toolkit";
|
|
2
|
+
export declare const errorMiddleware: Middleware;
|
|
3
|
+
export declare const loggerMiddleware: Middleware;
|
|
4
|
+
export declare const customMiddleware: Middleware<{}, any, import("@reduxjs/toolkit").Dispatch<import("@reduxjs/toolkit").UnknownAction>>[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { handleError } from "../utils/handleError";
|
|
11
|
+
// Error handling middleware for Redux actions
|
|
12
|
+
export var errorMiddleware = function (store) { return function (next) { return function (action) {
|
|
13
|
+
try {
|
|
14
|
+
return next(action);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
handleError(error, "Redux action failed: ".concat(action.type));
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}; }; };
|
|
21
|
+
// Logger middleware for development
|
|
22
|
+
export var loggerMiddleware = function (store) { return function (next) { return function (action) {
|
|
23
|
+
if (process.env.NODE_ENV === 'development') {
|
|
24
|
+
console.group("\uD83D\uDD04 Redux Action: ".concat(action.type));
|
|
25
|
+
console.log('Previous State:', store.getState());
|
|
26
|
+
console.log('Action:', action);
|
|
27
|
+
}
|
|
28
|
+
var result = next(action);
|
|
29
|
+
if (process.env.NODE_ENV === 'development') {
|
|
30
|
+
console.log('Next State:', store.getState());
|
|
31
|
+
console.groupEnd();
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}; }; };
|
|
35
|
+
// Combine all custom middleware
|
|
36
|
+
export var customMiddleware = __spreadArray([
|
|
37
|
+
errorMiddleware
|
|
38
|
+
], (process.env.NODE_ENV === 'development' ? [loggerMiddleware] : []), true);
|
|
39
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/store/middleware.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,8CAA8C;AAC9C,MAAM,CAAC,IAAM,eAAe,GAAe,UAAC,KAAK,IAAK,OAAA,UAAC,IAAI,IAAK,OA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|
1
|
+
export declare const rootReducer: import("@reduxjs/toolkit").Reducer<{
|
|
2
|
+
api: import("@reduxjs/toolkit/query").CombinedState<{}, "AppNotification", "api">;
|
|
3
|
+
appNotifications: import("./slices/appNotificationsSlice").AppNotificationsState;
|
|
4
|
+
}, import("@reduxjs/toolkit").UnknownAction, Partial<{
|
|
5
|
+
api: import("@reduxjs/toolkit/query").CombinedState<{}, "AppNotification", "api"> | undefined;
|
|
6
|
+
appNotifications: import("./slices/appNotificationsSlice").AppNotificationsState | undefined;
|
|
7
|
+
}>>;
|
|
8
|
+
export type RootState = ReturnType<typeof rootReducer>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { combineReducers } from "@reduxjs/toolkit";
|
|
3
|
+
import { baseApi } from "./api/baseApi";
|
|
4
|
+
import { appNotificationsSlice } from "./slices/appNotificationsSlice";
|
|
5
|
+
// Combine all reducers
|
|
6
|
+
export var rootReducer = combineReducers((_a = {},
|
|
7
|
+
// API slice reducer (manages RTK Query cache)
|
|
8
|
+
_a[baseApi.reducerPath] = baseApi.reducer,
|
|
9
|
+
// Feature slices
|
|
10
|
+
_a.appNotifications = appNotificationsSlice.reducer,
|
|
11
|
+
_a));
|
|
12
|
+
//# sourceMappingURL=rootReducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rootReducer.js","sourceRoot":"","sources":["../../../src/store/rootReducer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,uBAAuB;AACvB,MAAM,CAAC,IAAM,WAAW,GAAG,eAAe;IACxC,8CAA8C;IAC9C,GAAC,OAAO,CAAC,WAAW,IAAG,OAAO,CAAC,OAAO;IAEtC,iBAAiB;IACjB,mBAAgB,GAAE,qBAAqB,CAAC,OAAO;QAM/C,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import type { UnifiedAppNotification, NotificationTemplates } from "../../interfaces/models/AppNotification";
|
|
3
|
+
export interface AppNotificationsState {
|
|
4
|
+
notifications: UnifiedAppNotification[];
|
|
5
|
+
unreadCount: number;
|
|
6
|
+
loading: boolean;
|
|
7
|
+
hasMore: boolean;
|
|
8
|
+
page: number;
|
|
9
|
+
limit: number;
|
|
10
|
+
notificationTemplates?: Partial<NotificationTemplates>;
|
|
11
|
+
currentProjectId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const appNotificationsSlice: import("@reduxjs/toolkit").Slice<AppNotificationsState, {
|
|
14
|
+
setProjectContext: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>, action: PayloadAction<string>) => void;
|
|
15
|
+
setLimit: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>, action: PayloadAction<number>) => void;
|
|
16
|
+
setNotificationTemplates: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>, action: PayloadAction<Partial<NotificationTemplates>>) => void;
|
|
17
|
+
resetNotifications: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>) => void;
|
|
18
|
+
loadMore: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>) => void;
|
|
19
|
+
setLoading: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>, action: PayloadAction<boolean>) => void;
|
|
20
|
+
addNotifications: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>, action: PayloadAction<{
|
|
21
|
+
notifications: UnifiedAppNotification[];
|
|
22
|
+
isFirstPage?: boolean;
|
|
23
|
+
}>) => void;
|
|
24
|
+
markAsReadLocally: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>, action: PayloadAction<string>) => void;
|
|
25
|
+
setUnreadCount: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>, action: PayloadAction<number>) => void;
|
|
26
|
+
handleError: (state: import("@reduxjs/toolkit").WritableDraft<AppNotificationsState>) => void;
|
|
27
|
+
}, "appNotifications", "appNotifications", import("@reduxjs/toolkit").SliceSelectors<AppNotificationsState>>;
|
|
28
|
+
export declare const setProjectContext: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "appNotifications/setProjectContext">, setLimit: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, "appNotifications/setLimit">, setNotificationTemplates: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<NotificationTemplates>, "appNotifications/setNotificationTemplates">, resetNotifications: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"appNotifications/resetNotifications">, loadMore: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"appNotifications/loadMore">, setLoading: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "appNotifications/setLoading">, addNotifications: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
29
|
+
notifications: UnifiedAppNotification[];
|
|
30
|
+
isFirstPage?: boolean;
|
|
31
|
+
}, "appNotifications/addNotifications">, markAsReadLocally: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "appNotifications/markAsReadLocally">, setUnreadCount: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, "appNotifications/setUnreadCount">, handleError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"appNotifications/handleError">;
|
|
32
|
+
declare const _default: import("@reduxjs/toolkit").Reducer<AppNotificationsState>;
|
|
33
|
+
export default _default;
|
|
34
|
+
export declare const selectAppNotifications: (state: {
|
|
35
|
+
appNotifications: AppNotificationsState;
|
|
36
|
+
}) => UnifiedAppNotification[];
|
|
37
|
+
export declare const selectUnreadCount: (state: {
|
|
38
|
+
appNotifications: AppNotificationsState;
|
|
39
|
+
}) => number;
|
|
40
|
+
export declare const selectAppNotificationsLoading: (state: {
|
|
41
|
+
appNotifications: AppNotificationsState;
|
|
42
|
+
}) => boolean;
|
|
43
|
+
export declare const selectAppNotificationsHasMore: (state: {
|
|
44
|
+
appNotifications: AppNotificationsState;
|
|
45
|
+
}) => boolean;
|
|
46
|
+
export declare const selectAppNotificationsPage: (state: {
|
|
47
|
+
appNotifications: AppNotificationsState;
|
|
48
|
+
}) => number;
|
|
49
|
+
export declare const selectAppNotificationsLimit: (state: {
|
|
50
|
+
appNotifications: AppNotificationsState;
|
|
51
|
+
}) => number;
|
|
52
|
+
export declare const selectNotificationTemplates: (state: {
|
|
53
|
+
appNotifications: AppNotificationsState;
|
|
54
|
+
}) => Partial<NotificationTemplates> | undefined;
|
|
55
|
+
export declare const selectCurrentProjectId: (state: {
|
|
56
|
+
appNotifications: AppNotificationsState;
|
|
57
|
+
}) => string | undefined;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
// Initial state
|
|
4
|
+
var initialState = {
|
|
5
|
+
notifications: [],
|
|
6
|
+
unreadCount: 0,
|
|
7
|
+
loading: false,
|
|
8
|
+
hasMore: true,
|
|
9
|
+
page: 1,
|
|
10
|
+
limit: 10,
|
|
11
|
+
notificationTemplates: undefined,
|
|
12
|
+
currentProjectId: undefined,
|
|
13
|
+
};
|
|
14
|
+
// Create the slice
|
|
15
|
+
export var appNotificationsSlice = createSlice({
|
|
16
|
+
name: 'appNotifications',
|
|
17
|
+
initialState: initialState,
|
|
18
|
+
reducers: {
|
|
19
|
+
// Set the current project context
|
|
20
|
+
setProjectContext: function (state, action) {
|
|
21
|
+
state.currentProjectId = action.payload;
|
|
22
|
+
},
|
|
23
|
+
// Set pagination limit
|
|
24
|
+
setLimit: function (state, action) {
|
|
25
|
+
state.limit = action.payload;
|
|
26
|
+
},
|
|
27
|
+
// Set notification templates
|
|
28
|
+
setNotificationTemplates: function (state, action) {
|
|
29
|
+
state.notificationTemplates = action.payload;
|
|
30
|
+
},
|
|
31
|
+
// Reset notifications (clear all and restart pagination)
|
|
32
|
+
resetNotifications: function (state) {
|
|
33
|
+
state.notifications = [];
|
|
34
|
+
state.page = 1;
|
|
35
|
+
state.hasMore = true;
|
|
36
|
+
state.loading = false;
|
|
37
|
+
},
|
|
38
|
+
// Load more notifications (increment page)
|
|
39
|
+
loadMore: function (state) {
|
|
40
|
+
if (state.hasMore && !state.loading) {
|
|
41
|
+
state.page += 1;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
// Set loading state
|
|
45
|
+
setLoading: function (state, action) {
|
|
46
|
+
state.loading = action.payload;
|
|
47
|
+
},
|
|
48
|
+
// Add new notifications (for pagination)
|
|
49
|
+
addNotifications: function (state, action) {
|
|
50
|
+
var _a;
|
|
51
|
+
var _b = action.payload, notifications = _b.notifications, _c = _b.isFirstPage, isFirstPage = _c === void 0 ? false : _c;
|
|
52
|
+
if (isFirstPage) {
|
|
53
|
+
state.notifications = notifications;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Prevent duplicates when adding new pages
|
|
57
|
+
var existingIds_1 = new Set(state.notifications.map(function (n) { return n.id; }));
|
|
58
|
+
var newNotifications = notifications.filter(function (n) { return !existingIds_1.has(n.id); });
|
|
59
|
+
(_a = state.notifications).push.apply(_a, newNotifications);
|
|
60
|
+
}
|
|
61
|
+
// Update hasMore based on returned count vs limit
|
|
62
|
+
if (notifications.length < state.limit) {
|
|
63
|
+
state.hasMore = false;
|
|
64
|
+
}
|
|
65
|
+
state.loading = false;
|
|
66
|
+
},
|
|
67
|
+
// Mark notification as read locally (optimistic update)
|
|
68
|
+
markAsReadLocally: function (state, action) {
|
|
69
|
+
var notificationId = action.payload;
|
|
70
|
+
var notification = state.notifications.find(function (n) { return n.id === notificationId; });
|
|
71
|
+
if (notification && !notification.isRead) {
|
|
72
|
+
notification.isRead = true;
|
|
73
|
+
// Decrease unread count
|
|
74
|
+
state.unreadCount = Math.max(state.unreadCount - 1, 0);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
// Set unread count
|
|
78
|
+
setUnreadCount: function (state, action) {
|
|
79
|
+
state.unreadCount = action.payload;
|
|
80
|
+
},
|
|
81
|
+
// Handle errors by stopping loading
|
|
82
|
+
handleError: function (state) {
|
|
83
|
+
state.loading = false;
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
// Export actions
|
|
88
|
+
export var setProjectContext = (_a = appNotificationsSlice.actions, _a.setProjectContext), setLimit = _a.setLimit, setNotificationTemplates = _a.setNotificationTemplates, resetNotifications = _a.resetNotifications, loadMore = _a.loadMore, setLoading = _a.setLoading, addNotifications = _a.addNotifications, markAsReadLocally = _a.markAsReadLocally, setUnreadCount = _a.setUnreadCount, handleError = _a.handleError;
|
|
89
|
+
// Export reducer
|
|
90
|
+
export default appNotificationsSlice.reducer;
|
|
91
|
+
// Selectors
|
|
92
|
+
export var selectAppNotifications = function (state) {
|
|
93
|
+
return state.appNotifications.notifications;
|
|
94
|
+
};
|
|
95
|
+
export var selectUnreadCount = function (state) {
|
|
96
|
+
return state.appNotifications.unreadCount;
|
|
97
|
+
};
|
|
98
|
+
export var selectAppNotificationsLoading = function (state) {
|
|
99
|
+
return state.appNotifications.loading;
|
|
100
|
+
};
|
|
101
|
+
export var selectAppNotificationsHasMore = function (state) {
|
|
102
|
+
return state.appNotifications.hasMore;
|
|
103
|
+
};
|
|
104
|
+
export var selectAppNotificationsPage = function (state) {
|
|
105
|
+
return state.appNotifications.page;
|
|
106
|
+
};
|
|
107
|
+
export var selectAppNotificationsLimit = function (state) {
|
|
108
|
+
return state.appNotifications.limit;
|
|
109
|
+
};
|
|
110
|
+
export var selectNotificationTemplates = function (state) {
|
|
111
|
+
return state.appNotifications.notificationTemplates;
|
|
112
|
+
};
|
|
113
|
+
export var selectCurrentProjectId = function (state) {
|
|
114
|
+
return state.appNotifications.currentProjectId;
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=appNotificationsSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appNotificationsSlice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B,CAA8B,CAAC;AAEjC,MAAM,CAAC,IAAM,6BAA6B,GAAG,UAAC,KAAkD;IAC9F,OAAA,KAAK,CAAC,gBAAgB,CAAC,OAAO;AAA9B,CAA8B,CAAC;AAEjC,MAAM,CAAC,IAAM,0BAA0B,GAAG,UAAC,KAAkD;IAC3F,OAAA,KAAK,CAAC,gBAAgB,CAAC,IAAI;AAA3B,CAA2B,CAAC;AAE9B,MAAM,CAAC,IAAM,2BAA2B,GAAG,UAAC,KAAkD;IAC5F,OAAA,KAAK,CAAC,gBAAgB,CAAC,KAAK;AAA5B,CAA4B,CAAC;AAE/B,MAAM,CAAC,IAAM,2BAA2B,GAAG,UAAC,KAAkD;IAC5F,OAAA,KAAK,CAAC,gBAAgB,CAAC,qBAAqB;AAA5C,CAA4C,CAAC;AAE/C,MAAM,CAAC,IAAM,sBAAsB,GAAG,UAAC,KAAkD;IACvF,OAAA,KAAK,CAAC,gBAAgB,CAAC,gBAAgB;AAAvC,CAAuC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./appNotificationsSlice";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/store/slices/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,cAAc,yBAAyB,CAAC;AAExC,qCAAqC;AACrC,mCAAmC;AACnC,gCAAgC;AAChC,mCAAmC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Action, ThunkAction } from "@reduxjs/toolkit";
|
|
2
|
+
import type { RootState } from "../rootReducer";
|
|
3
|
+
import type { store } from "../index";
|
|
4
|
+
export type AppStore = typeof store;
|
|
5
|
+
export type { RootState };
|
|
6
|
+
export type AppDispatch = AppStore['dispatch'];
|
|
7
|
+
export type AppThunk<ReturnType = void> = ThunkAction<ReturnType, RootState, unknown, Action<string>>;
|
|
8
|
+
export type TypedSelector<T> = (state: RootState) => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/store/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replyke/core",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.5-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Replyke, maintained by Yanay Tsabary",
|
|
@@ -40,9 +40,11 @@
|
|
|
40
40
|
"dist"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@reduxjs/toolkit": "^2.0.1",
|
|
43
44
|
"axios": "^1.4.0",
|
|
44
45
|
"js-cookie": "^3.0.5",
|
|
45
|
-
"lodash": "^4.17.21"
|
|
46
|
+
"lodash": "^4.17.21",
|
|
47
|
+
"react-redux": "^9.0.4"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"@types/js-cookie": "^3.0.6",
|