@e-llm-studio/instant-learning 1.3.0-alpha.20 → 1.3.0-alpha.22

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/README.md CHANGED
@@ -3,6 +3,14 @@
3
3
 
4
4
  ## Changelog
5
5
 
6
+ ### 1.3.0-alpha.21 - 2026, June 8th
7
+ **Permissions — Union-based access resolution**
8
+
9
+ - **Union model**: When a user holds multiple roles on the same resource (e.g. inherited group role + direct assignment), permissions from all roles are merged. If any role grants a permission, the user has it.
10
+ - **Removed**: `ROLE_HIERARCHY`, `getRolePrecedence()`, `resolveHighestRolePerResource()`, and the `resolvedData` store field are all gone.
11
+ - **`hasPermission()`** and **`hasApplicationAccess()`** now run against the raw `accessData` via a new internal `getUnionPermissionsForResource()` helper that builds a `Set` of all permissions across matching records.
12
+ - `fetchPermissions()` no longer calls the resolver — stores raw API response only.
13
+
6
14
  ### 1.3.0-alpha.20 - 2026, June 8th
7
15
  **TeachMe Popup — LHS Customisation via `dtt()`**
8
16
 
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),r=require("@tanstack/react-query"),i=require("lucide-react"),o=require("primereact/toast"),s=require("uuid"),a=require("../components/StationOnboarding/StationAutocomplete.js"),l=require("./AddScopeApprovalSearchComponent.js"),u=require("../components/ScopeSkeletonLoader.js"),c=require("@mui/material"),d=require("../store/useAuthStore.js"),p=require("../store/useAppSecRolesStore.js"),_=require("../store/useEnvStore.js"),g=require("../apis/scopeApis.js"),h=require("../store/useLearningTemplateStore.js"),f=require("../config.js"),m=require("../store/useLMSConfigStore.js"),v=require("../constants.js");exports.default=function(S){var x=S.isOpen,y=S.onClose,b=S.onCreate,D=S.hasGlobalRuleSet,A=S.parentId,j=t.useState(""),C=j[0],R=j[1],E=t.useState(""),T=E[0],q=E[1],I=t.useState({}),L=I[0],P=I[1],w=t.useRef(null),k=d.default().user,W=p.useAppSecRolesStore(function(e){return e.roles}),N=_.default(function(e){return e.rbacConfig}),O=t.useState(null),F=O[0],M=O[1],z=t.useState("approval_required"),G=z[0],B=z[1],H=t.useState([]),V=H[0],K=H[1],U=t.useState([]),X=U[0],J=U[1],Q=t.useState(""),Y=Q[0],Z=Q[1],$=r.useMutation({mutationFn:function(n){return e.__awaiter(void 0,void 0,void 0,function(){var t;return e.__generator(this,function(e){switch(e.label){case 0:return[4,g.createRuleSet(n,null!==(t=null==k?void 0:k.accessToken)&&void 0!==t?t:"")];case 1:return[2,e.sent()]}})})},onSuccess:function(n){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){return console.log("Rule Set Created Successfully",n),[2]})})}});$.data;var ee=$.isPending,ne=$.mutateAsync;return t.useEffect(function(){x&&(R(""),q(""),P({}),M(null),B("approval_required"),K([]),J([]),Z(""))},[x]),x?ee?n.jsx(u.default,{isLoading:ee}):n.jsxs("div",e.__assign({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[n.jsx(o.Toast,{ref:w}),n.jsxs("div",e.__assign({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[n.jsxs("div",e.__assign({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[n.jsxs("div",{children:[n.jsx("h2",e.__assign({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".title"),"Add Scope")})),n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".subtitle"),"This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),n.jsx("button",e.__assign({onClick:y,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:n.jsx(i.X,{size:24})}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:20}},{children:[n.jsxs("div",e.__assign({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".scopeName"),"Scope Name")]})),"Custom"===C?n.jsx(a.default,{value:T,onChange:function(n){if(n.length>50)return q(n.slice(0,50)),void P(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});q(n),P(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},onStationSelect:function(e){M(e)},style:{border:L.name?"1px solid #8F2C23":void 0}}):n.jsx(c.Input,{value:T,onChange:function(n){var t=n.target.value;if(t.length>50)return q(t.slice(0,50)),void P(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});q(t),P(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},style:{border:"1px solid ".concat(L.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),L.name&&n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:L.name}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:12}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".title"),"Learning Approval Settings")]})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"approval_required"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return B("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||B("approval_required")}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===G?"#2563EB":"#CBD5E1")}},{children:"approval_required"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===G&&n.jsx(l.default,{selectedApprovers:V,selectedGroupOfApprovers:X,onApproversChange:K,onGroupsChange:J}),Y&&n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:Y})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"publish_without"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){B("publish_without"),Z("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(B("publish_without"),Z(""))}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===G?"#2563EB":"#CBD5E1")}},{children:"publish_without"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),n.jsxs("div",e.__assign({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[n.jsx("button",e.__assign({onClick:y,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:ee?.5:1},disabled:ee},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".cancel"),"Cancel")})),n.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,t,r,i,o,a,l,u,c,d,p,_,g,m;return e.__generator(this,function(v){switch(v.label){case 0:if(n={},T.trim()?T.length>50&&(n.name="Scope Name must be 50 characters or fewer"):n.name="Scope Name is required","approval_required"===G&&0===V.length&&0===X.length&&Z("Please select at least one approver or approver group."),n.name)return P(n),[2];if("approval_required"===G&&0===V.length&&0===X.length)return[2];Z(""),v.label=1;case 1:return v.trys.push([1,3,,4]),t="approval_required"===G,r=h.useLearningTemplateStore.getState().backwardCompatibility,i=r?{topic:D?"genreRuleSet":"globalRuleSet",customScopeGroupName:f.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:T,parentScopeId:null,customScopeName:T,customScopeId:s.v4(),createByName:(null==k?void 0:k.firstname)||"System",createdBy:(null==k?void 0:k.email)||"system@audacy.com",approvalRequired:t,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],t?[{users:V.map(function(e){return e.email}),groups:X.map(function(e){return e._id}),role:null!==(u=null===(l=W.find(function(e){return"Learning Manager"===e.name}))||void 0===l?void 0:l._id)&&void 0!==u?u:""}]:[],!0),[{users:[null==k?void 0:k.email],groups:[],role:null!==(d=null===(c=W.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===c?void 0:c._id)&&void 0!==d?d:""}],!1)}}:{topic:D?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:T,parentScopeId:null!=A?A:null,scopeName:T,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:h.useLearningTemplateStore.getState().app_integration_id},console.log("Add Scope payload:",i),[4,ne(i)];case 2:return o=v.sent(),b(null===(p=null==o?void 0:o.data)||void 0===p?void 0:p.scopeId),y(),[3,4];case 3:return a=v.sent(),console.error("An error occurred during scope creation.",a),null===(_=w.current)||void 0===_||_.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(m=null===(g=null==a?void 0:a.response)||void 0===g?void 0:g.data)||void 0===m?void 0:m.message)||"There was an error creating the scope. Please try again."}),[3,4];case 4:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:ee||"Custom"===C&&!F?.5:1},disabled:ee||"Custom"===C&&!F},{children:ee?n.jsxs(n.Fragment,{children:[n.jsx(i.Loader2,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),r=require("react"),n=require("@tanstack/react-query"),i=require("lucide-react"),o=require("primereact/toast"),s=require("uuid"),a=require("../components/StationOnboarding/StationAutocomplete.js"),l=require("./AddScopeApprovalSearchComponent.js"),c=require("../components/ScopeSkeletonLoader.js"),u=require("@mui/material"),d=require("../store/useAuthStore.js"),p=require("../store/useAppSecRolesStore.js"),_=require("../store/useEnvStore.js"),g=require("../apis/scopeApis.js"),h=require("../store/useLearningTemplateStore.js"),f=require("../config.js"),m=require("../store/useLMSConfigStore.js"),v=require("../constants.js");exports.default=function(S){var x=S.isOpen,y=S.onClose,b=S.onCreate,D=S.hasGlobalRuleSet,A=S.parentId,j=r.useState(""),C=j[0],R=j[1],E=r.useState(""),T=E[0],q=E[1],I=r.useState({}),L=I[0],w=I[1],P=r.useRef(null),k=d.default().user,W=p.useAppSecRolesStore(function(e){return e.roles}),N=_.default(function(e){return e.rbacConfig}),F=r.useState(null),O=F[0],M=F[1],z=r.useState("approval_required"),G=z[0],B=z[1],H=r.useState([]),V=H[0],K=H[1],U=r.useState([]),X=U[0],J=U[1],Q=r.useState(""),Y=Q[0],Z=Q[1],$=n.useMutation({mutationFn:function(t){return e.__awaiter(void 0,void 0,void 0,function(){var r;return e.__generator(this,function(e){switch(e.label){case 0:return[4,g.createRuleSet(t,null!==(r=null==k?void 0:k.accessToken)&&void 0!==r?r:"")];case 1:return[2,e.sent()]}})})},onSuccess:function(t){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){return console.log("Rule Set Created Successfully",t),[2]})})}});$.data;var ee=$.isPending,te=$.mutateAsync;return r.useEffect(function(){x&&(R(""),q(""),w({}),M(null),B("approval_required"),K([]),J([]),Z(""))},[x]),x?ee?t.jsx(c.default,{isLoading:ee}):t.jsxs("div",e.__assign({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[t.jsx(o.Toast,{ref:P}),t.jsxs("div",e.__assign({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[t.jsxs("div",e.__assign({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[t.jsxs("div",{children:[t.jsx("h2",e.__assign({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".title"),"Add Scope")})),t.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".subtitle"),"This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),t.jsx("button",e.__assign({onClick:y,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:t.jsx(i.X,{size:24})}))]})),t.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:20}},{children:[t.jsxs("div",e.__assign({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[t.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".scopeName"),"Scope Name")]})),"Custom"===C?t.jsx(a.default,{value:T,onChange:function(t){if(t.length>50)return q(t.slice(0,50)),void w(function(t){return e.__assign(e.__assign({},t),{name:"Scope Name must be 50 characters or fewer"})});q(t),w(function(t){return e.__assign(e.__assign({},t),{name:void 0})})},onStationSelect:function(e){M(e)},style:{border:L.name?"1px solid #8F2C23":void 0}}):t.jsx(u.Input,{value:T,onChange:function(t){var r=t.target.value;if(r.length>50)return q(r.slice(0,50)),void w(function(t){return e.__assign(e.__assign({},t),{name:"Scope Name must be 50 characters or fewer"})});q(r),w(function(t){return e.__assign(e.__assign({},t),{name:void 0})})},style:{border:"1px solid ".concat(L.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),L.name&&t.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:L.name}))]})),t.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:12}},{children:[t.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".title"),"Learning Approval Settings")]})),t.jsxs("div",e.__assign({role:"radio","aria-checked":"approval_required"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return B("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||B("approval_required")}},{children:[t.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[t.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===G?"#2563EB":"#CBD5E1")}},{children:"approval_required"===G&&t.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),t.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===G&&t.jsx(l.default,{selectedApprovers:V,selectedGroupOfApprovers:X,onApproversChange:K,onGroupsChange:J}),Y&&t.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:Y})),t.jsxs("div",e.__assign({role:"radio","aria-checked":"publish_without"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){B("publish_without"),Z("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(B("publish_without"),Z(""))}},{children:[t.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[t.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===G?"#2563EB":"#CBD5E1")}},{children:"publish_without"===G&&t.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),t.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),t.jsxs("div",e.__assign({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[t.jsx("button",e.__assign({onClick:y,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:ee?.5:1},disabled:ee},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".cancel"),"Cancel")})),t.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var t,r,n,i,o,a,l,c,u,d,p,_,m,v,S,x;return e.__generator(this,function(j){switch(j.label){case 0:if(t={},T.trim()?T.length>50&&(t.name="Scope Name must be 50 characters or fewer"):t.name="Scope Name is required","approval_required"===G&&0===V.length&&0===X.length&&Z("Please select at least one approver or approver group."),t.name)return w(t),[2];if("approval_required"===G&&0===V.length&&0===X.length)return[2];Z(""),j.label=1;case 1:return j.trys.push([1,7,,8]),r="approval_required"===G,n=h.useLearningTemplateStore.getState().backwardCompatibility,i=n?{topic:D?"genreRuleSet":"globalRuleSet",customScopeGroupName:f.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:T,parentScopeId:null,customScopeName:T,customScopeId:s.v4(),createByName:(null==k?void 0:k.firstname)||"System",createdBy:(null==k?void 0:k.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],r?[{users:V.map(function(e){return e.email}),groups:X.map(function(e){return e._id}),role:null!==(d=null===(u=W.find(function(e){return"Learning Manager"===e.name}))||void 0===u?void 0:u._id)&&void 0!==d?d:""}]:[],!0),[{users:[null==k?void 0:k.email],groups:[],role:null!==(_=null===(p=W.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===p?void 0:p._id)&&void 0!==_?_:""}],!1)}}:{topic:D?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:T,parentScopeId:null!=A?A:null,scopeName:T,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:h.useLearningTemplateStore.getState().app_integration_id},console.log("Add Scope payload:",i),[4,te(i)];case 2:if(o=j.sent(),a=null===(m=null==o?void 0:o.data)||void 0===m?void 0:m.scopeId,n||!a||!A)return[3,6];j.label=3;case 3:return j.trys.push([3,5,,6]),[4,g.inheritScope({source_scope_id:A,target_scope_id:a,application_mapping_id:h.useLearningTemplateStore.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return j.sent(),[3,6];case 5:return l=j.sent(),console.error("Failed to inherit rules for the new scope:",l),[3,6];case 6:return b(a),y(),[3,8];case 7:return c=j.sent(),console.error("An error occurred during scope creation.",c),null===(v=P.current)||void 0===v||v.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(x=null===(S=null==c?void 0:c.response)||void 0===S?void 0:S.data)||void 0===x?void 0:x.message)||"There was an error creating the scope. Please try again."}),[3,8];case 8:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:ee||"Custom"===C&&!O?.5:1},disabled:ee||"Custom"===C&&!O},{children:ee?t.jsxs(t.Fragment,{children:[t.jsx(i.Loader2,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};
2
2
  //# sourceMappingURL=AddScopeModal.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("zustand"),s=require("../apis/scopeApis.js"),n=require("./useEnvStore.js"),i=function(e,r){return!!r&&function(e){return e?"string"==typeof e?[e]:[e._id,e.id,e.resourceId,e.resource_id].filter(function(e){return"string"==typeof e&&e.length>0}):[]}(e).includes(r)},o=r.create(function(r,o){return{accessData:[],isLoading:!1,error:null,fetchPermissions:function(n,i){return e.__awaiter(void 0,void 0,void 0,function(){var o,t,a;return e.__generator(this,function(e){switch(e.label){case 0:if(!n)return[2];r({isLoading:!0,error:null}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,s.appsecApi.get("/users/me",{params:{appId:n,resourceId:i}})];case 2:return o=e.sent(),r({accessData:(null===(a=o.data)||void 0===a?void 0:a.data)||[],isLoading:!1}),[3,4];case 3:return t=e.sent(),console.error("Failed to fetch permissions:",t),r({error:t.message||"Failed to fetch permissions",isLoading:!1}),[3,4];case 4:return[2]}})})},hasPermission:function(e,r){var s,t=o().accessData,a=null===(s=n.default.getState().rbacConfig)||void 0===s?void 0:s.applicationResourceId,u=function(e,r){return t.some(function(s){var n,o,t;return i(s.resourceId,r)&&null!==(t=null===(o=null===(n=s.role)||void 0===n?void 0:n.permissions)||void 0===o?void 0:o.some(function(r){return r.name===e}))&&void 0!==t&&t})};return!(!a||!u(e,a))||u(e,r)},hasGlobalPermission:function(e,r){return!!r&&(o().hasApplicationAccess(r)||o().hasPermission(e,r))},hasApplicationAccess:function(e){return!!e&&o().accessData.some(function(r){var s,n,o;return i(r.resourceId,e)&&null!==(o=null===(n=null===(s=r.role)||void 0===s?void 0:s.permissions)||void 0===n?void 0:n.some(function(e){return"ilotj.scope.access.application.user.add"===e.name}))&&void 0!==o&&o})},reset:function(){return r({accessData:[],isLoading:!1,error:null})}}});exports.usePermissionsStore=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("zustand"),s=require("../apis/scopeApis.js"),i=require("./useEnvStore.js"),n=function(e,r){return!!r&&function(e){return e?"string"==typeof e?[e]:[e._id,e.id,e.resourceId,e.resource_id].filter(function(e){return"string"==typeof e&&e.length>0}):[]}(e).includes(r)},t=function(e,r){for(var s,i,t=new Set,a=0,o=e;a<o.length;a++){var u=o[a];if(n(u.resourceId,r))for(var c=0,l=null!==(i=null===(s=u.role)||void 0===s?void 0:s.permissions)&&void 0!==i?i:[];c<l.length;c++){var d=l[c];t.add(d.name)}}return t},a=r.create(function(r,n){return{accessData:[],isLoading:!1,error:null,fetchPermissions:function(i,n){return e.__awaiter(void 0,void 0,void 0,function(){var t,a,o;return e.__generator(this,function(e){switch(e.label){case 0:if(!i)return[2];r({isLoading:!0,error:null}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,s.appsecApi.get("/users/me",{params:{appId:i,resourceId:n}})];case 2:return t=e.sent(),r({accessData:(null===(o=t.data)||void 0===o?void 0:o.data)||[],isLoading:!1}),[3,4];case 3:return a=e.sent(),console.error("Failed to fetch permissions:",a),r({error:a.message||"Failed to fetch permissions",isLoading:!1}),[3,4];case 4:return[2]}})})},hasPermission:function(e,r){var s,a=n().accessData,o=null===(s=i.default.getState().rbacConfig)||void 0===s?void 0:s.applicationResourceId;if(o&&t(a,o).has(e))return!0;if(r&&t(a,r).has(e))return!0;return!1},hasGlobalPermission:function(e,r){return!!r&&(n().hasApplicationAccess(r)||n().hasPermission(e,r))},hasApplicationAccess:function(e){if(!e)return!1;var r=n().accessData;return t(r,e).has("ilotj.scope.access.application.user.add")},reset:function(){return r({accessData:[],isLoading:!1,error:null})}}});exports.usePermissionsStore=a;
2
2
  //# sourceMappingURL=usePermissionsStore.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e,__generator as o,__assign as r,__spreadArray as t}from"tslib";import{jsx as n,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as s}from"react";import{useMutation as d}from"@tanstack/react-query";import{X as p,Loader2 as u}from"lucide-react";import{Toast as m}from"primereact/toast";import{v4 as f}from"uuid";import h from"../components/StationOnboarding/StationAutocomplete.js";import g from"./AddScopeApprovalSearchComponent.js";import v from"../components/ScopeSkeletonLoader.js";import{Input as y}from"@mui/material";import b from"../store/useAuthStore.js";import{useAppSecRolesStore as S}from"../store/useAppSecRolesStore.js";import C from"../store/useEnvStore.js";import{createRuleSet as x}from"../apis/scopeApis.js";import{useLearningTemplateStore as w}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as _}from"../config.js";import{dt as k}from"../store/useLMSConfigStore.js";import{MIDDLE_DRAWER_ADD_SCOPE_DT_PATH as A,MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH as R}from"../constants.js";var D=function(D){var I=D.isOpen,q=D.onClose,j=D.onCreate,z=D.hasGlobalRuleSet,F=D.parentId,E=a(""),L=E[0],B=E[1],W=a(""),N=W[0],G=W[1],P=a({}),T=P[0],M=P[1],O=c(null),K=b().user,U=S(function(e){return e.roles}),H=C(function(e){return e.rbacConfig}),J=a(null),Q=J[0],V=J[1],X=a("approval_required"),Y=X[0],Z=X[1],$=a([]),ee=$[0],oe=$[1],re=a([]),te=re[0],ne=re[1],ie=a(""),le=ie[0],ae=ie[1],ce=d({mutationFn:function(r){return e(void 0,void 0,void 0,function(){var e;return o(this,function(o){switch(o.label){case 0:return[4,x(r,null!==(e=null==K?void 0:K.accessToken)&&void 0!==e?e:"")];case 1:return[2,o.sent()]}})})},onSuccess:function(r){return e(void 0,void 0,void 0,function(){return o(this,function(e){return console.log("Rule Set Created Successfully",r),[2]})})}});ce.data;var se=ce.isPending,de=ce.mutateAsync;return s(function(){I&&(B(""),G(""),M({}),V(null),Z("approval_required"),oe([]),ne([]),ae(""))},[I]),I?se?n(v,{isLoading:se}):i("div",r({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[n(m,{ref:O}),i("div",r({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[i("div",r({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[i("div",{children:[n("h2",r({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:k("".concat(A,".title"),"Add Scope")})),n("p",r({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:k("".concat(A,".subtitle"),"This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),n("button",r({onClick:q,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:n(p,{size:24})}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:20}},{children:[i("div",r({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),k("".concat(A,".scopeName"),"Scope Name")]})),"Custom"===L?n(h,{value:N,onChange:function(e){if(e.length>50)return G(e.slice(0,50)),void M(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});G(e),M(function(e){return r(r({},e),{name:void 0})})},onStationSelect:function(e){V(e)},style:{border:T.name?"1px solid #8F2C23":void 0}}):n(y,{value:N,onChange:function(e){var o=e.target.value;if(o.length>50)return G(o.slice(0,50)),void M(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});G(o),M(function(e){return r(r({},e),{name:void 0})})},style:{border:"1px solid ".concat(T.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),T.name&&n("p",r({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:T.name}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:12}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),k("".concat(R,".title"),"Learning Approval Settings")]})),i("div",r({role:"radio","aria-checked":"approval_required"===Y,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return Z("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||Z("approval_required")}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[n("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===Y?"#2563EB":"#CBD5E1")}},{children:"approval_required"===Y&&n("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:k("".concat(R,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),n("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:k("".concat(R,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===Y&&n(g,{selectedApprovers:ee,selectedGroupOfApprovers:te,onApproversChange:oe,onGroupsChange:ne}),le&&n("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:le})),i("div",r({role:"radio","aria-checked":"publish_without"===Y,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){Z("publish_without"),ae("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(Z("publish_without"),ae(""))}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[n("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===Y?"#2563EB":"#CBD5E1")}},{children:"publish_without"===Y&&n("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:k("".concat(R,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),n("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:k("".concat(R,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),i("div",r({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[n("button",r({onClick:q,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:se?.5:1},disabled:se},{children:k("".concat(A,".cancel"),"Cancel")})),n("button",r({onClick:function(){return e(void 0,void 0,void 0,function(){var e,r,n,i,l,a,c,s,d,p,u,m,h,g;return o(this,function(o){switch(o.label){case 0:if(e={},N.trim()?N.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required","approval_required"===Y&&0===ee.length&&0===te.length&&ae("Please select at least one approver or approver group."),e.name)return M(e),[2];if("approval_required"===Y&&0===ee.length&&0===te.length)return[2];ae(""),o.label=1;case 1:return o.trys.push([1,3,,4]),r="approval_required"===Y,n=w.getState().backwardCompatibility,i=n?{topic:z?"genreRuleSet":"globalRuleSet",customScopeGroupName:_.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:N,parentScopeId:null,customScopeName:N,customScopeId:f(),createByName:(null==K?void 0:K.firstname)||"System",createdBy:(null==K?void 0:K.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==H?void 0:H.applicationId,module:null==H?void 0:H.moduleId,roles:t(t([],r?[{users:ee.map(function(e){return e.email}),groups:te.map(function(e){return e._id}),role:null!==(s=null===(c=U.find(function(e){return"Learning Manager"===e.name}))||void 0===c?void 0:c._id)&&void 0!==s?s:""}]:[],!0),[{users:[null==K?void 0:K.email],groups:[],role:null!==(p=null===(d=U.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===d?void 0:d._id)&&void 0!==p?p:""}],!1)}}:{topic:z?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:N,parentScopeId:null!=F?F:null,scopeName:N,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:w.getState().app_integration_id},console.log("Add Scope payload:",i),[4,de(i)];case 2:return l=o.sent(),j(null===(u=null==l?void 0:l.data)||void 0===u?void 0:u.scopeId),q(),[3,4];case 3:return a=o.sent(),console.error("An error occurred during scope creation.",a),null===(m=O.current)||void 0===m||m.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(g=null===(h=null==a?void 0:a.response)||void 0===h?void 0:h.data)||void 0===g?void 0:g.message)||"There was an error creating the scope. Please try again."}),[3,4];case 4:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:se||"Custom"===L&&!Q?.5:1},disabled:se||"Custom"===L&&!Q},{children:se?i(l,{children:[n(u,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):k("".concat(A,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};export{D as default};
1
+ import{__awaiter as e,__generator as o,__assign as r,__spreadArray as t}from"tslib";import{jsx as n,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as s}from"react";import{useMutation as d}from"@tanstack/react-query";import{X as p,Loader2 as u}from"lucide-react";import{Toast as m}from"primereact/toast";import{v4 as f}from"uuid";import h from"../components/StationOnboarding/StationAutocomplete.js";import g from"./AddScopeApprovalSearchComponent.js";import v from"../components/ScopeSkeletonLoader.js";import{Input as y}from"@mui/material";import b from"../store/useAuthStore.js";import{useAppSecRolesStore as S}from"../store/useAppSecRolesStore.js";import C from"../store/useEnvStore.js";import{createRuleSet as x,inheritScope as _}from"../apis/scopeApis.js";import{useLearningTemplateStore as w}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as k}from"../config.js";import{dt as A}from"../store/useLMSConfigStore.js";import{MIDDLE_DRAWER_ADD_SCOPE_DT_PATH as R,MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH as D}from"../constants.js";var I=function(I){var q=I.isOpen,j=I.onClose,F=I.onCreate,z=I.hasGlobalRuleSet,E=I.parentId,L=a(""),B=L[0],W=L[1],N=a(""),G=N[0],P=N[1],T=a({}),M=T[0],O=T[1],K=c(null),U=b().user,H=S(function(e){return e.roles}),J=C(function(e){return e.rbacConfig}),Q=a(null),V=Q[0],X=Q[1],Y=a("approval_required"),Z=Y[0],$=Y[1],ee=a([]),oe=ee[0],re=ee[1],te=a([]),ne=te[0],ie=te[1],le=a(""),ae=le[0],ce=le[1],se=d({mutationFn:function(r){return e(void 0,void 0,void 0,function(){var e;return o(this,function(o){switch(o.label){case 0:return[4,x(r,null!==(e=null==U?void 0:U.accessToken)&&void 0!==e?e:"")];case 1:return[2,o.sent()]}})})},onSuccess:function(r){return e(void 0,void 0,void 0,function(){return o(this,function(e){return console.log("Rule Set Created Successfully",r),[2]})})}});se.data;var de=se.isPending,pe=se.mutateAsync;return s(function(){q&&(W(""),P(""),O({}),X(null),$("approval_required"),re([]),ie([]),ce(""))},[q]),q?de?n(v,{isLoading:de}):i("div",r({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[n(m,{ref:K}),i("div",r({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[i("div",r({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[i("div",{children:[n("h2",r({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:A("".concat(R,".title"),"Add Scope")})),n("p",r({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:A("".concat(R,".subtitle"),"This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),n("button",r({onClick:j,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:n(p,{size:24})}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:20}},{children:[i("div",r({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(R,".scopeName"),"Scope Name")]})),"Custom"===B?n(h,{value:G,onChange:function(e){if(e.length>50)return P(e.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});P(e),O(function(e){return r(r({},e),{name:void 0})})},onStationSelect:function(e){X(e)},style:{border:M.name?"1px solid #8F2C23":void 0}}):n(y,{value:G,onChange:function(e){var o=e.target.value;if(o.length>50)return P(o.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});P(o),O(function(e){return r(r({},e),{name:void 0})})},style:{border:"1px solid ".concat(M.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),M.name&&n("p",r({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:M.name}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:12}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(D,".title"),"Learning Approval Settings")]})),i("div",r({role:"radio","aria-checked":"approval_required"===Z,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return $("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||$("approval_required")}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[n("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===Z?"#2563EB":"#CBD5E1")}},{children:"approval_required"===Z&&n("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(D,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),n("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(D,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===Z&&n(g,{selectedApprovers:oe,selectedGroupOfApprovers:ne,onApproversChange:re,onGroupsChange:ie}),ae&&n("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:ae})),i("div",r({role:"radio","aria-checked":"publish_without"===Z,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){$("publish_without"),ce("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||($("publish_without"),ce(""))}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[n("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===Z?"#2563EB":"#CBD5E1")}},{children:"publish_without"===Z&&n("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(D,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),n("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(D,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),i("div",r({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[n("button",r({onClick:j,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:de?.5:1},disabled:de},{children:A("".concat(R,".cancel"),"Cancel")})),n("button",r({onClick:function(){return e(void 0,void 0,void 0,function(){var e,r,n,i,l,a,c,s,d,p,u,m,h,g,v,y;return o(this,function(o){switch(o.label){case 0:if(e={},G.trim()?G.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required","approval_required"===Z&&0===oe.length&&0===ne.length&&ce("Please select at least one approver or approver group."),e.name)return O(e),[2];if("approval_required"===Z&&0===oe.length&&0===ne.length)return[2];ce(""),o.label=1;case 1:return o.trys.push([1,7,,8]),r="approval_required"===Z,n=w.getState().backwardCompatibility,i=n?{topic:z?"genreRuleSet":"globalRuleSet",customScopeGroupName:k.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:G,parentScopeId:null,customScopeName:G,customScopeId:f(),createByName:(null==U?void 0:U.firstname)||"System",createdBy:(null==U?void 0:U.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:t(t([],r?[{users:oe.map(function(e){return e.email}),groups:ne.map(function(e){return e._id}),role:null!==(p=null===(d=H.find(function(e){return"Learning Manager"===e.name}))||void 0===d?void 0:d._id)&&void 0!==p?p:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(m=null===(u=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===u?void 0:u._id)&&void 0!==m?m:""}],!1)}}:{topic:z?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:G,parentScopeId:null!=E?E:null,scopeName:G,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:w.getState().app_integration_id},console.log("Add Scope payload:",i),[4,pe(i)];case 2:if(l=o.sent(),a=null===(h=null==l?void 0:l.data)||void 0===h?void 0:h.scopeId,n||!a||!E)return[3,6];o.label=3;case 3:return o.trys.push([3,5,,6]),[4,_({source_scope_id:E,target_scope_id:a,application_mapping_id:w.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return o.sent(),[3,6];case 5:return c=o.sent(),console.error("Failed to inherit rules for the new scope:",c),[3,6];case 6:return F(a),j(),[3,8];case 7:return s=o.sent(),console.error("An error occurred during scope creation.",s),null===(g=K.current)||void 0===g||g.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(y=null===(v=null==s?void 0:s.response)||void 0===v?void 0:v.data)||void 0===y?void 0:y.message)||"There was an error creating the scope. Please try again."}),[3,8];case 8:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:de||"Custom"===B&&!V?.5:1},disabled:de||"Custom"===B&&!V},{children:de?i(l,{children:[n(u,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):A("".concat(R,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};export{I as default};
2
2
  //# sourceMappingURL=AddScopeModal.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as r,__generator as e}from"tslib";import{create as n}from"zustand";import{appsecApi as i}from"../apis/scopeApis.js";import o from"./useEnvStore.js";var s=function(r,e){return!!e&&function(r){return r?"string"==typeof r?[r]:[r._id,r.id,r.resourceId,r.resource_id].filter(function(r){return"string"==typeof r&&r.length>0}):[]}(r).includes(e)},t=n(function(n,t){return{accessData:[],isLoading:!1,error:null,fetchPermissions:function(o,s){return r(void 0,void 0,void 0,function(){var r,t,a;return e(this,function(e){switch(e.label){case 0:if(!o)return[2];n({isLoading:!0,error:null}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,i.get("/users/me",{params:{appId:o,resourceId:s}})];case 2:return r=e.sent(),n({accessData:(null===(a=r.data)||void 0===a?void 0:a.data)||[],isLoading:!1}),[3,4];case 3:return t=e.sent(),console.error("Failed to fetch permissions:",t),n({error:t.message||"Failed to fetch permissions",isLoading:!1}),[3,4];case 4:return[2]}})})},hasPermission:function(r,e){var n,i=t().accessData,a=null===(n=o.getState().rbacConfig)||void 0===n?void 0:n.applicationResourceId,u=function(r,e){return i.some(function(n){var i,o,t;return s(n.resourceId,e)&&null!==(t=null===(o=null===(i=n.role)||void 0===i?void 0:i.permissions)||void 0===o?void 0:o.some(function(e){return e.name===r}))&&void 0!==t&&t})};return!(!a||!u(r,a))||u(r,e)},hasGlobalPermission:function(r,e){return!!e&&(t().hasApplicationAccess(e)||t().hasPermission(r,e))},hasApplicationAccess:function(r){return!!r&&t().accessData.some(function(e){var n,i,o;return s(e.resourceId,r)&&null!==(o=null===(i=null===(n=e.role)||void 0===n?void 0:n.permissions)||void 0===i?void 0:i.some(function(r){return"ilotj.scope.access.application.user.add"===r.name}))&&void 0!==o&&o})},reset:function(){return n({accessData:[],isLoading:!1,error:null})}}});export{t as usePermissionsStore};
1
+ import{__awaiter as r,__generator as e}from"tslib";import{create as s}from"zustand";import{appsecApi as n}from"../apis/scopeApis.js";import i from"./useEnvStore.js";var t=function(r,e){return!!e&&function(r){return r?"string"==typeof r?[r]:[r._id,r.id,r.resourceId,r.resource_id].filter(function(r){return"string"==typeof r&&r.length>0}):[]}(r).includes(e)},o=function(r,e){for(var s,n,i=new Set,o=0,a=r;o<a.length;o++){var c=a[o];if(t(c.resourceId,e))for(var u=0,l=null!==(n=null===(s=c.role)||void 0===s?void 0:s.permissions)&&void 0!==n?n:[];u<l.length;u++){var d=l[u];i.add(d.name)}}return i},a=s(function(s,t){return{accessData:[],isLoading:!1,error:null,fetchPermissions:function(i,t){return r(void 0,void 0,void 0,function(){var r,o,a;return e(this,function(e){switch(e.label){case 0:if(!i)return[2];s({isLoading:!0,error:null}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.get("/users/me",{params:{appId:i,resourceId:t}})];case 2:return r=e.sent(),s({accessData:(null===(a=r.data)||void 0===a?void 0:a.data)||[],isLoading:!1}),[3,4];case 3:return o=e.sent(),console.error("Failed to fetch permissions:",o),s({error:o.message||"Failed to fetch permissions",isLoading:!1}),[3,4];case 4:return[2]}})})},hasPermission:function(r,e){var s,n=t().accessData,a=null===(s=i.getState().rbacConfig)||void 0===s?void 0:s.applicationResourceId;if(a&&o(n,a).has(r))return!0;if(e&&o(n,e).has(r))return!0;return!1},hasGlobalPermission:function(r,e){return!!e&&(t().hasApplicationAccess(e)||t().hasPermission(r,e))},hasApplicationAccess:function(r){if(!r)return!1;var e=t().accessData;return o(e,r).has("ilotj.scope.access.application.user.add")},reset:function(){return s({accessData:[],isLoading:!1,error:null})}}});export{a as usePermissionsStore};
2
2
  //# sourceMappingURL=usePermissionsStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AddScopeModal.d.ts","sourceRoot":"","sources":["../../../../../../src/features/LearningManagement/RuleContent/AddScopeModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAqB3D,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAC,CAAC,OAAO,CAAC,EAAC,MAAM,KAAG,IAAI,CAAC;IACjC,gBAAgB,EAAC,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAQD,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAuSxD,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"AddScopeModal.d.ts","sourceRoot":"","sources":["../../../../../../src/features/LearningManagement/RuleContent/AddScopeModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAqB3D,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAC,CAAC,OAAO,CAAC,EAAC,MAAM,KAAG,IAAI,CAAC;IACjC,gBAAgB,EAAC,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAQD,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsTxD,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -13,7 +13,8 @@ interface AccessData {
13
13
  resourceId: any;
14
14
  resourceType: any;
15
15
  application: string;
16
- user_email: string;
16
+ groupId?: string;
17
+ user_email?: string;
17
18
  role: Role;
18
19
  grantedBy: string;
19
20
  grantedAt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"usePermissionsStore.d.ts","sourceRoot":"","sources":["../../../../../../src/features/LearningManagement/store/usePermissionsStore.ts"],"names":[],"mappings":"AAOA,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,IAAI;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,GAAG,CAAC;IAChB,YAAY,EAAE,GAAG,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;CACtB;AAmBD,UAAU,gBAAgB;IACxB,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IACxE,mBAAmB,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7E,oBAAoB,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IACvD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB,+EAkE7B,CAAC"}
1
+ {"version":3,"file":"usePermissionsStore.d.ts","sourceRoot":"","sources":["../../../../../../src/features/LearningManagement/store/usePermissionsStore.ts"],"names":[],"mappings":"AAMA,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,IAAI;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,GAAG,CAAC;IAChB,YAAY,EAAE,GAAG,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;CACtB;AA0CD,UAAU,gBAAgB;IACxB,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IACxE,mBAAmB,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7E,oBAAoB,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IACvD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB,+EAqD7B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-llm-studio/instant-learning",
3
- "version": "1.3.0-alpha.20",
3
+ "version": "1.3.0-alpha.22",
4
4
  "author": "Devesh Patel",
5
5
  "description": "",
6
6
  "license": "MIT",