@iblai/data-layer 1.40.0 → 1.42.0
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.d.ts +722 -2
- package/dist/index.esm.js +124 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +139 -0
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/features/mentor/__tests__/privacy.test.d.ts +1 -0
- package/dist/src/features/mentor/privacy.d.ts +9 -0
- package/dist/src/features/privacy-flags/__tests__/api-slice.test.d.ts +1 -0
- package/dist/src/features/privacy-flags/api-slice.d.ts +614 -0
- package/dist/src/features/privacy-flags/constants.d.ts +22 -0
- package/dist/src/features/privacy-flags/index.d.ts +3 -0
- package/dist/src/features/privacy-flags/types.d.ts +72 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45711,6 +45711,110 @@ const moderationLogsApiSlice = react.createApi({
|
|
|
45711
45711
|
const moderationLogsApiReducer = moderationLogsApiSlice.reducer;
|
|
45712
45712
|
const { useGetModerationLogsQuery, useLazyGetModerationLogsQuery, useDeleteModerationLogMutation, } = moderationLogsApiSlice;
|
|
45713
45713
|
|
|
45714
|
+
const PRIVACY_FLAGS_REDUCER_PATH = 'privacyFlagsApiSlice';
|
|
45715
|
+
const PRIVACY_FLAGS_QUERY_KEYS = {
|
|
45716
|
+
PRIVACY_FLAGS: 'PRIVACY_FLAGS',
|
|
45717
|
+
PRIVACY_FLAG: 'PRIVACY_FLAG',
|
|
45718
|
+
};
|
|
45719
|
+
/** Guardrail that produced the detection. */
|
|
45720
|
+
const PRIVACY_FLAG_RAILS = ['pii', 'phi'];
|
|
45721
|
+
/** What the privacy router did with the detected content. */
|
|
45722
|
+
const PRIVACY_FLAG_ACTIONS = ['redact', 'mask', 'block', 'allow'];
|
|
45723
|
+
/** Where in the pipeline the detection happened. `file_*` sources carry file metadata. */
|
|
45724
|
+
const PRIVACY_FLAG_SOURCES = [
|
|
45725
|
+
'text_prompt',
|
|
45726
|
+
'file_text',
|
|
45727
|
+
'file_image',
|
|
45728
|
+
'file_pdf',
|
|
45729
|
+
'llm_response',
|
|
45730
|
+
'memory_retrieval',
|
|
45731
|
+
];
|
|
45732
|
+
const encode = (value) => encodeURIComponent(String(value));
|
|
45733
|
+
const PRIVACY_FLAGS_ENDPOINTS = {
|
|
45734
|
+
LIST: {
|
|
45735
|
+
service: exports.SERVICES.DM,
|
|
45736
|
+
path: (org, userId) => `/api/ai-mentor/orgs/${encode(org)}/users/${encode(userId)}/privacy-flags/`,
|
|
45737
|
+
},
|
|
45738
|
+
RETRIEVE: {
|
|
45739
|
+
service: exports.SERVICES.DM,
|
|
45740
|
+
path: (org, userId, id) => `/api/ai-mentor/orgs/${encode(org)}/users/${encode(userId)}/privacy-flags/${encode(id)}/`,
|
|
45741
|
+
},
|
|
45742
|
+
};
|
|
45743
|
+
|
|
45744
|
+
/** Filter arg -> backend query key. */
|
|
45745
|
+
const QUERY_KEYS = {
|
|
45746
|
+
mentor: 'mentor',
|
|
45747
|
+
rail: 'rail',
|
|
45748
|
+
actionTaken: 'action_taken',
|
|
45749
|
+
source: 'source',
|
|
45750
|
+
sessionId: 'session_id',
|
|
45751
|
+
username: 'username',
|
|
45752
|
+
startTime: 'start_time',
|
|
45753
|
+
endTime: 'end_time',
|
|
45754
|
+
search: 'search',
|
|
45755
|
+
ordering: 'ordering',
|
|
45756
|
+
page: 'page',
|
|
45757
|
+
pageSize: 'page_size',
|
|
45758
|
+
};
|
|
45759
|
+
/** Builds the list query string, dropping empty filters. */
|
|
45760
|
+
const buildPrivacyFlagsQuery = (args) => {
|
|
45761
|
+
const params = new URLSearchParams();
|
|
45762
|
+
for (const [argKey, queryKey] of Object.entries(QUERY_KEYS)) {
|
|
45763
|
+
const value = args[argKey];
|
|
45764
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
45765
|
+
params.append(queryKey, String(value));
|
|
45766
|
+
}
|
|
45767
|
+
}
|
|
45768
|
+
const query = params.toString();
|
|
45769
|
+
return query ? `?${query}` : '';
|
|
45770
|
+
};
|
|
45771
|
+
/**
|
|
45772
|
+
* GETs a DM path with the app's DM auth. Throws `{ status, body }` on non-2xx
|
|
45773
|
+
* so `buildEndpointFromService` keeps the HTTP status (403 stays detectable
|
|
45774
|
+
* and is never retried).
|
|
45775
|
+
*/
|
|
45776
|
+
const fetchDmJson = async (path) => {
|
|
45777
|
+
const service = PRIVACY_FLAGS_ENDPOINTS.LIST.service;
|
|
45778
|
+
const headers = await getHeaders(service);
|
|
45779
|
+
const response = await fetch(`${getServiceUrl(service)}${path}`, {
|
|
45780
|
+
method: 'GET',
|
|
45781
|
+
headers: { Accept: 'application/json', ...(headers !== null && headers !== void 0 ? headers : {}) },
|
|
45782
|
+
credentials: 'omit',
|
|
45783
|
+
});
|
|
45784
|
+
const text = await response.text();
|
|
45785
|
+
let body = text;
|
|
45786
|
+
try {
|
|
45787
|
+
body = text ? JSON.parse(text) : null;
|
|
45788
|
+
}
|
|
45789
|
+
catch (_a) {
|
|
45790
|
+
// Non-JSON body (e.g. an HTML error page) — keep the raw text.
|
|
45791
|
+
}
|
|
45792
|
+
if (!response.ok) {
|
|
45793
|
+
throw { status: response.status, body };
|
|
45794
|
+
}
|
|
45795
|
+
return body;
|
|
45796
|
+
};
|
|
45797
|
+
const fetchPrivacyFlags = (args) => fetchDmJson(`${PRIVACY_FLAGS_ENDPOINTS.LIST.path(args.org, args.userId)}${buildPrivacyFlagsQuery(args)}`);
|
|
45798
|
+
const fetchPrivacyFlag = (args) => fetchDmJson(PRIVACY_FLAGS_ENDPOINTS.RETRIEVE.path(args.org, args.userId, args.id));
|
|
45799
|
+
const privacyFlagsApiSlice = react.createApi({
|
|
45800
|
+
reducerPath: PRIVACY_FLAGS_REDUCER_PATH,
|
|
45801
|
+
baseQuery: iblFakeBaseQuery,
|
|
45802
|
+
tagTypes: [PRIVACY_FLAGS_QUERY_KEYS.PRIVACY_FLAGS, PRIVACY_FLAGS_QUERY_KEYS.PRIVACY_FLAG],
|
|
45803
|
+
endpoints: (builder) => ({
|
|
45804
|
+
getPrivacyFlags: builder.query({
|
|
45805
|
+
...buildEndpointFromService(PRIVACY_FLAGS_ENDPOINTS.LIST.service, fetchPrivacyFlags),
|
|
45806
|
+
providesTags: [PRIVACY_FLAGS_QUERY_KEYS.PRIVACY_FLAGS],
|
|
45807
|
+
}),
|
|
45808
|
+
getPrivacyFlag: builder.query({
|
|
45809
|
+
...buildEndpointFromService(PRIVACY_FLAGS_ENDPOINTS.RETRIEVE.service, fetchPrivacyFlag),
|
|
45810
|
+
providesTags: (_result, _error, args) => [
|
|
45811
|
+
{ type: PRIVACY_FLAGS_QUERY_KEYS.PRIVACY_FLAG, id: args.id },
|
|
45812
|
+
],
|
|
45813
|
+
}),
|
|
45814
|
+
}),
|
|
45815
|
+
});
|
|
45816
|
+
const { useGetPrivacyFlagsQuery, useLazyGetPrivacyFlagsQuery, useGetPrivacyFlagQuery, useLazyGetPrivacyFlagQuery, } = privacyFlagsApiSlice;
|
|
45817
|
+
|
|
45714
45818
|
/**
|
|
45715
45819
|
* Privacy Router types and constants.
|
|
45716
45820
|
*
|
|
@@ -45755,6 +45859,23 @@ const SUGGESTED_PRIVACY_ENTITIES = [
|
|
|
45755
45859
|
];
|
|
45756
45860
|
const DEFAULT_PRIVACY_RESPONSE = 'Your message contains sensitive personal information and cannot be processed. Please remove any personal data and try again.';
|
|
45757
45861
|
const DEFAULT_PRIVACY_ACTION = 'redact';
|
|
45862
|
+
// Hardcoded until the settings API schema exposes the PHI entities as an enum.
|
|
45863
|
+
// The backend rejects any other name, so this list must match it exactly.
|
|
45864
|
+
const PHI_ENTITY_TYPES = [
|
|
45865
|
+
'DISEASE_DISORDER',
|
|
45866
|
+
'MEDICATION',
|
|
45867
|
+
'THERAPEUTIC_PROCEDURE',
|
|
45868
|
+
'BIOLOGICAL_STRUCTURE',
|
|
45869
|
+
'CLINICAL_EVENT',
|
|
45870
|
+
'BIOLOGICAL_ATTRIBUTE',
|
|
45871
|
+
'HISTORY',
|
|
45872
|
+
'FAMILY_HISTORY',
|
|
45873
|
+
'MEDICAL_RECORD_NUMBER',
|
|
45874
|
+
'HEALTH_PLAN_BENEFICIARY_NUMBER',
|
|
45875
|
+
'ACCOUNT_NUMBER',
|
|
45876
|
+
'DEVICE_SERIAL_NUMBER',
|
|
45877
|
+
];
|
|
45878
|
+
const DEFAULT_PHI_ACTION = 'allow';
|
|
45758
45879
|
/**
|
|
45759
45880
|
* `kind` value the backend returns on chat WS / SSE messages when a request
|
|
45760
45881
|
* is rejected by the privacy router (action = "block"). Sits alongside the
|
|
@@ -50606,6 +50727,7 @@ const mentorReducer = {
|
|
|
50606
50727
|
[billingCustomSlice.reducerPath]: billingCustomSlice.reducer,
|
|
50607
50728
|
[retirementApiSlice.reducerPath]: retirementApiSlice.reducer,
|
|
50608
50729
|
[auditLogsApiSlice.reducerPath]: auditLogsApiSlice.reducer,
|
|
50730
|
+
[privacyFlagsApiSlice.reducerPath]: privacyFlagsApiSlice.reducer,
|
|
50609
50731
|
[monetizationApiSlice.reducerPath]: monetizationApiSlice.reducer,
|
|
50610
50732
|
[coursesApiSlice.reducerPath]: coursesApiSlice.reducer,
|
|
50611
50733
|
[courseMetadataApiSlice.reducerPath]: courseMetadataApiSlice.reducer,
|
|
@@ -50673,6 +50795,7 @@ const mentorMiddleware = [
|
|
|
50673
50795
|
billingCustomSlice.middleware,
|
|
50674
50796
|
retirementApiSlice.middleware,
|
|
50675
50797
|
auditLogsApiSlice.middleware,
|
|
50798
|
+
privacyFlagsApiSlice.middleware,
|
|
50676
50799
|
monetizationApiSlice.middleware,
|
|
50677
50800
|
coursesApiSlice.middleware,
|
|
50678
50801
|
courseMetadataApiSlice.middleware,
|
|
@@ -50841,6 +50964,7 @@ exports.CUSTOM_DOMAIN_ENDPOINTS = CUSTOM_DOMAIN_ENDPOINTS;
|
|
|
50841
50964
|
exports.CUSTOM_DOMAIN_QUERY_KEYS = CUSTOM_DOMAIN_QUERY_KEYS;
|
|
50842
50965
|
exports.CUSTOM_DOMAIN_REDUCER_PATH = CUSTOM_DOMAIN_REDUCER_PATH;
|
|
50843
50966
|
exports.ChatPrivacyModeEnum = ChatPrivacyModeEnum;
|
|
50967
|
+
exports.DEFAULT_PHI_ACTION = DEFAULT_PHI_ACTION;
|
|
50844
50968
|
exports.DEFAULT_PRIVACY_ACTION = DEFAULT_PRIVACY_ACTION;
|
|
50845
50969
|
exports.DEFAULT_PRIVACY_RESPONSE = DEFAULT_PRIVACY_RESPONSE;
|
|
50846
50970
|
exports.DISCLAIMERS_ENDPOINTS = DISCLAIMERS_ENDPOINTS;
|
|
@@ -50878,6 +51002,7 @@ exports.NEVER_RETRY_STATUSES = NEVER_RETRY_STATUSES;
|
|
|
50878
51002
|
exports.NOTIFICATIONS_CUSTOM_ENDPOINTS = NOTIFICATIONS_CUSTOM_ENDPOINTS;
|
|
50879
51003
|
exports.NOTIFICATIONS_CUSTOM_REDUCER_PATH = NOTIFICATIONS_CUSTOM_REDUCER_PATH;
|
|
50880
51004
|
exports.NOTIFICATIONS_CUSTOM_TAGS = NOTIFICATIONS_CUSTOM_TAGS;
|
|
51005
|
+
exports.PHI_ENTITY_TYPES = PHI_ENTITY_TYPES;
|
|
50881
51006
|
exports.PLATFORM_AUDIT_ACTION_CODES = PLATFORM_AUDIT_ACTION_CODES;
|
|
50882
51007
|
exports.PLATFORM_AUDIT_EVENT_TYPES = PLATFORM_AUDIT_EVENT_TYPES;
|
|
50883
51008
|
exports.PLATFORM_AUDIT_LOGS_MAX_LIMIT = PLATFORM_AUDIT_LOGS_MAX_LIMIT;
|
|
@@ -50888,6 +51013,12 @@ exports.PLATFORM_MEMBERSHIP_TAG = PLATFORM_MEMBERSHIP_TAG;
|
|
|
50888
51013
|
exports.PRIVACY_ACTIONS = PRIVACY_ACTIONS;
|
|
50889
51014
|
exports.PRIVACY_BLOCKED_ERROR_KIND = PRIVACY_BLOCKED_ERROR_KIND;
|
|
50890
51015
|
exports.PRIVACY_ENTITY_TYPES = PRIVACY_ENTITY_TYPES;
|
|
51016
|
+
exports.PRIVACY_FLAGS_ENDPOINTS = PRIVACY_FLAGS_ENDPOINTS;
|
|
51017
|
+
exports.PRIVACY_FLAGS_QUERY_KEYS = PRIVACY_FLAGS_QUERY_KEYS;
|
|
51018
|
+
exports.PRIVACY_FLAGS_REDUCER_PATH = PRIVACY_FLAGS_REDUCER_PATH;
|
|
51019
|
+
exports.PRIVACY_FLAG_ACTIONS = PRIVACY_FLAG_ACTIONS;
|
|
51020
|
+
exports.PRIVACY_FLAG_RAILS = PRIVACY_FLAG_RAILS;
|
|
51021
|
+
exports.PRIVACY_FLAG_SOURCES = PRIVACY_FLAG_SOURCES;
|
|
50891
51022
|
exports.PRIVACY_TARGET_SYSTEM = PRIVACY_TARGET_SYSTEM;
|
|
50892
51023
|
exports.PROJECTS_CUSTOM_ENDPOINTS = PROJECTS_CUSTOM_ENDPOINTS;
|
|
50893
51024
|
exports.PROJECTS_CUSTOM_REDUCER_PATH = PROJECTS_CUSTOM_REDUCER_PATH;
|
|
@@ -50963,6 +51094,7 @@ exports.billingCustomSlice = billingCustomSlice;
|
|
|
50963
51094
|
exports.buildGlobalSearchUrl = buildGlobalSearchUrl;
|
|
50964
51095
|
exports.buildLearnerCompletionUrl = buildLearnerCompletionUrl;
|
|
50965
51096
|
exports.buildPinnedMessagesUrl = buildPinnedMessagesUrl;
|
|
51097
|
+
exports.buildPrivacyFlagsQuery = buildPrivacyFlagsQuery;
|
|
50966
51098
|
exports.buildRecentMessagesUrl = buildRecentMessagesUrl;
|
|
50967
51099
|
exports.buildSessionRetrieveUrl = buildSessionRetrieveUrl;
|
|
50968
51100
|
exports.buildSharedSessionRetrieveUrl = buildSharedSessionRetrieveUrl;
|
|
@@ -50998,6 +51130,8 @@ exports.fakeBaseQueryWithLogging = fakeBaseQueryWithLogging;
|
|
|
50998
51130
|
exports.featureTags = featureTags;
|
|
50999
51131
|
exports.fetchLatestMentorSessionId = fetchLatestMentorSessionId;
|
|
51000
51132
|
exports.fetchLearnerCompletion = fetchLearnerCompletion;
|
|
51133
|
+
exports.fetchPrivacyFlag = fetchPrivacyFlag;
|
|
51134
|
+
exports.fetchPrivacyFlags = fetchPrivacyFlags;
|
|
51001
51135
|
exports.fetchUserLlmUsage = fetchUserLlmUsage;
|
|
51002
51136
|
exports.filterCourseUserRoles = filterCourseUserRoles;
|
|
51003
51137
|
exports.filterGlobalUserRoles = filterGlobalUserRoles;
|
|
@@ -51054,6 +51188,7 @@ exports.periodicAgentsApiSlice = periodicAgentsApiSlice;
|
|
|
51054
51188
|
exports.platformApiReducer = platformApiReducer;
|
|
51055
51189
|
exports.platformApiSlice = platformApiSlice;
|
|
51056
51190
|
exports.platformCustomApiSlice = platformCustomApiSlice;
|
|
51191
|
+
exports.privacyFlagsApiSlice = privacyFlagsApiSlice;
|
|
51057
51192
|
exports.projectsApiSlice = projectsApiSlice;
|
|
51058
51193
|
exports.promptsApiSlice = promptsApiSlice;
|
|
51059
51194
|
exports.readMeasure = readMeasure;
|
|
@@ -51422,6 +51557,8 @@ exports.useGetPlatformImageAssetsListQuery = useGetPlatformImageAssetsListQuery;
|
|
|
51422
51557
|
exports.useGetPlatformInfoQuery = useGetPlatformInfoQuery;
|
|
51423
51558
|
exports.useGetPlatformMembershipQuery = useGetPlatformMembershipQuery;
|
|
51424
51559
|
exports.useGetPlatformUserGroupDetailsQuery = useGetPlatformUserGroupDetailsQuery;
|
|
51560
|
+
exports.useGetPrivacyFlagQuery = useGetPrivacyFlagQuery;
|
|
51561
|
+
exports.useGetPrivacyFlagsQuery = useGetPrivacyFlagsQuery;
|
|
51425
51562
|
exports.useGetProgramCompletionQuery = useGetProgramCompletionQuery;
|
|
51426
51563
|
exports.useGetProgramListQuery = useGetProgramListQuery;
|
|
51427
51564
|
exports.useGetPromptCategoriesQuery = useGetPromptCategoriesQuery;
|
|
@@ -51673,6 +51810,8 @@ exports.useLazyGetPinnedMessagesQuery = useLazyGetPinnedMessagesQuery;
|
|
|
51673
51810
|
exports.useLazyGetPlatformAuditLogsQuery = useLazyGetPlatformAuditLogsQuery;
|
|
51674
51811
|
exports.useLazyGetPlatformInfoQuery = useLazyGetPlatformInfoQuery;
|
|
51675
51812
|
exports.useLazyGetPlatformMembershipQuery = useLazyGetPlatformMembershipQuery;
|
|
51813
|
+
exports.useLazyGetPrivacyFlagQuery = useLazyGetPrivacyFlagQuery;
|
|
51814
|
+
exports.useLazyGetPrivacyFlagsQuery = useLazyGetPrivacyFlagsQuery;
|
|
51676
51815
|
exports.useLazyGetProgramCompletionQuery = useLazyGetProgramCompletionQuery;
|
|
51677
51816
|
exports.useLazyGetProgramListQuery = useLazyGetProgramListQuery;
|
|
51678
51817
|
exports.useLazyGetPromptCategoriesQuery = useLazyGetPromptCategoriesQuery;
|