@hortiview/modulebase 0.0.1 → 0.0.17-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.
- package/README.md +8 -8
- package/dist/ModuleCore-YCIFN_02.js +14973 -0
- package/dist/QueryClientProvider-Beog9TR7.js +437 -0
- package/dist/{_baseGet-Bh5zJ_C8.js → _baseGet-C6jMXSsQ.js} +448 -448
- package/dist/api-s6E2GJtu.js +458 -0
- package/dist/assets/ModuleCore.css +1 -0
- package/dist/chunk-QMGIS6GS-C4bgXQXY.js +9203 -0
- package/dist/components/ModuleBase.js +20 -681
- package/dist/components/ModuleCore.js +10 -0
- package/dist/hooks/useBreadcrumbTranslation.js +16 -13
- package/dist/hooks/useCustom.js +15 -15
- package/dist/hooks/useCustomMutation.js +23 -0
- package/dist/hooks/useEntity.js +53 -54
- package/dist/hooks/useOffline.js +45 -0
- package/dist/hooks/useOption.js +19 -17
- package/dist/hooks/useServiceBus.js +25 -0
- package/dist/hooks/useStores.js +11 -841
- package/dist/isRestoring-CLuxJVSA.js +281 -0
- package/dist/lib/components/ModuleBase.d.ts +36 -0
- package/dist/lib/components/ModuleCore.d.ts +32 -0
- package/dist/{constants.d.ts → lib/constants.d.ts} +1 -1
- package/dist/{hooks → lib/hooks}/useBreadcrumbTranslation.d.ts +1 -1
- package/dist/lib/hooks/useCustom.d.ts +8 -0
- package/dist/lib/hooks/useCustomMutation.d.ts +9 -0
- package/dist/{hooks → lib/hooks}/useEntity.d.ts +6 -30
- package/dist/lib/hooks/useOffline.d.ts +15 -0
- package/dist/{hooks → lib/hooks}/useOption.d.ts +1 -1
- package/dist/lib/hooks/useServiceBus.d.ts +19 -0
- package/dist/lib/hooks/useStores.d.ts +38 -0
- package/dist/lib/main.d.ts +27 -0
- package/dist/lib/module-router.d.ts +7 -0
- package/dist/{stores → lib/stores}/EnvironmentStore.d.ts +1 -1
- package/dist/lib/types/ActionStorage.d.ts +16 -0
- package/dist/{types → lib/types}/BaseProps.d.ts +14 -2
- package/dist/{types → lib/types}/Deprecated.d.ts +7 -1
- package/dist/lib/types/Entities.d.ts +22 -0
- package/dist/{types → lib/types}/Environment.d.ts +3 -2
- package/dist/lib/types/EnvironmentVariable.d.ts +6 -0
- package/dist/lib/types/ModuleApi.d.ts +163 -0
- package/dist/{types → lib/types}/Requests.d.ts +6 -11
- package/dist/lib/types/ServiceBus.d.ts +17 -0
- package/dist/{utils/fetches.d.ts → lib/utils/api.d.ts} +2 -8
- package/dist/lib/utils/baseFetches.d.ts +19 -0
- package/dist/lib/utils/fetches.d.ts +43 -0
- package/dist/lib/utils/helper.d.ts +29 -0
- package/dist/main.js +224 -17
- package/dist/module-router.js +137 -0
- package/dist/mutation-DSKlaYzY.js +192 -0
- package/dist/omit-C9Qe80rl.js +835 -0
- package/dist/stores/EnvironmentStore.js +9 -3
- package/dist/types/ActionStorage.js +4 -0
- package/dist/types/Entities.js +25 -0
- package/dist/types/EnvironmentVariable.js +1 -0
- package/dist/types/Requests.js +1 -4
- package/dist/types/ServiceBus.js +1 -0
- package/dist/useMutation-zu8uxBak.js +97 -0
- package/dist/{useQuery-znAyMQW1.js → useQuery-Bj9k9zik.js} +106 -108
- package/dist/utils/api.js +9 -0
- package/dist/utils/baseFetches.js +19 -0
- package/dist/utils/fetches.js +20 -14
- package/dist/utils/helper.js +55 -0
- package/dist/utils-DxRR_XLb.js +9 -0
- package/package.json +8 -3
- package/dist/QueryClientProvider-DQv4Y3Qu.js +0 -707
- package/dist/chunk-IR6S3I6Y-BvQXS3A3.js +0 -3908
- package/dist/components/ModuleBase.d.ts +0 -11
- package/dist/fetches-DUCQo_6B.js +0 -477
- package/dist/hooks/useCustom.d.ts +0 -6
- package/dist/hooks/useNavigate.d.ts +0 -5
- package/dist/hooks/useNavigate.js +0 -27
- package/dist/hooks/useStores.d.ts +0 -29
- package/dist/main.d.ts +0 -9
- package/dist/types/ModuleApi.d.ts +0 -80
- /package/dist/{hooks → lib/hooks}/useSignalRMessages.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/{types → lib/types}/AppInsights.d.ts +0 -0
- /package/dist/{types → lib/types}/CommonOptions.d.ts +0 -0
- /package/dist/{types → lib/types}/SystemMessage.d.ts +0 -0
|
@@ -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 {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useBreadcrumbTranslation: () => (key: string, value: string) => void;
|
|
1
|
+
export declare const useBreadcrumbTranslation: () => (key: string, value: string | false) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const useCustom: <T>({ endpoint, queryKey, token, selector, enabled, noAuth }: {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
queryKey: (string | undefined)[];
|
|
4
|
+
token?: string;
|
|
5
|
+
selector?: (data: any) => T;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
noAuth?: boolean;
|
|
8
|
+
}) => import('@tanstack/react-query').UseQueryResult<T, Error>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import { BaseResponse, httpMethod } from '../types/Requests';
|
|
3
|
+
export declare const useCustomMutation: <Input, Output>({ endpoint, method, token, headers, noAuth }: {
|
|
4
|
+
endpoint: string;
|
|
5
|
+
method: Omit<httpMethod, "GET">;
|
|
6
|
+
token?: string;
|
|
7
|
+
headers?: Headers;
|
|
8
|
+
noAuth?: boolean;
|
|
9
|
+
}) => UseMutationResult<BaseResponse<Output>, Error, Input, unknown>;
|
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type FarmOrganizationEntities = 'farms' | 'fields' | 'zones' | 'irrigation_stations' | 'farm_organizations' | 'alert_rules';
|
|
5
|
-
type FarmMemberEntities = 'farm_members';
|
|
6
|
-
type ModuleDependendEntities = 'Season' | 'BlockPlantLayout' | (string & {});
|
|
7
|
-
type HortiviewDataAreaEntity<T extends HortiviewDataAreaGroup | ModuleDataAreaGroup> = T extends 'FarmOrganization' ? FarmOrganizationEntities : T extends 'FarmMember' ? FarmMemberEntities : T extends 'ModuleDepended' ? ModuleDependendEntities : never;
|
|
8
|
-
type ResultMap<T extends FarmMemberEntities | FarmOrganizationEntities | ModuleDependendEntities> = T extends 'zones' ? Block : T extends 'fields' ? Field : T extends 'farms' ? Farm : T extends 'irrigation_stations' ? {
|
|
9
|
-
id: string;
|
|
10
|
-
} : T extends 'farm_organizations' ? {
|
|
11
|
-
id: string;
|
|
12
|
-
} : T extends 'alert_rules' ? {
|
|
13
|
-
id: string;
|
|
14
|
-
} : T extends 'Season' ? Season : T extends 'BlockPlantLayout' ? BlockPlantLayout : never;
|
|
15
|
-
export declare const FarmOrgEntitiesTypeResultMap: Record<FarmOrganizationEntities, string>;
|
|
16
|
-
export declare const FarmMemberEntitiesTypeResultMap: Record<FarmMemberEntities, string>;
|
|
17
|
-
export declare const ModuleDependedEntityTypeResultMap: Record<ModuleDependendEntities, string>;
|
|
18
|
-
export declare const AllEntitiesTypeResultMap: {
|
|
19
|
-
Season: string;
|
|
20
|
-
BlockPlantLayout: string;
|
|
21
|
-
farm_members: string;
|
|
22
|
-
farms: string;
|
|
23
|
-
fields: string;
|
|
24
|
-
zones: string;
|
|
25
|
-
irrigation_stations: string;
|
|
26
|
-
farm_organizations: string;
|
|
27
|
-
alert_rules: string;
|
|
28
|
-
};
|
|
29
|
-
export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, entity: E) => {
|
|
1
|
+
import { FarmOrgEntity, ModuleEntity } from '../types/ModuleApi';
|
|
2
|
+
import { HortiviewDataAreaEntity, HortiviewDataAreaGroup, ModuleDataAreaGroup, ResultMap } from '../types/Entities';
|
|
3
|
+
export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, entity: E, enabled?: boolean, shouldGetRawData?: boolean) => {
|
|
30
4
|
data: ResultMap<E>[];
|
|
31
5
|
error: Error;
|
|
32
6
|
isError: true;
|
|
@@ -183,4 +157,6 @@ export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAr
|
|
|
183
157
|
fetchStatus: import('@tanstack/query-core').FetchStatus;
|
|
184
158
|
promise: Promise<FarmOrgEntity[] | ModuleEntity[]>;
|
|
185
159
|
};
|
|
186
|
-
export {
|
|
160
|
+
export declare const useEntityId: (group: HortiviewDataAreaGroup | ModuleDataAreaGroup) => {
|
|
161
|
+
getEntityId: (entity: HortiviewDataAreaEntity<typeof group>) => string | undefined;
|
|
162
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HortiviewDataAreaEntity, HortiviewDataAreaGroup, ModuleDataAreaGroup } from '../types/Entities';
|
|
2
|
+
export declare const useOffline: () => {
|
|
3
|
+
prefetchCustom: <T>({ queryKey, endpoint, token, noAuth, }: {
|
|
4
|
+
queryKey: (string | undefined)[];
|
|
5
|
+
endpoint: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
noAuth?: boolean;
|
|
8
|
+
selector?: (data: any) => T;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
prefetch: <T>({ queryKey, queryFn, }: {
|
|
11
|
+
queryKey: (string | undefined)[];
|
|
12
|
+
queryFn: () => Promise<T>;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
usePrefetchEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, ...entities: E[]) => "Prefetch failed: no moduleId" | undefined;
|
|
15
|
+
};
|
|
@@ -14,4 +14,4 @@ import { RegisterOption } from '../types/ModuleApi';
|
|
|
14
14
|
* or fetches it from the API. The result is then processed by a universal selector.
|
|
15
15
|
*/
|
|
16
16
|
export declare const useOption: (dropdown: keyof typeof CommonOptionType) => UseQueryResult<CommonOption[], Error>;
|
|
17
|
-
export declare const useModuleDependency: () => UseQueryResult<RegisterOption[], Error>;
|
|
17
|
+
export declare const useModuleDependency: (enabled?: boolean) => UseQueryResult<RegisterOption[], Error>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import { BaseResponse } from '../types/Requests';
|
|
3
|
+
import { AlertServiceBusMessage } from '../types/ServiceBus';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param authenticationKey SASToken, that will be provided by the vendor portal of HortiView
|
|
7
|
+
* @param queue url of the service bus queue
|
|
8
|
+
* @param topic topic of the service bus, where the message will be sent to
|
|
9
|
+
* @deprecated use useNotification instead
|
|
10
|
+
*/
|
|
11
|
+
export declare const useServiceBus: ({ authenticationKey, queue, topic, }: {
|
|
12
|
+
authenticationKey: string;
|
|
13
|
+
queue: string;
|
|
14
|
+
topic: string;
|
|
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>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const useBaseProps: () => Pick<import('../main').DeprecatedBaseProps & {
|
|
2
|
+
isOnline?: boolean;
|
|
3
|
+
modulePermissionToken?: string;
|
|
4
|
+
moduleId?: string;
|
|
5
|
+
organizationId?: string;
|
|
6
|
+
basePath?: string;
|
|
7
|
+
currentNavigationPath?: string;
|
|
8
|
+
sourcePath?: string | null;
|
|
9
|
+
currentLanguage?: string;
|
|
10
|
+
currentLanguageId?: string;
|
|
11
|
+
alertRules?: string;
|
|
12
|
+
commonOptions?: import('../main').AllDropdownsData<import('../main').CommonOption>["items"];
|
|
13
|
+
riseNotification?: (message: import('../main').AlertServiceBusMessage) => Promise<unknown>;
|
|
14
|
+
navigateInHortiview?: (path: string) => void;
|
|
15
|
+
addBreadcrumbTranslation?: (translation: {
|
|
16
|
+
key: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}, hide?: boolean) => void;
|
|
19
|
+
showSnackbar?: (message: string, icon?: string) => void;
|
|
20
|
+
showMessage?: (message: import('../main').SystemMessage) => void;
|
|
21
|
+
pendingActions?: import('../main').ActionItem[];
|
|
22
|
+
resolveAction?: (key: string, result?: string) => void;
|
|
23
|
+
addAction?: (action?: (...args: unknown[]) => void | unknown | Promise<unknown>, actionInfo?: import('../main').ActionItem["actionInfo"], key?: string, ...args: unknown[]) => void;
|
|
24
|
+
addAction2?: (actionInfo: import('../main').ActionItem["actionInfo"], key?: string) => void;
|
|
25
|
+
getActions?: () => import('../main').ActionItem[];
|
|
26
|
+
getActionByKey?: (key: string) => import('../main').ActionItem | undefined;
|
|
27
|
+
logEvent?: (event: import('../main').AppInsightsEvent, customProperties?: import('../main').AppInsightsProperties) => void;
|
|
28
|
+
logError?: (exception: import('../main').AppInsightsException) => void;
|
|
29
|
+
throwError?: (message: string, code: number) => void;
|
|
30
|
+
environmentVariables?: import('../main').EnvironmentVariable[];
|
|
31
|
+
} & {
|
|
32
|
+
setBaseProps: (props: import('../main').BaseProps) => void;
|
|
33
|
+
}, keyof import('../main').DeprecatedBaseProps | "isOnline" | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "alertRules" | "commonOptions" | "riseNotification" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "pendingActions" | "resolveAction" | "addAction" | "addAction2" | "getActions" | "getActionByKey" | "logEvent" | "logError" | "throwError" | "environmentVariables">;
|
|
34
|
+
export declare const useConfig: () => Pick<{
|
|
35
|
+
environment: import('../main').HortiViewEnvironments;
|
|
36
|
+
setEnvironment: (environment: import('../main').HortiViewEnvironments) => void;
|
|
37
|
+
addEnvironment: (customEnv: import('../main').CustomEnv) => void;
|
|
38
|
+
}, "environment">;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { ModuleBase } from './components/ModuleBase';
|
|
2
|
+
export { ModuleCore } from './components/ModuleCore';
|
|
3
|
+
export type * from './types/AppInsights';
|
|
4
|
+
export type * from './types/BaseProps';
|
|
5
|
+
export type * from './types/CommonOptions';
|
|
6
|
+
export type * from './types/Deprecated';
|
|
7
|
+
export type * from './types/Environment';
|
|
8
|
+
export type * from './types/EnvironmentVariable';
|
|
9
|
+
export type * from './types/ModuleApi';
|
|
10
|
+
export type * from './types/Requests';
|
|
11
|
+
export type * from './types/ServiceBus';
|
|
12
|
+
export type * from './types/SystemMessage';
|
|
13
|
+
export type * from './types/ActionStorage';
|
|
14
|
+
export { useBreadcrumbTranslation } from './hooks/useBreadcrumbTranslation';
|
|
15
|
+
export { useOffline } from './hooks/useOffline';
|
|
16
|
+
export { useSignalRMessages } from './hooks/useSignalRMessages';
|
|
17
|
+
export * from './module-router';
|
|
18
|
+
export { useNavigate } from './module-router';
|
|
19
|
+
export { useBaseProps, useConfig } from './hooks/useStores';
|
|
20
|
+
export { useCustom } from './hooks/useCustom';
|
|
21
|
+
export { useCustomMutation } from './hooks/useCustomMutation';
|
|
22
|
+
export { useEntity } from './hooks/useEntity';
|
|
23
|
+
export { useOption } from './hooks/useOption';
|
|
24
|
+
export { useNotification, useServiceBus } from './hooks/useServiceBus';
|
|
25
|
+
export { QueryClient, useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
26
|
+
export { mutateOnCustomApi } from './utils/fetches';
|
|
27
|
+
export * from './utils/helper';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CustomEnv, HortiViewEnvironments } from '../types/Environment';
|
|
2
2
|
type EnvironmentStore = {
|
|
3
|
-
environment
|
|
3
|
+
environment: HortiViewEnvironments;
|
|
4
4
|
setEnvironment: (environment: HortiViewEnvironments) => void;
|
|
5
5
|
addEnvironment: (customEnv: CustomEnv) => void;
|
|
6
6
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare enum ActionState {
|
|
2
|
+
PENDING = "PENDING",
|
|
3
|
+
SUCCESS = "RESOLVED",
|
|
4
|
+
ERROR = "REJECTED"
|
|
5
|
+
}
|
|
6
|
+
export type ActionItem = {
|
|
7
|
+
action: (...args: unknown[]) => void | unknown | Promise<unknown>;
|
|
8
|
+
actionInfo: {
|
|
9
|
+
functionName: string;
|
|
10
|
+
args: unknown[];
|
|
11
|
+
};
|
|
12
|
+
dateAdded: string;
|
|
13
|
+
state: ActionState;
|
|
14
|
+
key: string;
|
|
15
|
+
result: string;
|
|
16
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { ActionItem } from './ActionStorage';
|
|
1
2
|
import { AppInsightsEvent, AppInsightsException, AppInsightsProperties } from './AppInsights';
|
|
2
3
|
import { AllDropdownsData, CommonOption } from './CommonOptions';
|
|
3
4
|
import { DeprecatedBaseProps } from './Deprecated';
|
|
5
|
+
import { EnvironmentVariable } from './EnvironmentVariable';
|
|
6
|
+
import { AlertServiceBusMessage } from './ServiceBus';
|
|
4
7
|
import { SystemMessage } from './SystemMessage';
|
|
5
8
|
/**
|
|
6
9
|
* Properties that are passed to the Base component by the host application
|
|
@@ -15,6 +18,7 @@ import { SystemMessage } from './SystemMessage';
|
|
|
15
18
|
* @param currentNavigationPath current path of the route, that is changed, when the host application navigates
|
|
16
19
|
*/
|
|
17
20
|
export type BaseProps = DeprecatedBaseProps & {
|
|
21
|
+
isOnline?: boolean;
|
|
18
22
|
modulePermissionToken?: string;
|
|
19
23
|
moduleId?: string;
|
|
20
24
|
organizationId?: string;
|
|
@@ -24,15 +28,23 @@ export type BaseProps = DeprecatedBaseProps & {
|
|
|
24
28
|
currentLanguage?: string;
|
|
25
29
|
currentLanguageId?: string;
|
|
26
30
|
alertRules?: string;
|
|
27
|
-
commonOptions?: AllDropdownsData<CommonOption>[
|
|
31
|
+
commonOptions?: AllDropdownsData<CommonOption>['items'];
|
|
32
|
+
riseNotification?: (message: AlertServiceBusMessage) => Promise<unknown>;
|
|
28
33
|
navigateInHortiview?: (path: string) => void;
|
|
29
34
|
addBreadcrumbTranslation?: (translation: {
|
|
30
35
|
key: string;
|
|
31
36
|
value: string;
|
|
32
|
-
}) => void;
|
|
37
|
+
}, hide?: boolean) => void;
|
|
33
38
|
showSnackbar?: (message: string, icon?: string) => void;
|
|
34
39
|
showMessage?: (message: SystemMessage) => void;
|
|
40
|
+
pendingActions?: ActionItem[];
|
|
41
|
+
resolveAction?: (key: string, result?: string) => void;
|
|
42
|
+
addAction?: (action?: (...args: unknown[]) => void | unknown | Promise<unknown>, actionInfo?: ActionItem['actionInfo'], key?: string, ...args: unknown[]) => void;
|
|
43
|
+
addAction2?: (actionInfo: ActionItem['actionInfo'], key?: string) => void;
|
|
44
|
+
getActions?: () => ActionItem[];
|
|
45
|
+
getActionByKey?: (key: string) => ActionItem | undefined;
|
|
35
46
|
logEvent?: (event: AppInsightsEvent, customProperties?: AppInsightsProperties) => void;
|
|
36
47
|
logError?: (exception: AppInsightsException) => void;
|
|
37
48
|
throwError?: (message: string, code: number) => void;
|
|
49
|
+
environmentVariables?: EnvironmentVariable[];
|
|
38
50
|
};
|
|
@@ -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
|
*/
|
|
@@ -31,7 +37,7 @@ export type DeprecatedBaseProps = {
|
|
|
31
37
|
addTranslation?: (translation: {
|
|
32
38
|
key: string;
|
|
33
39
|
value: string;
|
|
34
|
-
}) => void;
|
|
40
|
+
}, hide?: boolean) => void;
|
|
35
41
|
/**
|
|
36
42
|
* @deprecated Use `navigateInHortiview` instead
|
|
37
43
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Block, BlockPlantLayout, Farm, FarmAlertRule, FarmOrganization, Field, IrrigationStation, Season } from '../types/ModuleApi';
|
|
2
|
+
export type HortiviewDataAreaGroup = 'FarmOrganization' | 'FarmMember';
|
|
3
|
+
export type ModuleDataAreaGroup = 'ModuleDepended';
|
|
4
|
+
export type FarmOrganizationEntities = 'farms' | 'fields' | 'zones' | 'irrigation_stations' | 'farm_organizations' | 'alert_rules';
|
|
5
|
+
export type FarmMemberEntities = 'farm_members';
|
|
6
|
+
export type ModuleDependendEntities = 'Season' | 'BlockPlantLayout' | (string & {});
|
|
7
|
+
export type HortiviewDataAreaEntity<T extends HortiviewDataAreaGroup | ModuleDataAreaGroup> = T extends 'FarmOrganization' ? FarmOrganizationEntities : T extends 'FarmMember' ? FarmMemberEntities : T extends 'ModuleDepended' ? ModuleDependendEntities : never;
|
|
8
|
+
export type ResultMap<T extends FarmMemberEntities | FarmOrganizationEntities | ModuleDependendEntities> = T extends 'zones' ? Block : T extends 'fields' ? Field : T extends 'farms' ? Farm : T extends 'irrigation_stations' ? IrrigationStation : T extends 'farm_organizations' ? FarmOrganization : T extends 'alert_rules' ? FarmAlertRule : T extends 'Season' ? Season : T extends 'BlockPlantLayout' ? BlockPlantLayout : unknown;
|
|
9
|
+
export declare const FarmOrgEntitiesTypeResultMap: Record<FarmOrganizationEntities, string>;
|
|
10
|
+
export declare const FarmMemberEntitiesTypeResultMap: Record<FarmMemberEntities, string>;
|
|
11
|
+
export declare const ModuleDependedEntityTypeResultMap: Record<ModuleDependendEntities, string>;
|
|
12
|
+
export declare const AllEntitiesTypeResultMap: {
|
|
13
|
+
Season: string;
|
|
14
|
+
BlockPlantLayout: string;
|
|
15
|
+
farm_members: string;
|
|
16
|
+
farms: string;
|
|
17
|
+
fields: string;
|
|
18
|
+
zones: string;
|
|
19
|
+
irrigation_stations: string;
|
|
20
|
+
farm_organizations: string;
|
|
21
|
+
alert_rules: string;
|
|
22
|
+
};
|