@kong-ui-public/entities-consumers 4.0.8 → 4.0.9

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,8 +1,8 @@
1
- import { defineComponent as ce, ref as k, computed as I, watch as ye, resolveComponent as N, openBlock as D, createBlock as ne, unref as o, withCtx as l, createElementVNode as _, toDisplayString as b, createVNode as c, createElementBlock as L, createCommentVNode as z, Fragment as Le, renderList as He, onBeforeMount as Je, createSlots as ge, renderSlot as Se, Teleport as Qe, createTextVNode as te, reactive as Ge } from "vue";
1
+ import { defineComponent as ce, ref as k, computed as I, watch as ye, resolveComponent as N, createBlock as ne, openBlock as D, unref as o, withCtx as l, createElementVNode as _, createVNode as c, createElementBlock as L, createCommentVNode as z, toDisplayString as b, Fragment as Le, renderList as He, onBeforeMount as Je, createSlots as ge, createTextVNode as te, Teleport as Qe, renderSlot as Se, reactive as Ge } from "vue";
2
2
  import { useRouter as De } from "vue-router";
3
3
  import { BookIcon as ze, AddIcon as We, TeamIcon as Ye } from "@kong/icons";
4
4
  import { createI18n as Xe, i18nTComponent as Ze } from "@kong-ui-public/i18n";
