@whoz-oss/coday-client 3.15.0 → 3.16.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/browser/{chunk-CysW_ro-.js → chunk-0OiZWE88.js} +1 -1
- package/browser/{chunk-BhfpLr7-.js → chunk-6gdeYlLc.js} +1 -1
- package/browser/{chunk-B5_o_qhk.js → chunk-7jUQT_3F.js} +1 -1
- package/browser/{chunk-K-fhwl_z.js → chunk-B0vRsgnD.js} +1 -1
- package/browser/{chunk-RxHlNJ_t.js → chunk-BEKR4Un_.js} +1 -1
- package/browser/chunk-BEUXx3TO.js +1 -0
- package/browser/{chunk-Bnic_hdt.js → chunk-BHZY3TvC.js} +5 -5
- package/browser/{chunk-C6RPhP4t.js → chunk-BJYyjaQ6.js} +1 -1
- package/browser/chunk-BJeLQooO.js +1 -0
- package/browser/{chunk-BIMT-HvS.js → chunk-BNS6Fgaw.js} +1 -1
- package/browser/{chunk-BVCQOGLR.js → chunk-BSSDDOqW.js} +2 -2
- package/browser/{chunk-Dd2dq7xg.js → chunk-BTS5TBK0.js} +1 -1
- package/browser/{chunk-B11WEBEl.js → chunk-BUJoEGsf.js} +1 -1
- package/browser/chunk-BY7uKZAo.js +9 -0
- package/browser/{chunk-5t7zJzqM.js → chunk-B_9LxHBv.js} +1 -1
- package/browser/{chunk-DTZ7N3wC.js → chunk-BdApeECy.js} +1 -1
- package/browser/{chunk-BhM0bmJW.js → chunk-BdpJ2ZCM.js} +1 -1
- package/browser/{chunk-CyUmCedx.js → chunk-Be1LOFvg.js} +1 -1
- package/browser/{chunk-CYMQSJz6.js → chunk-Bhq5earA.js} +1 -1
- package/browser/{chunk-C5wr-vqf.js → chunk-Bib1Seeu.js} +1 -1
- package/browser/{chunk-C7MXO6BQ.js → chunk-Bn3R3VC2.js} +5 -5
- package/browser/{chunk-DxxECdrg.js → chunk-C-aF2_1R.js} +2 -2
- package/browser/{chunk-Jv7RGmnK.js → chunk-CBNhmZDS.js} +1 -1
- package/browser/{chunk-DzicJow4.js → chunk-CFZbDe5T.js} +3 -3
- package/browser/{chunk-mHtuxvLs.js → chunk-CGMAzvSo.js} +1 -1
- package/browser/chunk-CPBcDx4G.js +1 -0
- package/browser/{chunk-DYUMiAN8.js → chunk-CTuHnJP4.js} +1 -1
- package/browser/{chunk-n1eKIk8H.js → chunk-CXLytVC3.js} +1 -1
- package/browser/{chunk-5LRyprMF.js → chunk-CYulIMKp.js} +1 -1
- package/browser/{chunk-CyxhAtE7.js → chunk-C_s4Z3Dk.js} +1 -1
- package/browser/{chunk-D_vvo2qx.js → chunk-CbK5Lcu9.js} +1 -1
- package/browser/{chunk-9CSRlx74.js → chunk-CgqDTJ5-.js} +1 -1
- package/browser/{chunk-Dg6QAZUw.js → chunk-Ci1jk71f.js} +2 -2
- package/browser/{chunk-Bh1p6jDj.js → chunk-CiWu4t_i.js} +1 -1
- package/browser/{chunk-CUmS2-ak.js → chunk-CjrWXBiR.js} +1 -1
- package/browser/{chunk-BqKdrvcS.js → chunk-Co81dkbz.js} +1 -1
- package/browser/{chunk-Ce03Ba0V.js → chunk-CtWMrBfw.js} +1 -1
- package/browser/{chunk-l0HLnBLv.js → chunk-CtkiOUdU.js} +6 -6
- package/browser/{chunk-BlWlE-Cq.js → chunk-CwaAd8kk.js} +1 -1
- package/browser/{chunk-Bgy3uCgK.js → chunk-DDnWPYAA.js} +1 -1
- package/browser/{chunk-CHrmSvQM.js → chunk-DOq0u21j.js} +1 -1
- package/browser/{chunk-DX2ZzvT5.js → chunk-DQLU3kYb.js} +1 -1
- package/browser/{chunk-fP29MqaN.js → chunk-Dcftf7UY.js} +1 -1
- package/browser/{chunk-BZMAEe_X.js → chunk-Dfujxxcr.js} +1 -1
- package/browser/chunk-DgrvmqY2.js +2 -0
- package/browser/{chunk-CebS4RAf.js → chunk-DoKoAMs6.js} +1 -1
- package/browser/{chunk-CNIfOUla.js → chunk-Dtu-PLbq.js} +1 -1
- package/browser/{chunk-C4U0w8cP.js → chunk-DzlrRiVM.js} +1 -1
- package/browser/{chunk-BfD1F12k.js → chunk-HjD5Rk4C.js} +3 -3
- package/browser/{chunk-CcLheUaL.js → chunk-IUvEtpfr.js} +1 -1
- package/browser/{chunk-DTIhOEG_.js → chunk-S8F5_Te_.js} +6 -6
- package/browser/{chunk-HSc9fwVS.js → chunk-SbH2L3h2.js} +1 -1
- package/browser/{chunk-BKlwFrFB.js → chunk-UzUd84Qf.js} +1 -1
- package/browser/chunk-YS-vAhPY.js +190 -0
- package/browser/{chunk-BUEM7g7F.js → chunk-YfG457Nc.js} +3 -3
- package/browser/{chunk-DG2FCeMu.js → chunk-axGY7UtD.js} +1 -1
- package/browser/chunk-fYErSEXN.js +1 -0
- package/browser/{chunk-BgHTiTG2.js → chunk-fhFxOLYS.js} +1 -1
- package/browser/{chunk-qARg6ese.js → chunk-gmPqDrDS.js} +1 -1
- package/browser/{chunk-DvzNS1Bs.js → chunk-iNIQR015.js} +1 -1
- package/browser/{chunk-Dj9y_5pr.js → chunk-izARvh_2.js} +1 -1
- package/browser/{chunk-Cf3l2UgA.js → chunk-jv0lz5Ah.js} +1 -1
- package/browser/{chunk-nWqZHM4o.js → chunk-kvCfAm7Z.js} +1 -1
- package/browser/{chunk-ZvcyZV3G.js → chunk-pH1k_bet.js} +1 -1
- package/browser/{chunk-DYE131qf.js → chunk-rwEyLSEP.js} +1 -1
- package/browser/{chunk-XgEfnfT0.js → chunk-swj7IkJA.js} +1 -1
- package/browser/chunk-tTmeIHGS.js +37 -0
- package/browser/index.html +1 -1
- package/browser/{main-6K2UFGD2.js → main-5PAOSHSM.js} +19 -19
- package/package.json +1 -1
- package/browser/chunk-BC0acSZF.js +0 -1
- package/browser/chunk-BLa2Gx7h.js +0 -190
- package/browser/chunk-B_2kLXvG.js +0 -1
- package/browser/chunk-C9tuHQmZ.js +0 -37
- package/browser/chunk-CnnGSYzi.js +0 -2
- package/browser/chunk-DEsz0fzs.js +0 -1
- package/browser/chunk-DXDohTwX.js +0 -1
- package/browser/chunk-uPxETzZs.js +0 -9
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {v}from'./chunk-DEsz0fzs.js';import {R,q,J}from'./chunk-DYE131qf.js';import {g,ao as V,G,w as we,z as zi,F,y as yT,cd as Hf,c as U,a as z$1,b as P$1,h as Rw,I as Is,A as Ag,q as qC,m as pl,t as tC,J as JE,a8 as Zg,v as nC,a9 as fC,o as iC,a4 as oC,a3 as UI,n as bg,ac as yC,T as Tg,a6 as zI,x as sC,a5 as vl,cH as Jw,aa as If,ab as wf,b$ as PC,C as Cg}from'./main-6K2UFGD2.js';import'./chunk-uPxETzZs.js';import {k as _t,b as _e$1,o as z,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,m as mn,Z as Zn,l as Xn,C as Cn,E as En}from'./chunk-C9tuHQmZ.js';import'./chunk-DXDohTwX.js';import'./chunk-nWqZHM4o.js';import'./chunk-l0HLnBLv.js';import'./chunk-DTIhOEG_.js';function se(i,t){i&1&&(Is(0,"p",5),qC(1,"Loading\u2026"),pl());}function ce(i,t){if(i&1&&(Is(0,"label",23),bg(1,"input",24),UI(),Is(2,"span"),qC(3),pl()()),i&2){let e=t.$implicit,o=yC(3);JE(),Tg("formControl",o.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!o.isAdmin()),zI(),JE(2),Zg(e.label);}}function de(i,t){if(i&1&&(Is(0,"fieldset",8)(1,"legend",22),qC(2,"Configuration scope"),pl(),iC(3,ce,4,4,"label",23,Jw().trackByScope,true),pl()),i&2){let e=yC(2);Tg("disabled",e.isEditMode()),JE(3),sC(e.scopeOptions);}}function ue(i,t){if(i&1&&(Is(0,"option",13),qC(1),pl()),i&2){let e=t.$implicit,o=yC(2);Tg("value",e),JE(),Zg(o.authTypeLabel[e]);}}function pe(i,t){i&1&&qC(0," Leave a field unchanged to keep the stored credential. ");}function he(i,t){i&1&&(Is(0,"span",11),qC(1,"*"),pl());}function me(i,t){if(i&1&&(Is(0,"p",28),qC(1),pl()),i&2){let e=yC(2).$implicit;Tg("id","as-hint-"+e.key),JE(),Zg(e.hint);}}function ge(i,t){if(i&1&&(bg(0,"input",27),UI(),tC(1,me,2,2,"p",28)),i&2){let e=yC().$implicit;PC("auth-setting-form__input"+(e.secret?" auth-setting-form__input--secret":"")),Tg("id","as-cred-"+e.key)("type",e.secret?"password":"text")("placeholder",e.placeholder)("formControl",t)("autocomplete",e.secret?"new-password":"off"),Cg("aria-describedby",e.hint?"as-hint-"+e.key:null),zI(),JE(),nC(e.hint?1:-1);}}function Ce(i,t){if(i&1&&(Is(0,"div",9)(1,"label",26),qC(2),tC(3,he,2,0,"span",11),pl(),tC(4,ge,2,9),pl()),i&2){let e,o=t.$implicit,l=yC(3);JE(),Tg("for","as-cred-"+o.key),JE(),vl(" ",o.label," "),JE(),nC(o.required?3:-1),JE(),nC((e=l.controlForField(o.key))?4:-1,e);}}function fe(i,t){if(i&1&&(Is(0,"fieldset",18)(1,"legend",22),qC(2,"Credentials"),pl(),Is(3,"p",25),qC(4," Values are stored encrypted and masked on read. "),tC(5,pe,1,0),pl(),iC(6,Ce,5,4,"div",9,Jw().trackByField,true),pl()),i&2){let e=yC(2);JE(5),nC(e.isEditMode()?5:-1),JE(),sC(e.credentialFields());}}function ye(i,t){if(i&1){let e=fC();Is(0,"form",7),Ag("ngSubmit",function(){If(e);let l=yC();return wf(l.submit())}),tC(1,de,5,1,"fieldset",8),Is(2,"div",9)(3,"label",10),qC(4,"Auth type "),Is(5,"span",11),qC(6,"*"),pl()(),Is(7,"select",12),iC(8,ue,2,2,"option",13,oC),pl(),UI(),pl(),Is(10,"div",9)(11,"label",14),qC(12,"Name "),Is(13,"span",11),qC(14,"*"),pl()(),bg(15,"input",15),UI(),pl(),Is(16,"div",9)(17,"label",16),qC(18,"Description"),pl(),bg(19,"input",17),UI(),pl(),tC(20,fe,8,1,"fieldset",18),Is(21,"div",19)(22,"button",20),qC(23),pl(),Is(24,"button",21),Ag("click",function(){If(e);let l=yC();return wf(l.cancel())}),qC(25,"Cancel"),pl()()();}if(i&2){let e=yC();Tg("formGroup",e.form),JE(),nC(e.isPlatformMode?-1:1),JE(6),Tg("formControl",e.authTypeControl),zI(),JE(),sC(e.authTypeOptions),JE(7),Tg("formControl",e.nameControl),zI(),JE(4),Tg("formControl",e.descriptionControl),zI(),JE(),nC(e.credentialFields().length>0?20:-1),JE(2),Tg("disabled",e.form.invalid||e.isSubmitting()),JE(),vl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var _e=new Set(["namespace","userOnNs","userGlobal"]),P=Object.freeze({platform:"Platform (read-only)",namespace:"Namespace configuration",userOnNs:"Personal \u2014 this namespace only",userGlobal:"Personal \u2014 all namespaces"}),Se={ApiKeyAuthSetting:[{key:"apiKey",label:"API Key",placeholder:"sk-\u2026",secret:true,required:false}],BasicAuthAuthSetting:[{key:"username",label:"Username",placeholder:"user@example.com",secret:false,required:false},{key:"password",label:"Password",placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",secret:true,required:false}],BearerTokenAuthSetting:[{key:"token",label:"Bearer token",placeholder:"eyJ\u2026",secret:true,required:false}],OAuthDiscoverableAuthSetting:[{key:"discoveryUrl",label:"Discovery URL",placeholder:"https://\u2026/.well-known/openid-configuration",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthCustomAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthRegisteredAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthMcpDiscoverableAuthSetting:[{key:"resourceUrl",label:"Resource URL",placeholder:"https://mcp.example.com",hint:"Use the base URL exactly as documented by your provider \u2014 do not append a path suffix. Examples: https://mcp.hubspot.com (HubSpot), https://mcp.atlassian.com/v1/mcp (Atlassian).",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",hint:"Leave empty to let the server register an OAuth client automatically (RFC 7591 dynamic registration). Fill in only if you have a pre-registered client ID from your provider.",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Leave empty in most cases \u2014 the MCP server declares the required scopes itself. Fill in only if your provider explicitly requires client-declared scopes.",secret:false,required:false}]},le=class i{route=g(V);router=g(G);destroyRef=g(we);state=g(R);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?zi(true):F(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});authTypeOptions=q;authTypeLabel=J;scopeOptions=[{value:"namespace",label:P.namespace},{value:"userOnNs",label:P.userOnNs},{value:"userGlobal",label:P.userGlobal}];nameControl=new _t("",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]});descriptionControl=new _t(null);authTypeControl=new _t("ApiKeyAuthSetting",{nonNullable:true,validators:[_e$1.required]});scopeControl=new _t("namespace",{nonNullable:true});form=new z({name:this.nameControl,description:this.descriptionControl,authType:this.authTypeControl,scope:this.scopeControl});apiKeyControl=new _t("",{nonNullable:true});usernameControl=new _t("",{nonNullable:true});passwordControl=new _t("",{nonNullable:true});tokenControl=new _t("",{nonNullable:true});discoveryUrlControl=new _t("",{nonNullable:true});authorizationUrlControl=new _t("",{nonNullable:true});tokenUrlControl=new _t("",{nonNullable:true});clientIdControl=new _t("",{nonNullable:true});clientSecretControl=new _t("",{nonNullable:true});scopesControl=new _t("",{nonNullable:true});resourceUrlControl=new _t("",{nonNullable:true});selectedAuthType=F(this.authTypeControl.valueChanges,{initialValue:this.authTypeControl.value});credentialFields=yT(()=>Se[this.selectedAuthType()]);isEditMode=zi(false);isSubmitting=zi(false);isLoading=zi(false);existingConfig=null;initialCredentials={};constructor(){this.isPlatformMode||Hf(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,o=t.get("authSettingId");if(o){this.isEditMode.set(true),this.scopeControl.disable(),this.authTypeControl.disable(),this.loadConfig(o);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let l=this.parseScope(e.get("scope"));this.scopeControl.setValue(l);let v=e.get("template");v&&this.hydrateFromTemplate(v);}parseScope(t){return t&&_e.has(t)?t:"namespace"}deriveScopeFromConfig(t){return !t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[AuthSettingForm] Could not load auth setting '${t}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.authTypeControl.setValue(e.authType),this.clearCredentialControls(),this.initialCredentials={},this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[AuthSettingForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(t){switch(this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.authTypeControl.setValue(t.authType),this.clearCredentialControls(),this.initialCredentials={},t.authType){case "ApiKeyAuthSetting":{let e=t.apiKey??"";this.apiKeyControl.setValue(e),this.initialCredentials.apiKey=e;break}case "BasicAuthAuthSetting":{let e=t,o=e.username??"",l=e.password??"";this.usernameControl.setValue(o),this.passwordControl.setValue(l),this.initialCredentials.username=o,this.initialCredentials.password=l;break}case "BearerTokenAuthSetting":{let e=t.token??"";this.tokenControl.setValue(e),this.initialCredentials.token=e;break}case "OAuthDiscoverableAuthSetting":{let e=t;this.discoveryUrlControl.setValue(e.discoveryUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.discoveryUrl=e.discoveryUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthCustomAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthRegisteredAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthMcpDiscoverableAuthSetting":{let e=t;this.resourceUrlControl.setValue(e.resourceUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.resourceUrl=e.resourceUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}}}clearCredentialControls(){this.apiKeyControl.setValue(""),this.usernameControl.setValue(""),this.passwordControl.setValue(""),this.tokenControl.setValue(""),this.discoveryUrlControl.setValue(""),this.authorizationUrlControl.setValue(""),this.tokenUrlControl.setValue(""),this.clientIdControl.setValue(""),this.clientSecretControl.setValue(""),this.scopesControl.setValue(""),this.resourceUrlControl.setValue("");}credentialValue(t,e){if(!(this.isEditMode()&&e===this.initialCredentials[t]))return e||void 0}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let t=this.nameControl.value.trim(),e=this.descriptionControl.value?.trim()||void 0,o=this.authTypeControl.value,l=this.form.getRawValue().scope,v=this.isPlatformMode?null:this.namespaceId??null,w=this.buildTypedPayload(o,t,e);(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,w,this.existingConfig):this.state.create(w,l,v)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}buildTypedPayload(t,e,o){let l={name:e,description:o};switch(t){case "ApiKeyAuthSetting":return z$1(P$1({},l),{authType:"ApiKeyAuthSetting",apiKey:this.credentialValue("apiKey",this.apiKeyControl.value)});case "BasicAuthAuthSetting":return z$1(P$1({},l),{authType:"BasicAuthAuthSetting",username:this.credentialValue("username",this.usernameControl.value),password:this.credentialValue("password",this.passwordControl.value)});case "BearerTokenAuthSetting":return z$1(P$1({},l),{authType:"BearerTokenAuthSetting",token:this.credentialValue("token",this.tokenControl.value)});case "OAuthDiscoverableAuthSetting":return z$1(P$1({},l),{authType:"OAuthDiscoverableAuthSetting",discoveryUrl:this.credentialValue("discoveryUrl",this.discoveryUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthCustomAuthSetting":return z$1(P$1({},l),{authType:"OAuthCustomAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthRegisteredAuthSetting":return z$1(P$1({},l),{authType:"OAuthRegisteredAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthMcpDiscoverableAuthSetting":return z$1(P$1({},l),{authType:"OAuthMcpDiscoverableAuthSetting",resourceUrl:this.credentialValue("resourceUrl",this.resourceUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)})}}controlForField(t){return {apiKey:this.apiKeyControl,username:this.usernameControl,password:this.passwordControl,token:this.tokenControl,discoveryUrl:this.discoveryUrlControl,authorizationUrl:this.authorizationUrlControl,tokenUrl:this.tokenUrlControl,clientId:this.clientIdControl,clientSecret:this.clientSecretControl,scopes:this.scopesControl,resourceUrl:this.resourceUrlControl}[t]}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","auth-settings"]):this.router.navigate(["/agentos",this.namespaceId,"auth-settings"]);}trackByScope(t,e){return e.value}trackByField(t,e){return e.key}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=Rw({type:i,selectors:[["agentos-auth-setting-form"]],decls:10,vars:2,consts:[[1,"auth-setting-form"],[1,"auth-setting-form__header"],["type","button","title","Back to auth settings",1,"auth-setting-form__back",3,"click"],[1,"auth-setting-form__back-icon"],[1,"auth-setting-form__title"],[1,"auth-setting-form__loading"],[1,"auth-setting-form__form",3,"formGroup"],[1,"auth-setting-form__form",3,"ngSubmit","formGroup"],[1,"auth-setting-form__scope",3,"disabled"],[1,"auth-setting-form__field"],["for","as-auth-type",1,"auth-setting-form__label"],["aria-hidden","true"],["id","as-auth-type",1,"auth-setting-form__select",3,"formControl"],[3,"value"],["for","as-name",1,"auth-setting-form__label"],["id","as-name","type","text","placeholder","e.g. GitHub OAuth App","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],["for","as-description",1,"auth-setting-form__label"],["id","as-description","type","text","placeholder","Optional \u2014 short description of this auth setting","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],[1,"auth-setting-form__credentials"],[1,"auth-setting-form__actions"],["type","submit",1,"auth-setting-form__btn","auth-setting-form__btn--primary",3,"disabled"],["type","button",1,"auth-setting-form__btn",3,"click"],[1,"auth-setting-form__label"],[1,"auth-setting-form__scope-option"],["type","radio",3,"formControl","value","disabled"],[1,"auth-setting-form__credentials-hint"],[1,"auth-setting-form__label",3,"for"],[3,"id","type","placeholder","formControl","autocomplete"],[1,"auth-setting-form__field-hint",3,"id"]],template:function(e,o){e&1&&(Is(0,"div",0)(1,"header",1)(2,"button",2),Ag("click",function(){return o.cancel()}),Is(3,"span",3),qC(4,"\u2190"),pl(),qC(5," Auth Settings "),pl(),Is(6,"h1",4),qC(7),pl()(),tC(8,se,2,0,"p",5)(9,ye,26,8,"form",6),pl()),e&2&&(JE(7),Zg(o.isEditMode()?"Edit auth setting":"New auth setting"),JE(),nC(o.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,mn,Zn,Xn,Cn,En],styles:[".auth-setting-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;padding:1.5rem;max-width:640px}.auth-setting-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.4rem;background:none;border:none;cursor:pointer;color:var(--color-text-secondary);font-size:.85rem;padding:0}.auth-setting-form__back[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.auth-setting-form__back-icon[_ngcontent-%COMP%]{font-size:1rem}.auth-setting-form__title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:600;color:var(--color-text);margin:0}.auth-setting-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem}.auth-setting-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.auth-setting-form__scope[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem;display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__scope[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9rem;color:var(--color-text)}.auth-setting-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem}.auth-setting-form__field-hint[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary);margin:0;line-height:1.4}.auth-setting-form__label[_ngcontent-%COMP%]{font-size:.85rem;font-weight:500;color:var(--color-text-secondary)}.auth-setting-form__input[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;transition:border-color .15s ease;width:100%;box-sizing:border-box}.auth-setting-form__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.auth-setting-form__select[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;cursor:pointer;transition:border-color .15s ease}.auth-setting-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__credentials[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem 1rem;display:flex;flex-direction:column;gap:.75rem;margin:0}.auth-setting-form__credentials[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__credentials-hint[_ngcontent-%COMP%]{font-size:.78rem;color:var(--color-text-secondary);margin:0}.auth-setting-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center;padding-top:.5rem}.auth-setting-form__btn[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem 1.25rem;cursor:pointer;font-size:.9rem;font-weight:500;background:var(--color-bg-secondary);color:var(--color-text);transition:background .15s ease}.auth-setting-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.auth-setting-form__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.auth-setting-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-on-primary, #fff);border-color:var(--color-primary)}.auth-setting-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, var(--color-primary))}"]})};
|
|
1
|
+
import {v}from'./chunk-CPBcDx4G.js';import {R,q,J}from'./chunk-rwEyLSEP.js';import {g,ao as V,G,w as we,a as Gi,F,E as ET,cd as Uf,c as U,z as z$1,b as P$1,h as Fw,m as ws,o as Rg,Q as QC,n as hl,q as oC,t as nI,a8 as Yg,x as iC,a9 as gC,r as cC,a4 as aC,a3 as GI,S as Sg,ac as EC,v as bg,a6 as qI,y as uC,a5 as Dl,cH as nC,aa as wf,ab as Cf,b$ as BC,T as Tg}from'./main-5PAOSHSM.js';import'./chunk-BY7uKZAo.js';import {k as _t,b as _e$1,o as z,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,m as mn,Z as Zn,l as Xn,C as Cn,E as En}from'./chunk-tTmeIHGS.js';import'./chunk-BEUXx3TO.js';import'./chunk-kvCfAm7Z.js';import'./chunk-CtkiOUdU.js';import'./chunk-S8F5_Te_.js';function se(i,t){i&1&&(ws(0,"p",5),QC(1,"Loading\u2026"),hl());}function ce(i,t){if(i&1&&(ws(0,"label",23),Sg(1,"input",24),GI(),ws(2,"span"),QC(3),hl()()),i&2){let e=t.$implicit,o=EC(3);nI(),bg("formControl",o.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!o.isAdmin()),qI(),nI(2),Yg(e.label);}}function de(i,t){if(i&1&&(ws(0,"fieldset",8)(1,"legend",22),QC(2,"Configuration scope"),hl(),cC(3,ce,4,4,"label",23,nC().trackByScope,true),hl()),i&2){let e=EC(2);bg("disabled",e.isEditMode()),nI(3),uC(e.scopeOptions);}}function ue(i,t){if(i&1&&(ws(0,"option",13),QC(1),hl()),i&2){let e=t.$implicit,o=EC(2);bg("value",e),nI(),Yg(o.authTypeLabel[e]);}}function pe(i,t){i&1&&QC(0," Leave a field unchanged to keep the stored credential. ");}function he(i,t){i&1&&(ws(0,"span",11),QC(1,"*"),hl());}function me(i,t){if(i&1&&(ws(0,"p",28),QC(1),hl()),i&2){let e=EC(2).$implicit;bg("id","as-hint-"+e.key),nI(),Yg(e.hint);}}function ge(i,t){if(i&1&&(Sg(0,"input",27),GI(),oC(1,me,2,2,"p",28)),i&2){let e=EC().$implicit;BC("auth-setting-form__input"+(e.secret?" auth-setting-form__input--secret":"")),bg("id","as-cred-"+e.key)("type",e.secret?"password":"text")("placeholder",e.placeholder)("formControl",t)("autocomplete",e.secret?"new-password":"off"),Tg("aria-describedby",e.hint?"as-hint-"+e.key:null),qI(),nI(),iC(e.hint?1:-1);}}function Ce(i,t){if(i&1&&(ws(0,"div",9)(1,"label",26),QC(2),oC(3,he,2,0,"span",11),hl(),oC(4,ge,2,9),hl()),i&2){let e,o=t.$implicit,l=EC(3);nI(),bg("for","as-cred-"+o.key),nI(),Dl(" ",o.label," "),nI(),iC(o.required?3:-1),nI(),iC((e=l.controlForField(o.key))?4:-1,e);}}function fe(i,t){if(i&1&&(ws(0,"fieldset",18)(1,"legend",22),QC(2,"Credentials"),hl(),ws(3,"p",25),QC(4," Values are stored encrypted and masked on read. "),oC(5,pe,1,0),hl(),cC(6,Ce,5,4,"div",9,nC().trackByField,true),hl()),i&2){let e=EC(2);nI(5),iC(e.isEditMode()?5:-1),nI(),uC(e.credentialFields());}}function ye(i,t){if(i&1){let e=gC();ws(0,"form",7),Rg("ngSubmit",function(){wf(e);let l=EC();return Cf(l.submit())}),oC(1,de,5,1,"fieldset",8),ws(2,"div",9)(3,"label",10),QC(4,"Auth type "),ws(5,"span",11),QC(6,"*"),hl()(),ws(7,"select",12),cC(8,ue,2,2,"option",13,aC),hl(),GI(),hl(),ws(10,"div",9)(11,"label",14),QC(12,"Name "),ws(13,"span",11),QC(14,"*"),hl()(),Sg(15,"input",15),GI(),hl(),ws(16,"div",9)(17,"label",16),QC(18,"Description"),hl(),Sg(19,"input",17),GI(),hl(),oC(20,fe,8,1,"fieldset",18),ws(21,"div",19)(22,"button",20),QC(23),hl(),ws(24,"button",21),Rg("click",function(){wf(e);let l=EC();return Cf(l.cancel())}),QC(25,"Cancel"),hl()()();}if(i&2){let e=EC();bg("formGroup",e.form),nI(),iC(e.isPlatformMode?-1:1),nI(6),bg("formControl",e.authTypeControl),qI(),nI(),uC(e.authTypeOptions),nI(7),bg("formControl",e.nameControl),qI(),nI(4),bg("formControl",e.descriptionControl),qI(),nI(),iC(e.credentialFields().length>0?20:-1),nI(2),bg("disabled",e.form.invalid||e.isSubmitting()),nI(),Dl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var _e=new Set(["namespace","userOnNs","userGlobal"]),P=Object.freeze({platform:"Platform (read-only)",namespace:"Namespace configuration",userOnNs:"Personal \u2014 this namespace only",userGlobal:"Personal \u2014 all namespaces"}),Se={ApiKeyAuthSetting:[{key:"apiKey",label:"API Key",placeholder:"sk-\u2026",secret:true,required:false}],BasicAuthAuthSetting:[{key:"username",label:"Username",placeholder:"user@example.com",secret:false,required:false},{key:"password",label:"Password",placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",secret:true,required:false}],BearerTokenAuthSetting:[{key:"token",label:"Bearer token",placeholder:"eyJ\u2026",secret:true,required:false}],OAuthDiscoverableAuthSetting:[{key:"discoveryUrl",label:"Discovery URL",placeholder:"https://\u2026/.well-known/openid-configuration",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthCustomAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthRegisteredAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthMcpDiscoverableAuthSetting:[{key:"resourceUrl",label:"Resource URL",placeholder:"https://mcp.example.com",hint:"Use the base URL exactly as documented by your provider \u2014 do not append a path suffix. Examples: https://mcp.hubspot.com (HubSpot), https://mcp.atlassian.com/v1/mcp (Atlassian).",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",hint:"Leave empty to let the server register an OAuth client automatically (RFC 7591 dynamic registration). Fill in only if you have a pre-registered client ID from your provider.",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Leave empty in most cases \u2014 the MCP server declares the required scopes itself. Fill in only if your provider explicitly requires client-declared scopes.",secret:false,required:false}]},le=class i{route=g(V);router=g(G);destroyRef=g(we);state=g(R);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?Gi(true):F(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});authTypeOptions=q;authTypeLabel=J;scopeOptions=[{value:"namespace",label:P.namespace},{value:"userOnNs",label:P.userOnNs},{value:"userGlobal",label:P.userGlobal}];nameControl=new _t("",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]});descriptionControl=new _t(null);authTypeControl=new _t("ApiKeyAuthSetting",{nonNullable:true,validators:[_e$1.required]});scopeControl=new _t("namespace",{nonNullable:true});form=new z({name:this.nameControl,description:this.descriptionControl,authType:this.authTypeControl,scope:this.scopeControl});apiKeyControl=new _t("",{nonNullable:true});usernameControl=new _t("",{nonNullable:true});passwordControl=new _t("",{nonNullable:true});tokenControl=new _t("",{nonNullable:true});discoveryUrlControl=new _t("",{nonNullable:true});authorizationUrlControl=new _t("",{nonNullable:true});tokenUrlControl=new _t("",{nonNullable:true});clientIdControl=new _t("",{nonNullable:true});clientSecretControl=new _t("",{nonNullable:true});scopesControl=new _t("",{nonNullable:true});resourceUrlControl=new _t("",{nonNullable:true});selectedAuthType=F(this.authTypeControl.valueChanges,{initialValue:this.authTypeControl.value});credentialFields=ET(()=>Se[this.selectedAuthType()]);isEditMode=Gi(false);isSubmitting=Gi(false);isLoading=Gi(false);existingConfig=null;initialCredentials={};constructor(){this.isPlatformMode||Uf(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,o=t.get("authSettingId");if(o){this.isEditMode.set(true),this.scopeControl.disable(),this.authTypeControl.disable(),this.loadConfig(o);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let l=this.parseScope(e.get("scope"));this.scopeControl.setValue(l);let v=e.get("template");v&&this.hydrateFromTemplate(v);}parseScope(t){return t&&_e.has(t)?t:"namespace"}deriveScopeFromConfig(t){return !t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[AuthSettingForm] Could not load auth setting '${t}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.authTypeControl.setValue(e.authType),this.clearCredentialControls(),this.initialCredentials={},this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[AuthSettingForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(t){switch(this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.authTypeControl.setValue(t.authType),this.clearCredentialControls(),this.initialCredentials={},t.authType){case "ApiKeyAuthSetting":{let e=t.apiKey??"";this.apiKeyControl.setValue(e),this.initialCredentials.apiKey=e;break}case "BasicAuthAuthSetting":{let e=t,o=e.username??"",l=e.password??"";this.usernameControl.setValue(o),this.passwordControl.setValue(l),this.initialCredentials.username=o,this.initialCredentials.password=l;break}case "BearerTokenAuthSetting":{let e=t.token??"";this.tokenControl.setValue(e),this.initialCredentials.token=e;break}case "OAuthDiscoverableAuthSetting":{let e=t;this.discoveryUrlControl.setValue(e.discoveryUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.discoveryUrl=e.discoveryUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthCustomAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthRegisteredAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthMcpDiscoverableAuthSetting":{let e=t;this.resourceUrlControl.setValue(e.resourceUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.resourceUrl=e.resourceUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}}}clearCredentialControls(){this.apiKeyControl.setValue(""),this.usernameControl.setValue(""),this.passwordControl.setValue(""),this.tokenControl.setValue(""),this.discoveryUrlControl.setValue(""),this.authorizationUrlControl.setValue(""),this.tokenUrlControl.setValue(""),this.clientIdControl.setValue(""),this.clientSecretControl.setValue(""),this.scopesControl.setValue(""),this.resourceUrlControl.setValue("");}credentialValue(t,e){if(!(this.isEditMode()&&e===this.initialCredentials[t]))return e||void 0}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let t=this.nameControl.value.trim(),e=this.descriptionControl.value?.trim()||void 0,o=this.authTypeControl.value,l=this.form.getRawValue().scope,v=this.isPlatformMode?null:this.namespaceId??null,w=this.buildTypedPayload(o,t,e);(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,w,this.existingConfig):this.state.create(w,l,v)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}buildTypedPayload(t,e,o){let l={name:e,description:o};switch(t){case "ApiKeyAuthSetting":return z$1(P$1({},l),{authType:"ApiKeyAuthSetting",apiKey:this.credentialValue("apiKey",this.apiKeyControl.value)});case "BasicAuthAuthSetting":return z$1(P$1({},l),{authType:"BasicAuthAuthSetting",username:this.credentialValue("username",this.usernameControl.value),password:this.credentialValue("password",this.passwordControl.value)});case "BearerTokenAuthSetting":return z$1(P$1({},l),{authType:"BearerTokenAuthSetting",token:this.credentialValue("token",this.tokenControl.value)});case "OAuthDiscoverableAuthSetting":return z$1(P$1({},l),{authType:"OAuthDiscoverableAuthSetting",discoveryUrl:this.credentialValue("discoveryUrl",this.discoveryUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthCustomAuthSetting":return z$1(P$1({},l),{authType:"OAuthCustomAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthRegisteredAuthSetting":return z$1(P$1({},l),{authType:"OAuthRegisteredAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthMcpDiscoverableAuthSetting":return z$1(P$1({},l),{authType:"OAuthMcpDiscoverableAuthSetting",resourceUrl:this.credentialValue("resourceUrl",this.resourceUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)})}}controlForField(t){return {apiKey:this.apiKeyControl,username:this.usernameControl,password:this.passwordControl,token:this.tokenControl,discoveryUrl:this.discoveryUrlControl,authorizationUrl:this.authorizationUrlControl,tokenUrl:this.tokenUrlControl,clientId:this.clientIdControl,clientSecret:this.clientSecretControl,scopes:this.scopesControl,resourceUrl:this.resourceUrlControl}[t]}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","auth-settings"]):this.router.navigate(["/agentos",this.namespaceId,"auth-settings"]);}trackByScope(t,e){return e.value}trackByField(t,e){return e.key}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=Fw({type:i,selectors:[["agentos-auth-setting-form"]],decls:10,vars:2,consts:[[1,"auth-setting-form"],[1,"auth-setting-form__header"],["type","button","title","Back to auth settings",1,"auth-setting-form__back",3,"click"],[1,"auth-setting-form__back-icon"],[1,"auth-setting-form__title"],[1,"auth-setting-form__loading"],[1,"auth-setting-form__form",3,"formGroup"],[1,"auth-setting-form__form",3,"ngSubmit","formGroup"],[1,"auth-setting-form__scope",3,"disabled"],[1,"auth-setting-form__field"],["for","as-auth-type",1,"auth-setting-form__label"],["aria-hidden","true"],["id","as-auth-type",1,"auth-setting-form__select",3,"formControl"],[3,"value"],["for","as-name",1,"auth-setting-form__label"],["id","as-name","type","text","placeholder","e.g. GitHub OAuth App","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],["for","as-description",1,"auth-setting-form__label"],["id","as-description","type","text","placeholder","Optional \u2014 short description of this auth setting","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],[1,"auth-setting-form__credentials"],[1,"auth-setting-form__actions"],["type","submit",1,"auth-setting-form__btn","auth-setting-form__btn--primary",3,"disabled"],["type","button",1,"auth-setting-form__btn",3,"click"],[1,"auth-setting-form__label"],[1,"auth-setting-form__scope-option"],["type","radio",3,"formControl","value","disabled"],[1,"auth-setting-form__credentials-hint"],[1,"auth-setting-form__label",3,"for"],[3,"id","type","placeholder","formControl","autocomplete"],[1,"auth-setting-form__field-hint",3,"id"]],template:function(e,o){e&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return o.cancel()}),ws(3,"span",3),QC(4,"\u2190"),hl(),QC(5," Auth Settings "),hl(),ws(6,"h1",4),QC(7),hl()(),oC(8,se,2,0,"p",5)(9,ye,26,8,"form",6),hl()),e&2&&(nI(7),Yg(o.isEditMode()?"Edit auth setting":"New auth setting"),nI(),iC(o.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,mn,Zn,Xn,Cn,En],styles:[".auth-setting-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;padding:1.5rem;max-width:640px}.auth-setting-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.4rem;background:none;border:none;cursor:pointer;color:var(--color-text-secondary);font-size:.85rem;padding:0}.auth-setting-form__back[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.auth-setting-form__back-icon[_ngcontent-%COMP%]{font-size:1rem}.auth-setting-form__title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:600;color:var(--color-text);margin:0}.auth-setting-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem}.auth-setting-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.auth-setting-form__scope[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem;display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__scope[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9rem;color:var(--color-text)}.auth-setting-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem}.auth-setting-form__field-hint[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary);margin:0;line-height:1.4}.auth-setting-form__label[_ngcontent-%COMP%]{font-size:.85rem;font-weight:500;color:var(--color-text-secondary)}.auth-setting-form__input[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;transition:border-color .15s ease;width:100%;box-sizing:border-box}.auth-setting-form__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.auth-setting-form__select[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;cursor:pointer;transition:border-color .15s ease}.auth-setting-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__credentials[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem 1rem;display:flex;flex-direction:column;gap:.75rem;margin:0}.auth-setting-form__credentials[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__credentials-hint[_ngcontent-%COMP%]{font-size:.78rem;color:var(--color-text-secondary);margin:0}.auth-setting-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center;padding-top:.5rem}.auth-setting-form__btn[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem 1.25rem;cursor:pointer;font-size:.9rem;font-weight:500;background:var(--color-bg-secondary);color:var(--color-text);transition:background .15s ease}.auth-setting-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.auth-setting-form__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.auth-setting-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-on-primary, #fff);border-color:var(--color-primary)}.auth-setting-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, var(--color-primary))}"]})};
|
|
2
2
|
export{le as AuthSettingFormComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {v}from'./chunk-DEsz0fzs.js';import {R}from'./chunk-DYE131qf.js';import {N as N$1}from'./chunk-CyUmCedx.js';import {g,ao as V,G,w as we,d6 as F,F as F$1,X as br,z as zi,y as yT,cd as Hf,c as U,h as Rw,I as Is,A as Ag,q as qC,m as pl,t as tC,J as JE,a8 as Zg,v as nC,a9 as fC,o as iC,cH as Jw,a3 as UI,n as bg,a4 as oC,ac as yC,T as Tg,x as sC,a6 as zI,a5 as vl,aa as If,ab as wf}from'./main-6K2UFGD2.js';import'./chunk-uPxETzZs.js';import {n as nt}from'./chunk-l0HLnBLv.js';import'./chunk-DTIhOEG_.js';import {o as z,k as _t,b as _e,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,m as mn,Z as Zn,l as Xn,C as Cn,E as En}from'./chunk-C9tuHQmZ.js';import'./chunk-DXDohTwX.js';import'./chunk-nWqZHM4o.js';function ae(r,t){r&1&&(Is(0,"p",5),qC(1,"Loading\u2026"),pl());}function le(r,t){if(r&1&&(Is(0,"label",10),bg(1,"input",29),UI(),Is(2,"span"),qC(3),pl()()),r&2){let e=t.$implicit,n=yC(2);JE(),Tg("value",e.value)("formControl",n.scopeControl)("disabled",e.value==="namespace"&&!n.isAdmin()),zI(),JE(2),Zg(e.label);}}function se(r,t){if(r&1&&(Is(0,"option",16),qC(1),pl()),r&2){let e=t.$implicit;Tg("value",e.type),JE(),Zg(e.displayName);}}function ce(r,t){if(r&1&&(Is(0,"option",16),qC(1),pl()),r&2){let e=t.$implicit;Tg("value",e),JE(),Zg(e);}}function me(r,t){if(r&1){let e=fC();Is(0,"div",24)(1,"ds-json-schema-form",30),Ag("valueChange",function(s){If(e);let m=yC(2);return wf(m.onParamsChange(s))}),pl()();}if(r&2){let e=yC(2);JE(),Tg("schema",t)("value",e.initialParams());}}function de(r,t){if(r&1){let e=fC();Is(0,"button",31),Ag("click",function(){If(e);let s=yC(2);return wf(s.exportYaml())}),qC(1),pl();}if(r&2){let e=yC(2);Tg("disabled",e.isExporting()),JE(),vl(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function pe(r,t){if(r&1){let e=fC();Is(0,"form",7),Ag("ngSubmit",function(){If(e);let s=yC();return wf(s.submit())}),Is(1,"fieldset",8)(2,"legend",9),qC(3,"Scope"),pl(),iC(4,le,4,4,"label",10,Jw().trackByScope,true),pl(),Is(6,"div",11)(7,"label",12),qC(8,"Type "),Is(9,"span",13),qC(10,"*"),pl()(),Is(11,"select",14)(12,"option",15),qC(13,"Select type"),pl(),iC(14,se,2,2,"option",16,Jw().trackByType,true),pl(),UI(),pl(),Is(16,"div",11)(17,"label",17),qC(18,"Name "),Is(19,"span",13),qC(20,"*"),pl()(),bg(21,"input",18),UI(),pl(),Is(22,"div",11)(23,"label",19),qC(24,"Description"),pl(),bg(25,"textarea",20),UI(),pl(),Is(26,"div",11)(27,"label",21),qC(28,"Auth Setting"),pl(),Is(29,"select",22)(30,"option",23),qC(31,"None"),pl(),iC(32,ce,2,2,"option",16,oC),pl(),UI(),pl(),tC(34,me,2,2,"div",24),Is(35,"div",25)(36,"button",26),qC(37),pl(),tC(38,de,2,2,"button",27),Is(39,"button",28),Ag("click",function(){If(e);let s=yC();return wf(s.cancel())}),qC(40,"Cancel"),pl()()();}if(r&2){let e,n=yC();Tg("formGroup",n.form),JE(),Tg("disabled",n.isEditMode()),JE(3),sC(n.scopeOptions),JE(7),Tg("formControl",n.typeControl),zI(),JE(3),sC(n.integrationTypes()),JE(7),Tg("formControl",n.nameControl),zI(),JE(4),Tg("formControl",n.descriptionControl),zI(),JE(4),Tg("formControl",n.authSettingNameControl),zI(),JE(),Tg("ngValue",null),JE(2),sC(n.availableAuthSettings()),JE(2),nC((e=n.schema())?34:-1,e),JE(2),Tg("disabled",n.nameControl.invalid||n.typeControl.invalid||n.isSubmitting()),JE(),vl(" ",n.isEditMode()?"Save changes":"Create"," "),JE(),nC(n.isEditMode()?38:-1);}}var ge=new Set(["platform","namespace","userOnNs","userGlobal"]),N=Object.freeze({platform:"Configuration plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ie=class r{route=g(V);router=g(G);destroyRef=g(we);state=g(N$1);integrationTypeController=g(F);authSettingState=g(R);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isAdmin=F$1(this.isPlatformMode?br(true):this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:this.isPlatformMode});form=new z({name:new _t("",{nonNullable:true,validators:[_e.required,_e.minLength(1)]}),description:new _t(null),type:new _t("",{nonNullable:true,validators:[_e.required]}),scope:new _t("namespace",{nonNullable:true})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get typeControl(){return this.form.controls.type}get scopeControl(){return this.form.controls.scope}isEditMode=zi(false);isSubmitting=zi(false);isLoading=zi(false);isExporting=zi(false);scopeOptions=[{value:"platform",label:N.platform},{value:"namespace",label:N.namespace},{value:"userOnNs",label:N.userOnNs},{value:"userGlobal",label:N.userGlobal}];authSettingNameControl=new _t(null);availableAuthSettings=zi([]);paramsValue=zi(null);initialParams=zi(null);integrationTypes=F$1(this.integrationTypeController.listTypesIntegrationType(),{initialValue:[]});selectedType=F$1(this.form.controls.type.valueChanges,{initialValue:this.form.controls.type.value});schema=yT(()=>{let t=this.selectedType();return t?this.integrationTypes().find(n=>n.type===t)?.configSchema??null:null});existingConfig=null;constructor(){Hf(()=>{if(this.isAdmin()||this.isEditMode())return;["platform","namespace"].includes(this.scopeControl.value)&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,n=t.get("integrationId");if(n){this.isEditMode.set(true),this.scopeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable(),this.loadAuthSettingsForScope("platform");return}let s=this.parseScope(e.get("scope"));this.scopeControl.setValue(s),this.loadAuthSettingsForScope(s),this.scopeControl.valueChanges.pipe(U(this.destroyRef)).subscribe(re=>{this.loadAuthSettingsForScope(re);});let m=e.get("template");m&&this.hydrateFromTemplate(m);}parseScope(t){return t&&ge.has(t)?t:"namespace"}deriveScopeFromConfig(t){return !t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e;let n=this.deriveScopeFromConfig(e);this.scopeControl.setValue(n),this.applyConfigToForm(e),this.loadAuthSettingsForScope(n),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[IntegrationForm] Could not load config '${t}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.applyConfigToForm(e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[IntegrationForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.typeControl.setValue(t.integrationType),this.initialParams.set(t.parameters),this.paramsValue.set(t.parameters),this.authSettingNameControl.setValue(t.authSettingName??null);}loadAuthSettingsForScope(t){let e;switch(t){case "platform":e=this.authSettingState.loadPlatformSettings();break;case "namespace":e=this.authSettingState.loadNamespaceSettings(this.namespaceId);break;case "userOnNs":e=this.authSettingState.loadUserSettings(this.namespaceId);break;case "userGlobal":e=this.authSettingState.loadUserSettings("global");break}e.pipe(U(this.destroyRef)).subscribe({next:n=>{let s=n.map(m=>m.name).filter(Boolean);this.availableAuthSettings.set([...new Set(s)]);},error:()=>this.availableAuthSettings.set([])});}onParamsChange(t){this.paramsValue.set(t);}submit(){if(this.nameControl.invalid||this.typeControl.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let t=this.descriptionControl.value?.trim(),e={name:this.nameControl.value.trim(),description:t||null,integrationType:this.typeControl.value,parameters:this.paramsValue(),authSettingName:this.authSettingNameControl.value||null},n=this.form.getRawValue().scope;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,e,n,this.existingConfig):this.state.create(e,n,this.namespaceId??null)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}exportYaml(){let t=this.existingConfig?.id;!t||this.isExporting()||(this.isExporting.set(true),this.state.exportAsYaml(t).pipe(U(this.destroyRef)).subscribe({next:e=>{let n=new Blob([e],{type:"application/yaml"}),s=URL.createObjectURL(n),m=document.createElement("a");m.href=s,m.download=`${this.existingConfig?.name??"integration"}.yaml`,m.click(),URL.revokeObjectURL(s),this.isExporting.set(false);},error:()=>this.isExporting.set(false)}));}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","integration-configs"]):this.router.navigate(["/agentos",this.namespaceId,"integrations"]);}trackByType(t,e){return e.type}trackByScope(t,e){return e.value}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=Rw({type:r,selectors:[["agentos-integration-form"]],decls:10,vars:2,consts:[[1,"integration-form"],[1,"integration-form__header"],["type","button","title","Back to integrations",1,"integration-form__back",3,"click"],[1,"integration-form__back-icon"],[1,"integration-form__title"],[1,"integration-form__loading"],[1,"integration-form__form",3,"formGroup"],[1,"integration-form__form",3,"ngSubmit","formGroup"],[1,"integration-form__field","integration-form__scope",3,"disabled"],[1,"integration-form__label"],[1,"integration-form__scope-option"],[1,"integration-form__field"],["for","integration-type",1,"integration-form__label"],["aria-hidden","true"],["id","integration-type",1,"integration-form__select",3,"formControl"],["value","","disabled",""],[3,"value"],["for","integration-name",1,"integration-form__label"],["id","integration-name","type","text","placeholder","Integration name","autocomplete","off",1,"integration-form__input",3,"formControl"],["for","integration-description",1,"integration-form__label"],["id","integration-description","placeholder","Optional description","rows","3",1,"integration-form__textarea",3,"formControl"],["for","integration-auth-setting",1,"integration-form__label"],["id","integration-auth-setting",1,"integration-form__select",3,"formControl"],[3,"ngValue"],[1,"integration-form__schema-form"],[1,"integration-form__actions"],["type","submit",1,"integration-form__btn","integration-form__btn--primary",3,"disabled"],["type","button",1,"integration-form__btn","integration-form__btn--export",3,"disabled"],["type","button",1,"integration-form__btn",3,"click"],["type","radio",3,"value","formControl","disabled"],[3,"valueChange","schema","value"],["type","button",1,"integration-form__btn","integration-form__btn--export",3,"click","disabled"]],template:function(e,n){e&1&&(Is(0,"div",0)(1,"header",1)(2,"button",2),Ag("click",function(){return n.cancel()}),Is(3,"span",3),qC(4,"\u2190"),pl(),qC(5," Integrations "),pl(),Is(6,"h1",4),qC(7),pl()(),tC(8,ae,2,0,"p",5)(9,pe,41,11,"form",6),pl()),e&2&&(JE(7),Zg(n.isEditMode()?"Edit integration":"New integration"),JE(),nC(n.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,mn,Zn,Xn,Cn,En,nt],styles:[".integration-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.integration-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.integration-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.integration-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.integration-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.integration-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.integration-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.integration-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.integration-form__scope[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem;border:1px solid var(--color-divider);border-radius:0;padding:.75rem 1rem;background:transparent;margin:0}.integration-form__scope[disabled][_ngcontent-%COMP%]{opacity:.6}.integration-form__scope-option[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;font-size:.875rem;color:var(--color-text);cursor:pointer}.integration-form__scope-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin:0}.integration-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.integration-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.integration-form__input[_ngcontent-%COMP%], .integration-form__textarea[_ngcontent-%COMP%], .integration-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.integration-form__input[_ngcontent-%COMP%]:focus, .integration-form__textarea[_ngcontent-%COMP%]:focus, .integration-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.integration-form__input[_ngcontent-%COMP%]::placeholder, .integration-form__textarea[_ngcontent-%COMP%]::placeholder, .integration-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.integration-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:4.5rem;line-height:1.5}.integration-form__select[_ngcontent-%COMP%]{cursor:pointer}.integration-form__select[_ngcontent-%COMP%] option[disabled][_ngcontent-%COMP%]{color:var(--color-text-secondary)}.integration-form__schema-form[_ngcontent-%COMP%]{padding:1rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface)}.integration-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.integration-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.integration-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.integration-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.integration-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.integration-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}.integration-form__btn--export[_ngcontent-%COMP%]{border-color:var(--color-divider);color:var(--color-text-secondary)}.integration-form__btn--export[_ngcontent-%COMP%]:hover:not(:disabled){border-color:var(--color-accent);color:var(--color-accent)}"]})};export{ie as IntegrationFormComponent};
|
|
1
|
+
import {v}from'./chunk-CPBcDx4G.js';import {R}from'./chunk-rwEyLSEP.js';import {N as N$1}from'./chunk-Be1LOFvg.js';import {g,ao as V,G,w as we,d6 as F,F as F$1,X as br,a as Gi,E as ET,cd as Uf,c as U,h as Fw,m as ws,o as Rg,Q as QC,n as hl,q as oC,t as nI,a8 as Yg,x as iC,a9 as gC,r as cC,cH as nC,a3 as GI,S as Sg,a4 as aC,ac as EC,v as bg,y as uC,a6 as qI,a5 as Dl,aa as wf,ab as Cf}from'./main-5PAOSHSM.js';import'./chunk-BY7uKZAo.js';import {n as nt}from'./chunk-CtkiOUdU.js';import'./chunk-S8F5_Te_.js';import {o as z,k as _t,b as _e,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,m as mn,Z as Zn,l as Xn,C as Cn,E as En}from'./chunk-tTmeIHGS.js';import'./chunk-BEUXx3TO.js';import'./chunk-kvCfAm7Z.js';function ae(r,t){r&1&&(ws(0,"p",5),QC(1,"Loading\u2026"),hl());}function le(r,t){if(r&1&&(ws(0,"label",10),Sg(1,"input",29),GI(),ws(2,"span"),QC(3),hl()()),r&2){let e=t.$implicit,n=EC(2);nI(),bg("value",e.value)("formControl",n.scopeControl)("disabled",e.value==="namespace"&&!n.isAdmin()),qI(),nI(2),Yg(e.label);}}function se(r,t){if(r&1&&(ws(0,"option",16),QC(1),hl()),r&2){let e=t.$implicit;bg("value",e.type),nI(),Yg(e.displayName);}}function ce(r,t){if(r&1&&(ws(0,"option",16),QC(1),hl()),r&2){let e=t.$implicit;bg("value",e),nI(),Yg(e);}}function me(r,t){if(r&1){let e=gC();ws(0,"div",24)(1,"ds-json-schema-form",30),Rg("valueChange",function(s){wf(e);let m=EC(2);return Cf(m.onParamsChange(s))}),hl()();}if(r&2){let e=EC(2);nI(),bg("schema",t)("value",e.initialParams());}}function de(r,t){if(r&1){let e=gC();ws(0,"button",31),Rg("click",function(){wf(e);let s=EC(2);return Cf(s.exportYaml())}),QC(1),hl();}if(r&2){let e=EC(2);bg("disabled",e.isExporting()),nI(),Dl(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function pe(r,t){if(r&1){let e=gC();ws(0,"form",7),Rg("ngSubmit",function(){wf(e);let s=EC();return Cf(s.submit())}),ws(1,"fieldset",8)(2,"legend",9),QC(3,"Scope"),hl(),cC(4,le,4,4,"label",10,nC().trackByScope,true),hl(),ws(6,"div",11)(7,"label",12),QC(8,"Type "),ws(9,"span",13),QC(10,"*"),hl()(),ws(11,"select",14)(12,"option",15),QC(13,"Select type"),hl(),cC(14,se,2,2,"option",16,nC().trackByType,true),hl(),GI(),hl(),ws(16,"div",11)(17,"label",17),QC(18,"Name "),ws(19,"span",13),QC(20,"*"),hl()(),Sg(21,"input",18),GI(),hl(),ws(22,"div",11)(23,"label",19),QC(24,"Description"),hl(),Sg(25,"textarea",20),GI(),hl(),ws(26,"div",11)(27,"label",21),QC(28,"Auth Setting"),hl(),ws(29,"select",22)(30,"option",23),QC(31,"None"),hl(),cC(32,ce,2,2,"option",16,aC),hl(),GI(),hl(),oC(34,me,2,2,"div",24),ws(35,"div",25)(36,"button",26),QC(37),hl(),oC(38,de,2,2,"button",27),ws(39,"button",28),Rg("click",function(){wf(e);let s=EC();return Cf(s.cancel())}),QC(40,"Cancel"),hl()()();}if(r&2){let e,n=EC();bg("formGroup",n.form),nI(),bg("disabled",n.isEditMode()),nI(3),uC(n.scopeOptions),nI(7),bg("formControl",n.typeControl),qI(),nI(3),uC(n.integrationTypes()),nI(7),bg("formControl",n.nameControl),qI(),nI(4),bg("formControl",n.descriptionControl),qI(),nI(4),bg("formControl",n.authSettingNameControl),qI(),nI(),bg("ngValue",null),nI(2),uC(n.availableAuthSettings()),nI(2),iC((e=n.schema())?34:-1,e),nI(2),bg("disabled",n.nameControl.invalid||n.typeControl.invalid||n.isSubmitting()),nI(),Dl(" ",n.isEditMode()?"Save changes":"Create"," "),nI(),iC(n.isEditMode()?38:-1);}}var ge=new Set(["platform","namespace","userOnNs","userGlobal"]),N=Object.freeze({platform:"Configuration plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ie=class r{route=g(V);router=g(G);destroyRef=g(we);state=g(N$1);integrationTypeController=g(F);authSettingState=g(R);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isAdmin=F$1(this.isPlatformMode?br(true):this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:this.isPlatformMode});form=new z({name:new _t("",{nonNullable:true,validators:[_e.required,_e.minLength(1)]}),description:new _t(null),type:new _t("",{nonNullable:true,validators:[_e.required]}),scope:new _t("namespace",{nonNullable:true})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get typeControl(){return this.form.controls.type}get scopeControl(){return this.form.controls.scope}isEditMode=Gi(false);isSubmitting=Gi(false);isLoading=Gi(false);isExporting=Gi(false);scopeOptions=[{value:"platform",label:N.platform},{value:"namespace",label:N.namespace},{value:"userOnNs",label:N.userOnNs},{value:"userGlobal",label:N.userGlobal}];authSettingNameControl=new _t(null);availableAuthSettings=Gi([]);paramsValue=Gi(null);initialParams=Gi(null);integrationTypes=F$1(this.integrationTypeController.listTypesIntegrationType(),{initialValue:[]});selectedType=F$1(this.form.controls.type.valueChanges,{initialValue:this.form.controls.type.value});schema=ET(()=>{let t=this.selectedType();return t?this.integrationTypes().find(n=>n.type===t)?.configSchema??null:null});existingConfig=null;constructor(){Uf(()=>{if(this.isAdmin()||this.isEditMode())return;["platform","namespace"].includes(this.scopeControl.value)&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,n=t.get("integrationId");if(n){this.isEditMode.set(true),this.scopeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable(),this.loadAuthSettingsForScope("platform");return}let s=this.parseScope(e.get("scope"));this.scopeControl.setValue(s),this.loadAuthSettingsForScope(s),this.scopeControl.valueChanges.pipe(U(this.destroyRef)).subscribe(re=>{this.loadAuthSettingsForScope(re);});let m=e.get("template");m&&this.hydrateFromTemplate(m);}parseScope(t){return t&&ge.has(t)?t:"namespace"}deriveScopeFromConfig(t){return !t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e;let n=this.deriveScopeFromConfig(e);this.scopeControl.setValue(n),this.applyConfigToForm(e),this.loadAuthSettingsForScope(n),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[IntegrationForm] Could not load config '${t}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.applyConfigToForm(e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[IntegrationForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.typeControl.setValue(t.integrationType),this.initialParams.set(t.parameters),this.paramsValue.set(t.parameters),this.authSettingNameControl.setValue(t.authSettingName??null);}loadAuthSettingsForScope(t){let e;switch(t){case "platform":e=this.authSettingState.loadPlatformSettings();break;case "namespace":e=this.authSettingState.loadNamespaceSettings(this.namespaceId);break;case "userOnNs":e=this.authSettingState.loadUserSettings(this.namespaceId);break;case "userGlobal":e=this.authSettingState.loadUserSettings("global");break}e.pipe(U(this.destroyRef)).subscribe({next:n=>{let s=n.map(m=>m.name).filter(Boolean);this.availableAuthSettings.set([...new Set(s)]);},error:()=>this.availableAuthSettings.set([])});}onParamsChange(t){this.paramsValue.set(t);}submit(){if(this.nameControl.invalid||this.typeControl.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let t=this.descriptionControl.value?.trim(),e={name:this.nameControl.value.trim(),description:t||null,integrationType:this.typeControl.value,parameters:this.paramsValue(),authSettingName:this.authSettingNameControl.value||null},n=this.form.getRawValue().scope;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,e,n,this.existingConfig):this.state.create(e,n,this.namespaceId??null)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}exportYaml(){let t=this.existingConfig?.id;!t||this.isExporting()||(this.isExporting.set(true),this.state.exportAsYaml(t).pipe(U(this.destroyRef)).subscribe({next:e=>{let n=new Blob([e],{type:"application/yaml"}),s=URL.createObjectURL(n),m=document.createElement("a");m.href=s,m.download=`${this.existingConfig?.name??"integration"}.yaml`,m.click(),URL.revokeObjectURL(s),this.isExporting.set(false);},error:()=>this.isExporting.set(false)}));}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","integration-configs"]):this.router.navigate(["/agentos",this.namespaceId,"integrations"]);}trackByType(t,e){return e.type}trackByScope(t,e){return e.value}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=Fw({type:r,selectors:[["agentos-integration-form"]],decls:10,vars:2,consts:[[1,"integration-form"],[1,"integration-form__header"],["type","button","title","Back to integrations",1,"integration-form__back",3,"click"],[1,"integration-form__back-icon"],[1,"integration-form__title"],[1,"integration-form__loading"],[1,"integration-form__form",3,"formGroup"],[1,"integration-form__form",3,"ngSubmit","formGroup"],[1,"integration-form__field","integration-form__scope",3,"disabled"],[1,"integration-form__label"],[1,"integration-form__scope-option"],[1,"integration-form__field"],["for","integration-type",1,"integration-form__label"],["aria-hidden","true"],["id","integration-type",1,"integration-form__select",3,"formControl"],["value","","disabled",""],[3,"value"],["for","integration-name",1,"integration-form__label"],["id","integration-name","type","text","placeholder","Integration name","autocomplete","off",1,"integration-form__input",3,"formControl"],["for","integration-description",1,"integration-form__label"],["id","integration-description","placeholder","Optional description","rows","3",1,"integration-form__textarea",3,"formControl"],["for","integration-auth-setting",1,"integration-form__label"],["id","integration-auth-setting",1,"integration-form__select",3,"formControl"],[3,"ngValue"],[1,"integration-form__schema-form"],[1,"integration-form__actions"],["type","submit",1,"integration-form__btn","integration-form__btn--primary",3,"disabled"],["type","button",1,"integration-form__btn","integration-form__btn--export",3,"disabled"],["type","button",1,"integration-form__btn",3,"click"],["type","radio",3,"value","formControl","disabled"],[3,"valueChange","schema","value"],["type","button",1,"integration-form__btn","integration-form__btn--export",3,"click","disabled"]],template:function(e,n){e&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return n.cancel()}),ws(3,"span",3),QC(4,"\u2190"),hl(),QC(5," Integrations "),hl(),ws(6,"h1",4),QC(7),hl()(),oC(8,ae,2,0,"p",5)(9,pe,41,11,"form",6),hl()),e&2&&(nI(7),Yg(n.isEditMode()?"Edit integration":"New integration"),nI(),iC(n.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,mn,Zn,Xn,Cn,En,nt],styles:[".integration-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.integration-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.integration-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.integration-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.integration-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.integration-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.integration-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.integration-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.integration-form__scope[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem;border:1px solid var(--color-divider);border-radius:0;padding:.75rem 1rem;background:transparent;margin:0}.integration-form__scope[disabled][_ngcontent-%COMP%]{opacity:.6}.integration-form__scope-option[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;font-size:.875rem;color:var(--color-text);cursor:pointer}.integration-form__scope-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin:0}.integration-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.integration-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.integration-form__input[_ngcontent-%COMP%], .integration-form__textarea[_ngcontent-%COMP%], .integration-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.integration-form__input[_ngcontent-%COMP%]:focus, .integration-form__textarea[_ngcontent-%COMP%]:focus, .integration-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.integration-form__input[_ngcontent-%COMP%]::placeholder, .integration-form__textarea[_ngcontent-%COMP%]::placeholder, .integration-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.integration-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:4.5rem;line-height:1.5}.integration-form__select[_ngcontent-%COMP%]{cursor:pointer}.integration-form__select[_ngcontent-%COMP%] option[disabled][_ngcontent-%COMP%]{color:var(--color-text-secondary)}.integration-form__schema-form[_ngcontent-%COMP%]{padding:1rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface)}.integration-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.integration-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.integration-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.integration-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.integration-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.integration-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}.integration-form__btn--export[_ngcontent-%COMP%]{border-color:var(--color-divider);color:var(--color-text-secondary)}.integration-form__btn--export[_ngcontent-%COMP%]:hover:not(:disabled){border-color:var(--color-accent);color:var(--color-accent)}"]})};export{ie as IntegrationFormComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {n}from'./chunk-CfgXrte_.js';import {O}from'./chunk-
|
|
1
|
+
import {n}from'./chunk-CfgXrte_.js';import {O}from'./chunk-BNS6Fgaw.js';import {S}from'./chunk-CYulIMKp.js';import {v}from'./chunk-CPBcDx4G.js';import {g,ao as V,G,w as we,a as Gi,u as ue,c as U$1,bS as Da,X as br,h as Fw,aK as Ob,m as ws,bf as dT,o as Rg,n as hl,af as Eg,M as MC,v as bg,bg as pT,ah as aT,q as oC,ac as EC,x as iC,Q as QC,t as nI,a8 as Yg,a9 as gC,aa as wf,ab as Cf,ag as mT}from'./main-5PAOSHSM.js';import'./chunk-BY7uKZAo.js';import {W as Wn,S as Se}from'./chunk-CtkiOUdU.js';import'./chunk-S8F5_Te_.js';import'./chunk-tTmeIHGS.js';import'./chunk-BEUXx3TO.js';import'./chunk-kvCfAm7Z.js';var z=()=>[];function W(r,e){if(r&1&&(ws(0,"p",3),QC(1),hl()),r&2){let t=EC().$implicit;nI(),Yg(t.name);}}function U(r,e){if(r&1){let t=gC();ws(0,"agentos-ai-provider-item",5),Rg("editRequested",function(){let o=wf(t),a=EC(2);return Cf(a.onEdit(o))})("deleteRequested",function(){let o=wf(t),a=EC(2);return Cf(a.onDelete(o))})("duplicateRequested",function(){let o=wf(t),a=EC(2);return Cf(a.onDuplicate(o))}),hl();}if(r&2){let t=e,i=EC(2);bg("config",t.config)("scope",t.scope)("readOnly",t.scope==="platform"||t.scope==="namespace"&&!i.isAdmin());}}function X(r,e){if(r&1&&oC(0,W,2,1,"p",3)(1,U,1,3,"agentos-ai-provider-item",4),r&2){let t,i=e.$implicit,o=EC();iC(o.isEmptyPlaceholder(i.id)?0:(t=o.resolve(i.id))?1:-1,t);}}var k=Object.freeze({platform:"Platform (read-only)",namespace:"AI Providers du namespace",userOnNs:"Mes overrides sur ce namespace",userGlobal:"Mes overrides globaux"}),F="__empty__",j=class r{route=g(V);router=g(G);destroyRef=g(we);state=g(O);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isAdmin=Gi(false);listItems$=this.state.vm$.pipe(ue(e=>this.toListItems(e)));isLoading=Gi(true);resolved=new Map;ngOnInit(){this.route.paramMap.pipe(U$1(this.destroyRef)).subscribe(e=>{let t=e.get("namespaceId")??"";t&&t!==this.namespaceId&&(this.namespaceId=t),this.state.setNamespace(t);}),this.route.paramMap.pipe(ue(e=>e.get("namespaceId")??""),Da(e=>e?this.namespaceRole.isAdminOfNamespace$(e):br(false)),U$1(this.destroyRef)).subscribe(e=>this.isAdmin.set(e)),this.state.vm$.pipe(U$1(this.destroyRef)).subscribe(e=>{this.isLoading.set(false);let t=new Map;e.platform.forEach(i=>{i.id&&t.set(this.itemKey("platform",i.id),{config:i,scope:"platform"});}),e.namespace.forEach(i=>{i.id&&t.set(this.itemKey("namespace",i.id),{config:i,scope:"namespace"});}),e.userOnNs.forEach(i=>{i.id&&t.set(this.itemKey("userOnNs",i.id),{config:i,scope:"userOnNs"});}),e.userGlobal.forEach(i=>{i.id&&t.set(this.itemKey("userGlobal",i.id),{config:i,scope:"userGlobal"});}),this.resolved=t;});}isEmptyPlaceholder(e){return e.startsWith(F)}resolve(e){return this.resolved.get(e)??null}itemKey(e,t){return `${e}:${t}`}goBack(){this.router.navigate(["/agentos","namespaces"]);}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"ai-providers","new"],{queryParams:{scope:n(this.isAdmin())}});}onEdit(e){let t=e.config.id;t&&this.router.navigate(["/agentos",this.namespaceId,"ai-providers",t,"edit"],{queryParams:{scope:e.scope}});}onDelete(e){let t=e.config.id;t&&this.state.delete(t,e.scope).pipe(U$1(this.destroyRef)).subscribe({error:i=>{console.error(`[AiProvidersAllScopes] Delete failed for ${e.scope}:${t}:`,i);}});}onDuplicate(e){if(!e.config.id)return;let t=e.scope==="namespace"&&!this.isAdmin()?"userOnNs":e.scope;this.router.navigate(["/agentos",this.namespaceId,"ai-providers","new"],{queryParams:{scope:t,template:e.config.id,templateScope:e.scope}});}toListItems(e){let t=[];return t.push(...this.sectionItems("platform",e.platform)),t.push(...this.sectionItems("namespace",e.namespace)),t.push(...this.sectionItems("userOnNs",e.userOnNs)),t.push(...this.sectionItems("userGlobal",e.userGlobal)),t}sectionItems(e,t){return t.length===0?[{id:`${F}${e}`,name:"Aucun AI Provider",groupKey:e,groupLabel:k[e]}]:t.filter(i=>!!i.id).map(i=>({id:this.itemKey(e,i.id),name:i.name,description:i.apiType,groupKey:e,groupLabel:k[e]}))}static \u0275fac=function(t){return new(t||r)};static \u0275cmp=Fw({type:r,selectors:[["agentos-ai-providers-all-scopes"]],decls:5,vars:7,consts:[["aiProviderItemTpl",""],["title","AI Providers","emptyMessage","No AI providers available.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[1,"ai-providers-all-scopes__empty"],[3,"config","scope","readOnly"],[3,"editRequested","deleteRequested","duplicateRequested","config","scope","readOnly"]],template:function(t,i){if(t&1&&(ws(0,"ds-entity-list",1),dT(1,"async"),Rg("createRequested",function(){return i.openCreateForm()}),ws(2,"ds-icon-button",2),Rg("action",function(){return i.goBack()}),hl()(),Eg(3,X,2,1,"ng-template",null,0,mT)),t&2){let o=MC(4);bg("items",pT(1,4,i.listItems$)??aT(6,z))("loading",i.isLoading())("showCreate",true)("itemTemplate",o);}},dependencies:[Wn,S,Se,Ob],styles:[".ai-providers-all-scopes__empty[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);padding:.5rem .25rem;margin:0;font-style:italic}"]})};export{j as AiProvidersAllScopesComponent};
|