@feardread/feature-factory 5.1.1 → 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.1",
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
 
@@ -279,13 +283,11 @@ export const addHandlers = (builder, asyncActions, entity) => {
279
283
  state.loading = false;
280
284
  state.success = true;
281
285
  state.loadingState = 'fulfilled';
282
-
283
286
  // Handle different response structures
284
287
  const payload = actionPayload.payload;
285
- console.log('payload = ', payload);
286
288
  // Update data based on operation type
287
289
  if (key === 'fetch' || key === 'search') {
288
- state.data = Array.isArray(payload) ? payload : (payload?.data.result || []);
290
+ state.data = Array.isArray(payload) ? payload : (payload?.data || []);
289
291
  } else if (key === 'fetchOne') {
290
292
  state[entity] = Array.isArray(payload) ? payload[0] : payload;
291
293
  } else if (key === 'create') {