@getsoren/shared-module 2.43.4 → 2.44.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;
@@ -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,4 +1,3 @@
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';
@@ -21,8 +20,6 @@ export * from './components/Utils/RequireAuth';
21
20
  export { default as RequireAuth } from './components/Utils/RequireAuth';
22
21
  export * from './components/Utils/ShowHubSpotBubble';
23
22
  export { default as ShowHubSpotBubble } from './components/Utils/ShowHubSpotBubble';
24
- export * from './config/orval';
25
- export { default as getOrvalConfig } from './config/orval';
26
23
  export * from './context/ChatProvider';
27
24
  export { default as ChatProvider } from './context/ChatProvider';
28
25
  export * from './context/InjectDependenciesProvider';
@@ -46,6 +43,7 @@ export * from './hooks/useInfiniteDataGrid';
46
43
  export { default as useInfiniteDataGrid } from './hooks/useInfiniteDataGrid';
47
44
  export * from './hooks/useResponseError/useResponseError';
48
45
  export { default as useResponseError } from './hooks/useResponseError/useResponseError';
46
+ export { default as getOrvalConfig } from './orval/orval';
49
47
  export { default as dateAdapter } from './utils/adapter/dateAdapter';
50
48
  export { default as distanceAdapter } from './utils/adapter/distanceAdapter';
51
49
  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,12 @@ 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 = ({ data: e, ...t }) => {
126
+ let { libraries: n } = a(v), r = t?.reactRouter || n?.reactRouter, i = t?.gtm || n?.gtm;
136
127
  if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
137
128
  if (!i) throw Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
138
129
  let { useGoogleTagManager: s } = i, { useLocation: c, Outlet: l } = r, { pathname: d } = c(), { sendEvent: f } = s();
@@ -147,8 +138,8 @@ var d = (t, n) => {
147
138
  d,
148
139
  f
149
140
  ]), /* @__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;
141
+ }, x = ({ apiKey: e, platform: t = "desktop", sessionReplaySampleRate: n = .25, ...r }) => {
142
+ let { libraries: i } = a(v), s = r.amplitude || i?.amplitude;
152
143
  return o(() => {
153
144
  let r = s?.analytics, i = s?.sessionReplayPlugin;
154
145
  if (!(e && r)) return;
@@ -172,23 +163,23 @@ var d = (t, n) => {
172
163
  t,
173
164
  n
174
165
  ]), null;
175
- }, C = (() => {
166
+ }, S = (() => {
176
167
  try {
177
168
  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
169
  } catch {
179
170
  return !1;
180
171
  }
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;
172
+ })(), C = "user", w = ({ tokenTypeKey: e = "tokenType", tokenKey: t = "accessToken", postContentType: n = "application/json", ...r }) => {
173
+ let { apiURL: i = r.apiURL, libraries: o, localStorageKeys: s } = a(v), c = r?.userLocalStorageKey || s?.user || C, l = r?.axios || o?.axios;
183
174
  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;
175
+ if (!l?.defaults || S) return null;
185
176
  if (typeof window < "u" && window.localStorage) {
186
177
  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
178
  o && (l.defaults.headers.common.Authorization = o);
188
179
  }
189
180
  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;
181
+ }, T = ({ language: e, ...t }) => {
182
+ let { libraries: n } = a(v), r = t?.dayjs || n?.dayjs, i = t?.plugin || n?.dayjsPlugin;
192
183
  if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");
193
184
  return o(() => {
194
185
  (async () => {
@@ -203,7 +194,7 @@ var d = (t, n) => {
203
194
  e,
204
195
  t.localizedFormat
205
196
  ]), null;
206
- }, D = "hubspot-messages-iframe-container", O = "hs-show", k = "data-hs-hidden", A = ({ hubId: e }) => (o(() => {
197
+ }, E = "hubspot-messages-iframe-container", D = "hs-show", O = "data-hs-hidden", k = ({ hubId: e }) => (o(() => {
207
198
  if (!e) return;
208
199
  let t = document.createElement("script");
209
200
  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 +203,14 @@ var d = (t, n) => {
212
203
  }, [e]), o(() => {
213
204
  let e = document.createElement("style");
214
205
  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);
206
+ html[${O}] div#${E} { display: none !important; }
207
+ html[${O}] div#${E}.${D} { display: initial !important; }
208
+ `, document.head.appendChild(e), document.documentElement.setAttribute(O, ""), () => {
209
+ e.remove(), document.documentElement.removeAttribute(O);
219
210
  };
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;
211
+ }, []), null), A = ({ debug: e, resources: t, ...n }) => {
212
+ let { libraries: r } = a(v), i = n?.i18 || r?.i18, { i18next: o, initReactI18next: s, languageDetector: c } = i || {};
213
+ if (S) return null;
223
214
  if (!(i && o && c && s)) throw Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
224
215
  return o.isInitialized ? null : (o.use(c).use(s).init({
225
216
  debug: e,
@@ -237,12 +228,12 @@ var d = (t, n) => {
237
228
  }), o.on("languageChanged", (e) => {
238
229
  document.documentElement.setAttribute("lang", e);
239
230
  }), 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;
231
+ }, j = ({ dsn: e, integrations: t, tracesSampleRate: n, replaysSessionSampleRate: r, replaysOnErrorSampleRate: i, tracePropagationTargets: s, ignoreErrors: c, debug: l, environment: u, release: d, ...f }) => {
232
+ let { libraries: p } = a(v), m = f?.sentry || p?.sentry, h = f?.reactRouter || p?.reactRouter;
242
233
  if (!m) throw Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
243
234
  if (!h) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
244
235
  if (m.isInitialized()) return null;
245
- let { createRoutesFromChildren: g, matchRoutes: _, useLocation: v, useNavigationType: b } = h;
236
+ let { createRoutesFromChildren: g, matchRoutes: _, useLocation: y, useNavigationType: b } = h;
246
237
  return (l || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && m.init({
247
238
  debug: l,
248
239
  dsn: e,
@@ -260,7 +251,7 @@ var d = (t, n) => {
260
251
  createRoutesFromChildren: g,
261
252
  matchRoutes: _,
262
253
  useEffect: o,
263
- useLocation: v,
254
+ useLocation: y,
264
255
  useNavigationType: b
265
256
  }), ...t || []],
266
257
  release: d,
@@ -269,99 +260,49 @@ var d = (t, n) => {
269
260
  tracePropagationTargets: s,
270
261
  tracesSampleRate: n || 1
271
262
  }), 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;
263
+ }, M = /* @__PURE__ */ new WeakMap(), N = "user", P = ({ Fallback: e, isLogged: n, loginPath: r = "/login", redirect401Path: i = "/login", ...s }) => {
264
+ let { libraries: c, localStorageKeys: d } = a(v), f = s?.reactRouter || c?.reactRouter, p = s?.axios || c?.axios, m = s?.localStorageKey || d?.user || N;
274
265
  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;
266
+ 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
267
  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)))));
