@kong-ui-public/entities-consumers 1.2.0 → 1.2.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Z,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("vue-router"),require("@kong-ui-public/i18n"),require("axios"),require("@kong/kongponents")):typeof define=="function"&&define.amd?define(["exports","vue","vue-router","@kong-ui-public/i18n","axios","@kong/kongponents"],t):(Z=typeof globalThis<"u"?globalThis:Z||self,t(Z["kong-ui-public-entities-consumers"]={},Z.Vue,Z.VueRouter,Z["kong-ui-public-i18n"],Z.axios,Z.Kongponents))})(this,function(Z,t,$e,he,Nn,An){"use strict";const En={consumers:{list:{table_headers:{username:"Username",custom_id:"Custom ID",tags:"Tags",id:"ID"},empty_state:{title:"Configure a New Consumer",description:"Consumers are the end users of a service.",title_for_consumer_group:"Configure a New Consumer"},toolbar_actions:{new_consumer:"New Consumer"}},title:"Consumers",search:{placeholder:"Filter by exact username or ID"},actions:{add_consumer:"Add Consumer",create:"New Consumer",copy_id:"Copy ID",copy_json:"Copy JSON",edit:"Edit",delete:"Delete",remove:"Remove",view:"View Details"},delete:{title:"Delete a Consumer",description:"Deleting this consumer will also remove this consumer from any associated consumer group. This action cannot be reversed."},consumer_groups:{add:{title:"Add Consumers",ctaText:"Add consumers to this group",consumers_label:"Consumers",consumer_placeholder:"Add consumer",footer:"Search by exact name or ID to find consumers not included in the list"},remove:{title:"Remove a Consumer",confirmation:"Are you sure you want to remove this consumer {consumer} from consumer group {consumerGroup}?",confirmationNoCG:"Are you sure you want to remove this consumer {consumer} from this consumer group?",description:"Removing this consumer from the group could change the rate limit policy applied to this consumer."}},errors:{general:"Consumers could not be retrieved",delete:"The consumer could not be deleted at this time.",copy:"Failed to copy to clipboard",add:"Some consumers could not be added at this time.",already_added:"This consumer has already been added to the consumer group"},copy:{success:"Copied {val} to clipboard",success_brief:"Successfully copied to clipboard"},form:{title:"Consumer Identification",info:{title:"General Information",description:"General information will help identify and manage added consumer."},consumer_identification:{title:"Consumer Identification",description:"A consumer can have both unique username and unique custom ID or one of them."}},fields:{username:{label:"Username",placeholder:"Enter a unique username",tooltip:"The unique username of the Consumer. You must send either this field or {custom_id} with the request.",custom_id:"custom_id"},custom_id:{label:"Custom ID",placeholder:"Enter a unique custom ID",tooltip:"Field for storing an existing unique ID for the Consumer - useful for mapping Kong with users in your existing database. You must send either this field or {username} with the request.",username:"username"},tags:{label:"Tags",placeholder:"Enter a list of tags separated by comma",help:"e.g. tag1, tag2, tag3",tooltip:"An optional set of strings associated with the Consumer for grouping and filtering."}}}};function Vn(){const e=he.createI18n("en-us",En);return{i18n:e,i18nT:he.i18nTComponent(e)}}const _e={useI18n:Vn},ce="/api/runtime_groups/{controlPlaneId}",de="/{workspace}",ae={list:{konnect:{all:`${ce}/consumers`,forConsumerGroup:`${ce}/consumer_groups/{consumerGroupId}/consumers`,oneForConsumerGroup:`${ce}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`},kongManager:{all:`${de}/consumers`,forConsumerGroup:`${de}/consumer_groups/{consumerGroupId}/consumers`,oneForConsumerGroup:`${de}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`}},form:{konnect:{validate:`${ce}/v1/schemas/json/consumer/validate`,create:`${ce}/consumers`,edit:`${ce}/consumers/{id}`},kongManager:{validate:`${de}/schemas/consumers/validate`,create:`${de}/consumers`,edit:`${de}/consumers/{id}`}}};var ot=(e=>(e.GatewayService="service",e.Route="route",e.Consumer="consumer",e.ConsumerGroup="consumer group",e.Plugin="plugin",e.Upstream="upstream",e.Certificate="certificate",e.CACertificate="ca certificate",e.SNI="SNI",e.Key="key",e.KeySet="key set",e.Vault="vault",e.Application="application",e.Developer="developer",e.acls="ACL Credential",e["basic-auth"]="Basic Auth Credential",e["key-auth"]="Key Auth Credential",e["key-auth-enc"]="Key Auth Encrypted Credential",e.oauth2="OAuth 2.0 Credential",e["hmac-auth"]="HMAC Credential",e.jwt="JWT Credential",e.Target="target",e.Policy="policy",e))(ot||{}),Me=(e=>(e.Edit="edit",e.Create="create",e))(Me||{}),ie=(e=>(e[e.Loading=0]="Loading",e[e.Idle=1]="Idle",e[e.NoResults=2]="NoResults",e[e.Error=3]="Error",e))(ie||{}),K=(e=>(e.ID="id",e.IdArray="id-array",e.Text="plain-text",e.Date="date",e.Redacted="redacted",e.RedactedArray="redacted-array",e.Json="json",e.JsonArray="json-array",e.BadgeTag="badge-tag",e.BadgeStatus="badge-status",e.BadgeMethod="badge-method",e.LinkInternal="link-internal",e.LinkExternal="link-external",e))(K||{}),Y=(e=>(e.Basic="basic",e.Advanced="advanced",e.Plugin="plugin",e))(Y||{});function Oe(e={}){return{axiosInstance:Nn.create({withCredentials:!0,timeout:3e4,...e})}}function Tn(){return{debounce:(e,o)=>{let n;return(...r)=>{clearTimeout(n),n=window==null?void 0:window.setTimeout(()=>{e(...r)},o)}}}}const De="khcp-user-table-preferences",$n={pageSize:30,sortColumnKey:void 0,sortColumnOrder:void 0};function Mn(){const e=n=>{if(typeof n=="string")try{return JSON.parse(n)}catch(r){console.error("useTablePreferences(tryParseJson)",r);return}},o=()=>{const n=e(localStorage.getItem(De));return!n||!Object.keys(n).length?new Map:new Map(Object.entries(n))};return{setTablePreferences:(n,r)=>{try{const a=o();a.set(n,r),localStorage.setItem(De,JSON.stringify(Object.fromEntries(a.entries())))}catch(a){console.error("useTablePreferences(setTablePreferences)",a)}},getTablePreferences:n=>{const r=o();return(r==null?void 0:r.get(n))||void 0||$n},deleteAllTablePreferences:()=>{localStorage.removeItem(De)}}}const On={message:"Are you sure you want to delete this {entityType}?",messageWithName:"Are you sure you want to delete this {entityType} {entityName}?"},Dn={actions:{save:"Save",cancel:"Cancel",back:"Back"},errors:{edit:"The entity could not be edited at this time."}},jn={emptyState:{noSearchResultsTitle:"No results found",noSearchResultsMessage:"Please adjust the criteria and try again.",noSearchResultsCtaText:"Clear"}},Fn={title:"Configuration",actions:{copy:"Copy JSON"},sections:{advanced:"Advanced",plugin:"Plugin Specific Configuration"},commonFields:{id_label:"ID",name_label:"Name",enabled_label:"Enabled",enabled_tooltip:"Enabled is FTW",updated_at_label:"Last Updated",created_at_label:"Created",tags_label:"Tags",link:"Link"},statusBadge:{enabledLabel:"Enabled",disabledLabel:"Disabled"},copy:{tooltip:"Copy {label}",success:"Copied!"},errors:{load:"The entity configuration data could not be loaded at this time.",copy:"Failed to copy to clipboard"},general:{entryTitle:"Entry {index}",structuredFormat:"Structured"}},Kn={filterButtonText:"Filter",fieldLabel:"Filter by:",inputPlaceholder:"Enter a value",selectPlaceholder:"Select an item",applyButtonText:"Apply",clearButtonText:"Clear",clearAllButtonText:"Clear all filters"},Ln={errors:{fetch:"Could not fetch available items",invalid:"Please select a valid value"}},qn={unexpected:"An unexpected error has occurred",dataKeyUndefined:'The data key "{dataKey}" does not exist in the response.'},Pn={enable:{title:"Enable {entityType}",message:"Are you sure you want to enable the {entityType} {entityName}?",confirmText:"Yes, enable"},disable:{title:"Disable {entityType}",message:"Are you sure you want to disable the {entityType} {entityName}?",confirmText:"Yes, disable"}},vn={deleteModal:On,baseForm:Dn,baseTable:jn,baseConfigCard:Fn,filter:Kn,debouncedFilter:Ln,errors:qn,toggleModal:Pn};function je(){const e=he.createI18n("en-us",vn);return{i18n:e,i18nT:he.i18nTComponent(e)}}function Un(e,o,n,r={fetchedItemsKey:"data",searchKeys:["id"]}){n||(n="100");const{axiosInstance:a}=Oe({headers:e.requestHeaders}),{i18n:{t:i}}=je(),{debounce:l}=Tn(),s=l(async y=>{await h(y)},200),c=t.ref(!1),u=t.ref(""),p=t.ref(""),d=t.ref([]),g=t.ref(void 0),f=t.unref(o);let b=`${e.apiBaseUrl}${f}`;e.app==="konnect"?b=b.replace(/{controlPlaneId}/gi,(e==null?void 0:e.controlPlaneId)||""):e.app==="kongManager"&&(b=b.replace(/\/{workspace}/gi,e!=null&&e.workspace?`/${e.workspace}`:""));const C=async()=>{try{c.value=!0;const{data:y}=await a.get(`${b}?size=${n}`);y!=null&&y.next||(g.value=r.fetchedItemsKey in y?y[r.fetchedItemsKey]:[]),d.value=r.fetchedItemsKey in y?y[r.fetchedItemsKey]:[]}catch{d.value=[],u.value=i("debouncedFilter.errors.fetch")}finally{c.value=!1}},m=t.ref(""),h=async y=>{var S,M;if(m.value!==y)if(m.value=y||"",g.value===void 0)try{c.value=!0,u.value="",p.value="";let w=b+"";y&&(w+=`/${y}`);const{data:N}=await a.get(`${w}?size=${n}`);r.fetchedItemsKey in N?d.value=N[r.fetchedItemsKey]:N!=null&&N.id?d.value=[N]:d.value=[]}catch(w){((S=w==null?void 0:w.response)==null?void 0:S.status)===404?p.value=i("debouncedFilter.errors.invalid"):(d.value=[],u.value=i("debouncedFilter.errors.fetch"))}finally{c.value=!1}else c.value=!0,p.value="",y?(d.value=(M=g.value)==null?void 0:M.filter(w=>{var N;let T=!1;for(const k of r.searchKeys){const x=typeof w[k]=="string"?(N=w[k])==null?void 0:N.toLowerCase():w[k];x!=null&&x.includes(y.toLowerCase())&&(T=!0)}return T}),(!d.value||!d.value.length)&&(p.value=i("debouncedFilter.errors.invalid"))):d.value=g.value,c.value=!1};return{loading:c,error:u,validationError:p,results:d,allRecords:g,loadItems:C,debouncedQueryChange:s}}function Rn(e,o){const n=t.unref(o),r=t.computed(()=>e.apiBaseUrl.startsWith("/")?new URL(`${window.location.origin}${n}`):new URL(n));return r.value.search="",a=>`${r.value.href}/${a}`}function Gn(){const{i18n:{t:e}}=je();return{getMessageFromError:o=>{var n,r,a;if(!o)return e("errors.unexpected");if((n=o==null?void 0:o.response)!=null&&n.data){if(o.response.data.detail)return o.response.data.detail;if((r=o.response.data.details)!=null&&r.length)return o.response.data.details.map(i=>{let l=e("errors.unexpected");return i.messages&&typeof i.messages=="object"&&i.messages.length&&(l=i.messages.join(", ")),i.field?`${i.field} - ${l}`:l}).join("; ");if(o.response.data.message){const{message:i}=o.response.data;return Array.isArray(i)?(a=i[0])!=null&&a.constraints?Object.values(i[0].constraints)[0]:i[0]:i}if(typeof o.response.data=="string")return o.response.data;if(typeof o.response.data=="object")return Object.keys(o.response.data).map(i=>`${i} ${o.response.data[i]}`).join(", ")}return o.message||e("errors.unexpected")}}}function rt(e,o){const n=t.ref(t.unref(e)),r=t.ref(t.unref(o)),a=t.computed(()=>!!(n.value.app==="konnect"||n.value.isExactMatch)),i=t.computed(()=>r.value.startsWith("/")?new URL(`${window.location.origin}${r.value}`):new URL(r.value));return l=>{const{page:s,pageSize:c,offset:u,sortColumnKey:p,sortColumnOrder:d,query:g}=l;try{let f=new URL(i.value.href);return a.value&&g?(f.search="",f=new URL(`${f.href}/${g}/`)):(a.value||new URLSearchParams(g).forEach((b,C)=>{f.searchParams.append(C,b)}),p&&f.searchParams.append("sort_by",p),d==="desc"&&f.searchParams.append("sort_desc","1"),f.searchParams.append("size",String(c))),u&&s!==1&&f.searchParams.append("offset",String(u)),f.href}catch(f){return console.error("RouteList(fetcher)",f),r.value}}}function zn(e,o,n="data"){const r=t.unref(o),{axiosInstance:a}=Oe({headers:e.requestHeaders}),i=rt(e,r),l=t.ref({status:ie.Idle});return{fetcher:async s=>{try{l.value={status:ie.Loading};const c=i(s),{data:u}=await a.get(c),p=n&&n.replace(/[^\w-_]/gi,"");let d;u[p]&&Array.isArray(u[p])?d=u[p]:d=Object.keys(u).length?[u]:[];const g={data:d,total:d.length,...u.offset?{pagination:{offset:u.offset}}:null};return l.value={status:ie.Idle,response:g},g}catch(c){const u={data:[],total:0};return s.query&&c.response.status===404?(l.value={status:ie.NoResults,response:u,error:c},u):(l.value={status:ie.Error,response:u,error:c},u)}},fetcherState:l}}function Hn(){return{getPropValue:(e,o)=>(o==null?void 0:o[e])||void 0}}function Yn(){return{convertKeyToTitle:(e,o="_")=>e?e.split(o).map(n=>n.toLowerCase()==="id"?n.toUpperCase():n.charAt(0).toUpperCase()+n.substring(1)).join(" "):""}}const at=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,it=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");const o=e.match(at);if(!o)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return o.shift(),o},lt=e=>e==="*"||e==="x"||e==="X",st=e=>{const o=parseInt(e,10);return isNaN(o)?e:o},Jn=(e,o)=>typeof e!=typeof o?[String(e),String(o)]:[e,o],Wn=(e,o)=>{if(lt(e)||lt(o))return 0;const[n,r]=Jn(st(e),st(o));return n>r?1:n<r?-1:0},ct=(e,o)=>{for(let n=0;n<Math.max(e.length,o.length);n++){const r=Wn(e[n]||"0",o[n]||"0");if(r!==0)return r}return 0},Zn=(e,o)=>{const n=it(e),r=it(o),a=n.pop(),i=r.pop(),l=ct(n,r);return l!==0?l:a&&i?ct(a.split("."),i.split(".")):a||i?a?-1:1:0},dt=(e,o,n)=>{Qn(n);const r=Zn(e,o);return ut[n].includes(r)},ut={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},pt=Object.keys(ut),Qn=e=>{if(typeof e!="string")throw new TypeError(`Invalid operator type, expected string but got ${typeof e}`);if(pt.indexOf(e)===-1)throw new Error(`Invalid operator, expected one of ${pt.join("|")}`)},Xn=e=>typeof e=="string"&&/^[v\d]/.test(e)&&at.test(e);function eo(e){const{gatewayInfo:o,supportedRange:n}=e;if(!o)return!0;const{edition:r,version:a}=o;if(!Xn(a))return console.error("Invalid version"),!1;const i=n[r];if(!i)return!1;const[l,s]=i;return!(l&&dt(a,l,"<")||s&&dt(a,s,">"))}const R={useAxios:Oe,useDebouncedFilter:Un,useDeleteUrlBuilder:Rn,useErrors:Gn,useFetcher:zn,useFetchUrlBuilder:rt,useHelpers:Hn,useStringHelpers:Yn,useI18n:je,useGatewayFeatureSupported:eo},to={fail:"Failed to copy id to clipboard",success:{prefix:"Successfully",content:" copied to clipboard"}},no="Copy to clipboard",oo={message:to,iconTitle:no},ro="kong-ui-copy-uuid-notify",ao={class:"kong-ui-copy-uuid"},io=["onClick"],mt=15,lo=t.defineComponent({__name:"CopyUuid",props:{uuid:{type:String,required:!0},idTooltip:{type:String,default:""},truncated:{type:Boolean,default:!0},useMono:{type:Boolean,default:!0},notify:{type:Function,default:void 0},iconColor:{type:String,default:"rgba(0, 0, 0, 0.45)"},tooltip:{type:String,default:""},successTooltip:{type:String,default:""},format:{type:String,required:!1,default:"uuid",validator:e=>["uuid","hidden","redacted","deleted"].includes(e)}},emits:["success","error"],setup(e,{emit:o}){const n=e,{t:r}=he.createI18n("en-us",oo),a=n.notify||t.inject(ro,()=>{}),i=t.computed(()=>n.idTooltip?{label:n.idTooltip,positionFixed:!0,placement:"bottomStart"}:{title:n.uuid}),l=t.computed(()=>!!(n.tooltip&&n.successTooltip)),s=t.ref(n.tooltip),c=t.computed(()=>n.tooltip?{label:s.value,positionFixed:!0,maxWidth:"500px",placement:"bottomStart"}:{}),u=t.computed(()=>n.format==="redacted"?"*****":n.format==="deleted"?`*${n.uuid.substring(0,5)}`:n.uuid),p=g=>{s.value=g,setTimeout(()=>{s.value=n.tooltip},1800)},d=g=>{if(!g(n.uuid)){typeof a=="function"&&a({type:"error",message:r("message.fail")}),l.value?p(r("message.fail")):o("error",n.uuid);return}const f=n.uuid.length>mt,b=n.format==="hidden"||n.format==="redacted"?r("message.success.prefix"):`"${n.uuid.substring(0,mt)+(f?"...":"")}"`;typeof a=="function"&&a({type:"success",message:`${b}${r("message.success.content")}`}),l.value?p(n.successTooltip):o("success",n.uuid)};return(g,f)=>{const b=t.resolveComponent("KIcon"),C=t.resolveComponent("KClipboardProvider");return t.openBlock(),t.createElementBlock("div",ao,[e.format!=="hidden"?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.idTooltip?"KTooltip":"div"),t.mergeProps({key:0},i.value,{"data-testid":"copy-id"}),{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(["uuid-container",e.truncated?"truncated-uuid":null,e.useMono?"mono":null])},t.toDisplayString(u.value),3)]),_:1},16)):t.createCommentVNode("",!0),(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.tooltip?"KTooltip":"div"),t.mergeProps(c.value,{class:"uuid-icon-wrapper"}),{default:t.withCtx(()=>[t.createVNode(C,null,{default:t.withCtx(({copyToClipboard:m})=>[t.createElementVNode("span",{"data-testid":"copy-to-clipboard",role:"button",tabindex:"0",onClick:t.withModifiers(h=>d(m),["stop"])},[t.createVNode(b,{class:"uuid-icon",color:e.iconColor,"hide-title":!!e.tooltip||void 0,icon:"copy",size:"16",title:t.unref(r)("iconTitle")},null,8,["color","hide-title","title"])],8,io)]),_:1})]),_:1},16))])}}}),so=(e,o)=>{const n=e.__vccOpts||e;for(const[r,a]of o)n[r]=a;return n},ft=so(lo,[["__scopeId","data-v-bfdaf6f7"]]),co={key:0,class:"config-card-fieldset-title"},uo=t.defineComponent({__name:"JsonCardItem",props:{item:{type:Object,required:!0},index:{type:Number,default:-1},isArrayItem:{type:Boolean,default:!1}},setup(e){const o=e,{i18n:{t:n}}=R.useI18n(),{convertKeyToTitle:r}=R.useStringHelpers(),a=t.computed(()=>o.item.key??"json-array-item"),i=t.computed(()=>o.item.value??o.item),l=t.computed(()=>{const c=JSON.parse(JSON.stringify(i.value));return o.isArrayItem&&delete c.name,c}),s=t.computed(()=>{var c;return o.isArrayItem?(c=i.value)!=null&&c.name?r(i.value.name,"_"):n("baseConfigCard.general.entryTitle",{index:o.index}):""});return(c,u)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.isArrayItem?"fieldset":"div"),{class:t.normalizeClass(e.isArrayItem?"config-card-fieldset":"config-card-json-item")},{default:t.withCtx(()=>[e.isArrayItem?(t.openBlock(),t.createElementBlock("legend",co,[t.createElementVNode("b",null,t.toDisplayString(s.value),1)])):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Object.keys(l.value),(p,d)=>(t.openBlock(),t.createBlock(Fe,{key:`${a.value}-property-${d}`,item:{key:p,label:t.unref(r)(p),value:l.value[p]}},null,8,["item"]))),128))]),_:1},8,["class"]))}}),Q=(e,o)=>{const n=e.__vccOpts||e;for(const[r,a]of o)n[r]=a;return n},gt=Q(uo,[["__scopeId","data-v-68ca83ec"]]),po=Q(t.defineComponent({__name:"InternalLinkItem",props:{item:{type:Object,required:!0}},emits:["navigation-click"],setup(e){const{i18n:{t:o}}=R.useI18n();return(n,r)=>{const a=t.resolveComponent("KButton");return t.openBlock(),t.createElementBlock("div",null,[t.createVNode(a,{appearance:"btn-link",class:"navigation-button",onClick:r[0]||(r[0]=i=>n.$emit("navigation-click",e.item))},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.item.value||t.unref(o)("baseConfigCard.commonFields.link")),1)]),_:1})])}}}),[["__scopeId","data-v-7410504d"]]),mo=t.defineComponent({__name:"StatusBadge",props:{status:{type:Boolean,default:!1}},setup(e){const{i18n:{t:o}}=R.useI18n();return(n,r)=>{const a=t.resolveComponent("KBadge");return t.openBlock(),t.createBlock(a,{appearance:e.status?"success":"neutral"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.status?t.unref(o)("baseConfigCard.statusBadge.enabledLabel"):t.unref(o)("baseConfigCard.statusBadge.disabledLabel")),1)]),_:1},8,["appearance"])}}}),fo="#0044f4",go="#e0e4ea",yo="#3a3f51",ho="1px",bo="20px",Co={class:"config-card-details-row"},ko=["data-testid"],wo=["data-testid"],xo=["data-testid"],So=["data-testid"],_o={key:1},Bo=["data-testid"],Io=["data-testid"],No=["data-testid"],Ao=["data-testid"],Eo=["title"],Vo={name:"ConfigCardItem",components:{CopyUuid:ft,JsonCardItem:gt,StatusBadge:mo,InternalLinkItem:po}},To=t.defineComponent({...Vo,props:{item:{type:Object,required:!0},slim:{type:Boolean,required:!1,default:!1},truncated:{type:Boolean,required:!1,default:!1}},emits:["navigation-click"],setup(e,{emit:o}){const n=e;t.useCssVars(d=>({"2c6ac268":u.value?"none":`solid ${t.unref(ho)} ${t.unref(go)}`,c7a65802:c.value&&l.value?"block":"flex","778426fe":c.value&&l.value?"100%":n.slim?"50%":"25%","777f9b48":c.value&&l.value?"100%":n.slim?"50%":"75%"}));const r=t.useSlots(),{i18n:{t:a,formatUnixTimeStamp:i}}=R.useI18n(),l=t.computed(()=>n.item.value!==void 0&&n.item.value!==null&&n.item.value!==""),s=t.computed(()=>!!(n.item.tooltip||r["label-tooltip"])),c=t.computed(()=>n.item.type===K.Json||n.item.type===K.JsonArray),u=t.computed(()=>n.item.type===K.JsonArray),p=t.computed(()=>{switch(n.item.type){case K.ID:return{tag:"CopyUuid",attrs:{"data-testid":`${n.item.key}-copy-uuid`,"success-tooltip":a("baseConfigCard.copy.success"),tooltip:a("baseConfigCard.copy.tooltip",{label:n.item.label}),truncated:!1,uuid:n.item.value,notify:()=>{}}};case K.IdArray:return{tag:"div",additionalComponent:"CopyUuid",childAttrs:{"success-tooltip":a("baseConfigCard.copy.success"),tooltip:a("baseConfigCard.copy.tooltip",{label:n.item.label}),truncated:!1,notify:()=>{}}};case K.Redacted:return{tag:"CopyUuid",attrs:{"data-testid":`${n.item.key}-copy-uuid-redacted`,format:"redacted","success-tooltip":a("baseConfigCard.copy.success"),tooltip:a("baseConfigCard.copy.tooltip",{label:n.item.label}),truncated:!1,uuid:n.item.value,notify:()=>{}}};case K.RedactedArray:return{tag:"div",additionalComponent:"CopyUuid",childAttrs:{format:"redacted","success-tooltip":a("baseConfigCard.copy.success"),tooltip:a("baseConfigCard.copy.tooltip",{label:n.item.label}),truncated:!1,notify:()=>{}}};case K.Date:return{tag:"div",attrs:{"data-testid":`${n.item.key}-date`},text:i(n.item.value)};case K.BadgeStatus:return{tag:"StatusBadge",attrs:{"data-testid":`${n.item.key}-badge-status`,status:n.item.value}};case K.BadgeTag:return{tag:"div",additionalComponent:"KBadge"};case K.BadgeMethod:return{tag:"div",additionalComponent:"KMethodBadge"};case K.LinkInternal:return{tag:"InternalLinkItem",attrs:{"data-testid":`${n.item.key}-internal-link`,item:n.item,onNavigationClick:d=>{o("navigation-click",d)}}};case K.LinkExternal:return{tag:"KExternalLink",attrs:{"data-testid":`${n.item.key}-external-link`,href:n.item.value},text:n.item.value};case K.Json:return{tag:"JsonCardItem",attrs:{"data-testid":`${n.item.key}-json-content`,item:n.item}};case K.JsonArray:return{tag:"div",additionalComponent:"JsonCardItem",attrs:{"data-testid":`${n.item.key}-json-array-content`,item:n.item}};default:return{tag:"div",attrs:{"data-testid":`${n.item.key}-plain-text`},text:n.item.value}}});return(d,g)=>{const f=t.resolveComponent("KLabel"),b=t.resolveComponent("KBadge"),C=t.resolveComponent("KMethodBadge");return t.openBlock(),t.createElementBlock("div",Co,[t.createElementVNode("div",{class:"config-card-details-label","data-testid":`${e.item.key}-label`},[t.renderSlot(d.$slots,"label",{item:e.item},()=>[t.createVNode(f,{"tooltip-attributes":{maxWidth:"500px"}},t.createSlots({default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.item.label)+" ",1)]),_:2},[s.value?{name:"tooltip",fn:t.withCtx(()=>[t.createElementVNode("div",{"data-testid":`${e.item.key}-label-tooltip`},[t.renderSlot(d.$slots,"label-tooltip",{},()=>[t.createTextVNode(t.toDisplayString(e.item.tooltip),1)],!0)],8,wo)]),key:"0"}:void 0]),1024)],!0)],8,ko),t.createElementVNode("div",{class:"config-card-details-value","data-testid":`${e.item.key}-property-value`},[t.renderSlot(d.$slots,e.item.key,{rowValue:e.item.value},()=>[l.value?(t.openBlock(),t.createElementBlock("div",_o,[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(p.value.tag),t.normalizeProps(t.guardReactiveProps(p.value.attrs)),{default:t.withCtx(()=>[p.value.additionalComponent==="KBadge"?(t.openBlock(),t.createElementBlock("div",{key:0,"data-testid":`${e.item.key}-badge-tags`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.item.value,(m,h)=>(t.openBlock(),t.createBlock(b,{key:`${e.item.key}-badge-tag-${h}`,class:"config-badge","data-testid":`${e.item.key}-badge-tag-${h}`,"truncation-tooltip":m},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(m),1)]),_:2},1032,["data-testid","truncation-tooltip"]))),128))],8,Bo)):t.createCommentVNode("",!0),p.value.additionalComponent==="CopyUuid"?(t.openBlock(),t.createElementBlock("div",{key:1,class:"copy-uuid-array","data-testid":`${e.item.key}-copy-uuid-array`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.item.value,(m,h)=>(t.openBlock(),t.createBlock(t.unref(ft),t.mergeProps(p.value.childAttrs,{key:`${e.item.key}-copy-uuid-${h}`,"data-testid":`${e.item.key}-copy-uuid-${h}`,uuid:m}),null,16,["data-testid","uuid"]))),128))],8,Io)):p.value.additionalComponent==="KMethodBadge"?(t.openBlock(),t.createElementBlock("div",{key:2,class:"method-badge-array","data-testid":`${e.item.key}-badge-methods`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.item.value,(m,h)=>(t.openBlock(),t.createBlock(C,{key:`${e.item.key}-badge-method-${h}`,class:"config-badge","data-testid":`${e.item.key}-badge-method-${h}`,"is-rounded":"",label:m,method:t.unref(An.MethodsArray).includes(m.toLowerCase())?m.toLowerCase():"custom"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(m),1)]),_:2},1032,["data-testid","label","method"]))),128))],8,No)):t.createCommentVNode("",!0),p.value.additionalComponent==="JsonCardItem"?(t.openBlock(),t.createElementBlock("div",{key:3,"data-testid":`${n.item.key}-json-array-content`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.item.value,(m,h)=>(t.openBlock(),t.createBlock(gt,{key:`json-array-item-${h}`,index:h,"is-array-item":"",item:m},null,8,["index","item"]))),128))],8,Ao)):(t.openBlock(),t.createElementBlock("span",{key:4,class:t.normalizeClass(["attrs-data-text",{truncated:e.truncated}]),title:e.truncated?e.item.value:void 0},t.toDisplayString(p.value.text),11,Eo))]),_:1},16))])):(t.openBlock(),t.createElementBlock("div",{key:0,"data-testid":`${e.item.key}-no-value`}," – ",8,So))],!0)],8,xo)])}}}),Fe=Q(To,[["__scopeId","data-v-a3c5ab01"]]);/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function yt(e){return typeof e>"u"||e===null}function $o(e){return typeof e=="object"&&e!==null}function Mo(e){return Array.isArray(e)?e:yt(e)?[]:[e]}function Oo(e,o){var n,r,a,i;if(o)for(i=Object.keys(o),n=0,r=i.length;n<r;n+=1)a=i[n],e[a]=o[a];return e}function Do(e,o){var n="",r;for(r=0;r<o;r+=1)n+=e;return n}function jo(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Fo=yt,Ko=$o,Lo=Mo,qo=Do,Po=jo,vo=Oo,v={isNothing:Fo,isObject:Ko,toArray:Lo,repeat:qo,isNegativeZero:Po,extend:vo};function ht(e,o){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!o&&e.mark.snippet&&(n+=`
|
|
1
|
+
(function(Z,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("vue-router"),require("@kong-ui-public/i18n"),require("axios"),require("@kong/kongponents")):typeof define=="function"&&define.amd?define(["exports","vue","vue-router","@kong-ui-public/i18n","axios","@kong/kongponents"],t):(Z=typeof globalThis<"u"?globalThis:Z||self,t(Z["kong-ui-public-entities-consumers"]={},Z.Vue,Z.VueRouter,Z["kong-ui-public-i18n"],Z.axios,Z.Kongponents))})(this,function(Z,t,$e,he,Nn,An){"use strict";const En={consumers:{list:{table_headers:{username:"Username",custom_id:"Custom ID",tags:"Tags",id:"ID"},empty_state:{title:"Configure a New Consumer",description:"Consumers are the end users of a service.",title_for_consumer_group:"Configure a New Consumer"},toolbar_actions:{new_consumer:"New Consumer"}},title:"Consumers",search:{placeholder:"Filter by exact username or ID"},actions:{add_consumer:"Add Consumer",create:"New Consumer",copy_id:"Copy ID",copy_json:"Copy JSON",edit:"Edit",delete:"Delete",remove:"Remove",view:"View Details"},delete:{title:"Delete a Consumer",description:"Deleting this consumer will also remove this consumer from any associated consumer group. This action cannot be reversed."},consumer_groups:{add:{title:"Add Consumers",ctaText:"Add consumers to this group",consumers_label:"Consumers",consumer_placeholder:"Add consumer",footer:"Search by exact name or ID to find consumers not included in the list"},remove:{title:"Remove a Consumer",confirmation:"Are you sure you want to remove this consumer {consumer} from consumer group {consumerGroup}?",confirmationNoCG:"Are you sure you want to remove this consumer {consumer} from this consumer group?",description:"Removing this consumer from the group could change the rate limit policy applied to this consumer."}},errors:{general:"Consumers could not be retrieved",delete:"The consumer could not be deleted at this time.",copy:"Failed to copy to clipboard",add:"Some consumers could not be added at this time.",already_added:"This consumer has already been added to the consumer group"},copy:{success:"Copied {val} to clipboard",success_brief:"Successfully copied to clipboard"},form:{title:"Consumer Identification",info:{title:"General Information",description:"General information will help identify and manage added consumer."},consumer_identification:{title:"Consumer Identification",description:"A consumer can have both unique username and unique custom ID or one of them."}},fields:{username:{label:"Username",placeholder:"Enter a unique username",tooltip:"The unique username of the Consumer. You must send either this field or {custom_id} with the request.",custom_id:"custom_id"},custom_id:{label:"Custom ID",placeholder:"Enter a unique custom ID",tooltip:"Field for storing an existing unique ID for the Consumer - useful for mapping Kong with users in your existing database. You must send either this field or {username} with the request.",username:"username"},tags:{label:"Tags",placeholder:"Enter a list of tags separated by comma",help:"e.g. tag1, tag2, tag3",tooltip:"An optional set of strings associated with the Consumer for grouping and filtering."}}}};function Vn(){const e=he.createI18n("en-us",En);return{i18n:e,i18nT:he.i18nTComponent(e)}}const _e={useI18n:Vn},ce="/api/runtime_groups/{controlPlaneId}",de="/{workspace}",ae={list:{konnect:{all:`${ce}/consumers`,forConsumerGroup:`${ce}/consumer_groups/{consumerGroupId}/consumers`,oneForConsumerGroup:`${ce}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`},kongManager:{all:`${de}/consumers`,forConsumerGroup:`${de}/consumer_groups/{consumerGroupId}/consumers`,oneForConsumerGroup:`${de}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`}},form:{konnect:{validate:`${ce}/v1/schemas/json/consumer/validate`,create:`${ce}/consumers`,edit:`${ce}/consumers/{id}`},kongManager:{validate:`${de}/schemas/consumers/validate`,create:`${de}/consumers`,edit:`${de}/consumers/{id}`}}};var ot=(e=>(e.GatewayService="service",e.Route="route",e.Consumer="consumer",e.ConsumerGroup="consumer group",e.Plugin="plugin",e.Upstream="upstream",e.Certificate="certificate",e.CACertificate="ca certificate",e.SNI="SNI",e.Key="key",e.KeySet="key set",e.Vault="vault",e.Application="application",e.Developer="developer",e.acls="ACL Credential",e["basic-auth"]="Basic Auth Credential",e["key-auth"]="Key Auth Credential",e["key-auth-enc"]="Key Auth Encrypted Credential",e.oauth2="OAuth 2.0 Credential",e["hmac-auth"]="HMAC Credential",e.jwt="JWT Credential",e.Target="target",e.Policy="policy",e))(ot||{}),Me=(e=>(e.Edit="edit",e.Create="create",e))(Me||{}),ie=(e=>(e[e.Loading=0]="Loading",e[e.Idle=1]="Idle",e[e.NoResults=2]="NoResults",e[e.Error=3]="Error",e))(ie||{}),K=(e=>(e.ID="id",e.IdArray="id-array",e.Text="plain-text",e.Date="date",e.Redacted="redacted",e.RedactedArray="redacted-array",e.Json="json",e.JsonArray="json-array",e.BadgeTag="badge-tag",e.BadgeStatus="badge-status",e.BadgeMethod="badge-method",e.LinkInternal="link-internal",e.LinkExternal="link-external",e))(K||{}),Y=(e=>(e.Basic="basic",e.Advanced="advanced",e.Plugin="plugin",e))(Y||{});function Oe(e={}){return{axiosInstance:Nn.create({withCredentials:!0,timeout:3e4,...e})}}function Tn(){return{debounce:(e,o)=>{let n;return(...r)=>{clearTimeout(n),n=window==null?void 0:window.setTimeout(()=>{e(...r)},o)}}}}const De="khcp-user-table-preferences",$n={pageSize:30,sortColumnKey:void 0,sortColumnOrder:void 0};function Mn(){const e=n=>{if(typeof n=="string")try{return JSON.parse(n)}catch(r){console.error("useTablePreferences(tryParseJson)",r);return}},o=()=>{const n=e(localStorage.getItem(De));return!n||!Object.keys(n).length?new Map:new Map(Object.entries(n))};return{setTablePreferences:(n,r)=>{try{const a=o();a.set(n,r),localStorage.setItem(De,JSON.stringify(Object.fromEntries(a.entries())))}catch(a){console.error("useTablePreferences(setTablePreferences)",a)}},getTablePreferences:n=>{const r=o();return(r==null?void 0:r.get(n))||void 0||$n},deleteAllTablePreferences:()=>{localStorage.removeItem(De)}}}const On={message:"Are you sure you want to delete this {entityType}?",messageWithName:"Are you sure you want to delete this {entityType} {entityName}?"},Dn={actions:{save:"Save",cancel:"Cancel",back:"Back"},errors:{edit:"The entity could not be edited at this time."}},jn={emptyState:{noSearchResultsTitle:"No results found",noSearchResultsMessage:"Please adjust the criteria and try again.",noSearchResultsCtaText:"Clear"}},Fn={title:"Configuration",actions:{copy:"Copy JSON"},sections:{advanced:"Advanced",plugin:"Plugin Specific Configuration"},commonFields:{id_label:"ID",name_label:"Name",enabled_label:"Enabled",enabled_tooltip:"Enabled is FTW",updated_at_label:"Last Updated",created_at_label:"Created",tags_label:"Tags",link:"Link"},statusBadge:{enabledLabel:"Enabled",disabledLabel:"Disabled"},copy:{tooltip:"Copy {label}",success:"Copied!"},errors:{load:"The entity configuration data could not be loaded at this time.",copy:"Failed to copy to clipboard"},general:{entryTitle:"Entry {index}",structuredFormat:"Structured"}},Kn={filterButtonText:"Filter",fieldLabel:"Filter by:",inputPlaceholder:"Enter a value",selectPlaceholder:"Select an item",applyButtonText:"Apply",clearButtonText:"Clear",clearAllButtonText:"Clear all filters"},Ln={errors:{fetch:"Could not fetch available items",invalid:"Please select a valid value"}},qn={unexpected:"An unexpected error has occurred",dataKeyUndefined:'The data key "{dataKey}" does not exist in the response.'},Pn={enable:{title:"Enable {entityType}",message:"Are you sure you want to enable the {entityType} {entityName}?",confirmText:"Yes, enable"},disable:{title:"Disable {entityType}",message:"Are you sure you want to disable the {entityType} {entityName}?",confirmText:"Yes, disable"}},vn={deleteModal:On,baseForm:Dn,baseTable:jn,baseConfigCard:Fn,filter:Kn,debouncedFilter:Ln,errors:qn,toggleModal:Pn};function je(){const e=he.createI18n("en-us",vn);return{i18n:e,i18nT:he.i18nTComponent(e)}}function Un(e,o,n,r={fetchedItemsKey:"data",searchKeys:["id"]}){n||(n="100");const{axiosInstance:a}=Oe({headers:e.requestHeaders}),{i18n:{t:i}}=je(),{debounce:l}=Tn(),s=l(async y=>{await h(y)},200),c=t.ref(!1),u=t.ref(""),p=t.ref(""),d=t.ref([]),g=t.ref(void 0),f=t.unref(o);let b=`${e.apiBaseUrl}${f}`;e.app==="konnect"?b=b.replace(/{controlPlaneId}/gi,(e==null?void 0:e.controlPlaneId)||""):e.app==="kongManager"&&(b=b.replace(/\/{workspace}/gi,e!=null&&e.workspace?`/${e.workspace}`:""));const C=async()=>{try{c.value=!0;const{data:y}=await a.get(`${b}?size=${n}`);y!=null&&y.next||(g.value=r.fetchedItemsKey in y?y[r.fetchedItemsKey]:[]),d.value=r.fetchedItemsKey in y?y[r.fetchedItemsKey]:[]}catch{d.value=[],u.value=i("debouncedFilter.errors.fetch")}finally{c.value=!1}},m=t.ref(""),h=async y=>{var S,M;if(m.value!==y)if(m.value=y||"",g.value===void 0)try{c.value=!0,u.value="",p.value="";let w=b+"";y&&(w+=`/${y}`);const{data:N}=await a.get(`${w}?size=${n}`);r.fetchedItemsKey in N?d.value=N[r.fetchedItemsKey]:N!=null&&N.id?d.value=[N]:d.value=[]}catch(w){((S=w==null?void 0:w.response)==null?void 0:S.status)===404?p.value=i("debouncedFilter.errors.invalid"):(d.value=[],u.value=i("debouncedFilter.errors.fetch"))}finally{c.value=!1}else c.value=!0,p.value="",y?(d.value=(M=g.value)==null?void 0:M.filter(w=>{var N;let T=!1;for(const k of r.searchKeys){const x=typeof w[k]=="string"?(N=w[k])==null?void 0:N.toLowerCase():w[k];x!=null&&x.includes(y.toLowerCase())&&(T=!0)}return T}),(!d.value||!d.value.length)&&(p.value=i("debouncedFilter.errors.invalid"))):d.value=g.value,c.value=!1};return{loading:c,error:u,validationError:p,results:d,allRecords:g,loadItems:C,debouncedQueryChange:s}}function Rn(e,o){const n=t.unref(o),r=t.computed(()=>e.apiBaseUrl.startsWith("/")?new URL(`${window.location.origin}${n}`):new URL(n));return r.value.search="",a=>`${r.value.href}/${a}`}function Gn(){const{i18n:{t:e}}=je();return{getMessageFromError:o=>{var n,r,a;if(!o)return e("errors.unexpected");if((n=o==null?void 0:o.response)!=null&&n.data){if(o.response.data.detail)return o.response.data.detail;if((r=o.response.data.details)!=null&&r.length)return o.response.data.details.map(i=>{let l=e("errors.unexpected");return i.messages&&typeof i.messages=="object"&&i.messages.length&&(l=i.messages.join(", ")),i.field?`${i.field} - ${l}`:l}).join("; ");if(o.response.data.message){const{message:i}=o.response.data;return Array.isArray(i)?(a=i[0])!=null&&a.constraints?Object.values(i[0].constraints)[0]:i[0]:i}if(typeof o.response.data=="string")return o.response.data;if(typeof o.response.data=="object")return Object.keys(o.response.data).map(i=>`${i} ${o.response.data[i]}`).join(", ")}return o.message||e("errors.unexpected")}}}function rt(e,o){const n=t.ref(t.unref(e)),r=t.ref(t.unref(o)),a=t.computed(()=>!!(n.value.app==="konnect"||n.value.isExactMatch)),i=t.computed(()=>r.value.startsWith("/")?new URL(`${window.location.origin}${r.value}`):new URL(r.value));return l=>{const{page:s,pageSize:c,offset:u,sortColumnKey:p,sortColumnOrder:d,query:g}=l;try{let f=new URL(i.value.href);return a.value&&g?(f.search="",f=new URL(`${f.href}/${g}/`)):(a.value||new URLSearchParams(g).forEach((b,C)=>{f.searchParams.append(C,b)}),p&&f.searchParams.append("sort_by",p),d==="desc"&&f.searchParams.append("sort_desc","1"),f.searchParams.append("size",String(c))),u&&s!==1&&f.searchParams.append("offset",String(u)),f.href}catch(f){return console.error("RouteList(fetcher)",f),r.value}}}function zn(e,o,n="data"){const r=t.unref(o),{axiosInstance:a}=Oe({headers:e.requestHeaders}),i=rt(e,r),l=t.ref({status:ie.Idle});return{fetcher:async s=>{try{l.value={status:ie.Loading};const c=i(s),{data:u}=await a.get(c),p=n&&n.replace(/[^\w-_]/gi,"");let d;u[p]&&Array.isArray(u[p])?d=u[p]:d=Object.keys(u).length?[u]:[];const g={data:d,total:d.length,...u.offset?{pagination:{offset:u.offset}}:null};return l.value={status:ie.Idle,response:g},g}catch(c){const u={data:[],total:0};return s.query&&c.response.status===404?(l.value={status:ie.NoResults,response:u,error:c},u):(l.value={status:ie.Error,response:u,error:c},u)}},fetcherState:l}}function Hn(){return{getPropValue:(e,o)=>(o==null?void 0:o[e])??void 0}}function Yn(){return{convertKeyToTitle:(e,o="_")=>e?e.split(o).map(n=>n.toLowerCase()==="id"?n.toUpperCase():n.charAt(0).toUpperCase()+n.substring(1)).join(" "):""}}const at=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,it=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");const o=e.match(at);if(!o)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return o.shift(),o},lt=e=>e==="*"||e==="x"||e==="X",st=e=>{const o=parseInt(e,10);return isNaN(o)?e:o},Jn=(e,o)=>typeof e!=typeof o?[String(e),String(o)]:[e,o],Wn=(e,o)=>{if(lt(e)||lt(o))return 0;const[n,r]=Jn(st(e),st(o));return n>r?1:n<r?-1:0},ct=(e,o)=>{for(let n=0;n<Math.max(e.length,o.length);n++){const r=Wn(e[n]||"0",o[n]||"0");if(r!==0)return r}return 0},Zn=(e,o)=>{const n=it(e),r=it(o),a=n.pop(),i=r.pop(),l=ct(n,r);return l!==0?l:a&&i?ct(a.split("."),i.split(".")):a||i?a?-1:1:0},dt=(e,o,n)=>{Qn(n);const r=Zn(e,o);return ut[n].includes(r)},ut={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},pt=Object.keys(ut),Qn=e=>{if(typeof e!="string")throw new TypeError(`Invalid operator type, expected string but got ${typeof e}`);if(pt.indexOf(e)===-1)throw new Error(`Invalid operator, expected one of ${pt.join("|")}`)},Xn=e=>typeof e=="string"&&/^[v\d]/.test(e)&&at.test(e);function eo(e){const{gatewayInfo:o,supportedRange:n}=e;if(!o)return!0;const{edition:r,version:a}=o;if(!Xn(a))return console.error("Invalid version"),!1;const i=n[r];if(!i)return!1;const[l,s]=i;return!(l&&dt(a,l,"<")||s&&dt(a,s,">"))}const R={useAxios:Oe,useDebouncedFilter:Un,useDeleteUrlBuilder:Rn,useErrors:Gn,useFetcher:zn,useFetchUrlBuilder:rt,useHelpers:Hn,useStringHelpers:Yn,useI18n:je,useGatewayFeatureSupported:eo},to={fail:"Failed to copy id to clipboard",success:{prefix:"Successfully",content:" copied to clipboard"}},no="Copy to clipboard",oo={message:to,iconTitle:no},ro="kong-ui-copy-uuid-notify",ao={class:"kong-ui-copy-uuid"},io=["onClick"],mt=15,lo=t.defineComponent({__name:"CopyUuid",props:{uuid:{type:String,required:!0},idTooltip:{type:String,default:""},truncated:{type:Boolean,default:!0},useMono:{type:Boolean,default:!0},notify:{type:Function,default:void 0},iconColor:{type:String,default:"rgba(0, 0, 0, 0.45)"},tooltip:{type:String,default:""},successTooltip:{type:String,default:""},format:{type:String,required:!1,default:"uuid",validator:e=>["uuid","hidden","redacted","deleted"].includes(e)}},emits:["success","error"],setup(e,{emit:o}){const n=e,{t:r}=he.createI18n("en-us",oo),a=n.notify||t.inject(ro,()=>{}),i=t.computed(()=>n.idTooltip?{label:n.idTooltip,positionFixed:!0,placement:"bottomStart"}:{title:n.uuid}),l=t.computed(()=>!!(n.tooltip&&n.successTooltip)),s=t.ref(n.tooltip),c=t.computed(()=>n.tooltip?{label:s.value,positionFixed:!0,maxWidth:"500px",placement:"bottomStart"}:{}),u=t.computed(()=>n.format==="redacted"?"*****":n.format==="deleted"?`*${n.uuid.substring(0,5)}`:n.uuid),p=g=>{s.value=g,setTimeout(()=>{s.value=n.tooltip},1800)},d=g=>{if(!g(n.uuid)){typeof a=="function"&&a({type:"error",message:r("message.fail")}),l.value?p(r("message.fail")):o("error",n.uuid);return}const f=n.uuid.length>mt,b=n.format==="hidden"||n.format==="redacted"?r("message.success.prefix"):`"${n.uuid.substring(0,mt)+(f?"...":"")}"`;typeof a=="function"&&a({type:"success",message:`${b}${r("message.success.content")}`}),l.value?p(n.successTooltip):o("success",n.uuid)};return(g,f)=>{const b=t.resolveComponent("KIcon"),C=t.resolveComponent("KClipboardProvider");return t.openBlock(),t.createElementBlock("div",ao,[e.format!=="hidden"?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.idTooltip?"KTooltip":"div"),t.mergeProps({key:0},i.value,{"data-testid":"copy-id"}),{default:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(["uuid-container",e.truncated?"truncated-uuid":null,e.useMono?"mono":null])},t.toDisplayString(u.value),3)]),_:1},16)):t.createCommentVNode("",!0),(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.tooltip?"KTooltip":"div"),t.mergeProps(c.value,{class:"uuid-icon-wrapper"}),{default:t.withCtx(()=>[t.createVNode(C,null,{default:t.withCtx(({copyToClipboard:m})=>[t.createElementVNode("span",{"data-testid":"copy-to-clipboard",role:"button",tabindex:"0",onClick:t.withModifiers(h=>d(m),["stop"])},[t.createVNode(b,{class:"uuid-icon",color:e.iconColor,"hide-title":!!e.tooltip||void 0,icon:"copy",size:"16",title:t.unref(r)("iconTitle")},null,8,["color","hide-title","title"])],8,io)]),_:1})]),_:1},16))])}}}),so=(e,o)=>{const n=e.__vccOpts||e;for(const[r,a]of o)n[r]=a;return n},ft=so(lo,[["__scopeId","data-v-bfdaf6f7"]]),co={key:0,class:"config-card-fieldset-title"},uo=t.defineComponent({__name:"JsonCardItem",props:{item:{type:Object,required:!0},index:{type:Number,default:-1},isArrayItem:{type:Boolean,default:!1}},setup(e){const o=e,{i18n:{t:n}}=R.useI18n(),{convertKeyToTitle:r}=R.useStringHelpers(),a=t.computed(()=>o.item.key??"json-array-item"),i=t.computed(()=>o.item.value??o.item),l=t.computed(()=>{const c=JSON.parse(JSON.stringify(i.value));return o.isArrayItem&&delete c.name,c}),s=t.computed(()=>{var c;return o.isArrayItem?(c=i.value)!=null&&c.name?r(i.value.name,"_"):n("baseConfigCard.general.entryTitle",{index:o.index}):""});return(c,u)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.isArrayItem?"fieldset":"div"),{class:t.normalizeClass(e.isArrayItem?"config-card-fieldset":"config-card-json-item")},{default:t.withCtx(()=>[e.isArrayItem?(t.openBlock(),t.createElementBlock("legend",co,[t.createElementVNode("b",null,t.toDisplayString(s.value),1)])):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Object.keys(l.value),(p,d)=>(t.openBlock(),t.createBlock(Fe,{key:`${a.value}-property-${d}`,item:{key:p,label:t.unref(r)(p),value:l.value[p]}},null,8,["item"]))),128))]),_:1},8,["class"]))}}),Q=(e,o)=>{const n=e.__vccOpts||e;for(const[r,a]of o)n[r]=a;return n},gt=Q(uo,[["__scopeId","data-v-68ca83ec"]]),po=Q(t.defineComponent({__name:"InternalLinkItem",props:{item:{type:Object,required:!0}},emits:["navigation-click"],setup(e){const{i18n:{t:o}}=R.useI18n();return(n,r)=>{const a=t.resolveComponent("KButton");return t.openBlock(),t.createElementBlock("div",null,[t.createVNode(a,{appearance:"btn-link",class:"navigation-button",onClick:r[0]||(r[0]=i=>n.$emit("navigation-click",e.item))},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.item.value||t.unref(o)("baseConfigCard.commonFields.link")),1)]),_:1})])}}}),[["__scopeId","data-v-7410504d"]]),mo=t.defineComponent({__name:"StatusBadge",props:{status:{type:Boolean,default:!1}},setup(e){const{i18n:{t:o}}=R.useI18n();return(n,r)=>{const a=t.resolveComponent("KBadge");return t.openBlock(),t.createBlock(a,{appearance:e.status?"success":"neutral"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.status?t.unref(o)("baseConfigCard.statusBadge.enabledLabel"):t.unref(o)("baseConfigCard.statusBadge.disabledLabel")),1)]),_:1},8,["appearance"])}}}),fo="#0044f4",go="#e0e4ea",yo="#3a3f51",ho="1px",bo="20px",Co={class:"config-card-details-row"},ko=["data-testid"],wo=["data-testid"],xo=["data-testid"],So=["data-testid"],_o={key:1},Bo=["data-testid"],Io=["data-testid"],No=["data-testid"],Ao=["data-testid"],Eo=["title"],Vo={name:"ConfigCardItem",components:{CopyUuid:ft,JsonCardItem:gt,StatusBadge:mo,InternalLinkItem:po}},To=t.defineComponent({...Vo,props:{item:{type:Object,required:!0},slim:{type:Boolean,required:!1,default:!1},truncated:{type:Boolean,required:!1,default:!1}},emits:["navigation-click"],setup(e,{emit:o}){const n=e;t.useCssVars(d=>({"2c6ac268":u.value?"none":`solid ${t.unref(ho)} ${t.unref(go)}`,c7a65802:c.value&&l.value?"block":"flex","778426fe":c.value&&l.value?"100%":n.slim?"50%":"25%","777f9b48":c.value&&l.value?"100%":n.slim?"50%":"75%"}));const r=t.useSlots(),{i18n:{t:a,formatUnixTimeStamp:i}}=R.useI18n(),l=t.computed(()=>n.item.value!==void 0&&n.item.value!==null&&n.item.value!==""),s=t.computed(()=>!!(n.item.tooltip||r["label-tooltip"])),c=t.computed(()=>n.item.type===K.Json||n.item.type===K.JsonArray),u=t.computed(()=>n.item.type===K.JsonArray),p=t.computed(()=>{switch(n.item.type){case K.ID:return{tag:"CopyUuid",attrs:{"data-testid":`${n.item.key}-copy-uuid`,"success-tooltip":a("baseConfigCard.copy.success"),tooltip:a("baseConfigCard.copy.tooltip",{label:n.item.label}),truncated:!1,uuid:n.item.value,notify:()=>{}}};case K.IdArray:return{tag:"div",additionalComponent:"CopyUuid",childAttrs:{"success-tooltip":a("baseConfigCard.copy.success"),tooltip:a("baseConfigCard.copy.tooltip",{label:n.item.label}),truncated:!1,notify:()=>{}}};case K.Redacted:return{tag:"CopyUuid",attrs:{"data-testid":`${n.item.key}-copy-uuid-redacted`,format:"redacted","success-tooltip":a("baseConfigCard.copy.success"),tooltip:a("baseConfigCard.copy.tooltip",{label:n.item.label}),truncated:!1,uuid:n.item.value,notify:()=>{}}};case K.RedactedArray:return{tag:"div",additionalComponent:"CopyUuid",childAttrs:{format:"redacted","success-tooltip":a("baseConfigCard.copy.success"),tooltip:a("baseConfigCard.copy.tooltip",{label:n.item.label}),truncated:!1,notify:()=>{}}};case K.Date:return{tag:"div",attrs:{"data-testid":`${n.item.key}-date`},text:i(n.item.value)};case K.BadgeStatus:return{tag:"StatusBadge",attrs:{"data-testid":`${n.item.key}-badge-status`,status:n.item.value}};case K.BadgeTag:return{tag:"div",additionalComponent:"KBadge"};case K.BadgeMethod:return{tag:"div",additionalComponent:"KMethodBadge"};case K.LinkInternal:return{tag:"InternalLinkItem",attrs:{"data-testid":`${n.item.key}-internal-link`,item:n.item,onNavigationClick:d=>{o("navigation-click",d)}}};case K.LinkExternal:return{tag:"KExternalLink",attrs:{"data-testid":`${n.item.key}-external-link`,href:n.item.value},text:n.item.value};case K.Json:return{tag:"JsonCardItem",attrs:{"data-testid":`${n.item.key}-json-content`,item:n.item}};case K.JsonArray:return{tag:"div",additionalComponent:"JsonCardItem",attrs:{"data-testid":`${n.item.key}-json-array-content`,item:n.item}};default:return{tag:"div",attrs:{"data-testid":`${n.item.key}-plain-text`},text:n.item.value}}});return(d,g)=>{const f=t.resolveComponent("KLabel"),b=t.resolveComponent("KBadge"),C=t.resolveComponent("KMethodBadge");return t.openBlock(),t.createElementBlock("div",Co,[t.createElementVNode("div",{class:"config-card-details-label","data-testid":`${e.item.key}-label`},[t.renderSlot(d.$slots,"label",{item:e.item},()=>[t.createVNode(f,{"tooltip-attributes":{maxWidth:"500px"}},t.createSlots({default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.item.label)+" ",1)]),_:2},[s.value?{name:"tooltip",fn:t.withCtx(()=>[t.createElementVNode("div",{"data-testid":`${e.item.key}-label-tooltip`},[t.renderSlot(d.$slots,"label-tooltip",{},()=>[t.createTextVNode(t.toDisplayString(e.item.tooltip),1)],!0)],8,wo)]),key:"0"}:void 0]),1024)],!0)],8,ko),t.createElementVNode("div",{class:"config-card-details-value","data-testid":`${e.item.key}-property-value`},[t.renderSlot(d.$slots,e.item.key,{rowValue:e.item.value},()=>[l.value?(t.openBlock(),t.createElementBlock("div",_o,[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(p.value.tag),t.normalizeProps(t.guardReactiveProps(p.value.attrs)),{default:t.withCtx(()=>[p.value.additionalComponent==="KBadge"?(t.openBlock(),t.createElementBlock("div",{key:0,"data-testid":`${e.item.key}-badge-tags`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.item.value,(m,h)=>(t.openBlock(),t.createBlock(b,{key:`${e.item.key}-badge-tag-${h}`,class:"config-badge","data-testid":`${e.item.key}-badge-tag-${h}`,"truncation-tooltip":m},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(m),1)]),_:2},1032,["data-testid","truncation-tooltip"]))),128))],8,Bo)):t.createCommentVNode("",!0),p.value.additionalComponent==="CopyUuid"?(t.openBlock(),t.createElementBlock("div",{key:1,class:"copy-uuid-array","data-testid":`${e.item.key}-copy-uuid-array`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.item.value,(m,h)=>(t.openBlock(),t.createBlock(t.unref(ft),t.mergeProps(p.value.childAttrs,{key:`${e.item.key}-copy-uuid-${h}`,"data-testid":`${e.item.key}-copy-uuid-${h}`,uuid:m}),null,16,["data-testid","uuid"]))),128))],8,Io)):p.value.additionalComponent==="KMethodBadge"?(t.openBlock(),t.createElementBlock("div",{key:2,class:"method-badge-array","data-testid":`${e.item.key}-badge-methods`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.item.value,(m,h)=>(t.openBlock(),t.createBlock(C,{key:`${e.item.key}-badge-method-${h}`,class:"config-badge","data-testid":`${e.item.key}-badge-method-${h}`,"is-rounded":"",label:m,method:t.unref(An.MethodsArray).includes(m.toLowerCase())?m.toLowerCase():"custom"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(m),1)]),_:2},1032,["data-testid","label","method"]))),128))],8,No)):t.createCommentVNode("",!0),p.value.additionalComponent==="JsonCardItem"?(t.openBlock(),t.createElementBlock("div",{key:3,"data-testid":`${n.item.key}-json-array-content`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.item.value,(m,h)=>(t.openBlock(),t.createBlock(gt,{key:`json-array-item-${h}`,index:h,"is-array-item":"",item:m},null,8,["index","item"]))),128))],8,Ao)):(t.openBlock(),t.createElementBlock("span",{key:4,class:t.normalizeClass(["attrs-data-text",{truncated:e.truncated}]),title:e.truncated?e.item.value:void 0},t.toDisplayString(p.value.text),11,Eo))]),_:1},16))])):(t.openBlock(),t.createElementBlock("div",{key:0,"data-testid":`${e.item.key}-no-value`}," – ",8,So))],!0)],8,xo)])}}}),Fe=Q(To,[["__scopeId","data-v-a3c5ab01"]]);/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function yt(e){return typeof e>"u"||e===null}function $o(e){return typeof e=="object"&&e!==null}function Mo(e){return Array.isArray(e)?e:yt(e)?[]:[e]}function Oo(e,o){var n,r,a,i;if(o)for(i=Object.keys(o),n=0,r=i.length;n<r;n+=1)a=i[n],e[a]=o[a];return e}function Do(e,o){var n="",r;for(r=0;r<o;r+=1)n+=e;return n}function jo(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Fo=yt,Ko=$o,Lo=Mo,qo=Do,Po=jo,vo=Oo,v={isNothing:Fo,isObject:Ko,toArray:Lo,repeat:qo,isNegativeZero:Po,extend:vo};function ht(e,o){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!o&&e.mark.snippet&&(n+=`
|
|
2
2
|
|
|
3
3
|
`+e.mark.snippet),r+" "+n):r}function be(e,o){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=o,this.message=ht(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}be.prototype=Object.create(Error.prototype),be.prototype.constructor=be,be.prototype.toString=function(e){return this.name+": "+ht(this,e)};var H=be;function Ke(e,o,n,r,a){var i="",l="",s=Math.floor(a/2)-1;return r-o>s&&(i=" ... ",o=r-s+i.length),n-r>s&&(l=" ...",n=r+s-l.length),{str:i+e.slice(o,n).replace(/\t/g,"→")+l,pos:r-o+i.length}}function Le(e,o){return v.repeat(" ",o-e.length)+e}function Uo(e,o){if(o=Object.create(o||null),!e.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],a=[],i,l=-1;i=n.exec(e.buffer);)a.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&l<0&&(l=r.length-2);l<0&&(l=r.length-1);var s="",c,u,p=Math.min(e.line+o.linesAfter,a.length).toString().length,d=o.maxLength-(o.indent+p+3);for(c=1;c<=o.linesBefore&&!(l-c<0);c++)u=Ke(e.buffer,r[l-c],a[l-c],e.position-(r[l]-r[l-c]),d),s=v.repeat(" ",o.indent)+Le((e.line-c+1).toString(),p)+" | "+u.str+`
|
|
4
4
|
`+s;for(u=Ke(e.buffer,r[l],a[l],e.position,d),s+=v.repeat(" ",o.indent)+Le((e.line+1).toString(),p)+" | "+u.str+`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong-ui-public/entities-consumers",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/entities-consumers.umd.js",
|
|
6
6
|
"module": "./dist/entities-consumers.es.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"errorLimit": "400KB"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@kong-ui-public/entities-shared": "^1.5.
|
|
52
|
+
"@kong-ui-public/entities-shared": "^1.5.1"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"dev": "cross-env USE_SANDBOX=true vite",
|