@techstuff-dev/foundation-api-utils 1.51.0 → 1.52.0
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/cjs/chunks/{shared-CPf85o9W.js → shared-DjCjH7LG.js} +2 -2
- package/dist/cjs/chunks/{shared-CPf85o9W.js.map → shared-DjCjH7LG.js.map} +1 -1
- package/dist/cjs/chunks/{slice-CHzSWFmR.js → slice-Jly4VFS9.js} +78 -7
- package/dist/cjs/chunks/slice-Jly4VFS9.js.map +1 -0
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/store/index.native.js +2 -2
- package/dist/cjs/store/index.web.js +2 -2
- package/dist/esm/chunks/{shared-9n1t2QnH.js → shared-DhOT8XMm.js} +2 -2
- package/dist/esm/chunks/{shared-9n1t2QnH.js.map → shared-DhOT8XMm.js.map} +1 -1
- package/dist/esm/chunks/{slice-Bersugzi.js → slice-CFI-0qr6.js} +79 -9
- package/dist/esm/chunks/slice-CFI-0qr6.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/store/index.native.js +2 -2
- package/dist/esm/store/index.web.js +2 -2
- package/dist/types/index.d.ts +53 -3
- package/package.json +1 -1
- package/dist/cjs/chunks/slice-CHzSWFmR.js.map +0 -1
- package/dist/esm/chunks/slice-Bersugzi.js.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var slice = require('./chunks/slice-
|
|
3
|
+
var slice = require('./chunks/slice-Jly4VFS9.js');
|
|
4
4
|
var slice$1 = require('./chunks/slice-CkWobkWw.js');
|
|
5
5
|
var useAuth = require('./chunks/useAuth-DKhvUX_r.js');
|
|
6
6
|
require('aws-amplify');
|
|
@@ -17,6 +17,7 @@ exports.applyTax = slice.applyTax;
|
|
|
17
17
|
exports.authApi = slice.authApi;
|
|
18
18
|
exports.cartSlice = slice.cartSlice;
|
|
19
19
|
exports.contentApi = slice.contentApi;
|
|
20
|
+
exports.createUnwrappingBaseQuery = slice.createUnwrappingBaseQuery;
|
|
20
21
|
exports.emptyCart = slice.emptyCart;
|
|
21
22
|
exports.formatAuthSession = slice.formatAuthSession;
|
|
22
23
|
exports.formatChallengeDays = slice.formatChallengeDays;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var toolkit = require('@reduxjs/toolkit');
|
|
4
4
|
var storage = require('@react-native-async-storage/async-storage');
|
|
5
|
-
var slice = require('../chunks/slice-
|
|
6
|
-
var shared = require('../chunks/shared-
|
|
5
|
+
var slice = require('../chunks/slice-Jly4VFS9.js');
|
|
6
|
+
var shared = require('../chunks/shared-DjCjH7LG.js');
|
|
7
7
|
require('aws-amplify');
|
|
8
8
|
require('../chunks/slice-CkWobkWw.js');
|
|
9
9
|
require('react-redux');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var toolkit = require('@reduxjs/toolkit');
|
|
4
|
-
var slice = require('../chunks/slice-
|
|
5
|
-
var shared = require('../chunks/shared-
|
|
4
|
+
var slice = require('../chunks/slice-Jly4VFS9.js');
|
|
5
|
+
var shared = require('../chunks/shared-DjCjH7LG.js');
|
|
6
6
|
require('aws-amplify');
|
|
7
7
|
require('../chunks/slice-CkWobkWw.js');
|
|
8
8
|
require('react-redux');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { combineSlices } from '@reduxjs/toolkit';
|
|
2
|
-
import { r as cartSlice, a as authApi, c as contentApi, p as paymentApi, o as ordersApi } from './slice-
|
|
2
|
+
import { r as cartSlice, a as authApi, c as contentApi, p as paymentApi, o as ordersApi } from './slice-CFI-0qr6.js';
|
|
3
3
|
import { a as authSlice } from './slice-ChJ8ZvmP.js';
|
|
4
4
|
|
|
5
5
|
// This file exists just so TypeScript has a module at ./store for IDEs/build.
|
|
@@ -9,4 +9,4 @@ import { a as authSlice } from './slice-ChJ8ZvmP.js';
|
|
|
9
9
|
const rootReducer = combineSlices(cartSlice, authSlice, authApi, contentApi, paymentApi, ordersApi);
|
|
10
10
|
|
|
11
11
|
export { rootReducer as r };
|
|
12
|
-
//# sourceMappingURL=shared-
|
|
12
|
+
//# sourceMappingURL=shared-DhOT8XMm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-DhOT8XMm.js","sources":["../../../lib/store/shared.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;AACA;AASA;AAEA;AACO,MAAM,WAAW,GAAG,aAAa,CACtC,SAAS,EACT,SAAS,EACT,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Auth } from 'aws-amplify';
|
|
2
2
|
import { r as resetCreating, s as setCredentials, l as logout } from './slice-ChJ8ZvmP.js';
|
|
3
|
-
import { nanoid, formatProdErrorMessage,
|
|
3
|
+
import { nanoid, formatProdErrorMessage, createAction, createSelector as createSelector$1, isPlainObject as isPlainObject$1, createNextState, createAsyncThunk, createSlice, prepareAutoBatched, isAnyOf, isFulfilled, isRejectedWithValue, combineReducers, SHOULD_AUTOBATCH, isAllOf, isRejected, isPending, isAction, isAsyncThunkAction } from '@reduxjs/toolkit';
|
|
4
4
|
import { useStore, useSelector, useDispatch, batch, shallowEqual } from 'react-redux';
|
|
5
5
|
import { useCallback, useDebugValue, useMemo, useState, useEffect, useRef, useLayoutEffect } from 'react';
|
|
6
6
|
import { jwtDecode } from 'jwt-decode';
|
|
@@ -4682,6 +4682,75 @@ Hook ${hookName} was either not provided or not a function.`);
|
|
|
4682
4682
|
// src/query/react/index.ts
|
|
4683
4683
|
var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
|
|
4684
4684
|
|
|
4685
|
+
/**
|
|
4686
|
+
* Creates a base query that automatically unwraps standardized API responses.
|
|
4687
|
+
*
|
|
4688
|
+
* If the API returns `{ success: true, data: T }`, this will return just `T`.
|
|
4689
|
+
* If the API returns `{ success: false, error: {...} }`, this will pass through the error correctly.
|
|
4690
|
+
*
|
|
4691
|
+
* This eliminates the need for `transformResponse` on every endpoint when using
|
|
4692
|
+
* a standardized response format across your API routes.
|
|
4693
|
+
*
|
|
4694
|
+
* @param baseQueryOptions - The same options you would pass to fetchBaseQuery
|
|
4695
|
+
* @returns A BaseQueryFn that unwraps standardized responses
|
|
4696
|
+
*
|
|
4697
|
+
* @example
|
|
4698
|
+
* ```typescript
|
|
4699
|
+
* const api = createApi({
|
|
4700
|
+
* baseQuery: createUnwrappingBaseQuery({
|
|
4701
|
+
* baseUrl: '/api',
|
|
4702
|
+
* prepareHeaders: (headers) => {
|
|
4703
|
+
* // Add auth headers
|
|
4704
|
+
* return headers;
|
|
4705
|
+
* },
|
|
4706
|
+
* }),
|
|
4707
|
+
* endpoints: (builder) => ({
|
|
4708
|
+
* getPlans: builder.query<{ plans: Plan[] }, void>({
|
|
4709
|
+
* query: () => '/payment/plans',
|
|
4710
|
+
* // No need for transformResponse!
|
|
4711
|
+
* }),
|
|
4712
|
+
* }),
|
|
4713
|
+
* });
|
|
4714
|
+
* ```
|
|
4715
|
+
*/
|
|
4716
|
+
function createUnwrappingBaseQuery(baseQueryOptions) {
|
|
4717
|
+
const baseQuery = fetchBaseQuery(baseQueryOptions);
|
|
4718
|
+
return async (args, api, extraOptions) => {
|
|
4719
|
+
const result = await baseQuery(args, api, extraOptions);
|
|
4720
|
+
// If there's an error, return it as-is
|
|
4721
|
+
if (result.error) {
|
|
4722
|
+
return result;
|
|
4723
|
+
}
|
|
4724
|
+
// If there's data, check if it matches our standard format
|
|
4725
|
+
if (result.data) {
|
|
4726
|
+
const response = result.data;
|
|
4727
|
+
// Check if this is a wrapped response with success flag
|
|
4728
|
+
if (typeof response === 'object' && response !== null && 'success' in response) {
|
|
4729
|
+
// If success is false, treat it as an error
|
|
4730
|
+
if (response.success === false && response.error) {
|
|
4731
|
+
return {
|
|
4732
|
+
error: {
|
|
4733
|
+
status: 'CUSTOM_ERROR',
|
|
4734
|
+
data: response.error,
|
|
4735
|
+
},
|
|
4736
|
+
};
|
|
4737
|
+
}
|
|
4738
|
+
// If success is true and there's data, unwrap it
|
|
4739
|
+
if (response.success === true && 'data' in response) {
|
|
4740
|
+
return {
|
|
4741
|
+
...result,
|
|
4742
|
+
data: response.data,
|
|
4743
|
+
};
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
// If it doesn't match our standard format, return as-is
|
|
4747
|
+
// (e.g., direct responses from external APIs like Elasticsearch)
|
|
4748
|
+
return result;
|
|
4749
|
+
}
|
|
4750
|
+
return result;
|
|
4751
|
+
};
|
|
4752
|
+
}
|
|
4753
|
+
|
|
4685
4754
|
function onlyUnique(value, index, self) {
|
|
4686
4755
|
return self.indexOf(value) === index;
|
|
4687
4756
|
}
|
|
@@ -5553,13 +5622,13 @@ apiConfig.APP_ES_CHALLENGES_INDEX;
|
|
|
5553
5622
|
apiConfig.APP_ES_CHALLENGE_DAYS_INDEX;
|
|
5554
5623
|
apiConfig.PLATFORM;
|
|
5555
5624
|
|
|
5556
|
-
// Create a dynamic baseQuery that resolves URL at request time
|
|
5625
|
+
// Create a dynamic baseQuery that resolves URL at request time and unwraps standard responses
|
|
5557
5626
|
const createAuthBaseQuery = () => {
|
|
5558
5627
|
const baseUrl = typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_API_AUTH_PREFIX
|
|
5559
5628
|
? process.env.NEXT_PUBLIC_API_AUTH_PREFIX
|
|
5560
5629
|
: (API_AUTH_PREFIX || '');
|
|
5561
5630
|
console.log('[authApi] Resolved baseUrl:', baseUrl);
|
|
5562
|
-
return
|
|
5631
|
+
return createUnwrappingBaseQuery({
|
|
5563
5632
|
baseUrl,
|
|
5564
5633
|
prepareHeaders: async (headers) => {
|
|
5565
5634
|
headers.set('Content-Type', 'application/json');
|
|
@@ -5710,9 +5779,10 @@ const authApi = createApi({
|
|
|
5710
5779
|
};
|
|
5711
5780
|
}
|
|
5712
5781
|
},
|
|
5782
|
+
// No need for transformResponse - createUnwrappingBaseQuery handles it
|
|
5713
5783
|
transformResponse: (rawResult) => {
|
|
5714
|
-
|
|
5715
|
-
return { route: 'success', message:
|
|
5784
|
+
// Additional custom transform after unwrapping
|
|
5785
|
+
return { route: 'success', message: rawResult?.message };
|
|
5716
5786
|
},
|
|
5717
5787
|
}),
|
|
5718
5788
|
verifyUserAttributes: builder.query({
|
|
@@ -5824,13 +5894,13 @@ const contentApi = createApi({
|
|
|
5824
5894
|
});
|
|
5825
5895
|
const { useGetDataQuery, useLazyGetDataQuery, useGetDataByIdQuery, useLazyGetDataByIdQuery, } = contentApi;
|
|
5826
5896
|
|
|
5827
|
-
// Dynamic baseQuery that resolves URL at request time
|
|
5897
|
+
// Dynamic baseQuery that resolves URL at request time and unwraps standard responses
|
|
5828
5898
|
const dynamicBaseQuery = async (args, api, extraOptions) => {
|
|
5829
5899
|
// Resolve base URL at request time, not module load time
|
|
5830
5900
|
const baseUrl = typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_API_PAYMENTS_PREFIX
|
|
5831
5901
|
? process.env.NEXT_PUBLIC_API_PAYMENTS_PREFIX
|
|
5832
5902
|
: (API_PAYMENTS_PREFIX || '');
|
|
5833
|
-
const baseQuery =
|
|
5903
|
+
const baseQuery = createUnwrappingBaseQuery({
|
|
5834
5904
|
baseUrl,
|
|
5835
5905
|
prepareHeaders: async (headers) => {
|
|
5836
5906
|
headers.set('Content-Type', 'application/json');
|
|
@@ -6118,5 +6188,5 @@ const selectCartItemsIds = createSelector$1([selectMediaInCart], (items) => {
|
|
|
6118
6188
|
});
|
|
6119
6189
|
cartSlice.reducer;
|
|
6120
6190
|
|
|
6121
|
-
export { formatAuthSession as $, emptyCart as A, toggleCart as B, selectMediaInCart as C, selectCartTotal as D, selectCartNetTotal as E, selectCartTaxRate as F, selectCartTaxAmount as G, selectCartCount as H, selectCartStatus as I, selectPromoCode as J, selectCartItems as K, selectCartItemsIds as L, formatUserPayload as M, formatPromos as N, formatWorkout as O, formatShortform as P, formatFaqs as Q, formatPages as R, formatSettings as S, formatPress as T, formatGuests as U, formatVideos as V, formatSections as W, formatSchedule as X, formatChallenges as Y, formatChallengeDays as Z, formatSecondsToISO8601Duration as _, authApi as a, formatFedaratedSession as a0, formatSocialAuthSession as a1, formatConfig as a2, formatSectionPanels as a3, formatSectionItems as a4, formatTaxonomies as a5, formatSeries as a6, formatSeasons as a7, formatLongform as a8, formatMediaItem as a9, isWeb as aa, isReactNative as ab, getPlatform as ac, runOnPlatform as ad, onlyUnique as ae, applyCoupon as af, applyTax as ag, toCamelCaseObject as ah, useResetPasswordAuthMutation as b, contentApi as c, useRegisterMutation as d, useVerifyUserQuery as e, useLazyVerifyUserQuery as f, useGetUserInfoQuery as g, useLazyGetUserInfoQuery as h, useUpdateUserInfoMutation as i, useForgottenPasswordMutation as j, useVerifyUserAttributesQuery as k, useLazyVerifyUserAttributesQuery as l, useVerifyUserResendQuery as m, useLazyVerifyUserResendQuery as n, ordersApi as o, paymentApi as p, useUpdateUserMutation as q, cartSlice as r, setTaxRate as s, resetTaxRate as t, useResetPasswordMutation as u, setPromoCode as v, removePromoCode as w, addToCart as x, updateCart as y, removeFromCart as z };
|
|
6122
|
-
//# sourceMappingURL=slice-
|
|
6191
|
+
export { formatAuthSession as $, emptyCart as A, toggleCart as B, selectMediaInCart as C, selectCartTotal as D, selectCartNetTotal as E, selectCartTaxRate as F, selectCartTaxAmount as G, selectCartCount as H, selectCartStatus as I, selectPromoCode as J, selectCartItems as K, selectCartItemsIds as L, formatUserPayload as M, formatPromos as N, formatWorkout as O, formatShortform as P, formatFaqs as Q, formatPages as R, formatSettings as S, formatPress as T, formatGuests as U, formatVideos as V, formatSections as W, formatSchedule as X, formatChallenges as Y, formatChallengeDays as Z, formatSecondsToISO8601Duration as _, authApi as a, formatFedaratedSession as a0, formatSocialAuthSession as a1, formatConfig as a2, formatSectionPanels as a3, formatSectionItems as a4, formatTaxonomies as a5, formatSeries as a6, formatSeasons as a7, formatLongform as a8, formatMediaItem as a9, isWeb as aa, isReactNative as ab, getPlatform as ac, runOnPlatform as ad, onlyUnique as ae, applyCoupon as af, applyTax as ag, toCamelCaseObject as ah, createUnwrappingBaseQuery as ai, useResetPasswordAuthMutation as b, contentApi as c, useRegisterMutation as d, useVerifyUserQuery as e, useLazyVerifyUserQuery as f, useGetUserInfoQuery as g, useLazyGetUserInfoQuery as h, useUpdateUserInfoMutation as i, useForgottenPasswordMutation as j, useVerifyUserAttributesQuery as k, useLazyVerifyUserAttributesQuery as l, useVerifyUserResendQuery as m, useLazyVerifyUserResendQuery as n, ordersApi as o, paymentApi as p, useUpdateUserMutation as q, cartSlice as r, setTaxRate as s, resetTaxRate as t, useResetPasswordMutation as u, setPromoCode as v, removePromoCode as w, addToCart as x, updateCart as y, removeFromCart as z };
|
|
6192
|
+
//# sourceMappingURL=slice-CFI-0qr6.js.map
|