@feardread/feature-factory 5.1.2 → 5.2.3
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/bundle.min.js +2 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/factory/api.js +5 -6
- package/src/factory/state.js +5 -1
- package/src/factory/thunk.js +1 -0
- package/src/factory/utils.js +4 -6
package/package.json
CHANGED
package/src/factory/api.js
CHANGED
|
@@ -7,11 +7,12 @@ import CacheFactory from './cache';
|
|
|
7
7
|
*/
|
|
8
8
|
const CONFIG = {
|
|
9
9
|
BASE_URL: null,
|
|
10
|
+
environment: process.env.NODE_ENV,
|
|
10
11
|
// API Base URLs
|
|
11
12
|
baseUrls: {
|
|
12
|
-
production: process.env.API_BASE_URL_PROD || '
|
|
13
|
+
production: process.env.API_BASE_URL_PROD || 'https://fear.dedyn.io/fear/api/',
|
|
13
14
|
development: process.env.API_BASE_URL_DEV || 'http://localhost:4000/fear/api/',
|
|
14
|
-
test: process.env.API_BASE_URL_TEST || 'https://fear.
|
|
15
|
+
test: process.env.API_BASE_URL_TEST || 'https://fear.master.com/fear/api/',
|
|
15
16
|
},
|
|
16
17
|
tokenNames: {
|
|
17
18
|
bearer: 'Authorization',
|
|
@@ -231,10 +232,8 @@ const responseInterceptor = (response) => {
|
|
|
231
232
|
requestId: response.config.headers['X-Request-ID'],
|
|
232
233
|
};
|
|
233
234
|
|
|
234
|
-
console.log('Loaded Env = ', process.env);
|
|
235
|
-
|
|
236
235
|
// Log successful responses in development
|
|
237
|
-
if (
|
|
236
|
+
if (CONFIG.environment === 'development') {
|
|
238
237
|
console.log(`✅ API Success [${response.status}]:`, {
|
|
239
238
|
url: response.config.url,
|
|
240
239
|
data: response.data,
|
|
@@ -276,7 +275,7 @@ const responseErrorInterceptor = async (error) => {
|
|
|
276
275
|
const formattedError = formatError(error);
|
|
277
276
|
|
|
278
277
|
// Log errors in development
|
|
279
|
-
if (
|
|
278
|
+
if (CONFIG.environment === 'development') {
|
|
280
279
|
console.error(`❌ API Error [${formattedError.status}]:`, {
|
|
281
280
|
url: originalRequest?.url,
|
|
282
281
|
error: formattedError,
|
package/src/factory/state.js
CHANGED
|
@@ -10,6 +10,7 @@ const DEFAULT_OPTIONS = {
|
|
|
10
10
|
includeValidation: false,
|
|
11
11
|
includeMetadata: true,
|
|
12
12
|
customFields: {},
|
|
13
|
+
DEBUG: true,
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -219,7 +220,10 @@ export const StateFactory = (namespace, options = {}) => {
|
|
|
219
220
|
...optionalStates,
|
|
220
221
|
...config.customFields,
|
|
221
222
|
};
|
|
222
|
-
|
|
223
|
+
|
|
224
|
+
if (config.DEBUG) {
|
|
225
|
+
console.log('Initial State: ', initialState);
|
|
226
|
+
}
|
|
223
227
|
return initialState;
|
|
224
228
|
};
|
|
225
229
|
|
package/src/factory/thunk.js
CHANGED
|
@@ -258,6 +258,7 @@ export const ThunkFactory = {
|
|
|
258
258
|
fetch: ThunkFactory.create(entity, 'all'),
|
|
259
259
|
read: ThunkFactory.create(entity, 'one'),
|
|
260
260
|
create: ThunkFactory.post(entity, 'create'),
|
|
261
|
+
new: ThunkFactory.post(entity, 'new'),
|
|
261
262
|
update: ThunkFactory.put(entity, 'update'),
|
|
262
263
|
patch: ThunkFactory.patch(entity, 'patch'),
|
|
263
264
|
delete: ThunkFactory.delete(entity, 'delete'),
|
package/src/factory/utils.js
CHANGED
|
@@ -252,6 +252,10 @@ export const createThunks = (entity, operations = {}) => {
|
|
|
252
252
|
thunks.delete = ThunkFactory.delete(entity, 'delete');
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
if (config.new) {
|
|
256
|
+
thunks.new = ThunkFactory.post(entity, 'new');
|
|
257
|
+
}
|
|
258
|
+
|
|
255
259
|
return thunks;
|
|
256
260
|
};
|
|
257
261
|
|
|
@@ -274,17 +278,13 @@ export const addHandlers = (builder, asyncActions, entity) => {
|
|
|
274
278
|
lastRun: new Date().toISOString(),
|
|
275
279
|
};
|
|
276
280
|
}
|
|
277
|
-
console.log('pending state = ', state);
|
|
278
281
|
})
|
|
279
282
|
.addCase(action.fulfilled, (state, actionPayload) => {
|
|
280
283
|
state.loading = false;
|
|
281
284
|
state.success = true;
|
|
282
285
|
state.loadingState = 'fulfilled';
|
|
283
|
-
|
|
284
286
|
// Handle different response structures
|
|
285
287
|
const payload = actionPayload.payload;
|
|
286
|
-
console.log('fulfilled state = ', state);
|
|
287
|
-
console.log('loading state = false (success)', payload);
|
|
288
288
|
// Update data based on operation type
|
|
289
289
|
if (key === 'fetch' || key === 'search') {
|
|
290
290
|
state.data = Array.isArray(payload) ? payload : (payload?.data || []);
|
|
@@ -328,7 +328,6 @@ export const addHandlers = (builder, asyncActions, entity) => {
|
|
|
328
328
|
lastRun: new Date().toISOString(),
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
|
-
console.log('fully fulfilled state :: ', state);
|
|
332
331
|
})
|
|
333
332
|
.addCase(action.rejected, (state, actionPayload) => {
|
|
334
333
|
state.loading = false;
|
|
@@ -344,7 +343,6 @@ export const addHandlers = (builder, asyncActions, entity) => {
|
|
|
344
343
|
lastRun: new Date().toISOString(),
|
|
345
344
|
};
|
|
346
345
|
}
|
|
347
|
-
console.log('Rejected state = ', state);
|
|
348
346
|
});
|
|
349
347
|
});
|
|
350
348
|
};
|