@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/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 +5 -3
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
|
|
|
@@ -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
|
|
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') {
|