@hortiview/modulebase 0.0.12333 → 0.0.12550

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.
@@ -0,0 +1,17 @@
1
+ import { u } from "../useMutation-3rykrmeD.js";
2
+ import { useBasePropsStore as t } from "../stores/BasePropsStore.js";
3
+ const f = ({
4
+ authenticationKey: i,
5
+ queue: e,
6
+ topic: s
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)
13
+ });
14
+ };
15
+ export {
16
+ f as useServiceBus
17
+ };
@@ -9,6 +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
13
  navigateInHortiview?: (path: string) => void;
13
14
  addBreadcrumbTranslation?: (translation: {
14
15
  key: string;
@@ -21,7 +22,7 @@ export declare const useBaseProps: () => Pick<import('../types/Deprecated').Depr
21
22
  throwError?: (message: string, code: number) => void;
22
23
  } & {
23
24
  setBaseProps: (props: import('../main').BaseProps) => void;
24
- }, keyof import('../types/Deprecated').DeprecatedBaseProps | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "alertRules" | "commonOptions" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "logEvent" | "logError" | "throwError">;
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
26
  export declare const useConfig: () => Pick<{
26
27
  environment: import('../types/Environment').HortiViewEnvironments;
27
28
  setEnvironment: (environment: import('../types/Environment').HortiViewEnvironments) => void;
package/dist/main.d.ts CHANGED
@@ -9,4 +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
13
  export { mutateOnCustomApi } from './utils/fetches';
package/dist/main.js CHANGED
@@ -1,134 +1,136 @@
1
- import { M as s } from "./ModuleBase-brrfWM_W.js";
1
+ import { ModuleBase as s } from "./components/ModuleBase.js";
2
2
  import { useBreadcrumbTranslation as r } from "./hooks/useBreadcrumbTranslation.js";
3
3
  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
- import { useCustom as F } from "./hooks/useCustom.js";
6
+ import { useCustom as E } from "./hooks/useCustom.js";
7
7
  import { useEntity as l } 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 { mutateOnCustomApi as h } from "./utils/fetches.js";
11
- import { A as C, B as x, F as g, H as v, I as P, a as f, b as y, L, c as M, M as k, d as D, N as H, e as O, f as B, O as b, P as T, R as w, g as I, h as V, i as q, S as z, j as G, k as K, l as W, m as j, D as J, n as Q, E as X, o as Y, p as Z, q as $, r as aa, s as ea, t as sa, u as ta, v as ra, V as oa, w as ua, x as ia, y as na, z as ca, C as Sa, G as Ra, J as Ea, K as Fa, Q as ma, T as la, U as Na, W as Aa, X as _a, Y as da, Z as pa, _ as ha, $ as Ua, a0 as Ca, a1 as xa, a2 as ga, a3 as va, a4 as Pa, a5 as fa, a6 as ya, a7 as La, a8 as Ma, a9 as ka, aa as Da, ab as Ha, ac as Oa, ad as Ba, ae as ba, af as Ta, ag as wa, ah as Ia, ai as Va, aj as qa, ak as za, al as Ga, am as Ka, an as Wa, ao as ja, ap as Ja, aq as Qa, ar as Xa, as as Ya, at as Za, au as $a, av as ae, aw as ee, ax as se, ay as te, az as re, aA as oe, aB as ue, aC as ie, aD as ne, aE as ce, aF as Se, aG as Re, aH as Ee, aI as Fe, aJ as me, aK as le, aL as Ne, aM as Ae, aN as _e, aO as de, aP as pe, aQ as he, aR as Ue, aS as Ce, aT as xe } from "./chunk-IR6S3I6Y-BmDdD3SP.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";
12
13
  export {
13
- C as Await,
14
- x as BrowserRouter,
15
- g as Form,
16
- v as HashRouter,
17
- P as IDLE_BLOCKER,
18
- f as IDLE_FETCHER,
19
- y as IDLE_NAVIGATION,
20
- L as Link,
21
- M as Links,
22
- k as MemoryRouter,
23
- D as Meta,
14
+ g as Await,
15
+ v as BrowserRouter,
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,
24
25
  s as ModuleBase,
25
- H as NavLink,
26
- O as Navigate,
27
- B as NavigationType,
28
- b as Outlet,
29
- T as PrefetchPageLinks,
30
- w as Route,
31
- I as Router,
32
- V as RouterProvider,
33
- q as Routes,
34
- z as Scripts,
35
- G as ScrollRestoration,
36
- K as ServerRouter,
37
- W as StaticRouter,
38
- j as StaticRouterProvider,
39
- J as UNSAFE_DataRouterContext,
40
- Q as UNSAFE_DataRouterStateContext,
41
- X as UNSAFE_ErrorResponseImpl,
42
- Y as UNSAFE_FetchersContext,
43
- Z as UNSAFE_FrameworkContext,
44
- $ as UNSAFE_LocationContext,
45
- aa as UNSAFE_NavigationContext,
46
- ea as UNSAFE_RemixErrorBoundary,
47
- sa as UNSAFE_RouteContext,
48
- ta as UNSAFE_ServerMode,
49
- ra as UNSAFE_SingleFetchRedirectSymbol,
50
- oa as UNSAFE_ViewTransitionContext,
51
- ua as UNSAFE_createBrowserHistory,
52
- ia as UNSAFE_createClientRoutes,
53
- na as UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
54
- ca as UNSAFE_createRouter,
55
- Sa as UNSAFE_decodeViaTurboStream,
56
- Ra as UNSAFE_deserializeErrors,
57
- Ea as UNSAFE_getPatchRoutesOnNavigationFunction,
58
- Fa as UNSAFE_getSingleFetchDataStrategy,
59
- ma as UNSAFE_invariant,
60
- la as UNSAFE_mapRouteProperties,
61
- Na as UNSAFE_shouldHydrateRouteLoader,
62
- Aa as UNSAFE_useFogOFWarDiscovery,
63
- _a as UNSAFE_useScrollRestoration,
64
- da as createBrowserRouter,
65
- pa as createCookie,
66
- ha as createCookieSessionStorage,
67
- Ua as createHashRouter,
68
- Ca as createMemoryRouter,
69
- xa as createMemorySessionStorage,
70
- ga as createPath,
71
- va as createRequestHandler,
72
- Pa as createRoutesFromChildren,
73
- fa as createRoutesFromElements,
74
- ya as createRoutesStub,
75
- La as createSearchParams,
76
- Ma as createSession,
77
- ka as createSessionStorage,
78
- Da as createStaticHandler,
79
- Ha as createStaticRouter,
80
- Oa as data,
81
- Ba as generatePath,
82
- ba as isCookie,
83
- Ta as isRouteErrorResponse,
84
- wa as isSession,
85
- Ia as matchPath,
86
- Va as matchRoutes,
87
- h as mutateOnCustomApi,
88
- qa as parsePath,
89
- za as redirect,
90
- Ga as redirectDocument,
91
- Ka as renderMatches,
92
- Wa as replace,
93
- ja as resolvePath,
94
- Ja as unstable_HistoryRouter,
95
- Qa as unstable_setDevServerHooks,
96
- Xa as unstable_usePrompt,
97
- Ya as useActionData,
98
- Za as useAsyncError,
99
- $a as useAsyncValue,
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,
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,
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,
100
101
  S as useBaseProps,
101
- ae as useBeforeUnload,
102
- ee as useBlocker,
102
+ se as useBeforeUnload,
103
+ te as useBlocker,
103
104
  r as useBreadcrumbTranslation,
104
105
  R as useConfig,
105
- F as useCustom,
106
+ E as useCustom,
106
107
  d as useCustomMutation,
107
108
  l as useEntity,
108
- se as useFetcher,
109
- te as useFetchers,
110
- re as useFormAction,
111
- oe as useHref,
112
- ue as useInRouterContext,
113
- ie as useLinkClickHandler,
114
- ne as useLoaderData,
115
- ce as useLocation,
116
- Se as useMatch,
117
- Re as useMatches,
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,
118
119
  n as useNavigate,
119
- Ee as useNavigation,
120
- Fe as useNavigationType,
120
+ Fe as useNavigation,
121
+ le as useNavigationType,
121
122
  A as useOption,
122
- me as useOutlet,
123
- le as useOutletContext,
124
- Ne as useParams,
125
- Ae as useResolvedPath,
126
- _e as useRevalidator,
127
- de as useRouteError,
128
- pe as useRouteLoaderData,
129
- he as useRoutes,
130
- Ue as useSearchParams,
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,
131
133
  u as useSignalRMessages,
132
- Ce as useSubmit,
133
- xe as useViewTransitionState
134
+ ge as useSubmit,
135
+ ve as useViewTransitionState
134
136
  };
@@ -0,0 +1,192 @@
1
+ import { R as o, c as a, n as r } from "./QueryClientProvider-Q_mWQTzQ.js";
2
+ var d = class extends o {
3
+ #e;
4
+ #t;
5
+ #i;
6
+ constructor(t) {
7
+ super(), this.mutationId = t.mutationId, this.#t = t.mutationCache, this.#e = [], this.state = t.state || u(), this.setOptions(t.options), this.scheduleGc();
8
+ }
9
+ setOptions(t) {
10
+ this.options = t, this.updateGcTime(this.options.gcTime);
11
+ }
12
+ get meta() {
13
+ return this.options.meta;
14
+ }
15
+ addObserver(t) {
16
+ this.#e.includes(t) || (this.#e.push(t), this.clearGcTimeout(), this.#t.notify({
17
+ type: "observerAdded",
18
+ mutation: this,
19
+ observer: t
20
+ }));
21
+ }
22
+ removeObserver(t) {
23
+ this.#e = this.#e.filter((i) => i !== t), this.scheduleGc(), this.#t.notify({
24
+ type: "observerRemoved",
25
+ mutation: this,
26
+ observer: t
27
+ });
28
+ }
29
+ optionalRemove() {
30
+ this.#e.length || (this.state.status === "pending" ? this.scheduleGc() : this.#t.remove(this));
31
+ }
32
+ continue() {
33
+ return this.#i?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
34
+ this.execute(this.state.variables);
35
+ }
36
+ async execute(t) {
37
+ this.#i = a({
38
+ fn: () => this.options.mutationFn ? this.options.mutationFn(t) : Promise.reject(new Error("No mutationFn found")),
39
+ onFail: (e, n) => {
40
+ this.#s({ type: "failed", failureCount: e, error: n });
41
+ },
42
+ onPause: () => {
43
+ this.#s({ type: "pause" });
44
+ },
45
+ onContinue: () => {
46
+ this.#s({ type: "continue" });
47
+ },
48
+ retry: this.options.retry ?? 0,
49
+ retryDelay: this.options.retryDelay,
50
+ networkMode: this.options.networkMode,
51
+ canRun: () => this.#t.canRun(this)
52
+ });
53
+ const i = this.state.status === "pending", s = !this.#i.canStart();
54
+ try {
55
+ if (!i) {
56
+ this.#s({ type: "pending", variables: t, isPaused: s }), await this.#t.config.onMutate?.(
57
+ t,
58
+ this
59
+ );
60
+ const n = await this.options.onMutate?.(t);
61
+ n !== this.state.context && this.#s({
62
+ type: "pending",
63
+ context: n,
64
+ variables: t,
65
+ isPaused: s
66
+ });
67
+ }
68
+ const e = await this.#i.start();
69
+ return await this.#t.config.onSuccess?.(
70
+ e,
71
+ t,
72
+ this.state.context,
73
+ this
74
+ ), await this.options.onSuccess?.(e, t, this.state.context), await this.#t.config.onSettled?.(
75
+ e,
76
+ null,
77
+ this.state.variables,
78
+ this.state.context,
79
+ this
80
+ ), await this.options.onSettled?.(e, null, t, this.state.context), this.#s({ type: "success", data: e }), e;
81
+ } catch (e) {
82
+ try {
83
+ throw await this.#t.config.onError?.(
84
+ e,
85
+ t,
86
+ this.state.context,
87
+ this
88
+ ), await this.options.onError?.(
89
+ e,
90
+ t,
91
+ this.state.context
92
+ ), await this.#t.config.onSettled?.(
93
+ void 0,
94
+ e,
95
+ this.state.variables,
96
+ this.state.context,
97
+ this
98
+ ), await this.options.onSettled?.(
99
+ void 0,
100
+ e,
101
+ t,
102
+ this.state.context
103
+ ), e;
104
+ } finally {
105
+ this.#s({ type: "error", error: e });
106
+ }
107
+ } finally {
108
+ this.#t.runNext(this);
109
+ }
110
+ }
111
+ #s(t) {
112
+ const i = (s) => {
113
+ switch (t.type) {
114
+ case "failed":
115
+ return {
116
+ ...s,
117
+ failureCount: t.failureCount,
118
+ failureReason: t.error
119
+ };
120
+ case "pause":
121
+ return {
122
+ ...s,
123
+ isPaused: !0
124
+ };
125
+ case "continue":
126
+ return {
127
+ ...s,
128
+ isPaused: !1
129
+ };
130
+ case "pending":
131
+ return {
132
+ ...s,
133
+ context: t.context,
134
+ data: void 0,
135
+ failureCount: 0,
136
+ failureReason: null,
137
+ error: null,
138
+ isPaused: t.isPaused,
139
+ status: "pending",
140
+ variables: t.variables,
141
+ submittedAt: Date.now()
142
+ };
143
+ case "success":
144
+ return {
145
+ ...s,
146
+ data: t.data,
147
+ failureCount: 0,
148
+ failureReason: null,
149
+ error: null,
150
+ status: "success",
151
+ isPaused: !1
152
+ };
153
+ case "error":
154
+ return {
155
+ ...s,
156
+ data: void 0,
157
+ error: t.error,
158
+ failureCount: s.failureCount + 1,
159
+ failureReason: t.error,
160
+ isPaused: !1,
161
+ status: "error"
162
+ };
163
+ }
164
+ };
165
+ this.state = i(this.state), r.batch(() => {
166
+ this.#e.forEach((s) => {
167
+ s.onMutationUpdate(t);
168
+ }), this.#t.notify({
169
+ mutation: this,
170
+ type: "updated",
171
+ action: t
172
+ });
173
+ });
174
+ }
175
+ };
176
+ function u() {
177
+ return {
178
+ context: void 0,
179
+ data: void 0,
180
+ error: null,
181
+ failureCount: 0,
182
+ failureReason: null,
183
+ isPaused: !1,
184
+ status: "idle",
185
+ variables: void 0,
186
+ submittedAt: 0
187
+ };
188
+ }
189
+ export {
190
+ d as M,
191
+ u as g
192
+ };