268
+ p && (M.has(p) || (M.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
269
  }, [
279
270
  p,
280
271
  m,
281
272
  i
282
273
  ]), C && !h ? /* @__PURE__ */ u(t, {
283
274
  fallback: e,
284
- children: x.state?.from?.state && x.state?.from?.pathname === r ? /* @__PURE__ */ u(v, {
275
+ children: x.state?.from?.state && x.state?.from?.pathname === r ? /* @__PURE__ */ u(y, {
285
276
  to: x.state.from.state.from.pathname + x.state.from.state.from.search,
286
277
  replace: !0
287
278
  }) : /* @__PURE__ */ u(b, {})
288
- }) : /* @__PURE__ */ u(v, {
279
+ }) : /* @__PURE__ */ u(y, {
289
280
  to: r + x.search,
290
281
  state: { from: x },
291
282
  replace: !0
292
283
  });
293
- }, I = /* @__PURE__ */ new Set(), L = () => (o(() => {
284
+ }, F = /* @__PURE__ */ new Set(), I = () => (o(() => {
294
285
  let e = Symbol();
295
- return I.add(e), document.documentElement.removeAttribute(k), () => {
296
- I.delete(e), I.size === 0 && document.documentElement.setAttribute(k, "");
286
+ return F.add(e), document.documentElement.removeAttribute(O), () => {
287
+ F.delete(e), F.size === 0 && document.documentElement.setAttribute(O, "");
297
288
  };
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
- }
347
- };
348
- }, {}), ae = "user", oe = {
289
+ }, []), null), ee = "user", te = {
349
290
  client: "/v2/threads/ws",
350
291
  supplier: "/v1/threads/ws"
351
- }, se = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, ce = (e) => {
292
+ }, ne = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, re = (e) => {
352
293
  try {
353
294
  let t = localStorage.getItem(e);
354
295
  return t ? JSON.parse(t)?.accessToken ?? null : null;
355
296
  } catch {
356
297
  return null;
357
298
  }
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());
299
+ }, L = n(null), R = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: s, reconnectBaseDelay: d, maxMessageBodyLength: f = 1e4, reconnect: p = !0, enabled: m = !0, context: h = "client" }) => {
300
+ 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 || ee, A = c(null), j = c(/* @__PURE__ */ new Set());
360
301
  o(() => {
361
302
  if (!E) return;
362
- let e = r ?? oe[h], i = n || (D ? se(D, e) : null);
303
+ let e = r ?? te[h], i = n || (D ? ne(D, e) : null);
363
304
  if (!i) return;
364
- let a = () => t ?? ce(k), o = (e) => {
305
+ let a = () => t ?? re(k), o = (e) => {
365
306
  switch (e.type) {
366
307
  case "ready":
367
308
  x(!0), C(e.unreadCount ?? 0);
@@ -369,12 +310,12 @@ var d = (t, n) => {
369
310
  }
370
311
  for (let t of j.current) t(e);
371
312
  }, c = setTimeout(() => {
372
- let e = new _({
313
+ let e = new g({
373
314
  getToken: a,
374
315
  maxMessageBodyLength: f,
375
316
  maxReconnectAttempts: s,
376
317
  onConnectionChange: (e) => {
377
- v(e), e || x(!1);
318
+ y(e), e || x(!1);
378
319
  },
379
320
  onEvent: o,
380
321
  reconnect: p,
@@ -409,17 +350,17 @@ var d = (t, n) => {
409
350
  A.current?.markRead(e);
410
351
  }, []), I = i((e, t) => {
411
352
  A.current?.listThreads(e, t);
412
- }, []), L = i((e = 1) => {
353
+ }, []), R = i((e = 1) => {
413
354
  C((t) => t + e);
414
- }, []), R = {
355
+ }, []), z = {
415
356
  decrementUnreadCount: i((e = 1) => {
416
357
  C((t) => Math.max(0, t - e));
417
358
  }, []),
418
359
  disconnect: i(() => {
419
360
  A.current?.disconnect(), A.current = null;
420
361
  }, []),
421
- incrementUnreadCount: L,
422
- isConnected: g,
362
+ incrementUnreadCount: R,
363
+ isConnected: _,
423
364
  isReady: b,
424
365
  joinThread: M,
425
366
  leaveThread: N,
@@ -434,16 +375,16 @@ var d = (t, n) => {
434
375
  }), []),
435
376
  unreadCount: S
436
377
  };
437
- return /* @__PURE__ */ u(B.Provider, {
438
- value: R,
378
+ return /* @__PURE__ */ u(L.Provider, {
379
+ value: z,
439
380
  children: e
440
381
  });
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;
382
+ }, z = (e) => e && typeof e == "function", ie = (e) => e && typeof e == "function", ae = ({ children: e, defaultQueriesOptions: t, defaultMutationsOptions: n, ...r }) => {
383
+ let { libraries: i } = a(v), o = r?.QueryClient || i?.reactQuery?.QueryClient, s = r?.QueryClientProvider || i?.reactQuery?.QueryClientProvider;
443
384
  if (!o) throw Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
444
385
  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.");
386
+ if (!z(s)) throw Error("Provided QueryClientProvider dependencies are not valid.");
387
+ if (!ie(o)) throw Error("Provided QueryClient dependencies are not valid.");
447
388
  let l = c(null);
448
389
  return l.current ||= new o({ defaultOptions: {
449
390
  mutations: { ...n },
@@ -457,37 +398,37 @@ var d = (t, n) => {
457
398
  client: l.current,
458
399
  children: e
459
400
  });
460
- }, V = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), H = (e, t) => {
401
+ }, B = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), V = (e, t) => {
461
402
  let { fractionDigits: n = 0, metric: r = "km", spacingBetween: i = !0 } = t || {}, a = Number(e), o = i ? " " : "";
462
403
  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 }) => {
404
+ }, H = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), oe = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, se = ({ path: e, size: t, apiURL: n }) => {
464
405
  if (!e) return "";
465
- let r = `${n}${pe(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
406
+ let r = `${n}${oe(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
466
407
  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;
408
+ }, ce = (e) => {
409
+ let { apiURL: t, libraries: n } = a(v), r = e?.dayjs || n?.dayjs;
469
410
  return {
470
411
  dateAdapter: (e, t) => {
471
412
  if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
472
- return V({
413
+ return B({
473
414
  date: e,
474
415
  format: t,
475
416
  library: r
476
417
  });
477
418
  },
478
- distanceAdapter: H,
419
+ distanceAdapter: V,
479
420
  filePathAdapter: (e, n) => {
480
421
  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({
422
+ return typeof e == "string" && /^https?:\/\//.test(e) ? e : se({
482
423
  apiURL: t,
483
424
  path: e,
484
425
  size: n
485
426
  });
486
427
  },
487
- worksiteNameAdapter: U
428
+ worksiteNameAdapter: H
488
429
  };
489
- }, ge = () => {
490
- let { libraries: e } = a(y), t = e?.amplitude?.analytics, n = i((e, n) => {
430
+ }, le = () => {
431
+ let { libraries: e } = a(v), t = e?.amplitude?.analytics, n = i((e, n) => {
491
432
  if (!t || (t.setUserId(e), !n)) return;
492
433
  let r = new t.Identify();
493
434
  Object.entries(n).forEach(([e, t]) => {
@@ -510,14 +451,14 @@ var d = (t, n) => {
510
451
  setGroup: r,
511
452
  track: o
512
453
  };
513
- }, _e = (e) => {
514
- let { libraries: t, localStorageKeys: n } = a(y), r = e?.axios || t?.axios, s = e?.localStorageKey || n?.user || "user";
454
+ }, U = (e) => {
455
+ let { libraries: t, localStorageKeys: n } = a(v), r = e?.axios || t?.axios, s = e?.localStorageKey || n?.user || "user";
515
456
  if (!r) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
516
457
  let c = i(({ tokenType: e, accessToken: t }) => {
517
458
  r.defaults.headers.common.Authorization = `${e} ${t}`;
518
459
  }, [r.defaults.headers.common]);
519
460
  return o(() => {
520
- if (C) return;
461
+ if (S) return;
521
462
  let e = ({ newValue: e, key: t }) => {
522
463
  if (t === s && e) try {
523
464
  let { accessToken: t, tokenType: n } = JSON.parse(e);
@@ -538,9 +479,9 @@ var d = (t, n) => {
538
479
  },
539
480
  setAuthenticationToken: c
540
481
  };
541
- }, ve = "New message", ye = (e, t) => {
482
+ }, ue = "New message", de = (e, t) => {
542
483
  if (!("Notification" in window) || typeof Notification != "function" || Notification.permission !== "granted" || !document.hidden) return;
543
- let n = new Notification(t.title ?? ve, {
484
+ let n = new Notification(t.title ?? ue, {
544
485
  badge: t?.badge,
545
486
  body: t?.body || e.bodyPreview,
546
487
  data: t?.data,
@@ -555,8 +496,8 @@ var d = (t, n) => {
555
496
  let { onClick: r } = t;
556
497
  n.onclick = () => r(e);
557
498
  }
558
- }, be = (e) => {
559
- let t = a(B);
499
+ }, fe = (e) => {
500
+ let t = a(L);
560
501
  if (!t) throw Error("useChat must be used within ChatProvider");
561
502
  let { subscribe: n, setEnabled: r, ...i } = t, s = c(e);
562
503
  return s.current = e, o(() => {
@@ -573,7 +514,7 @@ var d = (t, n) => {
573
514
  r?.(e);
574
515
  break;
575
516
  case "new_message_notification":
576
- i?.(e), t && t.enabled !== !1 && ye(e, t);
517
+ i?.(e), t && t.enabled !== !1 && de(e, t);
577
518
  break;
578
519
  case "presence":
579
520
  a?.(e);
@@ -598,7 +539,7 @@ var d = (t, n) => {
598
539
  break;
599
540
  }
600
541
  }), [n]), i;
601
- }, W = (e, t) => t === "short" ? e.split("-")[0] : e, xe = (e, t = "full") => {
542
+ }, W = (e, t) => t === "short" ? e.split("-")[0] : e, pe = (e, t = "full") => {
602
543
  let [n, r] = l(() => {
603
544
  let n = e?.language || navigator.language;
604
545
  return e && "isInitialized" in e && e.isInitialized, W(n, t);
@@ -612,7 +553,7 @@ var d = (t, n) => {
612
553
  e?.off?.("languageChanged", n);
613
554
  };
614
555
  }, [e, t]), n;
615
- }, Se = "tracktor.filter", Ce = {
556
+ }, me = "tracktor.filter", he = {
616
557
  getFilter: () => void 0,
617
558
  getFilters: () => ({}),
618
559
  handleFilter: () => () => {},
@@ -623,16 +564,16 @@ var d = (t, n) => {
623
564
  } catch {
624
565
  return e;
625
566
  }
626
- }, K = (e, t, n) => `${n}_${e}=>${t}`, we = (e) => e.reduce((e, t) => {
567
+ }, K = (e, t, n) => `${n}_${e}=>${t}`, ge = (e) => e.reduce((e, t) => {
627
568
  let n = localStorage.getItem(t);
628
569
  if (n) try {
629
570
  let t = JSON.parse(n), r = Object.keys(t)?.[0];
630
571
  r && (e[r] = Object.values(t)?.[0]);
631
572
  } catch {}
632
573
  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;
574
+ }, {}), _e = (e) => {
575
+ 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 || me, f = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, p = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
576
+ if (S) return he;
636
577
  if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");
637
578
  let m = () => Object.keys(localStorage).filter((t) => t.startsWith(d) && t.endsWith(e?.pathname || i)), h = (t, n, r = !0) => {
638
579
  let a = K(t, e?.pathname || i, d);
@@ -673,7 +614,7 @@ var d = (t, n) => {
673
614
  return n;
674
615
  },
675
616
  getFilters: () => {
676
- let e = p ? we(m()) : {};
617
+ let e = p ? ge(m()) : {};
677
618
  if (f) {
678
619
  let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] = G(n), e), {});
679
620
  return {
@@ -696,7 +637,7 @@ var d = (t, n) => {
696
637
  },
697
638
  setFilter: h
698
639
  };
699
- }, J = () => document.getElementById(D), Te = () => {
640
+ }, q = () => document.getElementById(E), ve = () => {
700
641
  let [e, t] = l(() => !!window.HubSpotConversations);
701
642
  return o(() => {
702
643
  if (window.HubSpotConversations) {
@@ -706,16 +647,16 @@ var d = (t, n) => {
706
647
  window.hsConversationsOnReady = [() => t(!0)];
707
648
  }, []), o(() => {
708
649
  e && window.HubSpotConversations?.on("widgetClosed", () => {
709
- J()?.classList.remove(O);
650
+ q()?.classList.remove(D);
710
651
  });
711
652
  }, [e]), {
712
653
  isAvailable: e,
713
654
  toggle: i(() => {
714
- 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()));
655
+ let e = window.HubSpotConversations, t = q();
656
+ e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(D)) : (t.classList.add(D), e.widget.open()));
716
657
  }, [])
717
658
  };
718
- }, Ee = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: a, enabled: o = !0 }) => {
659
+ }, ye = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: a, enabled: o = !0 }) => {
719
660
  let c = i(async (e) => {
720
661
  n || !o || await t({ pageParam: e?.pageParam || e.visibleRowsCount });
721
662
  }, [
@@ -731,8 +672,8 @@ var d = (t, n) => {
731
672
  loadingVariant: r ? "skeleton" : "linear-progress",
732
673
  rows: l
733
674
  };
734
- }, 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) => {
675
+ }, be = (e) => {
676
+ 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
677
  if (e && typeof e == "object" && "response" in e) {
737
678
  let { response: t } = e || {};
738
679
  if (t && typeof t == "object" && "reason" in t && t.reason) return String(t.reason);
@@ -755,38 +696,38 @@ var d = (t, n) => {
755
696
  }, []),
756
697
  printError: l
757
698
  };
758
- }, Y = "chunk-reload-timestamp", X = "chunk-reload", Oe = 1e4, Z = 2, Q = !1;
759
- if (!C && typeof window < "u") {
699
+ }, J = "chunk-reload-timestamp", Y = "chunk-reload", xe = 1e4, X = 2, Z = !1;
700
+ if (!S && typeof window < "u") {
760
701
  try {
761
702
  let e = new URL(window.location.href);
762
- e.searchParams.has(X) && (Q = !0, e.searchParams.delete(X), window.history.replaceState(null, "", e.toString()));
703
+ e.searchParams.has(Y) && (Z = !0, e.searchParams.delete(Y), window.history.replaceState(null, "", e.toString()));
763
704
  } catch {}
764
705
  window.addEventListener("vite:preloadError", (e) => {
765
706
  e.preventDefault();
766
707
  });
767
708
  }
768
- var ke = (e) => {
709
+ var Se = (e) => {
769
710
  if (!(e instanceof Error)) return !1;
770
711
  let t = e.message.toLowerCase();
771
712
  return t.includes("dynamically imported module") || t.includes("importing a module script failed") || t.includes("loading chunk") || t.includes("loading css chunk") || t.includes("unable to preload css") || t.includes("failed to fetch") || t.includes("error loading dynamically imported module") || t.includes("load failed") || t.includes("without a valid default export") || e.name === "ChunkLoadError";
772
- }, Ae = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, je = (e) => e.toString().match(Ae)?.[2] ?? null, Me = (e) => {
713
+ }, Ce = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, we = (e) => e.toString().match(Ce)?.[2] ?? null, Q = (e) => {
773
714
  try {
774
715
  return sessionStorage.getItem(e);
775
716
  } catch {
776
717
  return null;
777
718
  }
778
- }, Ne = (e, t) => {
719
+ }, Te = (e, t) => {
779
720
  try {
780
721
  sessionStorage.setItem(e, t);
781
722
  } catch {}
782
- }, Pe = (e) => Function("url", "return import(url)")(e), Fe = async (e) => {
783
- for (let t = 0; t < Z; t++) try {
784
- return await Pe(`${e}?t=${Date.now()}`);
723
+ }, Ee = (e) => Function("url", "return import(url)")(e), De = async (e) => {
724
+ for (let t = 0; t < X; t++) try {
725
+ return await Ee(`${e}?t=${Date.now()}`);
785
726
  } catch {
786
- t < Z - 1 && await new Promise((e) => setTimeout(e, 500 * 2 ** t));
727
+ t < X - 1 && await new Promise((e) => setTimeout(e, 500 * 2 ** t));
787
728
  }
788
- throw Error(`Failed to import ${e} after ${Z} retries`);
789
- }, Ie = async () => {
729
+ throw Error(`Failed to import ${e} after ${X} retries`);
730
+ }, Oe = async () => {
790
731
  try {
791
732
  if (typeof navigator < "u" && "serviceWorker" in navigator) {
792
733
  let e = await navigator.serviceWorker.getRegistrations();
@@ -797,11 +738,11 @@ var ke = (e) => {
797
738
  await Promise.all(e.map((e) => caches.delete(e)));
798
739
  }
799
740
  } catch {}
800
- }, Le = async () => {
801
- await Ie();
741
+ }, ke = async () => {
742
+ await Oe();
802
743
  let e = new URL(window.location.href);
803
- e.searchParams.set(X, String(Date.now())), window.location.replace(e.toString());
804
- }, $ = (e) => e != null && e.default !== void 0, Re = (e) => r(async () => {
744
+ e.searchParams.set(Y, String(Date.now())), window.location.replace(e.toString());
745
+ }, $ = (e) => e != null && e.default !== void 0, Ae = (e) => r(async () => {
805
746
  let t;
806
747
  try {
807
748
  let n = await e();
@@ -810,14 +751,14 @@ var ke = (e) => {
810
751
  } catch (e) {
811
752
  t = e;
812
753
  }
813
- if (C || !ke(t)) throw t;
814
- let n = je(e);
754
+ if (S || !Se(t)) throw t;
755
+ let n = we(e);
815
756
  if (n) try {
816
- let e = await Fe(n);
757
+ let e = await De(n);
817
758
  if ($(e)) return e;
818
759
  } catch {}
819
- let r = Number(Me(Y) || "0");
820
- return Date.now() - r < Oe || Q || (Ne(Y, String(Date.now())), await Le()), { default: () => null };
760
+ let r = Number(Q(J) || "0");
761
+ return Date.now() - r < xe || Z || (Te(J, String(Date.now())), await ke()), { default: () => null };
821
762
  });
822
763
  //#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 };
764
+ export { g as ChatClient, L as ChatContext, R as ChatProvider, b as GTMSendPageView, x as InitializeAmplitude, w as InitializeAxiosConfig, T as InitializeDaysJSConfig, k as InitializeHubSpot, A as InitializeI18nConfig, j as InitializeSentryConfig, v as InjectDependenciesContext, y as InjectDependenciesProvider, _ as MaskTextField, ae as QueryProvider, P as RequireAuth, I as ShowHubSpotBubble, B as dateAdapter, V as distanceAdapter, e as getOrvalConfig, Ae as lazyWithRetry, ce as useAdapter, le as useAmplitude, U as useAuth, fe as useChat, pe as useCurrentLanguage, _e as useFilters, ve as useHubSpot, ye as useInfiniteDataGrid, be as useResponseError, H 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,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.44.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;
File without changes