@feardread/feature-factory 5.0.6 → 5.0.8
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/README.md +0 -0
- package/dist/bundle.min.js +2 -2
- package/dist/index.esm.js +3 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -0
- package/package.json +2 -1
- package/rollup.config.mjs +0 -0
- package/src/factory/api.js +14 -11
- package/src/factory/cache.js +0 -0
- package/src/factory/index.js +1 -2
- package/src/factory/service.js +0 -0
- package/src/factory/state.js +1 -1
- package/src/factory/thunk.js +4 -4
- package/src/index.js +0 -0
- package/tsup.config.ts +0 -0
- package/.env +0 -4
package/dist/index.mjs
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feardread/feature-factory",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.8",
|
|
4
4
|
"description": "Library to interact with redux toolkit and reduce boilerplate / repeated code",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/core": "^7.28.0",
|
|
20
20
|
"@reduxjs/toolkit": "^2.8.2",
|
|
21
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
21
22
|
"axios": "^1.11.0",
|
|
22
23
|
"react": "^19.1.0",
|
|
23
24
|
"react-redux": "^9.2.0",
|
package/rollup.config.mjs
CHANGED
|
File without changes
|
package/src/factory/api.js
CHANGED
|
@@ -6,39 +6,39 @@ import CacheFactory from './cache';
|
|
|
6
6
|
* Environment-based configuration
|
|
7
7
|
*/
|
|
8
8
|
const CONFIG = {
|
|
9
|
+
BASE_URL: null,
|
|
9
10
|
// API Base URLs
|
|
10
11
|
baseUrls: {
|
|
11
|
-
production: process.env.
|
|
12
|
-
development: process.env.
|
|
13
|
-
test: process.env.
|
|
12
|
+
production: process.env.API_BASE_URL_PROD || 'http://fear.master.com/fear/api/',
|
|
13
|
+
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/',
|
|
14
15
|
},
|
|
15
|
-
|
|
16
|
-
// Token configuration
|
|
17
16
|
tokenNames: {
|
|
18
17
|
bearer: 'Authorization',
|
|
19
18
|
custom: process.env.REACT_APP_JWT_TOKEN_HEADER || 'x-token',
|
|
20
19
|
},
|
|
21
|
-
|
|
22
|
-
// Cache keys
|
|
23
20
|
cacheKeys: {
|
|
24
21
|
auth: 'auth',
|
|
25
22
|
refreshToken: 'refresh_token',
|
|
26
23
|
userPrefs: 'user_preferences',
|
|
27
24
|
},
|
|
28
|
-
|
|
29
|
-
// Request configuration
|
|
30
25
|
timeout: parseInt(process.env.REACT_APP_API_TIMEOUT) || 30000,
|
|
31
26
|
retryAttempts: parseInt(process.env.REACT_APP_API_RETRY_ATTEMPTS) || 3,
|
|
32
27
|
retryDelay: parseInt(process.env.REACT_APP_API_RETRY_DELAY) || 1000,
|
|
33
28
|
};
|
|
34
29
|
|
|
30
|
+
const setBaseUrl = (uri) => {
|
|
31
|
+
CONFIG.BASE_URL = uri || CONFIG.baseUrls['development'];
|
|
32
|
+
getBaseUrl();
|
|
33
|
+
};
|
|
35
34
|
/**
|
|
36
35
|
* Gets the appropriate base URL for the current environment
|
|
37
36
|
* @returns {string} Base URL
|
|
38
37
|
*/
|
|
39
38
|
const getBaseUrl = () => {
|
|
40
|
-
const env =
|
|
41
|
-
|
|
39
|
+
const env = process.env.NODE_ENV || 'development';
|
|
40
|
+
if (!CONFIG.BASE_URL) CONFIG.BASE_URL = CONFIG.baseUrls[env] || CONFIG.baseUrls.development
|
|
41
|
+
return CONFIG.BASE_URL;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -232,6 +232,8 @@ const responseInterceptor = (response) => {
|
|
|
232
232
|
requestId: response.config.headers['X-Request-ID'],
|
|
233
233
|
};
|
|
234
234
|
|
|
235
|
+
console.log('Loaded Env = ', process.env);
|
|
236
|
+
|
|
235
237
|
// Log successful responses in development
|
|
236
238
|
if (process.env.NODE_ENV === 'development') {
|
|
237
239
|
console.log(`✅ API Success [${response.status}]:`, {
|
|
@@ -525,6 +527,7 @@ const API = {
|
|
|
525
527
|
// Configuration access
|
|
526
528
|
config: CONFIG,
|
|
527
529
|
getBaseUrl,
|
|
530
|
+
setBaseUrl
|
|
528
531
|
};
|
|
529
532
|
|
|
530
533
|
// Add event listener for auth failures (optional)
|
package/src/factory/cache.js
CHANGED
|
File without changes
|
package/src/factory/index.js
CHANGED
|
@@ -174,9 +174,8 @@ export function FeatureFactory(entity, reducers = {}, endpoints = null) {
|
|
|
174
174
|
reducers,
|
|
175
175
|
adapter,
|
|
176
176
|
manager: createReducerManager,
|
|
177
|
-
inject: mergeObjects,
|
|
177
|
+
inject: mergeObjects,
|
|
178
178
|
create: createFactorySlice,
|
|
179
|
-
|
|
180
179
|
// Utility methods
|
|
181
180
|
getEntityName: () => entity,
|
|
182
181
|
getAdapter: () => adapter,
|
package/src/factory/service.js
CHANGED
|
File without changes
|
package/src/factory/state.js
CHANGED
package/src/factory/thunk.js
CHANGED
|
@@ -255,13 +255,13 @@ export const ThunkFactory = {
|
|
|
255
255
|
validateThunkParams(entity, 'crud');
|
|
256
256
|
|
|
257
257
|
return {
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
fetch: ThunkFactory.create(entity, 'all'),
|
|
259
|
+
read: ThunkFactory.create(entity, 'one'),
|
|
260
260
|
create: ThunkFactory.post(entity, 'create'),
|
|
261
261
|
update: ThunkFactory.put(entity, 'update'),
|
|
262
262
|
patch: ThunkFactory.patch(entity, 'patch'),
|
|
263
263
|
delete: ThunkFactory.delete(entity, 'delete'),
|
|
264
|
-
search: ThunkFactory.
|
|
264
|
+
search: ThunkFactory.post(entity, 'search'),
|
|
265
265
|
};
|
|
266
266
|
},
|
|
267
267
|
|
|
@@ -276,8 +276,8 @@ export const ThunkFactory = {
|
|
|
276
276
|
* @returns {Object} Standard operations object
|
|
277
277
|
*/
|
|
278
278
|
getStandardOperations: () => ({ ...STANDARD_OPERATIONS }),
|
|
279
|
+
setApiUrl: (url) => { ThunkFactory.API_URL = url; ThunkFactory.getApiUrl(); },
|
|
279
280
|
getApiUrl: () => { return ThunkFactory.API_URL },
|
|
280
|
-
setApiUrl: (url) => { ThunkFactory.API_URL = url }
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
export default ThunkFactory;
|
package/src/index.js
CHANGED
|
File without changes
|
package/tsup.config.ts
CHANGED
|
File without changes
|
package/.env
DELETED