@getsoren/shared-module 2.43.4 → 2.45.0

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 CHANGED
@@ -7,6 +7,7 @@
7
7
  - [Usage](#Usage)
8
8
  - [Inject dependencies with provider](#Inject-dependencies-with-provider)
9
9
  - [WebSocket](#WebSocket)
10
+ - [Orval](#Orval)
10
11
 
11
12
  ## Installation
12
13
 
@@ -141,10 +142,71 @@ client.sendMessage("thread-1", "Hello!");
141
142
  | useChat | React hook to consume the ChatProvider context | ChatProvider |
142
143
 
143
144
 
144
- ## Config
145
- | Module | Description |
146
- |-----------------------|------------------------------------|
147
- | getOrvalOperationName | Get config for orval operationName |
145
+ ## Orval
146
+
147
+ The `@getsoren/shared-module/orval` entry point provides everything needed to write an `orval.config.ts`.
148
+
149
+ > ⚠️ This entry relies on Node built-ins (`fs`, `child_process`) and must only be imported
150
+ > from `orval.config.ts` files, never from browser code.
151
+
152
+ ```typescript
153
+ // orval.config.ts
154
+ import { getOrvalConfig } from "@getsoren/shared-module/orval";
155
+ import { defineConfig } from "orval";
156
+
157
+ const config = getOrvalConfig([
158
+ { customAxiosInstancePath: "./src/api/customSaasInstance.ts", input: { host: "saas" } },
159
+ { customAxiosInstancePath: "./src/api/customAuthInstance.ts", input: { host: "auth" } },
160
+ { customAxiosInstancePath: "./src/api/customSupplierInstance.ts", input: { host: "supplier" } },
161
+ ]);
162
+
163
+ export default defineConfig(config);
164
+ ```
165
+
166
+ ### Input resolution
167
+
168
+ When `input` is an object, the OpenAPI schema target is resolved with the following priorities:
169
+
170
+ 1. **Local file** (`./openapi.<name>.json`) — pulled schema snapshot
171
+ 2. **Local service** (`https://<subdomain>.api.tracktor.test/openapi.json`) — docker compose back environment, probed via cURL
172
+ 3. **Upstream deployed service** (`https://<subdomain>.api.dev.tracktor.fr/openapi.json`) — dev cluster, fallback
173
+
174
+ ### Host
175
+
176
+ `host` is the API name (`"saas" | "auth" | "supplier"`) and derives all defaults:
177
+
178
+ | Derived value | Default |
179
+ |-------------------|----------------------------------------------------------|
180
+ | `overrideApiName` | `<host>` → generated folders `src/api/<host>/` |
181
+ | `localFile` | `./openapi.<host>.json` |
182
+ | `localUrl` | `https://<subdomain>.api.tracktor.test/openapi.json` |
183
+ | `upstreamUrl` | `https://<subdomain>.api.dev.tracktor.fr/openapi.json` |
184
+
185
+ The subdomain matches the host, except `saas` which is served on the `app` subdomain.
186
+ Every derived value can be overridden individually:
187
+
188
+ ```typescript
189
+ // Target a specific environment
190
+ input: { host: "saas", upstreamUrl: "https://app.api.rc.tracktor.fr/openapi.json" }
191
+
192
+ // Fully custom, without host
193
+ input: {
194
+ localFile: "./openapi.custom.json",
195
+ localUrl: "https://custom.test/openapi.json",
196
+ upstreamUrl: "https://custom.fr/openapi.json",
197
+ }
198
+
199
+ // Plain path or URL, no resolution
200
+ input: "./openapi.json"
201
+ ```
202
+
203
+ `customAxiosInstancePath` is required: each API needs a dedicated axios instance file
204
+ (its own `baseURL` env variable) which orval uses as mutator.
205
+
206
+ | Module | Description |
207
+ |-----------------------|----------------------------------------------------------------------|
208
+ | getOrvalConfig | Build the orval config (input resolution included) |
209
+ | resolveOrvalInput | Standalone schema target resolution (local file → local → upstream) |
148
210
 
149
211
  ## Utils function
150
212
  | Module | Description |
@@ -28,5 +28,5 @@ interface MaskTextFieldProps<T> {
28
28
  */
29
29
  IMaskMixin: (param: (props: any) => any) => any;
30
30
  }
31
- declare const MaskTextField: <T extends ComponentType>({ IMaskMixin, ...props }: MaskTextFieldProps<T> & ComponentProps<T>) => import("react/jsx-runtime").JSX.Element;
31
+ declare const MaskTextField: <T extends ComponentType>({ IMaskMixin, ...props }: MaskTextFieldProps<T> & ComponentProps<T>) => import("react").JSX.Element;
32
32
  export default MaskTextField;
@@ -0,0 +1,34 @@
1
+ import { PropsWithChildren, ReactNode } from 'react';
2
+ import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
3
+ export interface AutoReloadOnNewVersionProps extends PropsWithChildren {
4
+ /**
5
+ * Version of the currently running bundle, usually imported from the app's package.json.
6
+ * Compared against the meta[name="version"] tag of the remote index.html.
7
+ */
8
+ version: string;
9
+ /**
10
+ * React Router library
11
+ */
12
+ reactRouter?: NonNullable<InjectDependenciesContextProps["libraries"]>["reactRouter"];
13
+ /**
14
+ * Interval in ms between version checks (also checked when the tab regains visibility)
15
+ */
16
+ checkInterval?: number;
17
+ }
18
+ /**
19
+ * Silently reloads the app when a new version has been deployed.
20
+ *
21
+ * Fetches the remote index.html (bypassing caches) when the tab regains visibility
22
+ * and on a fixed interval, then compares its meta[name="version"] with the running
23
+ * bundle version. When they differ, the page is reloaded on the NEXT route change:
24
+ * the user is navigating anyway, so no in-progress work (forms, dialogs) can be lost,
25
+ * and the reload is indistinguishable from a regular page load.
26
+ *
27
+ * Use it as a layout route element (like GTMSendPageView) or wrap an existing one:
28
+ * ```tsx
29
+ * <Route element={<AutoReloadOnNewVersion version={version}><GTMSendPageView /></AutoReloadOnNewVersion>}>
30
+ * ```
31
+ * @constructor
32
+ */
33
+ declare const AutoReloadOnNewVersion: ({ version, checkInterval, children, ...props }: AutoReloadOnNewVersionProps) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element;
34
+ export default AutoReloadOnNewVersion;
@@ -19,5 +19,5 @@ export interface GTMSendPageViewProps {
19
19
  * @param props
20
20
  * @constructor
21
21
  */
22
- declare const GTMSendPageView: ({ data, ...props }: GTMSendPageViewProps) => import("react/jsx-runtime").JSX.Element;
22
+ declare const GTMSendPageView: ({ data, ...props }: GTMSendPageViewProps) => import("react").JSX.Element;
23
23
  export default GTMSendPageView;
@@ -44,5 +44,5 @@ export interface RequireAuthProps {
44
44
  * @param props
45
45
  * @constructor
46
46
  */
47
- declare const RequireAuth: ({ Fallback, isLogged, loginPath, redirect401Path, ...props }: RequireAuthProps) => import("react/jsx-runtime").JSX.Element;
47
+ declare const RequireAuth: ({ Fallback, isLogged, loginPath, redirect401Path, ...props }: RequireAuthProps) => import("react").JSX.Element;
48
48
  export default RequireAuth;
@@ -29,5 +29,5 @@ export interface ChatContextValue {
29
29
  setEnabled: (enabled: boolean) => void;
30
30
  }
31
31
  export declare const ChatContext: import('react').Context<ChatContextValue | null>;
32
- declare const ChatProvider: ({ children, token, url, wsPath, maxReconnectAttempts, reconnectBaseDelay, maxMessageBodyLength, reconnect, enabled: enabledProp, context, }: PropsWithChildren<ChatProviderProps>) => import("react/jsx-runtime").JSX.Element;
32
+ declare const ChatProvider: ({ children, token, url, wsPath, maxReconnectAttempts, reconnectBaseDelay, maxMessageBodyLength, reconnect, enabled: enabledProp, context, }: PropsWithChildren<ChatProviderProps>) => import("react").JSX.Element;
33
33
  export default ChatProvider;
@@ -1,6 +1,6 @@
1
1
  import { sessionReplayPlugin } from '@amplitude/plugin-session-replay-browser';
2
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
2
  import { useGoogleTagManager } from '@getsoren/react-google-tag-manager';
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
4
4
  import { AxiosInstance } from 'axios';
5
5
  import { default as dayjs, PluginFunc } from 'dayjs';
6
6
  import { i18n, TFunction } from 'i18next';
@@ -68,5 +68,5 @@ export declare const InjectDependenciesContext: import('react').Context<InjectDe
68
68
  * @param apiURL
69
69
  * @constructor
70
70
  */
71
- declare const InjectDependenciesProvider: ({ children, apiURL, libraries, localStorageKeys }: InjectDependenciesContextProps) => import("react/jsx-runtime").JSX.Element;
71
+ declare const InjectDependenciesProvider: ({ children, apiURL, libraries, localStorageKeys }: InjectDependenciesContextProps) => import("react").JSX.Element;
72
72
  export default InjectDependenciesProvider;
@@ -22,5 +22,5 @@ interface QueryProviderProps extends PropsWithChildren {
22
22
  [key: string]: any;
23
23
  };
24
24
  }
25
- declare const QueryProvider: ({ children, defaultQueriesOptions, defaultMutationsOptions, ...props }: QueryProviderProps) => import("react/jsx-runtime").JSX.Element;
25
+ declare const QueryProvider: ({ children, defaultQueriesOptions, defaultMutationsOptions, ...props }: QueryProviderProps) => import("react").JSX.Element;
26
26
  export default QueryProvider;
package/dist/main.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- export { axiosCustomInstance, type BodyType, type ErrorType } from './axios/axiosCustomInstance';
2
1
  export { default as ChatClient } from './chat/ChatClient';
3
2
  export * from './chat/types';
4
3
  export * from './components/Inputs/MaskTextField';
5
4
  export { default as MaskTextField } from './components/Inputs/MaskTextField';
5
+ export * from './components/Utils/AutoReloadOnNewVersion';
6
+ export { default as AutoReloadOnNewVersion } from './components/Utils/AutoReloadOnNewVersion';
6
7
  export * from './components/Utils/GTMSendPageView';
7
8
  export { default as GTMSendPageView } from './components/Utils/GTMSendPageView';
8
9
  export * from './components/Utils/InitializeAmplitude';
@@ -21,8 +22,6 @@ export * from './components/Utils/RequireAuth';
21
22
  export { default as RequireAuth } from './components/Utils/RequireAuth';
22
23
  export * from './components/Utils/ShowHubSpotBubble';
23
24
  export { default as ShowHubSpotBubble } from './components/Utils/ShowHubSpotBubble';
24
- export * from './config/orval';
25
- export { default as getOrvalConfig } from './config/orval';
26
25
  export * from './context/ChatProvider';
27
26
  export { default as ChatProvider } from './context/ChatProvider';
28
27
  export * from './context/InjectDependenciesProvider';
@@ -46,6 +45,7 @@ export * from './hooks/useInfiniteDataGrid';
46
45
  export { default as useInfiniteDataGrid } from './hooks/useInfiniteDataGrid';
47
46
  export * from './hooks/useResponseError/useResponseError';
48
47
  export { default as useResponseError } from './hooks/useResponseError/useResponseError';
48
+ export { default as getOrvalConfig } from './orval/orval';
49
49
  export { default as dateAdapter } from './utils/adapter/dateAdapter';
50
50
  export { default as distanceAdapter } from './utils/adapter/distanceAdapter';
51
51
  export { default as worksiteNameAdapter } from './utils/adapter/worksiteNameAdapter/worksiteNameAdapter';
package/dist/main.js CHANGED
@@ -1,17 +1,8 @@
1
- import e from "axios";
1
+ import { t as e } from "./orval-Bf_zcxLE.js";
2
2
  import { Suspense as t, createContext as n, lazy as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
3
3
  import { jsx as u } from "react/jsx-runtime";
4
- //#region src/axios/axiosCustomInstance.ts
5
- var d = (t, n) => {
6
- let r = e.CancelToken.source(), i = e({
7
- ...t,
8
- ...n,
9
- cancelToken: r.token
10
- }).then(({ data: e }) => e);
11
- return i.cancel = () => {
12
- r.cancel("Query was cancelled");
13
- }, i;
14
- }, f = 3e4, p = 1e3, m = 1e4, h = (e) => Array.isArray(e) ? e.map(h) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/_([a-z])/g, (e, t) => t.toUpperCase()), h(t)])) : e, g = (e) => Array.isArray(e) ? e.map(g) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`), g(t)])) : e, _ = class {
4
+ //#region src/chat/ChatClient.ts
5
+ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/_([a-z])/g, (e, t) => t.toUpperCase()), m(t)])) : e, h = (e) => Array.isArray(e) ? e.map(h) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`), h(t)])) : e, g = class {
15
6
  url;
16
7
  getToken;
17
8
  onEvent;
@@ -29,7 +20,7 @@ var d = (t, n) => {
29
20
  _connected = !1;
30
21
  _ready = !1;
31
22
  constructor(e) {
32
- this.url = e.url, this.getToken = e.getToken, this.onEvent = e.onEvent, this.onConnectionChange = e.onConnectionChange, this.shouldReconnect = e.reconnect ?? !0, this.maxReconnectAttempts = e.maxReconnectAttempts ?? Infinity, this.reconnectBaseDelay = e.reconnectBaseDelay ?? p, this.maxMessageBodyLength = e.maxMessageBodyLength ?? m;
23
+ this.url = e.url, this.getToken = e.getToken, this.onEvent = e.onEvent, this.onConnectionChange = e.onConnectionChange, this.shouldReconnect = e.reconnect ?? !0, this.maxReconnectAttempts = e.maxReconnectAttempts ?? Infinity, this.reconnectBaseDelay = e.reconnectBaseDelay ?? f, this.maxMessageBodyLength = e.maxMessageBodyLength ?? p;
33
24
  }
34
25
  get connected() {
35
26
  return this._connected;
@@ -46,7 +37,7 @@ var d = (t, n) => {
46
37
  this._connected = !0, this.reconnectAttempt = 0, this.onConnectionChange?.(!0), this.rejoinThreads(), this.flushPendingMessages();
47
38
  }, this.ws.onmessage = (e) => {
48
39
  try {
49
- let t = h(JSON.parse(e.data));
40
+ let t = m(JSON.parse(e.data));
50
41
  t.type === "ready" && (this._ready = !0), this.onEvent?.(t);
51
42
  } catch {}
52
43
  }, this.ws.onclose = () => {
@@ -94,7 +85,7 @@ var d = (t, n) => {
94
85
  this.pendingMessages.push(e);
95
86
  return;
96
87
  }
97
- this.ws.send(JSON.stringify(g(e)));
88
+ this.ws.send(JSON.stringify(h(e)));
98
89
  }
99
90
  flushPendingMessages() {
100
91
  let e = [...this.pendingMessages];
@@ -109,7 +100,7 @@ var d = (t, n) => {
109
100
  }
110
101
  scheduleReconnect() {
111
102
  this.clearReconnectTimer();
112
- let e = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt, f);
103
+ let e = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt, d);
113
104
  this.reconnectAttempt++, this.reconnectTimer = setTimeout(() => {
114
105
  this.connect();
115
106
  }, e);
@@ -117,7 +108,7 @@ var d = (t, n) => {
117
108
  clearReconnectTimer() {
118
109
  this.reconnectTimer !== null && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
119
110
  }
120
- }, v = ({ IMaskMixin: e, ...t }) => /* @__PURE__ */ u(s(() => e(({ TextField: e, ...t }) => /* @__PURE__ */ u(e, { ...t })), [e]), { ...t }), y = n({}), b = ({ children: e, apiURL: t, libraries: n, localStorageKeys: r }) => {
111
+ }, _ = ({ IMaskMixin: e, ...t }) => /* @__PURE__ */ u(s(() => e(({ TextField: e, ...t }) => /* @__PURE__ */ u(e, { ...t })), [e]), { ...t }), v = n({}), y = ({ children: e, apiURL: t, libraries: n, localStorageKeys: r }) => {
121
112
  let i = s(() => ({
122
113
  apiURL: t,
123
114
  libraries: n,
@@ -127,12 +118,50 @@ var d = (t, n) => {
127
118
  n,
128
119
  r
129
120
  ]);
130
- return /* @__PURE__ */ u(y.Provider, {
121
+ return /* @__PURE__ */ u(v.Provider, {
131
122
  value: i,
132
123
  children: e
133
124
  });
134
- }, x = ({ data: e, ...t }) => {
135
- let { libraries: n } = a(y), r = t?.reactRouter || n?.reactRouter, i = t?.gtm || n?.gtm;
125
+ }, b = 900 * 1e3, x = 60 * 1e3, S = 600 * 1e3, C = "auto-reload-on-new-version-timestamp", w = /<meta[^>]*name="version"[^>]*content="([^"]*)"/, T = (e) => {
126
+ try {
127
+ return sessionStorage.getItem(e);
128
+ } catch {
129
+ return null;
130
+ }
131
+ }, E = (e, t) => {
132
+ try {
133
+ sessionStorage.setItem(e, t);
134
+ } catch {}
135
+ }, D = ({ version: e, checkInterval: t = b, children: n, ...r }) => {
136
+ let { libraries: i } = a(v), s = r?.reactRouter || i?.reactRouter, l = c(!1), d = c(0);
137
+ if (!s) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of AutoReloadOnNewVersion.");
138
+ let { useLocation: f, Outlet: p } = s, { pathname: m } = f(), h = c(m);
139
+ return o(() => {
140
+ if (!e || typeof window > "u") return;
141
+ let n = async () => {
142
+ if (!(l.current || Date.now() - d.current < x)) {
143
+ d.current = Date.now();
144
+ try {
145
+ let t = await fetch("/index.html", { cache: "no-store" });
146
+ if (!t.ok) return;
147
+ let n = (await t.text()).match(w)?.[1];
148
+ n && n !== "%VERSION%" && n !== e && (l.current = !0);
149
+ } catch {}
150
+ }
151
+ }, r = () => {
152
+ document.visibilityState === "visible" && n();
153
+ }, i = setInterval(n, t);
154
+ return document.addEventListener("visibilitychange", r), () => {
155
+ clearInterval(i), document.removeEventListener("visibilitychange", r);
156
+ };
157
+ }, [e, t]), o(() => {
158
+ if (m === h.current || (h.current = m, !l.current)) return;
159
+ l.current = !1;
160
+ let e = Number(T(C) || "0");
161
+ Date.now() - e < S || (E(C, String(Date.now())), window.location.reload());
162
+ }, [m]), n ?? /* @__PURE__ */ u(p, {});
163
+ }, O = ({ data: e, ...t }) => {
164
+ let { libraries: n } = a(v), r = t?.reactRouter || n?.reactRouter, i = t?.gtm || n?.gtm;
136
165
  if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
137
166
  if (!i) throw Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
138
167
  let { useGoogleTagManager: s } = i, { useLocation: c, Outlet: l } = r, { pathname: d } = c(), { sendEvent: f } = s();
@@ -147,8 +176,8 @@ var d = (t, n) => {
147
176
  d,
148
177
  f
149
178
  ]), /* @__PURE__ */ u(l, {});
150
- }, S = ({ apiKey: e, platform: t = "desktop", sessionReplaySampleRate: n = .25, ...r }) => {
151
- let { libraries: i } = a(y), s = r.amplitude || i?.amplitude;
179
+ }, k = ({ apiKey: e, platform: t = "desktop", sessionReplaySampleRate: n = .25, ...r }) => {
180
+ let { libraries: i } = a(v), s = r.amplitude || i?.amplitude;
152
181
  return o(() => {
153
182
  let r = s?.analytics, i = s?.sessionReplayPlugin;
154
183
  if (!(e && r)) return;
@@ -172,23 +201,23 @@ var d = (t, n) => {
172
201
  t,
173
202
  n
174
203
  ]), null;
175
- }, C = (() => {
204
+ }, A = (() => {
176
205
  try {
177
206
  return typeof global == "object" && global !== null && ("HermesInternal" in global || "__fbBatchedBridge" in global || "__metro" in global) || typeof window > "u" && typeof global < "u" ? !0 : typeof navigator < "u" && navigator.userAgent ? /react.native|ReactNative/i.test(navigator.userAgent) : !1;
178
207
  } catch {
179
208
  return !1;
180
209
  }
181
- })(), w = "user", T = ({ tokenTypeKey: e = "tokenType", tokenKey: t = "accessToken", postContentType: n = "application/json", ...r }) => {
182
- let { apiURL: i = r.apiURL, libraries: o, localStorageKeys: s } = a(y), c = r?.userLocalStorageKey || s?.user || w, l = r?.axios || o?.axios;
210
+ })(), j = "user", M = ({ tokenTypeKey: e = "tokenType", tokenKey: t = "accessToken", postContentType: n = "application/json", ...r }) => {
211
+ let { apiURL: i = r.apiURL, libraries: o, localStorageKeys: s } = a(v), c = r?.userLocalStorageKey || s?.user || j, l = r?.axios || o?.axios;
183
212
  if (!l) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
184
- if (!l?.defaults || C) return null;
213
+ if (!l?.defaults || A) return null;
185
214
  if (typeof window < "u" && window.localStorage) {
186
215
  let n = localStorage.getItem(c), r = n ? JSON.parse(n) : null, i = r?.[e] ? r[e] : null, a = r?.[t] ? r[t] : null, o = n ? `${i} ${a}` : null;
187
216
  o && (l.defaults.headers.common.Authorization = o);
188
217
  }
189
218
  return l.defaults.baseURL = i, l.defaults.headers.post["Content-Type"] = n, null;
190
- }, E = ({ language: e, ...t }) => {
191
- let { libraries: n } = a(y), r = t?.dayjs || n?.dayjs, i = t?.plugin || n?.dayjsPlugin;
219
+ }, N = ({ language: e, ...t }) => {
220
+ let { libraries: n } = a(v), r = t?.dayjs || n?.dayjs, i = t?.plugin || n?.dayjsPlugin;
192
221
  if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");
193
222
  return o(() => {
194
223
  (async () => {
@@ -203,7 +232,7 @@ var d = (t, n) => {
203
232
  e,
204
233
  t.localizedFormat
205
234
  ]), null;
206
- }, D = "hubspot-messages-iframe-container", O = "hs-show", k = "data-hs-hidden", A = ({ hubId: e }) => (o(() => {
235
+ }, P = "hubspot-messages-iframe-container", F = "hs-show", I = "data-hs-hidden", L = ({ hubId: e }) => (o(() => {
207
236
  if (!e) return;
208
237
  let t = document.createElement("script");
209
238
  return t.id = "hs-script-loader", t.src = `//js-eu1.hs-scripts.com/${e}.js`, t.async = !0, t.defer = !0, document.body.appendChild(t), () => {
@@ -212,14 +241,14 @@ var d = (t, n) => {
212
241
  }, [e]), o(() => {
213
242
  let e = document.createElement("style");
214
243
  return e.textContent = `
215
- html[${k}] div#${D} { display: none !important; }
216
- html[${k}] div#${D}.${O} { display: initial !important; }
217
- `, document.head.appendChild(e), document.documentElement.setAttribute(k, ""), () => {
218
- e.remove(), document.documentElement.removeAttribute(k);
244
+ html[${I}] div#${P} { display: none !important; }
245
+ html[${I}] div#${P}.${F} { display: initial !important; }
246
+ `, document.head.appendChild(e), document.documentElement.setAttribute(I, ""), () => {
247
+ e.remove(), document.documentElement.removeAttribute(I);
219
248
  };
220
- }, []), null), j = ({ debug: e, resources: t, ...n }) => {
221
- let { libraries: r } = a(y), i = n?.i18 || r?.i18, { i18next: o, initReactI18next: s, languageDetector: c } = i || {};
222
- if (C) return null;
249
+ }, []), null), R = ({ debug: e, resources: t, ...n }) => {
250
+ let { libraries: r } = a(v), i = n?.i18 || r?.i18, { i18next: o, initReactI18next: s, languageDetector: c } = i || {};
251
+ if (A) return null;
223
252
  if (!(i && o && c && s)) throw Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
224
253
  return o.isInitialized ? null : (o.use(c).use(s).init({
225
254
  debug: e,
@@ -237,12 +266,12 @@ var d = (t, n) => {
237
266
  }), o.on("languageChanged", (e) => {
238
267
  document.documentElement.setAttribute("lang", e);
239
268
  }), null);
240
- }, M = ({ dsn: e, integrations: t, tracesSampleRate: n, replaysSessionSampleRate: r, replaysOnErrorSampleRate: i, tracePropagationTargets: s, ignoreErrors: c, debug: l, environment: u, release: d, ...f }) => {
241
- let { libraries: p } = a(y), m = f?.sentry || p?.sentry, h = f?.reactRouter || p?.reactRouter;
269
+ }, ee = ({ dsn: e, integrations: t, tracesSampleRate: n, replaysSessionSampleRate: r, replaysOnErrorSampleRate: i, tracePropagationTargets: s, ignoreErrors: c, debug: l, environment: u, release: d, ...f }) => {
270
+ let { libraries: p } = a(v), m = f?.sentry || p?.sentry, h = f?.reactRouter || p?.reactRouter;
242
271
  if (!m) throw Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
243
272
  if (!h) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
244
273
  if (m.isInitialized()) return null;
245
- let { createRoutesFromChildren: g, matchRoutes: _, useLocation: v, useNavigationType: b } = h;
274
+ let { createRoutesFromChildren: g, matchRoutes: _, useLocation: y, useNavigationType: b } = h;
246
275
  return (l || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && m.init({
247
276
  debug: l,
248
277
  dsn: e,
@@ -260,7 +289,7 @@ var d = (t, n) => {
260
289
  createRoutesFromChildren: g,
261
290
  matchRoutes: _,
262
291
  useEffect: o,
263
- useLocation: v,
292
+ useLocation: y,
264
293
  useNavigationType: b
265
294
  }), ...t || []],
266
295
  release: d,
@@ -269,99 +298,49 @@ var d = (t, n) => {
269
298
  tracePropagationTargets: s,
270
299
  tracesSampleRate: n || 1
271
300
  }), null;
272
- }, N = /* @__PURE__ */ new WeakMap(), P = "user", F = ({ Fallback: e, isLogged: n, loginPath: r = "/login", redirect401Path: i = "/login", ...s }) => {
273
- let { libraries: c, localStorageKeys: d } = a(y), f = s?.reactRouter || c?.reactRouter, p = s?.axios || c?.axios, m = s?.localStorageKey || d?.user || P;
301
+ }, z = /* @__PURE__ */ new WeakMap(), te = "user", ne = ({ Fallback: e, isLogged: n, loginPath: r = "/login", redirect401Path: i = "/login", ...s }) => {
302
+ let { libraries: c, localStorageKeys: d } = a(v), f = s?.reactRouter || c?.reactRouter, p = s?.axios || c?.axios, m = s?.localStorageKey || d?.user || te;
274
303
  if (!f) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
275
- let [h, g] = l(null), { useLocation: _, Navigate: v, Outlet: b } = f, x = _(), S = typeof n == "function" ? n() : !!n, C = typeof S == "boolean" ? S : S?.isLogged;
304
+ let [h, g] = l(null), { useLocation: _, Navigate: y, Outlet: b } = f, x = _(), S = typeof n == "function" ? n() : !!n, C = typeof S == "boolean" ? S : S?.isLogged;
276
305
  return o(() => {
277
- p && (N.has(p) || (N.set(p, !0), p.interceptors.response.use((e) => e, (e) => (typeof e == "object" && e && "response" in e && e.response && typeof e.response == "object" && "status" in e.response && e.response && typeof e.response == "object" && "status" in e.response && e?.response?.status === 401 && (typeof e == "object" && e && "config" in e && e.config && typeof e.config == "object" && "headers" in e.config && e.config.headers && typeof e.config.headers == "object" && "Authorization" in e.config.headers && e.config.headers.Authorization && (p.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(m)), g(i)), Promise.reject(e)))));
306
+ p && (z.has(p) || (z.set(p, !0), p.interceptors.response.use((e) => e, (e) => (typeof e == "object" && e && "response" in e && e.response && typeof e.response == "object" && "status" in e.response && e.response && typeof e.response == "object" && "status" in e.response && e?.response?.status === 401 && (typeof e == "object" && e && "config" in e && e.config && typeof e.config == "object" && "headers" in e.config && e.config.headers && typeof e.config.headers == "object" && "Authorization" in e.config.headers && e.config.headers.Authorization && (p.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(m)), g(i)), Promise.reject(e)))));
278
307
  }, [
279
308
  p,
280
309
  m,
281
310
  i
282
311
  ]), C && !h ? /* @__PURE__ */ u(t, {
283
312
  fallback: e,
284
- children: x.state?.from?.state && x.state?.from?.pathname === r ? /* @__PURE__ */ u(v, {
313
+ children: x.state?.from?.state && x.state?.from?.pathname === r ? /* @__PURE__ */ u(y, {
285
314
  to: x.state.from.state.from.pathname + x.state.from.state.from.search,
286
315
  replace: !0
287
316
  }) : /* @__PURE__ */ u(b, {})
288
- }) : /* @__PURE__ */ u(v, {
317
+ }) : /* @__PURE__ */ u(y, {
289
318
  to: r + x.search,
290
319
  state: { from: x },
291
320
  replace: !0
292
321
  });
293
- }, I = /* @__PURE__ */ new Set(), L = () => (o(() => {
322
+ }, B = /* @__PURE__ */ new Set(), re = () => (o(() => {
294
323
  let e = Symbol();
295
- return I.add(e), document.documentElement.removeAttribute(k), () => {
296
- I.delete(e), I.size === 0 && document.documentElement.setAttribute(k, "");
297
- };
298
- }, []), null), R = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), ee = (e) => {
299
- let t = e.split(/[/\\]/).pop() || "";
300
- return t.substring(0, t.lastIndexOf("."));
301
- }, z = (e) => {
302
- let t = e.split("/").filter((e) => e.length > 0).map((e) => e.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("")).join("");
303
- return t.charAt(0).toLowerCase() + t.slice(1);
304
- }, te = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), ne = (e, t, n, r) => {
305
- let i = `${z(t)}${R(n)}`;
306
- return e && typeof e == "object" && "operationId" in e && r?.includes(String(e.operationId)) ? `${i}AsQuery` : i;
307
- }, re = (e, t) => {
308
- let n = {};
309
- return e?.forEach((e) => {
310
- n[e] = { query: {
311
- useInfinite: !0,
312
- useInfiniteQueryParam: "offset",
313
- useQuery: !0
314
- } };
315
- }), t?.filter((e) => !n[e]).forEach((e) => {
316
- n[e] = { query: { useQuery: !0 } };
317
- }), Object.keys(n).length ? n : void 0;
318
- }, ie = (e) => (Array.isArray(e) ? e : [e]).reduce((e, t) => {
319
- let { output: n, useInfiniteIds: r, useQueryIds: i, input: a = "./openapi.json", customAxiosInstancePath: o, overrideApiName: s } = t || {}, c = s || te(a), l = o || "./node_modules/@getsoren/shared-module/dist/axiosCustomInstance.ts";
320
- return {
321
- ...e,
322
- [c]: {
323
- input: a,
324
- output: {
325
- baseUrl: n?.baseUrl,
326
- client: "react-query",
327
- mode: "tags-split",
328
- override: {
329
- ...(r?.length || i?.length) && { operations: re(r, i) },
330
- header: (e) => [
331
- "Generated by orval 🍺",
332
- ...e.title ? [e.title] : [],
333
- ...e.description ? [e.description] : []
334
- ],
335
- mutator: {
336
- name: ee(l),
337
- path: l
338
- },
339
- operationName: (e, t, n) => ne(e, t, n, i),
340
- query: { useQuery: !0 }
341
- },
342
- schemas: n?.schemas || `src/api/${c}/model`,
343
- target: n?.target || `src/api/${c}/services/api.ts`,
344
- ...n
345
- }
346
- }
324
+ return B.add(e), document.documentElement.removeAttribute(I), () => {
325
+ B.delete(e), B.size === 0 && document.documentElement.setAttribute(I, "");
347
326
  };
348
- }, {}), ae = "user", oe = {
327
+ }, []), null), ie = "user", ae = {
349
328
  client: "/v2/threads/ws",
350
329
  supplier: "/v1/threads/ws"
351
- }, se = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, ce = (e) => {
330
+ }, oe = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, se = (e) => {
352
331
  try {
353
332
  let t = localStorage.getItem(e);
354
333
  return t ? JSON.parse(t)?.accessToken ?? null : null;
355
334
  } catch {
356
335
  return null;
357
336
  }
358
- }, B = n(null), le = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: s, reconnectBaseDelay: d, maxMessageBodyLength: f = 1e4, reconnect: p = !0, enabled: m = !0, context: h = "client" }) => {
359
- let [g, v] = l(!1), [b, x] = l(!1), [S, C] = l(0), [w, T] = l(m), E = m && w, { apiURL: D, localStorageKeys: O } = a(y), k = O?.user || ae, A = c(null), j = c(/* @__PURE__ */ new Set());
337
+ }, V = n(null), ce = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: s, reconnectBaseDelay: d, maxMessageBodyLength: f = 1e4, reconnect: p = !0, enabled: m = !0, context: h = "client" }) => {
338
+ let [_, y] = l(!1), [b, x] = l(!1), [S, C] = l(0), [w, T] = l(m), E = m && w, { apiURL: D, localStorageKeys: O } = a(v), k = O?.user || ie, A = c(null), j = c(/* @__PURE__ */ new Set());
360
339
  o(() => {
361
340
  if (!E) return;
362
- let e = r ?? oe[h], i = n || (D ? se(D, e) : null);
341
+ let e = r ?? ae[h], i = n || (D ? oe(D, e) : null);
363
342
  if (!i) return;
364
- let a = () => t ?? ce(k), o = (e) => {
343
+ let a = () => t ?? se(k), o = (e) => {
365
344
  switch (e.type) {
366
345
  case "ready":
367
346
  x(!0), C(e.unreadCount ?? 0);
@@ -369,12 +348,12 @@ var d = (t, n) => {
369
348
  }
370
349
  for (let t of j.current) t(e);
371
350
  }, c = setTimeout(() => {
372
- let e = new _({
351
+ let e = new g({
373
352
  getToken: a,
374
353
  maxMessageBodyLength: f,
375
354
  maxReconnectAttempts: s,
376
355
  onConnectionChange: (e) => {
377
- v(e), e || x(!1);
356
+ y(e), e || x(!1);
378
357
  },
379
358
  onEvent: o,
380
359
  reconnect: p,
@@ -419,7 +398,7 @@ var d = (t, n) => {
419
398
  A.current?.disconnect(), A.current = null;
420
399
  }, []),
421
400
  incrementUnreadCount: L,
422
- isConnected: g,
401
+ isConnected: _,
423
402
  isReady: b,
424
403
  joinThread: M,
425
404
  leaveThread: N,
@@ -434,16 +413,16 @@ var d = (t, n) => {
434
413
  }), []),
435
414
  unreadCount: S
436
415
  };
437
- return /* @__PURE__ */ u(B.Provider, {
416
+ return /* @__PURE__ */ u(V.Provider, {
438
417
  value: R,
439
418
  children: e
440
419
  });
441
- }, ue = (e) => e && typeof e == "function", de = (e) => e && typeof e == "function", fe = ({ children: e, defaultQueriesOptions: t, defaultMutationsOptions: n, ...r }) => {
442
- let { libraries: i } = a(y), o = r?.QueryClient || i?.reactQuery?.QueryClient, s = r?.QueryClientProvider || i?.reactQuery?.QueryClientProvider;
420
+ }, le = (e) => e && typeof e == "function", ue = (e) => e && typeof e == "function", de = ({ children: e, defaultQueriesOptions: t, defaultMutationsOptions: n, ...r }) => {
421
+ let { libraries: i } = a(v), o = r?.QueryClient || i?.reactQuery?.QueryClient, s = r?.QueryClientProvider || i?.reactQuery?.QueryClientProvider;
443
422
  if (!o) throw Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
444
423
  if (!s) throw Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
445
- if (!ue(s)) throw Error("Provided QueryClientProvider dependencies are not valid.");
446
- if (!de(o)) throw Error("Provided QueryClient dependencies are not valid.");
424
+ if (!le(s)) throw Error("Provided QueryClientProvider dependencies are not valid.");
425
+ if (!ue(o)) throw Error("Provided QueryClient dependencies are not valid.");
447
426
  let l = c(null);
448
427
  return l.current ||= new o({ defaultOptions: {
449
428
  mutations: { ...n },
@@ -457,37 +436,37 @@ var d = (t, n) => {
457
436
  client: l.current,
458
437
  children: e
459
438
  });
460
- }, V = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), H = (e, t) => {
439
+ }, H = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), U = (e, t) => {
461
440
  let { fractionDigits: n = 0, metric: r = "km", spacingBetween: i = !0 } = t || {}, a = Number(e), o = i ? " " : "";
462
441
  return Number.isNaN(a) ? `0${o}${r}` : `${a.toFixed(n)}${o}${r}`;
463
- }, U = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), pe = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, me = ({ path: e, size: t, apiURL: n }) => {
442
+ }, W = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), fe = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, pe = ({ path: e, size: t, apiURL: n }) => {
464
443
  if (!e) return "";
465
- let r = `${n}${pe(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
444
+ let r = `${n}${fe(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
466
445
  return typeof t == "number" && i ? `${r.replace("/files", `/thumbs/${t}`)}` : r;
467
- }, he = (e) => {
468
- let { apiURL: t, libraries: n } = a(y), r = e?.dayjs || n?.dayjs;
446
+ }, me = (e) => {
447
+ let { apiURL: t, libraries: n } = a(v), r = e?.dayjs || n?.dayjs;
469
448
  return {
470
449
  dateAdapter: (e, t) => {
471
450
  if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
472
- return V({
451
+ return H({
473
452
  date: e,
474
453
  format: t,
475
454
  library: r
476
455
  });
477
456
  },
478
- distanceAdapter: H,
457
+ distanceAdapter: U,
479
458
  filePathAdapter: (e, n) => {
480
459
  if (!t) throw Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");
481
- return typeof e == "string" && /^https?:\/\//.test(e) ? e : me({
460
+ return typeof e == "string" && /^https?:\/\//.test(e) ? e : pe({
482
461
  apiURL: t,
483
462
  path: e,
484
463
  size: n
485
464
  });
486
465
  },
487
- worksiteNameAdapter: U
466
+ worksiteNameAdapter: W
488
467
  };
489
- }, ge = () => {
490
- let { libraries: e } = a(y), t = e?.amplitude?.analytics, n = i((e, n) => {
468
+ }, he = () => {
469
+ let { libraries: e } = a(v), t = e?.amplitude?.analytics, n = i((e, n) => {
491
470
  if (!t || (t.setUserId(e), !n)) return;
492
471
  let r = new t.Identify();
493
472
  Object.entries(n).forEach(([e, t]) => {
@@ -510,14 +489,14 @@ var d = (t, n) => {
510
489
  setGroup: r,
511
490
  track: o
512
491
  };
513
- }, _e = (e) => {
514
- let { libraries: t, localStorageKeys: n } = a(y), r = e?.axios || t?.axios, s = e?.localStorageKey || n?.user || "user";
492
+ }, ge = (e) => {
493
+ let { libraries: t, localStorageKeys: n } = a(v), r = e?.axios || t?.axios, s = e?.localStorageKey || n?.user || "user";
515
494
  if (!r) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
516
495
  let c = i(({ tokenType: e, accessToken: t }) => {
517
496
  r.defaults.headers.common.Authorization = `${e} ${t}`;
518
497
  }, [r.defaults.headers.common]);
519
498
  return o(() => {
520
- if (C) return;
499
+ if (A) return;
521
500
  let e = ({ newValue: e, key: t }) => {
522
501
  if (t === s && e) try {
523
502
  let { accessToken: t, tokenType: n } = JSON.parse(e);
@@ -538,9 +517,9 @@ var d = (t, n) => {
538
517
  },
539
518
  setAuthenticationToken: c
540
519
  };
541
- }, ve = "New message", ye = (e, t) => {
520
+ }, _e = "New message", ve = (e, t) => {
542
521
  if (!("Notification" in window) || typeof Notification != "function" || Notification.permission !== "granted" || !document.hidden) return;
543
- let n = new Notification(t.title ?? ve, {
522
+ let n = new Notification(t.title ?? _e, {
544
523
  badge: t?.badge,
545
524
  body: t?.body || e.bodyPreview,
546
525
  data: t?.data,
@@ -555,8 +534,8 @@ var d = (t, n) => {
555
534
  let { onClick: r } = t;
556
535
  n.onclick = () => r(e);
557
536
  }
558
- }, be = (e) => {
559
- let t = a(B);
537
+ }, ye = (e) => {
538
+ let t = a(V);
560
539
  if (!t) throw Error("useChat must be used within ChatProvider");
561
540
  let { subscribe: n, setEnabled: r, ...i } = t, s = c(e);
562
541
  return s.current = e, o(() => {
@@ -573,7 +552,7 @@ var d = (t, n) => {
573
552
  r?.(e);
574
553
  break;
575
554
  case "new_message_notification":
576
- i?.(e), t && t.enabled !== !1 && ye(e, t);
555
+ i?.(e), t && t.enabled !== !1 && ve(e, t);
577
556
  break;
578
557
  case "presence":
579
558
  a?.(e);
@@ -598,44 +577,44 @@ var d = (t, n) => {
598
577
  break;
599
578
  }
600
579
  }), [n]), i;
601
- }, W = (e, t) => t === "short" ? e.split("-")[0] : e, xe = (e, t = "full") => {
580
+ }, G = (e, t) => t === "short" ? e.split("-")[0] : e, be = (e, t = "full") => {
602
581
  let [n, r] = l(() => {
603
582
  let n = e?.language || navigator.language;
604
- return e && "isInitialized" in e && e.isInitialized, W(n, t);
583
+ return e && "isInitialized" in e && e.isInitialized, G(n, t);
605
584
  });
606
585
  return o(() => {
607
- e && "isInitialized" in e && e.isInitialized && e.language && r(W(e.language, t));
586
+ e && "isInitialized" in e && e.isInitialized && e.language && r(G(e.language, t));
608
587
  let n = (e) => {
609
- r(W(e, t));
588
+ r(G(e, t));
610
589
  };
611
590
  return e?.on?.("languageChanged", n), () => {
612
591
  e?.off?.("languageChanged", n);
613
592
  };
614
593
  }, [e, t]), n;
615
- }, Se = "tracktor.filter", Ce = {
594
+ }, xe = "tracktor.filter", Se = {
616
595
  getFilter: () => void 0,
617
596
  getFilters: () => ({}),
618
597
  handleFilter: () => () => {},
619
598
  setFilter: () => {}
620
- }, G = (e) => {
599
+ }, K = (e) => {
621
600
  try {
622
601
  return JSON.parse(e);
623
602
  } catch {
624
603
  return e;
625
604
  }
626
- }, K = (e, t, n) => `${n}_${e}=>${t}`, we = (e) => e.reduce((e, t) => {
605
+ }, q = (e, t, n) => `${n}_${e}=>${t}`, Ce = (e) => e.reduce((e, t) => {
627
606
  let n = localStorage.getItem(t);
628
607
  if (n) try {
629
608
  let t = JSON.parse(n), r = Object.keys(t)?.[0];
630
609
  r && (e[r] = Object.values(t)?.[0]);
631
610
  } catch {}
632
611
  return e;
633
- }, {}), q = (e) => {
634
- let { libraries: t, localStorageKeys: n } = a(y), r = e?.reactRouter || t?.reactRouter, { pathname: i } = r?.useLocation?.() ?? { pathname: "/" }, [o, s] = r?.useSearchParams?.() ?? [new URLSearchParams(), () => {}], [c, u] = l({}), d = n?.filter || Se, f = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, p = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
635
- if (C) return Ce;
612
+ }, {}), we = (e) => {
613
+ let { libraries: t, localStorageKeys: n } = a(v), r = e?.reactRouter || t?.reactRouter, { pathname: i } = r?.useLocation?.() ?? { pathname: "/" }, [o, s] = r?.useSearchParams?.() ?? [new URLSearchParams(), () => {}], [c, u] = l({}), d = n?.filter || xe, f = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, p = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
614
+ if (A) return Se;
636
615
  if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");
637
616
  let m = () => Object.keys(localStorage).filter((t) => t.startsWith(d) && t.endsWith(e?.pathname || i)), h = (t, n, r = !0) => {
638
- let a = K(t, e?.pathname || i, d);
617
+ let a = q(t, e?.pathname || i, d);
639
618
  if (!n || Array.isArray(n) && !n.length) {
640
619
  f ? (o.delete(t), s(o)) : u((e) => {
641
620
  let n = { ...e };
@@ -655,13 +634,13 @@ var d = (t, n) => {
655
634
  getFilter: (t, n) => {
656
635
  if (f) {
657
636
  let e = o.get(t);
658
- if (e) return G(e);
637
+ if (e) return K(e);
659
638
  } else {
660
639
  let e = c[t];
661
640
  if (e !== void 0) return e;
662
641
  }
663
642
  if (p) {
664
- let n = K(t, e?.pathname || i, d), r = localStorage.getItem(n);
643
+ let n = q(t, e?.pathname || i, d), r = localStorage.getItem(n);
665
644
  if (r) try {
666
645
  let e = JSON.parse(r)[t];
667
646
  return !f && e !== void 0 && u((n) => ({
@@ -673,9 +652,9 @@ var d = (t, n) => {
673
652
  return n;
674
653
  },
675
654
  getFilters: () => {
676
- let e = p ? we(m()) : {};
655
+ let e = p ? Ce(m()) : {};
677
656
  if (f) {
678
- let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] = G(n), e), {});
657
+ let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] = K(n), e), {});
679
658
  return {
680
659
  ...e,
681
660
  ...t
@@ -696,7 +675,7 @@ var d = (t, n) => {
696
675
  },
697
676
  setFilter: h
698
677
  };
699
- }, J = () => document.getElementById(D), Te = () => {
678
+ }, J = () => document.getElementById(P), Te = () => {
700
679
  let [e, t] = l(() => !!window.HubSpotConversations);
701
680
  return o(() => {
702
681
  if (window.HubSpotConversations) {
@@ -706,13 +685,13 @@ var d = (t, n) => {
706
685
  window.hsConversationsOnReady = [() => t(!0)];
707
686
  }, []), o(() => {
708
687
  e && window.HubSpotConversations?.on("widgetClosed", () => {
709
- J()?.classList.remove(O);
688
+ J()?.classList.remove(F);
710
689
  });
711
690
  }, [e]), {
712
691
  isAvailable: e,
713
692
  toggle: i(() => {
714
693
  let e = window.HubSpotConversations, t = J();
715
- e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(O)) : (t.classList.add(O), e.widget.open()));
694
+ e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(F)) : (t.classList.add(F), e.widget.open()));
716
695
  }, [])
717
696
  };
718
697
  }, Ee = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: a, enabled: o = !0 }) => {
@@ -732,7 +711,7 @@ var d = (t, n) => {
732
711
  rows: l
733
712
  };
734
713
  }, De = (e) => {
735
- let { libraries: t } = a(y), n = e?.i18 || t?.i18, r = e?.i18?.translateFunction || t?.i18?.translateFunction, o = n?.i18next?.t || r || ((e) => e), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = o(s), l = i((e) => {
714
+ let { libraries: t } = a(v), n = e?.i18 || t?.i18, r = e?.i18?.translateFunction || t?.i18?.translateFunction, o = n?.i18next?.t || r || ((e) => e), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = o(s), l = i((e) => {
736
715
  if (e && typeof e == "object" && "response" in e) {
737
716
  let { response: t } = e || {};
738
717
  if (t && typeof t == "object" && "reason" in t && t.reason) return String(t.reason);
@@ -756,7 +735,7 @@ var d = (t, n) => {
756
735
  printError: l
757
736
  };
758
737
  }, Y = "chunk-reload-timestamp", X = "chunk-reload", Oe = 1e4, Z = 2, Q = !1;
759
- if (!C && typeof window < "u") {
738
+ if (!A && typeof window < "u") {
760
739
  try {
761
740
  let e = new URL(window.location.href);
762
741
  e.searchParams.has(X) && (Q = !0, e.searchParams.delete(X), window.history.replaceState(null, "", e.toString()));
@@ -810,7 +789,7 @@ var ke = (e) => {
810
789
  } catch (e) {
811
790
  t = e;
812
791
  }
813
- if (C || !ke(t)) throw t;
792
+ if (A || !ke(t)) throw t;
814
793
  let n = je(e);
815
794
  if (n) try {
816
795
  let e = await Fe(n);
@@ -820,4 +799,4 @@ var ke = (e) => {
820
799
  return Date.now() - r < Oe || Q || (Ne(Y, String(Date.now())), await Le()), { default: () => null };
821
800
  });
822
801
  //#endregion
823
- export { _ as ChatClient, B as ChatContext, le as ChatProvider, x as GTMSendPageView, S as InitializeAmplitude, T as InitializeAxiosConfig, E as InitializeDaysJSConfig, A as InitializeHubSpot, j as InitializeI18nConfig, M as InitializeSentryConfig, y as InjectDependenciesContext, b as InjectDependenciesProvider, v as MaskTextField, fe as QueryProvider, F as RequireAuth, L as ShowHubSpotBubble, d as axiosCustomInstance, V as dateAdapter, H as distanceAdapter, ie as getOrvalConfig, Re as lazyWithRetry, he as useAdapter, ge as useAmplitude, _e as useAuth, be as useChat, xe as useCurrentLanguage, q as useFilters, Te as useHubSpot, Ee as useInfiniteDataGrid, De as useResponseError, U as worksiteNameAdapter };
802
+ export { D as AutoReloadOnNewVersion, g as ChatClient, V as ChatContext, ce as ChatProvider, O as GTMSendPageView, k as InitializeAmplitude, M as InitializeAxiosConfig, N as InitializeDaysJSConfig, L as InitializeHubSpot, R as InitializeI18nConfig, ee as InitializeSentryConfig, v as InjectDependenciesContext, y as InjectDependenciesProvider, _ as MaskTextField, de as QueryProvider, ne as RequireAuth, re as ShowHubSpotBubble, H as dateAdapter, U as distanceAdapter, e as getOrvalConfig, Re as lazyWithRetry, me as useAdapter, he as useAmplitude, ge as useAuth, ye as useChat, be as useCurrentLanguage, we as useFilters, Te as useHubSpot, Ee as useInfiniteDataGrid, De as useResponseError, W as worksiteNameAdapter };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Node-only entry point dedicated to orval.config.ts files.
3
+ * Unlike the main entry, it can rely on Node built-ins (fs, child_process),
4
+ * so it must never be imported from browser code.
5
+ */
6
+ export * from './orvalNode';
7
+ export * from './resolveOrvalInput';
@@ -1,4 +1,4 @@
1
- interface CustomOrvalConfig {
1
+ export interface CustomOrvalConfig {
2
2
  /**
3
3
  * Path to the openapi file(s)
4
4
  * @default "./openapi.json"
@@ -33,18 +33,22 @@ interface CustomOrvalConfig {
33
33
  */
34
34
  useQueryIds?: string[];
35
35
  /**
36
- * A custom Axios instance to be used instead of the default one provided by us.
37
- * This is useful to define dynamic baseUrl in the axios default instance.
36
+ * Path to the Axios instance file used as orval mutator.
37
+ * This is useful to define dynamic baseUrl in the axios instance.
38
38
  */
39
- customAxiosInstancePath?: string;
39
+ customAxiosInstancePath: string;
40
40
  /**
41
41
  * The default API name inferred from the "filename".
42
42
  * Orval can also retrieve OAS from a fully formed URL.
43
43
  */
44
44
  overrideApiName?: string;
45
45
  }
46
- interface OrvalConfig {
47
- [key: string]: CustomOrvalConfig;
46
+ /**
47
+ * Generated orval config, keyed by API name.
48
+ * Loosely typed to stay compatible with orval's defineConfig.
49
+ */
50
+ export interface OrvalConfig {
51
+ [key: string]: Record<string, any>;
48
52
  }
49
53
  /**
50
54
  * Convert a string to capitalize
@@ -77,5 +81,5 @@ export declare const getOrvalOperationName: (operation: unknown, route: string,
77
81
  /**
78
82
  * Get the orval config required for the generation
79
83
  */
80
- export declare const getOrvalConfig: (config?: CustomOrvalConfig | CustomOrvalConfig[]) => OrvalConfig;
84
+ export declare const getOrvalConfig: (config: CustomOrvalConfig | CustomOrvalConfig[]) => OrvalConfig;
81
85
  export default getOrvalConfig;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { CustomOrvalConfig, OrvalConfig } from './orval';
2
+ import { ResolveOrvalInputOptions } from './resolveOrvalInput';
3
+ /**
4
+ * Available APIs.
5
+ */
6
+ export type OrvalApiHost = "saas" | "auth" | "supplier";
7
+ export interface ResolveOrvalHostInputOptions extends Partial<ResolveOrvalInputOptions> {
8
+ /**
9
+ * API name, also used as default "overrideApiName" and to derive:
10
+ * - localFile: ./openapi.<host>.json
11
+ * - localUrl: https://<subdomain>.api.tracktor.test/openapi.json
12
+ * - upstreamUrl: https://<subdomain>.api.dev.tracktor.fr/openapi.json
13
+ * Each value can still be overridden individually.
14
+ */
15
+ host: OrvalApiHost;
16
+ }
17
+ export interface CustomOrvalNodeConfig extends Omit<CustomOrvalConfig, "input" | "overrideApiName"> {
18
+ /**
19
+ * Path or URL to the openapi file(s), or an object describing
20
+ * where to resolve it from (local file, local service, upstream service).
21
+ * @default "./openapi.json"
22
+ */
23
+ input?: string | ResolveOrvalInputOptions | ResolveOrvalHostInputOptions;
24
+ /**
25
+ * The API name, used for the generated folders (src/api/<name>).
26
+ * Defaults to "input.host" when provided.
27
+ */
28
+ overrideApiName?: string;
29
+ }
30
+ /**
31
+ * Node-only version of getOrvalConfig.
32
+ * In addition to a path or URL, "input" also accepts an object
33
+ * resolved through resolveOrvalInput. Order of priorities:
34
+ *
35
+ * 1) Local file
36
+ * 2) Local service (docker compose back environment)
37
+ * 3) Upstream deployed service (dev cluster)
38
+ */
39
+ export declare const getOrvalConfig: (config: CustomOrvalNodeConfig | CustomOrvalNodeConfig[]) => OrvalConfig;
40
+ export default getOrvalConfig;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ export interface ResolveOrvalInputOptions {
2
+ /**
3
+ * Path to a local OpenAPI schema file (e.g. "./openapi.saas.json").
4
+ * Takes priority over any URL when the file exists.
5
+ */
6
+ localFile?: string;
7
+ /**
8
+ * URL of the local service (docker compose back environment).
9
+ * Used when no local file is found and the service responds.
10
+ */
11
+ localUrl?: string;
12
+ /**
13
+ * URL of the upstream deployed service (dev cluster).
14
+ * Used as fallback.
15
+ */
16
+ upstreamUrl: string;
17
+ }
18
+ /**
19
+ * Probe HTTP service via cURL on process invocation.
20
+ * This function is synchronous, don't use it outside
21
+ * of an orval config resolution.
22
+ * @param url The full URL to fetch
23
+ * @param timeout Timeout in milliseconds
24
+ */
25
+ export declare const probeUrlSync: (url: string, timeout?: number) => boolean;
26
+ /**
27
+ * Resolve where to fetch the OpenAPI schema.
28
+ * Order of priorities:
29
+ *
30
+ * 1) Local file
31
+ * 2) Local service (docker compose back environment)
32
+ * 3) Upstream deployed service (dev cluster)
33
+ */
34
+ export declare const resolveOrvalInput: ({ localFile, localUrl, upstreamUrl }: ResolveOrvalInputOptions) => string;
35
+ export default resolveOrvalInput;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ //#region src/orval/orval.ts
2
+ var e = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), t = (e) => {
3
+ let t = e.split(/[/\\]/).pop() || "";
4
+ return t.substring(0, t.lastIndexOf("."));
5
+ }, n = (e) => {
6
+ let t = e.split("/").filter((e) => e.length > 0).map((e) => e.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("")).join("");
7
+ return t.charAt(0).toLowerCase() + t.slice(1);
8
+ }, r = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), i = (t, r, i, a) => {
9
+ let o = `${n(r)}${e(i)}`;
10
+ return t && typeof t == "object" && "operationId" in t && a?.includes(String(t.operationId)) ? `${o}AsQuery` : o;
11
+ }, a = (e, t) => {
12
+ let n = {};
13
+ return e?.forEach((e) => {
14
+ n[e] = { query: {
15
+ useInfinite: !0,
16
+ useInfiniteQueryParam: "offset",
17
+ useQuery: !0
18
+ } };
19
+ }), t?.filter((e) => !n[e]).forEach((e) => {
20
+ n[e] = { query: { useQuery: !0 } };
21
+ }), Object.keys(n).length ? n : void 0;
22
+ }, o = (e) => (Array.isArray(e) ? e : [e]).reduce((e, n) => {
23
+ let { output: o, useInfiniteIds: s, useQueryIds: c, input: l = "./openapi.json", customAxiosInstancePath: u, overrideApiName: d } = n || {}, f = d || r(l);
24
+ if (!u) throw Error(`Orval config "${f}": "customAxiosInstancePath" is required.`);
25
+ return {
26
+ ...e,
27
+ [f]: {
28
+ input: l,
29
+ output: {
30
+ baseUrl: o?.baseUrl,
31
+ client: "react-query",
32
+ mode: "tags-split",
33
+ override: {
34
+ ...(s?.length || c?.length) && { operations: a(s, c) },
35
+ header: (e) => [
36
+ "Generated by orval 🍺",
37
+ ...e.title ? [e.title] : [],
38
+ ...e.description ? [e.description] : []
39
+ ],
40
+ mutator: {
41
+ name: t(u),
42
+ path: u
43
+ },
44
+ operationName: (e, t, n) => i(e, t, n, c),
45
+ query: { useQuery: !0 }
46
+ },
47
+ schemas: o?.schemas || `src/api/${f}/model`,
48
+ target: o?.target || `src/api/${f}/services/api.ts`,
49
+ ...o
50
+ }
51
+ }
52
+ };
53
+ }, {});
54
+ //#endregion
55
+ export { o as t };
package/dist/orval.js ADDED
@@ -0,0 +1,38 @@
1
+ import { t as e } from "./orval-Bf_zcxLE.js";
2
+ import { execSync as t } from "child_process";
3
+ import { existsSync as n } from "fs";
4
+ //#region src/orval/resolveOrvalInput.ts
5
+ var r = (e, n = 1500) => {
6
+ try {
7
+ return t(`curl -I -s -o /dev/null -w "%{http_code}" ${e}`, {
8
+ encoding: "utf-8",
9
+ timeout: n
10
+ }).trim() === "200";
11
+ } catch {
12
+ return !1;
13
+ }
14
+ }, i = ({ localFile: e, localUrl: t, upstreamUrl: i }) => e && n(e) ? (console.log(`Hint: remove ${e} to change target by upstream (http) instead.`), e) : t && r(t) ? t : i, a = "api.tracktor.test", o = "api.dev.tracktor.fr", s = {
15
+ auth: "auth",
16
+ saas: "app",
17
+ supplier: "supplier"
18
+ }, c = (t) => e((Array.isArray(t) ? t : [t]).map(({ input: e, ...t }) => {
19
+ if (typeof e != "object") return {
20
+ ...t,
21
+ input: e
22
+ };
23
+ let { host: n, localFile: r, localUrl: c, upstreamUrl: l } = e;
24
+ if (!(n || l)) throw Error(`Orval config "${t.overrideApiName || "?"}": either "host" or "upstreamUrl" must be provided.`);
25
+ if (n && !s[n]) throw Error(`Orval config: unknown host "${n}". Available hosts: ${Object.keys(s).join(", ")}.`);
26
+ let u = t.overrideApiName ?? n, d = n && s[n];
27
+ return {
28
+ ...t,
29
+ input: i({
30
+ localFile: r ?? (u ? `./openapi.${u}.json` : void 0),
31
+ localUrl: c ?? (d ? `https://${d}.${a}/openapi.json` : void 0),
32
+ upstreamUrl: l ?? `https://${d}.${o}/openapi.json`
33
+ }),
34
+ overrideApiName: u
35
+ };
36
+ }));
37
+ //#endregion
38
+ export { c as getOrvalConfig, r as probeUrlSync, i as resolveOrvalInput };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getsoren/shared-module",
3
- "version": "2.43.4",
3
+ "version": "2.45.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./dist/main.d.ts",
@@ -13,6 +13,11 @@
13
13
  "types": "./dist/main.d.ts",
14
14
  "import": "./dist/main.js",
15
15
  "default": "./dist/main.js"
16
+ },
17
+ "./orval": {
18
+ "types": "./dist/orval/index.d.ts",
19
+ "import": "./dist/orval.js",
20
+ "default": "./dist/orval.js"
16
21
  }
17
22
  },
18
23
  "repository": {
@@ -1,5 +0,0 @@
1
- import { AxiosError, AxiosRequestConfig } from 'axios';
2
- export declare const axiosCustomInstance: <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig) => Promise<T>;
3
- export default axiosCustomInstance;
4
- export type ErrorType<Error> = AxiosError<Error>;
5
- export type BodyType<BodyData> = BodyData;
@@ -1,23 +0,0 @@
1
- import axios, { AxiosError, AxiosRequestConfig } from "axios";
2
-
3
- export const axiosCustomInstance = <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig): Promise<T> => {
4
- const source = axios.CancelToken.source();
5
-
6
- const promise = axios({
7
- ...config,
8
- ...options,
9
- cancelToken: source.token,
10
- }).then(({ data }) => data);
11
-
12
- // @ts-expect-error
13
- promise.cancel = () => {
14
- source.cancel("Query was cancelled");
15
- };
16
-
17
- return promise;
18
- };
19
-
20
- export default axiosCustomInstance;
21
-
22
- export type ErrorType<Error> = AxiosError<Error>;
23
- export type BodyType<BodyData> = BodyData;
@@ -1,2 +0,0 @@
1
- import { default as Orval } from './orval';
2
- export default Orval;