@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.js CHANGED
@@ -3271,6 +3271,40 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3271
3271
  }
3272
3272
  return tenants;
3273
3273
  };
3274
+ /**
3275
+ * Joins a tenant, fetches fresh tokens and tenants, loads RBAC permissions,
3276
+ * and updates all relevant state. If the join fails, saves the tenant as a
3277
+ * visiting tenant instead.
3278
+ */
3279
+ const joinAndActivateTenant = async (tenantKey, tenantMetadata, newCurrentTenant, { handleVisitingTenant = true } = {}) => {
3280
+ var _a;
3281
+ try {
3282
+ await joinTenant({ platform_key: tenantKey }).unwrap();
3283
+ const formData = new FormData();
3284
+ formData.append("platform_key", tenantKey);
3285
+ const { data: newTenants } = await fetchUserTenants();
3286
+ const enhancedNewTenants = await enhanceTenants(newTenants, tenantMetadata);
3287
+ const { data: tokenResponse } = await getAppToken(formData).unwrap();
3288
+ saveUserTokens === null || saveUserTokens === void 0 ? void 0 : saveUserTokens(tokenResponse);
3289
+ saveCurrentTenant(newCurrentTenant);
3290
+ if (enhancedNewTenants && enhancedNewTenants.length) {
3291
+ saveUserTenants(enhancedNewTenants);
3292
+ }
3293
+ const rbacPermissions = await loadPlatformPermissions(tenantMetadata.platform_key);
3294
+ onLoadPlatformPermissions === null || onLoadPlatformPermissions === void 0 ? void 0 : onLoadPlatformPermissions(rbacPermissions);
3295
+ 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());
3296
+ saveTenant === null || saveTenant === void 0 ? void 0 : saveTenant(tenantKey);
3297
+ setUserIsAccessingPublicRoute(false);
3298
+ removeVisitingTenant === null || removeVisitingTenant === void 0 ? void 0 : removeVisitingTenant();
3299
+ return true;
3300
+ }
3301
+ catch (e) {
3302
+ if (handleVisitingTenant) {
3303
+ saveVisitingTenant === null || saveVisitingTenant === void 0 ? void 0 : saveVisitingTenant(newCurrentTenant);
3304
+ }
3305
+ return false;
3306
+ }
3307
+ };
3274
3308
  /**
3275
3309
  * Determines which tenant the user should access by:
3276
3310
  * 1. Fetching user's available tenants
@@ -3336,7 +3370,18 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3336
3370
  if (isWeb() && sessionStorage.getItem(guardKey)) {
3337
3371
  sessionStorage.removeItem(guardKey);
3338
3372
  console.warn(`[TenantProvider] User still does not belong to custom domain tenant after re-auth: ${customDomainPlatformKey}`);
3339
- onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${customDomainPlatformKey}). Please contact your administrator.`);
3373
+ const joined = await joinAndActivateTenant(customDomainPlatformKey, {
3374
+ platform_key: customDomainPlatformKey,
3375
+ platform_name: customDomainPlatformKey,
3376
+ }, {
3377
+ key: customDomainPlatformKey,
3378
+ is_admin: false,
3379
+ org: customDomainPlatformKey,
3380
+ platform_name: customDomainPlatformKey,
3381
+ }, { handleVisitingTenant: false });
3382
+ if (!joined) {
3383
+ onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${customDomainPlatformKey}). Please contact your administrator.`);
3384
+ }
3340
3385
  return;
3341
3386
  }
3342
3387
  if (isWeb()) {
@@ -3427,7 +3472,7 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3427
3472
  }
3428
3473
  }
3429
3474
  async function handleLoadTenantMetadata(tenantKey) {
3430
- var _a, _b, _c;
3475
+ var _a, _b;
3431
3476
  setIsLoading(true);
3432
3477
  const MAIN_TENANT_KEY = "main";
3433
3478
  try {
@@ -3482,41 +3527,7 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3482
3527
  setIsLoading(false);
3483
3528
  return;
3484
3529
  }
3485
- try {
3486
- await joinTenant({
3487
- platform_key: tenantKey,
3488
- }).unwrap();
3489
- try {
3490
- // succesfully joined tenant at this point
3491
- // we want to fetch tokens for this new tenant
3492
- const formData = new FormData();
3493
- formData.append("platform_key", tenantKey);
3494
- const { data: newTenants } = await fetchUserTenants();
3495
- const enhancedNewTenants = await enhanceTenants(newTenants, data);
3496
- const { data: tokenResponse } = await getAppToken(formData).unwrap();
3497
- saveUserTokens === null || saveUserTokens === void 0 ? void 0 : saveUserTokens(tokenResponse);
3498
- saveCurrentTenant(newCurrentTenant);
3499
- if (enhancedNewTenants && enhancedNewTenants.length) {
3500
- saveUserTenants(enhancedNewTenants);
3501
- }
3502
- else {
3503
- // TODO: What happense when if for any reason we fetch tenants and it's an empty list
3504
- }
3505
- const rbacPermissions = await loadPlatformPermissions(data.platform_key);
3506
- onLoadPlatformPermissions === null || onLoadPlatformPermissions === void 0 ? void 0 : onLoadPlatformPermissions(rbacPermissions);
3507
- 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());
3508
- saveTenant === null || saveTenant === void 0 ? void 0 : saveTenant(tenantKey);
3509
- setUserIsAccessingPublicRoute(false);
3510
- removeVisitingTenant === null || removeVisitingTenant === void 0 ? void 0 : removeVisitingTenant();
3511
- }
3512
- catch (e) {
3513
- throw e;
3514
- }
3515
- }
3516
- catch (e) {
3517
- // failed to join the visiting tenant so save the visiting tenant
3518
- saveVisitingTenant === null || saveVisitingTenant === void 0 ? void 0 : saveVisitingTenant(newCurrentTenant);
3519
- }
3530
+ await joinAndActivateTenant(tenantKey, data, newCurrentTenant);
3520
3531
  }
3521
3532
  else {
3522
3533
  if (!currentTenant) {
@@ -16479,175 +16490,220 @@ createApi({
16479
16490
  });
16480
16491
 
16481
16492
  const MEMORY_REDUCER_PATH = 'memoryApiSlice';
16482
- const MEMORY_ENDPOINTS = {
16483
- GET_MEMORIES: {
16493
+ const MEMORY_QUERY_KEYS = {
16494
+ MEMSEARCH_USER_SETTINGS: () => ['MEMSEARCH_USER_SETTINGS'],
16495
+ MEMSEARCH_GLOBAL_MEMORIES: () => ['MEMSEARCH_GLOBAL_MEMORIES'],
16496
+ MEMSEARCH_MENTOR_MEMORIES: () => ['MEMSEARCH_MENTOR_MEMORIES'],
16497
+ MEMSEARCH_MEMORY_CATEGORIES: () => ['MEMSEARCH_MEMORY_CATEGORIES'],
16498
+ MEMSEARCH_PLATFORM_CONFIG: () => ['MEMSEARCH_PLATFORM_CONFIG'],
16499
+ };
16500
+ const MEMSEARCH_ENDPOINTS = {
16501
+ // User Memory Settings
16502
+ GET_USER_SETTINGS: {
16484
16503
  service: SERVICES.AXD,
16485
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memories/`,
16504
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/memsearch-settings/`,
16486
16505
  },
16487
- GET_MEMORY_CATEGORIES: {
16506
+ UPDATE_USER_SETTINGS: {
16488
16507
  service: SERVICES.AXD,
16489
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-categories/`,
16508
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/memsearch-settings/`,
16490
16509
  },
16491
- GET_MENTOR_USER_SETTINGS: {
16510
+ // Global Memories
16511
+ GET_GLOBAL_MEMORIES: {
16492
16512
  service: SERVICES.AXD,
16493
- path: (tenantKey, username, mentorId) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/mentors/${mentorId}/mentor-user-settings/`,
16513
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/global-memories/`,
16494
16514
  },
16495
- UPDATE_MENTOR_USER_SETTINGS: {
16515
+ CREATE_GLOBAL_MEMORY: {
16496
16516
  service: SERVICES.AXD,
16497
- path: (tenantKey, username, mentorId) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/mentors/${mentorId}/mentor-user-settings/`,
16517
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/global-memories/`,
16498
16518
  },
16499
- DELETE_MEMORY: {
16519
+ DELETE_GLOBAL_MEMORY: {
16500
16520
  service: SERVICES.AXD,
16501
- path: (tenantKey, username, memoryId) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-entries/${memoryId}/`,
16521
+ path: (org, userId, memoryId) => `/api/ai-mentor/orgs/${org}/users/${userId}/global-memories/${memoryId}/`,
16502
16522
  },
16503
- DELETE_MEMORY_BY_CATEGORY: {
16523
+ // Mentor-Specific Memories
16524
+ GET_MENTOR_MEMORIES: {
16504
16525
  service: SERVICES.AXD,
16505
- path: (tenantKey, username, category) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-entries/${category}/`,
16526
+ path: (org, userId, mentorId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories/`,
16506
16527
  },
16507
- UPDATE_MEMORY_ENTRY: {
16528
+ CREATE_MENTOR_MEMORY: {
16508
16529
  service: SERVICES.AXD,
16509
- path: (tenantKey, username, entryId) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-entries/${entryId}/`,
16530
+ path: (org, userId, mentorId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories/`,
16510
16531
  },
16511
- CREATE_MEMORY: {
16532
+ UPDATE_MENTOR_MEMORY: {
16512
16533
  service: SERVICES.AXD,
16513
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memories/`,
16534
+ path: (org, userId, mentorId, memoryId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories/${memoryId}/`,
16514
16535
  },
16515
- GET_MEMORY_FILTERS: {
16536
+ DELETE_MENTOR_MEMORY: {
16516
16537
  service: SERVICES.AXD,
16517
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/memory-filter/`,
16538
+ path: (org, userId, mentorId, memoryId) => `/api/ai-mentor/orgs/${org}/users/${userId}/mentors/${mentorId}/mentor-memories/${memoryId}/`,
16518
16539
  },
16519
- GET_FILTERED_MEMORIES: {
16540
+ // Memory Categories (Admin)
16541
+ GET_MEMSEARCH_CATEGORIES: {
16520
16542
  service: SERVICES.AXD,
16521
- path: (tenantKey, username) => `/api/ai-mentor/orgs/${tenantKey}/users/${username}/filtered-memories/`,
16543
+ path: (org, mentorId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorId}/memory-categories/`,
16544
+ },
16545
+ CREATE_MEMSEARCH_CATEGORY: {
16546
+ service: SERVICES.AXD,
16547
+ path: (org, mentorId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorId}/memory-categories/`,
16548
+ },
16549
+ UPDATE_MEMSEARCH_CATEGORY: {
16550
+ service: SERVICES.AXD,
16551
+ path: (org, mentorId, categoryId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorId}/memory-categories/${categoryId}/`,
16552
+ },
16553
+ DELETE_MEMSEARCH_CATEGORY: {
16554
+ service: SERVICES.AXD,
16555
+ path: (org, mentorId, categoryId) => `/api/ai-mentor/orgs/${org}/mentors/${mentorId}/memory-categories/${categoryId}/`,
16556
+ },
16557
+ // Platform Configuration
16558
+ GET_MEMSEARCH_CONFIG: {
16559
+ service: SERVICES.AXD,
16560
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/memsearch-config/`,
16561
+ },
16562
+ UPDATE_MEMSEARCH_CONFIG: {
16563
+ service: SERVICES.AXD,
16564
+ path: (org, userId) => `/api/ai-mentor/orgs/${org}/users/${userId}/memsearch-config/`,
16522
16565
  },
16523
- };
16524
- const MEMORY_QUERY_KEYS = {
16525
- GET_MEMORIES: () => ['MEMORIES'],
16526
- GET_MEMORY_CATEGORIES: () => ['MEMORY_CATEGORIES'],
16527
- GET_MENTOR_USER_SETTINGS: () => ['MENTOR_USER_SETTINGS'],
16528
- GET_FILTERED_MEMORIES: () => ['FILTERED_MEMORIES'],
16529
16566
  };
16530
16567
 
16531
16568
  createApi({
16532
16569
  reducerPath: MEMORY_REDUCER_PATH,
16533
16570
  tagTypes: [
16534
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16535
- ...MEMORY_QUERY_KEYS.GET_MEMORY_CATEGORIES(),
16536
- ...MEMORY_QUERY_KEYS.GET_MENTOR_USER_SETTINGS(),
16537
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16571
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_USER_SETTINGS(),
16572
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_GLOBAL_MEMORIES(),
16573
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16574
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16575
+ ...MEMORY_QUERY_KEYS.MEMSEARCH_PLATFORM_CONFIG(),
16538
16576
  ],
16539
16577
  baseQuery: iblFetchBaseQuery,
16540
16578
  endpoints: (builder) => ({
16541
- getMemories: builder.query({
16542
- query: (args) => {
16543
- return {
16544
- url: MEMORY_ENDPOINTS.GET_MEMORIES.path(args.tenantKey, args.username),
16545
- params: args.params,
16546
- service: MEMORY_ENDPOINTS.GET_MEMORIES.service,
16547
- };
16548
- },
16549
- providesTags: MEMORY_QUERY_KEYS.GET_MEMORIES(),
16579
+ // User Memory Settings
16580
+ getUserMemorySettings: builder.query({
16581
+ query: (args) => ({
16582
+ url: MEMSEARCH_ENDPOINTS.GET_USER_SETTINGS.path(args.org, args.userId),
16583
+ service: MEMSEARCH_ENDPOINTS.GET_USER_SETTINGS.service,
16584
+ }),
16585
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_USER_SETTINGS(),
16550
16586
  }),
16551
- getMemoryCategories: builder.query({
16552
- query: (args) => {
16553
- return {
16554
- url: MEMORY_ENDPOINTS.GET_MEMORY_CATEGORIES.path(args.tenantKey, args.username),
16555
- service: MEMORY_ENDPOINTS.GET_MEMORY_CATEGORIES.service,
16556
- };
16557
- },
16558
- providesTags: MEMORY_QUERY_KEYS.GET_MEMORY_CATEGORIES(),
16587
+ updateUserMemorySettings: builder.mutation({
16588
+ query: (args) => ({
16589
+ url: MEMSEARCH_ENDPOINTS.UPDATE_USER_SETTINGS.path(args.org, args.userId),
16590
+ service: MEMSEARCH_ENDPOINTS.UPDATE_USER_SETTINGS.service,
16591
+ method: 'PUT',
16592
+ body: args.settings,
16593
+ }),
16594
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_USER_SETTINGS(),
16559
16595
  }),
16560
- getMentorUserSettings: builder.query({
16561
- query: (args) => {
16562
- return {
16563
- url: MEMORY_ENDPOINTS.GET_MENTOR_USER_SETTINGS.path(args.tenantKey, args.username, args.mentorId),
16564
- service: MEMORY_ENDPOINTS.GET_MENTOR_USER_SETTINGS.service,
16565
- };
16566
- },
16567
- providesTags: MEMORY_QUERY_KEYS.GET_MENTOR_USER_SETTINGS(),
16596
+ // Global Memories
16597
+ getGlobalMemories: builder.query({
16598
+ query: (args) => ({
16599
+ url: MEMSEARCH_ENDPOINTS.GET_GLOBAL_MEMORIES.path(args.org, args.userId),
16600
+ service: MEMSEARCH_ENDPOINTS.GET_GLOBAL_MEMORIES.service,
16601
+ params: args.params,
16602
+ }),
16603
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_GLOBAL_MEMORIES(),
16568
16604
  }),
16569
- updateMentorUserSettings: builder.mutation({
16570
- query: (args) => {
16571
- return {
16572
- url: MEMORY_ENDPOINTS.UPDATE_MENTOR_USER_SETTINGS.path(args.tenantKey, args.username, args.mentorId),
16573
- method: 'POST',
16574
- body: args.settings,
16575
- service: MEMORY_ENDPOINTS.UPDATE_MENTOR_USER_SETTINGS.service,
16576
- };
16577
- },
16578
- invalidatesTags: MEMORY_QUERY_KEYS.GET_MENTOR_USER_SETTINGS(),
16605
+ createGlobalMemory: builder.mutation({
16606
+ query: (args) => ({
16607
+ url: MEMSEARCH_ENDPOINTS.CREATE_GLOBAL_MEMORY.path(args.org, args.userId),
16608
+ service: MEMSEARCH_ENDPOINTS.CREATE_GLOBAL_MEMORY.service,
16609
+ method: 'POST',
16610
+ body: { content: args.content },
16611
+ }),
16612
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_GLOBAL_MEMORIES(),
16579
16613
  }),
16580
- deleteMemory: builder.mutation({
16581
- query: (args) => {
16582
- return {
16583
- url: MEMORY_ENDPOINTS.DELETE_MEMORY.path(args.tenantKey, args.username, args.memoryId),
16584
- method: 'DELETE',
16585
- service: MEMORY_ENDPOINTS.DELETE_MEMORY.service,
16586
- };
16587
- },
16588
- invalidatesTags: [
16589
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16590
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16591
- ],
16614
+ deleteGlobalMemory: builder.mutation({
16615
+ query: (args) => ({
16616
+ url: MEMSEARCH_ENDPOINTS.DELETE_GLOBAL_MEMORY.path(args.org, args.userId, args.memoryId),
16617
+ service: MEMSEARCH_ENDPOINTS.DELETE_GLOBAL_MEMORY.service,
16618
+ method: 'DELETE',
16619
+ }),
16620
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_GLOBAL_MEMORIES(),
16592
16621
  }),
16593
- deleteMemoryByCategory: builder.mutation({
16594
- query: (args) => {
16595
- return {
16596
- url: MEMORY_ENDPOINTS.DELETE_MEMORY_BY_CATEGORY.path(args.tenantKey, args.username, args.category),
16597
- method: 'DELETE',
16598
- service: MEMORY_ENDPOINTS.DELETE_MEMORY_BY_CATEGORY.service,
16599
- };
16600
- },
16601
- invalidatesTags: [
16602
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16603
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16604
- ],
16622
+ // Mentor-Specific Memories
16623
+ getMentorMemories: builder.query({
16624
+ query: (args) => ({
16625
+ url: MEMSEARCH_ENDPOINTS.GET_MENTOR_MEMORIES.path(args.org, args.userId, args.mentorId),
16626
+ service: MEMSEARCH_ENDPOINTS.GET_MENTOR_MEMORIES.service,
16627
+ params: args.params,
16628
+ }),
16629
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16605
16630
  }),
16606
- updateMemoryEntry: builder.mutation({
16607
- query: (args) => {
16608
- return {
16609
- url: MEMORY_ENDPOINTS.UPDATE_MEMORY_ENTRY.path(args.tenantKey, args.username, args.entryId),
16610
- method: 'POST',
16611
- body: args.data,
16612
- service: MEMORY_ENDPOINTS.UPDATE_MEMORY_ENTRY.service,
16613
- };
16614
- },
16615
- invalidatesTags: [
16616
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16617
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16618
- ],
16631
+ createMentorMemory: builder.mutation({
16632
+ query: (args) => ({
16633
+ url: MEMSEARCH_ENDPOINTS.CREATE_MENTOR_MEMORY.path(args.org, args.userId, args.mentorId),
16634
+ service: MEMSEARCH_ENDPOINTS.CREATE_MENTOR_MEMORY.service,
16635
+ method: 'POST',
16636
+ body: args.data,
16637
+ }),
16638
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16619
16639
  }),
16620
- createMemory: builder.mutation({
16621
- query: (args) => {
16622
- return {
16623
- url: MEMORY_ENDPOINTS.CREATE_MEMORY.path(args.tenantKey, args.username),
16624
- method: 'POST',
16625
- body: args.data,
16626
- service: MEMORY_ENDPOINTS.CREATE_MEMORY.service,
16627
- };
16628
- },
16629
- invalidatesTags: [
16630
- ...MEMORY_QUERY_KEYS.GET_MEMORIES(),
16631
- ...MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16632
- ],
16640
+ updateMentorMemory: builder.mutation({
16641
+ query: (args) => ({
16642
+ url: MEMSEARCH_ENDPOINTS.UPDATE_MENTOR_MEMORY.path(args.org, args.userId, args.mentorId, args.memoryId),
16643
+ service: MEMSEARCH_ENDPOINTS.UPDATE_MENTOR_MEMORY.service,
16644
+ method: 'PATCH',
16645
+ body: args.data,
16646
+ }),
16647
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16633
16648
  }),
16634
- getMemoryFilters: builder.query({
16635
- query: (args) => {
16636
- return {
16637
- url: MEMORY_ENDPOINTS.GET_MEMORY_FILTERS.path(args.tenantKey, args.username),
16638
- service: MEMORY_ENDPOINTS.GET_MEMORY_FILTERS.service,
16639
- };
16640
- },
16649
+ deleteMentorMemory: builder.mutation({
16650
+ query: (args) => ({
16651
+ url: MEMSEARCH_ENDPOINTS.DELETE_MENTOR_MEMORY.path(args.org, args.userId, args.mentorId, args.memoryId),
16652
+ service: MEMSEARCH_ENDPOINTS.DELETE_MENTOR_MEMORY.service,
16653
+ method: 'DELETE',
16654
+ }),
16655
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MENTOR_MEMORIES(),
16641
16656
  }),
16642
- getFilteredMemories: builder.query({
16643
- query: (args) => {
16644
- return {
16645
- url: MEMORY_ENDPOINTS.GET_FILTERED_MEMORIES.path(args.tenantKey, args.username),
16646
- params: args.params,
16647
- service: MEMORY_ENDPOINTS.GET_FILTERED_MEMORIES.service,
16648
- };
16649
- },
16650
- providesTags: MEMORY_QUERY_KEYS.GET_FILTERED_MEMORIES(),
16657
+ // Memory Categories (Admin)
16658
+ getMemoryCategoriesAdmin: builder.query({
16659
+ query: (args) => ({
16660
+ url: MEMSEARCH_ENDPOINTS.GET_MEMSEARCH_CATEGORIES.path(args.org, args.mentorId),
16661
+ service: MEMSEARCH_ENDPOINTS.GET_MEMSEARCH_CATEGORIES.service,
16662
+ }),
16663
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16664
+ }),
16665
+ createMemoryCategory: builder.mutation({
16666
+ query: (args) => ({
16667
+ url: MEMSEARCH_ENDPOINTS.CREATE_MEMSEARCH_CATEGORY.path(args.org, args.mentorId),
16668
+ service: MEMSEARCH_ENDPOINTS.CREATE_MEMSEARCH_CATEGORY.service,
16669
+ method: 'POST',
16670
+ body: args.data,
16671
+ }),
16672
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16673
+ }),
16674
+ updateMemoryCategory: builder.mutation({
16675
+ query: (args) => ({
16676
+ url: MEMSEARCH_ENDPOINTS.UPDATE_MEMSEARCH_CATEGORY.path(args.org, args.mentorId, args.categoryId),
16677
+ service: MEMSEARCH_ENDPOINTS.UPDATE_MEMSEARCH_CATEGORY.service,
16678
+ method: 'PATCH',
16679
+ body: args.data,
16680
+ }),
16681
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16682
+ }),
16683
+ deleteMemoryCategory: builder.mutation({
16684
+ query: (args) => ({
16685
+ url: MEMSEARCH_ENDPOINTS.DELETE_MEMSEARCH_CATEGORY.path(args.org, args.mentorId, args.categoryId),
16686
+ service: MEMSEARCH_ENDPOINTS.DELETE_MEMSEARCH_CATEGORY.service,
16687
+ method: 'DELETE',
16688
+ }),
16689
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_MEMORY_CATEGORIES(),
16690
+ }),
16691
+ // Platform Configuration
16692
+ getMemsearchConfig: builder.query({
16693
+ query: (args) => ({
16694
+ url: MEMSEARCH_ENDPOINTS.GET_MEMSEARCH_CONFIG.path(args.org, args.userId),
16695
+ service: MEMSEARCH_ENDPOINTS.GET_MEMSEARCH_CONFIG.service,
16696
+ }),
16697
+ providesTags: MEMORY_QUERY_KEYS.MEMSEARCH_PLATFORM_CONFIG(),
16698
+ }),
16699
+ updateMemsearchConfig: builder.mutation({
16700
+ query: (args) => ({
16701
+ url: MEMSEARCH_ENDPOINTS.UPDATE_MEMSEARCH_CONFIG.path(args.org, args.userId),
16702
+ service: MEMSEARCH_ENDPOINTS.UPDATE_MEMSEARCH_CONFIG.service,
16703
+ method: 'POST',
16704
+ body: args.config,
16705
+ }),
16706
+ invalidatesTags: MEMORY_QUERY_KEYS.MEMSEARCH_PLATFORM_CONFIG(),
16651
16707
  }),
16652
16708
  }),
16653
16709
  });