@kong-ui-public/entities-consumers 3.5.7 → 3.5.8

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,9 +1,9 @@
1
- import { defineComponent as ue, ref as C, computed as E, watch as ge, resolveComponent as U, openBlock as $, createBlock as W, unref as s, withCtx as l, createElementVNode as I, toDisplayString as h, createVNode as d, createElementBlock as q, createCommentVNode as ne, Fragment as xe, renderList as De, onBeforeMount as Oe, Teleport as je, withDirectives as He, createTextVNode as te, vShow as Je, withModifiers as Le, createSlots as Qe, reactive as Ee } from "vue";
2
- import { useRouter as Ae } from "vue-router";
3
- import { AddIcon as We } from "@kong/icons";
4
- import { createI18n as ze, i18nTComponent as Ye } from "@kong-ui-public/i18n";
5
- import { useAxios as ve, useDebouncedFilter as Xe, useFetcher as Ze, useDeleteUrlBuilder as et, FetcherStatus as tt, EntityBaseTable as ot, EntityFilter as st, PermissionsWrapper as ie, EntityDeleteModal as nt, EntityTypes as rt, useErrors as at, EntityBaseFormType as Ge, EntityBaseForm as it, SupportedEntityType as Re, EntityFormSection as lt, ConfigurationSchemaSection as Me, EntityBaseConfigCard as ut } from "@kong-ui-public/entities-shared";
6
- const ct = {
1
+ import { defineComponent as ue, ref as C, computed as E, watch as ve, resolveComponent as U, openBlock as $, createBlock as W, unref as s, withCtx as l, createElementVNode as I, toDisplayString as h, createVNode as d, createElementBlock as q, createCommentVNode as ne, Fragment as De, renderList as Ae, onBeforeMount as je, Teleport as Le, withDirectives as He, createTextVNode as te, vShow as Je, withModifiers as Qe, createSlots as We, reactive as Ge } from "vue";
2
+ import { useRouter as Re } from "vue-router";
3
+ import { AddIcon as ze } from "@kong/icons";
4
+ import { createI18n as Ye, i18nTComponent as Xe } from "@kong-ui-public/i18n";
5
+ import { useAxios as ye, useDebouncedFilter as Ze, useFetcher as et, useDeleteUrlBuilder as tt, FetcherStatus as ot, EntityBaseTable as st, EntityFilter as nt, PermissionsWrapper as ie, EntityDeleteModal as rt, EntityTypes as at, useErrors as it, EntityBaseFormType as Me, EntityBaseForm as lt, SupportedEntityType as Te, EntityFormSection as ut, ConfigurationSchemaSection as Se, EntityBaseConfigCard as ct } from "@kong-ui-public/entities-shared";
6
+ const dt = {
7
7
  list: {
8
8
  table_headers: {
9
9
  username: "Username",
@@ -98,19 +98,19 @@ const ct = {
98
98
  tooltip: "An optional set of strings associated with the Consumer for grouping and filtering."
99
99
  }
100
100
  }
101
- }, dt = {
102
- consumers: ct
101
+ }, mt = {
102
+ consumers: dt
103
103
  };
104
- function mt() {
105
- const e = ze("en-us", dt);
104
+ function pt() {
105
+ const e = Ye("en-us", mt);
106
106
  return {
107
107
  i18n: e,
108
- i18nT: Ye(e)
108
+ i18nT: Xe(e)
109
109
  // Translation component <i18n-t>
110
110
  };
111
111
  }
112
112
  const ce = {
113
- useI18n: mt
113
+ useI18n: pt
114
114
  }, oe = "/v2/control-planes/{controlPlaneId}/core-entities", se = "/{workspace}", z = {
115
115
  list: {
116
116
  konnect: {
@@ -136,13 +136,13 @@ const ce = {
136
136
  edit: `${se}/consumers/{id}`
137
137
  }
138
138
  }
139
- }, pt = { class: "add-consumer-form-container" }, ft = { class: "add-consumer-form-cta" }, gt = { class: "select-item-label" }, vt = {
139
+ }, ft = { class: "add-consumer-form-container" }, gt = { class: "add-consumer-form-cta" }, vt = { class: "select-item-label" }, yt = {
140
140
  key: 0,
141
141
  class: "select-item-desc"
142
- }, yt = {
142
+ }, ht = {
143
143
  key: 0,
144
144
  class: "kong-ui-entity-add-consumers-error"
145
- }, ht = { key: 0 }, bt = /* @__PURE__ */ ue({
145
+ }, bt = { key: 0 }, Ct = /* @__PURE__ */ ue({
146
146
  __name: "AddConsumerModal",
147
147
  props: {
148
148
  /** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
@@ -160,14 +160,14 @@ const ce = {
160
160
  emits: ["cancel", "add:success", "add:partial-success", "error"],
161
161
  setup(e, { emit: m }) {
162
162
  var _;
163
- const { i18n: { t: r } } = ce.useI18n(), t = e, D = m, { axiosInstance: n } = ve((_ = t.config) == null ? void 0 : _.axiosRequestConfig), G = C([]), {
163
+ const { i18n: { t: r } } = ce.useI18n(), t = e, D = m, { axiosInstance: n } = ye((_ = t.config) == null ? void 0 : _.axiosRequestConfig), G = C([]), {
164
164
  debouncedQueryChange: M,
165
165
  loading: S,
166
166
  allRecords: x,
167
167
  error: p,
168
168
  loadItems: Y,
169
169
  results: j
170
- } = Xe(
170
+ } = Ze(
171
171
  t.config,
172
172
  z.list[t.config.app].all,
173
173
  "",
@@ -175,7 +175,7 @@ const ce = {
175
175
  fetchedItemsKey: "data",
176
176
  searchKeys: ["username", "id"]
177
177
  }
178
- ), H = (u) => u, X = E(() => p.value ? r("consumers.errors.general") : ""), Z = C(0), V = E(() => x.value === void 0), J = E(() => j.value.map((u) => ({
178
+ ), L = (u) => u, X = E(() => p.value ? r("consumers.errors.general") : ""), Z = C(0), V = E(() => x.value === void 0), H = E(() => j.value.map((u) => ({
179
179
  label: u.username || u.customId,
180
180
  value: u.id,
181
181
  selected: G.value.includes(u.id),
@@ -187,7 +187,7 @@ const ce = {
187
187
  return f ? f.username || f.custom_id : u;
188
188
  }, re = () => {
189
189
  T.value = "", B.value = [], y.value = [], D("cancel");
190
- }, B = C([]), R = C(!1), T = C(""), L = async () => {
190
+ }, B = C([]), R = C(!1), T = C(""), J = async () => {
191
191
  if (!G.value.length) {
192
192
  T.value = "", y.value = [], D("cancel");
193
193
  return;
@@ -225,9 +225,9 @@ const ce = {
225
225
  return (g = f.reason) == null ? void 0 : g.message;
226
226
  }).filter(Boolean);
227
227
  };
228
- return ge(J, () => {
228
+ return ve(H, () => {
229
229
  Z.value++;
230
- }, { immediate: !0, deep: !0 }), ge(() => t.visible, () => {
230
+ }, { immediate: !0, deep: !0 }), ve(() => t.visible, () => {
231
231
  t.visible && Y();
232
232
  }, { immediate: !0 }), (u, f) => {
233
233
  const g = U("KMultiselect"), k = U("KAlert"), Q = U("KPrompt");
@@ -238,18 +238,18 @@ const ce = {
238
238
  title: s(r)("consumers.consumer_groups.add.title"),
239
239
  visible: e.visible,
240
240
  onCancel: re,
241
- onProceed: L
241
+ onProceed: J
242
242
  }, {
243
243
  default: l(() => [
244
- I("div", pt, [
245
- I("p", ft, h(s(r)("consumers.consumer_groups.add.ctaText")), 1),
244
+ I("div", ft, [
245
+ I("p", gt, h(s(r)("consumers.consumer_groups.add.ctaText")), 1),
246
246
  d(g, {
247
247
  modelValue: G.value,
248
248
  "onUpdate:modelValue": f[0] || (f[0] = (K) => G.value = K),
249
249
  autosuggest: "",
250
250
  "data-testid": "add-consumers-multiselect",
251
251
  "dropdown-footer-text": V.value ? s(r)("consumers.consumer_groups.add.footer") : void 0,
252
- items: J.value,
252
+ items: H.value,
253
253
  label: s(r)("consumers.consumer_groups.add.consumers_label"),
254
254
  loading: s(S),
255
255
  placeholder: s(r)("consumers.consumer_groups.add.consumer_placeholder"),
@@ -259,17 +259,17 @@ const ce = {
259
259
  onQueryChange: s(M)
260
260
  }, {
261
261
  "item-template": l(({ item: K }) => [
262
- I("div", gt, h(K.label), 1),
263
- H(K).data.username && H(K).data.custom_id ? ($(), q("div", vt, h(H(K).data.custom_id), 1)) : ne("", !0)
262
+ I("div", vt, h(K.label), 1),
263
+ L(K).data.username && L(K).data.custom_id ? ($(), q("div", yt, h(L(K).data.custom_id), 1)) : ne("", !0)
264
264
  ]),
265
265
  _: 1
266
266
  }, 8, ["modelValue", "dropdown-footer-text", "items", "label", "loading", "placeholder", "readonly", "onQueryChange"]),
267
- T.value || X.value || y.value.length ? ($(), q("div", yt, [
267
+ T.value || X.value || y.value.length ? ($(), q("div", ht, [
268
268
  d(k, { appearance: "danger" }, {
269
269
  default: l(() => [
270
270
  I("p", null, h(s(r)("consumers.errors.add")), 1),
271
- y.value.length ? ($(), q("ul", ht, [
272
- ($(!0), q(xe, null, De(y.value, (K, de) => ($(), q("li", { key: de }, h(K), 1))), 128))
271
+ y.value.length ? ($(), q("ul", bt, [
272
+ ($(!0), q(De, null, Ae(y.value, (K, de) => ($(), q("li", { key: de }, h(K), 1))), 128))
273
273
  ])) : ne("", !0),
274
274
  I("div", null, h(T.value || X.value), 1)
275
275
  ]),
@@ -282,12 +282,12 @@ const ce = {
282
282
  }, 8, ["action-button-disabled", "title", "visible"]);
283
283
  };
284
284
  }
285
- }), ye = (e, m) => {
285
+ }), he = (e, m) => {
286
286
  const r = e.__vccOpts || e;
287
287
  for (const [t, D] of m)
288
288
  r[t] = D;
289
289
  return r;
290
- }, Ct = /* @__PURE__ */ ye(bt, [["__scopeId", "data-v-d54468ab"]]), _t = { class: "kong-ui-entities-consumers-list" }, kt = { key: 1 }, It = /* @__PURE__ */ ue({
290
+ }, _t = /* @__PURE__ */ he(Ct, [["__scopeId", "data-v-d54468ab"]]), kt = { class: "kong-ui-entities-consumers-list" }, It = { key: 1 }, wt = /* @__PURE__ */ ue({
291
291
  __name: "ConsumerList",
292
292
  props: {
293
293
  /** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
@@ -333,21 +333,21 @@ const ce = {
333
333
  },
334
334
  emits: ["error", "copy:success", "copy:error", "delete:success", "add:success", "remove:success"],
335
335
  setup(e, { emit: m }) {
336
- var we;
337
- const r = m, t = e, { i18nT: D, i18n: { t: n } } = ce.useI18n(), G = Ae(), { axiosInstance: M } = ve((we = t.config) == null ? void 0 : we.axiosRequestConfig), S = C(1), x = E(() => !!t.config.consumerGroupId), p = E(
336
+ var $e;
337
+ const r = m, t = e, { i18nT: D, i18n: { t: n } } = ce.useI18n(), G = Re(), { axiosInstance: M } = ye(($e = t.config) == null ? void 0 : $e.axiosRequestConfig), S = C(1), x = E(() => !!t.config.consumerGroupId), p = E(
338
338
  () => x.value ? "kong-ui-entities-consumers-list-in-group-page" : "kong-ui-entities-consumers-list"
339
339
  ), Y = E(() => t.config.app !== "kongManager" || !!t.config.disableSorting), j = {
340
340
  // the Username column is non-hidable
341
341
  username: { label: n("consumers.list.table_headers.username"), searchable: !0, sortable: !0, hidable: !1 },
342
342
  custom_id: { label: n("consumers.list.table_headers.custom_id"), searchable: !0, sortable: !0 },
343
343
  tags: { label: n("consumers.list.table_headers.tags"), sortable: !1 }
344
- }, H = j, X = (o) => ({
344
+ }, L = j, X = (o) => ({
345
345
  "data-testid": o.username ?? o.custom_id ?? o.id
346
346
  }), Z = E(() => {
347
347
  var c, b, A, P;
348
348
  let o = `${t.config.apiBaseUrl}${z.list[t.config.app][x.value ? "forConsumerGroup" : "all"]}`;
349
349
  return t.config.app === "konnect" ? o = o.replace(/{controlPlaneId}/gi, ((c = t.config) == null ? void 0 : c.controlPlaneId) || "").replace(/{consumerGroupId}/gi, ((b = t.config) == null ? void 0 : b.consumerGroupId) || "") : t.config.app === "kongManager" && (o = o.replace(/\/{workspace}/gi, (A = t.config) != null && A.workspace ? `/${t.config.workspace}` : "").replace(/{consumerGroupId}/gi, ((P = t.config) == null ? void 0 : P.consumerGroupId) || "")), o;
350
- }), V = C(""), J = E(() => {
350
+ }), V = C(""), H = E(() => {
351
351
  const o = t.config.app === "konnect" || t.config.isExactMatch;
352
352
  return o ? {
353
353
  isExactMatch: o,
@@ -360,11 +360,11 @@ const ce = {
360
360
  },
361
361
  schema: t.config.filterSchema
362
362
  };
363
- }), N = E(() => x.value && !t.config.paginatedEndpoint ? "consumers" : void 0), { fetcher: re, fetcherState: B } = Ze(t.config, Z.value, N.value), R = () => {
363
+ }), N = E(() => x.value && !t.config.paginatedEndpoint ? "consumers" : void 0), { fetcher: re, fetcherState: B } = et(t.config, Z.value, N.value), R = () => {
364
364
  V.value = "";
365
365
  }, T = () => {
366
366
  S.value++;
367
- }, L = (o) => o ?? "-", a = C(null), i = (o, c) => {
367
+ }, J = (o) => o ?? "-", a = C(null), i = (o, c) => {
368
368
  const b = o.id;
369
369
  if (!c(b)) {
370
370
  r("copy:error", {
@@ -401,11 +401,11 @@ const ce = {
401
401
  }), u = (o) => ({
402
402
  label: n("consumers.actions.edit"),
403
403
  to: t.config.getEditRoute(o)
404
- }), f = C(void 0), g = C(!1), k = C(!1), Q = C(""), K = et(t.config, Z.value), de = (o) => {
404
+ }), f = C(void 0), g = C(!1), k = C(!1), Q = C(""), K = tt(t.config, Z.value), de = (o) => {
405
405
  f.value = o, g.value = !0;
406
- }, Te = () => {
406
+ }, Fe = () => {
407
407
  g.value = !1;
408
- }, Fe = async () => {
408
+ }, Ue = async () => {
409
409
  var o, c, b;
410
410
  if ((o = f.value) != null && o.id) {
411
411
  k.value = !0;
@@ -417,38 +417,38 @@ const ce = {
417
417
  k.value = !1;
418
418
  }
419
419
  }
420
- }, me = C(!1), he = () => {
420
+ }, me = C(!1), be = () => {
421
421
  me.value = !0;
422
- }, be = () => {
422
+ }, Ce = () => {
423
423
  me.value = !1;
424
- }, Ce = (o, c) => {
425
- c || be(), S.value++, r("add:success", o);
426
- }, Ue = () => {
427
- x.value && he();
428
- }, O = C(void 0), pe = C(!1), Ve = C(""), Be = (o) => {
424
+ }, _e = (o, c) => {
425
+ c || Ce(), S.value++, r("add:success", o);
426
+ }, Ve = () => {
427
+ x.value && be();
428
+ }, O = C(void 0), pe = C(!1), Be = C(""), Ke = (o) => {
429
429
  O.value = o, pe.value = !0;
430
- }, _e = () => {
430
+ }, ke = () => {
431
431
  pe.value = !1, O.value = void 0;
432
- }, Ke = E(() => {
432
+ }, Pe = E(() => {
433
433
  var c, b, A, P;
434
434
  let o = `${t.config.apiBaseUrl}${z.list[t.config.app].oneForConsumerGroup}`;
435
435
  return t.config.app === "konnect" ? o = o.replace(/{controlPlaneId}/gi, ((c = t.config) == null ? void 0 : c.controlPlaneId) || "").replace(/{consumerGroupId}/gi, ((b = t.config) == null ? void 0 : b.consumerGroupId) || "") : t.config.app === "kongManager" && (o = o.replace(/\/{workspace}/gi, (A = t.config) != null && A.workspace ? `/${t.config.workspace}` : "").replace(/{consumerGroupId}/gi, ((P = t.config) == null ? void 0 : P.consumerGroupId) || "")), o;
436
- }), ke = C(!1), Pe = async () => {
436
+ }), Ie = C(!1), qe = async () => {
437
437
  if (O.value) {
438
- ke.value = !0;
438
+ Ie.value = !0;
439
439
  try {
440
- const o = Ke.value.replace(/{consumerId}/gi, O.value.id);
441
- await M.delete(o), r("remove:success", O.value), _e(), S.value++;
440
+ const o = Pe.value.replace(/{consumerId}/gi, O.value.id);
441
+ await M.delete(o), r("remove:success", O.value), ke(), S.value++;
442
442
  } catch (o) {
443
- Ve.value = o.message || n("consumers.errors.delete"), r("error", o);
443
+ Be.value = o.message || n("consumers.errors.delete"), r("error", o);
444
444
  } finally {
445
- ke.value = !1;
445
+ Ie.value = !1;
446
446
  }
447
447
  }
448
- }, Ie = C(!1);
449
- ge(B, (o) => {
448
+ }, we = C(!1);
449
+ ve(B, (o) => {
450
450
  var c, b, A, P;
451
- if (Array.isArray((c = o == null ? void 0 : o.response) == null ? void 0 : c.data) && (Ie.value = o.response.data.length > 0), o.status === tt.Error) {
451
+ if (Array.isArray((c = o == null ? void 0 : o.response) == null ? void 0 : c.data) && (we.value = o.response.data.length > 0), o.status === ot.Error) {
452
452
  a.value = {
453
453
  title: n("consumers.errors.general")
454
454
  }, (P = (A = (b = o.error) == null ? void 0 : b.response) == null ? void 0 : A.data) != null && P.message && (a.value.message = o.error.response.data.message), r("error", o.error);
@@ -462,12 +462,12 @@ const ce = {
462
462
  message: `${n("consumers.list.empty_state.description")}${t.config.additionMessageForEmptyState ? ` ${t.config.additionMessageForEmptyState}` : ""}`,
463
463
  title: n("consumers.title")
464
464
  });
465
- return Oe(async () => {
465
+ return je(async () => {
466
466
  await t.canCreate() && (fe.value.title = x.value ? n("consumers.list.empty_state.title_for_consumer_group") : n("consumers.list.empty_state.title"), fe.value.ctaText = x.value ? n("consumers.actions.add_consumer") : n("consumers.actions.create"));
467
467
  }), (o, c) => {
468
- const b = U("KButton"), A = U("KBadge"), P = U("KTruncate"), ae = U("KDropdownItem"), $e = U("KClipboardProvider"), qe = U("KPrompt");
469
- return $(), q("div", _t, [
470
- d(s(ot), {
468
+ const b = U("KButton"), A = U("KBadge"), P = U("KTruncate"), ae = U("KDropdownItem"), Ee = U("KClipboardProvider"), Ne = U("KPrompt");
469
+ return $(), q("div", kt, [
470
+ d(s(st), {
471
471
  "cache-identifier": e.cacheIdentifier,
472
472
  "disable-pagination": x.value && !e.config.paginatedEndpoint,
473
473
  "disable-pagination-page-jump": "",
@@ -481,22 +481,22 @@ const ce = {
481
481
  "preferences-storage-key": p.value,
482
482
  query: V.value,
483
483
  "row-attributes": X,
484
- "table-headers": s(H),
484
+ "table-headers": s(L),
485
485
  onClearSearchInput: R,
486
486
  "onClick:row": c[3] || (c[3] = (v) => F(v)),
487
- onEmptyStateCtaClicked: Ue,
487
+ onEmptyStateCtaClicked: Ve,
488
488
  onSort: T
489
489
  }, {
490
490
  "toolbar-filter": l(() => [
491
- x.value ? ne("", !0) : ($(), W(s(st), {
491
+ x.value ? ne("", !0) : ($(), W(s(nt), {
492
492
  key: 0,
493
493
  modelValue: V.value,
494
494
  "onUpdate:modelValue": c[0] || (c[0] = (v) => V.value = v),
495
- config: J.value
495
+ config: H.value
496
496
  }, null, 8, ["modelValue", "config"]))
497
497
  ]),
498
498
  "toolbar-button": l(() => [
499
- ($(), W(je, {
499
+ ($(), W(Le, {
500
500
  disabled: !e.useActionOutside,
501
501
  to: "#kong-ui-app-page-header-action-button"
502
502
  }, [
@@ -509,15 +509,15 @@ const ce = {
509
509
  "data-testid": "toolbar-add-consumer",
510
510
  size: e.useActionOutside ? "medium" : "large",
511
511
  to: e.config.consumerGroupId ? void 0 : e.config.createRoute,
512
- onClick: c[1] || (c[1] = () => e.config.consumerGroupId ? he() : void 0)
512
+ onClick: c[1] || (c[1] = () => e.config.consumerGroupId ? be() : void 0)
513
513
  }, {
514
514
  default: l(() => [
515
- d(s(We)),
515
+ d(s(ze)),
516
516
  te(" " + h(e.config.consumerGroupId ? s(n)("consumers.actions.add_consumer") : s(n)("consumers.list.toolbar_actions.new_consumer")), 1)
517
517
  ]),
518
518
  _: 1
519
519
  }, 8, ["size", "to"]), [
520
- [Je, Ie.value]
520
+ [Je, we.value]
521
521
  ])
522
522
  ]),
523
523
  _: 1
@@ -525,17 +525,17 @@ const ce = {
525
525
  ], 8, ["disabled"]))
526
526
  ]),
527
527
  username: l(({ rowValue: v }) => [
528
- I("b", null, h(L(v)), 1)
528
+ I("b", null, h(J(v)), 1)
529
529
  ]),
530
530
  custom_id: l(({ rowValue: v }) => [
531
- te(h(L(v)), 1)
531
+ te(h(J(v)), 1)
532
532
  ]),
533
533
  tags: l(({ rowValue: v }) => [
534
534
  v && v.length > 0 ? ($(), W(P, { key: 0 }, {
535
535
  default: l(() => [
536
- ($(!0), q(xe, null, De(v, (ee) => ($(), W(A, {
536
+ ($(!0), q(De, null, Ae(v, (ee) => ($(), W(A, {
537
537
  key: ee,
538
- onClick: c[2] || (c[2] = Le(() => {
538
+ onClick: c[2] || (c[2] = Qe(() => {
539
539
  }, ["stop"]))
540
540
  }, {
541
541
  default: l(() => [
@@ -545,14 +545,14 @@ const ce = {
545
545
  }, 1024))), 128))
546
546
  ]),
547
547
  _: 2
548
- }, 1024)) : ($(), q("span", kt, "-"))
548
+ }, 1024)) : ($(), q("span", It, "-"))
549
549
  ]),
550
550
  actions: l(({ row: v }) => [
551
- d($e, null, {
551
+ d(Ee, null, {
552
552
  default: l(({ copyToClipboard: ee }) => [
553
553
  d(ae, {
554
554
  "data-testid": "action-entity-copy-id",
555
- onClick: (Ne) => i(v, ee)
555
+ onClick: (Oe) => i(v, ee)
556
556
  }, {
557
557
  default: l(() => [
558
558
  te(h(s(n)("consumers.actions.copy_id")), 1)
@@ -562,11 +562,11 @@ const ce = {
562
562
  ]),
563
563
  _: 2
564
564
  }, 1024),
565
- d($e, null, {
565
+ d(Ee, null, {
566
566
  default: l(({ copyToClipboard: ee }) => [
567
567
  d(ae, {
568
568
  "data-testid": "action-entity-copy-json",
569
- onClick: (Ne) => y(v, ee)
569
+ onClick: (Oe) => y(v, ee)
570
570
  }, {
571
571
  default: l(() => [
572
572
  te(h(s(n)("consumers.actions.copy_json")), 1)
@@ -607,7 +607,7 @@ const ce = {
607
607
  danger: "",
608
608
  "data-testid": "action-entity-delete",
609
609
  "has-divider": "",
610
- onClick: () => e.config.consumerGroupId ? Be(v) : de(v)
610
+ onClick: () => e.config.consumerGroupId ? Ke(v) : de(v)
611
611
  }, {
612
612
  default: l(() => [
613
613
  te(h(e.config.consumerGroupId ? s(n)("consumers.actions.remove") : s(n)("consumers.actions.delete")), 1)
@@ -620,42 +620,42 @@ const ce = {
620
620
  ]),
621
621
  _: 1
622
622
  }, 8, ["cache-identifier", "disable-pagination", "disable-sorting", "empty-state-options", "error-message", "fetcher", "fetcher-cache-key", "preferences-storage-key", "query", "table-headers"]),
623
- d(s(nt), {
623
+ d(s(rt), {
624
624
  "action-button-disabled": k.value,
625
625
  "data-testid": "delete-consumer-modal",
626
626
  description: s(n)("consumers.delete.description"),
627
627
  "entity-name": f.value && (f.value.username || f.value.custom_id || f.value.id),
628
- "entity-type": s(rt).Consumer,
628
+ "entity-type": s(at).Consumer,
629
629
  error: Q.value,
630
630
  title: s(n)("consumers.delete.title"),
631
631
  visible: g.value,
632
- onCancel: Te,
633
- onProceed: Fe
632
+ onCancel: Fe,
633
+ onProceed: Ue
634
634
  }, null, 8, ["action-button-disabled", "description", "entity-name", "entity-type", "error", "title", "visible"]),
635
- e.config.consumerGroupId ? ($(), W(Ct, {
635
+ e.config.consumerGroupId ? ($(), W(_t, {
636
636
  key: 0,
637
637
  config: e.config,
638
638
  "data-testid": "add-consumer-modal",
639
639
  visible: me.value,
640
- "onAdd:partialSuccess": c[4] || (c[4] = (v) => Ce(v, !0)),
641
- "onAdd:success": c[5] || (c[5] = (v) => Ce(v)),
642
- onCancel: be
640
+ "onAdd:partialSuccess": c[4] || (c[4] = (v) => _e(v, !0)),
641
+ "onAdd:success": c[5] || (c[5] = (v) => _e(v)),
642
+ onCancel: Ce
643
643
  }, null, 8, ["config", "visible"])) : ne("", !0),
644
- e.config.consumerGroupId && O.value ? ($(), W(qe, {
644
+ e.config.consumerGroupId && O.value ? ($(), W(Ne, {
645
645
  key: 1,
646
646
  "action-button-appearance": "danger",
647
647
  "data-testid": "remove-consumer-modal",
648
648
  title: s(n)("consumers.consumer_groups.remove.title"),
649
649
  visible: pe.value,
650
- onCancel: _e,
651
- onProceed: Pe
650
+ onCancel: ke,
651
+ onProceed: qe
652
652
  }, {
653
653
  default: l(() => [
654
654
  d(s(D), {
655
655
  class: "message",
656
656
  keypath: e.config.consumerGroupName ? "consumers.consumer_groups.remove.confirmation" : "consumers.consumer_groups.remove.confirmationNoCG",
657
657
  tag: "p"
658
- }, Qe({
658
+ }, We({
659
659
  consumer: l(() => [
660
660
  I("strong", null, h(O.value.username || O.value.custom_id || O.value.id), 1)
661
661
  ]),
@@ -676,31 +676,31 @@ const ce = {
676
676
  ]);
677
677
  };
678
678
  }
679
- }), Pt = /* @__PURE__ */ ye(It, [["__scopeId", "data-v-b03c77ce"]]);
680
- let le;
681
- const wt = new Uint8Array(16);
682
- function $t() {
679
+ }), qt = /* @__PURE__ */ he(wt, [["__scopeId", "data-v-b03c77ce"]]);
680
+ var w = [];
681
+ for (var ge = 0; ge < 256; ++ge)
682
+ w.push((ge + 256).toString(16).slice(1));
683
+ function $t(e, m = 0) {
684
+ return (w[e[m + 0]] + w[e[m + 1]] + w[e[m + 2]] + w[e[m + 3]] + "-" + w[e[m + 4]] + w[e[m + 5]] + "-" + w[e[m + 6]] + w[e[m + 7]] + "-" + w[e[m + 8]] + w[e[m + 9]] + "-" + w[e[m + 10]] + w[e[m + 11]] + w[e[m + 12]] + w[e[m + 13]] + w[e[m + 14]] + w[e[m + 15]]).toLowerCase();
685
+ }
686
+ var le, Et = new Uint8Array(16);
687
+ function Gt() {
683
688
  if (!le && (le = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !le))
684
689
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
685
- return le(wt);
686
- }
687
- const w = [];
688
- for (let e = 0; e < 256; ++e)
689
- w.push((e + 256).toString(16).slice(1));
690
- function Et(e, m = 0) {
691
- return w[e[m + 0]] + w[e[m + 1]] + w[e[m + 2]] + w[e[m + 3]] + "-" + w[e[m + 4]] + w[e[m + 5]] + "-" + w[e[m + 6]] + w[e[m + 7]] + "-" + w[e[m + 8]] + w[e[m + 9]] + "-" + w[e[m + 10]] + w[e[m + 11]] + w[e[m + 12]] + w[e[m + 13]] + w[e[m + 14]] + w[e[m + 15]];
690
+ return le(Et);
692
691
  }
693
- const Gt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Se = {
694
- randomUUID: Gt
692
+ var Mt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
693
+ const xe = {
694
+ randomUUID: Mt
695
695
  };
696
- function Mt(e, m, r) {
697
- if (Se.randomUUID && !m && !e)
698
- return Se.randomUUID();
696
+ function St(e, m, r) {
697
+ if (xe.randomUUID && !m && !e)
698
+ return xe.randomUUID();
699
699
  e = e || {};
700
- const t = e.random || (e.rng || $t)();
701
- return t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128, Et(t);
700
+ var t = e.random || (e.rng || Gt)();
701
+ return t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128, $t(t);
702
702
  }
703
- const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { class: "fields-group-text" }, At = ["aria-labelledby"], Rt = /* @__PURE__ */ ue({
703
+ const xt = { class: "kong-ui-entities-consumer-form" }, Dt = ["id"], At = { class: "fields-group-text" }, Rt = ["aria-labelledby"], Tt = /* @__PURE__ */ ue({
704
704
  __name: "ConsumerForm",
705
705
  props: {
706
706
  /** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
@@ -726,8 +726,8 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
726
726
  },
727
727
  emits: ["update", "error", "loading"],
728
728
  setup(e, { emit: m }) {
729
- var L;
730
- const r = e, t = m, { i18nT: D, i18n: { t: n } } = ce.useI18n(), G = Ae(), { axiosInstance: M } = ve((L = r.config) == null ? void 0 : L.axiosRequestConfig), { getMessageFromError: S } = at(), x = Mt(), p = Ee({
729
+ var J;
730
+ const r = e, t = m, { i18nT: D, i18n: { t: n } } = ce.useI18n(), G = Re(), { axiosInstance: M } = ye((J = r.config) == null ? void 0 : J.axiosRequestConfig), { getMessageFromError: S } = it(), x = St(), p = Ge({
731
731
  fields: {
732
732
  username: "",
733
733
  customId: "",
@@ -735,14 +735,14 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
735
735
  },
736
736
  readonly: !1,
737
737
  errorMessage: ""
738
- }), Y = Ee({
738
+ }), Y = Ge({
739
739
  username: "",
740
740
  customId: "",
741
741
  tags: ""
742
742
  }), j = E(() => {
743
743
  var a, i;
744
744
  return (i = z.form[(a = r.config) == null ? void 0 : a.app]) == null ? void 0 : i.edit;
745
- }), H = () => {
745
+ }), L = () => {
746
746
  var a;
747
747
  G.push(((a = r.config) == null ? void 0 : a.cancelRoute) || { name: "consumer-list" });
748
748
  }, X = (a) => {
@@ -754,7 +754,7 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
754
754
  p.fields.username = ((y = a == null ? void 0 : a.item) == null ? void 0 : y.username) || (a == null ? void 0 : a.username) || "", p.fields.customId = ((F = a == null ? void 0 : a.item) == null ? void 0 : F.custom_id) || (a == null ? void 0 : a.custom_id) || "";
755
755
  const i = ((_ = a == null ? void 0 : a.item) == null ? void 0 : _.tags) || (a == null ? void 0 : a.tags) || [];
756
756
  p.fields.tags = (i == null ? void 0 : i.join(", ")) || "", Object.assign(Y, p.fields);
757
- }, J = E(() => r.consumerId ? Ge.Edit : Ge.Create), N = (a) => {
757
+ }, H = E(() => r.consumerId ? Me.Edit : Me.Create), N = (a) => {
758
758
  var y, F, _, u, f, g;
759
759
  let i = `${(y = r.config) == null ? void 0 : y.apiBaseUrl}${z.form[(F = r.config) == null ? void 0 : F.app][a]}`;
760
760
  return ((_ = r.config) == null ? void 0 : _.app) === "konnect" ? i = i.replace(/{controlPlaneId}/gi, ((u = r.config) == null ? void 0 : u.controlPlaneId) || "") : ((f = r.config) == null ? void 0 : f.app) === "kongManager" && (i = i.replace(/\/{workspace}/gi, (g = r.config) != null && g.workspace ? `/${r.config.workspace}` : "")), i = i.replace(/{id}/gi, r.consumerId), i;
@@ -770,7 +770,7 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
770
770
  try {
771
771
  p.readonly = !0;
772
772
  let i;
773
- await M.post(N("validate"), R.value), J.value === "create" ? i = await M.post(N("create"), R.value) : J.value === "edit" && (i = ((a = r.config) == null ? void 0 : a.app) === "konnect" ? await M.put(N("edit"), R.value) : await M.patch(N("edit"), R.value)), V(i == null ? void 0 : i.data), t("update", i == null ? void 0 : i.data);
773
+ await M.post(N("validate"), R.value), H.value === "create" ? i = await M.post(N("create"), R.value) : H.value === "edit" && (i = ((a = r.config) == null ? void 0 : a.app) === "konnect" ? await M.put(N("edit"), R.value) : await M.patch(N("edit"), R.value)), V(i == null ? void 0 : i.data), t("update", i == null ? void 0 : i.data);
774
774
  } catch (i) {
775
775
  p.errorMessage = S(i), t("error", i);
776
776
  } finally {
@@ -779,18 +779,18 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
779
779
  };
780
780
  return (a, i) => {
781
781
  const y = U("KInput"), F = U("KCard");
782
- return $(), q("div", St, [
783
- d(s(it), {
782
+ return $(), q("div", xt, [
783
+ d(s(lt), {
784
784
  "can-submit": re.value && B.value,
785
785
  config: e.config,
786
786
  "edit-id": e.consumerId,
787
787
  "enable-terraform": e.enableTerraform,
788
- "entity-type": s(Re).Consumer,
788
+ "entity-type": s(Te).Consumer,
789
789
  "error-message": p.errorMessage,
790
790
  "fetch-url": j.value,
791
791
  "form-fields": R.value,
792
792
  "is-readonly": p.readonly,
793
- onCancel: H,
793
+ onCancel: L,
794
794
  "onFetch:error": i[3] || (i[3] = (_) => Z(_)),
795
795
  "onFetch:success": V,
796
796
  onLoading: i[4] || (i[4] = (_) => X(_)),
@@ -798,7 +798,7 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
798
798
  }, {
799
799
  default: l(() => [
800
800
  I("div", null, [
801
- d(s(lt), {
801
+ d(s(ut), {
802
802
  description: s(n)("consumers.form.info.description"),
803
803
  "has-divider": "",
804
804
  title: s(n)("consumers.form.info.title")
@@ -808,8 +808,8 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
808
808
  I("h3", {
809
809
  id: `fields-group-title-${s(x)}`,
810
810
  class: "fields-group-title"
811
- }, h(s(n)("consumers.form.consumer_identification.title")) + "* ", 9, xt),
812
- I("p", Dt, h(s(n)("consumers.form.consumer_identification.description")), 1)
811
+ }, h(s(n)("consumers.form.consumer_identification.title")) + "* ", 9, Dt),
812
+ I("p", At, h(s(n)("consumers.form.consumer_identification.description")), 1)
813
813
  ]),
814
814
  d(F, null, {
815
815
  default: l(() => [
@@ -867,7 +867,7 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
867
867
  ]),
868
868
  _: 1
869
869
  }, 8, ["modelValue", "label", "placeholder", "readonly"])
870
- ], 8, At)
870
+ ], 8, Rt)
871
871
  ]),
872
872
  _: 1
873
873
  }),
@@ -897,7 +897,7 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
897
897
  ]);
898
898
  };
899
899
  }
900
- }), qt = /* @__PURE__ */ ye(Rt, [["__scopeId", "data-v-5973c664"]]), Tt = { class: "kong-ui-consumer-entity-config-card" }, Nt = /* @__PURE__ */ ue({
900
+ }), Nt = /* @__PURE__ */ he(Tt, [["__scopeId", "data-v-5973c664"]]), Ft = { class: "kong-ui-consumer-entity-config-card" }, Ot = /* @__PURE__ */ ue({
901
901
  __name: "ConsumerConfigCard",
902
902
  props: {
903
903
  /** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
@@ -935,12 +935,12 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
935
935
  const m = e, { i18n: { t: r }, i18nT: t } = ce.useI18n(), D = E(() => z.form[m.config.app].edit), n = C({
936
936
  id: {},
937
937
  username: {
938
- section: Me.Basic,
938
+ section: Se.Basic,
939
939
  tooltip: r("consumers.fields.username.tooltip"),
940
940
  order: 1
941
941
  },
942
942
  custom_id: {
943
- section: Me.Basic,
943
+ section: Se.Basic,
944
944
  tooltip: r("consumers.fields.custom_id.tooltip"),
945
945
  label: r("consumers.fields.custom_id.label"),
946
946
  order: 2
@@ -957,13 +957,13 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
957
957
  hidden: !0
958
958
  }
959
959
  });
960
- return (G, M) => ($(), q("div", Tt, [
961
- d(s(ut), {
960
+ return (G, M) => ($(), q("div", Ft, [
961
+ d(s(ct), {
962
962
  config: e.config,
963
963
  "config-card-doc": e.configCardDoc,
964
964
  "config-schema": n.value,
965
965
  "enable-terraform": e.enableTerraform,
966
- "entity-type": s(Re).Consumer,
966
+ "entity-type": s(Te).Consumer,
967
967
  "fetch-url": D.value,
968
968
  "hide-title": e.hideTitle,
969
969
  "onFetch:error": M[0] || (M[0] = (S) => G.$emit("fetch:error", S)),
@@ -998,7 +998,7 @@ const St = { class: "kong-ui-entities-consumer-form" }, xt = ["id"], Dt = { clas
998
998
  }
999
999
  });
1000
1000
  export {
1001
- Nt as ConsumerConfigCard,
1002
- qt as ConsumerForm,
1003
- Pt as ConsumerList
1001
+ Ot as ConsumerConfigCard,
1002
+ Nt as ConsumerForm,
1003
+ qt as ConsumerList
1004
1004
  };
@@ -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,re,ge,se,f){"use strict";const ye={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:{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. 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 he(){const t=se.createI18n("en-us",ye);return{i18n:t,i18nT:se.i18nTComponent(t)}}const X={useI18n:he},j="/v2/control-planes/{controlPlaneId}/core-entities",L="/{workspace}",P={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}`}}},Ce={class:"add-consumer-form-container"},be={class:"add-consumer-form-cta"},ke={class:"select-item-label"},_e={key:0,class:"select-item-desc"},Ie={key:0,class:"kong-ui-entity-add-consumers-error"},we={key:0},Ve=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:d}){var C;const{i18n:{t:s}}=X.useI18n(),o=t,x=d,{axiosInstance:r}=f.useAxios((C=o.config)==null?void 0:C.axiosRequestConfig),_=e.ref([]),{debouncedQueryChange:I,loading:w,allRecords:V,error:u,loadItems:W,results:R}=f.useDebouncedFilter(o.config,P.list[o.config.app].all,"",{fetchedItemsKey:"data",searchKeys:["username","id"]}),U=l=>l,H=e.computed(()=>u.value?s("consumers.errors.general"):""),J=e.ref(0),M=e.computed(()=>V.value===void 0),K=e.computed(()=>R.value.map(l=>({label:l.username||l.customId,value:l.id,selected:_.value.includes(l.id),data:l}))),A=l=>{var p;const m=M.value?R.value.find(b=>b.id===l):(p=V.value)==null?void 0:p.find(b=>b.id===l);return m?m.username||m.custom_id:l},z=()=>{D.value="",G.value=[],y.value=[],x("cancel")},G=e.ref([]),B=e.ref(!1),D=e.ref(""),q=async()=>{if(!_.value.length){D.value="",y.value=[],x("cancel");return}B.value=!0,D.value="",G.value=[],y.value=[];try{const l=_.value.map(b=>i(b)),m=await Promise.allSettled(l);let p=!0;m.forEach(b=>{b.status!=="fulfilled"&&(p=!1)}),p?(G.value=[],y.value=[],x("add:success",_.value),_.value=[]):(G.value.length&&x("add:partial-success",G.value),_.value=[],$(m))}catch{D.value=s("consumers.errors.add"),x("error",D.value)}finally{B.value=!1}},a=e.computed(()=>{var m,p,b,O;let l=`${o.config.apiBaseUrl}${P.list[o.config.app].forConsumerGroup}`;return o.config.app==="konnect"?l=l.replace(/{controlPlaneId}/gi,((m=o.config)==null?void 0:m.controlPlaneId)||"").replace(/{consumerGroupId}/gi,((p=o.config)==null?void 0:p.consumerGroupId)||""):o.config.app==="kongManager"&&(l=l.replace(/\/{workspace}/gi,(b=o.config)!=null&&b.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((O=o.config)==null?void 0:O.consumerGroupId)||"")),l}),i=async l=>{const m={consumer:l};try{const p=await r.post(a.value,m);return G.value.push(l),p}catch(p){let b=`${A(l)} - ${p.message}`;return p.response.status===409&&(b=`${A(l)} - ${s("consumers.errors.already_added")}`),Promise.reject(Error(b))}},y=e.ref([]),$=l=>{y.value=l.map(m=>{var p;return(p=m.reason)==null?void 0:p.message}).filter(Boolean)};return e.watch(K,()=>{J.value++},{immediate:!0,deep:!0}),e.watch(()=>o.visible,()=>{o.visible&&W()},{immediate:!0}),(l,m)=>{const p=e.resolveComponent("KMultiselect"),b=e.resolveComponent("KAlert"),O=e.resolveComponent("KPrompt");return e.openBlock(),e.createBlock(O,{"action-button-disabled":B.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:z,onProceed:q},{default:e.withCtx(()=>[e.createElementVNode("div",Ce,[e.createElementVNode("p",be,e.toDisplayString(e.unref(s)("consumers.consumer_groups.add.ctaText")),1),e.createVNode(p,{modelValue:_.value,"onUpdate:modelValue":m[0]||(m[0]=T=>_.value=T),autosuggest:"","data-testid":"add-consumers-multiselect","dropdown-footer-text":M.value?e.unref(s)("consumers.consumer_groups.add.footer"):void 0,items:K.value,label:e.unref(s)("consumers.consumer_groups.add.consumers_label"),loading:e.unref(w),placeholder:e.unref(s)("consumers.consumer_groups.add.consumer_placeholder"),readonly:B.value,required:"",width:"100%",onQueryChange:e.unref(I)},{"item-template":e.withCtx(({item:T})=>[e.createElementVNode("div",ke,e.toDisplayString(T.label),1),U(T).data.username&&U(T).data.custom_id?(e.openBlock(),e.createElementBlock("div",_e,e.toDisplayString(U(T).data.custom_id),1)):e.createCommentVNode("",!0)]),_:1},8,["modelValue","dropdown-footer-text","items","label","loading","placeholder","readonly","onQueryChange"]),D.value||H.value||y.value.length?(e.openBlock(),e.createElementBlock("div",Ie,[e.createVNode(b,{appearance:"danger"},{default:e.withCtx(()=>[e.createElementVNode("p",null,e.toDisplayString(e.unref(s)("consumers.errors.add")),1),y.value.length?(e.openBlock(),e.createElementBlock("ul",we,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,(T,ee)=>(e.openBlock(),e.createElementBlock("li",{key:ee},e.toDisplayString(T),1))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",null,e.toDisplayString(D.value||H.value),1)]),_:1})])):e.createCommentVNode("",!0)])]),_:1},8,["action-button-disabled","title","visible"])}}}),v=(t,d)=>{const s=t.__vccOpts||t;for(const[o,x]of d)s[o]=x;return s},xe=v(Ve,[["__scopeId","data-v-d54468ab"]]),Ne={class:"kong-ui-entities-consumers-list"},Ee={key:1},Be=v(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","copy:success","copy:error","delete:success","add:success","remove:success"],setup(t,{emit:d}){var pe;const s=d,o=t,{i18nT:x,i18n:{t:r}}=X.useI18n(),_=re.useRouter(),{axiosInstance:I}=f.useAxios((pe=o.config)==null?void 0:pe.axiosRequestConfig),w=e.ref(1),V=e.computed(()=>!!o.config.consumerGroupId),u=e.computed(()=>V.value?"kong-ui-entities-consumers-list-in-group-page":"kong-ui-entities-consumers-list"),W=e.computed(()=>o.config.app!=="kongManager"||!!o.config.disableSorting),R={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=R,H=n=>({"data-testid":n.username??n.custom_id??n.id}),J=e.computed(()=>{var c,h,N,S;let n=`${o.config.apiBaseUrl}${P.list[o.config.app][V.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,(N=o.config)!=null&&N.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((S=o.config)==null?void 0:S.consumerGroupId)||"")),n}),M=e.ref(""),K=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:R.username,custom_id:R.custom_id},schema:o.config.filterSchema}}),A=e.computed(()=>V.value&&!o.config.paginatedEndpoint?"consumers":void 0),{fetcher:z,fetcherState:G}=f.useFetcher(o.config,J.value,A.value),B=()=>{M.value=""},D=()=>{w.value++},q=n=>n??"-",a=e.ref(null),i=(n,c)=>{const h=n.id;if(!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})})},y=(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")})},$=async n=>{var h;await((h=o.canRetrieve)==null?void 0:h.call(o,n))&&_.push(o.config.getViewRoute(n.id))},C=n=>({label:r("consumers.actions.view"),to:o.config.getViewRoute(n)}),l=n=>({label:r("consumers.actions.edit"),to:o.config.getEditRoute(n)}),m=e.ref(void 0),p=e.ref(!1),b=e.ref(!1),O=e.ref(""),T=f.useDeleteUrlBuilder(o.config,J.value),ee=n=>{m.value=n,p.value=!0},Ke=()=>{p.value=!1},qe=async()=>{var n,c,h;if((n=m.value)!=null&&n.id){b.value=!0;try{await I.delete(T(m.value.id)),b.value=!1,p.value=!1,w.value++,s("delete:success",m.value)}catch(N){O.value=((h=(c=N.response)==null?void 0:c.data)==null?void 0:h.message)||N.message||r("consumers.errors.delete"),s("error",N)}finally{b.value=!1}}},te=e.ref(!1),ie=()=>{te.value=!0},le=()=>{te.value=!1},ce=(n,c)=>{c||le(),w.value++,s("add:success",n)},Oe=()=>{V.value&&ie()},F=e.ref(void 0),oe=e.ref(!1),je=e.ref(""),Le=n=>{F.value=n,oe.value=!0},de=()=>{oe.value=!1,F.value=void 0},We=e.computed(()=>{var c,h,N,S;let n=`${o.config.apiBaseUrl}${P.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,(N=o.config)!=null&&N.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((S=o.config)==null?void 0:S.consumerGroupId)||"")),n}),ue=e.ref(!1),He=async()=>{if(F.value){ue.value=!0;try{const n=We.value.replace(/{consumerId}/gi,F.value.id);await I.delete(n),s("remove:success",F.value),de(),w.value++}catch(n){je.value=n.message||r("consumers.errors.delete"),s("error",n)}finally{ue.value=!1}}},me=e.ref(!1);e.watch(G,n=>{var c,h,N,S;if(Array.isArray((c=n==null?void 0:n.response)==null?void 0:c.data)&&(me.value=n.response.data.length>0),n.status===f.FetcherStatus.Error){a.value={title:r("consumers.errors.general")},(S=(N=(h=n.error)==null?void 0:h.response)==null?void 0:N.data)!=null&&S.message&&(a.value.message=n.error.response.data.message),s("error",n.error);return}a.value=null});const ne=e.ref({ctaPath:V.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()&&(ne.value.title=V.value?r("consumers.list.empty_state.title_for_consumer_group"):r("consumers.list.empty_state.title"),ne.value.ctaText=V.value?r("consumers.actions.add_consumer"):r("consumers.actions.create"))}),(n,c)=>{const h=e.resolveComponent("KButton"),N=e.resolveComponent("KBadge"),S=e.resolveComponent("KTruncate"),Y=e.resolveComponent("KDropdownItem"),fe=e.resolveComponent("KClipboardProvider"),Je=e.resolveComponent("KPrompt");return e.openBlock(),e.createElementBlock("div",Ne,[e.createVNode(e.unref(f.EntityBaseTable),{"cache-identifier":t.cacheIdentifier,"disable-pagination":V.value&&!t.config.paginatedEndpoint,"disable-pagination-page-jump":"","disable-sorting":W.value,"empty-state-options":ne.value,"enable-entity-actions":"","error-message":a.value,fetcher:e.unref(z),"fetcher-cache-key":w.value,"pagination-type":"offset","preferences-storage-key":u.value,query:M.value,"row-attributes":H,"table-headers":e.unref(U),onClearSearchInput:B,"onClick:row":c[3]||(c[3]=g=>$(g)),onEmptyStateCtaClicked:Oe,onSort:D},{"toolbar-filter":e.withCtx(()=>[V.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(f.EntityFilter),{key:0,modelValue:M.value,"onUpdate:modelValue":c[0]||(c[0]=g=>M.value=g),config:K.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.createVNode(e.unref(f.PermissionsWrapper),{"auth-function":()=>t.canCreate()},{default:e.withCtx(()=>[e.withDirectives(e.createVNode(h,{appearance:"primary","data-testid":"toolbar-add-consumer",size:t.useActionOutside?"medium":"large",to:t.config.consumerGroupId?void 0:t.config.createRoute,onClick:c[1]||(c[1]=()=>t.config.consumerGroupId?ie():void 0)},{default:e.withCtx(()=>[e.createVNode(e.unref(ge.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","to"]),[[e.vShow,me.value]])]),_:1},8,["auth-function"])],8,["disabled"]))]),username:e.withCtx(({rowValue:g})=>[e.createElementVNode("b",null,e.toDisplayString(q(g)),1)]),custom_id:e.withCtx(({rowValue:g})=>[e.createTextVNode(e.toDisplayString(q(g)),1)]),tags:e.withCtx(({rowValue:g})=>[g&&g.length>0?(e.openBlock(),e.createBlock(S,{key:0},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g,Q=>(e.openBlock(),e.createBlock(N,{key:Q,onClick:c[2]||(c[2]=e.withModifiers(()=>{},["stop"]))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Q),1)]),_:2},1024))),128))]),_:2},1024)):(e.openBlock(),e.createElementBlock("span",Ee,"-"))]),actions:e.withCtx(({row:g})=>[e.createVNode(fe,null,{default:e.withCtx(({copyToClipboard:Q})=>[e.createVNode(Y,{"data-testid":"action-entity-copy-id",onClick:Qe=>i(g,Q)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.actions.copy_id")),1)]),_:2},1032,["onClick"])]),_:2},1024),e.createVNode(fe,null,{default:e.withCtx(({copyToClipboard:Q})=>[e.createVNode(Y,{"data-testid":"action-entity-copy-json",onClick:Qe=>y(g,Q)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.actions.copy_json")),1)]),_:2},1032,["onClick"])]),_:2},1024),e.createVNode(e.unref(f.PermissionsWrapper),{"auth-function":()=>t.canRetrieve(g)},{default:e.withCtx(()=>[e.createVNode(Y,{"data-testid":"action-entity-view","has-divider":"",item:C(g.id)},null,8,["item"])]),_:2},1032,["auth-function"]),e.createVNode(e.unref(f.PermissionsWrapper),{"auth-function":()=>t.canEdit(g)},{default:e.withCtx(()=>[e.createVNode(Y,{"data-testid":"action-entity-edit",item:l(g.id)},null,8,["item"])]),_:2},1032,["auth-function"]),e.createVNode(e.unref(f.PermissionsWrapper),{"auth-function":()=>t.canDelete(g)},{default:e.withCtx(()=>[e.createVNode(Y,{danger:"","data-testid":"action-entity-delete","has-divider":"",onClick:()=>t.config.consumerGroupId?Le(g):ee(g)},{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"])]),_:1},8,["cache-identifier","disable-pagination","disable-sorting","empty-state-options","error-message","fetcher","fetcher-cache-key","preferences-storage-key","query","table-headers"]),e.createVNode(e.unref(f.EntityDeleteModal),{"action-button-disabled":b.value,"data-testid":"delete-consumer-modal",description:e.unref(r)("consumers.delete.description"),"entity-name":m.value&&(m.value.username||m.value.custom_id||m.value.id),"entity-type":e.unref(f.EntityTypes).Consumer,error:O.value,title:e.unref(r)("consumers.delete.title"),visible:p.value,onCancel:Ke,onProceed:qe},null,8,["action-button-disabled","description","entity-name","entity-type","error","title","visible"]),t.config.consumerGroupId?(e.openBlock(),e.createBlock(xe,{key:0,config:t.config,"data-testid":"add-consumer-modal",visible:te.value,"onAdd:partialSuccess":c[4]||(c[4]=g=>ce(g,!0)),"onAdd:success":c[5]||(c[5]=g=>ce(g)),onCancel:le},null,8,["config","visible"])):e.createCommentVNode("",!0),t.config.consumerGroupId&&F.value?(e.openBlock(),e.createBlock(Je,{key:1,"action-button-appearance":"danger","data-testid":"remove-consumer-modal",title:e.unref(r)("consumers.consumer_groups.remove.title"),visible:oe.value,onCancel:de,onProceed:He},{default:e.withCtx(()=>[e.createVNode(e.unref(x),{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(F.value.username||F.value.custom_id||F.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-b03c77ce"]]);let Z;const De=new Uint8Array(16);function $e(){if(!Z&&(Z=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Z))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Z(De)}const k=[];for(let t=0;t<256;++t)k.push((t+256).toString(16).slice(1));function Me(t,d=0){return k[t[d+0]]+k[t[d+1]]+k[t[d+2]]+k[t[d+3]]+"-"+k[t[d+4]]+k[t[d+5]]+"-"+k[t[d+6]]+k[t[d+7]]+"-"+k[t[d+8]]+k[t[d+9]]+"-"+k[t[d+10]]+k[t[d+11]]+k[t[d+12]]+k[t[d+13]]+k[t[d+14]]+k[t[d+15]]}const ae={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ge(t,d,s){if(ae.randomUUID&&!d&&!t)return ae.randomUUID();t=t||{};const o=t.random||(t.rng||$e)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,Me(o)}const Te={class:"kong-ui-entities-consumer-form"},Se=["id"],Ae={class:"fields-group-text"},Fe=["aria-labelledby"],Re=v(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:""},enableTerraform:{type:Boolean,default:!1}},emits:["update","error","loading"],setup(t,{emit:d}){var q;const s=t,o=d,{i18nT:x,i18n:{t:r}}=X.useI18n(),_=re.useRouter(),{axiosInstance:I}=f.useAxios((q=s.config)==null?void 0:q.axiosRequestConfig),{getMessageFromError:w}=f.useErrors(),V=Ge(),u=e.reactive({fields:{username:"",customId:"",tags:""},readonly:!1,errorMessage:""}),W=e.reactive({username:"",customId:"",tags:""}),R=e.computed(()=>{var a,i;return(i=P.form[(a=s.config)==null?void 0:a.app])==null?void 0:i.edit}),U=()=>{var a;_.push(((a=s.config)==null?void 0:a.cancelRoute)||{name:"consumer-list"})},H=a=>{o("loading",a)},J=a=>{o("error",a)},M=a=>{var y,$,C;u.fields.username=((y=a==null?void 0:a.item)==null?void 0:y.username)||(a==null?void 0:a.username)||"",u.fields.customId=(($=a==null?void 0:a.item)==null?void 0:$.custom_id)||(a==null?void 0:a.custom_id)||"";const i=((C=a==null?void 0:a.item)==null?void 0:C.tags)||(a==null?void 0:a.tags)||[];u.fields.tags=(i==null?void 0:i.join(", "))||"",Object.assign(W,u.fields)},K=e.computed(()=>s.consumerId?f.EntityBaseFormType.Edit:f.EntityBaseFormType.Create),A=a=>{var y,$,C,l,m,p;let i=`${(y=s.config)==null?void 0:y.apiBaseUrl}${P.form[($=s.config)==null?void 0:$.app][a]}`;return((C=s.config)==null?void 0:C.app)==="konnect"?i=i.replace(/{controlPlaneId}/gi,((l=s.config)==null?void 0:l.controlPlaneId)||""):((m=s.config)==null?void 0:m.app)==="kongManager"&&(i=i.replace(/\/{workspace}/gi,(p=s.config)!=null&&p.workspace?`/${s.config.workspace}`:"")),i=i.replace(/{id}/gi,s.consumerId),i},z=e.computed(()=>!!u.fields.username||!!u.fields.customId),G=e.computed(()=>JSON.stringify(u.fields)!==JSON.stringify(W)),B=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(y=>String(y||"").trim()))==null?void 0:i.filter(y=>y!=="")}}),D=async()=>{var a;try{u.readonly=!0;let i;await I.post(A("validate"),B.value),K.value==="create"?i=await I.post(A("create"),B.value):K.value==="edit"&&(i=((a=s.config)==null?void 0:a.app)==="konnect"?await I.put(A("edit"),B.value):await I.patch(A("edit"),B.value)),M(i==null?void 0:i.data),o("update",i==null?void 0:i.data)}catch(i){u.errorMessage=w(i),o("error",i)}finally{u.readonly=!1}};return(a,i)=>{const y=e.resolveComponent("KInput"),$=e.resolveComponent("KCard");return e.openBlock(),e.createElementBlock("div",Te,[e.createVNode(e.unref(f.EntityBaseForm),{"can-submit":z.value&&G.value,config:t.config,"edit-id":t.consumerId,"enable-terraform":t.enableTerraform,"entity-type":e.unref(f.SupportedEntityType).Consumer,"error-message":u.errorMessage,"fetch-url":R.value,"form-fields":B.value,"is-readonly":u.readonly,onCancel:U,"onFetch:error":i[3]||(i[3]=C=>J(C)),"onFetch:success":M,onLoading:i[4]||(i[4]=C=>H(C)),onSubmit:D},{default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createVNode(e.unref(f.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(V)}`,class:"fields-group-title"},e.toDisplayString(e.unref(r)("consumers.form.consumer_identification.title"))+"* ",9,Se),e.createElementVNode("p",Ae,e.toDisplayString(e.unref(r)("consumers.form.consumer_identification.description")),1)]),e.createVNode($,null,{default:e.withCtx(()=>[e.createElementVNode("fieldset",{"aria-labelledby":`fields-group-title-${e.unref(V)}`},[e.createVNode(y,{modelValue:u.fields.username,"onUpdate:modelValue":i[0]||(i[0]=C=>u.fields.username=C),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(x),{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(y,{modelValue:u.fields.customId,"onUpdate:modelValue":i[1]||(i[1]=C=>u.fields.customId=C),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(x),{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,Fe)]),_:1}),e.createVNode(y,{modelValue:u.fields.tags,"onUpdate:modelValue":i[2]||(i[2]=C=>u.fields.tags=C),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","enable-terraform","entity-type","error-message","fetch-url","form-fields","is-readonly"])])}}}),[["__scopeId","data-v-5973c664"]]),Pe={class:"kong-ui-consumer-entity-config-card"},Ue=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},enableTerraform:{type:Boolean,default:!1}},emits:["loading","fetch:error","fetch:success"],setup(t){const d=t,{i18n:{t:s},i18nT:o}=X.useI18n(),x=e.computed(()=>P.form[d.config.app].edit),r=e.ref({id:{},username:{section:f.ConfigurationSchemaSection.Basic,tooltip:s("consumers.fields.username.tooltip"),order:1},custom_id:{section:f.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(_,I)=>(e.openBlock(),e.createElementBlock("div",Pe,[e.createVNode(e.unref(f.EntityBaseConfigCard),{config:t.config,"config-card-doc":t.configCardDoc,"config-schema":r.value,"enable-terraform":t.enableTerraform,"entity-type":e.unref(f.SupportedEntityType).Consumer,"fetch-url":x.value,"hide-title":t.hideTitle,"onFetch:error":I[0]||(I[0]=w=>_.$emit("fetch:error",w)),"onFetch:success":I[1]||(I[1]=w=>_.$emit("fetch:success",w)),onLoading:I[2]||(I[2]=w=>_.$emit("loading",w))},{"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","enable-terraform","entity-type","fetch-url","hide-title"])]))}});E.ConsumerConfigCard=Ue,E.ConsumerForm=Re,E.ConsumerList=Be,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,se,ye,ae,f){"use strict";const he={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:{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. 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 Ce(){const t=ae.createI18n("en-us",he);return{i18n:t,i18nT:ae.i18nTComponent(t)}}const X={useI18n:Ce},j="/v2/control-planes/{controlPlaneId}/core-entities",L="/{workspace}",P={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}`}}},be={class:"add-consumer-form-container"},ke={class:"add-consumer-form-cta"},_e={class:"select-item-label"},we={key:0,class:"select-item-desc"},Ie={key:0,class:"kong-ui-entity-add-consumers-error"},Ve={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:d}){var C;const{i18n:{t:s}}=X.useI18n(),o=t,x=d,{axiosInstance:r}=f.useAxios((C=o.config)==null?void 0:C.axiosRequestConfig),_=e.ref([]),{debouncedQueryChange:w,loading:I,allRecords:V,error:u,loadItems:W,results:R}=f.useDebouncedFilter(o.config,P.list[o.config.app].all,"",{fetchedItemsKey:"data",searchKeys:["username","id"]}),U=l=>l,H=e.computed(()=>u.value?s("consumers.errors.general"):""),J=e.ref(0),M=e.computed(()=>V.value===void 0),K=e.computed(()=>R.value.map(l=>({label:l.username||l.customId,value:l.id,selected:_.value.includes(l.id),data:l}))),A=l=>{var p;const m=M.value?R.value.find(b=>b.id===l):(p=V.value)==null?void 0:p.find(b=>b.id===l);return m?m.username||m.custom_id:l},z=()=>{D.value="",G.value=[],y.value=[],x("cancel")},G=e.ref([]),B=e.ref(!1),D=e.ref(""),q=async()=>{if(!_.value.length){D.value="",y.value=[],x("cancel");return}B.value=!0,D.value="",G.value=[],y.value=[];try{const l=_.value.map(b=>i(b)),m=await Promise.allSettled(l);let p=!0;m.forEach(b=>{b.status!=="fulfilled"&&(p=!1)}),p?(G.value=[],y.value=[],x("add:success",_.value),_.value=[]):(G.value.length&&x("add:partial-success",G.value),_.value=[],$(m))}catch{D.value=s("consumers.errors.add"),x("error",D.value)}finally{B.value=!1}},a=e.computed(()=>{var m,p,b,O;let l=`${o.config.apiBaseUrl}${P.list[o.config.app].forConsumerGroup}`;return o.config.app==="konnect"?l=l.replace(/{controlPlaneId}/gi,((m=o.config)==null?void 0:m.controlPlaneId)||"").replace(/{consumerGroupId}/gi,((p=o.config)==null?void 0:p.consumerGroupId)||""):o.config.app==="kongManager"&&(l=l.replace(/\/{workspace}/gi,(b=o.config)!=null&&b.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((O=o.config)==null?void 0:O.consumerGroupId)||"")),l}),i=async l=>{const m={consumer:l};try{const p=await r.post(a.value,m);return G.value.push(l),p}catch(p){let b=`${A(l)} - ${p.message}`;return p.response.status===409&&(b=`${A(l)} - ${s("consumers.errors.already_added")}`),Promise.reject(Error(b))}},y=e.ref([]),$=l=>{y.value=l.map(m=>{var p;return(p=m.reason)==null?void 0:p.message}).filter(Boolean)};return e.watch(K,()=>{J.value++},{immediate:!0,deep:!0}),e.watch(()=>o.visible,()=>{o.visible&&W()},{immediate:!0}),(l,m)=>{const p=e.resolveComponent("KMultiselect"),b=e.resolveComponent("KAlert"),O=e.resolveComponent("KPrompt");return e.openBlock(),e.createBlock(O,{"action-button-disabled":B.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:z,onProceed:q},{default:e.withCtx(()=>[e.createElementVNode("div",be,[e.createElementVNode("p",ke,e.toDisplayString(e.unref(s)("consumers.consumer_groups.add.ctaText")),1),e.createVNode(p,{modelValue:_.value,"onUpdate:modelValue":m[0]||(m[0]=T=>_.value=T),autosuggest:"","data-testid":"add-consumers-multiselect","dropdown-footer-text":M.value?e.unref(s)("consumers.consumer_groups.add.footer"):void 0,items:K.value,label:e.unref(s)("consumers.consumer_groups.add.consumers_label"),loading:e.unref(I),placeholder:e.unref(s)("consumers.consumer_groups.add.consumer_placeholder"),readonly:B.value,required:"",width:"100%",onQueryChange:e.unref(w)},{"item-template":e.withCtx(({item:T})=>[e.createElementVNode("div",_e,e.toDisplayString(T.label),1),U(T).data.username&&U(T).data.custom_id?(e.openBlock(),e.createElementBlock("div",we,e.toDisplayString(U(T).data.custom_id),1)):e.createCommentVNode("",!0)]),_:1},8,["modelValue","dropdown-footer-text","items","label","loading","placeholder","readonly","onQueryChange"]),D.value||H.value||y.value.length?(e.openBlock(),e.createElementBlock("div",Ie,[e.createVNode(b,{appearance:"danger"},{default:e.withCtx(()=>[e.createElementVNode("p",null,e.toDisplayString(e.unref(s)("consumers.errors.add")),1),y.value.length?(e.openBlock(),e.createElementBlock("ul",Ve,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,(T,te)=>(e.openBlock(),e.createElementBlock("li",{key:te},e.toDisplayString(T),1))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",null,e.toDisplayString(D.value||H.value),1)]),_:1})])):e.createCommentVNode("",!0)])]),_:1},8,["action-button-disabled","title","visible"])}}}),v=(t,d)=>{const s=t.__vccOpts||t;for(const[o,x]of d)s[o]=x;return s},Ne=v(xe,[["__scopeId","data-v-d54468ab"]]),Ee={class:"kong-ui-entities-consumers-list"},Be={key:1},De=v(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","copy:success","copy:error","delete:success","add:success","remove:success"],setup(t,{emit:d}){var fe;const s=d,o=t,{i18nT:x,i18n:{t:r}}=X.useI18n(),_=se.useRouter(),{axiosInstance:w}=f.useAxios((fe=o.config)==null?void 0:fe.axiosRequestConfig),I=e.ref(1),V=e.computed(()=>!!o.config.consumerGroupId),u=e.computed(()=>V.value?"kong-ui-entities-consumers-list-in-group-page":"kong-ui-entities-consumers-list"),W=e.computed(()=>o.config.app!=="kongManager"||!!o.config.disableSorting),R={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=R,H=n=>({"data-testid":n.username??n.custom_id??n.id}),J=e.computed(()=>{var c,h,N,S;let n=`${o.config.apiBaseUrl}${P.list[o.config.app][V.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,(N=o.config)!=null&&N.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((S=o.config)==null?void 0:S.consumerGroupId)||"")),n}),M=e.ref(""),K=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:R.username,custom_id:R.custom_id},schema:o.config.filterSchema}}),A=e.computed(()=>V.value&&!o.config.paginatedEndpoint?"consumers":void 0),{fetcher:z,fetcherState:G}=f.useFetcher(o.config,J.value,A.value),B=()=>{M.value=""},D=()=>{I.value++},q=n=>n??"-",a=e.ref(null),i=(n,c)=>{const h=n.id;if(!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})})},y=(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")})},$=async n=>{var h;await((h=o.canRetrieve)==null?void 0:h.call(o,n))&&_.push(o.config.getViewRoute(n.id))},C=n=>({label:r("consumers.actions.view"),to:o.config.getViewRoute(n)}),l=n=>({label:r("consumers.actions.edit"),to:o.config.getEditRoute(n)}),m=e.ref(void 0),p=e.ref(!1),b=e.ref(!1),O=e.ref(""),T=f.useDeleteUrlBuilder(o.config,J.value),te=n=>{m.value=n,p.value=!0},Oe=()=>{p.value=!1},je=async()=>{var n,c,h;if((n=m.value)!=null&&n.id){b.value=!0;try{await w.delete(T(m.value.id)),b.value=!1,p.value=!1,I.value++,s("delete:success",m.value)}catch(N){O.value=((h=(c=N.response)==null?void 0:c.data)==null?void 0:h.message)||N.message||r("consumers.errors.delete"),s("error",N)}finally{b.value=!1}}},oe=e.ref(!1),le=()=>{oe.value=!0},ce=()=>{oe.value=!1},de=(n,c)=>{c||ce(),I.value++,s("add:success",n)},Le=()=>{V.value&&le()},F=e.ref(void 0),ne=e.ref(!1),We=e.ref(""),He=n=>{F.value=n,ne.value=!0},ue=()=>{ne.value=!1,F.value=void 0},Je=e.computed(()=>{var c,h,N,S;let n=`${o.config.apiBaseUrl}${P.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,(N=o.config)!=null&&N.workspace?`/${o.config.workspace}`:"").replace(/{consumerGroupId}/gi,((S=o.config)==null?void 0:S.consumerGroupId)||"")),n}),me=e.ref(!1),Qe=async()=>{if(F.value){me.value=!0;try{const n=Je.value.replace(/{consumerId}/gi,F.value.id);await w.delete(n),s("remove:success",F.value),ue(),I.value++}catch(n){We.value=n.message||r("consumers.errors.delete"),s("error",n)}finally{me.value=!1}}},pe=e.ref(!1);e.watch(G,n=>{var c,h,N,S;if(Array.isArray((c=n==null?void 0:n.response)==null?void 0:c.data)&&(pe.value=n.response.data.length>0),n.status===f.FetcherStatus.Error){a.value={title:r("consumers.errors.general")},(S=(N=(h=n.error)==null?void 0:h.response)==null?void 0:N.data)!=null&&S.message&&(a.value.message=n.error.response.data.message),s("error",n.error);return}a.value=null});const re=e.ref({ctaPath:V.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()&&(re.value.title=V.value?r("consumers.list.empty_state.title_for_consumer_group"):r("consumers.list.empty_state.title"),re.value.ctaText=V.value?r("consumers.actions.add_consumer"):r("consumers.actions.create"))}),(n,c)=>{const h=e.resolveComponent("KButton"),N=e.resolveComponent("KBadge"),S=e.resolveComponent("KTruncate"),Y=e.resolveComponent("KDropdownItem"),ge=e.resolveComponent("KClipboardProvider"),ze=e.resolveComponent("KPrompt");return e.openBlock(),e.createElementBlock("div",Ee,[e.createVNode(e.unref(f.EntityBaseTable),{"cache-identifier":t.cacheIdentifier,"disable-pagination":V.value&&!t.config.paginatedEndpoint,"disable-pagination-page-jump":"","disable-sorting":W.value,"empty-state-options":re.value,"enable-entity-actions":"","error-message":a.value,fetcher:e.unref(z),"fetcher-cache-key":I.value,"pagination-type":"offset","preferences-storage-key":u.value,query:M.value,"row-attributes":H,"table-headers":e.unref(U),onClearSearchInput:B,"onClick:row":c[3]||(c[3]=g=>$(g)),onEmptyStateCtaClicked:Le,onSort:D},{"toolbar-filter":e.withCtx(()=>[V.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(f.EntityFilter),{key:0,modelValue:M.value,"onUpdate:modelValue":c[0]||(c[0]=g=>M.value=g),config:K.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.createVNode(e.unref(f.PermissionsWrapper),{"auth-function":()=>t.canCreate()},{default:e.withCtx(()=>[e.withDirectives(e.createVNode(h,{appearance:"primary","data-testid":"toolbar-add-consumer",size:t.useActionOutside?"medium":"large",to:t.config.consumerGroupId?void 0:t.config.createRoute,onClick:c[1]||(c[1]=()=>t.config.consumerGroupId?le():void 0)},{default:e.withCtx(()=>[e.createVNode(e.unref(ye.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","to"]),[[e.vShow,pe.value]])]),_:1},8,["auth-function"])],8,["disabled"]))]),username:e.withCtx(({rowValue:g})=>[e.createElementVNode("b",null,e.toDisplayString(q(g)),1)]),custom_id:e.withCtx(({rowValue:g})=>[e.createTextVNode(e.toDisplayString(q(g)),1)]),tags:e.withCtx(({rowValue:g})=>[g&&g.length>0?(e.openBlock(),e.createBlock(S,{key:0},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g,Q=>(e.openBlock(),e.createBlock(N,{key:Q,onClick:c[2]||(c[2]=e.withModifiers(()=>{},["stop"]))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Q),1)]),_:2},1024))),128))]),_:2},1024)):(e.openBlock(),e.createElementBlock("span",Be,"-"))]),actions:e.withCtx(({row:g})=>[e.createVNode(ge,null,{default:e.withCtx(({copyToClipboard:Q})=>[e.createVNode(Y,{"data-testid":"action-entity-copy-id",onClick:Ye=>i(g,Q)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.actions.copy_id")),1)]),_:2},1032,["onClick"])]),_:2},1024),e.createVNode(ge,null,{default:e.withCtx(({copyToClipboard:Q})=>[e.createVNode(Y,{"data-testid":"action-entity-copy-json",onClick:Ye=>y(g,Q)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(r)("consumers.actions.copy_json")),1)]),_:2},1032,["onClick"])]),_:2},1024),e.createVNode(e.unref(f.PermissionsWrapper),{"auth-function":()=>t.canRetrieve(g)},{default:e.withCtx(()=>[e.createVNode(Y,{"data-testid":"action-entity-view","has-divider":"",item:C(g.id)},null,8,["item"])]),_:2},1032,["auth-function"]),e.createVNode(e.unref(f.PermissionsWrapper),{"auth-function":()=>t.canEdit(g)},{default:e.withCtx(()=>[e.createVNode(Y,{"data-testid":"action-entity-edit",item:l(g.id)},null,8,["item"])]),_:2},1032,["auth-function"]),e.createVNode(e.unref(f.PermissionsWrapper),{"auth-function":()=>t.canDelete(g)},{default:e.withCtx(()=>[e.createVNode(Y,{danger:"","data-testid":"action-entity-delete","has-divider":"",onClick:()=>t.config.consumerGroupId?He(g):te(g)},{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"])]),_:1},8,["cache-identifier","disable-pagination","disable-sorting","empty-state-options","error-message","fetcher","fetcher-cache-key","preferences-storage-key","query","table-headers"]),e.createVNode(e.unref(f.EntityDeleteModal),{"action-button-disabled":b.value,"data-testid":"delete-consumer-modal",description:e.unref(r)("consumers.delete.description"),"entity-name":m.value&&(m.value.username||m.value.custom_id||m.value.id),"entity-type":e.unref(f.EntityTypes).Consumer,error:O.value,title:e.unref(r)("consumers.delete.title"),visible:p.value,onCancel:Oe,onProceed:je},null,8,["action-button-disabled","description","entity-name","entity-type","error","title","visible"]),t.config.consumerGroupId?(e.openBlock(),e.createBlock(Ne,{key:0,config:t.config,"data-testid":"add-consumer-modal",visible:oe.value,"onAdd:partialSuccess":c[4]||(c[4]=g=>de(g,!0)),"onAdd:success":c[5]||(c[5]=g=>de(g)),onCancel:ce},null,8,["config","visible"])):e.createCommentVNode("",!0),t.config.consumerGroupId&&F.value?(e.openBlock(),e.createBlock(ze,{key:1,"action-button-appearance":"danger","data-testid":"remove-consumer-modal",title:e.unref(r)("consumers.consumer_groups.remove.title"),visible:ne.value,onCancel:ue,onProceed:Qe},{default:e.withCtx(()=>[e.createVNode(e.unref(x),{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(F.value.username||F.value.custom_id||F.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-b03c77ce"]]);for(var k=[],ee=0;ee<256;++ee)k.push((ee+256).toString(16).slice(1));function $e(t,d=0){return(k[t[d+0]]+k[t[d+1]]+k[t[d+2]]+k[t[d+3]]+"-"+k[t[d+4]]+k[t[d+5]]+"-"+k[t[d+6]]+k[t[d+7]]+"-"+k[t[d+8]]+k[t[d+9]]+"-"+k[t[d+10]]+k[t[d+11]]+k[t[d+12]]+k[t[d+13]]+k[t[d+14]]+k[t[d+15]]).toLowerCase()}var Z,Me=new Uint8Array(16);function Ge(){if(!Z&&(Z=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Z))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Z(Me)}var Te=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const ie={randomUUID:Te};function Se(t,d,s){if(ie.randomUUID&&!d&&!t)return ie.randomUUID();t=t||{};var o=t.random||(t.rng||Ge)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,$e(o)}const Ae={class:"kong-ui-entities-consumer-form"},Fe=["id"],Re={class:"fields-group-text"},Pe=["aria-labelledby"],Ue=v(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:""},enableTerraform:{type:Boolean,default:!1}},emits:["update","error","loading"],setup(t,{emit:d}){var q;const s=t,o=d,{i18nT:x,i18n:{t:r}}=X.useI18n(),_=se.useRouter(),{axiosInstance:w}=f.useAxios((q=s.config)==null?void 0:q.axiosRequestConfig),{getMessageFromError:I}=f.useErrors(),V=Se(),u=e.reactive({fields:{username:"",customId:"",tags:""},readonly:!1,errorMessage:""}),W=e.reactive({username:"",customId:"",tags:""}),R=e.computed(()=>{var a,i;return(i=P.form[(a=s.config)==null?void 0:a.app])==null?void 0:i.edit}),U=()=>{var a;_.push(((a=s.config)==null?void 0:a.cancelRoute)||{name:"consumer-list"})},H=a=>{o("loading",a)},J=a=>{o("error",a)},M=a=>{var y,$,C;u.fields.username=((y=a==null?void 0:a.item)==null?void 0:y.username)||(a==null?void 0:a.username)||"",u.fields.customId=(($=a==null?void 0:a.item)==null?void 0:$.custom_id)||(a==null?void 0:a.custom_id)||"";const i=((C=a==null?void 0:a.item)==null?void 0:C.tags)||(a==null?void 0:a.tags)||[];u.fields.tags=(i==null?void 0:i.join(", "))||"",Object.assign(W,u.fields)},K=e.computed(()=>s.consumerId?f.EntityBaseFormType.Edit:f.EntityBaseFormType.Create),A=a=>{var y,$,C,l,m,p;let i=`${(y=s.config)==null?void 0:y.apiBaseUrl}${P.form[($=s.config)==null?void 0:$.app][a]}`;return((C=s.config)==null?void 0:C.app)==="konnect"?i=i.replace(/{controlPlaneId}/gi,((l=s.config)==null?void 0:l.controlPlaneId)||""):((m=s.config)==null?void 0:m.app)==="kongManager"&&(i=i.replace(/\/{workspace}/gi,(p=s.config)!=null&&p.workspace?`/${s.config.workspace}`:"")),i=i.replace(/{id}/gi,s.consumerId),i},z=e.computed(()=>!!u.fields.username||!!u.fields.customId),G=e.computed(()=>JSON.stringify(u.fields)!==JSON.stringify(W)),B=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(y=>String(y||"").trim()))==null?void 0:i.filter(y=>y!=="")}}),D=async()=>{var a;try{u.readonly=!0;let i;await w.post(A("validate"),B.value),K.value==="create"?i=await w.post(A("create"),B.value):K.value==="edit"&&(i=((a=s.config)==null?void 0:a.app)==="konnect"?await w.put(A("edit"),B.value):await w.patch(A("edit"),B.value)),M(i==null?void 0:i.data),o("update",i==null?void 0:i.data)}catch(i){u.errorMessage=I(i),o("error",i)}finally{u.readonly=!1}};return(a,i)=>{const y=e.resolveComponent("KInput"),$=e.resolveComponent("KCard");return e.openBlock(),e.createElementBlock("div",Ae,[e.createVNode(e.unref(f.EntityBaseForm),{"can-submit":z.value&&G.value,config:t.config,"edit-id":t.consumerId,"enable-terraform":t.enableTerraform,"entity-type":e.unref(f.SupportedEntityType).Consumer,"error-message":u.errorMessage,"fetch-url":R.value,"form-fields":B.value,"is-readonly":u.readonly,onCancel:U,"onFetch:error":i[3]||(i[3]=C=>J(C)),"onFetch:success":M,onLoading:i[4]||(i[4]=C=>H(C)),onSubmit:D},{default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createVNode(e.unref(f.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(V)}`,class:"fields-group-title"},e.toDisplayString(e.unref(r)("consumers.form.consumer_identification.title"))+"* ",9,Fe),e.createElementVNode("p",Re,e.toDisplayString(e.unref(r)("consumers.form.consumer_identification.description")),1)]),e.createVNode($,null,{default:e.withCtx(()=>[e.createElementVNode("fieldset",{"aria-labelledby":`fields-group-title-${e.unref(V)}`},[e.createVNode(y,{modelValue:u.fields.username,"onUpdate:modelValue":i[0]||(i[0]=C=>u.fields.username=C),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(x),{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(y,{modelValue:u.fields.customId,"onUpdate:modelValue":i[1]||(i[1]=C=>u.fields.customId=C),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(x),{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,Pe)]),_:1}),e.createVNode(y,{modelValue:u.fields.tags,"onUpdate:modelValue":i[2]||(i[2]=C=>u.fields.tags=C),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","enable-terraform","entity-type","error-message","fetch-url","form-fields","is-readonly"])])}}}),[["__scopeId","data-v-5973c664"]]),Ke={class:"kong-ui-consumer-entity-config-card"},qe=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},enableTerraform:{type:Boolean,default:!1}},emits:["loading","fetch:error","fetch:success"],setup(t){const d=t,{i18n:{t:s},i18nT:o}=X.useI18n(),x=e.computed(()=>P.form[d.config.app].edit),r=e.ref({id:{},username:{section:f.ConfigurationSchemaSection.Basic,tooltip:s("consumers.fields.username.tooltip"),order:1},custom_id:{section:f.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(_,w)=>(e.openBlock(),e.createElementBlock("div",Ke,[e.createVNode(e.unref(f.EntityBaseConfigCard),{config:t.config,"config-card-doc":t.configCardDoc,"config-schema":r.value,"enable-terraform":t.enableTerraform,"entity-type":e.unref(f.SupportedEntityType).Consumer,"fetch-url":x.value,"hide-title":t.hideTitle,"onFetch:error":w[0]||(w[0]=I=>_.$emit("fetch:error",I)),"onFetch:success":w[1]||(w[1]=I=>_.$emit("fetch:success",I)),onLoading:w[2]||(w[2]=I=>_.$emit("loading",I))},{"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","enable-terraform","entity-type","fetch-url","hide-title"])]))}});E.ConsumerConfigCard=qe,E.ConsumerForm=Ue,E.ConsumerList=De,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": "3.5.7",
3
+ "version": "3.5.8",
4
4
  "type": "module",
5
5
  "main": "./dist/entities-consumers.umd.js",
6
6
  "module": "./dist/entities-consumers.es.js",
@@ -26,7 +26,7 @@
26
26
  "axios": "^1.6.8",
27
27
  "vue": ">= 3.3.13 < 4",
28
28
  "vue-router": "^4.3.3",
29
- "@kong-ui-public/entities-shared": "^3.8.5",
29
+ "@kong-ui-public/entities-shared": "^3.8.6",
30
30
  "@kong-ui-public/i18n": "^2.2.2"
31
31
  },
32
32
  "devDependencies": {
@@ -36,7 +36,7 @@
36
36
  "axios": "^1.6.8",
37
37
  "vue": "^3.4.38",
38
38
  "vue-router": "^4.4.3",
39
- "@kong-ui-public/entities-shared": "^3.8.5",
39
+ "@kong-ui-public/entities-shared": "^3.8.6",
40
40
  "@kong-ui-public/i18n": "^2.2.2"
41
41
  },
42
42
  "repository": {