@techstuff-dev/foundation-api-utils 2.7.0 → 2.7.1

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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var toolkit = require('@reduxjs/toolkit');
4
- var slice = require('./slice-BZ9cHcE8.js');
4
+ var slice = require('./slice-2_5ax6TZ.js');
5
5
  var slice$1 = require('./slice-CkWobkWw.js');
6
6
 
7
7
  // This file exists just so TypeScript has a module at ./store for IDEs/build.
@@ -11,4 +11,4 @@ var slice$1 = require('./slice-CkWobkWw.js');
11
11
  const rootReducer = toolkit.combineSlices(slice.cartSlice, slice$1.authSlice, slice.authApi, slice.contentApi, slice.paymentApi, slice.productsApi, slice.ordersApi);
12
12
 
13
13
  exports.rootReducer = rootReducer;
14
- //# sourceMappingURL=shared-BB1LJXHU.js.map
14
+ //# sourceMappingURL=shared-CNZnVs2B.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-BB1LJXHU.js","sources":["../../../lib/store/shared.ts"],"sourcesContent":[null],"names":["combineSlices","cartSlice","authSlice","authApi","contentApi","paymentApi","productsApi","ordersApi"],"mappings":";;;;;;AAAA;AACA;AAUA;AAEA;MACa,WAAW,GAAGA,qBAAa,CACtCC,eAAS,EACTC,iBAAS,EACTC,aAAO,EACPC,gBAAU,EACVC,gBAAU,EACVC,iBAAW,EACXC,eAAS;;;;"}
1
+ {"version":3,"file":"shared-CNZnVs2B.js","sources":["../../../lib/store/shared.ts"],"sourcesContent":[null],"names":["combineSlices","cartSlice","authSlice","authApi","contentApi","paymentApi","productsApi","ordersApi"],"mappings":";;;;;;AAAA;AACA;AAUA;AAEA;MACa,WAAW,GAAGA,qBAAa,CACtCC,eAAS,EACTC,iBAAS,EACTC,aAAO,EACPC,gBAAU,EACVC,gBAAU,EACVC,iBAAW,EACXC,eAAS;;;;"}
@@ -5196,7 +5196,7 @@ const APP_ES_SCHEDULE_INDEX$1 = getEnvVar$1('NEXT_PUBLIC_APP_ES_SCHEDULE_INDEX')
5196
5196
  const APP_ES_CHALLENGES_INDEX$1 = getEnvVar$1('NEXT_PUBLIC_APP_ES_CHALLENGES_INDEX');
5197
5197
  const APP_ES_CHALLENGE_DAYS_INDEX$1 = getEnvVar$1('NEXT_PUBLIC_APP_ES_CHALLENGE_DAYS_INDEX');
5198
5198
  // Platform identifier
5199
- const PLATFORM$1 = 'web';
5199
+ const PLATFORM$2 = 'web';
5200
5200
 
