@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feardread/feature-factory",
3
- "version": "5.1.2",
3
+ "version": "5.2.3",
4
4
  "description": "Library to interact with redux toolkit and reduce boilerplate / repeated code",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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 || 'http://fear.master.com/fear/api/',
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.dedyn.io/fear/api/',
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 (process.env.NODE_ENV === 'development') {
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 (process.env.NODE_ENV === 'development') {
278
+ if (CONFIG.environment === 'development') {
280
279
  console.error(`❌ API Error [${formattedError.status}]:`, {
281
280
  url: originalRequest?.url,
282
281
  error: formattedError,
@@ -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
- console.log('Initial State :: ', initialState);
223
+
224
+ if (config.DEBUG) {
225
+ console.log('Initial State: ', initialState);
226
+ }
223
227
  return initialState;
224
228
  };
225
229
 
@@ -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'),
@@ -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
  };