@hortiview/modulebase 0.0.13075 → 0.0.13318

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.
Files changed (35) hide show
  1. package/dist/components/ModuleBase.js +88 -97
  2. package/dist/hooks/useServiceBus.js +19 -11
  3. package/dist/{hooks → lib/hooks}/useServiceBus.d.ts +6 -2
  4. package/dist/{hooks → lib/hooks}/useStores.d.ts +2 -2
  5. package/dist/{main.d.ts → lib/main.d.ts} +1 -1
  6. package/dist/{types → lib/types}/BaseProps.d.ts +1 -2
  7. package/dist/{types → lib/types}/Deprecated.d.ts +6 -0
  8. package/dist/{types → lib/types}/Environment.d.ts +1 -0
  9. package/dist/lib/utils/helper.d.ts +20 -0
  10. package/dist/main.js +114 -113
  11. package/dist/stores/EnvironmentStore.js +3 -2
  12. package/dist/utils/helper.js +48 -0
  13. package/package.json +3 -2
  14. /package/dist/{components → lib/components}/ModuleBase.d.ts +0 -0
  15. /package/dist/{constants.d.ts → lib/constants.d.ts} +0 -0
  16. /package/dist/{hooks → lib/hooks}/useBreadcrumbTranslation.d.ts +0 -0
  17. /package/dist/{hooks → lib/hooks}/useCustom.d.ts +0 -0
  18. /package/dist/{hooks → lib/hooks}/useCustomMutation.d.ts +0 -0
  19. /package/dist/{hooks → lib/hooks}/useEntity.d.ts +0 -0
  20. /package/dist/{hooks → lib/hooks}/useOption.d.ts +0 -0
  21. /package/dist/{hooks → lib/hooks}/useSignalRMessages.d.ts +0 -0
  22. /package/dist/{module-router.d.ts → lib/module-router.d.ts} +0 -0
  23. /package/dist/{provider → lib/provider}/SignalR/SignalRProvider.d.ts +0 -0
  24. /package/dist/{provider → lib/provider}/SignalR/signalR.d.ts +0 -0
  25. /package/dist/{stores → lib/stores}/BasePropsStore.d.ts +0 -0
  26. /package/dist/{stores → lib/stores}/EnvironmentStore.d.ts +0 -0
  27. /package/dist/{types → lib/types}/AppInsights.d.ts +0 -0
  28. /package/dist/{types → lib/types}/CommonOptions.d.ts +0 -0
  29. /package/dist/{types → lib/types}/ModuleApi.d.ts +0 -0
  30. /package/dist/{types → lib/types}/Requests.d.ts +0 -0
  31. /package/dist/{types → lib/types}/ServiceBus.d.ts +0 -0
  32. /package/dist/{types → lib/types}/SystemMessage.d.ts +0 -0
  33. /package/dist/{utils → lib/utils}/api.d.ts +0 -0
  34. /package/dist/{utils → lib/utils}/baseFetches.d.ts +0 -0
  35. /package/dist/{utils → lib/utils}/fetches.d.ts +0 -0
@@ -1,29 +1,29 @@
1
- import { jsx as y } from "react/jsx-runtime";
2
- import { S as R, g as k, n as u, m as q, j as A, a as h, e as H, k as K, l as B, o as j, p as D, q as S, v as L, h as I, w as F, s as U, Q as V } from "../QueryClientProvider-Q_mWQTzQ.js";
3
- import { Q as W } from "../query-CRIVoEP7.js";
4
- import { M as X } from "../mutation-X73nm7Df.js";
5
- import { useState as $, useEffect as b } from "react";
6
- import { Y as z, h as Y, O as G, aU as J } from "../chunk-IR6S3I6Y-BmDdD3SP.js";
7
- import { REQUIRED_PROPS as Z } from "../constants.js";
8
- import { SignalRProvider as x } from "../provider/SignalR/SignalRProvider.js";
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { S as N, g as H, n as u, m as q, j as D, a as h, e as R, k as j, l as V, o as L, p as A, q as S, v as W, h as C, w as F, s as _, Q as U } from "../QueryClientProvider-Q_mWQTzQ.js";
3
+ import { Q as z } from "../query-CRIVoEP7.js";
4
+ import { M as Y } from "../mutation-X73nm7Df.js";
5
+ import { useState as T, useEffect as b } from "react";
6
+ import { Y as G, h as J, O as X, aU as Z } from "../chunk-IR6S3I6Y-BmDdD3SP.js";
7
+ import { SignalRProvider as $ } from "../provider/SignalR/SignalRProvider.js";
9
8
  import { useBasePropsStore as M } from "../stores/BasePropsStore.js";
10
- import { useEnvironmentStore as T } from "../stores/EnvironmentStore.js";
11
- var ee = class extends R {
9
+ import { useEnvironmentStore as k } from "../stores/EnvironmentStore.js";
10
+ import { getEnvironmentVariables as x, checkVersion as ee, arePropsValid as te } from "../utils/helper.js";
11
+ var se = class extends N {
12
12
  constructor(e = {}) {
13
13
  super(), this.config = e, this.#e = /* @__PURE__ */ new Map();
14
14
  }
15
15
  #e;
16
16
  build(e, t, s) {
17
- const r = t.queryKey, n = t.queryHash ?? k(r, t);
18
- let i = this.get(n);
19
- return i || (i = new W({
17
+ const r = t.queryKey, i = t.queryHash ?? H(r, t);
18
+ let a = this.get(i);
19
+ return a || (a = new z({
20
20
  client: e,
21
21
  queryKey: r,
22
- queryHash: n,
22
+ queryHash: i,
23
23
  options: e.defaultQueryOptions(t),
24
24
  state: s,
25
25
  defaultOptions: e.getQueryDefaults(r)
26
- }), this.add(i)), i;
26
+ }), this.add(a)), a;
27
27
  }
28
28
  add(e) {
29
29
  this.#e.has(e.queryHash) || (this.#e.set(e.queryHash, e), this.notify({
@@ -79,7 +79,7 @@ var ee = class extends R {
79
79
  });
80
80
  });