5201
5201
  var webConfig = /*#__PURE__*/Object.freeze({
5202
5202
  __proto__: null,
@@ -5219,7 +5219,7 @@ var webConfig = /*#__PURE__*/Object.freeze({
5219
5219
  APP_ES_SETTINGS_INDEX: APP_ES_SETTINGS_INDEX$1,
5220
5220
  APP_ES_VIDEOS_INDEX: APP_ES_VIDEOS_INDEX$1,
5221
5221
  APP_ES_WORKOUTS_INDEX: APP_ES_WORKOUTS_INDEX$1,
5222
- PLATFORM: PLATFORM$1
5222
+ PLATFORM: PLATFORM$2
5223
5223
  });
5224
5224
 
5225
5225
  /**
@@ -5263,7 +5263,7 @@ const APP_ES_SCHEDULE_INDEX = getEnvVar('APP_ES_SCHEDULE_INDEX');
5263
5263
  const APP_ES_CHALLENGES_INDEX = getEnvVar('APP_ES_CHALLENGES_INDEX');
5264
5264
  const APP_ES_CHALLENGE_DAYS_INDEX = getEnvVar('APP_ES_CHALLENGE_DAYS_INDEX');
5265
5265
  // Platform identifier
5266
- const PLATFORM = 'native';
5266
+ const PLATFORM$1 = 'native';
5267
5267
 
5268
5268
  var nativeConfig = /*#__PURE__*/Object.freeze({
5269
5269
  __proto__: null,
@@ -5286,7 +5286,7 @@ var nativeConfig = /*#__PURE__*/Object.freeze({
5286
5286
  APP_ES_SETTINGS_INDEX: APP_ES_SETTINGS_INDEX,
5287
5287
  APP_ES_VIDEOS_INDEX: APP_ES_VIDEOS_INDEX,
5288
5288
  APP_ES_WORKOUTS_INDEX: APP_ES_WORKOUTS_INDEX,
5289
- PLATFORM: PLATFORM
5289
+ PLATFORM: PLATFORM$1
5290
5290
  });
5291
5291
 
5292
5292
  /**
@@ -5328,7 +5328,7 @@ apiConfig.APP_ES_WORKOUTS_INDEX;
5328
5328
  apiConfig.APP_ES_SCHEDULE_INDEX;
5329
5329
  apiConfig.APP_ES_CHALLENGES_INDEX;
5330
5330
  apiConfig.APP_ES_CHALLENGE_DAYS_INDEX;
5331
- apiConfig.PLATFORM;
5331
+ const PLATFORM = apiConfig.PLATFORM;
5332
5332
 
5333
5333
  /**
5334
5334
  * Mutex to prevent multiple concurrent refresh attempts.
@@ -5507,6 +5507,24 @@ function getAuthHeaders(getState) {
5507
5507
  return { accessToken, idToken };
5508
5508
  }
5509
5509
 
5510
+ /**
5511
+ * Build a per-platform URL for user-scoped data endpoints.
5512
+ *
5513
+ * Native apps call the backend API Gateway directly and must use the canonical
5514
+ * path shape: `/data/user/{sub}/{endpoint}`.
5515
+ *
5516
+ * Web apps route library requests through their own Next.js `/api/user/*`
5517
+ * proxy layer, which then forwards to the same canonical backend path. That
5518
+ * proxy expects the legacy `/user/{endpoint}?sub=X` shape.
5519
+ */
5520
+ const userDataPath = (sub, endpoint, query) => {
5521
+ if (PLATFORM === 'native') {
5522
+ const suffix = query ? `?${query}` : '';
5523
+ return `/data/user/${sub}/${endpoint}${suffix}`;
5524
+ }
5525
+ const suffix = query ? `&${query}` : '';
5526
+ return `/user/${endpoint}?sub=${sub}${suffix}`;
5527
+ };
5510
5528
  // Create a dynamic baseQuery that resolves URL at request time and unwraps standard responses
5511
5529
  const createAuthBaseQuery = () => {
5512
5530
  const baseUrl = typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_API_AUTH_PREFIX
@@ -5672,14 +5690,14 @@ const authApi = createApi({
5672
5690
  // Dashboard data endpoints
5673
5691
  getStreak: builder.query({
5674
5692
  query: (sub) => ({
5675
- url: `/user/streak?sub=${sub}`,
5693
+ url: userDataPath(sub, 'streak'),
5676
5694
  method: 'GET',
5677
5695
  }),
5678
5696
  providesTags: ['Streak'],
5679
5697
  }),
5680
5698
  getWeeklyProgress: builder.query({
5681
5699
  query: (sub) => ({
5682
- url: `/user/weekly-progress?sub=${sub}`,
5700
+ url: userDataPath(sub, 'weekly-progress'),
5683
5701
  method: 'GET',
5684
5702
  }),
5685
5703
  providesTags: ['WeeklyProgress'],
@@ -5694,35 +5712,35 @@ const authApi = createApi({
5694
5712
  }),
5695
5713
  getWatchProgress: builder.query({
5696
5714
  query: ({ sub, limit = 1 }) => ({
5697
- url: `/user/watch-progress?sub=${sub}&limit=${limit}`,
5715
+ url: userDataPath(sub, 'watch-progress', `limit=${limit}`),
5698
5716
  method: 'GET',
5699
5717
  }),
5700
5718
  providesTags: ['WatchProgress'],
5701
5719
  }),
5702
5720
  getRecommendations: builder.query({
5703
5721
  query: ({ sub, limit = 8 }) => ({
5704
- url: `/user/recommendations?sub=${sub}&limit=${limit}`,
5722
+ url: userDataPath(sub, 'recommendations', `limit=${limit}`),
5705
5723
  method: 'GET',
5706
5724
  }),
5707
5725
  providesTags: ['Recommendations'],
5708
5726
  }),
5709
5727
  getActivityStats: builder.query({
5710
5728
  query: ({ sub, period = 'this-month' }) => ({
5711
- url: `/user/activity-stats?sub=${sub}&period=${period}`,
5729
+ url: userDataPath(sub, 'activity-stats', `period=${period}`),
5712
5730
  method: 'GET',
5713
5731
  }),
5714
5732
  providesTags: ['ActivityStats'],
5715
5733
  }),
5716
5734
  getActiveChallenges: builder.query({
5717
5735
  query: (sub) => ({
5718
- url: `/user/active-challenges?sub=${sub}`,
5736
+ url: userDataPath(sub, 'active-challenges'),
5719
5737
  method: 'GET',
5720
5738
  }),
5721
5739
  providesTags: ['UserData'],
5722
5740
  }),
5723
5741
  getChallengeProgress: builder.query({
5724
5742
  query: ({ sub, challengeId }) => ({
5725
- url: `/user/challenge-progress/${challengeId}?sub=${sub}`,
5743
+ url: userDataPath(sub, `challenge-progress/${challengeId}`),
5726
5744
  method: 'GET',
5727
5745
  }),
5728
5746
  providesTags: ['UserData'],
@@ -5730,7 +5748,8 @@ const authApi = createApi({
5730
5748
  // Activity logging — invalidates dashboard caches
5731
5749
  logActivity: builder.mutation({
5732
5750
  query: (data) => ({
5733
- url: '/activity',
5751
+ // Native hits the backend directly at /data/activity; web proxies via /activity → /data/activity
5752
+ url: PLATFORM === 'native' ? '/data/activity' : '/activity',
5734
5753
  method: 'POST',
5735
5754
  body: data,
5736
5755
  }),
@@ -6273,4 +6292,4 @@ exports.useVerifyUserAttributesQuery = useVerifyUserAttributesQuery;
6273
6292
  exports.useVerifyUserQuery = useVerifyUserQuery;
6274
6293
  exports.useVerifyUserResendQuery = useVerifyUserResendQuery;
6275
6294
  exports.withReauth = withReauth;
6276
- //# sourceMappingURL=slice-BZ9cHcE8.js.map
6295
+ //# sourceMappingURL=slice-2_5ax6TZ.js.map