@aprilium/tripsm_global-states 0.0.106 → 0.0.107

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aprilium/tripsm_global-states",
3
- "version": "0.0.106",
3
+ "version": "0.0.107",
4
4
  "description": "global states",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -14,17 +14,12 @@
14
14
  "dependencies": {
15
15
  "@aprilium/tripsm_passenger": "^0.0.49",
16
16
  "@aprilium/tripsm_common": "^0.0.6",
17
- "@aprilium/tripsm_constants": "^0.0.12",
17
+ "@aprilium/tripsm_constants": "^0.0.14",
18
18
  "@aprilium/tripsm_trip": "^0.0.5",
19
19
  "@aprilium/tripsm_trip-group": "^0.0.2",
20
20
  "@aprilium/tripsm_user":"^0.0.6",
21
21
  "@aprilium/tripsm_passenger-hotel":"^0.0.2",
22
22
  "@aprilium/tripsm_identity-type":"^0.0.2",
23
- "@aprilium/tripsm_identity":"^0.0.1",
24
- "@aprilium/tripsm_luggage":"^0.0.1",
25
-
26
-
27
-
28
23
  "@types/react": "^17.0.0",
29
24
  "axios": "^0.21.1",
30
25
  "immer": "^9.0.15",
package/lib/index.d.ts DELETED
@@ -1,51 +0,0 @@
1
- /// <reference types="redux-persist/types/types" />
2
- import { Store } from 'redux';
3
- import { Saga } from 'redux-saga';
4
- import { PersistGate } from 'redux-persist/integration/react';
5
- import { PersistConfig } from 'redux-persist';
6
- import { State as passengerState } from '@aprilium/tripsm_passenger/lib/state';
7
- import { State as constantState } from '@aprilium/tripsm_constants/lib/state';
8
- import { State as tripState } from '@aprilium/tripsm_trip/lib/state';
9
- import { State as groupState } from '@aprilium/tripsm_trip-group/lib/state';
10
- import { State as userState } from '@aprilium/tripsm_user/lib/state';
11
- import passengerSaga from '@aprilium/tripsm_passenger/lib/effects';
12
- import constantsSaga from '@aprilium/tripsm_constants/lib/effects';
13
- import TripSaga from '@aprilium/tripsm_trip/lib/effects';
14
- import groupSaga from '@aprilium/tripsm_trip-group/lib/effects';
15
- import userSaga from '@aprilium/tripsm_user/lib/effects';
16
- export declare const sagaMiddleware: import("redux-saga").SagaMiddleware<object>;
17
- export declare const reducers: {
18
- passenger: import("immer-reducer").ImmerReducerFunction<typeof import("@aprilium/tripsm_passenger/lib/state").PassengerState>;
19
- constants: import("immer-reducer").ImmerReducerFunction<typeof import("@aprilium/tripsm_constants/lib/state").ConstantState>;
20
- trip: import("immer-reducer").ImmerReducerFunction<typeof import("@aprilium/tripsm_trip/lib/state").TripState>;
21
- group: import("immer-reducer").ImmerReducerFunction<typeof import("@aprilium/tripsm_trip-group/lib/state").GroupState>;
22
- user: import("immer-reducer").ImmerReducerFunction<typeof import("@aprilium/tripsm_user/lib/state").UserState>;
23
- };
24
- export declare const initialSagas: {
25
- passenger: typeof passengerSaga;
26
- constants: typeof constantsSaga;
27
- trip: typeof TripSaga;
28
- group: typeof groupSaga;
29
- user: typeof userSaga;
30
- };
31
- export type States = {
32
- passenger: passengerState;
33
- constants: constantState;
34
- group: groupState;
35
- trip: tripState;
36
- user: userState;
37
- };
38
- export type StateName = 'passenger' | 'constants' | 'trip' | 'group' | 'user';
39
- export declare function setUrlConfig(coreApi: string, debugMode?: boolean): void;
40
- export declare const sagas: (typeof passengerSaga | typeof constantsSaga | typeof userSaga | typeof TripSaga | typeof groupSaga)[];
41
- export declare function initSagaMiddleware(extraSagas?: Array<Saga>, // local sagas from frontEnd Client
42
- waitForRehydrate?: boolean): void;
43
- declare function configStore(extraMiddleWares: any[] | undefined, // Adding other middlewares
44
- persistConfig: PersistConfig<unknown, any, any, any>, // Configuration for persistState
45
- extraStates?: any, // Adding other states in the store
46
- replaceAllStates?: boolean): {
47
- store: Store<any, any>;
48
- persistor: import("redux-persist").Persistor;
49
- PersistGate: typeof PersistGate;
50
- };
51
- export default configStore;
package/lib/index.js DELETED
@@ -1,172 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __generator = (this && this.__generator) || function (thisArg, body) {
14
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
15
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
16
- function verb(n) { return function (v) { return step([n, v]); }; }
17
- function step(op) {
18
- if (f) throw new TypeError("Generator is already executing.");
19
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
20
- 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;
21
- if (y = 0, t) op = [op[0] & 2, t.value];
22
- switch (op[0]) {
23
- case 0: case 1: t = op; break;
24
- case 4: _.label++; return { value: op[1], done: false };
25
- case 5: _.label++; y = op[1]; op = [0]; continue;
26
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
27
- default:
28
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
29
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
30
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
31
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
32
- if (t[2]) _.ops.pop();
33
- _.trys.pop(); continue;
34
- }
35
- op = body.call(thisArg, _);
36
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
37
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
38
- }
39
- };
40
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
41
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
42
- if (ar || !(i in from)) {
43
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
44
- ar[i] = from[i];
45
- }
46
- }
47
- return to.concat(ar || Array.prototype.slice.call(from));
48
- };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.initSagaMiddleware = exports.sagas = exports.setUrlConfig = exports.initialSagas = exports.reducers = exports.sagaMiddleware = void 0;
54
- var redux_1 = require("redux");
55
- var redux_saga_1 = __importDefault(require("redux-saga"));
56
- var effects_1 = require("redux-saga/effects");
57
- var react_1 = require("redux-persist/integration/react");
58
- var redux_persist_1 = require("redux-persist");
59
- var lib_1 = require("@aprilium/tripsm_passenger/lib");
60
- var lib_2 = require("@aprilium/tripsm_constants/lib");
61
- var lib_3 = require("@aprilium/tripsm_passenger/lib");
62
- var lib_4 = require("@aprilium/tripsm_user/lib");
63
- var state_1 = require("@aprilium/tripsm_passenger/lib/state");
64
- var state_2 = require("@aprilium/tripsm_constants/lib/state");
65
- var state_3 = require("@aprilium/tripsm_trip/lib/state");
66
- var state_4 = require("@aprilium/tripsm_trip-group/lib/state");
67
- var state_5 = require("@aprilium/tripsm_user/lib/state");
68
- //import sagas
69
- var effects_2 = __importDefault(require("@aprilium/tripsm_passenger/lib/effects"));
70
- var effects_3 = __importDefault(require("@aprilium/tripsm_constants/lib/effects"));
71
- var effects_4 = __importDefault(require("@aprilium/tripsm_trip/lib/effects"));
72
- var effects_5 = __importDefault(require("@aprilium/tripsm_trip-group/lib/effects"));
73
- var effects_6 = __importDefault(require("@aprilium/tripsm_user/lib/effects"));
74
- exports.sagaMiddleware = (0, redux_saga_1.default)();
75
- exports.reducers = {
76
- passenger: state_1.passengerReducerFunction,
77
- constants: state_2.ConstantsReducerFunction,
78
- trip: state_3.TripReducerFunction,
79
- group: state_4.GroupReducerFunction,
80
- user: state_5.userReducerFunction
81
- };
82
- exports.initialSagas = {
83
- passenger: effects_2.default,
84
- constants: effects_3.default,
85
- trip: effects_4.default,
86
- group: effects_5.default,
87
- user: effects_6.default
88
- };
89
- function setUrlConfig(coreApi, debugMode) {
90
- if (debugMode === void 0) { debugMode = false; }
91
- lib_1.urlsConfig.setURls({
92
- CORE_BASE_URL: coreApi,
93
- DEBUG_MODE: debugMode
94
- });
95
- lib_2.urlsConfig.setURls({
96
- CORE_BASE_URL: coreApi,
97
- DEBUG_MODE: debugMode
98
- });
99
- lib_3.urlsConfig.setURls({
100
- CORE_BASE_URL: coreApi,
101
- DEBUG_MODE: debugMode
102
- });
103
- lib_4.urlsConfig.setURls({
104
- CORE_BASE_URL: coreApi,
105
- DEBUG_MODE: debugMode
106
- });
107
- }
108
- exports.setUrlConfig = setUrlConfig;
109
- exports.sagas = Object.keys(exports.initialSagas).map(function (key) { return exports.initialSagas[key]; });
110
- function initSagaMiddleware(extraSagas, // local sagas from frontEnd Client
111
- waitForRehydrate) {
112
- if (extraSagas === void 0) { extraSagas = []; }
113
- if (waitForRehydrate === void 0) { waitForRehydrate = false; }
114
- console.log("extraSagas", extraSagas);
115
- var _sagas = __spreadArray(__spreadArray([], exports.sagas, true), extraSagas, true);
116
- console.log("_sagas", _sagas);
117
- // It will initialize all sagas
118
- function rootSaga() {
119
- var instSagas;
120
- return __generator(this, function (_a) {
121
- switch (_a.label) {
122
- case 0:
123
- if (!waitForRehydrate) return [3 /*break*/, 2];
124
- return [4 /*yield*/, (0, effects_1.take)(redux_persist_1.REHYDRATE)];
125
- case 1:
126
- _a.sent();
127
- _a.label = 2;
128
- case 2: return [4 /*yield*/, _sagas.map(function (saga) {
129
- return __generator(this, function (_a) {
130
- switch (_a.label) {
131
- case 0: return [4 /*yield*/, (0, effects_1.fork)(saga)];
132
- case 1:
133
- _a.sent();
134
- return [2 /*return*/];
135
- }
136
- });
137
- })];
138
- case 3:
139
- instSagas = _a.sent();
140
- return [4 /*yield*/, (0, effects_1.all)(instSagas)];
141
- case 4:
142
- _a.sent();
143
- return [2 /*return*/];
144
- }
145
- });
146
- }
147
- // Start the listener
148
- exports.sagaMiddleware.run(rootSaga);
149
- }
150
- exports.initSagaMiddleware = initSagaMiddleware;
151
- function configStore(extraMiddleWares, // Adding other middlewares
152
- persistConfig, // Configuration for persistState
153
- extraStates, // Adding other states in the store
154
- replaceAllStates // It will keep only extraStates
155
- ) {
156
- if (extraMiddleWares === void 0) { extraMiddleWares = []; }
157
- if (extraStates === void 0) { extraStates = {}; }
158
- if (replaceAllStates === void 0) { replaceAllStates = false; }
159
- console.log("configuration du store");
160
- console.log("extra middleware", extraMiddleWares);
161
- var _reducers = (0, redux_1.combineReducers)(__assign(__assign({}, exports.reducers), extraStates));
162
- if (replaceAllStates) {
163
- _reducers = (0, redux_1.combineReducers)(__assign({}, extraStates));
164
- }
165
- var _middleWares = __spreadArray(__spreadArray([], extraMiddleWares, true), [exports.sagaMiddleware], false);
166
- // @ts-ignore
167
- var persistedReducer = (0, redux_persist_1.persistReducer)(persistConfig, _reducers);
168
- var store = (0, redux_1.createStore)(persistedReducer, redux_1.applyMiddleware.apply(void 0, _middleWares));
169
- var persistor = (0, redux_persist_1.persistStore)(store);
170
- return { store: store, persistor: persistor, PersistGate: react_1.PersistGate };
171
- }
172
- exports.default = configStore;