@telia-ace/alliance-utilities 1.1.1-next.0 → 1.1.1-next.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 +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{queryObjects as l}from"@telia-ace/alliance-framework";import{AllianceError as
|
|
1
|
+
import{queryObjects as l}from"@telia-ace/alliance-framework";import{AllianceError as o,FrameworkErrorCodes as u,UtilitiesErrorCodes as a,isAllianceError as p}from"@telia-ace/alliance-internal-client-utilities";async function m(){try{let e=await l("currentUser").resolve();return{...e,hasPermission(r,t){return!!e?.permissions.find(({permission:n})=>n.app.name===r&&n.name===t)},isSystemAdmin(){return!!e&&e.type==="system-admin"}}}catch(e){throw p(e)&&e?.code===u.MissingManagedObjectProvider?new o(a.CurrentUserMissingProvider):e.message?.includes("No User Found")?new o(a.CurrentUserMissingInDatabase):e?.name==="TRPCClientError"&&e.message.includes("is not valid JSON")?new o(a.CurrentUserMissingBackend):e}}import{queryObjects as g}from"@telia-ace/alliance-framework";async function d(){return await g("currentWorkspace").resolve()}import{getAppManifest as f,getAppManifests as y,queryObjects as w}from"@telia-ace/alliance-framework";import{AllianceError as C,FrameworkErrorCodes as E}from"@telia-ace/alliance-internal-client-utilities";function b(e){let r={"app-name":e.name,"app-description":""};return e.resources?.localization?{...Object.keys(e.resources.localization).reduce((s,i)=>(s[i]=e.resources.localization[i].value,s),{}),...r}:r}function k(e="",r){return Object.entries(r).reduce((t,[n,s])=>t.replaceAll(`{{${n}}}`,s),e)}async function R(){let e=f(),r=y(),t=b(e),n={};return r?.find(({name:s})=>s==="resource-management")&&(n=await w("resourceTexts",{app:e?.name}).resolve()),Object.keys(t).reduce((s,i)=>(n[i]&&(s[i]=n[i]),s),t)}var c={};async function U(){return Object.keys(c).length===0&&(c=await R()),(e,r)=>{let t=c[e];if(t===void 0)throw new C(E.LocalizationTemplateNotDefined,{key:e});return!r||typeof r!="object"||Object.keys(r).length===0?t:k(t,r)}}export{m as getCurrentUser,d as getCurrentWorkspace,U as getTranslator};
|