@iblai/web-utils 1.1.18 → 1.2.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.
package/dist/index.esm.js CHANGED
@@ -3251,6 +3251,40 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3251
3251
  }
3252
3252
  return tenants;
3253
3253
  };
3254
+ /**
3255
+ * Joins a tenant, fetches fresh tokens and tenants, loads RBAC permissions,
3256
+ * and updates all relevant state. If the join fails, saves the tenant as a
3257
+ * visiting tenant instead.
3258
+ */
3259
+ const joinAndActivateTenant = async (tenantKey, tenantMetadata, newCurrentTenant, { handleVisitingTenant = true } = {}) => {
3260
+ var _a;
3261
+ try {
3262
+ await joinTenant({ platform_key: tenantKey }).unwrap();
3263
+ const formData = new FormData();
3264
+ formData.append("platform_key", tenantKey);
3265
+ const { data: newTenants } = await fetchUserTenants();
3266
+ const enhancedNewTenants = await enhanceTenants(newTenants, tenantMetadata);
3267
+ const { data: tokenResponse } = await getAppToken(formData).unwrap();
3268
+ saveUserTokens === null || saveUserTokens === void 0 ? void 0 : saveUserTokens(tokenResponse);
3269
+ saveCurrentTenant(newCurrentTenant);
3270
+ if (enhancedNewTenants && enhancedNewTenants.length) {
3271
+ saveUserTenants(enhancedNewTenants);
3272
+ }
3273
+ const rbacPermissions = await loadPlatformPermissions(tenantMetadata.platform_key);
3274
+ onLoadPlatformPermissions === null || onLoadPlatformPermissions === void 0 ? void 0 : onLoadPlatformPermissions(rbacPermissions);
3275
+ onAutoJoinUserToTenant === null || onAutoJoinUserToTenant === void 0 ? void 0 : onAutoJoinUserToTenant((_a = tenantMetadata.platform_name) !== null && _a !== void 0 ? _a : tenantMetadata === null || tenantMetadata === void 0 ? void 0 : tenantMetadata.platform_key.toUpperCase());
3276
+ saveTenant === null || saveTenant === void 0 ? void 0 : saveTenant(tenantKey);
3277
+ setUserIsAccessingPublicRoute(false);
3278
+ removeVisitingTenant === null || removeVisitingTenant === void 0 ? void 0 : removeVisitingTenant();
3279
+ return true;
3280
+ }
3281
+ catch (e) {
3282
+ if (handleVisitingTenant) {
3283
+ saveVisitingTenant === null || saveVisitingTenant === void 0 ? void 0 : saveVisitingTenant(newCurrentTenant);
3284
+ }
3285
+ return false;
3286
+ }
3287
+ };
3254
3288
  /**
3255
3289
  * Determines which tenant the user should access by:
3256
3290
  * 1. Fetching user's available tenants
@@ -3316,7 +3350,18 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3316
3350
  if (isWeb() && sessionStorage.getItem(guardKey)) {
3317
3351
  sessionStorage.removeItem(guardKey);
3318
3352
  console.warn(`[TenantProvider] User still does not belong to custom domain tenant after re-auth: ${customDomainPlatformKey}`);
3319
- onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${customDomainPlatformKey}). Please contact your administrator.`);
3353
+ const joined = await joinAndActivateTenant(customDomainPlatformKey, {
3354
+ platform_key: customDomainPlatformKey,
3355
+ platform_name: customDomainPlatformKey,
3356
+ }, {
3357
+ key: customDomainPlatformKey,
3358
+ is_admin: false,
3359
+ org: customDomainPlatformKey,
3360
+ platform_name: customDomainPlatformKey,
3361
+ }, { handleVisitingTenant: false });
3362
+ if (!joined) {
3363
+ onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${customDomainPlatformKey}). Please contact your administrator.`);
3364
+ }
3320
3365
  return;
3321
3366
  }
3322
3367
  if (isWeb()) {
@@ -3407,7 +3452,7 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3407
3452
  }
3408
3453
  }
3409
3454
  async function handleLoadTenantMetadata(tenantKey) {
3410
- var _a, _b, _c;
3455
+ var _a, _b;
3411
3456
  setIsLoading(true);
3412
3457
  const MAIN_TENANT_KEY = "main";
3413
3458
  try {
@@ -3462,41 +3507,7 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3462
3507
  setIsLoading(false);
3463
3508
  return;
3464
3509
  }
3465
- try {
3466
- await joinTenant({
3467
- platform_key: tenantKey,
3468
- }).unwrap();
3469
- try {
3470
- // succesfully joined tenant at this point
3471
- // we want to fetch tokens for this new tenant
3472
- const formData = new FormData();
3473
- formData.append("platform_key", tenantKey);
3474
- const { data: newTenants } = await fetchUserTenants();
3475
- const enhancedNewTenants = await enhanceTenants(newTenants, data);
3476
- const { data: tokenResponse } = await getAppToken(formData).unwrap();
3477
- saveUserTokens === null || saveUserTokens === void 0 ? void 0 : saveUserTokens(tokenResponse);
3478
- saveCurrentTenant(newCurrentTenant);
3479
- if (enhancedNewTenants && enhancedNewTenants.length) {
3480
- saveUserTenants(enhancedNewTenants);
3481
- }
3482
- else {
3483
- // TODO: What happense when if for any reason we fetch tenants and it's an empty list
3484
- }
3485
- const rbacPermissions = await loadPlatformPermissions(data.platform_key);
3486
- onLoadPlatformPermissions === null || onLoadPlatformPermissions === void 0 ? void 0 : onLoadPlatformPermissions(rbacPermissions);
3487
- onAutoJoinUserToTenant === null || onAutoJoinUserToTenant === void 0 ? void 0 : onAutoJoinUserToTenant((_c = data.platform_name) !== null && _c !== void 0 ? _c : data === null || data === void 0 ? void 0 : data.platform_key.toUpperCase());
3488
- saveTenant === null || saveTenant === void 0 ? void 0 : saveTenant(tenantKey);
3489
- setUserIsAccessingPublicRoute(false);
3490
- removeVisitingTenant === null || removeVisitingTenant === void 0 ? void 0 : removeVisitingTenant();
3491
- }
3492
- catch (e) {
3493
- throw e;
3494
- }
3495
- }
3496
- catch (e) {
3497
- // failed to join the visiting tenant so save the visiting tenant
3498
- saveVisitingTenant === null || saveVisitingTenant === void 0 ? void 0 : saveVisitingTenant(newCurrentTenant);
3499
- }
3510
+ await joinAndActivateTenant(tenantKey, data, newCurrentTenant);
3500
3511
  }
3501
3512
  else {
3502
3513
  if (!currentTenant) {
@@ -16459,175 +16470,220 @@ createApi({
16459
16470
  });
16460
16471
 
16461
16472
  const MEMORY_REDUCER_PATH = 'memoryApiSlice';
16462
- const MEMORY_ENDPOINTS = {
16463
- GET_MEMORIES: {
16473
+ const MEMORY_QUERY_KEYS = {
16474
+ MEMSEARCH_USER_SETTINGS: () => ['MEMSEARCH_USER_SETTINGS'],
16475
+ MEMSEARCH_GLOBAL_MEMORIES: () => ['MEMSEARCH_GLOBAL_MEMORIES'],
16476
+ MEMSEARCH_MENTOR_MEMORIES: () => ['MEMSEARCH_MENTOR_MEMORIES'],
16477
+ MEMSEARCH_MEMORY_CATEGORIES: () => ['MEMSEARCH_MEMORY_CATEGORIES'],
16478
+ MEMSEARCH_PLATFORM_CONFIG: () => ['MEMSEARCH_PLATFORM_CONFIG'],
16479
+ };
16480
+ const MEMSEARCH_ENDPOINTS = {
16481
+ // User Memory Settings
16482
+ GET_USER_SETTINGS: {
16464
16483
  service: SERVICES.AXD,
16465
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memories/`,
16484
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/memsearch-settings/`,
16466
16485
  },
16467
- GET_MEMORY_CATEGORIES: {
16486
+ UPDATE_USER_SETTINGS: {
16468
16487
  service: SERVICES.AXD,
16469
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-categories/`,
16488
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/memsearch-settings/`,
16470
16489
  },
16471
- GET_MENTOR_USER_SETTINGS: {
16490
+ // Global Memories
16491
+ GET_GLOBAL_MEMORIES: {
16472
16492
  service: SERVICES.AXD,
16473
- path: (tenantKey, username, mentorId) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/mentors/${mentorId}/mentor-user-settings/`,
16493
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/global-memories/`,
16474
16494
  },
16475
- UPDATE_MENTOR_USER_SETTINGS: {
16495
+ CREATE_GLOBAL_MEMORY: {
16476
16496
  service: SERVICES.AXD,
16477
- path: (tenantKey, username, mentorId) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/mentors/${mentorId}/mentor-user-settings/`,
16497
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/global-memories/`,
16478
16498
  },
16479
- DELETE_MEMORY: {
16499
+ DELETE_GLOBAL_MEMORY: {
16480
16500
  service: SERVICES.AXD,
16481
- path: (tenantKey, username, memoryId) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-entries/${memoryId}/`,
16501
+ path: (org, userId, memoryId) => `/api/ai-mentor/orgs/${org}/users/${userId}/global-memories/${memoryId}/`,
16482
16502
  },
16483
- DELETE_MEMORY_BY_CATEGORY: {
16503
+ // Mentor-Specific Memories
16504
+ GET_MENTOR_MEMORIES: {
16484
16505
  service: SERVICES.AXD,
16485
- path: (tenantKey, username, category) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-entries/${category}/`,
16506
+ path: (org, userId, mentorId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories/`,
16486
16507
  },
16487
- UPDATE_MEMORY_ENTRY: {
16508
+ CREATE_MENTOR_MEMORY: {
16488
16509
  service: SERVICES.AXD,
16489
- path: (tenantKey, username, entryId) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-entries/${entryId}/`,
16510
+ path: (org, userId, mentorId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories/`,
16490
16511
  },
16491
- CREATE_MEMORY: {
16512
+ UPDATE_MENTOR_MEMORY: {
16492
16513
  service: SERVICES.AXD,
16493
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memories/`,
16514
+ path: (org, userId, mentorId, memoryId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories/${memoryId}/`,
16494
16515
  },
16495
- GET_MEMORY_FILTERS: {
16516
+ DELETE_MENTOR_MEMORY: {
16496
16517
  service: SERVICES.AXD,
16497
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-filter/`,
16518
+ path: (org, userId, mentorId, memoryId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories/${memoryId}/`,
16498
16519
  },
16499
- GET_FILTERED_MEMORIES: {
16520
+ // Memory Categories (Admin)
16521
+ GET_MEMSEARCH_CATEGORIES: {
16500
16522
  service: SERVICES.AXD,
16501
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/filtered-memories/`,
16523
+ path: (org, mentorId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorId}/memory-categories/`,
16524
+ },
16525
+ CREATE_MEMSEARCH_CATEGORY: {
16526
+ service: SERVICES.AXD,
16527
+ path: (org, mentorId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorId}/memory-categories/`,
16528
+ },
16529
+ UPDATE_MEMSEARCH_CATEGORY: {
16530
+ service: SERVICES.AXD,
16531
+ path: (org, mentorId, categoryId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorId}/memory-categories/${categoryId}/`,
16532
+ },
16533
+ DELETE_MEMSEARCH_CATEGORY: {
16534
+ service: SERVICES.AXD,
16535
+ path: (org, mentorId, categoryId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorId}/memory-categories/${categoryId}/`,
16536
+ },
16537
+ // Platform Configuration
16538
+ GET_MEMSEARCH_CONFIG: {
16539
+ service: SERVICES.AXD,
16540
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/memsearch-config/`,
16541
+ },
16542
+ UPDATE_MEMSEARCH_CONFIG: {
16543
+ service: SERVICES.AXD,
16544
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/memsearch-config/`,
16502
16545
  },
16503
- };
16504
- const MEMORY_QUERY_KEYS = {
16505
- GET_MEMORIES: () => ['MEMORIES'],
16506
- GET_MEMORY_CATEGORIES: () => ['MEMORY_CATEGORIES'],
16507
- GET_MENTOR_USER_SETTINGS: () => ['MENTOR_USER_SETTINGS'],
16508
- GET_FILTERED_MEMORIES: () => ['FILTERED_MEMORIES'],
16509
16546
  };
16510
16547
 
16511
16548
  createApi({
16512
16549
  reducerPath: MEMORY_REDUCER_PATH,
16513
16550
  tagTypes: [
16514
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16515
- ...MEMORY_QUERY_KEYS.GET_MEMORY_CATEGORIES(),
16516
- ...MEMORY_QUERY_KEYS.GET_MENTOR_USER_SETTINGS(),
16517
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16551
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_USER_SETTINGS(),
16552
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_GLOBAL_MEMORIES(),
16553
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16554
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16555
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_PLATFORM_CONFIG(),
16518
16556
  ],
16519
16557
  baseQuery: iblFetchBaseQuery,
16520
16558
  endpoints: (builder) => ({
16521
- getMemories: builder.query({
16522
- query: (args) => {
16523
- return {
16524
- url: MEMORY_ENDPOINTS.GET_MEMORIES.path(args.tenantKey, args.username),
16525
- params: args.params,
16526
- service: MEMORY_ENDPOINTS.GET_MEMORIES.service,
16527
- };
16528
- },
16529
- providesTags: MEMORY_QUERY_KEYS.GET_MEMORIES(),
16559
+ // User Memory Settings
16560
+ getUserMemorySettings: builder.query({
16561
+ query: (args) => ({
16562
+ url: MEMSEARCH_ENDPOINTS.GET_USER_SETTINGS.path(args.org, args.userId),
16563
+ service: MEMSEARCH_ENDPOINTS.GET_USER_SETTINGS.service,
16564
+ }),
16565
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_USER_SETTINGS(),
16530
16566
  }),
16531
- getMemoryCategories: builder.query({
16532
- query: (args) => {
16533
- return {
16534
- url: MEMORY_ENDPOINTS.GET_MEMORY_CATEGORIES.path(args.tenantKey, args.username),
16535
- service: MEMORY_ENDPOINTS.GET_MEMORY_CATEGORIES.service,
16536
- };
16537
- },
16538
- providesTags: MEMORY_QUERY_KEYS.GET_MEMORY_CATEGORIES(),
16567
+ updateUserMemorySettings: builder.mutation({
16568
+ query: (args) => ({
16569
+ url: MEMSEARCH_ENDPOINTS.UPDATE_USER_SETTINGS.path(args.org, args.userId),
16570
+ service: MEMSEARCH_ENDPOINTS.UPDATE_USER_SETTINGS.service,
16571
+ method: 'PUT',
16572
+ body: args.settings,
16573
+ }),
16574
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_USER_SETTINGS(),
16539
16575
  }),
16540
- getMentorUserSettings: builder.query({
16541
- query: (args) => {
16542
- return {
16543
- url: MEMORY_ENDPOINTS.GET_MENTOR_USER_SETTINGS.path(args.tenantKey, args.username, args.mentorId),
16544
- service: MEMORY_ENDPOINTS.GET_MENTOR_USER_SETTINGS.service,
16545
- };
16546
- },
16547
- providesTags: MEMORY_QUERY_KEYS.GET_MENTOR_USER_SETTINGS(),
16576
+ // Global Memories
16577
+ getGlobalMemories: builder.query({
16578
+ query: (args) => ({
16579
+ url: MEMSEARCH_ENDPOINTS.GET_GLOBAL_MEMORIES.path(args.org, args.userId),
16580
+ service: MEMSEARCH_ENDPOINTS.GET_GLOBAL_MEMORIES.service,
16581
+ params: args.params,
16582
+ }),
16583
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_GLOBAL_MEMORIES(),
16548
16584
  }),
16549
- updateMentorUserSettings: builder.mutation({
16550
- query: (args) => {
16551
- return {
16552
- url: MEMORY_ENDPOINTS.UPDATE_MENTOR_USER_SETTINGS.path(args.tenantKey, args.username, args.mentorId),
16553
- method: 'POST',
16554
- body: args.settings,
16555
- service: MEMORY_ENDPOINTS.UPDATE_MENTOR_USER_SETTINGS.service,
16556
- };
16557
- },
16558
- invalidatesTags: MEMORY_QUERY_KEYS.GET_MENTOR_USER_SETTINGS(),
16585
+ createGlobalMemory: builder.mutation({
16586
+ query: (args) => ({
16587
+ url: MEMSEARCH_ENDPOINTS.CREATE_GLOBAL_MEMORY.path(args.org, args.userId),
16588
+ service: MEMSEARCH_ENDPOINTS.CREATE_GLOBAL_MEMORY.service,
16589
+ method: 'POST',
16590
+ body: { content: args.content },
16591
+ }),
16592
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_GLOBAL_MEMORIES(),
16559
16593
  }),
16560
- deleteMemory: builder.mutation({
16561
- query: (args) => {
16562
- return {
16563
- url: MEMORY_ENDPOINTS.DELETE_MEMORY.path(args.tenantKey, args.username, args.memoryId),
16564
- method: 'DELETE',
16565
- service: MEMORY_ENDPOINTS.DELETE_MEMORY.service,
16566
- };
16567
- },
16568
- invalidatesTags: [
16569
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16570
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16571
- ],
16594
+ deleteGlobalMemory: builder.mutation({
16595
+ query: (args) => ({
16596
+ url: MEMSEARCH_ENDPOINTS.DELETE_GLOBAL_MEMORY.path(args.org, args.userId, args.memoryId),
16597
+ service: MEMSEARCH_ENDPOINTS.DELETE_GLOBAL_MEMORY.service,
16598
+ method: 'DELETE',
16599
+ }),
16600
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_GLOBAL_MEMORIES(),
16572
16601
  }),
16573
- deleteMemoryByCategory: builder.mutation({
16574
- query: (args) => {
16575
- return {
16576
- url: MEMORY_ENDPOINTS.DELETE_MEMORY_BY_CATEGORY.path(args.tenantKey, args.username, args.category),
16577
- method: 'DELETE',
16578
- service: MEMORY_ENDPOINTS.DELETE_MEMORY_BY_CATEGORY.service,
16579
- };
16580
- },
16581
- invalidatesTags: [
16582
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16583
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16584
- ],
16602
+ // Mentor-Specific Memories
16603
+ getMentorMemories: builder.query({
16604
+ query: (args) => ({
16605
+ url: MEMSEARCH_ENDPOINTS.GET_MENTOR_MEMORIES.path(args.org, args.userId, args.mentorId),
16606
+ service: MEMSEARCH_ENDPOINTS.GET_MENTOR_MEMORIES.service,
16607
+ params: args.params,
16608
+ }),
16609
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16585
16610
  }),
16586
- updateMemoryEntry: builder.mutation({
16587
- query: (args) => {
16588
- return {
16589
- url: MEMORY_ENDPOINTS.UPDATE_MEMORY_ENTRY.path(args.tenantKey, args.username, args.entryId),
16590
- method: 'POST',
16591
- body: args.data,
16592
- service: MEMORY_ENDPOINTS.UPDATE_MEMORY_ENTRY.service,
16593
- };
16594
- },
16595
- invalidatesTags: [
16596
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16597
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16598
- ],
16611
+ createMentorMemory: builder.mutation({
16612
+ query: (args) => ({
16613
+ url: MEMSEARCH_ENDPOINTS.CREATE_MENTOR_MEMORY.path(args.org, args.userId, args.mentorId),
16614
+ service: MEMSEARCH_ENDPOINTS.CREATE_MENTOR_MEMORY.service,
16615
+ method: 'POST',
16616
+ body: args.data,
16617
+ }),
16618
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16599
16619
  }),
16600
- createMemory: builder.mutation({
16601
- query: (args) => {
16602
- return {
16603
- url: MEMORY_ENDPOINTS.CREATE_MEMORY.path(args.tenantKey, args.username),
16604
- method: 'POST',
16605
- body: args.data,
16606
- service: MEMORY_ENDPOINTS.CREATE_MEMORY.service,
16607
- };
16608
- },
16609
- invalidatesTags: [
16610
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16611
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16612
- ],
16620
+ updateMentorMemory: builder.mutation({
16621
+ query: (args) => ({
16622
+ url: MEMSEARCH_ENDPOINTS.UPDATE_MENTOR_MEMORY.path(args.org, args.userId, args.mentorId, args.memoryId),
16623
+ service: MEMSEARCH_ENDPOINTS.UPDATE_MENTOR_MEMORY.service,
16624
+ method: 'PATCH',
16625
+ body: args.data,
16626
+ }),
16627
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16613
16628
  }),
16614
- getMemoryFilters: builder.query({
16615
- query: (args) => {
16616
- return {
16617
- url: MEMORY_ENDPOINTS.GET_MEMORY_FILTERS.path(args.tenantKey, args.username),
16618
- service: MEMORY_ENDPOINTS.GET_MEMORY_FILTERS.service,
16619
- };
16620
- },
16629
+ deleteMentorMemory: builder.mutation({
16630
+ query: (args) => ({
16631
+ url: MEMSEARCH_ENDPOINTS.DELETE_MENTOR_MEMORY.path(args.org, args.userId, args.mentorId, args.memoryId),
16632
+ service: MEMSEARCH_ENDPOINTS.DELETE_MENTOR_MEMORY.service,
16633
+ method: 'DELETE',
16634
+ }),
16635
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16621
16636
  }),
16622
- getFilteredMemories: builder.query({
16623
- query: (args) => {
16624
- return {
16625
- url: MEMORY_ENDPOINTS.GET_FILTERED_MEMORIES.path(args.tenantKey, args.username),
16626
- params: args.params,
16627
- service: MEMORY_ENDPOINTS.GET_FILTERED_MEMORIES.service,
16628
- };
16629
- },
16630
- providesTags: MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16637
+ // Memory Categories (Admin)
16638
+ getMemoryCategoriesAdmin: builder.query({
16639
+ query: (args) => ({
16640
+ url: MEMSEARCH_ENDPOINTS.GET_MEMSEARCH_CATEGORIES.path(args.org, args.mentorId),
16641
+ service: MEMSEARCH_ENDPOINTS.GET_MEMSEARCH_CATEGORIES.service,
16642
+ }),
16643
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16644
+ }),
16645
+ createMemoryCategory: builder.mutation({
16646
+ query: (args) => ({
16647
+ url: MEMSEARCH_ENDPOINTS.CREATE_MEMSEARCH_CATEGORY.path(args.org, args.mentorId),
16648
+ service: MEMSEARCH_ENDPOINTS.CREATE_MEMSEARCH_CATEGORY.service,
16649
+ method: 'POST',
16650
+ body: args.data,
16651
+ }),
16652
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16653
+ }),
16654
+ updateMemoryCategory: builder.mutation({
16655
+ query: (args) => ({
16656
+ url: MEMSEARCH_ENDPOINTS.UPDATE_MEMSEARCH_CATEGORY.path(args.org, args.mentorId, args.categoryId),
16657
+ service: MEMSEARCH_ENDPOINTS.UPDATE_MEMSEARCH_CATEGORY.service,
16658
+ method: 'PATCH',
16659
+ body: args.data,
16660
+ }),
16661
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16662
+ }),
16663
+ deleteMemoryCategory: builder.mutation({
16664
+ query: (args) => ({
16665
+ url: MEMSEARCH_ENDPOINTS.DELETE_MEMSEARCH_CATEGORY.path(args.org, args.mentorId, args.categoryId),
16666
+ service: MEMSEARCH_ENDPOINTS.DELETE_MEMSEARCH_CATEGORY.service,
16667
+ method: 'DELETE',
16668
+ }),
16669
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16670
+ }),
16671
+ // Platform Configuration
16672
+ getMemsearchConfig: builder.query({
16673
+ query: (args) => ({
16674
+ url: MEMSEARCH_ENDPOINTS.GET_MEMSEARCH_CONFIG.path(args.org, args.userId),
16675
+ service: MEMSEARCH_ENDPOINTS.GET_MEMSEARCH_CONFIG.service,
16676
+ }),
16677
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_PLATFORM_CONFIG(),
16678
+ }),
16679
+ updateMemsearchConfig: builder.mutation({
16680
+ query: (args) => ({
16681
+ url: MEMSEARCH_ENDPOINTS.UPDATE_MEMSEARCH_CONFIG.path(args.org, args.userId),
16682
+ service: MEMSEARCH_ENDPOINTS.UPDATE_MEMSEARCH_CONFIG.service,
16683
+ method: 'POST',
16684
+ body: args.config,
16685
+ }),
16686
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_PLATFORM_CONFIG(),
16631
16687
  }),
16632
16688
  }),
16633
16689
  });