@hortiview/modulebase 0.0.13075 → 0.0.13179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ModuleBase.js +88 -97
- package/dist/{types → lib/types}/Environment.d.ts +1 -0
- package/dist/lib/utils/helper.d.ts +20 -0
- package/dist/stores/EnvironmentStore.js +3 -2
- package/dist/utils/helper.js +48 -0
- package/package.json +2 -1
- /package/dist/{components → lib/components}/ModuleBase.d.ts +0 -0
- /package/dist/{constants.d.ts → lib/constants.d.ts} +0 -0
- /package/dist/{hooks → lib/hooks}/useBreadcrumbTranslation.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useCustom.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useCustomMutation.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useEntity.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useOption.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useServiceBus.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useSignalRMessages.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useStores.d.ts +0 -0
- /package/dist/{main.d.ts → lib/main.d.ts} +0 -0
- /package/dist/{module-router.d.ts → lib/module-router.d.ts} +0 -0
- /package/dist/{provider → lib/provider}/SignalR/SignalRProvider.d.ts +0 -0
- /package/dist/{provider → lib/provider}/SignalR/signalR.d.ts +0 -0
- /package/dist/{stores → lib/stores}/BasePropsStore.d.ts +0 -0
- /package/dist/{stores → lib/stores}/EnvironmentStore.d.ts +0 -0
- /package/dist/{types → lib/types}/AppInsights.d.ts +0 -0
- /package/dist/{types → lib/types}/BaseProps.d.ts +0 -0
- /package/dist/{types → lib/types}/CommonOptions.d.ts +0 -0
- /package/dist/{types → lib/types}/Deprecated.d.ts +0 -0
- /package/dist/{types → lib/types}/ModuleApi.d.ts +0 -0
- /package/dist/{types → lib/types}/Requests.d.ts +0 -0
- /package/dist/{types → lib/types}/ServiceBus.d.ts +0 -0
- /package/dist/{types → lib/types}/SystemMessage.d.ts +0 -0
- /package/dist/{utils → lib/utils}/api.d.ts +0 -0
- /package/dist/{utils → lib/utils}/baseFetches.d.ts +0 -0
- /package/dist/{utils → lib/utils}/fetches.d.ts +0 -0
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { S as
|
|
3
|
-
import { Q as
|
|
4
|
-
import { M as
|
|
5
|
-
import { useState as
|
|
6
|
-
import { Y as
|
|
7
|
-
import {
|
|
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
|
|
11
|
-
|
|
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,
|
|
18
|
-
let
|
|
19
|
-
return
|
|
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:
|
|
22
|
+
queryHash: i,
|
|
23
23
|
options: e.defaultQueryOptions(t),
|
|
24
24
|
state: s,
|
|
25
25
|
defaultOptions: e.getQueryDefaults(r)
|
|
26
|
-
}), this.add(
|
|
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
|
-
},
|
|
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
|
|
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
|
-
(
|
|
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) =>
|
|
148
|
+
(s) => D(t, s)
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
151
|
findAll(e = {}) {
|
|
152
|
-
return this.getAll().filter((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
|
|
173
|
+
function I(e) {
|
|
174
174
|
return {
|
|
175
175
|
onFetch: (t, s) => {
|
|
176
|
-
const r = t.options,
|
|
177
|
-
let c = { pages: [], pageParams: [] },
|
|
178
|
-
const
|
|
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
|
|
181
|
-
Object.defineProperty(
|
|
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
|
-
},
|
|
187
|
+
}, Q = R(t.options, t.fetchOptions), P = async (n, o, l) => {
|
|
188
188
|
if (g)
|
|
189
189
|
return Promise.reject();
|
|
190
|
-
if (
|
|
191
|
-
return Promise.resolve(
|
|
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:
|
|
196
|
-
direction:
|
|
195
|
+
pageParam: o,
|
|
196
|
+
direction: l ? "backward" : "forward",
|
|
197
197
|
meta: t.options.meta
|
|
198
198
|
};
|
|
199
|
-
|
|
200
|
-
const
|
|
199
|
+
p(v);
|
|
200
|
+
const B = await Q(
|
|
201
201
|
v
|
|
202
|
-
), { maxPages: w } = t.options, E =
|
|
202
|
+
), { maxPages: w } = t.options, E = l ? j : V;
|
|
203
203
|
return {
|
|
204
|
-
pages: E(
|
|
205
|
-
pageParams: E(
|
|
204
|
+
pages: E(n.pages, B, w),
|
|
205
|
+
pageParams: E(n.pageParams, o, w)
|
|
206
206
|
};
|
|
207
207
|
};
|
|
208
|
-
if (
|
|
209
|
-
const
|
|
210
|
-
pages:
|
|
211
|
-
pageParams:
|
|
212
|
-
}, v =
|
|
213
|
-
c = await
|
|
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
|
|
215
|
+
const n = e ?? a.length;
|
|
216
216
|
do {
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
217
|
+
const o = y === 0 ? d[0] ?? r.initialPageParam : K(r, c);
|
|
218
|
+
if (y > 0 && o == null)
|
|
219
219
|
break;
|
|
220
|
-
c = await
|
|
221
|
-
} while (
|
|
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
|
-
|
|
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 =
|
|
234
|
+
) : t.fetchFn = m;
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
263
|
+
this.#r++, this.#r === 1 && (this.#a = L.subscribe(async (e) => {
|
|
264
264
|
e && (await this.resumePausedMutations(), this.#e.onFocus());
|
|
265
|
-
}), this.#u =
|
|
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 }),
|
|
293
|
+
const r = this.defaultQueryOptions({ queryKey: e }), a = this.#e.get(
|
|
294
294
|
r.queryHash
|
|
295
|
-
)?.state.data,
|
|
296
|
-
if (
|
|
297
|
-
return this.#e.build(this, r).setData(
|
|
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((
|
|
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((
|
|
356
|
-
let
|
|
357
|
-
return s.throwOnError || (
|
|
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 =
|
|
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 =
|
|
380
|
+
return e.behavior = I(e.pages), this.ensureQueryData(e);
|
|
381
381
|
}
|
|
382
382
|
resumePausedMutations() {
|
|
383
|
-
return
|
|
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(
|
|
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(
|
|
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 =
|
|
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 ===
|
|
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
|
|
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
|
-
}),
|
|
462
|
-
const e = M((s) => s.currentNavigationPath), t =
|
|
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
|
-
},
|
|
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:
|
|
471
|
+
queryClient: i = ae
|
|
472
472
|
}) => {
|
|
473
|
-
const
|
|
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
|
|
476
|
-
if (g(!
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
|
491
|
+
const P = G([
|
|
490
492
|
{
|
|
491
493
|
path: e.basePath,
|
|
492
494
|
children: t,
|
|
493
|
-
element: /* @__PURE__ */
|
|
495
|
+
element: /* @__PURE__ */ f(oe, {})
|
|
494
496
|
}
|
|
495
497
|
]);
|
|
496
|
-
return
|
|
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
|
-
|
|
501
|
+
ve as ModuleBase
|
|
511
502
|
};
|
|
@@ -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;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { c as r } from "../react-QiIgv49H.js";
|
|
2
|
-
const
|
|
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
|
-
|
|
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.13179", 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.
|
|
4
|
+
"version": "0.0.13179",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Falk Menge <falk.menge.ext@bayer.com>",
|
|
7
7
|
"contributors": [
|
|
@@ -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
|
|
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
|