5
- import { useAxios as he, useDebouncedFilter as et, useTableState as tt, useFetcher as ot, useDeleteUrlBuilder as st, FetcherStatus as nt, EntityBaseTable as rt, EntityFilter as at, PermissionsWrapper as le, TableTags as it, EntityEmptyState as lt, EntityDeleteModal as ut, EntityTypes as ct, useErrors as dt, EntityBaseFormType as Me, EntityBaseForm as mt, SupportedEntityType as Re, EntityFormSection as pt, ConfigurationSchemaSection as xe, EntityBaseConfigCard as ft } from "@kong-ui-public/entities-shared";
5
+ import { useAxios as he, useDebouncedFilter as et, useTableState as tt, useFetcher as ot, useDeleteUrlBuilder as st, FetcherStatus as nt, EntityBaseTable as rt, PermissionsWrapper as le, TableTags as at, EntityFilter as it, EntityEmptyState as lt, EntityDeleteModal as ut, EntityTypes as ct, useErrors as dt, EntityBaseFormType as Me, EntityBaseForm as mt, SupportedEntityType as Re, EntityFormSection as pt, ConfigurationSchemaSection as xe, EntityBaseConfigCard as ft } from "@kong-ui-public/entities-shared";
6
6
  const gt = "#00abd2", vt = "24px", yt = {
7
7
  list: {
8
8
  table_headers: {
@@ -163,13 +163,13 @@ const de = {
163
163
  }
164
164
  },
165
165
  emits: ["cancel", "add:success", "add:partial-success", "error"],
166
- setup(e, { emit: m }) {
166
+ setup(e, { emit: p }) {
167
167
  var v;
168
- const { i18n: { t: r } } = de.useI18n(), t = e, x = m, { axiosInstance: n } = he((v = t.config) == null ? void 0 : v.axiosRequestConfig), $ = k([]), {
168
+ const { i18n: { t: r } } = de.useI18n(), t = e, x = p, { axiosInstance: n } = he((v = t.config) == null ? void 0 : v.axiosRequestConfig), $ = k([]), {
169
169
  debouncedQueryChange: M,
170
170
  loading: U,
171
171
  allRecords: B,
172
- error: p,
172
+ error: m,
173
173
  loadItems: Y,
174
174
  results: H
175
175
  } = et(
@@ -180,7 +180,7 @@ const de = {
180
180
  fetchedItemsKey: "data",
181
181
  searchKeys: ["username", "id"]
182
182
  }
183
- ), O = (u) => u, V = I(() => p.value ? r("consumers.errors.general") : ""), re = k(0), J = I(() => B.value === void 0), Q = I(() => H.value.map((u) => ({
183
+ ), O = (u) => u, V = I(() => m.value ? r("consumers.errors.general") : ""), re = k(0), J = I(() => B.value === void 0), Q = I(() => H.value.map((u) => ({
184
184
  label: u.username || u.customId,
185
185
  value: u.id,
186
186
  selected: $.value.includes(u.id),
@@ -287,9 +287,9 @@ const de = {
287
287
  }, 8, ["action-button-disabled", "title", "visible"]);
288
288
  };
289
289
  }
290
- }), be = (e, m) => {
290
+ }), be = (e, p) => {
291
291
  const r = e.__vccOpts || e;
292
- for (const [t, x] of m)
292
+ for (const [t, x] of p)
293
293
  r[t] = x;
294
294
  return r;
295
295
  }, St = /* @__PURE__ */ be(Et, [["__scopeId", "data-v-d54468ab"]]), Gt = { class: "kong-ui-entities-consumers-list" }, Mt = { class: "button-row" }, xt = { class: "empty-state-wrapper" }, At = { class: "empty-state-icon-gateway" }, Dt = /* @__PURE__ */ ce({
@@ -337,14 +337,14 @@ const de = {
337
337
  }
338
338
  },
339
339
  emits: ["error", "click:learn-more", "copy:success", "copy:error", "delete:success", "add:success", "remove:success"],
340
- setup(e, { emit: m }) {
340
+ setup(e, { emit: p }) {
341
341
  var Ee;
342
- const r = m, t = e, { i18nT: x, i18n: { t: n } } = de.useI18n(), $ = De(), { axiosInstance: M } = he((Ee = t.config) == null ? void 0 : Ee.axiosRequestConfig), U = I(() => t.config.app !== "kongManager" || !!t.config.disableSorting), B = {
342
+ const r = p, t = e, { i18nT: x, i18n: { t: n } } = de.useI18n(), $ = De(), { axiosInstance: M } = he((Ee = t.config) == null ? void 0 : Ee.axiosRequestConfig), U = I(() => t.config.app !== "kongManager" || !!t.config.disableSorting), B = {
343
343
  // the Username column is non-hidable
344
344
  username: { label: n("consumers.list.table_headers.username"), searchable: !0, sortable: !0, hidable: !1 },
345
345
  custom_id: { label: n("consumers.list.table_headers.custom_id"), searchable: !0, sortable: !0 },
346
346
  tags: { label: n("consumers.list.table_headers.tags"), sortable: !1 }
347
- }, p = B, Y = (s) => ({
347
+ }, m = B, Y = (s) => ({
348
348
  "data-testid": s.username ?? s.custom_id ?? s.id
349
349
  }), H = () => {
350
350
  t.config.consumerGroupId ? _e() : $.push(t.config.createRoute);
@@ -491,7 +491,7 @@ const de = {
491
491
  "preferences-storage-key": P.value,
492
492
  query: V.value,
493
493
  "row-attributes": Y,
494
- "table-headers": o(p),
494
+ "table-headers": o(m),
495
495
  onClearSearchInput: i,
496
496
  "onClick:row": d[3] || (d[3] = (f) => y(f)),
497
497
  onEmptyStateCtaClicked: Pe,
@@ -500,7 +500,7 @@ const de = {
500
500
  }, ge({
501
501
  "toolbar-filter": l(() => [
502
502
  Se(s.$slots, "toolbar-filter", {}, void 0, !0),
503
- A.value ? z("", !0) : (D(), ne(o(at), {
503
+ A.value ? z("", !0) : (D(), ne(o(it), {
504
504
  key: 0,
505
505
  modelValue: V.value,
506
506
  "onUpdate:modelValue": d[0] || (d[0] = (f) => V.value = f),
@@ -555,7 +555,7 @@ const de = {
555
555
  te(b(T(f)), 1)
556
556
  ]),
557
557
  tags: l(({ rowValue: f }) => [
558
- c(o(it), { tags: f }, null, 8, ["tags"])
558
+ c(o(at), { tags: f }, null, 8, ["tags"])
559
559
  ]),
560
560
  actions: l(({ row: f }) => [
561
561
  c(j, null, {
@@ -732,8 +732,8 @@ const de = {
732
732
  var G = [];
733
733
  for (var ve = 0; ve < 256; ++ve)
734
734
  G.push((ve + 256).toString(16).slice(1));
735
- function Rt(e, m = 0) {
736
- return (G[e[m + 0]] + G[e[m + 1]] + G[e[m + 2]] + G[e[m + 3]] + "-" + G[e[m + 4]] + G[e[m + 5]] + "-" + G[e[m + 6]] + G[e[m + 7]] + "-" + G[e[m + 8]] + G[e[m + 9]] + "-" + G[e[m + 10]] + G[e[m + 11]] + G[e[m + 12]] + G[e[m + 13]] + G[e[m + 14]] + G[e[m + 15]]).toLowerCase();
735
+ function Rt(e, p = 0) {
736
+ return (G[e[p + 0]] + G[e[p + 1]] + G[e[p + 2]] + G[e[p + 3]] + "-" + G[e[p + 4]] + G[e[p + 5]] + "-" + G[e[p + 6]] + G[e[p + 7]] + "-" + G[e[p + 8]] + G[e[p + 9]] + "-" + G[e[p + 10]] + G[e[p + 11]] + G[e[p + 12]] + G[e[p + 13]] + G[e[p + 14]] + G[e[p + 15]]).toLowerCase();
737
737
  }
738
738
  var ue, Tt = new Uint8Array(16);
739
739
  function Ut() {
@@ -745,8 +745,8 @@ var Vt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(cryp
745
745
  const Ae = {
746
746
  randomUUID: Vt
747
747
  };
748
- function Ft(e, m, r) {
749
- if (Ae.randomUUID && !m && !e)
748
+ function Ft(e, p, r) {
749
+ if (Ae.randomUUID && !e)
750
750
  return Ae.randomUUID();
751
751
  e = e || {};
752
752
  var t = e.random || (e.rng || Ut)();
@@ -769,9 +769,9 @@ const Pt = { class: "kong-ui-entities-consumer-form" }, Bt = ["id"], Kt = { clas
769
769
  }
770
770
  },
771
771
  emits: ["update", "error", "loading"],
772
- setup(e, { emit: m }) {
772
+ setup(e, { emit: p }) {
773
773
  var X;
774
- const r = e, t = m, { i18nT: x, i18n: { t: n } } = de.useI18n(), $ = De(), { axiosInstance: M } = he((X = r.config) == null ? void 0 : X.axiosRequestConfig), { getMessageFromError: U } = dt(), B = Ft(), p = Ge({
774
+ const r = e, t = p, { i18nT: x, i18n: { t: n } } = de.useI18n(), $ = De(), { axiosInstance: M } = he((X = r.config) == null ? void 0 : X.axiosRequestConfig), { getMessageFromError: U } = dt(), B = Ft(), m = Ge({
775
775
  fields: {
776
776
  username: "",
777
777
  customId: "",
@@ -795,30 +795,30 @@ const Pt = { class: "kong-ui-entities-consumer-form" }, Bt = ["id"], Kt = { clas
795
795
  t("error", a);
796
796
  }, J = (a) => {
797
797
  var g, T, v;
798
- p.fields.username = ((g = a == null ? void 0 : a.item) == null ? void 0 : g.username) || (a == null ? void 0 : a.username) || "", p.fields.customId = ((T = a == null ? void 0 : a.item) == null ? void 0 : T.custom_id) || (a == null ? void 0 : a.custom_id) || "";
798
+ m.fields.username = ((g = a == null ? void 0 : a.item) == null ? void 0 : g.username) || (a == null ? void 0 : a.username) || "", m.fields.customId = ((T = a == null ? void 0 : a.item) == null ? void 0 : T.custom_id) || (a == null ? void 0 : a.custom_id) || "";
799
799
  const i = ((v = a == null ? void 0 : a.item) == null ? void 0 : v.tags) || (a == null ? void 0 : a.tags) || [];
800
- p.fields.tags = (i == null ? void 0 : i.join(", ")) || "", Object.assign(Y, p.fields);
800
+ m.fields.tags = (i == null ? void 0 : i.join(", ")) || "", Object.assign(Y, m.fields);
801
801
  }, Q = I(() => r.consumerId ? Me.Edit : Me.Create), K = (a) => {
802
802
  var g, T, v, u, C, y;
803
803
  let i = `${(g = r.config) == null ? void 0 : g.apiBaseUrl}${W.form[(T = r.config) == null ? void 0 : T.app][a]}`;
804
804
  return ((v = r.config) == null ? void 0 : v.app) === "konnect" ? i = i.replace(/{controlPlaneId}/gi, ((u = r.config) == null ? void 0 : u.controlPlaneId) || "") : ((C = r.config) == null ? void 0 : C.app) === "kongManager" && (i = i.replace(/\/{workspace}/gi, (y = r.config) != null && y.workspace ? `/${r.config.workspace}` : "")), i = i.replace(/{id}/gi, r.consumerId), i;
805
- }, A = I(() => !!p.fields.username || !!p.fields.customId), P = I(() => JSON.stringify(p.fields) !== JSON.stringify(Y)), R = I(() => {
805
+ }, A = I(() => !!m.fields.username || !!m.fields.customId), P = I(() => JSON.stringify(m.fields) !== JSON.stringify(Y)), R = I(() => {
806
806
  var a, i;
807
807
  return {
808
- username: p.fields.username || null,
809
- custom_id: p.fields.customId || null,
810
- tags: (i = (a = p.fields.tags.split(",")) == null ? void 0 : a.map((g) => String(g || "").trim())) == null ? void 0 : i.filter((g) => g !== "")
808
+ username: m.fields.username || null,
809
+ custom_id: m.fields.customId || null,
810
+ tags: (i = (a = m.fields.tags.split(",")) == null ? void 0 : a.map((g) => String(g || "").trim())) == null ? void 0 : i.filter((g) => g !== "")
811
811
  };
812
812
  }), F = async () => {
813
813
  var a;
814
814
  try {
815
- p.readonly = !0;
815
+ m.readonly = !0;
816
816
  let i;
817
817
  await M.post(K("validate"), R.value), Q.value === "create" ? i = await M.post(K("create"), R.value) : Q.value === "edit" && (i = ((a = r.config) == null ? void 0 : a.app) === "konnect" ? await M.put(K("edit"), R.value) : await M.patch(K("edit"), R.value)), J(i == null ? void 0 : i.data), t("update", i == null ? void 0 : i.data);
818
818
  } catch (i) {
819
- p.errorMessage = U(i), t("error", i);
819
+ m.errorMessage = U(i), t("error", i);
820
820
  } finally {
821
- p.readonly = !1;
821
+ m.readonly = !1;
822
822
  }
823
823
  };
824
824
  return (a, i) => {
@@ -829,10 +829,10 @@ const Pt = { class: "kong-ui-entities-consumer-form" }, Bt = ["id"], Kt = { clas
829
829
  config: e.config,
830
830
  "edit-id": e.consumerId,
831
831
  "entity-type": o(Re).Consumer,
832
- "error-message": p.errorMessage,
832
+ "error-message": m.errorMessage,
833
833
  "fetch-url": H.value,
834
834
  "form-fields": R.value,
835
- "is-readonly": p.readonly,
835
+ "is-readonly": m.readonly,
836
836
  onCancel: O,
837
837
  "onFetch:error": i[3] || (i[3] = (v) => re(v)),
838
838
  "onFetch:success": J,
@@ -860,8 +860,8 @@ const Pt = { class: "kong-ui-entities-consumer-form" }, Bt = ["id"], Kt = { clas
860
860
  "aria-labelledby": `fields-group-title-${o(B)}`
861
861
  }, [
862
862
  c(g, {
863
- modelValue: p.fields.username,
864
- "onUpdate:modelValue": i[0] || (i[0] = (v) => p.fields.username = v),
863
+ modelValue: m.fields.username,
864
+ "onUpdate:modelValue": i[0] || (i[0] = (v) => m.fields.username = v),
865
865
  modelModifiers: { trim: !0 },
866
866
  autocomplete: "off",
867
867
  class: "username-field",
@@ -869,7 +869,7 @@ const Pt = { class: "kong-ui-entities-consumer-form" }, Bt = ["id"], Kt = { clas
869
869
  label: o(n)("consumers.fields.username.label"),
870
870
  "label-attributes": { tooltipAttributes: { maxWidth: "400" } },
871
871
  placeholder: o(n)("consumers.fields.username.placeholder"),
872
- readonly: p.readonly,
872
+ readonly: m.readonly,
873
873
  type: "text"
874
874
  }, {
875
875
  "label-tooltip": l(() => [
@@ -886,15 +886,15 @@ const Pt = { class: "kong-ui-entities-consumer-form" }, Bt = ["id"], Kt = { clas
886
886
  _: 1
887
887
  }, 8, ["modelValue", "label", "placeholder", "readonly"]),
888
888
  c(g, {
889
- modelValue: p.fields.customId,
890
- "onUpdate:modelValue": i[1] || (i[1] = (v) => p.fields.customId = v),
889
+ modelValue: m.fields.customId,
890
+ "onUpdate:modelValue": i[1] || (i[1] = (v) => m.fields.customId = v),
891
891
  modelModifiers: { trim: !0 },
892
892
  autocomplete: "off",
893
893
  "data-testid": "consumer-form-custom-id",
894
894
  label: o(n)("consumers.fields.custom_id.label"),
895
895
  "label-attributes": { tooltipAttributes: { maxWidth: "400" } },
896
896
  placeholder: o(n)("consumers.fields.custom_id.placeholder"),
897
- readonly: p.readonly,
897
+ readonly: m.readonly,
898
898
  type: "text"
899
899
  }, {
900
900
  "label-tooltip": l(() => [
@@ -915,8 +915,8 @@ const Pt = { class: "kong-ui-entities-consumer-form" }, Bt = ["id"], Kt = { clas
915
915
  _: 1
916
916
  }),
917
917
  c(g, {
918
- modelValue: p.fields.tags,
919
- "onUpdate:modelValue": i[2] || (i[2] = (v) => p.fields.tags = v),
918
+ modelValue: m.fields.tags,
919
+ "onUpdate:modelValue": i[2] || (i[2] = (v) => m.fields.tags = v),
920
920
  modelModifiers: { trim: !0 },
921
921
  autocomplete: "off",
922
922
  "data-testid": "consumer-form-tags",
@@ -927,7 +927,7 @@ const Pt = { class: "kong-ui-entities-consumer-form" }, Bt = ["id"], Kt = { clas
927
927
  tooltipAttributes: { maxWidth: "400" }
928
928
  },
929
929
  placeholder: o(n)("consumers.fields.tags.placeholder"),
930
- readonly: p.readonly,
930
+ readonly: m.readonly,
931
931
  type: "text"
932
932
  }, null, 8, ["modelValue", "help", "label", "label-attributes", "placeholder", "readonly"])
933
933
  ]),
@@ -967,7 +967,7 @@ const Pt = { class: "kong-ui-entities-consumer-form" }, Bt = ["id"], Kt = { clas
967
967
  },
968
968
  emits: ["loading", "fetch:error", "fetch:success"],
969
969
  setup(e) {
970
- const m = e, { i18n: { t: r }, i18nT: t } = de.useI18n(), x = I(() => W.form[m.config.app].edit), n = k({
970
+ const p = e, { i18n: { t: r }, i18nT: t } = de.useI18n(), x = I(() => W.form[p.config.app].edit), n = k({
971
971
  id: {},
972
972
  username: {
973
973
  section: xe.Basic,
@@ -1 +1 @@
1
- (function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-router"),require("@kong/icons"),require("@kong-ui-public/i18n"),require("@kong-ui-public/entities-shared")):typeof define=="function"&&define.amd?define(["exports","vue","vue-router","@kong/icons","@kong-ui-public/i18n","@kong-ui-public/entities-shared"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E["kong-ui-public-entities-consumers"]={},E.Vue,E.VueRouter,E.KongIcons,E["kong-ui-public-i18n"],E["kong-ui-public-entities-shared"]))})(this,function(E,e,ae,ee,ie,d){"use strict";const ye="#00abd2",he="24px",Ce={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"},empty_state_v2:{title:"Configure your first consumer",group:"Consumers created in gateways within this group will automatically appear here.",description:"Consumers represent users or apps accessing your APIs, allowing for tailored authentication and individual access control."},toolbar_actions:{new_consumer:"New consumer"}},title:"Consumers",search:{placeholder:{konnect:"Filter by name",kongManager:"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 and delete all its plugins. 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 be(){const t=ie.createI18n("en-us",Ce);return{i18n:t,i18nT:ie.i18nTComponent(t)}}const Y={useI18n:be},j="/v2/control-planes/{controlPlaneId}/core-entities",L="/{workspace}",F={list:{konnect:{all:`${j}/consumers`,forConsumerGroup:`${j}/consumer_groups/{consumerGroupId}/consumers`,oneForConsumerGroup:`${j}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`},kongManager:{all:`${L}/consumers`,forConsumerGroup:`${L}/consumer_groups/{consumerGroupId}/consumers`,oneForConsumerGroup:`${L}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`}},form:{konnect:{validate:`${j}/v1/schemas/json/consumer/validate`,create:`${j}/consumers`,edit:`${j}/consumers/{id}`},kongManager:{validate:`${L}/schemas/consumers/validate`,create:`${L}/consumers`,edit:`${L}/consumers/{id}`}}},ke={class:"add-consumer-form-container"},_e={class:"add-consumer-form-cta"},we={class:"select-item-label"},Ie={key:0,class:"select-item-desc"},Ve={key:0,class:"kong-ui-entity-add-consumers-error"},Ne={key:0},xe=e.defineComponent({__name:"AddConsumerModal",props:{config:{type:Object,required:!0,validator:t=>!(!t||!["konnect","kongManager"].includes(t==null?void 0:t.app)||!t.consumerGroupId)},visible:{type:Boolean,required:!0,default:!1}},emits:["cancel","add:success","add:partial-success","error"],setup(t,{emit:u}){var g;const{i18n:{t:s}}=Y.useI18n(),o=t,N=u,{axiosInstance:r}=d.useAxios((g=o.config)==null?void 0:g.axiosRequestConfig),_=e.ref([]),{debouncedQueryChange:V,loading:B,allRecords:T,error:m,loadItems:H,results:q}=d.useDebouncedFilter(o.config,F.list[o.config.app].all,"",{fetchedItemsKey:"data",searchKeys:["username","id"]}),P=l=>l,S=e.computed(()=>m.value?s("consumers.errors.general"):""),z=e.ref(0),K=e.computed(()=>T.value===void 0),O=e.computed(()=>q.value.map(l=>({label:l.username||l.customId,value:l.id,selected:_.value.includes(l.id),data:l}))),A=l=>{var y;const C=K.value?q.value.find(w=>w.id===l):(y=T.value)==null?void 0:y.find(w=>w.id===l);return C?C.username||C.custom_id:l},x=()=>{G.value="",M.value=[],f.value=[],N("cancel")},M=e.ref([]),$=e.ref(!1),G=e.ref(""),W=async()=>{if(!_.value.length){G.value="",f.value=[],N("cancel");return}$.value=!0,G.value="",M.value=[],f.value=[];try{const l=_.value.map(w=>i(w)),C=await Promise.allSettled(l);let y=!0;C.forEach(w=>{w.status!=="fulfilled"&&(y=!1)}),y?(M.value=[],f.value=[],N("add:success",_.value),_.value=[]):(M.value.length&&N("add:partial-success",M.value),_.value=[],D(C))}catch{G.value=s("consumers.errors.add"),N("error",G.value)}finally{$.value=!1}},a=e.computed(()=>{var C,y,w,J;let l=`${o.config.apiBaseUrl}${F.list[o.config.app].forConsumerGroup}`;return o.config.app==="konnect"?l=l.replace(/{controlPlaneId}/gi,((C=o.config)==null?void 0:C.controlPlaneId)||"").replace(/{consumerGroupId}/gi,((y=o.config)==null?void 0:y.consumerGroupId)||""):o.config.app==="kongManager"&&(l=l.replace(/\/{workspace}/gi,(w=o.config)!=null&&w.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((J=o.config)==null?void 0:J.consumerGroupId)||"")),l}),i=async l=>{const C={consumer:l};try{const y=await r.post(a.value,C);return M.value.push(l),y}catch(y){let w=`${A(l)} - ${y.message}`;return y.response.status===409&&(w=`${A(l)} - ${s("consumers.errors.already_added")}`),Promise.reject(Error(w))}},f=e.ref([]),D=l=>{f.value=l.map(C=>{var y;return(y=C.reason)==null?void 0:y.message}).filter(Boolean)};return e.watch(O,()=>{z.value++},{immediate:!0,deep:!0}),e.watch(()=>o.visible,()=>{o.visible&&H()},{immediate:!0}),(l,C)=>{const y=e.resolveComponent("KMultiselect"),w=e.resolveComponent("KAlert"),J=e.resolveComponent("KPrompt");return e.openBlock(),e.createBlock(J,{"action-button-disabled":$.value,class:"kong-ui-entities-add-consumers-modal","data-testid":"add-consumer-modal",title:e.unref(s)("consumers.consumer_groups.add.title"),visible:t.visible,onCancel:x,onProceed:W},{default:e.withCtx(()=>[e.createElementVNode("div",ke,[e.createElementVNode("p",_e,e.toDisplayString(e.unref(s)("consumers.consumer_groups.add.ctaText")),1),e.createVNode(y,{modelValue:_.value,"onUpdate:modelValue":C[0]||(C[0]=I=>_.value=I),autosuggest:"","data-testid":"add-consumers-multiselect","dropdown-footer-text":K.value?e.unref(s)("consumers.consumer_groups.add.footer"):void 0,items:O.value,label:e.unref(s)("consumers.consumer_groups.add.consumers_label"),loading:e.unref(B),placeholder:e.unref(s)("consumers.consumer_groups.add.consumer_placeholder"),readonly:$.value,required:"",width:"100%",onQueryChange:e.unref(V)},{"item-template":e.withCtx(({item:I})=>[e.createElementVNode("div",we,e.toDisplayString(I.label),1),P(I).data.username&&P(I).data.custom_id?(e.openBlock(),e.createElementBlock("div",Ie,e.toDisplayString(P(I).data.custom_id),1)):e.createCommentVNode("",!0)]),_:1},8,["modelValue","dropdown-footer-text","items","label","loading","placeholder","readonly","onQueryChange"]),G.value||S.value||f.value.length?(e.openBlock(),e.createElementBlock("div",Ve,[e.createVNode(w,{appearance:"danger"},{default:e.withCtx(()=>[e.createElementVNode("p",null,e.toDisplayString(e.unref(s)("consumers.errors.add")),1),f.value.length?(e.openBlock(),e.createElementBlock("ul",Ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(I,Q)=>(e.openBlock(),e.createElementBlock("li",{key:Q},e.toDisplayString(I),1))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",null,e.toDisplayString(G.value||S.value),1)]),_:1})])):e.createCommentVNode("",!0)])]),_:1},8,["action-button-disabled","title","visible"])}}}),te=(t,u)=>{const s=t.__vccOpts||t;for(const[o,N]of u)s[o]=N;return s},Ee=te(xe,[["__scopeId","data-v-d54468ab"]]),$e={class:"kong-ui-entities-consumers-list"},De={class:"button-row"},Be={class:"empty-state-wrapper"},Se={class:"empty-state-icon-gateway"},Ge=te(e.defineComponent({__name:"ConsumerList",props:{config:{type:Object,required:!0,validator:t=>!(!t||!["konnect","kongManager"].includes(t==null?void 0:t.app)||!t.createRoute||!t.getViewRoute||!t.getEditRoute||t.app==="kongManager"&&!t.isExactMatch&&!t.filterSchema)},cacheIdentifier:{type:String,default:""},canCreate:{type:Function,required:!1,default:async()=>!0},canDelete:{type:Function,required:!1,default:async()=>!0},canEdit:{type:Function,required:!1,default:async()=>!0},canRetrieve:{type:Function,required:!1,default:async()=>!0},useActionOutside:{type:Boolean,default:!1}},emits:["error","click:learn-more","copy:success","copy:error","delete:success","add:success","remove:success"],setup(t,{emit:u}){var ge;const s=u,o=t,{i18nT:N,i18n:{t:r}}=Y.useI18n(),_=ae.useRouter(),{axiosInstance:V}=d.useAxios((ge=o.config)==null?void 0:ge.axiosRequestConfig),B=e.computed(()=>o.config.app!=="kongManager"||!!o.config.disableSorting),T={username:{label:r("consumers.list.table_headers.username"),searchable:!0,sortable:!0,hidable:!1},custom_id:{label:r("consumers.list.table_headers.custom_id"),searchable:!0,sortable:!0},tags:{label:r("consumers.list.table_headers.tags"),sortable:!1}},m=T,H=n=>({"data-testid":n.username??n.custom_id??n.id}),q=()=>{o.config.consumerGroupId?de():_.push(o.config.createRoute)},P=e.computed(()=>{var c,h,b,U;let n=`${o.config.apiBaseUrl}${F.list[o.config.app][x.value?"forConsumerGroup":"all"]}`;return o.config.app==="konnect"?n=n.replace(/{controlPlaneId}/gi,((c=o.config)==null?void 0:c.controlPlaneId)||"").replace(/{consumerGroupId}/gi,((h=o.config)==null?void 0:h.consumerGroupId)||""):o.config.app==="kongManager"&&(n=n.replace(/\/{workspace}/gi,(b=o.config)!=null&&b.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((U=o.config)==null?void 0:U.consumerGroupId)||"")),n}),S=e.ref(""),z=e.computed(()=>{const n=o.config.app==="konnect"||o.config.isExactMatch;return n?{isExactMatch:n,placeholder:r(`consumers.search.placeholder.${o.config.app}`)}:{isExactMatch:n,fields:{username:T.username,custom_id:T.custom_id},schema:o.config.filterSchema}}),{hasRecords:K,handleStateChange:O}=d.useTableState(S),A=e.computed(()=>K.value&&o.config.app==="konnect"),x=e.computed(()=>!!o.config.consumerGroupId),M=e.computed(()=>x.value?"kong-ui-entities-consumers-list-in-group-page":"kong-ui-entities-consumers-list"),$=e.computed(()=>x.value&&!o.config.paginatedEndpoint?"consumers":void 0),{fetcher:G,fetcherState:W,fetcherCacheKey:a}=d.useFetcher(e.computed(()=>({...o.config,cacheIdentifier:o.cacheIdentifier})),P,$),i=()=>{S.value=""},f=()=>{a.value++},D=n=>n??"-",g=e.ref(null),l=async(n,c)=>{const h=n.id;if(!await c(h)){s("copy:error",{entity:n,field:"id",message:r("consumers.errors.copy")});return}s("copy:success",{entity:n,field:"id",message:r("consumers.copy.success",{val:h})})},C=(n,c)=>{const h=JSON.stringify(n);if(!c(h)){s("copy:error",{entity:n,message:r("consumers.errors.copy")});return}s("copy:success",{entity:n,message:r("consumers.copy.success_brief")})},y=async n=>{var h;await((h=o.canRetrieve)==null?void 0:h.call(o,n))&&_.push(o.config.getViewRoute(n.id))},w=n=>({label:r("consumers.actions.view"),to:o.config.getViewRoute(n)}),J=n=>({label:r("consumers.actions.edit"),to:o.config.getEditRoute(n)}),I=e.ref(void 0),Q=e.ref(!1),Z=e.ref(!1),ce=e.ref(""),He=d.useDeleteUrlBuilder(o.config,P.value),We=n=>{I.value=n,Q.value=!0},Je=()=>{Q.value=!1},Qe=async()=>{var n,c,h;if((n=I.value)!=null&&n.id){Z.value=!0;try{await V.delete(He(I.value.id)),Z.value=!1,Q.value=!1,a.value++,s("delete:success",I.value)}catch(b){ce.value=((h=(c=b.response)==null?void 0:c.data)==null?void 0:h.message)||b.message||r("consumers.errors.delete"),s("error",b)}finally{Z.value=!1}}},ne=e.ref(!1),de=()=>{ne.value=!0},ue=()=>{ne.value=!1},me=(n,c)=>{c||ue(),a.value++,s("add:success",n)},ze=()=>{x.value&&de()},R=e.ref(void 0),re=e.ref(!1),Ye=e.ref(""),Xe=n=>{R.value=n,re.value=!0},pe=()=>{re.value=!1,R.value=void 0},Ze=e.computed(()=>{var c,h,b,U;let n=`${o.config.apiBaseUrl}${F.list[o.config.app].oneForConsumerGroup}`;return o.config.app==="konnect"?n=n.replace(/{controlPlaneId}/gi,((c=o.config)==null?void 0:c.controlPlaneId)||"").replace(/{consumerGroupId}/gi,((h=o.config)==null?void 0:h.consumerGroupId)||""):o.config.app==="kongManager"&&(n=n.replace(/\/{workspace}/gi,(b=o.config)!=null&&b.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((U=o.config)==null?void 0:U.consumerGroupId)||"")),n}),fe=e.ref(!1),ve=async()=>{if(R.value){fe.value=!0;try{const n=Ze.value.replace(/{consumerId}/gi,R.value.id);await V.delete(n),s("remove:success",R.value),pe(),a.value++}catch(n){Ye.value=n.message||r("consumers.errors.delete"),s("error",n)}finally{fe.value=!1}}};e.watch(W,n=>{var c,h,b;if(n.status===d.FetcherStatus.Error){g.value={title:r("consumers.errors.general")},(b=(h=(c=n.error)==null?void 0:c.response)==null?void 0:h.data)!=null&&b.message&&(g.value.message=n.error.response.data.message),s("error",n.error);return}g.value=null});const se=e.ref({ctaPath:x.value?void 0:o.config.createRoute,ctaText:void 0,message:`${r("consumers.list.empty_state.description")}${o.config.additionMessageForEmptyState?` ${o.config.additionMessageForEmptyState}`:""}`,title:r("consumers.title")});return e.onBeforeMount(async()=>{await o.canCreate()&&(se.value.title=x.value?r("consumers.list.empty_state.title_for_consumer_group"):r("consumers.list.empty_state.title"),se.value.ctaText=x.value?r("consumers.actions.add_consumer"):r("consumers.actions.create"))}),(n,c)=>{const h=e.resolveComponent("KButton"),b=e.resolveComponent("KDropdownItem"),U=e.resolveComponent("KClipboardProvider"),et=e.resolveComponent("KPrompt");return e.openBlock(),e.createElementBlock("div",$e,[e.createVNode(e.unref(d.EntityBaseTable),{"cache-identifier":t.cacheIdentifier,"disable-sorting":B.value,"empty-state-options":se.value,"enable-entity-actions":"","error-message":g.value,fetcher:e.unref(G),"fetcher-cache-key":e.unref(a),"hide-pagination":x.value&&!t.config.paginatedEndpoint,"pagination-type":"offset","preferences-storage-key":M.value,query:S.value,"row-attributes":H,"table-headers":e.unref(m),onClearSearchInput:i,"onClick:row":c[3]||(c[3]=p=>y(p)),onEmptyStateCtaClicked:ze,onSort:f,onState:e.unref(O)},e.createSlots({"toolbar-filter":e.withCtx(()=>[e.renderSlot(n.$slots,"toolbar-filter",{},void 0,!0),x.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(d.EntityFilter),{key:0,modelValue:S.value,"onUpdate:modelValue":c[0]||(c[0]=p=>S.value=p),config:z.value},null,8,["modelValue","config"]))]),"toolbar-button":e.withCtx(()=>[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!t.useActionOutside,to:"#kong-ui-app-page-header-action-button"},[e.createElementVNode("div",De,[!x.value&&A.value?(e.openBlock(),e.createBlock(h,{key:0,appearance:"secondary",class:"open-learning-hub","data-testid":"consumers-learn-more-button",icon:"",onClick:c[1]||(c[1]=p=>n.$emit("click:learn-more"))},{default:e.withCtx(()=>[e.createVNode(e.unref(ee.BookIcon),{decorative:""})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(d.PermissionsWrapper),{"auth-function":()=>t.canCreate()},{default:e.withCtx(()=>[e.createVNode(h,{appearance:"primary","data-testid":"toolbar-add-consumer",size:t.useActionOutside?"medium":"large",onClick:q},{default:e.withCtx(()=>[e.createVNode(e.unref(ee.AddIcon)),e.createTextVNode(" "+e.toDisplayString(t.config.consumerGroupId?e.unref(r)("consumers.actions.add_consumer"):e.unref(r)("consumers.list.toolbar_actions.new_consumer")),1)]),_:1},8,["size"])]),_:1},8,["auth-function"])])],8,["disabled"]))]),username:e.withCtx(({rowValue:p})=>[e.createElementVNode("b",null,e.toDisplayString(D(p)),1)]),custom_id:e.withCtx(({rowValue:p})=>[e.createTextVNode(e.toDisplayString(D(p)),1)]),tags:e.withCtx(({rowValue:p})=>[e.createVNode(e.unref(d.TableTags),{tags:p},null,8,["tags"])]),actions:e.withCtx(({row:p})=>[e.createVNode(U,null,{default:e.withCtx(({copyToClipboard:v})=>[e.createVNode(b,{"data-testid":"action-entity-copy-id",onClick:tt=>l(p,v)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.actions.copy_id")),1)]),_:2},1032,["onClick"])]),_:2},1024),e.createVNode(U,null,{default:e.withCtx(({copyToClipboard:v})=>[e.createVNode(b,{"data-testid":"action-entity-copy-json",onClick:tt=>C(p,v)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.actions.copy_json")),1)]),_:2},1032,["onClick"])]),_:2},1024),e.createVNode(e.unref(d.PermissionsWrapper),{"auth-function":()=>t.canRetrieve(p)},{default:e.withCtx(()=>[e.createVNode(b,{"data-testid":"action-entity-view","has-divider":"",item:w(p.id)},null,8,["item"])]),_:2},1032,["auth-function"]),e.createVNode(e.unref(d.PermissionsWrapper),{"auth-function":()=>t.canEdit(p)},{default:e.withCtx(()=>[e.createVNode(b,{"data-testid":"action-entity-edit",item:J(p.id)},null,8,["item"])]),_:2},1032,["auth-function"]),e.createVNode(e.unref(d.PermissionsWrapper),{"auth-function":()=>t.canDelete(p)},{default:e.withCtx(()=>[e.createVNode(b,{danger:"","data-testid":"action-entity-delete","has-divider":"",onClick:()=>t.config.consumerGroupId?Xe(p):We(p)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.config.consumerGroupId?e.unref(r)("consumers.actions.remove"):e.unref(r)("consumers.actions.delete")),1)]),_:2},1032,["onClick"])]),_:2},1032,["auth-function"])]),_:2},[!S.value&&t.config.app==="konnect"?{name:"empty-state",fn:e.withCtx(()=>{var p;return[e.createElementVNode("div",Be,[e.renderSlot(n.$slots,"empty-state-toolbar",{},void 0,!0),e.createVNode(e.unref(d.EntityEmptyState),{"action-button-text":e.unref(r)("consumers.list.toolbar_actions.new_consumer"),appearance:"secondary","can-create":()=>t.canCreate(),"data-testid":t.config.consumerGroupId?"nested-consumers-entity-empty-state":"consumers-entity-empty-state",description:e.unref(r)("consumers.list.empty_state_v2.description"),"learn-more":t.config.app==="konnect",title:e.unref(r)("consumers.list.empty_state_v2.title"),"onClick:create":q,"onClick:learnMore":c[2]||(c[2]=v=>n.$emit("click:learn-more"))},e.createSlots({image:e.withCtx(()=>[e.createElementVNode("div",Se,[e.createVNode(e.unref(ee.TeamIcon),{color:e.unref(ye),size:e.unref(he)},null,8,["color","size"])])]),_:2},[(p=t.config)!=null&&p.isControlPlaneGroup?{name:"message",fn:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.list.empty_state_v2.group")),1)]),key:"0"}:void 0]),1032,["action-button-text","can-create","data-testid","description","learn-more","title"])])]}),key:"0"}:void 0]),1032,["cache-identifier","disable-sorting","empty-state-options","error-message","fetcher","fetcher-cache-key","hide-pagination","preferences-storage-key","query","table-headers","onState"]),e.createVNode(e.unref(d.EntityDeleteModal),{"action-button-disabled":Z.value,"data-testid":"delete-consumer-modal",description:e.unref(r)("consumers.delete.description"),"entity-name":I.value&&(I.value.username||I.value.custom_id||I.value.id),"entity-type":e.unref(d.EntityTypes).Consumer,error:ce.value,title:e.unref(r)("consumers.delete.title"),visible:Q.value,onCancel:Je,onProceed:Qe},null,8,["action-button-disabled","description","entity-name","entity-type","error","title","visible"]),t.config.consumerGroupId?(e.openBlock(),e.createBlock(Ee,{key:0,config:t.config,"data-testid":"add-consumer-modal",visible:ne.value,"onAdd:partialSuccess":c[4]||(c[4]=p=>me(p,!0)),"onAdd:success":c[5]||(c[5]=p=>me(p)),onCancel:ue},null,8,["config","visible"])):e.createCommentVNode("",!0),t.config.consumerGroupId&&R.value?(e.openBlock(),e.createBlock(et,{key:1,"action-button-appearance":"danger","data-testid":"remove-consumer-modal",title:e.unref(r)("consumers.consumer_groups.remove.title"),visible:re.value,onCancel:pe,onProceed:ve},{default:e.withCtx(()=>[e.createVNode(e.unref(N),{class:"message",keypath:t.config.consumerGroupName?"consumers.consumer_groups.remove.confirmation":"consumers.consumer_groups.remove.confirmationNoCG",tag:"p"},e.createSlots({consumer:e.withCtx(()=>[e.createElementVNode("strong",null,e.toDisplayString(R.value.username||R.value.custom_id||R.value.id),1)]),_:2},[t.config.consumerGroupName?{name:"consumerGroup",fn:e.withCtx(()=>[e.createElementVNode("strong",null,e.toDisplayString(t.config.consumerGroupName),1)]),key:"0"}:void 0]),1032,["keypath"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(r)("consumers.consumer_groups.remove.description")),1)]),_:1},8,["title","visible"])):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-c5be280d"]]);for(var k=[],oe=0;oe<256;++oe)k.push((oe+256).toString(16).slice(1));function Me(t,u=0){return(k[t[u+0]]+k[t[u+1]]+k[t[u+2]]+k[t[u+3]]+"-"+k[t[u+4]]+k[t[u+5]]+"-"+k[t[u+6]]+k[t[u+7]]+"-"+k[t[u+8]]+k[t[u+9]]+"-"+k[t[u+10]]+k[t[u+11]]+k[t[u+12]]+k[t[u+13]]+k[t[u+14]]+k[t[u+15]]).toLowerCase()}var X,Te=new Uint8Array(16);function Ae(){if(!X&&(X=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!X))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return X(Te)}var Re=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const le={randomUUID:Re};function Pe(t,u,s){if(le.randomUUID&&!u&&!t)return le.randomUUID();t=t||{};var o=t.random||(t.rng||Ae)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,Me(o)}const Ue={class:"kong-ui-entities-consumer-form"},Fe=["id"],qe={class:"fields-group-text"},Ke=["aria-labelledby"],Oe=te(e.defineComponent({__name:"ConsumerForm",props:{config:{type:Object,required:!0,validator:t=>!(!t||!["konnect","kongManager"].includes(t==null?void 0:t.app)||(t==null?void 0:t.app)==="konnect"&&!(t!=null&&t.controlPlaneId)||(t==null?void 0:t.app)==="kongManager"&&typeof(t==null?void 0:t.workspace)!="string"||!(t!=null&&t.cancelRoute))},consumerId:{type:String,required:!1,default:""}},emits:["update","error","loading"],setup(t,{emit:u}){var W;const s=t,o=u,{i18nT:N,i18n:{t:r}}=Y.useI18n(),_=ae.useRouter(),{axiosInstance:V}=d.useAxios((W=s.config)==null?void 0:W.axiosRequestConfig),{getMessageFromError:B}=d.useErrors(),T=Pe(),m=e.reactive({fields:{username:"",customId:"",tags:""},readonly:!1,errorMessage:""}),H=e.reactive({username:"",customId:"",tags:""}),q=e.computed(()=>{var a,i;return(i=F.form[(a=s.config)==null?void 0:a.app])==null?void 0:i.edit}),P=()=>{var a;_.push(((a=s.config)==null?void 0:a.cancelRoute)||{name:"consumer-list"})},S=a=>{o("loading",a)},z=a=>{o("error",a)},K=a=>{var f,D,g;m.fields.username=((f=a==null?void 0:a.item)==null?void 0:f.username)||(a==null?void 0:a.username)||"",m.fields.customId=((D=a==null?void 0:a.item)==null?void 0:D.custom_id)||(a==null?void 0:a.custom_id)||"";const i=((g=a==null?void 0:a.item)==null?void 0:g.tags)||(a==null?void 0:a.tags)||[];m.fields.tags=(i==null?void 0:i.join(", "))||"",Object.assign(H,m.fields)},O=e.computed(()=>s.consumerId?d.EntityBaseFormType.Edit:d.EntityBaseFormType.Create),A=a=>{var f,D,g,l,C,y;let i=`${(f=s.config)==null?void 0:f.apiBaseUrl}${F.form[(D=s.config)==null?void 0:D.app][a]}`;return((g=s.config)==null?void 0:g.app)==="konnect"?i=i.replace(/{controlPlaneId}/gi,((l=s.config)==null?void 0:l.controlPlaneId)||""):((C=s.config)==null?void 0:C.app)==="kongManager"&&(i=i.replace(/\/{workspace}/gi,(y=s.config)!=null&&y.workspace?`/${s.config.workspace}`:"")),i=i.replace(/{id}/gi,s.consumerId),i},x=e.computed(()=>!!m.fields.username||!!m.fields.customId),M=e.computed(()=>JSON.stringify(m.fields)!==JSON.stringify(H)),$=e.computed(()=>{var a,i;return{username:m.fields.username||null,custom_id:m.fields.customId||null,tags:(i=(a=m.fields.tags.split(","))==null?void 0:a.map(f=>String(f||"").trim()))==null?void 0:i.filter(f=>f!=="")}}),G=async()=>{var a;try{m.readonly=!0;let i;await V.post(A("validate"),$.value),O.value==="create"?i=await V.post(A("create"),$.value):O.value==="edit"&&(i=((a=s.config)==null?void 0:a.app)==="konnect"?await V.put(A("edit"),$.value):await V.patch(A("edit"),$.value)),K(i==null?void 0:i.data),o("update",i==null?void 0:i.data)}catch(i){m.errorMessage=B(i),o("error",i)}finally{m.readonly=!1}};return(a,i)=>{const f=e.resolveComponent("KInput"),D=e.resolveComponent("KCard");return e.openBlock(),e.createElementBlock("div",Ue,[e.createVNode(e.unref(d.EntityBaseForm),{"can-submit":x.value&&M.value,config:t.config,"edit-id":t.consumerId,"entity-type":e.unref(d.SupportedEntityType).Consumer,"error-message":m.errorMessage,"fetch-url":q.value,"form-fields":$.value,"is-readonly":m.readonly,onCancel:P,"onFetch:error":i[3]||(i[3]=g=>z(g)),"onFetch:success":K,onLoading:i[4]||(i[4]=g=>S(g)),onSubmit:G},{default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createVNode(e.unref(d.EntityFormSection),{description:e.unref(r)("consumers.form.info.description"),"has-divider":"",title:e.unref(r)("consumers.form.info.title")},{default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("h3",{id:`fields-group-title-${e.unref(T)}`,class:"fields-group-title"},e.toDisplayString(e.unref(r)("consumers.form.consumer_identification.title"))+"* ",9,Fe),e.createElementVNode("p",qe,e.toDisplayString(e.unref(r)("consumers.form.consumer_identification.description")),1)]),e.createVNode(D,null,{default:e.withCtx(()=>[e.createElementVNode("fieldset",{"aria-labelledby":`fields-group-title-${e.unref(T)}`},[e.createVNode(f,{modelValue:m.fields.username,"onUpdate:modelValue":i[0]||(i[0]=g=>m.fields.username=g),modelModifiers:{trim:!0},autocomplete:"off",class:"username-field","data-testid":"consumer-form-username",label:e.unref(r)("consumers.fields.username.label"),"label-attributes":{tooltipAttributes:{maxWidth:"400"}},placeholder:e.unref(r)("consumers.fields.username.placeholder"),readonly:m.readonly,type:"text"},{"label-tooltip":e.withCtx(()=>[e.createVNode(e.unref(N),{keypath:"consumers.fields.username.tooltip",scope:"global"},{custom_id:e.withCtx(()=>[e.createElementVNode("code",null,e.toDisplayString(e.unref(r)("consumers.fields.username.custom_id")),1)]),_:1})]),_:1},8,["modelValue","label","placeholder","readonly"]),e.createVNode(f,{modelValue:m.fields.customId,"onUpdate:modelValue":i[1]||(i[1]=g=>m.fields.customId=g),modelModifiers:{trim:!0},autocomplete:"off","data-testid":"consumer-form-custom-id",label:e.unref(r)("consumers.fields.custom_id.label"),"label-attributes":{tooltipAttributes:{maxWidth:"400"}},placeholder:e.unref(r)("consumers.fields.custom_id.placeholder"),readonly:m.readonly,type:"text"},{"label-tooltip":e.withCtx(()=>[e.createVNode(e.unref(N),{keypath:"consumers.fields.custom_id.tooltip",scope:"global"},{username:e.withCtx(()=>[e.createElementVNode("code",null,e.toDisplayString(e.unref(r)("consumers.fields.custom_id.username")),1)]),_:1})]),_:1},8,["modelValue","label","placeholder","readonly"])],8,Ke)]),_:1}),e.createVNode(f,{modelValue:m.fields.tags,"onUpdate:modelValue":i[2]||(i[2]=g=>m.fields.tags=g),modelModifiers:{trim:!0},autocomplete:"off","data-testid":"consumer-form-tags",help:e.unref(r)("consumers.fields.tags.help"),label:e.unref(r)("consumers.fields.tags.label"),"label-attributes":{info:e.unref(r)("consumers.fields.tags.tooltip"),tooltipAttributes:{maxWidth:"400"}},placeholder:e.unref(r)("consumers.fields.tags.placeholder"),readonly:m.readonly,type:"text"},null,8,["modelValue","help","label","label-attributes","placeholder","readonly"])]),_:1},8,["description","title"])])]),_:1},8,["can-submit","config","edit-id","entity-type","error-message","fetch-url","form-fields","is-readonly"])])}}}),[["__scopeId","data-v-ab3e5b9b"]]),je={class:"kong-ui-consumer-entity-config-card"},Le=e.defineComponent({__name:"ConsumerConfigCard",props:{config:{type:Object,required:!0,validator:t=>!(!t||!["konnect","kongManager"].includes(t==null?void 0:t.app)||t.app==="konnect"&&!t.controlPlaneId||t.app==="kongManager"&&typeof t.workspace!="string"||!t.entityId)},configCardDoc:{type:String,default:"",required:!1},hideTitle:{type:Boolean,default:!1}},emits:["loading","fetch:error","fetch:success"],setup(t){const u=t,{i18n:{t:s},i18nT:o}=Y.useI18n(),N=e.computed(()=>F.form[u.config.app].edit),r=e.ref({id:{},username:{section:d.ConfigurationSchemaSection.Basic,tooltip:s("consumers.fields.username.tooltip"),order:1},custom_id:{section:d.ConfigurationSchemaSection.Basic,tooltip:s("consumers.fields.custom_id.tooltip"),label:s("consumers.fields.custom_id.label"),order:2},updated_at:{},created_at:{},tags:{tooltip:s("consumers.fields.tags.tooltip")},username_lower:{hidden:!0},type:{hidden:!0}});return(_,V)=>(e.openBlock(),e.createElementBlock("div",je,[e.createVNode(e.unref(d.EntityBaseConfigCard),{config:t.config,"config-card-doc":t.configCardDoc,"config-schema":r.value,"entity-type":e.unref(d.SupportedEntityType).Consumer,"fetch-url":N.value,"hide-title":t.hideTitle,"onFetch:error":V[0]||(V[0]=B=>_.$emit("fetch:error",B)),"onFetch:success":V[1]||(V[1]=B=>_.$emit("fetch:success",B)),onLoading:V[2]||(V[2]=B=>_.$emit("loading",B))},{"username-label-tooltip":e.withCtx(()=>[e.createVNode(e.unref(o),{keypath:"consumers.fields.username.tooltip",scope:"global"},{custom_id:e.withCtx(()=>[e.createElementVNode("code",null,e.toDisplayString(e.unref(s)("consumers.fields.username.custom_id")),1)]),_:1})]),"custom_id-label-tooltip":e.withCtx(()=>[e.createVNode(e.unref(o),{keypath:"consumers.fields.custom_id.tooltip",scope:"global"},{username:e.withCtx(()=>[e.createElementVNode("code",null,e.toDisplayString(e.unref(s)("consumers.fields.custom_id.username")),1)]),_:1})]),_:1},8,["config","config-card-doc","config-schema","entity-type","fetch-url","hide-title"])]))}});E.ConsumerConfigCard=Le,E.ConsumerForm=Oe,E.ConsumerList=Ge,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
1
+ (function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-router"),require("@kong/icons"),require("@kong-ui-public/i18n"),require("@kong-ui-public/entities-shared")):typeof define=="function"&&define.amd?define(["exports","vue","vue-router","@kong/icons","@kong-ui-public/i18n","@kong-ui-public/entities-shared"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E["kong-ui-public-entities-consumers"]={},E.Vue,E.VueRouter,E.KongIcons,E["kong-ui-public-i18n"],E["kong-ui-public-entities-shared"]))})(this,function(E,e,ae,ee,ie,d){"use strict";const ye="#00abd2",he="24px",Ce={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"},empty_state_v2:{title:"Configure your first consumer",group:"Consumers created in gateways within this group will automatically appear here.",description:"Consumers represent users or apps accessing your APIs, allowing for tailored authentication and individual access control."},toolbar_actions:{new_consumer:"New consumer"}},title:"Consumers",search:{placeholder:{konnect:"Filter by name",kongManager:"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 and delete all its plugins. 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 be(){const t=ie.createI18n("en-us",Ce);return{i18n:t,i18nT:ie.i18nTComponent(t)}}const Y={useI18n:be},j="/v2/control-planes/{controlPlaneId}/core-entities",L="/{workspace}",F={list:{konnect:{all:`${j}/consumers`,forConsumerGroup:`${j}/consumer_groups/{consumerGroupId}/consumers`,oneForConsumerGroup:`${j}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`},kongManager:{all:`${L}/consumers`,forConsumerGroup:`${L}/consumer_groups/{consumerGroupId}/consumers`,oneForConsumerGroup:`${L}/consumer_groups/{consumerGroupId}/consumers/{consumerId}`}},form:{konnect:{validate:`${j}/v1/schemas/json/consumer/validate`,create:`${j}/consumers`,edit:`${j}/consumers/{id}`},kongManager:{validate:`${L}/schemas/consumers/validate`,create:`${L}/consumers`,edit:`${L}/consumers/{id}`}}},ke={class:"add-consumer-form-container"},_e={class:"add-consumer-form-cta"},we={class:"select-item-label"},Ie={key:0,class:"select-item-desc"},Ve={key:0,class:"kong-ui-entity-add-consumers-error"},Ne={key:0},xe=e.defineComponent({__name:"AddConsumerModal",props:{config:{type:Object,required:!0,validator:t=>!(!t||!["konnect","kongManager"].includes(t==null?void 0:t.app)||!t.consumerGroupId)},visible:{type:Boolean,required:!0,default:!1}},emits:["cancel","add:success","add:partial-success","error"],setup(t,{emit:m}){var g;const{i18n:{t:s}}=Y.useI18n(),o=t,N=m,{axiosInstance:r}=d.useAxios((g=o.config)==null?void 0:g.axiosRequestConfig),_=e.ref([]),{debouncedQueryChange:V,loading:B,allRecords:T,error:u,loadItems:H,results:q}=d.useDebouncedFilter(o.config,F.list[o.config.app].all,"",{fetchedItemsKey:"data",searchKeys:["username","id"]}),P=l=>l,S=e.computed(()=>u.value?s("consumers.errors.general"):""),z=e.ref(0),K=e.computed(()=>T.value===void 0),O=e.computed(()=>q.value.map(l=>({label:l.username||l.customId,value:l.id,selected:_.value.includes(l.id),data:l}))),A=l=>{var y;const C=K.value?q.value.find(w=>w.id===l):(y=T.value)==null?void 0:y.find(w=>w.id===l);return C?C.username||C.custom_id:l},x=()=>{G.value="",M.value=[],f.value=[],N("cancel")},M=e.ref([]),$=e.ref(!1),G=e.ref(""),W=async()=>{if(!_.value.length){G.value="",f.value=[],N("cancel");return}$.value=!0,G.value="",M.value=[],f.value=[];try{const l=_.value.map(w=>i(w)),C=await Promise.allSettled(l);let y=!0;C.forEach(w=>{w.status!=="fulfilled"&&(y=!1)}),y?(M.value=[],f.value=[],N("add:success",_.value),_.value=[]):(M.value.length&&N("add:partial-success",M.value),_.value=[],D(C))}catch{G.value=s("consumers.errors.add"),N("error",G.value)}finally{$.value=!1}},a=e.computed(()=>{var C,y,w,J;let l=`${o.config.apiBaseUrl}${F.list[o.config.app].forConsumerGroup}`;return o.config.app==="konnect"?l=l.replace(/{controlPlaneId}/gi,((C=o.config)==null?void 0:C.controlPlaneId)||"").replace(/{consumerGroupId}/gi,((y=o.config)==null?void 0:y.consumerGroupId)||""):o.config.app==="kongManager"&&(l=l.replace(/\/{workspace}/gi,(w=o.config)!=null&&w.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((J=o.config)==null?void 0:J.consumerGroupId)||"")),l}),i=async l=>{const C={consumer:l};try{const y=await r.post(a.value,C);return M.value.push(l),y}catch(y){let w=`${A(l)} - ${y.message}`;return y.response.status===409&&(w=`${A(l)} - ${s("consumers.errors.already_added")}`),Promise.reject(Error(w))}},f=e.ref([]),D=l=>{f.value=l.map(C=>{var y;return(y=C.reason)==null?void 0:y.message}).filter(Boolean)};return e.watch(O,()=>{z.value++},{immediate:!0,deep:!0}),e.watch(()=>o.visible,()=>{o.visible&&H()},{immediate:!0}),(l,C)=>{const y=e.resolveComponent("KMultiselect"),w=e.resolveComponent("KAlert"),J=e.resolveComponent("KPrompt");return e.openBlock(),e.createBlock(J,{"action-button-disabled":$.value,class:"kong-ui-entities-add-consumers-modal","data-testid":"add-consumer-modal",title:e.unref(s)("consumers.consumer_groups.add.title"),visible:t.visible,onCancel:x,onProceed:W},{default:e.withCtx(()=>[e.createElementVNode("div",ke,[e.createElementVNode("p",_e,e.toDisplayString(e.unref(s)("consumers.consumer_groups.add.ctaText")),1),e.createVNode(y,{modelValue:_.value,"onUpdate:modelValue":C[0]||(C[0]=I=>_.value=I),autosuggest:"","data-testid":"add-consumers-multiselect","dropdown-footer-text":K.value?e.unref(s)("consumers.consumer_groups.add.footer"):void 0,items:O.value,label:e.unref(s)("consumers.consumer_groups.add.consumers_label"),loading:e.unref(B),placeholder:e.unref(s)("consumers.consumer_groups.add.consumer_placeholder"),readonly:$.value,required:"",width:"100%",onQueryChange:e.unref(V)},{"item-template":e.withCtx(({item:I})=>[e.createElementVNode("div",we,e.toDisplayString(I.label),1),P(I).data.username&&P(I).data.custom_id?(e.openBlock(),e.createElementBlock("div",Ie,e.toDisplayString(P(I).data.custom_id),1)):e.createCommentVNode("",!0)]),_:1},8,["modelValue","dropdown-footer-text","items","label","loading","placeholder","readonly","onQueryChange"]),G.value||S.value||f.value.length?(e.openBlock(),e.createElementBlock("div",Ve,[e.createVNode(w,{appearance:"danger"},{default:e.withCtx(()=>[e.createElementVNode("p",null,e.toDisplayString(e.unref(s)("consumers.errors.add")),1),f.value.length?(e.openBlock(),e.createElementBlock("ul",Ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(I,Q)=>(e.openBlock(),e.createElementBlock("li",{key:Q},e.toDisplayString(I),1))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",null,e.toDisplayString(G.value||S.value),1)]),_:1})])):e.createCommentVNode("",!0)])]),_:1},8,["action-button-disabled","title","visible"])}}}),te=(t,m)=>{const s=t.__vccOpts||t;for(const[o,N]of m)s[o]=N;return s},Ee=te(xe,[["__scopeId","data-v-d54468ab"]]),$e={class:"kong-ui-entities-consumers-list"},De={class:"button-row"},Be={class:"empty-state-wrapper"},Se={class:"empty-state-icon-gateway"},Ge=te(e.defineComponent({__name:"ConsumerList",props:{config:{type:Object,required:!0,validator:t=>!(!t||!["konnect","kongManager"].includes(t==null?void 0:t.app)||!t.createRoute||!t.getViewRoute||!t.getEditRoute||t.app==="kongManager"&&!t.isExactMatch&&!t.filterSchema)},cacheIdentifier:{type:String,default:""},canCreate:{type:Function,required:!1,default:async()=>!0},canDelete:{type:Function,required:!1,default:async()=>!0},canEdit:{type:Function,required:!1,default:async()=>!0},canRetrieve:{type:Function,required:!1,default:async()=>!0},useActionOutside:{type:Boolean,default:!1}},emits:["error","click:learn-more","copy:success","copy:error","delete:success","add:success","remove:success"],setup(t,{emit:m}){var ge;const s=m,o=t,{i18nT:N,i18n:{t:r}}=Y.useI18n(),_=ae.useRouter(),{axiosInstance:V}=d.useAxios((ge=o.config)==null?void 0:ge.axiosRequestConfig),B=e.computed(()=>o.config.app!=="kongManager"||!!o.config.disableSorting),T={username:{label:r("consumers.list.table_headers.username"),searchable:!0,sortable:!0,hidable:!1},custom_id:{label:r("consumers.list.table_headers.custom_id"),searchable:!0,sortable:!0},tags:{label:r("consumers.list.table_headers.tags"),sortable:!1}},u=T,H=n=>({"data-testid":n.username??n.custom_id??n.id}),q=()=>{o.config.consumerGroupId?de():_.push(o.config.createRoute)},P=e.computed(()=>{var c,h,b,U;let n=`${o.config.apiBaseUrl}${F.list[o.config.app][x.value?"forConsumerGroup":"all"]}`;return o.config.app==="konnect"?n=n.replace(/{controlPlaneId}/gi,((c=o.config)==null?void 0:c.controlPlaneId)||"").replace(/{consumerGroupId}/gi,((h=o.config)==null?void 0:h.consumerGroupId)||""):o.config.app==="kongManager"&&(n=n.replace(/\/{workspace}/gi,(b=o.config)!=null&&b.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((U=o.config)==null?void 0:U.consumerGroupId)||"")),n}),S=e.ref(""),z=e.computed(()=>{const n=o.config.app==="konnect"||o.config.isExactMatch;return n?{isExactMatch:n,placeholder:r(`consumers.search.placeholder.${o.config.app}`)}:{isExactMatch:n,fields:{username:T.username,custom_id:T.custom_id},schema:o.config.filterSchema}}),{hasRecords:K,handleStateChange:O}=d.useTableState(S),A=e.computed(()=>K.value&&o.config.app==="konnect"),x=e.computed(()=>!!o.config.consumerGroupId),M=e.computed(()=>x.value?"kong-ui-entities-consumers-list-in-group-page":"kong-ui-entities-consumers-list"),$=e.computed(()=>x.value&&!o.config.paginatedEndpoint?"consumers":void 0),{fetcher:G,fetcherState:W,fetcherCacheKey:a}=d.useFetcher(e.computed(()=>({...o.config,cacheIdentifier:o.cacheIdentifier})),P,$),i=()=>{S.value=""},f=()=>{a.value++},D=n=>n??"-",g=e.ref(null),l=async(n,c)=>{const h=n.id;if(!await c(h)){s("copy:error",{entity:n,field:"id",message:r("consumers.errors.copy")});return}s("copy:success",{entity:n,field:"id",message:r("consumers.copy.success",{val:h})})},C=(n,c)=>{const h=JSON.stringify(n);if(!c(h)){s("copy:error",{entity:n,message:r("consumers.errors.copy")});return}s("copy:success",{entity:n,message:r("consumers.copy.success_brief")})},y=async n=>{var h;await((h=o.canRetrieve)==null?void 0:h.call(o,n))&&_.push(o.config.getViewRoute(n.id))},w=n=>({label:r("consumers.actions.view"),to:o.config.getViewRoute(n)}),J=n=>({label:r("consumers.actions.edit"),to:o.config.getEditRoute(n)}),I=e.ref(void 0),Q=e.ref(!1),Z=e.ref(!1),ce=e.ref(""),He=d.useDeleteUrlBuilder(o.config,P.value),We=n=>{I.value=n,Q.value=!0},Je=()=>{Q.value=!1},Qe=async()=>{var n,c,h;if((n=I.value)!=null&&n.id){Z.value=!0;try{await V.delete(He(I.value.id)),Z.value=!1,Q.value=!1,a.value++,s("delete:success",I.value)}catch(b){ce.value=((h=(c=b.response)==null?void 0:c.data)==null?void 0:h.message)||b.message||r("consumers.errors.delete"),s("error",b)}finally{Z.value=!1}}},ne=e.ref(!1),de=()=>{ne.value=!0},ue=()=>{ne.value=!1},me=(n,c)=>{c||ue(),a.value++,s("add:success",n)},ze=()=>{x.value&&de()},R=e.ref(void 0),re=e.ref(!1),Ye=e.ref(""),Xe=n=>{R.value=n,re.value=!0},pe=()=>{re.value=!1,R.value=void 0},Ze=e.computed(()=>{var c,h,b,U;let n=`${o.config.apiBaseUrl}${F.list[o.config.app].oneForConsumerGroup}`;return o.config.app==="konnect"?n=n.replace(/{controlPlaneId}/gi,((c=o.config)==null?void 0:c.controlPlaneId)||"").replace(/{consumerGroupId}/gi,((h=o.config)==null?void 0:h.consumerGroupId)||""):o.config.app==="kongManager"&&(n=n.replace(/\/{workspace}/gi,(b=o.config)!=null&&b.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((U=o.config)==null?void 0:U.consumerGroupId)||"")),n}),fe=e.ref(!1),ve=async()=>{if(R.value){fe.value=!0;try{const n=Ze.value.replace(/{consumerId}/gi,R.value.id);await V.delete(n),s("remove:success",R.value),pe(),a.value++}catch(n){Ye.value=n.message||r("consumers.errors.delete"),s("error",n)}finally{fe.value=!1}}};e.watch(W,n=>{var c,h,b;if(n.status===d.FetcherStatus.Error){g.value={title:r("consumers.errors.general")},(b=(h=(c=n.error)==null?void 0:c.response)==null?void 0:h.data)!=null&&b.message&&(g.value.message=n.error.response.data.message),s("error",n.error);return}g.value=null});const se=e.ref({ctaPath:x.value?void 0:o.config.createRoute,ctaText:void 0,message:`${r("consumers.list.empty_state.description")}${o.config.additionMessageForEmptyState?` ${o.config.additionMessageForEmptyState}`:""}`,title:r("consumers.title")});return e.onBeforeMount(async()=>{await o.canCreate()&&(se.value.title=x.value?r("consumers.list.empty_state.title_for_consumer_group"):r("consumers.list.empty_state.title"),se.value.ctaText=x.value?r("consumers.actions.add_consumer"):r("consumers.actions.create"))}),(n,c)=>{const h=e.resolveComponent("KButton"),b=e.resolveComponent("KDropdownItem"),U=e.resolveComponent("KClipboardProvider"),et=e.resolveComponent("KPrompt");return e.openBlock(),e.createElementBlock("div",$e,[e.createVNode(e.unref(d.EntityBaseTable),{"cache-identifier":t.cacheIdentifier,"disable-sorting":B.value,"empty-state-options":se.value,"enable-entity-actions":"","error-message":g.value,fetcher:e.unref(G),"fetcher-cache-key":e.unref(a),"hide-pagination":x.value&&!t.config.paginatedEndpoint,"pagination-type":"offset","preferences-storage-key":M.value,query:S.value,"row-attributes":H,"table-headers":e.unref(u),onClearSearchInput:i,"onClick:row":c[3]||(c[3]=p=>y(p)),onEmptyStateCtaClicked:ze,onSort:f,onState:e.unref(O)},e.createSlots({"toolbar-filter":e.withCtx(()=>[e.renderSlot(n.$slots,"toolbar-filter",{},void 0,!0),x.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(d.EntityFilter),{key:0,modelValue:S.value,"onUpdate:modelValue":c[0]||(c[0]=p=>S.value=p),config:z.value},null,8,["modelValue","config"]))]),"toolbar-button":e.withCtx(()=>[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!t.useActionOutside,to:"#kong-ui-app-page-header-action-button"},[e.createElementVNode("div",De,[!x.value&&A.value?(e.openBlock(),e.createBlock(h,{key:0,appearance:"secondary",class:"open-learning-hub","data-testid":"consumers-learn-more-button",icon:"",onClick:c[1]||(c[1]=p=>n.$emit("click:learn-more"))},{default:e.withCtx(()=>[e.createVNode(e.unref(ee.BookIcon),{decorative:""})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(d.PermissionsWrapper),{"auth-function":()=>t.canCreate()},{default:e.withCtx(()=>[e.createVNode(h,{appearance:"primary","data-testid":"toolbar-add-consumer",size:t.useActionOutside?"medium":"large",onClick:q},{default:e.withCtx(()=>[e.createVNode(e.unref(ee.AddIcon)),e.createTextVNode(" "+e.toDisplayString(t.config.consumerGroupId?e.unref(r)("consumers.actions.add_consumer"):e.unref(r)("consumers.list.toolbar_actions.new_consumer")),1)]),_:1},8,["size"])]),_:1},8,["auth-function"])])],8,["disabled"]))]),username:e.withCtx(({rowValue:p})=>[e.createElementVNode("b",null,e.toDisplayString(D(p)),1)]),custom_id:e.withCtx(({rowValue:p})=>[e.createTextVNode(e.toDisplayString(D(p)),1)]),tags:e.withCtx(({rowValue:p})=>[e.createVNode(e.unref(d.TableTags),{tags:p},null,8,["tags"])]),actions:e.withCtx(({row:p})=>[e.createVNode(U,null,{default:e.withCtx(({copyToClipboard:v})=>[e.createVNode(b,{"data-testid":"action-entity-copy-id",onClick:tt=>l(p,v)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.actions.copy_id")),1)]),_:2},1032,["onClick"])]),_:2},1024),e.createVNode(U,null,{default:e.withCtx(({copyToClipboard:v})=>[e.createVNode(b,{"data-testid":"action-entity-copy-json",onClick:tt=>C(p,v)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.actions.copy_json")),1)]),_:2},1032,["onClick"])]),_:2},1024),e.createVNode(e.unref(d.PermissionsWrapper),{"auth-function":()=>t.canRetrieve(p)},{default:e.withCtx(()=>[e.createVNode(b,{"data-testid":"action-entity-view","has-divider":"",item:w(p.id)},null,8,["item"])]),_:2},1032,["auth-function"]),e.createVNode(e.unref(d.PermissionsWrapper),{"auth-function":()=>t.canEdit(p)},{default:e.withCtx(()=>[e.createVNode(b,{"data-testid":"action-entity-edit",item:J(p.id)},null,8,["item"])]),_:2},1032,["auth-function"]),e.createVNode(e.unref(d.PermissionsWrapper),{"auth-function":()=>t.canDelete(p)},{default:e.withCtx(()=>[e.createVNode(b,{danger:"","data-testid":"action-entity-delete","has-divider":"",onClick:()=>t.config.consumerGroupId?Xe(p):We(p)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.config.consumerGroupId?e.unref(r)("consumers.actions.remove"):e.unref(r)("consumers.actions.delete")),1)]),_:2},1032,["onClick"])]),_:2},1032,["auth-function"])]),_:2},[!S.value&&t.config.app==="konnect"?{name:"empty-state",fn:e.withCtx(()=>{var p;return[e.createElementVNode("div",Be,[e.renderSlot(n.$slots,"empty-state-toolbar",{},void 0,!0),e.createVNode(e.unref(d.EntityEmptyState),{"action-button-text":e.unref(r)("consumers.list.toolbar_actions.new_consumer"),appearance:"secondary","can-create":()=>t.canCreate(),"data-testid":t.config.consumerGroupId?"nested-consumers-entity-empty-state":"consumers-entity-empty-state",description:e.unref(r)("consumers.list.empty_state_v2.description"),"learn-more":t.config.app==="konnect",title:e.unref(r)("consumers.list.empty_state_v2.title"),"onClick:create":q,"onClick:learnMore":c[2]||(c[2]=v=>n.$emit("click:learn-more"))},e.createSlots({image:e.withCtx(()=>[e.createElementVNode("div",Se,[e.createVNode(e.unref(ee.TeamIcon),{color:e.unref(ye),size:e.unref(he)},null,8,["color","size"])])]),_:2},[(p=t.config)!=null&&p.isControlPlaneGroup?{name:"message",fn:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.list.empty_state_v2.group")),1)]),key:"0"}:void 0]),1032,["action-button-text","can-create","data-testid","description","learn-more","title"])])]}),key:"0"}:void 0]),1032,["cache-identifier","disable-sorting","empty-state-options","error-message","fetcher","fetcher-cache-key","hide-pagination","preferences-storage-key","query","table-headers","onState"]),e.createVNode(e.unref(d.EntityDeleteModal),{"action-button-disabled":Z.value,"data-testid":"delete-consumer-modal",description:e.unref(r)("consumers.delete.description"),"entity-name":I.value&&(I.value.username||I.value.custom_id||I.value.id),"entity-type":e.unref(d.EntityTypes).Consumer,error:ce.value,title:e.unref(r)("consumers.delete.title"),visible:Q.value,onCancel:Je,onProceed:Qe},null,8,["action-button-disabled","description","entity-name","entity-type","error","title","visible"]),t.config.consumerGroupId?(e.openBlock(),e.createBlock(Ee,{key:0,config:t.config,"data-testid":"add-consumer-modal",visible:ne.value,"onAdd:partialSuccess":c[4]||(c[4]=p=>me(p,!0)),"onAdd:success":c[5]||(c[5]=p=>me(p)),onCancel:ue},null,8,["config","visible"])):e.createCommentVNode("",!0),t.config.consumerGroupId&&R.value?(e.openBlock(),e.createBlock(et,{key:1,"action-button-appearance":"danger","data-testid":"remove-consumer-modal",title:e.unref(r)("consumers.consumer_groups.remove.title"),visible:re.value,onCancel:pe,onProceed:ve},{default:e.withCtx(()=>[e.createVNode(e.unref(N),{class:"message",keypath:t.config.consumerGroupName?"consumers.consumer_groups.remove.confirmation":"consumers.consumer_groups.remove.confirmationNoCG",tag:"p"},e.createSlots({consumer:e.withCtx(()=>[e.createElementVNode("strong",null,e.toDisplayString(R.value.username||R.value.custom_id||R.value.id),1)]),_:2},[t.config.consumerGroupName?{name:"consumerGroup",fn:e.withCtx(()=>[e.createElementVNode("strong",null,e.toDisplayString(t.config.consumerGroupName),1)]),key:"0"}:void 0]),1032,["keypath"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(r)("consumers.consumer_groups.remove.description")),1)]),_:1},8,["title","visible"])):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-c5be280d"]]);for(var k=[],oe=0;oe<256;++oe)k.push((oe+256).toString(16).slice(1));function Me(t,m=0){return(k[t[m+0]]+k[t[m+1]]+k[t[m+2]]+k[t[m+3]]+"-"+k[t[m+4]]+k[t[m+5]]+"-"+k[t[m+6]]+k[t[m+7]]+"-"+k[t[m+8]]+k[t[m+9]]+"-"+k[t[m+10]]+k[t[m+11]]+k[t[m+12]]+k[t[m+13]]+k[t[m+14]]+k[t[m+15]]).toLowerCase()}var X,Te=new Uint8Array(16);function Ae(){if(!X&&(X=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!X))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return X(Te)}var Re=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const le={randomUUID:Re};function Pe(t,m,s){if(le.randomUUID&&!t)return le.randomUUID();t=t||{};var o=t.random||(t.rng||Ae)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,Me(o)}const Ue={class:"kong-ui-entities-consumer-form"},Fe=["id"],qe={class:"fields-group-text"},Ke=["aria-labelledby"],Oe=te(e.defineComponent({__name:"ConsumerForm",props:{config:{type:Object,required:!0,validator:t=>!(!t||!["konnect","kongManager"].includes(t==null?void 0:t.app)||(t==null?void 0:t.app)==="konnect"&&!(t!=null&&t.controlPlaneId)||(t==null?void 0:t.app)==="kongManager"&&typeof(t==null?void 0:t.workspace)!="string"||!(t!=null&&t.cancelRoute))},consumerId:{type:String,required:!1,default:""}},emits:["update","error","loading"],setup(t,{emit:m}){var W;const s=t,o=m,{i18nT:N,i18n:{t:r}}=Y.useI18n(),_=ae.useRouter(),{axiosInstance:V}=d.useAxios((W=s.config)==null?void 0:W.axiosRequestConfig),{getMessageFromError:B}=d.useErrors(),T=Pe(),u=e.reactive({fields:{username:"",customId:"",tags:""},readonly:!1,errorMessage:""}),H=e.reactive({username:"",customId:"",tags:""}),q=e.computed(()=>{var a,i;return(i=F.form[(a=s.config)==null?void 0:a.app])==null?void 0:i.edit}),P=()=>{var a;_.push(((a=s.config)==null?void 0:a.cancelRoute)||{name:"consumer-list"})},S=a=>{o("loading",a)},z=a=>{o("error",a)},K=a=>{var f,D,g;u.fields.username=((f=a==null?void 0:a.item)==null?void 0:f.username)||(a==null?void 0:a.username)||"",u.fields.customId=((D=a==null?void 0:a.item)==null?void 0:D.custom_id)||(a==null?void 0:a.custom_id)||"";const i=((g=a==null?void 0:a.item)==null?void 0:g.tags)||(a==null?void 0:a.tags)||[];u.fields.tags=(i==null?void 0:i.join(", "))||"",Object.assign(H,u.fields)},O=e.computed(()=>s.consumerId?d.EntityBaseFormType.Edit:d.EntityBaseFormType.Create),A=a=>{var f,D,g,l,C,y;let i=`${(f=s.config)==null?void 0:f.apiBaseUrl}${F.form[(D=s.config)==null?void 0:D.app][a]}`;return((g=s.config)==null?void 0:g.app)==="konnect"?i=i.replace(/{controlPlaneId}/gi,((l=s.config)==null?void 0:l.controlPlaneId)||""):((C=s.config)==null?void 0:C.app)==="kongManager"&&(i=i.replace(/\/{workspace}/gi,(y=s.config)!=null&&y.workspace?`/${s.config.workspace}`:"")),i=i.replace(/{id}/gi,s.consumerId),i},x=e.computed(()=>!!u.fields.username||!!u.fields.customId),M=e.computed(()=>JSON.stringify(u.fields)!==JSON.stringify(H)),$=e.computed(()=>{var a,i;return{username:u.fields.username||null,custom_id:u.fields.customId||null,tags:(i=(a=u.fields.tags.split(","))==null?void 0:a.map(f=>String(f||"").trim()))==null?void 0:i.filter(f=>f!=="")}}),G=async()=>{var a;try{u.readonly=!0;let i;await V.post(A("validate"),$.value),O.value==="create"?i=await V.post(A("create"),$.value):O.value==="edit"&&(i=((a=s.config)==null?void 0:a.app)==="konnect"?await V.put(A("edit"),$.value):await V.patch(A("edit"),$.value)),K(i==null?void 0:i.data),o("update",i==null?void 0:i.data)}catch(i){u.errorMessage=B(i),o("error",i)}finally{u.readonly=!1}};return(a,i)=>{const f=e.resolveComponent("KInput"),D=e.resolveComponent("KCard");return e.openBlock(),e.createElementBlock("div",Ue,[e.createVNode(e.unref(d.EntityBaseForm),{"can-submit":x.value&&M.value,config:t.config,"edit-id":t.consumerId,"entity-type":e.unref(d.SupportedEntityType).Consumer,"error-message":u.errorMessage,"fetch-url":q.value,"form-fields":$.value,"is-readonly":u.readonly,onCancel:P,"onFetch:error":i[3]||(i[3]=g=>z(g)),"onFetch:success":K,onLoading:i[4]||(i[4]=g=>S(g)),onSubmit:G},{default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createVNode(e.unref(d.EntityFormSection),{description:e.unref(r)("consumers.form.info.description"),"has-divider":"",title:e.unref(r)("consumers.form.info.title")},{default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("h3",{id:`fields-group-title-${e.unref(T)}`,class:"fields-group-title"},e.toDisplayString(e.unref(r)("consumers.form.consumer_identification.title"))+"* ",9,Fe),e.createElementVNode("p",qe,e.toDisplayString(e.unref(r)("consumers.form.consumer_identification.description")),1)]),e.createVNode(D,null,{default:e.withCtx(()=>[e.createElementVNode("fieldset",{"aria-labelledby":`fields-group-title-${e.unref(T)}`},[e.createVNode(f,{modelValue:u.fields.username,"onUpdate:modelValue":i[0]||(i[0]=g=>u.fields.username=g),modelModifiers:{trim:!0},autocomplete:"off",class:"username-field","data-testid":"consumer-form-username",label:e.unref(r)("consumers.fields.username.label"),"label-attributes":{tooltipAttributes:{maxWidth:"400"}},placeholder:e.unref(r)("consumers.fields.username.placeholder"),readonly:u.readonly,type:"text"},{"label-tooltip":e.withCtx(()=>[e.createVNode(e.unref(N),{keypath:"consumers.fields.username.tooltip",scope:"global"},{custom_id:e.withCtx(()=>[e.createElementVNode("code",null,e.toDisplayString(e.unref(r)("consumers.fields.username.custom_id")),1)]),_:1})]),_:1},8,["modelValue","label","placeholder","readonly"]),e.createVNode(f,{modelValue:u.fields.customId,"onUpdate:modelValue":i[1]||(i[1]=g=>u.fields.customId=g),modelModifiers:{trim:!0},autocomplete:"off","data-testid":"consumer-form-custom-id",label:e.unref(r)("consumers.fields.custom_id.label"),"label-attributes":{tooltipAttributes:{maxWidth:"400"}},placeholder:e.unref(r)("consumers.fields.custom_id.placeholder"),readonly:u.readonly,type:"text"},{"label-tooltip":e.withCtx(()=>[e.createVNode(e.unref(N),{keypath:"consumers.fields.custom_id.tooltip",scope:"global"},{username:e.withCtx(()=>[e.createElementVNode("code",null,e.toDisplayString(e.unref(r)("consumers.fields.custom_id.username")),1)]),_:1})]),_:1},8,["modelValue","label","placeholder","readonly"])],8,Ke)]),_:1}),e.createVNode(f,{modelValue:u.fields.tags,"onUpdate:modelValue":i[2]||(i[2]=g=>u.fields.tags=g),modelModifiers:{trim:!0},autocomplete:"off","data-testid":"consumer-form-tags",help:e.unref(r)("consumers.fields.tags.help"),label:e.unref(r)("consumers.fields.tags.label"),"label-attributes":{info:e.unref(r)("consumers.fields.tags.tooltip"),tooltipAttributes:{maxWidth:"400"}},placeholder:e.unref(r)("consumers.fields.tags.placeholder"),readonly:u.readonly,type:"text"},null,8,["modelValue","help","label","label-attributes","placeholder","readonly"])]),_:1},8,["description","title"])])]),_:1},8,["can-submit","config","edit-id","entity-type","error-message","fetch-url","form-fields","is-readonly"])])}}}),[["__scopeId","data-v-ab3e5b9b"]]),je={class:"kong-ui-consumer-entity-config-card"},Le=e.defineComponent({__name:"ConsumerConfigCard",props:{config:{type:Object,required:!0,validator:t=>!(!t||!["konnect","kongManager"].includes(t==null?void 0:t.app)||t.app==="konnect"&&!t.controlPlaneId||t.app==="kongManager"&&typeof t.workspace!="string"||!t.entityId)},configCardDoc:{type:String,default:"",required:!1},hideTitle:{type:Boolean,default:!1}},emits:["loading","fetch:error","fetch:success"],setup(t){const m=t,{i18n:{t:s},i18nT:o}=Y.useI18n(),N=e.computed(()=>F.form[m.config.app].edit),r=e.ref({id:{},username:{section:d.ConfigurationSchemaSection.Basic,tooltip:s("consumers.fields.username.tooltip"),order:1},custom_id:{section:d.ConfigurationSchemaSection.Basic,tooltip:s("consumers.fields.custom_id.tooltip"),label:s("consumers.fields.custom_id.label"),order:2},updated_at:{},created_at:{},tags:{tooltip:s("consumers.fields.tags.tooltip")},username_lower:{hidden:!0},type:{hidden:!0}});return(_,V)=>(e.openBlock(),e.createElementBlock("div",je,[e.createVNode(e.unref(d.EntityBaseConfigCard),{config:t.config,"config-card-doc":t.configCardDoc,"config-schema":r.value,"entity-type":e.unref(d.SupportedEntityType).Consumer,"fetch-url":N.value,"hide-title":t.hideTitle,"onFetch:error":V[0]||(V[0]=B=>_.$emit("fetch:error",B)),"onFetch:success":V[1]||(V[1]=B=>_.$emit("fetch:success",B)),onLoading:V[2]||(V[2]=B=>_.$emit("loading",B))},{"username-label-tooltip":e.withCtx(()=>[e.createVNode(e.unref(o),{keypath:"consumers.fields.username.tooltip",scope:"global"},{custom_id:e.withCtx(()=>[e.createElementVNode("code",null,e.toDisplayString(e.unref(s)("consumers.fields.username.custom_id")),1)]),_:1})]),"custom_id-label-tooltip":e.withCtx(()=>[e.createVNode(e.unref(o),{keypath:"consumers.fields.custom_id.tooltip",scope:"global"},{username:e.withCtx(()=>[e.createElementVNode("code",null,e.toDisplayString(e.unref(s)("consumers.fields.custom_id.username")),1)]),_:1})]),_:1},8,["config","config-card-doc","config-schema","entity-type","fetch-url","hide-title"])]))}});E.ConsumerConfigCard=Le,E.ConsumerForm=Oe,E.ConsumerList=Ge,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kong-ui-public/entities-consumers",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "type": "module",
5
5
  "main": "./dist/entities-consumers.umd.js",
6
6
  "module": "./dist/entities-consumers.es.js",
@@ -23,10 +23,10 @@
23
23
  "peerDependencies": {
24
24
  "@kong/icons": "^1.31.0",
25
25
  "@kong/kongponents": "^9.34.2",
26
- "axios": "^1.7.7",
26
+ "axios": "^1.7.9",
27
27
  "vue": ">= 3.3.13 < 4",
28
28
  "vue-router": "^4.4.5",
29
- "@kong-ui-public/entities-shared": "^3.26.1",
29
+ "@kong-ui-public/entities-shared": "^3.26.2",
30
30
  "@kong-ui-public/i18n": "^2.3.2"
31
31
  },
32
32
  "devDependencies": {
@@ -36,7 +36,7 @@
36
36
  "axios": "^1.7.7",
37
37
  "vue": "^3.5.13",
38
38
  "vue-router": "^4.4.5",
39
- "@kong-ui-public/entities-shared": "^3.26.1",
39
+ "@kong-ui-public/entities-shared": "^3.26.2",
40
40
  "@kong-ui-public/i18n": "^2.3.2"
41
41
  },
42
42
  "repository": {