81
81
  }
82
- }, te = class extends R {
82
+ }, re = class extends N {
83
83
  constructor(e = {}) {
84
84
  super(), this.config = e, this.#e = /* @__PURE__ */ new Set(), this.#t = /* @__PURE__ */ new Map(), this.#s = 0;
85
85
  }
@@ -87,7 +87,7 @@ var ee = class extends R {
87
87
  #t;
88
88
  #s;
89
89
  build(e, t, s) {
90
- const r = new X({
90
+ const r = new Y({
91
91
  mutationCache: this,
92
92
  mutationId: ++this.#s,
93
93
  options: e.defaultMutationOptions(t),
@@ -122,7 +122,7 @@ var ee = class extends R {
122
122
  const t = O(e);
123
123
  if (typeof t == "string") {
124
124
  const r = this.#t.get(t)?.find(
125
- (n) => n.state.status === "pending"
125
+ (i) => i.state.status === "pending"
126
126
  );
127
127
  return !r || r === e;
128
128
  } else
@@ -145,11 +145,11 @@ var ee = class extends R {
145
145
  find(e) {
146
146
  const t = { exact: !0, ...e };
147
147
  return this.getAll().find(
148
- (s) => A(t, s)
148
+ (s) => D(t, s)
149
149
  );
150
150
  }
151
151
  findAll(e = {}) {
152
- return this.getAll().filter((t) => A(e, t));
152
+ return this.getAll().filter((t) => D(e, t));
153
153
  }
154
154
  notify(e) {
155
155
  u.batch(() => {
@@ -170,60 +170,60 @@ var ee = class extends R {
170
170
  function O(e) {
171
171
  return e.options.scope?.id;
172
172
  }
173
- function C(e) {
173
+ function I(e) {
174
174
  return {
175
175
  onFetch: (t, s) => {
176
- const r = t.options, n = t.fetchOptions?.meta?.fetchMore?.direction, i = t.state.data?.pages || [], f = t.state.data?.pageParams || [];
177
- let c = { pages: [], pageParams: [] }, d = 0;
178
- const P = async () => {
176
+ const r = t.options, i = t.fetchOptions?.meta?.fetchMore?.direction, a = t.state.data?.pages || [], d = t.state.data?.pageParams || [];
177
+ let c = { pages: [], pageParams: [] }, y = 0;
178
+ const m = async () => {
179
179
  let g = !1;
180
- const Q = (o) => {
181
- Object.defineProperty(o, "signal", {
180
+ const p = (n) => {
181
+ Object.defineProperty(n, "signal", {
182
182
  enumerable: !0,
183
183
  get: () => (t.signal.aborted ? g = !0 : t.signal.addEventListener("abort", () => {
184
184
  g = !0;
185
185
  }), t.signal)
186
186
  });
187
- }, a = H(t.options, t.fetchOptions), m = async (o, l, p) => {
187
+ }, Q = R(t.options, t.fetchOptions), P = async (n, o, l) => {
188
188
  if (g)
189
189
  return Promise.reject();
190
- if (l == null && o.pages.length)
191
- return Promise.resolve(o);
190
+ if (o == null && n.pages.length)
191
+ return Promise.resolve(n);
192
192
  const v = {
193
193
  client: t.client,
194
194
  queryKey: t.queryKey,
195
- pageParam: l,
196
- direction: p ? "backward" : "forward",
195
+ pageParam: o,
196
+ direction: l ? "backward" : "forward",
197
197
  meta: t.options.meta
198
198
  };
199
- Q(v);
200
- const _ = await a(
199
+ p(v);
200
+ const B = await Q(
201
201
  v
202
- ), { maxPages: w } = t.options, E = p ? K : B;
202
+ ), { maxPages: w } = t.options, E = l ? j : V;
203
203
  return {
204
- pages: E(o.pages, _, w),
205
- pageParams: E(o.pageParams, l, w)
204
+ pages: E(n.pages, B, w),
205
+ pageParams: E(n.pageParams, o, w)
206
206
  };
207
207
  };
208
- if (n && i.length) {
209
- const o = n === "backward", l = o ? se : N, p = {
210
- pages: i,
211
- pageParams: f
212
- }, v = l(r, p);
213
- c = await m(p, v, o);
208
+ if (i && a.length) {
209
+ const n = i === "backward", o = n ? ne : K, l = {
210
+ pages: a,
211
+ pageParams: d
212
+ }, v = o(r, l);
213
+ c = await P(l, v, n);
214
214
  } else {
215
- const o = e ?? i.length;
215
+ const n = e ?? a.length;
216
216
  do {
217
- const l = d === 0 ? f[0] ?? r.initialPageParam : N(r, c);
218
- if (d > 0 && l == null)
217
+ const o = y === 0 ? d[0] ?? r.initialPageParam : K(r, c);
218
+ if (y > 0 && o == null)
219
219
  break;
220
- c = await m(c, l), d++;
221
- } while (d < o);
220
+ c = await P(c, o), y++;
221
+ } while (y < n);
222
222
  }
223
223
  return c;
224
224
  };
225
225
  t.options.persister ? t.fetchFn = () => t.options.persister?.(
226
- P,
226
+ m,
227
227
  {
228
228
  client: t.client,
229
229
  queryKey: t.queryKey,
@@ -231,11 +231,11 @@ function C(e) {
231
231
  signal: t.signal
232
232
  },
233
233
  s
234
- ) : t.fetchFn = P;
234
+ ) : t.fetchFn = m;
235
235
  }
236
236
  };
237
237
  }
238
- function N(e, { pages: t, pageParams: s }) {
238
+ function K(e, { pages: t, pageParams: s }) {
239
239
  const r = t.length - 1;
240
240
  return t.length > 0 ? e.getNextPageParam(
241
241
  t[r],
@@ -244,10 +244,10 @@ function N(e, { pages: t, pageParams: s }) {
244
244
  s
245
245
  ) : void 0;
246
246
  }
247
- function se(e, { pages: t, pageParams: s }) {
247
+ function ne(e, { pages: t, pageParams: s }) {
248
248
  return t.length > 0 ? e.getPreviousPageParam?.(t[0], t, s[0], s) : void 0;
249
249
  }
250
- var re = class {
250
+ var ie = class {
251
251
  #e;
252
252
  #t;
253
253
  #s;
@@ -257,12 +257,12 @@ var re = class {
257
257
  #a;
258
258
  #u;
259
259
  constructor(e = {}) {
260
- this.#e = e.queryCache || new ee(), this.#t = e.mutationCache || new te(), this.#s = e.defaultOptions || {}, this.#n = /* @__PURE__ */ new Map(), this.#i = /* @__PURE__ */ new Map(), this.#r = 0;
260
+ this.#e = e.queryCache || new se(), this.#t = e.mutationCache || new re(), this.#s = e.defaultOptions || {}, this.#n = /* @__PURE__ */ new Map(), this.#i = /* @__PURE__ */ new Map(), this.#r = 0;
261
261
  }
262
262
  mount() {
263
- this.#r++, this.#r === 1 && (this.#a = j.subscribe(async (e) => {
263
+ this.#r++, this.#r === 1 && (this.#a = L.subscribe(async (e) => {
264
264
  e && (await this.resumePausedMutations(), this.#e.onFocus());
265
- }), this.#u = D.subscribe(async (e) => {
265
+ }), this.#u = A.subscribe(async (e) => {
266
266
  e && (await this.resumePausedMutations(), this.#e.onOnline());
267
267
  }));
268
268
  }
@@ -290,11 +290,11 @@ var re = class {
290
290
  });
291
291
  }
292
292
  setQueryData(e, t, s) {
293
- const r = this.defaultQueryOptions({ queryKey: e }), i = this.#e.get(
293
+ const r = this.defaultQueryOptions({ queryKey: e }), a = this.#e.get(
294
294
  r.queryHash
295
- )?.state.data, f = L(t, i);
296
- if (f !== void 0)
297
- return this.#e.build(this, r).setData(f, { ...s, manual: !0 });
295
+ )?.state.data, d = W(t, a);
296
+ if (d !== void 0)
297
+ return this.#e.build(this, r).setData(d, { ...s, manual: !0 });
298
298
  }
299
299
  setQueriesData(e, t, s) {
300
300
  return u.batch(
@@ -332,7 +332,7 @@ var re = class {
332
332
  }
333
333
  cancelQueries(e, t = {}) {
334
334
  const s = { revert: !0, ...t }, r = u.batch(
335
- () => this.#e.findAll(e).map((n) => n.cancel(s))
335
+ () => this.#e.findAll(e).map((i) => i.cancel(s))
336
336
  );
337
337
  return Promise.all(r).then(h).catch(h);
338
338
  }
@@ -352,9 +352,9 @@ var re = class {
352
352
  ...t,
353
353
  cancelRefetch: t.cancelRefetch ?? !0
354
354
  }, r = u.batch(
355
- () => this.#e.findAll(e).filter((n) => !n.isDisabled()).map((n) => {
356
- let i = n.fetch(void 0, s);
357
- return s.throwOnError || (i = i.catch(h)), n.state.fetchStatus === "paused" ? Promise.resolve() : i;
355
+ () => this.#e.findAll(e).filter((i) => !i.isDisabled()).map((i) => {
356
+ let a = i.fetch(void 0, s);
357
+ return s.throwOnError || (a = a.catch(h)), i.state.fetchStatus === "paused" ? Promise.resolve() : a;
358
358
  })
359
359
  );
360
360
  return Promise.all(r).then(h);
@@ -371,16 +371,16 @@ var re = class {
371
371
  return this.fetchQuery(e).then(h).catch(h);
372
372
  }
373
373
  fetchInfiniteQuery(e) {
374
- return e.behavior = C(e.pages), this.fetchQuery(e);
374
+ return e.behavior = I(e.pages), this.fetchQuery(e);
375
375
  }
376
376
  prefetchInfiniteQuery(e) {
377
377
  return this.fetchInfiniteQuery(e).then(h).catch(h);
378
378
  }
379
379
  ensureInfiniteQueryData(e) {
380
- return e.behavior = C(e.pages), this.ensureQueryData(e);
380
+ return e.behavior = I(e.pages), this.ensureQueryData(e);
381
381
  }
382
382
  resumePausedMutations() {
383
- return D.isOnline() ? this.#t.resumePausedMutations() : Promise.resolve();
383
+ return A.isOnline() ? this.#t.resumePausedMutations() : Promise.resolve();
384
384
  }
385
385
  getQueryCache() {
386
386
  return this.#e;
@@ -395,7 +395,7 @@ var re = class {
395
395
  this.#s = e;
396
396
  }
397
397
  setQueryDefaults(e, t) {
398
- this.#n.set(I(e), {
398
+ this.#n.set(C(e), {
399
399
  queryKey: e,
400
400
  defaultOptions: t
401
401
  });
@@ -407,7 +407,7 @@ var re = class {
407
407
  }), s;
408
408
  }
409
409
  setMutationDefaults(e, t) {
410
- this.#i.set(I(e), {
410
+ this.#i.set(C(e), {
411
411
  mutationKey: e,
412
412
  defaultOptions: t
413
413
  });
@@ -427,10 +427,10 @@ var re = class {
427
427
  ...e,
428
428
  _defaulted: !0
429
429
  };
430
- return t.queryHash || (t.queryHash = k(
430
+ return t.queryHash || (t.queryHash = H(
431
431
  t.queryKey,
432
432
  t
433
- )), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.queryFn === U && (t.enabled = !1), t;
433
+ )), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.queryFn === _ && (t.enabled = !1), t;
434
434
  }
435
435
  defaultMutationOptions(e) {
436
436
  return e?._defaulted ? e : {
@@ -444,7 +444,7 @@ var re = class {
444
444
  this.#e.clear(), this.#t.clear();
445
445
  }
446
446
  };
447
- const ne = new re({
447
+ const ae = new ie({
448
448
  defaultOptions: {
449
449
  mutations: {
450
450
  retry: !1
@@ -458,26 +458,28 @@ const ne = new re({
458
458
  retry: !1
459
459
  }
460
460
  }
461
- }), ie = () => {
462
- const e = M((s) => s.currentNavigationPath), t = J();
461
+ }), ue = () => {
462
+ const e = M((s) => s.currentNavigationPath), t = Z();
463
463
  b(() => {
464
464
  e && t(e, { replace: !0 });
465
465
  }, [e, t]);
466
- }, ae = () => (ie(), /* @__PURE__ */ y(G, {})), Oe = ({
466
+ }, oe = () => (ue(), /* @__PURE__ */ f(X, {})), ve = ({
467
467
  props: e,
468
468
  routes: t,
469
469
  env: s = void 0,
470
470
  useSignalR: r = !1,
471
- queryClient: n = ne
471
+ queryClient: i = ae
472
472
  }) => {
473
- const i = M((a) => a.setBaseProps), f = M((a) => a.modulePermissionToken), c = T((a) => a.setEnvironment), d = T((a) => a.addEnvironment), [P, g] = $(!1);
473
+ const a = M((n) => n.setBaseProps), d = M((n) => n.modulePermissionToken), c = k((n) => n.setEnvironment), y = k((n) => n.addEnvironment), [m, g] = T(!1), [p, Q] = T(null);
474
474
  b(() => {
475
- const a = he();
476
- if (g(!a), a && c(a), !s) return;
477
- const m = s[a?.ENVIRONMENT];
478
- m && d(m);
479
- }, [d, s, c]), b(() => {
480
- g(!ue(e)), i(e);
475
+ const n = x();
476
+ if (g(!n), n && c(n), !s) return;
477
+ const o = ee(n);
478
+ o && Q(o);
479
+ const l = s[n?.ENVIRONMENT];
480
+ l && y(l);
481
+ }, [y, s, c]), b(() => {
482
+ g(!te(e)), a(e);
481
483
  }, [
482
484
  e.currentLanguage,
483
485
  e.currentLanguageId,
@@ -486,26 +488,15 @@ const ne = new re({
486
488
  e.currentNavigationPath,
487
489
  e.sourcePath
488
490
  ]);
489
- const Q = z([
491
+ const P = G([
490
492
  {
491
493
  path: e.basePath,
492
494
  children: t,
493
- element: /* @__PURE__ */ y(ae, {})
495
+ element: /* @__PURE__ */ f(oe, {})
494
496
  }
495
497
  ]);
496
- return P ? /* @__PURE__ */ y("div", { children: "TODO: Show fancy error" }) : f ? /* @__PURE__ */ y(V, { client: n, children: /* @__PURE__ */ y(x, { enabled: r, children: /* @__PURE__ */ y(Y, { router: Q }) }) }) : /* @__PURE__ */ y("div", { children: "TODO: Show fancy Loadingspinner" });
497
- }, ue = (e) => Z.every((t) => oe(t, e)), oe = (e, t) => {
498
- if (!t[e]) {
499
- if (t.throwError)
500
- return t.throwError(`Missing required prop: ${e}`, 404), !1;
501
- throw new Error(`Missing required prop: ${e}`);
502
- }
503
- return !0;
504
- }, he = () => {
505
- const e = window.__env__;
506
- if (e && (e.API_PREFIX = "/api/v8.0", !!e.COMMON_API && e.MODULE_AUTH_API && e.API_PREFIX && e.ENVIRONMENT))
507
- return e;
498
+ return m ? /* @__PURE__ */ f("div", { children: "TODO: Show fancy Error" }) : p ? /* @__PURE__ */ f("div", { children: p }) : d ? /* @__PURE__ */ f(U, { client: i, children: /* @__PURE__ */ f($, { enabled: r, children: /* @__PURE__ */ f(J, { router: P }) }) }) : /* @__PURE__ */ f("div", { children: "TODO: Show fancy Loadingspinner" });
508
499
  };
509
500
  export {
510
- Oe as ModuleBase
501
+ ve as ModuleBase
511
502
  };
@@ -1,17 +1,25 @@
1
- import { u } from "../useMutation-3rykrmeD.js";
2
- import { useBasePropsStore as t } from "../stores/BasePropsStore.js";
3
- const f = ({
1
+ import { u as n } from "../useMutation-3rykrmeD.js";
2
+ import { useBasePropsStore as r } from "../stores/BasePropsStore.js";
3
+ const a = ({
4
4
  authenticationKey: i,
5
- queue: e,
6
- topic: s
5
+ queue: s,
6
+ topic: o
7
7
  }) => {
8
- const r = t((o) => o.serviceBusNotification), n = t((o) => o.throwError);
9
- if (!r)
10
- throw n?.("serviceBusNotification is not defined", 400);
11
- return u({
12
- mutationFn: (o) => r(o, i, e, s)
8
+ const e = r((t) => t.serviceBusNotification), c = r((t) => t.throwError);
9
+ if (!e)
10
+ throw c?.("serviceBusNotification is not defined", 400);
11
+ return n({
12
+ mutationFn: (t) => e(t, i, s, o)
13
+ });
14
+ }, N = () => {
15
+ const i = r((o) => o.riseNotification), s = r((o) => o.throwError);
16
+ if (!i)
17
+ throw s?.("riseNotification is not defined", 400);
18
+ return n({
19
+ mutationFn: (o) => i(o)
13
20
  });
14
21
  };
15
22
  export {
16
- f as useServiceBus
23
+ N as useNotification,
24
+ a as useServiceBus
17
25
  };
@@ -1,15 +1,19 @@
1
1
  import { UseMutationResult } from '@tanstack/react-query';
2
- import { AlertServiceBusMessage } from '../types/ServiceBus';
3
2
  import { BaseResponse } from '../types/Requests';
3
+ import { AlertServiceBusMessage } from '../types/ServiceBus';
4
4
  /**
5
5
  *
6
6
  * @param authenticationKey SASToken, that will be provided by the vendor portal of HortiView
7
7
  * @param queue url of the service bus queue
8
8
  * @param topic topic of the service bus, where the message will be sent to
9
- * @returns
9
+ * @deprecated use useNotification instead
10
10
  */
11
11
  export declare const useServiceBus: ({ authenticationKey, queue, topic, }: {
12
12
  authenticationKey: string;
13
13
  queue: string;
14
14
  topic: string;
15
15
  }) => UseMutationResult<BaseResponse<unknown>, Error, AlertServiceBusMessage, unknown>;
16
+ /**
17
+ * create a notification in the service bus
18
+ */
19
+ export declare const useNotification: () => UseMutationResult<BaseResponse<unknown>, Error, AlertServiceBusMessage, unknown>;
@@ -9,7 +9,7 @@ export declare const useBaseProps: () => Pick<import('../types/Deprecated').Depr
9
9
  currentLanguageId?: string;
10
10
  alertRules?: string;
11
11
  commonOptions?: import('../types/CommonOptions').AllDropdownsData<import('../types/CommonOptions').CommonOption>["items"];
12
- serviceBusNotification?: (message: import('../types/ServiceBus').AlertServiceBusMessage, apiKey: string, queue: string, topic: string) => Promise<unknown>;
12
+ riseNotification?: (message: import('../types/ServiceBus').AlertServiceBusMessage) => Promise<unknown>;
13
13
  navigateInHortiview?: (path: string) => void;
14
14
  addBreadcrumbTranslation?: (translation: {
15
15
  key: string;
@@ -22,7 +22,7 @@ export declare const useBaseProps: () => Pick<import('../types/Deprecated').Depr
22
22
  throwError?: (message: string, code: number) => void;
23
23
  } & {
24
24
  setBaseProps: (props: import('../main').BaseProps) => void;
25
- }, keyof import('../types/Deprecated').DeprecatedBaseProps | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "alertRules" | "commonOptions" | "serviceBusNotification" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "logEvent" | "logError" | "throwError">;
25
+ }, keyof import('../types/Deprecated').DeprecatedBaseProps | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "alertRules" | "commonOptions" | "riseNotification" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "logEvent" | "logError" | "throwError">;
26
26
  export declare const useConfig: () => Pick<{
27
27
  environment: import('../types/Environment').HortiViewEnvironments;
28
28
  setEnvironment: (environment: import('../types/Environment').HortiViewEnvironments) => void;
@@ -9,5 +9,5 @@ export { useCustom } from './hooks/useCustom';
9
9
  export { useEntity } from './hooks/useEntity';
10
10
  export { useOption } from './hooks/useOption';
11
11
  export { useCustomMutation } from './hooks/useCustomMutation';
12
- export { useServiceBus } from './hooks/useServiceBus';
12
+ export { useServiceBus, useNotification } from './hooks/useServiceBus';
13
13
  export { mutateOnCustomApi } from './utils/fetches';
@@ -26,8 +26,7 @@ export type BaseProps = DeprecatedBaseProps & {
26
26
  currentLanguageId?: string;
27
27
  alertRules?: string;
28
28
  commonOptions?: AllDropdownsData<CommonOption>['items'];
29
- serviceBusNotification?: (message: AlertServiceBusMessage, //currently only used for alerts
30
- apiKey: string, queue: string, topic: string) => Promise<unknown>;
29
+ riseNotification?: (message: AlertServiceBusMessage) => Promise<unknown>;
31
30
  navigateInHortiview?: (path: string) => void;
32
31
  addBreadcrumbTranslation?: (translation: {
33
32
  key: string;
@@ -1,3 +1,4 @@
1
+ import { AlertServiceBusMessage } from './ServiceBus';
1
2
  import { SystemMessage } from './SystemMessage';
2
3
  /**
3
4
  * @deprecated should not be used anymore, will be removed in the near future (max 2 months)
@@ -21,6 +22,11 @@ export type DeprecatedBaseProps = {
21
22
  * @deprecated
22
23
  */
23
24
  addNotification?: (notification: OldAlertDto) => void;
25
+ /**
26
+ * @deprecated use `riseNotification` instead
27
+ */
28
+ serviceBusNotification?: (message: AlertServiceBusMessage, //currently only used for alerts
29
+ apiKey: string, queue: string, topic: string) => Promise<unknown>;
24
30
  /**
25
31
  * @deprecated Use `showMessage` instead
26
32
  */
@@ -3,6 +3,7 @@ export interface HortiViewEnvironments {
3
3
  MODULE_AUTH_API: string;
4
4
  API_PREFIX: string;
5
5
  ENVIRONMENT: string;
6
+ REQ_VERSION: string;
6
7
  [customkey: string]: string;
7
8
  }
8
9
  export interface CustomWindow extends Window {
@@ -0,0 +1,20 @@
1
+ import { BaseProps } from '../main';
2
+ import { HortiViewEnvironments } from '../types/Environment';
3
+ /**
4
+ * Validates the props and checks if the required props are set
5
+ * @param props props to be validated
6
+ * @param requiredProps props that will be validated/checked if they exist
7
+ */
8
+ export declare const arePropsValid: (props: BaseProps) => boolean;
9
+ /**
10
+ * Checks if a prop exists and throws an error if it does not
11
+ * @param prop prop to be checked
12
+ * @param props props to be checked against
13
+ */
14
+ export declare const checkIfPropExists: (prop: keyof BaseProps, props: BaseProps) => boolean;
15
+ /**
16
+ * check if hortiview return the __env__ object correctly
17
+ * @returns the environment variables from the window object
18
+ */
19
+ export declare const getEnvironmentVariables: () => HortiViewEnvironments | undefined;
20
+ export declare const checkVersion: (environmentVariables?: HortiViewEnvironments) => string | null;
package/dist/main.js CHANGED
@@ -4,133 +4,134 @@ import { useSignalRMessages as u } from "./hooks/useSignalRMessages.js";
4
4
  import { useNavigate as n } from "./module-router.js";
5
5
  import { useBaseProps as S, useConfig as R } from "./hooks/useStores.js";
6
6
  import { useCustom as E } from "./hooks/useCustom.js";
7
- import { useEntity as l } from "./hooks/useEntity.js";
7
+ import { useEntity as N } from "./hooks/useEntity.js";
8
8
  import { useOption as A } from "./hooks/useOption.js";
9
9
  import { useCustomMutation as d } from "./hooks/useCustomMutation.js";
10
- import { useServiceBus as h } from "./hooks/useServiceBus.js";
11
- import { mutateOnCustomApi as x } from "./utils/fetches.js";
12
- import { A as g, B as v, F as P, H as f, I as y, a as L, b as k, L as D, c as H, M, d as B, N as O, e as b, f as T, O as w, P as I, R as V, g as q, h as z, i as G, S as K, j as W, k as j, l as J, m as Q, D as X, n as Y, E as Z, o as $, p as aa, q as ea, r as sa, s as ta, t as ra, u as oa, v as ua, V as ia, w as na, x as ca, y as Sa, z as Ra, C as ma, G as Ea, J as Fa, K as la, Q as Na, T as Aa, U as _a, W as da, X as pa, Y as ha, Z as Ua, _ as xa, $ as Ca, a0 as ga, a1 as va, a2 as Pa, a3 as fa, a4 as ya, a5 as La, a6 as ka, a7 as Da, a8 as Ha, a9 as Ma, aa as Ba, ab as Oa, ac as ba, ad as Ta, ae as wa, af as Ia, ag as Va, ah as qa, ai as za, aj as Ga, ak as Ka, al as Wa, am as ja, an as Ja, ao as Qa, ap as Xa, aq as Ya, ar as Za, as as $a, at as ae, au as ee, av as se, aw as te, ax as re, ay as oe, az as ue, aA as ie, aB as ne, aC as ce, aD as Se, aE as Re, aF as me, aG as Ee, aH as Fe, aI as le, aJ as Ne, aK as Ae, aL as _e, aM as de, aN as pe, aO as he, aP as Ue, aQ as xe, aR as Ce, aS as ge, aT as ve } from "./chunk-IR6S3I6Y-BmDdD3SP.js";
10
+ import { useNotification as h, useServiceBus as U } from "./hooks/useServiceBus.js";
11
+ import { mutateOnCustomApi as C } from "./utils/fetches.js";
12
+ import { A as v, B as f, F as P, H as y, I as L, a as k, b as D, L as H, c as M, M as B, d as O, N as b, e as T, f as w, O as I, P as V, R as q, g as z, h as G, i as K, S as W, j, k as J, l as Q, m as X, D as Y, n as Z, E as $, o as aa, p as ea, q as sa, r as ta, s as ra, t as oa, u as ua, v as ia, V as na, w as ca, x as Sa, y as Ra, z as ma, C as Ea, G as Fa, J as Na, K as la, Q as Aa, T as _a, U as da, W as pa, X as ha, Y as Ua, Z as xa, _ as Ca, $ as ga, a0 as va, a1 as fa, a2 as Pa, a3 as ya, a4 as La, a5 as ka, a6 as Da, a7 as Ha, a8 as Ma, a9 as Ba, aa as Oa, ab as ba, ac as Ta, ad as wa, ae as Ia, af as Va, ag as qa, ah as za, ai as Ga, aj as Ka, ak as Wa, al as ja, am as Ja, an as Qa, ao as Xa, ap as Ya, aq as Za, ar as $a, as as ae, at as ee, au as se, av as te, aw as re, ax as oe, ay as ue, az as ie, aA as ne, aB as ce, aC as Se, aD as Re, aE as me, aF as Ee, aG as Fe, aH as Ne, aI as le, aJ as Ae, aK as _e, aL as de, aM as pe, aN as he, aO as Ue, aP as xe, aQ as Ce, aR as ge, aS as ve, aT as fe } from "./chunk-IR6S3I6Y-BmDdD3SP.js";
13
13
  export {
14
- g as Await,
15
- v as BrowserRouter,
14
+ v as Await,
15
+ f as BrowserRouter,
16
16
  P as Form,
17
- f as HashRouter,
18
- y as IDLE_BLOCKER,
19
- L as IDLE_FETCHER,
20
- k as IDLE_NAVIGATION,
21
- D as Link,
22
- H as Links,
23
- M as MemoryRouter,
24
- B as Meta,
17
+ y as HashRouter,
18
+ L as IDLE_BLOCKER,
19
+ k as IDLE_FETCHER,
20
+ D as IDLE_NAVIGATION,
21
+ H as Link,
22
+ M as Links,
23
+ B as MemoryRouter,
24
+ O as Meta,
25
25
  s as ModuleBase,
26
- O as NavLink,
27
- b as Navigate,
28
- T as NavigationType,
29
- w as Outlet,
30
- I as PrefetchPageLinks,
31
- V as Route,
32
- q as Router,
33
- z as RouterProvider,
34
- G as Routes,
35
- K as Scripts,
36
- W as ScrollRestoration,
37
- j as ServerRouter,
38
- J as StaticRouter,
39
- Q as StaticRouterProvider,
40
- X as UNSAFE_DataRouterContext,
41
- Y as UNSAFE_DataRouterStateContext,
42
- Z as UNSAFE_ErrorResponseImpl,
43
- $ as UNSAFE_FetchersContext,
44
- aa as UNSAFE_FrameworkContext,
45
- ea as UNSAFE_LocationContext,
46
- sa as UNSAFE_NavigationContext,
47
- ta as UNSAFE_RemixErrorBoundary,
48
- ra as UNSAFE_RouteContext,
49
- oa as UNSAFE_ServerMode,
50
- ua as UNSAFE_SingleFetchRedirectSymbol,
51
- ia as UNSAFE_ViewTransitionContext,
52
- na as UNSAFE_createBrowserHistory,
53
- ca as UNSAFE_createClientRoutes,
54
- Sa as UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
55
- Ra as UNSAFE_createRouter,
56
- ma as UNSAFE_decodeViaTurboStream,
57
- Ea as UNSAFE_deserializeErrors,
58
- Fa as UNSAFE_getPatchRoutesOnNavigationFunction,
26
+ b as NavLink,
27
+ T as Navigate,
28
+ w as NavigationType,
29
+ I as Outlet,
30
+ V as PrefetchPageLinks,
31
+ q as Route,
32
+ z as Router,
33
+ G as RouterProvider,
34
+ K as Routes,
35
+ W as Scripts,
36
+ j as ScrollRestoration,
37
+ J as ServerRouter,
38
+ Q as StaticRouter,
39
+ X as StaticRouterProvider,
40
+ Y as UNSAFE_DataRouterContext,
41
+ Z as UNSAFE_DataRouterStateContext,
42
+ $ as UNSAFE_ErrorResponseImpl,
43
+ aa as UNSAFE_FetchersContext,
44
+ ea as UNSAFE_FrameworkContext,
45
+ sa as UNSAFE_LocationContext,
46
+ ta as UNSAFE_NavigationContext,
47
+ ra as UNSAFE_RemixErrorBoundary,
48
+ oa as UNSAFE_RouteContext,
49
+ ua as UNSAFE_ServerMode,
50
+ ia as UNSAFE_SingleFetchRedirectSymbol,
51
+ na as UNSAFE_ViewTransitionContext,
52
+ ca as UNSAFE_createBrowserHistory,
53
+ Sa as UNSAFE_createClientRoutes,
54
+ Ra as UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
55
+ ma as UNSAFE_createRouter,
56
+ Ea as UNSAFE_decodeViaTurboStream,
57
+ Fa as UNSAFE_deserializeErrors,
58
+ Na as UNSAFE_getPatchRoutesOnNavigationFunction,
59
59
  la as UNSAFE_getSingleFetchDataStrategy,
60
- Na as UNSAFE_invariant,
61
- Aa as UNSAFE_mapRouteProperties,
62
- _a as UNSAFE_shouldHydrateRouteLoader,
63
- da as UNSAFE_useFogOFWarDiscovery,
64
- pa as UNSAFE_useScrollRestoration,
65
- ha as createBrowserRouter,
66
- Ua as createCookie,
67
- xa as createCookieSessionStorage,
68
- Ca as createHashRouter,
69
- ga as createMemoryRouter,
70
- va as createMemorySessionStorage,
60
+ Aa as UNSAFE_invariant,
61
+ _a as UNSAFE_mapRouteProperties,
62
+ da as UNSAFE_shouldHydrateRouteLoader,
63
+ pa as UNSAFE_useFogOFWarDiscovery,
64
+ ha as UNSAFE_useScrollRestoration,
65
+ Ua as createBrowserRouter,
66
+ xa as createCookie,
67
+ Ca as createCookieSessionStorage,
68
+ ga as createHashRouter,
69
+ va as createMemoryRouter,
70
+ fa as createMemorySessionStorage,
71
71
  Pa as createPath,
72
- fa as createRequestHandler,
73
- ya as createRoutesFromChildren,
74
- La as createRoutesFromElements,
75
- ka as createRoutesStub,
76
- Da as createSearchParams,
77
- Ha as createSession,
78
- Ma as createSessionStorage,
79
- Ba as createStaticHandler,
80
- Oa as createStaticRouter,
81
- ba as data,
82
- Ta as generatePath,
83
- wa as isCookie,
84
- Ia as isRouteErrorResponse,
85
- Va as isSession,
86
- qa as matchPath,
87
- za as matchRoutes,
88
- x as mutateOnCustomApi,
89
- Ga as parsePath,
90
- Ka as redirect,
91
- Wa as redirectDocument,
92
- ja as renderMatches,
93
- Ja as replace,
94
- Qa as resolvePath,
95
- Xa as unstable_HistoryRouter,
96
- Ya as unstable_setDevServerHooks,
97
- Za as unstable_usePrompt,
98
- $a as useActionData,
99
- ae as useAsyncError,
100
- ee as useAsyncValue,
72
+ ya as createRequestHandler,
73
+ La as createRoutesFromChildren,
74
+ ka as createRoutesFromElements,
75
+ Da as createRoutesStub,
76
+ Ha as createSearchParams,
77
+ Ma as createSession,
78
+ Ba as createSessionStorage,
79
+ Oa as createStaticHandler,
80
+ ba as createStaticRouter,
81
+ Ta as data,
82
+ wa as generatePath,
83
+ Ia as isCookie,
84
+ Va as isRouteErrorResponse,
85
+ qa as isSession,
86
+ za as matchPath,
87
+ Ga as matchRoutes,
88
+ C as mutateOnCustomApi,
89
+ Ka as parsePath,
90
+ Wa as redirect,
91
+ ja as redirectDocument,
92
+ Ja as renderMatches,
93
+ Qa as replace,
94
+ Xa as resolvePath,
95
+ Ya as unstable_HistoryRouter,
96
+ Za as unstable_setDevServerHooks,
97
+ $a as unstable_usePrompt,
98
+ ae as useActionData,
99
+ ee as useAsyncError,
100
+ se as useAsyncValue,
101
101
  S as useBaseProps,
102
- se as useBeforeUnload,
103
- te as useBlocker,
102
+ te as useBeforeUnload,
103
+ re as useBlocker,
104
104
  r as useBreadcrumbTranslation,
105
105
  R as useConfig,
106
106
  E as useCustom,
107
107
  d as useCustomMutation,
108
- l as useEntity,
109
- re as useFetcher,
110
- oe as useFetchers,
111
- ue as useFormAction,
112
- ie as useHref,
113
- ne as useInRouterContext,
114
- ce as useLinkClickHandler,
115
- Se as useLoaderData,
116
- Re as useLocation,
117
- me as useMatch,
118
- Ee as useMatches,
108
+ N as useEntity,
109
+ oe as useFetcher,
110
+ ue as useFetchers,
111
+ ie as useFormAction,
112
+ ne as useHref,
113
+ ce as useInRouterContext,
114
+ Se as useLinkClickHandler,
115
+ Re as useLoaderData,
116
+ me as useLocation,
117
+ Ee as useMatch,
118
+ Fe as useMatches,
119
119
  n as useNavigate,
120
- Fe as useNavigation,
120
+ Ne as useNavigation,
121
121
  le as useNavigationType,
122
+ h as useNotification,
122
123
  A as useOption,
123
- Ne as useOutlet,
124
- Ae as useOutletContext,
125
- _e as useParams,
126
- de as useResolvedPath,
127
- pe as useRevalidator,
128
- he as useRouteError,
129
- Ue as useRouteLoaderData,
130
- xe as useRoutes,
131
- Ce as useSearchParams,
132
- h as useServiceBus,
124
+ Ae as useOutlet,
125
+ _e as useOutletContext,
126
+ de as useParams,
127
+ pe as useResolvedPath,
128
+ he as useRevalidator,
129
+ Ue as useRouteError,
130
+ xe as useRouteLoaderData,
131
+ Ce as useRoutes,
132
+ ge as useSearchParams,
133
+ U as useServiceBus,
133
134
  u as useSignalRMessages,
134
- ge as useSubmit,
135
- ve as useViewTransitionState
135
+ ve as useSubmit,
136
+ fe as useViewTransitionState
136
137
  };
@@ -1,8 +1,9 @@
1
1
  import { c as r } from "../react-QiIgv49H.js";
2
- const m = r((e) => ({
2
+ const E = r((e) => ({
3
3
  environment: {
4
4
  ENVIRONMENT: "DEV",
5
5
  COMMON_API: "",
6
+ REQ_VERSION: "",
6
7
  MODULE_AUTH_API: "",
7
8
  API_PREFIX: ""
8
9
  },
@@ -10,5 +11,5 @@ const m = r((e) => ({
10
11
  addEnvironment: (n) => e((o) => ({ environment: { ...n, ...o.environment } }))
11
12
  }));
12
13
  export {
13
- m as useEnvironmentStore
14
+ E as useEnvironmentStore
14
15
  };
@@ -0,0 +1,48 @@
1
+ import { REQUIRED_PROPS as p } from "../constants.js";
2
+ const l = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, u = (r) => {
3
+ if (typeof r != "string")
4
+ throw new TypeError("Invalid argument expected string");
5
+ const e = r.match(l);
6
+ if (!e)
7
+ throw new Error(`Invalid argument not valid semver ('${r}' received)`);
8
+ return e.shift(), e;
9
+ }, c = (r) => r === "*" || r === "x" || r === "X", d = (r) => {
10
+ const e = parseInt(r, 10);
11
+ return isNaN(e) ? r : e;
12
+ }, E = (r, e) => typeof r != typeof e ? [String(r), String(e)] : [r, e], h = (r, e) => {
13
+ if (c(r) || c(e))
14
+ return 0;
15
+ const [t, n] = E(d(r), d(e));
16
+ return t > n ? 1 : t < n ? -1 : 0;
17
+ }, a = (r, e) => {
18
+ for (let t = 0; t < Math.max(r.length, e.length); t++) {
19
+ const n = h(r[t] || "0", e[t] || "0");
20
+ if (n !== 0)
21
+ return n;
22
+ }
23
+ return 0;
24
+ }, m = (r, e) => {
25
+ const t = u(r), n = u(e), i = t.pop(), o = n.pop(), s = a(t, n);
26
+ return s !== 0 ? s : i && o ? a(i.split("."), o.split(".")) : i || o ? i ? -1 : 1 : 0;
27
+ }, f = "0.0.13318", v = (r) => p.every((e) => I(e, r)), I = (r, e) => {
28
+ if (!e[r]) {
29
+ if (e.throwError)
30
+ return e.throwError(`Missing required prop: ${r}`, 404), !1;
31
+ throw new Error(`Missing required prop: ${r}`);
32
+ }
33
+ return !0;
34
+ }, w = () => {
35
+ const r = window.__env__;
36
+ if (r && (r.API_PREFIX = "/api/v8.0", !!r.COMMON_API && r.MODULE_AUTH_API && r.API_PREFIX && r.ENVIRONMENT))
37
+ return r;
38
+ }, P = (r) => {
39
+ if (!r?.REQ_VERSION) return null;
40
+ const e = r.REQ_VERSION;
41
+ return m(f, e) < 0 ? `ModuleBase version ${f} is probably not compatible with the current HortiView version ${e}. Please update the modulebase to be at least ${e}` : null;
42
+ };
43
+ export {
44
+ v as arePropsValid,
45
+ I as checkIfPropExists,
46
+ P as checkVersion,
47
+ w as getEnvironmentVariables
48
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hortiview/modulebase",
3
3
  "description": "This is a base module for hortiview",
4
- "version": "0.0.13075",
4
+ "version": "0.0.13318",
5
5
  "type": "module",
6
6
  "author": "Falk Menge <falk.menge.ext@bayer.com>",
7
7
  "contributors": [
@@ -9,7 +9,7 @@
9
9
  ],
10
10
  "license": "GPL-3.0",
11
11
  "main": "dist/main.js",
12
- "types": "dist/main.d.ts",
12
+ "types": "dist/lib/main.d.ts",
13
13
  "files": [
14
14
  "dist"
15
15
  ],
@@ -25,6 +25,7 @@
25
25
  "dependencies": {
26
26
  "@microsoft/signalr": "^8.0.7",
27
27
  "@tanstack/react-query": "^5.67.3",
28
+ "compare-versions": "^6.1.1",
28
29
  "lodash": "^4.17.21",
29
30
  "odata-query": "^7.0.9",
30
31
  "react": "^18.3.1",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes