@hortiview/modulebase 0.0.1-7.1-beta

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 (85) hide show
  1. package/README.md +8 -0
  2. package/dist/ModuleCore-YCIFN_02.js +14973 -0
  3. package/dist/QueryClientProvider-Beog9TR7.js +437 -0
  4. package/dist/_baseGet-C6jMXSsQ.js +805 -0
  5. package/dist/_commonjsHelpers-BkfeUUK-.js +28 -0
  6. package/dist/api-s6E2GJtu.js +458 -0
  7. package/dist/assets/ModuleCore.css +1 -0
  8. package/dist/chunk-IR6S3I6Y-BmDdD3SP.js +8162 -0
  9. package/dist/components/ModuleBase.js +30 -0
  10. package/dist/components/ModuleCore.js +10 -0
  11. package/dist/constants.js +34 -0
  12. package/dist/hooks/useBreadcrumbTranslation.js +23 -0
  13. package/dist/hooks/useCustom.js +19 -0
  14. package/dist/hooks/useCustomMutation.js +23 -0
  15. package/dist/hooks/useEntity.js +57 -0
  16. package/dist/hooks/useOffline.js +45 -0
  17. package/dist/hooks/useOption.js +25 -0
  18. package/dist/hooks/useServiceBus.js +25 -0
  19. package/dist/hooks/useSignalRMessages.js +13 -0
  20. package/dist/hooks/useStores.js +14 -0
  21. package/dist/isRestoring-CLuxJVSA.js +281 -0
  22. package/dist/lib/components/ModuleBase.d.ts +36 -0
  23. package/dist/lib/components/ModuleCore.d.ts +32 -0
  24. package/dist/lib/constants.d.ts +25 -0
  25. package/dist/lib/hooks/useBreadcrumbTranslation.d.ts +1 -0
  26. package/dist/lib/hooks/useCustom.d.ts +8 -0
  27. package/dist/lib/hooks/useCustomMutation.d.ts +9 -0
  28. package/dist/lib/hooks/useEntity.d.ts +162 -0
  29. package/dist/lib/hooks/useOffline.d.ts +15 -0
  30. package/dist/lib/hooks/useOption.d.ts +17 -0
  31. package/dist/lib/hooks/useServiceBus.d.ts +19 -0
  32. package/dist/lib/hooks/useSignalRMessages.d.ts +6 -0
  33. package/dist/lib/hooks/useStores.d.ts +37 -0
  34. package/dist/lib/main.d.ts +27 -0
  35. package/dist/lib/module-router.d.ts +7 -0
  36. package/dist/lib/provider/SignalR/SignalRProvider.d.ts +13 -0
  37. package/dist/lib/provider/SignalR/signalR.d.ts +53 -0
  38. package/dist/lib/stores/BasePropsStore.d.ts +6 -0
  39. package/dist/lib/stores/EnvironmentStore.d.ts +8 -0
  40. package/dist/lib/types/ActionStorage.d.ts +12 -0
  41. package/dist/lib/types/AppInsights.d.ts +12 -0
  42. package/dist/lib/types/BaseProps.d.ts +49 -0
  43. package/dist/lib/types/CommonOptions.d.ts +61 -0
  44. package/dist/lib/types/Deprecated.d.ts +99 -0
  45. package/dist/lib/types/Entities.d.ts +22 -0
  46. package/dist/lib/types/Environment.d.ts +18 -0
  47. package/dist/lib/types/EnvironmentVariable.d.ts +6 -0
  48. package/dist/lib/types/ModuleApi.d.ts +163 -0
  49. package/dist/lib/types/Requests.d.ts +44 -0
  50. package/dist/lib/types/ServiceBus.d.ts +17 -0
  51. package/dist/lib/types/SystemMessage.d.ts +14 -0
  52. package/dist/lib/utils/api.d.ts +20 -0
  53. package/dist/lib/utils/baseFetches.d.ts +19 -0
  54. package/dist/lib/utils/fetches.d.ts +43 -0
  55. package/dist/lib/utils/helper.d.ts +29 -0
  56. package/dist/main.js +218 -0
  57. package/dist/module-router.js +129 -0
  58. package/dist/mutation-DSKlaYzY.js +192 -0
  59. package/dist/omit-C9Qe80rl.js +835 -0
  60. package/dist/provider/SignalR/SignalRProvider.js +6408 -0
  61. package/dist/provider/SignalR/signalR.js +11 -0
  62. package/dist/react-QiIgv49H.js +27 -0
  63. package/dist/stores/BasePropsStore.js +7 -0
  64. package/dist/stores/EnvironmentStore.js +15 -0
  65. package/dist/types/ActionStorage.js +4 -0
  66. package/dist/types/AppInsights.js +1 -0
  67. package/dist/types/BaseProps.js +1 -0
  68. package/dist/types/CommonOptions.js +4 -0
  69. package/dist/types/Deprecated.js +1 -0
  70. package/dist/types/Entities.js +25 -0
  71. package/dist/types/Environment.js +1 -0
  72. package/dist/types/EnvironmentVariable.js +1 -0
  73. package/dist/types/ModuleApi.js +1 -0
  74. package/dist/types/Requests.js +1 -0
  75. package/dist/types/ServiceBus.js +1 -0
  76. package/dist/types/SystemMessage.js +1 -0
  77. package/dist/useMutation-zu8uxBak.js +97 -0
  78. package/dist/useQuery-Bj9k9zik.js +395 -0
  79. package/dist/utils/api.js +9 -0
  80. package/dist/utils/baseFetches.js +19 -0
  81. package/dist/utils/fetches.js +22 -0
  82. package/dist/utils/helper.js +55 -0
  83. package/dist/utils-DxRR_XLb.js +9 -0
  84. package/dist/vite-env.d.js +1 -0
  85. package/package.json +60 -0
@@ -0,0 +1,30 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { useEffect as s } from "react";
3
+ import { Y as u, h as l, O as c, aU as d } from "../chunk-IR6S3I6Y-BmDdD3SP.js";
4
+ import { SignalRProvider as m } from "../provider/SignalR/SignalRProvider.js";
5
+ import { useBasePropsStore as f } from "../stores/BasePropsStore.js";
6
+ import { M as p, a as h } from "../ModuleCore-YCIFN_02.js";
7
+ const v = () => {
8
+ const e = f((o) => o.currentNavigationPath), t = d();
9
+ s(() => {
10
+ e && t(e, { replace: !0 });
11
+ }, [e, t]);
12
+ }, g = () => (v(), /* @__PURE__ */ r(c, {})), x = ({
13
+ props: e,
14
+ routes: t,
15
+ env: o = void 0,
16
+ useSignalR: a = !1,
17
+ queryClient: i = h
18
+ }) => {
19
+ const n = u([
20
+ {
21
+ path: e.basePath,
22
+ children: t,
23
+ element: /* @__PURE__ */ r(g, {})
24
+ }
25
+ ]);
26
+ return /* @__PURE__ */ r(p, { props: e, env: o, queryClient: i, children: /* @__PURE__ */ r(m, { enabled: a, children: /* @__PURE__ */ r(l, { router: n }) }) });
27
+ };
28
+ export {
29
+ x as ModuleBase
30
+ };
@@ -0,0 +1,10 @@
1
+ import "react/jsx-runtime";
2
+ import { M as a, a as l } from "../ModuleCore-YCIFN_02.js";
3
+ import "react";
4
+ import "../stores/BasePropsStore.js";
5
+ import "../stores/EnvironmentStore.js";
6
+ import "../utils/helper.js";
7
+ export {
8
+ a as ModuleCore,
9
+ l as ModuleQueryClient
10
+ };
@@ -0,0 +1,34 @@
1
+ const a = [
2
+ "addTranslation",
3
+ "navigateTo",
4
+ "modulePermissionToken",
5
+ "organizationId",
6
+ "currentLanguageId",
7
+ "currentNavigationPath"
8
+ ], e = 1, t = {
9
+ /**
10
+ * The server timed out waiting for the request.
11
+ */
12
+ RequestTimeout: 408,
13
+ /**
14
+ * The user has sent too many requests in a given amount of time ("rate limiting").
15
+ */
16
+ TooManyRequests: 429,
17
+ /**
18
+ * The server is not ready to handle the request.
19
+ */
20
+ BadGateway: 502,
21
+ /**
22
+ * The server is not available.
23
+ */
24
+ ServiceUnavailable: 503,
25
+ /**
26
+ * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
27
+ */
28
+ GatewayTimeout: 504
29
+ };
30
+ export {
31
+ a as REQUIRED_PROPS,
32
+ e as RETRIES,
33
+ t as RETRY_HTTP_STATUS_CODES
34
+ };
@@ -0,0 +1,23 @@
1
+ import { useCallback as d } from "react";
2
+ import { useBasePropsStore as s } from "../stores/BasePropsStore.js";
3
+ const u = () => {
4
+ const o = s((a) => a.addBreadcrumbTranslation), t = s((a) => a.addTranslation);
5
+ return d(
6
+ (a, r) => {
7
+ const e = a, n = typeof r == "boolean" ? a : r;
8
+ if (o) {
9
+ o(
10
+ { key: e, value: n },
11
+ //if boolean hide the translation in the breadcrumb
12
+ typeof r == "boolean"
13
+ );
14
+ return;
15
+ }
16
+ t && t({ key: e, value: n }, typeof r == "boolean");
17
+ },
18
+ [o, t]
19
+ );
20
+ };
21
+ export {
22
+ u as useBreadcrumbTranslation
23
+ };
@@ -0,0 +1,19 @@
1
+ import { u as f } from "../useQuery-Bj9k9zik.js";
2
+ import { fetchFromCustomApi as i } from "../utils/fetches.js";
3
+ import { universalSelector as n } from "../utils/helper.js";
4
+ const y = ({
5
+ endpoint: o,
6
+ queryKey: t,
7
+ token: u,
8
+ selector: r,
9
+ enabled: m = !0,
10
+ noAuth: s = !1
11
+ }) => f({
12
+ queryKey: t,
13
+ queryFn: () => i(o, u, s),
14
+ select: (e) => r ? r(e) : n(e),
15
+ enabled: m
16
+ });
17
+ export {
18
+ y as useCustom
19
+ };
@@ -0,0 +1,23 @@
1
+ import { u as n } from "../useMutation-zu8uxBak.js";
2
+ import "react/jsx-runtime";
3
+ import "react";
4
+ import "../provider/SignalR/SignalRProvider.js";
5
+ import "../stores/BasePropsStore.js";
6
+ import "../ModuleCore-YCIFN_02.js";
7
+ import { mutateOnCustomApi as s } from "../utils/fetches.js";
8
+ import "../api-s6E2GJtu.js";
9
+ import "../types/Entities.js";
10
+ import "../omit-C9Qe80rl.js";
11
+ import "../stores/EnvironmentStore.js";
12
+ const d = ({
13
+ endpoint: t,
14
+ method: o,
15
+ token: m,
16
+ headers: r,
17
+ noAuth: i
18
+ }) => n({
19
+ mutationFn: (p, u) => s(u ?? t, p, o, m, r, i)
20
+ });
21
+ export {
22
+ d as useCustomMutation
23
+ };
@@ -0,0 +1,57 @@
1
+ import { u as l } from "../useQuery-Bj9k9zik.js";
2
+ import { useMemo as M, useCallback as g } from "react";
3
+ import { useBasePropsStore as p } from "../stores/BasePropsStore.js";
4
+ import { getModuleDependedEntitiesRaw as Q, getModuleDependedEntities as A, getFarmOrgEntities as D } from "../utils/fetches.js";
5
+ import { getModuleQueryKey as m, universalSelector as y } from "../utils/helper.js";
6
+ import { useOption as E, useModuleDependency as q } from "./useOption.js";
7
+ import { AllEntitiesTypeResultMap as k } from "../types/Entities.js";
8
+ const N = (t, e, u = !0, n = !1) => {
9
+ const a = p((i) => i.moduleId), o = p((i) => i.organizationId), s = t === "ModuleDepended", { getEntityId: d } = K(t), r = F(
10
+ a,
11
+ d(e),
12
+ o,
13
+ s,
14
+ n,
15
+ u
16
+ );
17
+ return M(() => {
18
+ const i = (r.data ?? []).map((c) => {
19
+ const f = k[e];
20
+ return s && n ? c : c[f];
21
+ });
22
+ return {
23
+ ...r,
24
+ data: i
25
+ };
26
+ }, [e, r, s, n]);
27
+ }, F = (t, e, u, n, a, o = !0) => {
28
+ const s = l({
29
+ queryKey: m([e]),
30
+ queryFn: () => a ? Q(t ?? "", e ?? "") : A(t ?? "", e ?? ""),
31
+ enabled: o && n && !!t && !!e && !!u,
32
+ select: (r) => y(r)
33
+ }), d = l({
34
+ queryKey: m([e]),
35
+ queryFn: () => D(t ?? "", e ?? ""),
36
+ enabled: o && !n && !!t && !!e && !!u,
37
+ select: (r) => y(r)
38
+ });
39
+ return n ? s : d;
40
+ }, K = (t) => {
41
+ const { data: e } = E("DataAreaGroup"), { data: u } = E("DataAreaEntity"), { data: n } = q(t === "ModuleDepended");
42
+ return { getEntityId: g(
43
+ (o) => {
44
+ if (t === "ModuleDepended")
45
+ return n ? n.find((r) => r.registeredEntityName === o)?.id : void 0;
46
+ if (!e || !u) return;
47
+ const d = e.find((r) => r.key === t)?.id;
48
+ if (d)
49
+ return u.find((r) => r.description === d && r.value === o)?.id;
50
+ },
51
+ [t, e, u, n]
52
+ ) };
53
+ };
54
+ export {
55
+ N as useEntity,
56
+ K as useEntityId
57
+ };
@@ -0,0 +1,45 @@
1
+ import { u as f } from "../QueryClientProvider-Beog9TR7.js";
2
+ import { fetchFromCustomApi as i, getFarmOrgEntities as c, getModuleDependedEntities as m } from "../utils/fetches.js";
3
+ import { getModuleQueryKey as o } from "../utils/helper.js";
4
+ import { useBasePropsStore as p } from "../stores/BasePropsStore.js";
5
+ import { useEntityId as d } from "./useEntity.js";
6
+ const I = () => {
7
+ const { moduleId: n } = p(), u = f();
8
+ return {
9
+ prefetchCustom: async ({
10
+ queryKey: e,
11
+ endpoint: t,
12
+ token: s,
13
+ noAuth: y = !1
14
+ }) => {
15
+ await u.prefetchQuery({
16
+ queryKey: o(e),
17
+ queryFn: () => i(t, s, y)
18
+ });
19
+ },
20
+ prefetch: ({
21
+ queryKey: e,
22
+ queryFn: t
23
+ }) => u.prefetchQuery({
24
+ queryKey: o(e),
25
+ queryFn: t
26
+ }),
27
+ usePrefetchEntity: (e, ...t) => {
28
+ const { getEntityId: s } = d(e);
29
+ if (!n) return "Prefetch failed: no moduleId";
30
+ t.forEach(async (y) => {
31
+ const r = s(y);
32
+ r && (e !== "ModuleDepended" ? await u.prefetchQuery({
33
+ queryKey: o([r]),
34
+ queryFn: () => c(n, r)
35
+ }) : await u.prefetchQuery({
36
+ queryKey: o([r]),
37
+ queryFn: () => m(n, r)
38
+ }));
39
+ });
40
+ }
41
+ };
42
+ };
43
+ export {
44
+ I as useOffline
45
+ };
@@ -0,0 +1,25 @@
1
+ import { u as m } from "../useQuery-Bj9k9zik.js";
2
+ import { g as u } from "../api-s6E2GJtu.js";
3
+ import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
4
+ import { fetchFromModuleApi as c, fetchFromCommonApi as i } from "../utils/fetches.js";
5
+ import { getModuleQueryKey as p, universalSelector as s } from "../utils/helper.js";
6
+ const q = (o) => {
7
+ const r = n((t) => t.commonOptions), e = u(r, o);
8
+ return m({
9
+ queryKey: [o],
10
+ queryFn: () => e ? Promise.resolve(e) : i(`${o}/dropdown`),
11
+ select: (t) => s(t)
12
+ });
13
+ }, F = (o = !0) => {
14
+ const r = n((e) => e.moduleId);
15
+ return m({
16
+ queryKey: p([]),
17
+ queryFn: () => c(`ModuleDependencies/${r}`),
18
+ select: (e) => s(e),
19
+ enabled: o
20
+ });
21
+ };
22
+ export {
23
+ F as useModuleDependency,
24
+ q as useOption
25
+ };
@@ -0,0 +1,25 @@
1
+ import { u as n } from "../useMutation-zu8uxBak.js";
2
+ import { useBasePropsStore as r } from "../stores/BasePropsStore.js";
3
+ const a = ({
4
+ authenticationKey: i,
5
+ queue: s,
6
+ topic: o
7
+ }) => {
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)
20
+ });
21
+ };
22
+ export {
23
+ N as useNotification,
24
+ a as useServiceBus
25
+ };
@@ -0,0 +1,13 @@
1
+ import { SignalRModuleContext as i } from "../provider/SignalR/SignalRProvider.js";
2
+ const s = (e) => {
3
+ i.useSignalREffect(
4
+ "ModuleApiPushNotification",
5
+ (...[o]) => {
6
+ e(o);
7
+ },
8
+ [e]
9
+ );
10
+ };
11
+ export {
12
+ s as useSignalRMessages
13
+ };
@@ -0,0 +1,14 @@
1
+ import { o as r } from "../omit-C9Qe80rl.js";
2
+ import { useBasePropsStore as e } from "../stores/BasePropsStore.js";
3
+ import { useEnvironmentStore as t } from "../stores/EnvironmentStore.js";
4
+ const i = () => {
5
+ const o = e();
6
+ return r(o, "setBaseProps");
7
+ }, m = () => {
8
+ const o = t();
9
+ return r(o, "setEnvironment", "addEnvironment");
10
+ };
11
+ export {
12
+ i as useBaseProps,
13
+ m as useConfig
14
+ };
@@ -0,0 +1,281 @@
1
+ import { R as f, r as p, a as u, b as y, d as v, t as b, c as m, n as C, e as g, i as h, f as S } from "./QueryClientProvider-Beog9TR7.js";
2
+ import * as c from "react";
3
+ var D = class extends f {
4
+ #a;
5
+ #n;
6
+ #e;
7
+ #i;
8
+ #t;
9
+ #o;
10
+ #r;
11
+ constructor(t) {
12
+ super(), this.#r = !1, this.#o = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#i = t.client, this.#e = this.#i.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#a = q(this.options), this.state = t.state ?? this.#a, this.scheduleGc();
13
+ }
14
+ get meta() {
15
+ return this.options.meta;
16
+ }
17
+ get promise() {
18
+ return this.#t?.promise;
19
+ }
20
+ setOptions(t) {
21
+ this.options = { ...this.#o, ...t }, this.updateGcTime(this.options.gcTime);
22
+ }
23
+ optionalRemove() {
24
+ !this.observers.length && this.state.fetchStatus === "idle" && this.#e.remove(this);
25
+ }
26
+ setData(t, e) {
27
+ const s = p(this.state.data, t, this.options);
28
+ return this.#s({
29
+ data: s,
30
+ type: "success",
31
+ dataUpdatedAt: e?.updatedAt,
32
+ manual: e?.manual
33
+ }), s;
34
+ }
35
+ setState(t, e) {
36
+ this.#s({ type: "setState", state: t, setStateOptions: e });
37
+ }
38
+ cancel(t) {
39
+ const e = this.#t?.promise;
40
+ return this.#t?.cancel(t), e ? e.then(u).catch(u) : Promise.resolve();
41
+ }
42
+ destroy() {
43
+ super.destroy(), this.cancel({ silent: !0 });
44
+ }
45
+ reset() {
46
+ this.destroy(), this.setState(this.#a);
47
+ }
48
+ isActive() {
49
+ return this.observers.some(
50
+ (t) => y(t.options.enabled, this) !== !1
51
+ );
52
+ }
53
+ isDisabled() {
54
+ return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === v || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
55
+ }
56
+ isStale() {
57
+ return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
58
+ (t) => t.getCurrentResult().isStale
59
+ ) : this.state.data === void 0;
60
+ }
61
+ isStaleByTime(t = 0) {
62
+ return this.state.isInvalidated || this.state.data === void 0 || !b(this.state.dataUpdatedAt, t);
63
+ }
64
+ onFocus() {
65
+ this.observers.find((e) => e.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
66
+ }
67
+ onOnline() {
68
+ this.observers.find((e) => e.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
69
+ }
70
+ addObserver(t) {
71
+ this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), this.#e.notify({ type: "observerAdded", query: this, observer: t }));
72
+ }
73
+ removeObserver(t) {
74
+ this.observers.includes(t) && (this.observers = this.observers.filter((e) => e !== t), this.observers.length || (this.#t && (this.#r ? this.#t.cancel({ revert: !0 }) : this.#t.cancelRetry()), this.scheduleGc()), this.#e.notify({ type: "observerRemoved", query: this, observer: t }));
75
+ }
76
+ getObserversCount() {
77
+ return this.observers.length;
78
+ }
79
+ invalidate() {
80
+ this.state.isInvalidated || this.#s({ type: "invalidate" });
81
+ }
82
+ fetch(t, e) {
83
+ if (this.state.fetchStatus !== "idle") {
84
+ if (this.state.data !== void 0 && e?.cancelRefetch)
85
+ this.cancel({ silent: !0 });
86
+ else if (this.#t)
87
+ return this.#t.continueRetry(), this.#t.promise;
88
+ }
89
+ if (t && this.setOptions(t), !this.options.queryFn) {
90
+ const i = this.observers.find((a) => a.options.queryFn);
91
+ i && this.setOptions(i.options);
92
+ }
93
+ process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
94
+ "As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"
95
+ ));
96
+ const s = new AbortController(), r = (i) => {
97
+ Object.defineProperty(i, "signal", {
98
+ enumerable: !0,
99
+ get: () => (this.#r = !0, s.signal)
100
+ });
101
+ }, l = () => {
102
+ const i = g(this.options, e), a = {
103
+ client: this.#i,
104
+ queryKey: this.queryKey,
105
+ meta: this.meta
106
+ };
107
+ return r(a), this.#r = !1, this.options.persister ? this.options.persister(
108
+ i,
109
+ a,
110
+ this
111
+ ) : i(a);
112
+ }, n = {
113
+ fetchOptions: e,
114
+ options: this.options,
115
+ queryKey: this.queryKey,
116
+ client: this.#i,
117
+ state: this.state,
118
+ fetchFn: l
119
+ };
120
+ r(n), this.options.behavior?.onFetch(
121
+ n,
122
+ this
123
+ ), this.#n = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== n.fetchOptions?.meta) && this.#s({ type: "fetch", meta: n.fetchOptions?.meta });
124
+ const o = (i) => {
125
+ h(i) && i.silent || this.#s({
126
+ type: "error",
127
+ error: i
128
+ }), h(i) || (this.#e.config.onError?.(
129
+ i,
130
+ this
131
+ ), this.#e.config.onSettled?.(
132
+ this.state.data,
133
+ i,
134
+ this
135
+ )), this.scheduleGc();
136
+ };
137
+ return this.#t = m({
138
+ initialPromise: e?.initialPromise,
139
+ fn: n.fetchFn,
140
+ abort: s.abort.bind(s),
141
+ onSuccess: (i) => {
142
+ if (i === void 0) {
143
+ process.env.NODE_ENV !== "production" && console.error(
144
+ `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
145
+ ), o(new Error(`${this.queryHash} data is undefined`));
146
+ return;
147
+ }
148
+ try {
149
+ this.setData(i);
150
+ } catch (a) {
151
+ o(a);
152
+ return;
153
+ }
154
+ this.#e.config.onSuccess?.(i, this), this.#e.config.onSettled?.(
155
+ i,
156
+ this.state.error,
157
+ this
158
+ ), this.scheduleGc();
159
+ },
160
+ onError: o,
161
+ onFail: (i, a) => {
162
+ this.#s({ type: "failed", failureCount: i, error: a });
163
+ },
164
+ onPause: () => {
165
+ this.#s({ type: "pause" });
166
+ },
167
+ onContinue: () => {
168
+ this.#s({ type: "continue" });
169
+ },
170
+ retry: n.options.retry,
171
+ retryDelay: n.options.retryDelay,
172
+ networkMode: n.options.networkMode,
173
+ canRun: () => !0
174
+ }), this.#t.start();
175
+ }
176
+ #s(t) {
177
+ const e = (s) => {
178
+ switch (t.type) {
179
+ case "failed":
180
+ return {
181
+ ...s,
182
+ fetchFailureCount: t.failureCount,
183
+ fetchFailureReason: t.error
184
+ };
185
+ case "pause":
186
+ return {
187
+ ...s,
188
+ fetchStatus: "paused"
189
+ };
190
+ case "continue":
191
+ return {
192
+ ...s,
193
+ fetchStatus: "fetching"
194
+ };
195
+ case "fetch":
196
+ return {
197
+ ...s,
198
+ ...F(s.data, this.options),
199
+ fetchMeta: t.meta ?? null
200
+ };
201
+ case "success":
202
+ return {
203
+ ...s,
204
+ data: t.data,
205
+ dataUpdateCount: s.dataUpdateCount + 1,
206
+ dataUpdatedAt: t.dataUpdatedAt ?? Date.now(),
207
+ error: null,
208
+ isInvalidated: !1,
209
+ status: "success",
210
+ ...!t.manual && {
211
+ fetchStatus: "idle",
212
+ fetchFailureCount: 0,
213
+ fetchFailureReason: null
214
+ }
215
+ };
216
+ case "error":
217
+ const r = t.error;
218
+ return h(r) && r.revert && this.#n ? { ...this.#n, fetchStatus: "idle" } : {
219
+ ...s,
220
+ error: r,
221
+ errorUpdateCount: s.errorUpdateCount + 1,
222
+ errorUpdatedAt: Date.now(),
223
+ fetchFailureCount: s.fetchFailureCount + 1,
224
+ fetchFailureReason: r,
225
+ fetchStatus: "idle",
226
+ status: "error"
227
+ };
228
+ case "invalidate":
229
+ return {
230
+ ...s,
231
+ isInvalidated: !0
232
+ };
233
+ case "setState":
234
+ return {
235
+ ...s,
236
+ ...t.state
237
+ };
238
+ }
239
+ };
240
+ this.state = e(this.state), C.batch(() => {
241
+ this.observers.forEach((s) => {
242
+ s.onQueryUpdate();
243
+ }), this.#e.notify({ query: this, type: "updated", action: t });
244
+ });
245
+ }
246
+ };
247
+ function F(t, e) {
248
+ return {
249
+ fetchFailureCount: 0,
250
+ fetchFailureReason: null,
251
+ fetchStatus: S(e.networkMode) ? "fetching" : "paused",
252
+ ...t === void 0 && {
253
+ error: null,
254
+ status: "pending"
255
+ }
256
+ };
257
+ }
258
+ function q(t) {
259
+ const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0, r = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
260
+ return {
261
+ data: e,
262
+ dataUpdateCount: 0,
263
+ dataUpdatedAt: s ? r ?? Date.now() : 0,
264
+ error: null,
265
+ errorUpdateCount: 0,
266
+ errorUpdatedAt: 0,
267
+ fetchFailureCount: 0,
268
+ fetchFailureReason: null,
269
+ fetchMeta: null,
270
+ isInvalidated: !1,
271
+ status: s ? "success" : "pending",
272
+ fetchStatus: "idle"
273
+ };
274
+ }
275
+ var d = c.createContext(!1), R = () => c.useContext(d), U = d.Provider;
276
+ export {
277
+ U as I,
278
+ D as Q,
279
+ F as f,
280
+ R as u
281
+ };
@@ -0,0 +1,36 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ import { RouteObject } from 'react-router';
3
+ import { BaseProps } from '../types/BaseProps';
4
+ import { EnvConfig } from '../types/Environment';
5
+ type ModuleBaseProps = {
6
+ /**
7
+ * Properties that are passed to the Base component by the host application, {@link BaseProps}
8
+ */
9
+ props: BaseProps;
10
+ /**
11
+ * Routes that are used in the module, {@link RouteObject}
12
+ */
13
+ routes: RouteObject[];
14
+ /**
15
+ * @deprecated
16
+ * Environment configuration that is used to configure the module, {@link EnvConfig}.
17
+ * New way to pass environment variables is through the base props:
18
+ * Setup the environment variables in the host application (module edit in the vendor section).
19
+ * They are then passed to the module within the base props.
20
+ */
21
+ env?: EnvConfig;
22
+ /**
23
+ * If true, the module will use the SignalR provider to connect to the module API.
24
+ */
25
+ useSignalR?: boolean;
26
+ /**
27
+ * Query client that is used to provide the module with a query client, {@link QueryClient}.
28
+ * If not provided, the default query client will be used.
29
+ */
30
+ queryClient?: QueryClient;
31
+ };
32
+ /**
33
+ * Main component of the module. This component is used to create a module with a router and a signalR provider.
34
+ */
35
+ export declare const ModuleBase: ({ props, routes, env, useSignalR, queryClient, }: ModuleBaseProps) => import("react/jsx-runtime").JSX.Element;
36
+ export {};
@@ -0,0 +1,32 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ import { BaseProps } from '../types/BaseProps';
3
+ import { EnvConfig } from '../types/Environment';
4
+ export declare const ModuleQueryClient: QueryClient;
5
+ type ModuleCoreProps = {
6
+ /**
7
+ * Properties that are passed to the Base component by the host application, {@link BaseProps}
8
+ */
9
+ props: BaseProps;
10
+ /**
11
+ * @deprecated
12
+ * Environment configuration that is used to configure the module, {@link EnvConfig}.
13
+ * New way to pass environment variables is through the base props:
14
+ * Setup the environment variables in the host application (module edit in the vendor section).
15
+ * They are then passed to the module within the base props.
16
+ */
17
+ env?: EnvConfig;
18
+ /**
19
+ * Query client that is used to provide the module with a query client, {@link QueryClient}.
20
+ * If not provided, the default query client will be used.
21
+ */
22
+ queryClient?: QueryClient;
23
+ /**
24
+ * Children components that are rendered within the module core
25
+ */
26
+ children: React.ReactNode;
27
+ };
28
+ /**
29
+ * Minimal component to create a module with a query client and a signalR provider (to use module api)
30
+ */
31
+ export declare const ModuleCore: ({ props, env, queryClient, children, }: ModuleCoreProps) => import("react/jsx-runtime").JSX.Element;
32
+ export {};