@iblai/web-utils 1.2.4 → 1.2.6
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 +21 -4
- package/dist/index.esm.js +388 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +392 -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
|
@@ -3532,7 +3532,6 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
3532
3532
|
saveUserTokens === null || saveUserTokens === void 0 ? void 0 : saveUserTokens(tokenResponse);
|
|
3533
3533
|
saveCurrentTenant(userAlreadyInTenant);
|
|
3534
3534
|
setUserIsAccessingPublicRoute(false);
|
|
3535
|
-
saveTenant === null || saveTenant === void 0 ? void 0 : saveTenant(userAlreadyInTenant.key);
|
|
3536
3535
|
setIsLoading(false);
|
|
3537
3536
|
return;
|
|
3538
3537
|
}
|
|
@@ -5882,7 +5881,7 @@ const STREAMING_CONTENT_BUFFER_THRESHOLD = 300; // characters
|
|
|
5882
5881
|
const STREAMING_CONTENT_FLUSH_INTERVAL = 300; // milliseconds
|
|
5883
5882
|
const defaultSessionIds = Object.fromEntries(Object.keys(advancedTabsProperties).map((key) => [key, ""]));
|
|
5884
5883
|
const defaultChatState = Object.fromEntries(Object.keys(advancedTabsProperties).map((key) => [key, []]));
|
|
5885
|
-
const initialState$
|
|
5884
|
+
const initialState$3 = {
|
|
5886
5885
|
chats: defaultChatState,
|
|
5887
5886
|
isTyping: false,
|
|
5888
5887
|
streaming: false,
|
|
@@ -5915,7 +5914,7 @@ const initialState$2 = {
|
|
|
5915
5914
|
};
|
|
5916
5915
|
const chatSlice = createSlice$1({
|
|
5917
5916
|
name: "chatSliceShared",
|
|
5918
|
-
initialState: initialState$
|
|
5917
|
+
initialState: initialState$3,
|
|
5919
5918
|
reducers: {
|
|
5920
5919
|
setChats: (state, action) => {
|
|
5921
5920
|
state.chats = action.payload;
|
|
@@ -6579,12 +6578,12 @@ function useTimeTrackerNative(config) {
|
|
|
6579
6578
|
};
|
|
6580
6579
|
}
|
|
6581
6580
|
|
|
6582
|
-
const initialState$
|
|
6581
|
+
const initialState$2 = {
|
|
6583
6582
|
attachedFiles: [],
|
|
6584
6583
|
};
|
|
6585
6584
|
const filesSlice = createSlice$1({
|
|
6586
6585
|
name: "files",
|
|
6587
|
-
initialState: initialState$
|
|
6586
|
+
initialState: initialState$2,
|
|
6588
6587
|
reducers: {
|
|
6589
6588
|
addFiles: (state, action) => {
|
|
6590
6589
|
state.attachedFiles = [...state.attachedFiles, ...action.payload];
|
|
@@ -6763,6 +6762,44 @@ function csvDataToText(data) {
|
|
|
6763
6762
|
].join("\n");
|
|
6764
6763
|
}
|
|
6765
6764
|
|
|
6765
|
+
const initialState$1 = {
|
|
6766
|
+
displayMonetizationCheckoutModal: false,
|
|
6767
|
+
accessCheckResponse: null,
|
|
6768
|
+
paywallClosable: true,
|
|
6769
|
+
onClosePayload: undefined,
|
|
6770
|
+
};
|
|
6771
|
+
const monetizationSlice = createSlice$1({
|
|
6772
|
+
name: "monetization",
|
|
6773
|
+
initialState: initialState$1,
|
|
6774
|
+
reducers: {
|
|
6775
|
+
setDisplayMonetizationCheckoutModal(state, action) {
|
|
6776
|
+
state.displayMonetizationCheckoutModal = action.payload;
|
|
6777
|
+
if (!action.payload) {
|
|
6778
|
+
state.accessCheckResponse = null;
|
|
6779
|
+
}
|
|
6780
|
+
},
|
|
6781
|
+
setAccessCheckResponse(state, action) {
|
|
6782
|
+
state.accessCheckResponse = action.payload;
|
|
6783
|
+
},
|
|
6784
|
+
showMonetizationCheckoutModal(state, action) {
|
|
6785
|
+
var _a, _b, _c, _d, _e;
|
|
6786
|
+
state.displayMonetizationCheckoutModal =
|
|
6787
|
+
(_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.showModal) !== null && _b !== void 0 ? _b : true;
|
|
6788
|
+
state.accessCheckResponse = action.payload;
|
|
6789
|
+
state.paywallClosable = (_d = (_c = action.payload) === null || _c === void 0 ? void 0 : _c.paywallClosable) !== null && _d !== void 0 ? _d : true;
|
|
6790
|
+
state.onClosePayload = (_e = action.payload) === null || _e === void 0 ? void 0 : _e.onClosePayload;
|
|
6791
|
+
},
|
|
6792
|
+
setAdvancedDisplayMonetizationCheckoutModal(state, action) {
|
|
6793
|
+
var _a, _b, _c, _d, _e;
|
|
6794
|
+
state.displayMonetizationCheckoutModal =
|
|
6795
|
+
(_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.showModal) !== null && _b !== void 0 ? _b : true;
|
|
6796
|
+
state.paywallClosable = (_d = (_c = action.payload) === null || _c === void 0 ? void 0 : _c.paywallClosable) !== null && _d !== void 0 ? _d : true;
|
|
6797
|
+
state.onClosePayload = (_e = action.payload) === null || _e === void 0 ? void 0 : _e.onClosePayload;
|
|
6798
|
+
},
|
|
6799
|
+
},
|
|
6800
|
+
});
|
|
6801
|
+
const { setDisplayMonetizationCheckoutModal, setAccessCheckResponse, showMonetizationCheckoutModal, setAdvancedDisplayMonetizationCheckoutModal, } = monetizationSlice.actions;
|
|
6802
|
+
|
|
6766
6803
|
/**
|
|
6767
6804
|
* Ollama API client for local LLM chat
|
|
6768
6805
|
*
|
|
@@ -13540,12 +13577,12 @@ const buildEndpointFromService = (service, serviceFn) => {
|
|
|
13540
13577
|
}
|
|
13541
13578
|
catch (err) {
|
|
13542
13579
|
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, err === null || err === void 0 ? void 0 : err.status)) {
|
|
13543
|
-
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]();
|
|
13580
|
+
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]({ ...((err === null || err === void 0 ? void 0 : err.data) || {}) });
|
|
13544
13581
|
}
|
|
13545
13582
|
return {
|
|
13546
13583
|
error: {
|
|
13547
13584
|
status: (err === null || err === void 0 ? void 0 : err.status) || 500,
|
|
13548
|
-
data: (err === null || err === void 0 ? void 0 : err.body) || (err === null || err === void 0 ? void 0 : err.message) || 'Unknown error',
|
|
13585
|
+
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',
|
|
13549
13586
|
},
|
|
13550
13587
|
};
|
|
13551
13588
|
}
|
|
@@ -13599,24 +13636,40 @@ const baseQuery = (service, jsonContentType = true, contentType, skipAuth = fals
|
|
|
13599
13636
|
/**
|
|
13600
13637
|
* Helper to invoke registered HTTP error handlers (e.g., logout on 401).
|
|
13601
13638
|
*/
|
|
13602
|
-
const invokeHttpErrorHandler = (status) => {
|
|
13639
|
+
const invokeHttpErrorHandler = (status, error) => {
|
|
13603
13640
|
const numericStatus = typeof status === 'number' ? status : parseInt(String(status), 10);
|
|
13641
|
+
console.log('[MONETIZATION error] ', { error });
|
|
13604
13642
|
if (!isNaN(numericStatus) &&
|
|
13605
13643
|
Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, numericStatus)) {
|
|
13606
|
-
|
|
13644
|
+
const err = error;
|
|
13645
|
+
Config.httpErrorHandlers[numericStatus]({ ...(err || {}) });
|
|
13607
13646
|
}
|
|
13608
13647
|
};
|
|
13648
|
+
/** HTTP status codes that should not be retried (e.g., 402 Payment Required). */
|
|
13649
|
+
const NON_RETRYABLE_STATUS_CODES = [402];
|
|
13650
|
+
/**
|
|
13651
|
+
* Wraps a base query to skip retries for non-retryable HTTP status codes.
|
|
13652
|
+
* Uses `retry.fail()` to immediately bail out of the retry loop.
|
|
13653
|
+
*/
|
|
13654
|
+
const withNonRetryableErrors = (query) => async (args, api, extraOptions) => {
|
|
13655
|
+
const result = await query(args, api, extraOptions);
|
|
13656
|
+
if (result.error && NON_RETRYABLE_STATUS_CODES.includes(result.error.status)) {
|
|
13657
|
+
retry.fail(result.error);
|
|
13658
|
+
}
|
|
13659
|
+
return result;
|
|
13660
|
+
};
|
|
13609
13661
|
const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
13610
|
-
var _a, _b;
|
|
13662
|
+
var _a, _b, _c;
|
|
13611
13663
|
try {
|
|
13612
13664
|
// Executing base query
|
|
13613
|
-
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), {
|
|
13665
|
+
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)), {
|
|
13614
13666
|
maxRetries: 3,
|
|
13615
13667
|
})(args, api, extraOptions);
|
|
13616
13668
|
// Query completed
|
|
13617
13669
|
if (result.error) {
|
|
13670
|
+
console.log('[MONETIZATION ERROR HANDLER]: ', { result });
|
|
13618
13671
|
// Invoke registered HTTP error handlers (e.g., logout on 401)
|
|
13619
|
-
invokeHttpErrorHandler(result.error.status);
|
|
13672
|
+
invokeHttpErrorHandler(result.error.status, (_b = result.error) === null || _b === void 0 ? void 0 : _b.data);
|
|
13620
13673
|
// For profile image upload errors, preserve the original error structure
|
|
13621
13674
|
if (args.url && args.url.includes('/profile_images/')) {
|
|
13622
13675
|
throw result.error;
|
|
@@ -13634,7 +13687,7 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
13634
13687
|
// Ensure we throw a plain FetchBaseQueryError shape with enumerable fields
|
|
13635
13688
|
throw {
|
|
13636
13689
|
status: result.error.status,
|
|
13637
|
-
data: (
|
|
13690
|
+
data: (_c = result.error.data) !== null && _c !== void 0 ? _c : errorMessage,
|
|
13638
13691
|
};
|
|
13639
13692
|
}
|
|
13640
13693
|
return { data: result === null || result === void 0 ? void 0 : result.data };
|
|
@@ -13648,10 +13701,12 @@ const iblFetchBaseQuery = async (args, api, extraOptions) => {
|
|
|
13648
13701
|
error: e,
|
|
13649
13702
|
}));
|
|
13650
13703
|
// Extract status from error and invoke HTTP error handlers
|
|
13704
|
+
console.log('[MONETIZATION e]', { e });
|
|
13705
|
+
const err = e;
|
|
13651
13706
|
const errorStatus = typeof e === 'object' && e !== null && 'status' in e
|
|
13652
13707
|
? e.status
|
|
13653
13708
|
: undefined;
|
|
13654
|
-
invokeHttpErrorHandler(errorStatus);
|
|
13709
|
+
invokeHttpErrorHandler(errorStatus, err === null || err === void 0 ? void 0 : err.data);
|
|
13655
13710
|
// Preserve original RTK error object for profile image uploads
|
|
13656
13711
|
if (args.url &&
|
|
13657
13712
|
args.url.includes('/profile_images/') &&
|
|
@@ -13688,7 +13743,11 @@ const buildEndpointFromServiceLegacy = (service, serviceFn) => {
|
|
|
13688
13743
|
}
|
|
13689
13744
|
catch (err) {
|
|
13690
13745
|
if (Object.prototype.hasOwnProperty.call(Config.httpErrorHandlers, err === null || err === void 0 ? void 0 : err.status)) {
|
|
13691
|
-
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status](
|
|
13746
|
+
Config.httpErrorHandlers[err === null || err === void 0 ? void 0 : err.status]({
|
|
13747
|
+
status: err === null || err === void 0 ? void 0 : err.status,
|
|
13748
|
+
body: err === null || err === void 0 ? void 0 : err.body,
|
|
13749
|
+
message: err === null || err === void 0 ? void 0 : err.message,
|
|
13750
|
+
});
|
|
13692
13751
|
}
|
|
13693
13752
|
return {
|
|
13694
13753
|
error: {
|
|
@@ -15128,6 +15187,309 @@ createApi({
|
|
|
15128
15187
|
}),
|
|
15129
15188
|
});
|
|
15130
15189
|
|
|
15190
|
+
const MONETIZATION_REDUCER_PATH = 'monetizationApiSlice';
|
|
15191
|
+
const SERVICE_BASE = '/api/service/platforms';
|
|
15192
|
+
const BILLING_BASE = '/api/billing/platforms';
|
|
15193
|
+
const MONETIZATION_ENDPOINTS = {
|
|
15194
|
+
// Flow 1 — Stripe Connect Onboarding (Admin)
|
|
15195
|
+
STRIPE_CONNECT_STATUS: {
|
|
15196
|
+
path: (key) => `${SERVICE_BASE}/${key}/stripe/connect/status/`,
|
|
15197
|
+
service: SERVICES.DM,
|
|
15198
|
+
},
|
|
15199
|
+
STRIPE_CONNECT_ONBOARD: {
|
|
15200
|
+
path: (key) => `${SERVICE_BASE}/${key}/stripe/connect/onboard/`,
|
|
15201
|
+
service: SERVICES.DM,
|
|
15202
|
+
},
|
|
15203
|
+
STRIPE_CONNECT_DASHBOARD: {
|
|
15204
|
+
path: (key) => `${SERVICE_BASE}/${key}/stripe/connect/dashboard/`,
|
|
15205
|
+
service: SERVICES.DM,
|
|
15206
|
+
},
|
|
15207
|
+
// Flow 2 — Configure Paywall (Admin)
|
|
15208
|
+
PAYWALL_CONFIG: {
|
|
15209
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/paywall/`,
|
|
15210
|
+
service: SERVICES.DM,
|
|
15211
|
+
},
|
|
15212
|
+
// Flow 3 — Manage Prices (Admin)
|
|
15213
|
+
PAYWALL_PRICES: {
|
|
15214
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/paywall/prices/`,
|
|
15215
|
+
service: SERVICES.DM,
|
|
15216
|
+
},
|
|
15217
|
+
PAYWALL_PRICE_DETAIL: {
|
|
15218
|
+
path: (key, type, id, priceId) => `${BILLING_BASE}/${key}/items/${type}/${id}/paywall/prices/${priceId}/`,
|
|
15219
|
+
service: SERVICES.DM,
|
|
15220
|
+
},
|
|
15221
|
+
// Flow 4 — Public Pricing (No Auth)
|
|
15222
|
+
PUBLIC_PRICING: {
|
|
15223
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/pricing/`,
|
|
15224
|
+
service: SERVICES.DM,
|
|
15225
|
+
},
|
|
15226
|
+
// Flow 5 — Access Check
|
|
15227
|
+
ACCESS_CHECK: {
|
|
15228
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/access-check/`,
|
|
15229
|
+
service: SERVICES.DM,
|
|
15230
|
+
},
|
|
15231
|
+
ACCESS_CHECK_UNSCOPED: {
|
|
15232
|
+
path: (type, id) => `/api/billing/access-check/${type}/${id}/`,
|
|
15233
|
+
service: SERVICES.DM,
|
|
15234
|
+
},
|
|
15235
|
+
// Flow 6 — Checkout
|
|
15236
|
+
CHECKOUT: {
|
|
15237
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/checkout/`,
|
|
15238
|
+
service: SERVICES.DM,
|
|
15239
|
+
},
|
|
15240
|
+
CHECKOUT_GUEST: {
|
|
15241
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/checkout-guest/`,
|
|
15242
|
+
service: SERVICES.DM,
|
|
15243
|
+
},
|
|
15244
|
+
// Flow 7 — Cancel Subscription
|
|
15245
|
+
CANCEL_SUBSCRIPTION: {
|
|
15246
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/subscription/cancel/`,
|
|
15247
|
+
service: SERVICES.DM,
|
|
15248
|
+
},
|
|
15249
|
+
// Flow 8 — User Subscriptions
|
|
15250
|
+
MY_SUBSCRIPTIONS: {
|
|
15251
|
+
path: (key) => `${BILLING_BASE}/${key}/my-subscriptions/`,
|
|
15252
|
+
service: SERVICES.DM,
|
|
15253
|
+
},
|
|
15254
|
+
ITEM_SUBSCRIPTION: {
|
|
15255
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/subscription/`,
|
|
15256
|
+
service: SERVICES.DM,
|
|
15257
|
+
},
|
|
15258
|
+
// Flow 9 — Platform Analytics (Admin)
|
|
15259
|
+
LIST_PAYWALLS: {
|
|
15260
|
+
path: (key) => `${BILLING_BASE}/${key}/paywalls/`,
|
|
15261
|
+
service: SERVICES.DM,
|
|
15262
|
+
},
|
|
15263
|
+
LIST_SUBSCRIBERS: {
|
|
15264
|
+
path: (key) => `${BILLING_BASE}/${key}/subscribers/`,
|
|
15265
|
+
service: SERVICES.DM,
|
|
15266
|
+
},
|
|
15267
|
+
ITEM_SUBSCRIBERS: {
|
|
15268
|
+
path: (key, type, id) => `${BILLING_BASE}/${key}/items/${type}/${id}/subscribers/`,
|
|
15269
|
+
service: SERVICES.DM,
|
|
15270
|
+
},
|
|
15271
|
+
REVENUE: {
|
|
15272
|
+
path: (key) => `${BILLING_BASE}/${key}/revenue/`,
|
|
15273
|
+
service: SERVICES.DM,
|
|
15274
|
+
},
|
|
15275
|
+
};
|
|
15276
|
+
|
|
15277
|
+
createApi({
|
|
15278
|
+
reducerPath: MONETIZATION_REDUCER_PATH,
|
|
15279
|
+
baseQuery: iblFetchBaseQuery,
|
|
15280
|
+
tagTypes: [
|
|
15281
|
+
'stripeConnectStatus',
|
|
15282
|
+
'paywallConfig',
|
|
15283
|
+
'paywallPrices',
|
|
15284
|
+
'publicPricing',
|
|
15285
|
+
'accessCheck',
|
|
15286
|
+
'mySubscriptions',
|
|
15287
|
+
'itemSubscription',
|
|
15288
|
+
'paywalls',
|
|
15289
|
+
'subscribers',
|
|
15290
|
+
'revenue',
|
|
15291
|
+
],
|
|
15292
|
+
endpoints: (builder) => ({
|
|
15293
|
+
// ── Flow 1: Stripe Connect ──
|
|
15294
|
+
getStripeConnectStatus: builder.query({
|
|
15295
|
+
query: ({ platform_key }) => ({
|
|
15296
|
+
url: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_STATUS.path(platform_key),
|
|
15297
|
+
service: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_STATUS.service,
|
|
15298
|
+
method: 'GET',
|
|
15299
|
+
}),
|
|
15300
|
+
providesTags: ['stripeConnectStatus'],
|
|
15301
|
+
}),
|
|
15302
|
+
startStripeConnectOnboarding: builder.mutation({
|
|
15303
|
+
query: ({ platform_key, ...body }) => ({
|
|
15304
|
+
url: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_ONBOARD.path(platform_key),
|
|
15305
|
+
service: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_ONBOARD.service,
|
|
15306
|
+
method: 'POST',
|
|
15307
|
+
body: JSON.stringify(body),
|
|
15308
|
+
}),
|
|
15309
|
+
invalidatesTags: ['stripeConnectStatus'],
|
|
15310
|
+
}),
|
|
15311
|
+
getStripeConnectDashboard: builder.query({
|
|
15312
|
+
query: ({ platform_key }) => ({
|
|
15313
|
+
url: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_DASHBOARD.path(platform_key),
|
|
15314
|
+
service: MONETIZATION_ENDPOINTS.STRIPE_CONNECT_DASHBOARD.service,
|
|
15315
|
+
method: 'GET',
|
|
15316
|
+
}),
|
|
15317
|
+
}),
|
|
15318
|
+
// ── Flow 2: Paywall Config ──
|
|
15319
|
+
getPaywallConfig: builder.query({
|
|
15320
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15321
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
|
|
15322
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.service,
|
|
15323
|
+
method: 'GET',
|
|
15324
|
+
}),
|
|
15325
|
+
providesTags: ['paywallConfig'],
|
|
15326
|
+
}),
|
|
15327
|
+
enablePaywall: builder.mutation({
|
|
15328
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15329
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
|
|
15330
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.service,
|
|
15331
|
+
method: 'POST',
|
|
15332
|
+
body: JSON.stringify(body),
|
|
15333
|
+
}),
|
|
15334
|
+
invalidatesTags: ['paywallConfig', 'paywalls'],
|
|
15335
|
+
}),
|
|
15336
|
+
disablePaywall: builder.mutation({
|
|
15337
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15338
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
|
|
15339
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.service,
|
|
15340
|
+
method: 'DELETE',
|
|
15341
|
+
}),
|
|
15342
|
+
invalidatesTags: ['paywallConfig', 'paywalls'],
|
|
15343
|
+
}),
|
|
15344
|
+
// ── Flow 3: Manage Prices ──
|
|
15345
|
+
listPrices: builder.query({
|
|
15346
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15347
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_PRICES.path(platform_key, item_type, item_id),
|
|
15348
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_PRICES.service,
|
|
15349
|
+
method: 'GET',
|
|
15350
|
+
}),
|
|
15351
|
+
providesTags: ['paywallPrices'],
|
|
15352
|
+
}),
|
|
15353
|
+
createPrice: builder.mutation({
|
|
15354
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15355
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_PRICES.path(platform_key, item_type, item_id),
|
|
15356
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_PRICES.service,
|
|
15357
|
+
method: 'POST',
|
|
15358
|
+
body: JSON.stringify(body),
|
|
15359
|
+
}),
|
|
15360
|
+
invalidatesTags: ['paywallPrices', 'paywallConfig'],
|
|
15361
|
+
}),
|
|
15362
|
+
updatePrice: builder.mutation({
|
|
15363
|
+
query: ({ platform_key, item_type, item_id, price_unique_id, ...body }) => ({
|
|
15364
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_PRICE_DETAIL.path(platform_key, item_type, item_id, price_unique_id),
|
|
15365
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_PRICE_DETAIL.service,
|
|
15366
|
+
method: 'PUT',
|
|
15367
|
+
body: JSON.stringify(body),
|
|
15368
|
+
}),
|
|
15369
|
+
invalidatesTags: ['paywallPrices', 'paywallConfig'],
|
|
15370
|
+
}),
|
|
15371
|
+
deletePrice: builder.mutation({
|
|
15372
|
+
query: ({ platform_key, item_type, item_id, price_unique_id }) => ({
|
|
15373
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_PRICE_DETAIL.path(platform_key, item_type, item_id, price_unique_id),
|
|
15374
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_PRICE_DETAIL.service,
|
|
15375
|
+
method: 'DELETE',
|
|
15376
|
+
}),
|
|
15377
|
+
invalidatesTags: ['paywallPrices', 'paywallConfig'],
|
|
15378
|
+
}),
|
|
15379
|
+
// ── Flow 4: Public Pricing (No Auth) ──
|
|
15380
|
+
getPublicPricing: builder.query({
|
|
15381
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15382
|
+
url: MONETIZATION_ENDPOINTS.PUBLIC_PRICING.path(platform_key, item_type, item_id),
|
|
15383
|
+
service: MONETIZATION_ENDPOINTS.PUBLIC_PRICING.service,
|
|
15384
|
+
method: 'GET',
|
|
15385
|
+
skipAuth: true,
|
|
15386
|
+
}),
|
|
15387
|
+
providesTags: ['publicPricing'],
|
|
15388
|
+
}),
|
|
15389
|
+
// ── Flow 5: Access Check ──
|
|
15390
|
+
checkAccess: builder.query({
|
|
15391
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15392
|
+
url: MONETIZATION_ENDPOINTS.ACCESS_CHECK.path(platform_key, item_type, item_id),
|
|
15393
|
+
service: MONETIZATION_ENDPOINTS.ACCESS_CHECK.service,
|
|
15394
|
+
method: 'GET',
|
|
15395
|
+
}),
|
|
15396
|
+
providesTags: ['accessCheck'],
|
|
15397
|
+
}),
|
|
15398
|
+
checkAccessUnscoped: builder.query({
|
|
15399
|
+
query: ({ item_type, item_id, platform_key }) => ({
|
|
15400
|
+
url: MONETIZATION_ENDPOINTS.ACCESS_CHECK_UNSCOPED.path(item_type, item_id),
|
|
15401
|
+
service: MONETIZATION_ENDPOINTS.ACCESS_CHECK_UNSCOPED.service,
|
|
15402
|
+
method: 'GET',
|
|
15403
|
+
params: { platform_key },
|
|
15404
|
+
}),
|
|
15405
|
+
providesTags: ['accessCheck'],
|
|
15406
|
+
}),
|
|
15407
|
+
// ── Flow 6A/6B: Checkout (Subscription & One-Time) ──
|
|
15408
|
+
createCheckout: builder.mutation({
|
|
15409
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15410
|
+
url: MONETIZATION_ENDPOINTS.CHECKOUT.path(platform_key, item_type, item_id),
|
|
15411
|
+
service: MONETIZATION_ENDPOINTS.CHECKOUT.service,
|
|
15412
|
+
method: 'POST',
|
|
15413
|
+
body: JSON.stringify(body),
|
|
15414
|
+
}),
|
|
15415
|
+
}),
|
|
15416
|
+
// ── Flow 6C: Guest Checkout (No Auth) ──
|
|
15417
|
+
createGuestCheckout: builder.mutation({
|
|
15418
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15419
|
+
url: MONETIZATION_ENDPOINTS.CHECKOUT_GUEST.path(platform_key, item_type, item_id),
|
|
15420
|
+
service: MONETIZATION_ENDPOINTS.CHECKOUT_GUEST.service,
|
|
15421
|
+
method: 'POST',
|
|
15422
|
+
body: JSON.stringify(body),
|
|
15423
|
+
skipAuth: true,
|
|
15424
|
+
}),
|
|
15425
|
+
}),
|
|
15426
|
+
// ── Flow 7: Cancel Subscription ──
|
|
15427
|
+
cancelSubscription: builder.mutation({
|
|
15428
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15429
|
+
url: MONETIZATION_ENDPOINTS.CANCEL_SUBSCRIPTION.path(platform_key, item_type, item_id),
|
|
15430
|
+
service: MONETIZATION_ENDPOINTS.CANCEL_SUBSCRIPTION.service,
|
|
15431
|
+
method: 'POST',
|
|
15432
|
+
body: JSON.stringify(body),
|
|
15433
|
+
}),
|
|
15434
|
+
invalidatesTags: ['mySubscriptions', 'itemSubscription', 'accessCheck', 'subscribers'],
|
|
15435
|
+
}),
|
|
15436
|
+
// ── Flow 8: User Subscriptions ──
|
|
15437
|
+
getMySubscriptions: builder.query({
|
|
15438
|
+
query: ({ platform_key, ...params }) => ({
|
|
15439
|
+
url: MONETIZATION_ENDPOINTS.MY_SUBSCRIPTIONS.path(platform_key),
|
|
15440
|
+
service: MONETIZATION_ENDPOINTS.MY_SUBSCRIPTIONS.service,
|
|
15441
|
+
method: 'GET',
|
|
15442
|
+
params,
|
|
15443
|
+
}),
|
|
15444
|
+
providesTags: ['mySubscriptions'],
|
|
15445
|
+
}),
|
|
15446
|
+
getItemSubscription: builder.query({
|
|
15447
|
+
query: ({ platform_key, item_type, item_id }) => ({
|
|
15448
|
+
url: MONETIZATION_ENDPOINTS.ITEM_SUBSCRIPTION.path(platform_key, item_type, item_id),
|
|
15449
|
+
service: MONETIZATION_ENDPOINTS.ITEM_SUBSCRIPTION.service,
|
|
15450
|
+
method: 'GET',
|
|
15451
|
+
}),
|
|
15452
|
+
providesTags: ['itemSubscription'],
|
|
15453
|
+
}),
|
|
15454
|
+
// ── Flow 9: Platform Analytics (Admin) ──
|
|
15455
|
+
listPaywalls: builder.query({
|
|
15456
|
+
query: ({ platform_key, ...params }) => ({
|
|
15457
|
+
url: MONETIZATION_ENDPOINTS.LIST_PAYWALLS.path(platform_key),
|
|
15458
|
+
service: MONETIZATION_ENDPOINTS.LIST_PAYWALLS.service,
|
|
15459
|
+
method: 'GET',
|
|
15460
|
+
params,
|
|
15461
|
+
}),
|
|
15462
|
+
providesTags: ['paywalls'],
|
|
15463
|
+
}),
|
|
15464
|
+
listSubscribers: builder.query({
|
|
15465
|
+
query: ({ platform_key, ...params }) => ({
|
|
15466
|
+
url: MONETIZATION_ENDPOINTS.LIST_SUBSCRIBERS.path(platform_key),
|
|
15467
|
+
service: MONETIZATION_ENDPOINTS.LIST_SUBSCRIBERS.service,
|
|
15468
|
+
method: 'GET',
|
|
15469
|
+
params,
|
|
15470
|
+
}),
|
|
15471
|
+
providesTags: ['subscribers'],
|
|
15472
|
+
}),
|
|
15473
|
+
listItemSubscribers: builder.query({
|
|
15474
|
+
query: ({ platform_key, item_type, item_id, ...params }) => ({
|
|
15475
|
+
url: MONETIZATION_ENDPOINTS.ITEM_SUBSCRIBERS.path(platform_key, item_type, item_id),
|
|
15476
|
+
service: MONETIZATION_ENDPOINTS.ITEM_SUBSCRIBERS.service,
|
|
15477
|
+
method: 'GET',
|
|
15478
|
+
params,
|
|
15479
|
+
}),
|
|
15480
|
+
providesTags: ['subscribers'],
|
|
15481
|
+
}),
|
|
15482
|
+
getRevenue: builder.query({
|
|
15483
|
+
query: ({ platform_key }) => ({
|
|
15484
|
+
url: MONETIZATION_ENDPOINTS.REVENUE.path(platform_key),
|
|
15485
|
+
service: MONETIZATION_ENDPOINTS.REVENUE.service,
|
|
15486
|
+
method: 'GET',
|
|
15487
|
+
}),
|
|
15488
|
+
providesTags: ['revenue'],
|
|
15489
|
+
}),
|
|
15490
|
+
}),
|
|
15491
|
+
});
|
|
15492
|
+
|
|
15131
15493
|
const STRIPE_ENDPOINTS = {
|
|
15132
15494
|
GET_STRIPE_CONTEXT: {
|
|
15133
15495
|
service: SERVICES.DM,
|
|
@@ -17940,11 +18302,18 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
17940
18302
|
onStartNewChat === null || onStartNewChat === void 0 ? void 0 : onStartNewChat(response.session_id);
|
|
17941
18303
|
}
|
|
17942
18304
|
catch (error) {
|
|
18305
|
+
console.log("[MONETIZATION] session error", { error });
|
|
17943
18306
|
if (mentorSettings.mentorVisibility !==
|
|
17944
18307
|
iblaiApi.MentorVisibilityEnum.VIEWABLE_BY_ANYONE) {
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
18308
|
+
//only logging out if error code isn't 402
|
|
18309
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 402) {
|
|
18310
|
+
on402Error === null || on402Error === void 0 ? void 0 : on402Error(error === null || error === void 0 ? void 0 : error.data);
|
|
18311
|
+
}
|
|
18312
|
+
else {
|
|
18313
|
+
errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler(`Failed to start new chat: ${JSON.stringify(error)}`);
|
|
18314
|
+
console.log("[auth-redirect] Failed to start new chat", JSON.stringify({ error }));
|
|
18315
|
+
redirectToAuthSpa(undefined, undefined, true);
|
|
18316
|
+
}
|
|
17948
18317
|
}
|
|
17949
18318
|
}
|
|
17950
18319
|
}, [
|
|
@@ -22993,6 +23362,7 @@ exports.isTauri = isTauri;
|
|
|
22993
23362
|
exports.isWeb = isWeb$2;
|
|
22994
23363
|
exports.loadMetadataConfig = loadMetadataConfig;
|
|
22995
23364
|
exports.markdownToPlainText = markdownToPlainText;
|
|
23365
|
+
exports.monetizationSlice = monetizationSlice;
|
|
22996
23366
|
exports.parseCSV = parseCSV;
|
|
22997
23367
|
exports.redirectToAuthSpa = redirectToAuthSpa;
|
|
22998
23368
|
exports.redirectToAuthSpaJoinTenant = redirectToAuthSpaJoinTenant;
|
|
@@ -23025,7 +23395,11 @@ exports.selectToken = selectToken;
|
|
|
23025
23395
|
exports.selectTokenEnabled = selectTokenEnabled;
|
|
23026
23396
|
exports.selectTools = selectTools;
|
|
23027
23397
|
exports.sendMessageToParentWebsite = sendMessageToParentWebsite;
|
|
23398
|
+
exports.setAccessCheckResponse = setAccessCheckResponse;
|
|
23399
|
+
exports.setAdvancedDisplayMonetizationCheckoutModal = setAdvancedDisplayMonetizationCheckoutModal;
|
|
23028
23400
|
exports.setCookieForAuth = setCookieForAuth;
|
|
23401
|
+
exports.setDisplayMonetizationCheckoutModal = setDisplayMonetizationCheckoutModal;
|
|
23402
|
+
exports.showMonetizationCheckoutModal = showMonetizationCheckoutModal;
|
|
23029
23403
|
exports.streamOllamaChat = streamOllamaChat;
|
|
23030
23404
|
exports.syncAuthToCookies = syncAuthToCookies;
|
|
23031
23405
|
exports.tenantKeySchema = tenantKeySchema;
|