@iblai/data-layer 1.40.0 → 1.41.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 +713 -2
- package/dist/index.esm.js +107 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +120 -0
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- 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
|
*
|
|
@@ -50606,6 +50710,7 @@ const mentorReducer = {
|
|
|
50606
50710
|
[billingCustomSlice.reducerPath]: billingCustomSlice.reducer,
|
|
50607
50711
|
[retirementApiSlice.reducerPath]: retirementApiSlice.reducer,
|
|
50608
50712
|
[auditLogsApiSlice.reducerPath]: auditLogsApiSlice.reducer,
|
|
50713
|
+
[privacyFlagsApiSlice.reducerPath]: privacyFlagsApiSlice.reducer,
|
|
50609
50714
|
[monetizationApiSlice.reducerPath]: monetizationApiSlice.reducer,
|
|
50610
50715
|
[coursesApiSlice.reducerPath]: coursesApiSlice.reducer,
|
|
50611
50716
|
[courseMetadataApiSlice.reducerPath]: courseMetadataApiSlice.reducer,
|
|
@@ -50673,6 +50778,7 @@ const mentorMiddleware = [
|
|
|
50673
50778
|
billingCustomSlice.middleware,
|
|
50674
50779
|
retirementApiSlice.middleware,
|
|
50675
50780
|
auditLogsApiSlice.middleware,
|
|
50781
|
+
privacyFlagsApiSlice.middleware,
|
|
50676
50782
|
monetizationApiSlice.middleware,
|
|
50677
50783
|
coursesApiSlice.middleware,
|
|
50678
50784
|
courseMetadataApiSlice.middleware,
|
|
@@ -50888,6 +50994,12 @@ exports.PLATFORM_MEMBERSHIP_TAG = PLATFORM_MEMBERSHIP_TAG;
|
|
|
50888
50994
|
exports.PRIVACY_ACTIONS = PRIVACY_ACTIONS;
|
|
50889
50995
|
exports.PRIVACY_BLOCKED_ERROR_KIND = PRIVACY_BLOCKED_ERROR_KIND;
|
|
50890
50996
|
exports.PRIVACY_ENTITY_TYPES = PRIVACY_ENTITY_TYPES;
|
|
50997
|
+
exports.PRIVACY_FLAGS_ENDPOINTS = PRIVACY_FLAGS_ENDPOINTS;
|
|
50998
|
+
exports.PRIVACY_FLAGS_QUERY_KEYS = PRIVACY_FLAGS_QUERY_KEYS;
|
|
50999
|
+
exports.PRIVACY_FLAGS_REDUCER_PATH = PRIVACY_FLAGS_REDUCER_PATH;
|
|
51000
|
+
exports.PRIVACY_FLAG_ACTIONS = PRIVACY_FLAG_ACTIONS;
|
|
51001
|
+
exports.PRIVACY_FLAG_RAILS = PRIVACY_FLAG_RAILS;
|
|
51002
|
+
exports.PRIVACY_FLAG_SOURCES = PRIVACY_FLAG_SOURCES;
|
|
50891
51003
|
exports.PRIVACY_TARGET_SYSTEM = PRIVACY_TARGET_SYSTEM;
|
|
50892
51004
|
exports.PROJECTS_CUSTOM_ENDPOINTS = PROJECTS_CUSTOM_ENDPOINTS;
|
|
50893
51005
|
exports.PROJECTS_CUSTOM_REDUCER_PATH = PROJECTS_CUSTOM_REDUCER_PATH;
|
|
@@ -50963,6 +51075,7 @@ exports.billingCustomSlice = billingCustomSlice;
|
|
|
50963
51075
|
exports.buildGlobalSearchUrl = buildGlobalSearchUrl;
|
|
50964
51076
|
exports.buildLearnerCompletionUrl = buildLearnerCompletionUrl;
|
|
50965
51077
|
exports.buildPinnedMessagesUrl = buildPinnedMessagesUrl;
|
|
51078
|
+
exports.buildPrivacyFlagsQuery = buildPrivacyFlagsQuery;
|
|
50966
51079
|
exports.buildRecentMessagesUrl = buildRecentMessagesUrl;
|
|
50967
51080
|
exports.buildSessionRetrieveUrl = buildSessionRetrieveUrl;
|
|
50968
51081
|
exports.buildSharedSessionRetrieveUrl = buildSharedSessionRetrieveUrl;
|
|
@@ -50998,6 +51111,8 @@ exports.fakeBaseQueryWithLogging = fakeBaseQueryWithLogging;
|
|
|
50998
51111
|
exports.featureTags = featureTags;
|
|
50999
51112
|
exports.fetchLatestMentorSessionId = fetchLatestMentorSessionId;
|
|
51000
51113
|
exports.fetchLearnerCompletion = fetchLearnerCompletion;
|
|
51114
|
+
exports.fetchPrivacyFlag = fetchPrivacyFlag;
|
|
51115
|
+
exports.fetchPrivacyFlags = fetchPrivacyFlags;
|
|
51001
51116
|
exports.fetchUserLlmUsage = fetchUserLlmUsage;
|
|
51002
51117
|
exports.filterCourseUserRoles = filterCourseUserRoles;
|
|
51003
51118
|
exports.filterGlobalUserRoles = filterGlobalUserRoles;
|
|
@@ -51054,6 +51169,7 @@ exports.periodicAgentsApiSlice = periodicAgentsApiSlice;
|
|
|
51054
51169
|
exports.platformApiReducer = platformApiReducer;
|
|
51055
51170
|
exports.platformApiSlice = platformApiSlice;
|
|
51056
51171
|
exports.platformCustomApiSlice = platformCustomApiSlice;
|
|
51172
|
+
exports.privacyFlagsApiSlice = privacyFlagsApiSlice;
|
|
51057
51173
|
exports.projectsApiSlice = projectsApiSlice;
|
|
51058
51174
|
exports.promptsApiSlice = promptsApiSlice;
|
|
51059
51175
|
exports.readMeasure = readMeasure;
|
|
@@ -51422,6 +51538,8 @@ exports.useGetPlatformImageAssetsListQuery = useGetPlatformImageAssetsListQuery;
|
|
|
51422
51538
|
exports.useGetPlatformInfoQuery = useGetPlatformInfoQuery;
|
|
51423
51539
|
exports.useGetPlatformMembershipQuery = useGetPlatformMembershipQuery;
|
|
51424
51540
|
exports.useGetPlatformUserGroupDetailsQuery = useGetPlatformUserGroupDetailsQuery;
|
|
51541
|
+
exports.useGetPrivacyFlagQuery = useGetPrivacyFlagQuery;
|
|
51542
|
+
exports.useGetPrivacyFlagsQuery = useGetPrivacyFlagsQuery;
|
|
51425
51543
|
exports.useGetProgramCompletionQuery = useGetProgramCompletionQuery;
|
|
51426
51544
|
exports.useGetProgramListQuery = useGetProgramListQuery;
|
|
51427
51545
|
exports.useGetPromptCategoriesQuery = useGetPromptCategoriesQuery;
|
|
@@ -51673,6 +51791,8 @@ exports.useLazyGetPinnedMessagesQuery = useLazyGetPinnedMessagesQuery;
|
|
|
51673
51791
|
exports.useLazyGetPlatformAuditLogsQuery = useLazyGetPlatformAuditLogsQuery;
|
|
51674
51792
|
exports.useLazyGetPlatformInfoQuery = useLazyGetPlatformInfoQuery;
|
|
51675
51793
|
exports.useLazyGetPlatformMembershipQuery = useLazyGetPlatformMembershipQuery;
|
|
51794
|
+
exports.useLazyGetPrivacyFlagQuery = useLazyGetPrivacyFlagQuery;
|
|
51795
|
+
exports.useLazyGetPrivacyFlagsQuery = useLazyGetPrivacyFlagsQuery;
|
|
51676
51796
|
exports.useLazyGetProgramCompletionQuery = useLazyGetProgramCompletionQuery;
|
|
51677
51797
|
exports.useLazyGetProgramListQuery = useLazyGetProgramListQuery;
|
|
51678
51798
|
exports.useLazyGetPromptCategoriesQuery = useLazyGetPromptCategoriesQuery;
|