@iblai/web-utils 1.2.5 → 1.2.7
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/data-layer/src/features/monetization/constants.d.ts +76 -0
- package/dist/data-layer/src/features/monetization/custom-api-slice.d.ts +5017 -0
- package/dist/data-layer/src/features/monetization/types.d.ts +224 -0
- package/dist/data-layer/src/index.d.ts +2 -0
- package/dist/data-layer/src/utils/index.d.ts +5 -1
- package/dist/index.d.ts +24 -7
- package/dist/index.esm.js +412 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +416 -18
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/web-utils/src/features/index.d.ts +1 -0
- package/dist/web-utils/src/features/monetization/__tests__/slice.test.d.ts +1 -0
- package/dist/web-utils/src/features/monetization/slice.d.ts +16 -0
- package/dist/web-utils/src/types/subscription.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2856,6 +2856,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2856
2856
|
* Skipped if enableStorageSync is false
|
|
2857
2857
|
*/
|
|
2858
2858
|
React.useEffect(() => {
|
|
2859
|
+
console.log("[AuthProvider] cookie-sync effect running", {
|
|
2860
|
+
pathname,
|
|
2861
|
+
enableStorageSync,
|
|
2862
|
+
hasStorageService: !!storageService,
|
|
2863
|
+
});
|
|
2859
2864
|
if (!storageService || !isWeb$1() || !enableStorageSync) {
|
|
2860
2865
|
// If no storage service, not web, or sync disabled, mark sync as complete immediately
|
|
2861
2866
|
setInitialSyncComplete(true);
|
|
@@ -2865,16 +2870,22 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2865
2870
|
isRedirectingRef.current = false;
|
|
2866
2871
|
// Initial sync on mount
|
|
2867
2872
|
async function initialSync() {
|
|
2873
|
+
console.log("[AuthProvider] initialSync starting");
|
|
2868
2874
|
try {
|
|
2869
2875
|
// Initialize last known logout timestamp
|
|
2870
2876
|
lastLogoutTimestampRef.current = CookieUtils.get(COOKIE_KEYS.LOGOUT_TIMESTAMP);
|
|
2871
2877
|
const { needsRefresh, userDataOutOfSync } = await syncCookiesToLocalStorage(storageService);
|
|
2878
|
+
console.log("[AuthProvider] initialSync result", {
|
|
2879
|
+
needsRefresh,
|
|
2880
|
+
userDataOutOfSync,
|
|
2881
|
+
});
|
|
2872
2882
|
if (needsRefresh) {
|
|
2873
2883
|
console.log("[auth-redirect] Cookie sync detected changes, refreshing page");
|
|
2874
2884
|
// If user data is out of sync, trigger logout to force re-authentication
|
|
2875
2885
|
safeRedirectToAuthSpa(undefined, undefined, userDataOutOfSync, false);
|
|
2876
2886
|
}
|
|
2877
2887
|
else {
|
|
2888
|
+
console.log("[AuthProvider] initialSync no changes, syncing auth to cookies");
|
|
2878
2889
|
await syncAuthToCookies(storageService);
|
|
2879
2890
|
}
|
|
2880
2891
|
}
|
|
@@ -2887,8 +2898,10 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2887
2898
|
// Poll for cookie changes every 2 seconds to detect cross-SPA updates
|
|
2888
2899
|
cookieCheckIntervalRef.current = setInterval(async () => {
|
|
2889
2900
|
// If a redirect is already in progress, skip entirely
|
|
2890
|
-
if (isRedirectingRef.current)
|
|
2901
|
+
if (isRedirectingRef.current) {
|
|
2902
|
+
console.log("[AuthProvider] interval: redirect already in progress, skipping");
|
|
2891
2903
|
return;
|
|
2904
|
+
}
|
|
2892
2905
|
// Skip cookie sync checks if user is completing SSO at /sso-login
|
|
2893
2906
|
const completingSso = /^\/sso-login/.test(pathname);
|
|
2894
2907
|
if (completingSso) {
|
|
@@ -2909,6 +2922,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2909
2922
|
return;
|
|
2910
2923
|
}
|
|
2911
2924
|
const { needsRefresh, userDataOutOfSync } = await syncCookiesToLocalStorage(storageService);
|
|
2925
|
+
console.log("[AuthProvider] interval poll result", {
|
|
2926
|
+
needsRefresh,
|
|
2927
|
+
userDataOutOfSync,
|
|
2928
|
+
pathname,
|
|
2929
|
+
});
|
|
2912
2930
|
if (needsRefresh) {
|
|
2913
2931
|
console.log("[auth-redirect] Cookie sync detected changes from another SPA, refreshing page");
|
|
2914
2932
|
let cookieTenantKey;
|
|
@@ -2917,6 +2935,10 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2917
2935
|
cookieTenantKey = cookieCurrentTenant.key;
|
|
2918
2936
|
}
|
|
2919
2937
|
catch (_a) { }
|
|
2938
|
+
console.log("[AuthProvider] interval redirecting to auth spa", {
|
|
2939
|
+
cookieTenantKey,
|
|
2940
|
+
userDataOutOfSync,
|
|
2941
|
+
});
|
|
2920
2942
|
// If user data is out of sync, trigger logout to force re-authentication
|
|
2921
2943
|
safeRedirectToAuthSpa(undefined, cookieTenantKey, userDataOutOfSync, false);
|
|
2922
2944
|
}
|
|
@@ -2926,6 +2948,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2926
2948
|
}, 2000);
|
|
2927
2949
|
// Cleanup interval on unmount
|
|
2928
2950
|
return () => {
|
|
2951
|
+
console.log("[AuthProvider] cookie-sync effect cleanup", { pathname });
|
|
2929
2952
|
if (cookieCheckIntervalRef.current) {
|
|
2930
2953
|
clearInterval(cookieCheckIntervalRef.current);
|
|
2931
2954
|
}
|
|
@@ -5881,7 +5904,7 @@ const STREAMING_CONTENT_BUFFER_THRESHOLD = 300; // characters
|
|
|
5881
5904
|
const STREAMING_CONTENT_FLUSH_INTERVAL = 300; // milliseconds
|
|
5882
5905
|
const defaultSessionIds = Object.fromEntries(Object.keys(advancedTabsProperties).map((key) => [key, ""]));
|
|
5883
5906
|
const defaultChatState = Object.fromEntries(Object.keys(advancedTabsProperties).map((key) => [key, []]));
|
|
5884
|
-
const initialState$
|
|
5907
|
+
const initialState$3 = {
|
|
5885
5908
|
chats: defaultChatState,
|
|
5886
5909
|
isTyping: false,
|
|
5887
5910
|
streaming: false,
|
|
@@ -5914,7 +5937,7 @@ const initialState$2 = {
|
|
|
5914
5937
|
};
|
|
5915
5938
|
const chatSlice = createSlice$1({
|
|
5916
5939
|
name: "chatSliceShared",
|
|
5917
|
-
initialState: initialState$
|
|
5940
|
+
initialState: initialState$3,
|
|
5918
5941
|
reducers: {
|
|
5919
5942
|
setChats: (state, action) => {
|
|
5920
5943
|
state.chats = action.payload;
|
|
@@ -6578,12 +6601,12 @@ function useTimeTrackerNative(config) {
|
|
|
6578
6601
|
};
|
|
6579
6602
|
}
|
|
6580
6603
|
|
|
6581
|
-
const initialState$
|
|
6604
|
+
const initialState$2 = {
|
|
6582
6605
|
attachedFiles: [],
|
|
6583
6606
|
};
|
|
6584
6607
|
const filesSlice = createSlice$1({
|
|
6585
6608
|
name: "files",
|
|
6586
|
-
initialState: initialState$
|
|
6609
|
+
initialState: initialState$2,
|
|
6587
6610
|
reducers: {
|
|
6588
6611
|
addFiles: (state, action) => {
|
|
6589
6612
|
state.attachedFiles = [...state.attachedFiles, ...action.payload];
|
|
@@ -6762,6 +6785,44 @@ function csvDataToText(data) {
|
|
|
6762
6785
|
].join("\n");
|
|
6763
6786
|
}
|
|
6764
6787
|
|
|
6788
|
+
const initialState$1 = {
|
|
6789
|
+
displayMonetizationCheckoutModal: false,
|
|
6790
|
+
accessCheckResponse: null,
|
|
6791
|
+
paywallClosable: true,
|
|
6792
|
+
onClosePayload: undefined,
|
|
6793
|
+
};
|
|
6794
|
+
const monetizationSlice = createSlice$1({
|
|
6795
|
+
name: "monetization",
|
|
6796
|
+
initialState: initialState$1,
|
|
6797
|
+
reducers: {
|
|
6798
|
+
setDisplayMonetizationCheckoutModal(state, action) {
|
|
6799
|
+
state.displayMonetizationCheckoutModal = action.payload;
|
|
6800
|
+
if (!action.payload) {
|
|
6801
|
+
state.accessCheckResponse = null;
|
|
6802
|
+
}
|
|
6803
|
+
},
|
|
6804
|
+
setAccessCheckResponse(state, action) {
|
|
6805
|
+
state.accessCheckResponse = action.payload;
|
|
6806
|
+
},
|
|
6807
|
+
showMonetizationCheckoutModal(state, action) {
|
|
6808
|
+
var _a, _b, _c, _d, _e;
|
|
6809
|
+
state.displayMonetizationCheckoutModal =
|
|
6810
|
+
(_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.showModal) !== null && _b !== void 0 ? _b : true;
|
|
6811
|
+
state.accessCheckResponse = action.payload;
|
|
6812
|
+
state.paywallClosable = (_d = (_c = action.payload) === null || _c === void 0 ? void 0 : _c.paywallClosable) !== null && _d !== void 0 ? _d : true;
|
|
6813
|
+
state.onClosePayload = (_e = action.payload) === null || _e === void 0 ? void 0 : _e.onClosePayload;
|
|
6814
|
+
},
|
|
6815
|
+
setAdvancedDisplayMonetizationCheckoutModal(state, action) {
|
|
6816
|
+
var _a, _b, _c, _d, _e;
|
|
6817
|
+
state.displayMonetizationCheckoutModal =
|
|
6818
|
+
(_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.showModal) !== null && _b !== void 0 ? _b : true;
|
|
6819
|
+
state.paywallClosable = (_d = (_c = action.payload) === null || _c === void 0 ? void 0 : _c.paywallClosable) !== null && _d !== void 0 ? _d : true;
|
|
6820
|
+
state.onClosePayload = (_e = action.payload) === null || _e === void 0 ? void 0 : _e.onClosePayload;
|
|
6821
|
+
},
|
|
6822
|
+
},
|
|
6823
|
+
});
|
|
6824
|
+
const { setDisplayMonetizationCheckoutModal, setAccessCheckResponse, showMonetizationCheckoutModal, setAdvancedDisplayMonetizationCheckoutModal, } = monetizationSlice.actions;
|
|
6825
|
+
|
|
6765
6826
|
/**
|
|
6766
6827
|
* Ollama API client for local LLM chat
|
|
6767
6828
|
*
|
|
@@ -13539,12 +13600,12 @@ const buildEndpointFromService = (service, serviceFn) => {
|
|
|
13539
13600
|
}
|
|
13540
13601
|
catch (err) {
|
|
13541
13602
|
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, err === null || err === void 0 ? void 0 : err.status)) {
|
|
13542
|
-
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]();
|
|
13603
|
+
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]({ ...((err === null || err === void 0 ? void 0 : err.data) || {}) });
|
|
13543
13604
|
}
|
|
13544
13605
|
return {
|
|
13545
13606
|
error: {
|
|
13546
13607
|
status: (err === null || err === void 0 ? void 0 : err.status) || 500,
|
|
13547
|
-
data: (err === null || err === void 0 ? void 0 : err.body) || (err === null || err === void 0 ? void 0 : err.message) || 'Unknown error',
|
|
13608
|
+
data: (err === null || err === void 0 ? void 0 : err.body) || (err === null || err === void 0 ? void 0 : err.data) || (err === null || err === void 0 ? void 0 : err.message) || 'Unknown error',
|
|
13548
13609
|
},
|
|
13549
13610
|
};
|
|
13550
13611
|
}
|
|
@@ -13598,24 +13659,40 @@ const baseQuery = (service, jsonContentType = true, contentType, skipAuth = fals
|
|
|
13598
13659
|
/**
|
|
13599
13660
|
* Helper to invoke registered HTTP error handlers (e.g., logout on 401).
|
|
13600
13661
|
*/
|
|
13601
|
-
const invokeHttpErrorHandler = (status) => {
|
|
13662
|
+
const invokeHttpErrorHandler = (status, error) => {
|
|
13602
13663
|
const numericStatus = typeof status === 'number' ? status : parseInt(String(status), 10);
|
|
13664
|
+
console.log('[MONETIZATION error] ', { error });
|
|
13603
13665
|
if (!isNaN(numericStatus) &&
|
|
13604
13666
|
Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, numericStatus)) {
|
|
13605
|
-
|
|
13667
|
+
const err = error;
|
|
13668
|
+
Config.httpErrorHandlers[numericStatus]({ ...(err || {}) });
|
|
13606
13669
|
}
|
|
13607
13670
|
};
|
|
13671
|
+
/** HTTP status codes that should not be retried (e.g., 402 Payment Required). */
|
|
13672
|
+
const NON_RETRYABLE_STATUS_CODES = [402];
|
|
13673
|
+
/**
|
|
13674
|
+
* Wraps a base query to skip retries for non-retryable HTTP status codes.
|
|
13675
|
+
* Uses `retry.fail()` to immediately bail out of the retry loop.
|
|
13676
|
+
*/
|
|
13677
|
+
const withNonRetryableErrors = (query) => async (args, api, extraOptions) => {
|
|
13678
|
+
const result = await query(args, api, extraOptions);
|
|
13679
|
+
if (result.error && NON_RETRYABLE_STATUS_CODES.includes(result.error.status)) {
|
|
13680
|
+
retry.fail(result.error);
|
|
13681
|
+
}
|
|
13682
|
+
return result;
|
|
13683
|
+
};
|
|
13608
13684
|
const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
13609
|
-
var _a, _b;
|
|
13685
|
+
var _a, _b, _c;
|
|
13610
13686
|
try {
|
|
13611
13687
|
// Executing base query
|
|
13612
|
-
const result = await retry(baseQuery(args.service, (_a = args === null || args === void 0 ? void 0 : args.isJson) !== null && _a !== void 0 ? _a : true, args === null || args === void 0 ? void 0 : args.contentType, args === null || args === void 0 ? void 0 : args.skipAuth), {
|
|
13688
|
+
const result = await retry(withNonRetryableErrors(baseQuery(args.service, (_a = args === null || args === void 0 ? void 0 : args.isJson) !== null && _a !== void 0 ? _a : true, args === null || args === void 0 ? void 0 : args.contentType, args === null || args === void 0 ? void 0 : args.skipAuth)), {
|
|
13613
13689
|
maxRetries: 3,
|
|
13614
13690
|
})(args, api, extraOptions);
|
|
13615
13691
|
// Query completed
|
|
13616
13692
|
if (result.error) {
|
|
13693
|
+
console.log('[MONETIZATION ERROR HANDLER]: ', { result });
|
|
13617
13694
|
// Invoke registered HTTP error handlers (e.g., logout on 401)
|
|
13618
|
-
invokeHttpErrorHandler(result.error.status);
|
|
13695
|
+
invokeHttpErrorHandler(result.error.status, (_b = result.error) === null || _b === void 0 ? void 0 : _b.data);
|
|
13619
13696
|
// For profile image upload errors, preserve the original error structure
|
|
13620
13697
|
if (args.url && args.url.includes('/profile_images/')) {
|
|
13621
13698
|
throw result.error;
|
|
@@ -13633,7 +13710,7 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
13633
13710
|
// Ensure we throw a plain FetchBaseQueryError shape with enumerable fields
|
|
13634
13711
|
throw {
|
|
13635
13712
|
status: result.error.status,
|
|
13636
|
-
data: (
|
|
13713
|
+
data: (_c = result.error.data) !== null && _c !== void 0 ? _c : errorMessage,
|
|
13637
13714
|
};
|
|
13638
13715
|
}
|
|
13639
13716
|
return { data: result === null || result === void 0 ? void 0 : result.data };
|
|
@@ -13647,10 +13724,12 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
13647
13724
|
error: e,
|
|
13648
13725
|
}));
|
|
13649
13726
|
// Extract status from error and invoke HTTP error handlers
|
|
13727
|
+
console.log('[MONETIZATION e]', { e });
|
|
13728
|
+
const err = e;
|
|
13650
13729
|
const errorStatus = typeof e === 'object' && e !== null && 'status' in e
|
|
13651
13730
|
? e.status
|
|
13652
13731
|
: undefined;
|
|
13653
|
-
invokeHttpErrorHandler(errorStatus);
|
|
13732
|
+
invokeHttpErrorHandler(errorStatus, err === null || err === void 0 ? void 0 : err.data);
|
|
13654
13733
|
// Preserve original RTK error object for profile image uploads
|
|
13655
13734
|
if (args.url &&
|
|
13656
13735
|
args.url.includes('/profile_images/') &&
|
|
@@ -13687,7 +13766,11 @@ const buildEndpointFromServiceLegacy = (service, serviceFn) => {
|
|
|
13687
13766
|
}
|
|
13688
13767
|
catch (err) {
|
|
13689
13768
|
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, err === null || err === void 0 ? void 0 : err.status)) {
|
|
13690
|
-
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status](
|
|
13769
|
+
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]({
|
|
13770
|
+
status: err === null || err === void 0 ? void 0 : err.status,
|
|
13771
|
+
body: err === null || err === void 0 ? void 0 : err.body,
|
|
13772
|
+
message: err === null || err === void 0 ? void 0 : err.message,
|
|
13773
|
+
});
|
|
13691
13774
|
}
|
|
13692
13775
|
return {
|
|
13693
13776
|
error: {
|
|
@@ -15127,6 +15210,309 @@ createApi({
|
|
|
15127
15210
|
}),
|
|
15128
15211
|
});
|
|
15129
15212
|
|
|
15213
|
+
const MONETIZATION_REDUCER_PATH = 'monetizationApiSlice';
|
|
15214
|
+
const SERVICE_BASE = '/api/service/platforms';
|
|
15215
|
+
const BILLING_BASE = '/api/billing/platforms';
|
|
15216
|
+
const MONETIZATION_ENDPOINTS = {
|
|
15217
|
+
// Flow 1 — Stripe Connect Onboarding (Admin)
|
|
15218
|
+
STRIPE_CONNECT_STATUS: {
|
|
15219
|
+
path: (key) => `${SERVICE_BASE}/${key}/stripe/connect/status/`,
|
|
15220
|
+
service: SERVICES.DM,
|
|
15221
|
+
},
|
|
15222
|
+
STRIPE_CONNECT_ONBOARD: {
|
|
15223
|
+
path: (key) => `${SERVICE_BASE}/${key}/stripe/connect/onboard/`,
|
|
15224
|
+
service: SERVICES.DM,
|
|
15225
|
+
},
|
|
15226
|
+
STRIPE_CONNECT_DASHBOARD: {
|
|
15227
|
+
path: (key) => `${SERVICE_BASE}/${key}/stripe/connect/dashboard/`,
|
|
15228
|
+
service: SERVICES.DM,
|
|
15229
|
+
},
|
|
15230
|
+
// Flow 2 — Configure Paywall (Admin)
|
|
15231
|
+
PAYWALL_CONFIG: {
|
|
15232
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/paywall/`,
|
|
15233
|
+
service: SERVICES.DM,
|
|
15234
|
+
},
|
|
15235
|
+
// Flow 3 — Manage Prices (Admin)
|
|
15236
|
+
PAYWALL_PRICES: {
|
|
15237
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/paywall/prices/`,
|
|
15238
|
+
service: SERVICES.DM,
|
|
15239
|
+
},
|
|
15240
|
+
PAYWALL_PRICE_DETAIL: {
|
|
15241
|
+
path: (key, type, id, priceId) => `${BILLING_BASE}/${key}/items/${type}/${id}/paywall/prices/${priceId}/`,
|
|
15242
|
+
service: SERVICES.DM,
|
|
15243
|
+
},
|
|
15244
|
+
// Flow 4 — Public Pricing (No Auth)
|
|
15245
|
+
PUBLIC_PRICING: {
|
|
15246
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/pricing/`,
|
|
15247
|
+
service: SERVICES.DM,
|
|
15248
|
+
},
|
|
15249
|
+
// Flow 5 — Access Check
|
|
15250
|
+
ACCESS_CHECK: {
|
|
15251
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/access-check/`,
|
|
15252
|
+
service: SERVICES.DM,
|
|
15253
|
+
},
|
|
15254
|
+
ACCESS_CHECK_UNSCOPED: {
|
|
15255
|
+
path: (type, id) => `/api/billing/access-check/${type}/${id}/`,
|
|
15256
|
+
service: SERVICES.DM,
|
|
15257
|
+
},
|
|
15258
|
+
// Flow 6 — Checkout
|
|
15259
|
+
CHECKOUT: {
|
|
15260
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/checkout/`,
|
|
15261
|
+
service: SERVICES.DM,
|
|
15262
|
+
},
|
|
15263
|
+
CHECKOUT_GUEST: {
|
|
15264
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/checkout-guest/`,
|
|
15265
|
+
service: SERVICES.DM,
|
|
15266
|
+
},
|
|
15267
|
+
// Flow 7 — Cancel Subscription
|
|
15268
|
+
CANCEL_SUBSCRIPTION: {
|
|
15269
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/subscription/cancel/`,
|
|
15270
|
+
service: SERVICES.DM,
|
|
15271
|
+
},
|
|
15272
|
+
// Flow 8 — User Subscriptions
|
|
15273
|
+
MY_SUBSCRIPTIONS: {
|
|
15274
|
+
path: (key) => `${BILLING_BASE}/${key}/my-subscriptions/`,
|
|
15275
|
+
service: SERVICES.DM,
|
|
15276
|
+
},
|
|
15277
|
+
ITEM_SUBSCRIPTION: {
|
|
15278
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/subscription/`,
|
|
15279
|
+
service: SERVICES.DM,
|
|
15280
|
+
},
|
|
15281
|
+
// Flow 9 — Platform Analytics (Admin)
|
|
15282
|
+
LIST_PAYWALLS: {
|
|
15283
|
+
path: (key) => `${BILLING_BASE}/${key}/paywalls/`,
|
|
15284
|
+
service: SERVICES.DM,
|
|
15285
|
+
},
|
|
15286
|
+
LIST_SUBSCRIBERS: {
|
|
15287
|
+
path: (key) => `${BILLING_BASE}/${key}/subscribers/`,
|
|
15288
|
+
service: SERVICES.DM,
|
|
15289
|
+
},
|
|
15290
|
+
ITEM_SUBSCRIBERS: {
|
|
15291
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/subscribers/`,
|
|
15292
|
+
service: SERVICES.DM,
|
|
15293
|
+
},
|
|
15294
|
+
REVENUE: {
|
|
15295
|
+
path: (key) => `${BILLING_BASE}/${key}/revenue/`,
|
|
15296
|
+
service: SERVICES.DM,
|
|
15297
|
+
},
|
|
15298
|
+
};
|
|
15299
|
+
|
|
15300
|
+
createApi({
|
|
15301
|
+
reducerPath: MONETIZATION_REDUCER_PATH,
|
|
15302
|
+
baseQuery: iblFetchBaseQuery,
|
|
15303
|
+
tagTypes: [
|
|
15304
|
+
'stripeConnectStatus',
|
|
15305
|
+
'paywallConfig',
|
|
15306
|
+
'paywallPrices',
|
|
15307
|
+
'publicPricing',
|
|
15308
|
+
'accessCheck',
|
|
15309
|
+
'mySubscriptions',
|
|
15310
|
+
'itemSubscription',
|
|
15311
|
+
'paywalls',
|
|
15312
|
+
'subscribers',
|
|
15313
|
+
'revenue',
|
|
15314
|
+
],
|
|
15315
|
+
endpoints: (builder) => ({
|
|
15316
|
+
// ── Flow 1: Stripe Connect ──
|
|
15317
|
+
getStripeConnectStatus: builder.query({
|
|
15318
|
+
query: ({ platform_key }) => ({
|
|
15319
|
+
url: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_STATUS.path(platform_key),
|
|
15320
|
+
service: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_STATUS.service,
|
|
15321
|
+
method: 'GET',
|
|
15322
|
+
}),
|
|
15323
|
+
providesTags: ['stripeConnectStatus'],
|
|
15324
|
+
}),
|
|
15325
|
+
startStripeConnectOnboarding: builder.mutation({
|
|
15326
|
+
query: ({ platform_key, ...body }) => ({
|
|
15327
|
+
url: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_ONBOARD.path(platform_key),
|
|
15328
|
+
service: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_ONBOARD.service,
|
|
15329
|
+
method: 'POST',
|
|
15330
|
+
body: JSON.stringify(body),
|
|
15331
|
+
}),
|
|
15332
|
+
invalidatesTags: ['stripeConnectStatus'],
|
|
15333
|
+
}),
|
|
15334
|
+
getStripeConnectDashboard: builder.query({
|
|
15335
|
+
query: ({ platform_key }) => ({
|
|
15336
|
+
url: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_DASHBOARD.path(platform_key),
|
|
15337
|
+
service: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_DASHBOARD.service,
|
|
15338
|
+
method: 'GET',
|
|
15339
|
+
}),
|
|
15340
|
+
}),
|
|
15341
|
+
// ── Flow 2: Paywall Config ──
|
|
15342
|
+
getPaywallConfig: builder.query({
|
|
15343
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15344
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
|
|
15345
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.service,
|
|
15346
|
+
method: 'GET',
|
|
15347
|
+
}),
|
|
15348
|
+
providesTags: ['paywallConfig'],
|
|
15349
|
+
}),
|
|
15350
|
+
enablePaywall: builder.mutation({
|
|
15351
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15352
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
|
|
15353
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.service,
|
|
15354
|
+
method: 'POST',
|
|
15355
|
+
body: JSON.stringify(body),
|
|
15356
|
+
}),
|
|
15357
|
+
invalidatesTags: ['paywallConfig', 'paywalls'],
|
|
15358
|
+
}),
|
|
15359
|
+
disablePaywall: builder.mutation({
|
|
15360
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15361
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
|
|
15362
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.service,
|
|
15363
|
+
method: 'DELETE',
|
|
15364
|
+
}),
|
|
15365
|
+
invalidatesTags: ['paywallConfig', 'paywalls'],
|
|
15366
|
+
}),
|
|
15367
|
+
// ── Flow 3: Manage Prices ──
|
|
15368
|
+
listPrices: builder.query({
|
|
15369
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15370
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_PRICES.path(platform_key, item_type, item_id),
|
|
15371
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_PRICES.service,
|
|
15372
|
+
method: 'GET',
|
|
15373
|
+
}),
|
|
15374
|
+
providesTags: ['paywallPrices'],
|
|
15375
|
+
}),
|
|
15376
|
+
createPrice: builder.mutation({
|
|
15377
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15378
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_PRICES.path(platform_key, item_type, item_id),
|
|
15379
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_PRICES.service,
|
|
15380
|
+
method: 'POST',
|
|
15381
|
+
body: JSON.stringify(body),
|
|
15382
|
+
}),
|
|
15383
|
+
invalidatesTags: ['paywallPrices', 'paywallConfig'],
|
|
15384
|
+
}),
|
|
15385
|
+
updatePrice: builder.mutation({
|
|
15386
|
+
query: ({ platform_key, item_type, item_id, price_unique_id, ...body }) => ({
|
|
15387
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_PRICE_DETAIL.path(platform_key, item_type, item_id, price_unique_id),
|
|
15388
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_PRICE_DETAIL.service,
|
|
15389
|
+
method: 'PUT',
|
|
15390
|
+
body: JSON.stringify(body),
|
|
15391
|
+
}),
|
|
15392
|
+
invalidatesTags: ['paywallPrices', 'paywallConfig'],
|
|
15393
|
+
}),
|
|
15394
|
+
deletePrice: builder.mutation({
|
|
15395
|
+
query: ({ platform_key, item_type, item_id, price_unique_id }) => ({
|
|
15396
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_PRICE_DETAIL.path(platform_key, item_type, item_id, price_unique_id),
|
|
15397
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_PRICE_DETAIL.service,
|
|
15398
|
+
method: 'DELETE',
|
|
15399
|
+
}),
|
|
15400
|
+
invalidatesTags: ['paywallPrices', 'paywallConfig'],
|
|
15401
|
+
}),
|
|
15402
|
+
// ── Flow 4: Public Pricing (No Auth) ──
|
|
15403
|
+
getPublicPricing: builder.query({
|
|
15404
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15405
|
+
url: MONETIZATION_ENDPOINTS.PUBLIC_PRICING.path(platform_key, item_type, item_id),
|
|
15406
|
+
service: MONETIZATION_ENDPOINTS.PUBLIC_PRICING.service,
|
|
15407
|
+
method: 'GET',
|
|
15408
|
+
skipAuth: true,
|
|
15409
|
+
}),
|
|
15410
|
+
providesTags: ['publicPricing'],
|
|
15411
|
+
}),
|
|
15412
|
+
// ── Flow 5: Access Check ──
|
|
15413
|
+
checkAccess: builder.query({
|
|
15414
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15415
|
+
url: MONETIZATION_ENDPOINTS.ACCESS_CHECK.path(platform_key, item_type, item_id),
|
|
15416
|
+
service: MONETIZATION_ENDPOINTS.ACCESS_CHECK.service,
|
|
15417
|
+
method: 'GET',
|
|
15418
|
+
}),
|
|
15419
|
+
providesTags: ['accessCheck'],
|
|
15420
|
+
}),
|
|
15421
|
+
checkAccessUnscoped: builder.query({
|
|
15422
|
+
query: ({ item_type, item_id, platform_key }) => ({
|
|
15423
|
+
url: MONETIZATION_ENDPOINTS.ACCESS_CHECK_UNSCOPED.path(item_type, item_id),
|
|
15424
|
+
service: MONETIZATION_ENDPOINTS.ACCESS_CHECK_UNSCOPED.service,
|
|
15425
|
+
method: 'GET',
|
|
15426
|
+
params: { platform_key },
|
|
15427
|
+
}),
|
|
15428
|
+
providesTags: ['accessCheck'],
|
|
15429
|
+
}),
|
|
15430
|
+
// ── Flow 6A/6B: Checkout (Subscription & One-Time) ──
|
|
15431
|
+
createCheckout: builder.mutation({
|
|
15432
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15433
|
+
url: MONETIZATION_ENDPOINTS.CHECKOUT.path(platform_key, item_type, item_id),
|
|
15434
|
+
service: MONETIZATION_ENDPOINTS.CHECKOUT.service,
|
|
15435
|
+
method: 'POST',
|
|
15436
|
+
body: JSON.stringify(body),
|
|
15437
|
+
}),
|
|
15438
|
+
}),
|
|
15439
|
+
// ── Flow 6C: Guest Checkout (No Auth) ──
|
|
15440
|
+
createGuestCheckout: builder.mutation({
|
|
15441
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15442
|
+
url: MONETIZATION_ENDPOINTS.CHECKOUT_GUEST.path(platform_key, item_type, item_id),
|
|
15443
|
+
service: MONETIZATION_ENDPOINTS.CHECKOUT_GUEST.service,
|
|
15444
|
+
method: 'POST',
|
|
15445
|
+
body: JSON.stringify(body),
|
|
15446
|
+
skipAuth: true,
|
|
15447
|
+
}),
|
|
15448
|
+
}),
|
|
15449
|
+
// ── Flow 7: Cancel Subscription ──
|
|
15450
|
+
cancelSubscription: builder.mutation({
|
|
15451
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15452
|
+
url: MONETIZATION_ENDPOINTS.CANCEL_SUBSCRIPTION.path(platform_key, item_type, item_id),
|
|
15453
|
+
service: MONETIZATION_ENDPOINTS.CANCEL_SUBSCRIPTION.service,
|
|
15454
|
+
method: 'POST',
|
|
15455
|
+
body: JSON.stringify(body),
|
|
15456
|
+
}),
|
|
15457
|
+
invalidatesTags: ['mySubscriptions', 'itemSubscription', 'accessCheck', 'subscribers'],
|
|
15458
|
+
}),
|
|
15459
|
+
// ── Flow 8: User Subscriptions ──
|
|
15460
|
+
getMySubscriptions: builder.query({
|
|
15461
|
+
query: ({ platform_key, ...params }) => ({
|
|
15462
|
+
url: MONETIZATION_ENDPOINTS.MY_SUBSCRIPTIONS.path(platform_key),
|
|
15463
|
+
service: MONETIZATION_ENDPOINTS.MY_SUBSCRIPTIONS.service,
|
|
15464
|
+
method: 'GET',
|
|
15465
|
+
params,
|
|
15466
|
+
}),
|
|
15467
|
+
providesTags: ['mySubscriptions'],
|
|
15468
|
+
}),
|
|
15469
|
+
getItemSubscription: builder.query({
|
|
15470
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15471
|
+
url: MONETIZATION_ENDPOINTS.ITEM_SUBSCRIPTION.path(platform_key, item_type, item_id),
|
|
15472
|
+
service: MONETIZATION_ENDPOINTS.ITEM_SUBSCRIPTION.service,
|
|
15473
|
+
method: 'GET',
|
|
15474
|
+
}),
|
|
15475
|
+
providesTags: ['itemSubscription'],
|
|
15476
|
+
}),
|
|
15477
|
+
// ── Flow 9: Platform Analytics (Admin) ──
|
|
15478
|
+
listPaywalls: builder.query({
|
|
15479
|
+
query: ({ platform_key, ...params }) => ({
|
|
15480
|
+
url: MONETIZATION_ENDPOINTS.LIST_PAYWALLS.path(platform_key),
|
|
15481
|
+
service: MONETIZATION_ENDPOINTS.LIST_PAYWALLS.service,
|
|
15482
|
+
method: 'GET',
|
|
15483
|
+
params,
|
|
15484
|
+
}),
|
|
15485
|
+
providesTags: ['paywalls'],
|
|
15486
|
+
}),
|
|
15487
|
+
listSubscribers: builder.query({
|
|
15488
|
+
query: ({ platform_key, ...params }) => ({
|
|
15489
|
+
url: MONETIZATION_ENDPOINTS.LIST_SUBSCRIBERS.path(platform_key),
|
|
15490
|
+
service: MONETIZATION_ENDPOINTS.LIST_SUBSCRIBERS.service,
|
|
15491
|
+
method: 'GET',
|
|
15492
|
+
params,
|
|
15493
|
+
}),
|
|
15494
|
+
providesTags: ['subscribers'],
|
|
15495
|
+
}),
|
|
15496
|
+
listItemSubscribers: builder.query({
|
|
15497
|
+
query: ({ platform_key, item_type, item_id, ...params }) => ({
|
|
15498
|
+
url: MONETIZATION_ENDPOINTS.ITEM_SUBSCRIBERS.path(platform_key, item_type, item_id),
|
|
15499
|
+
service: MONETIZATION_ENDPOINTS.ITEM_SUBSCRIBERS.service,
|
|
15500
|
+
method: 'GET',
|
|
15501
|
+
params,
|
|
15502
|
+
}),
|
|
15503
|
+
providesTags: ['subscribers'],
|
|
15504
|
+
}),
|
|
15505
|
+
getRevenue: builder.query({
|
|
15506
|
+
query: ({ platform_key }) => ({
|
|
15507
|
+
url: MONETIZATION_ENDPOINTS.REVENUE.path(platform_key),
|
|
15508
|
+
service: MONETIZATION_ENDPOINTS.REVENUE.service,
|
|
15509
|
+
method: 'GET',
|
|
15510
|
+
}),
|
|
15511
|
+
providesTags: ['revenue'],
|
|
15512
|
+
}),
|
|
15513
|
+
}),
|
|
15514
|
+
});
|
|
15515
|
+
|
|
15130
15516
|
const STRIPE_ENDPOINTS = {
|
|
15131
15517
|
GET_STRIPE_CONTEXT: {
|
|
15132
15518
|
service: SERVICES.DM,
|
|
@@ -17939,11 +18325,18 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
17939
18325
|
onStartNewChat === null || onStartNewChat === void 0 ? void 0 : onStartNewChat(response.session_id);
|
|
17940
18326
|
}
|
|
17941
18327
|
catch (error) {
|
|
18328
|
+
console.log("[MONETIZATION] session error", { error });
|
|
17942
18329
|
if (mentorSettings.mentorVisibility !==
|
|
17943
18330
|
iblaiApi.MentorVisibilityEnum.VIEWABLE_BY_ANYONE) {
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
18331
|
+
//only logging out if error code isn't 402
|
|
18332
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 402) {
|
|
18333
|
+
on402Error === null || on402Error === void 0 ? void 0 : on402Error(error === null || error === void 0 ? void 0 : error.data);
|
|
18334
|
+
}
|
|
18335
|
+
else {
|
|
18336
|
+
errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler(`Failed to start new chat: ${JSON.stringify(error)}`);
|
|
18337
|
+
console.log("[auth-redirect] Failed to start new chat", JSON.stringify({ error }));
|
|
18338
|
+
redirectToAuthSpa(undefined, undefined, true);
|
|
18339
|
+
}
|
|
17947
18340
|
}
|
|
17948
18341
|
}
|
|
17949
18342
|
}, [
|
|
@@ -22992,6 +23385,7 @@ exports.isTauri = isTauri;
|
|
|
22992
23385
|
exports.isWeb = isWeb$2;
|
|
22993
23386
|
exports.loadMetadataConfig = loadMetadataConfig;
|
|
22994
23387
|
exports.markdownToPlainText = markdownToPlainText;
|
|
23388
|
+
exports.monetizationSlice = monetizationSlice;
|
|
22995
23389
|
exports.parseCSV = parseCSV;
|
|
22996
23390
|
exports.redirectToAuthSpa = redirectToAuthSpa;
|
|
22997
23391
|
exports.redirectToAuthSpaJoinTenant = redirectToAuthSpaJoinTenant;
|
|
@@ -23024,7 +23418,11 @@ exports.selectToken = selectToken;
|
|
|
23024
23418
|
exports.selectTokenEnabled = selectTokenEnabled;
|
|
23025
23419
|
exports.selectTools = selectTools;
|
|
23026
23420
|
exports.sendMessageToParentWebsite = sendMessageToParentWebsite;
|
|
23421
|
+
exports.setAccessCheckResponse = setAccessCheckResponse;
|
|
23422
|
+
exports.setAdvancedDisplayMonetizationCheckoutModal = setAdvancedDisplayMonetizationCheckoutModal;
|
|
23027
23423
|
exports.setCookieForAuth = setCookieForAuth;
|
|
23424
|
+
exports.setDisplayMonetizationCheckoutModal = setDisplayMonetizationCheckoutModal;
|
|
23425
|
+
exports.showMonetizationCheckoutModal = showMonetizationCheckoutModal;
|
|
23028
23426
|
exports.streamOllamaChat = streamOllamaChat;
|
|
23029
23427
|
exports.syncAuthToCookies = syncAuthToCookies;
|
|
23030
23428
|
exports.tenantKeySchema = tenantKeySchema;
|