@getsoren/shared-module 2.43.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +154 -0
  3. package/dist/axios/axiosCustomInstance.d.ts +5 -0
  4. package/dist/axiosCustomInstance.ts +23 -0
  5. package/dist/chat/ChatClient.d.ts +35 -0
  6. package/dist/chat/tests/ChatClient.test.d.ts +1 -0
  7. package/dist/chat/types.d.ts +116 -0
  8. package/dist/components/Inputs/MaskTextField.d.ts +32 -0
  9. package/dist/components/Utils/GTMSendPageView.d.ts +23 -0
  10. package/dist/components/Utils/InitializeAmplitude.d.ts +27 -0
  11. package/dist/components/Utils/InitializeAxiosConfig.d.ts +41 -0
  12. package/dist/components/Utils/InitializeDaysJSConfig.d.ts +27 -0
  13. package/dist/components/Utils/InitializeHubSpot.d.ts +27 -0
  14. package/dist/components/Utils/InitializeI18nConfig.d.ts +26 -0
  15. package/dist/components/Utils/InitializeSentryConfig.d.ts +81 -0
  16. package/dist/components/Utils/RequireAuth.d.ts +48 -0
  17. package/dist/components/Utils/ShowHubSpotBubble.d.ts +10 -0
  18. package/dist/config/orval/index.d.ts +2 -0
  19. package/dist/config/orval/orval.d.ts +81 -0
  20. package/dist/config/orval/orval.test.d.ts +1 -0
  21. package/dist/constants/hubspot.d.ts +12 -0
  22. package/dist/context/ChatProvider.d.ts +33 -0
  23. package/dist/context/InjectDependenciesProvider.d.ts +72 -0
  24. package/dist/context/QueryClientProviderWithConfig.d.ts +26 -0
  25. package/dist/hooks/tests/useFilters.test.d.ts +1 -0
  26. package/dist/hooks/useAdapter.d.ts +22 -0
  27. package/dist/hooks/useAmplitude.d.ts +16 -0
  28. package/dist/hooks/useAuth.d.ts +20 -0
  29. package/dist/hooks/useChat.d.ts +13 -0
  30. package/dist/hooks/useCurrentLanguage/useCurrentLanguage.d.ts +13 -0
  31. package/dist/hooks/useCurrentLanguage/useCurrentLanguage.test.d.ts +1 -0
  32. package/dist/hooks/useFilters.d.ts +44 -0
  33. package/dist/hooks/useHubSpot.d.ts +9 -0
  34. package/dist/hooks/useInfiniteDataGrid.d.ts +30 -0
  35. package/dist/hooks/useResponseError/useResponseError.d.ts +33 -0
  36. package/dist/hooks/useResponseError/useResponseError.test.d.ts +1 -0
  37. package/dist/main.d.ts +52 -0
  38. package/dist/main.js +823 -0
  39. package/dist/utils/adapter/dateAdapter.d.ts +17 -0
  40. package/dist/utils/adapter/distanceAdapter.d.ts +12 -0
  41. package/dist/utils/adapter/worksiteNameAdapter/worksiteNameAdapter.d.ts +9 -0
  42. package/dist/utils/adapter/worksiteNameAdapter/worksiteNameAdapter.test.d.ts +1 -0
  43. package/dist/utils/isReactNative.d.ts +5 -0
  44. package/dist/utils/lazyWithRetry.d.ts +18 -0
  45. package/package.json +117 -0
@@ -0,0 +1,17 @@
1
+ type DateType = string | number | Date | null | undefined;
2
+ type Library = (date: DateType) => {
3
+ format: (format: string) => string;
4
+ };
5
+ interface DateAdapterParams<T> {
6
+ library: T;
7
+ date: DateType;
8
+ format?: string;
9
+ }
10
+ /**
11
+ * Format date to own specific format
12
+ * @param library
13
+ * @param date
14
+ * @param format
15
+ */
16
+ export declare const dateAdapter: <T extends Library>({ library, date, format }: DateAdapterParams<T>) => string;
17
+ export default dateAdapter;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Adapter for distance
3
+ * Get distance and metric and return formatted distance
4
+ * @param distance
5
+ * @param options
6
+ */
7
+ declare const distanceAdapter: (distance?: string | number | null, options?: {
8
+ fractionDigits?: number;
9
+ metric?: string;
10
+ spacingBetween?: boolean;
11
+ }) => string;
12
+ export default distanceAdapter;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Adapts the worksite name to a more readable format.
3
+ * Simply replaces underscores with spaces and capitalizes the first letter of each word.
4
+ *
5
+ * @param name - The worksite name to format
6
+ * @returns The formatted worksite name
7
+ */
8
+ declare const worksiteNameAdapter: (name: unknown) => string;
9
+ export default worksiteNameAdapter;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * React Native detection
3
+ */
4
+ export declare const isReactNative: boolean;
5
+ export default isReactNative;
@@ -0,0 +1,18 @@
1
+ import { ComponentType } from 'react';
2
+ /**
3
+ * Lazy loader with retry mechanism for dynamic imports.
4
+ *
5
+ * On chunk loading failure:
6
+ * 1. First, retries the import() itself with a cache-busting query param.
7
+ * This handles transient network errors without any visible page reload.
8
+ * 2. If retries fail (e.g. chunk was deleted after a deployment), falls back
9
+ * to a full page reload with cache-busting to fetch fresh HTML with new chunk references.
10
+ * 3. Uses a timestamp-based cooldown (with module-level fallback) to prevent infinite reload loops.
11
+ *
12
+ * Also guards against corrupt module resolution (e.g. import resolving with undefined
13
+ * instead of a proper module object), which is treated the same as a chunk load error.
14
+ */
15
+ declare const lazyWithRetry: (importFn: () => Promise<{
16
+ default: ComponentType<any>;
17
+ }>) => import('react').LazyExoticComponent<ComponentType<any>>;
18
+ export default lazyWithRetry;
package/package.json ADDED
@@ -0,0 +1,117 @@
1
+ {
2
+ "name": "@getsoren/shared-module",
3
+ "version": "2.43.4",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "types": "./dist/main.d.ts",
7
+ "module": "./dist/main.js",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/main.d.ts",
14
+ "import": "./dist/main.js",
15
+ "default": "./dist/main.js"
16
+ }
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/getsoren/shared-module.git"
21
+ },
22
+ "author": "Mickaël Austoni",
23
+ "bugs": {
24
+ "url": "https://github.com/getsoren/shared-module/issues"
25
+ },
26
+ "homepage": "https://github.com/getsoren/shared-module#readme",
27
+ "scripts": {
28
+ "dev": "bunx vite",
29
+ "build": "bunx vite build",
30
+ "lint": "bunx biome check --diagnostic-level=error . && bunx tsc --noEmit --incremental",
31
+ "lint:fix": "bunx biome check . --write",
32
+ "preview": "bunx vite preview",
33
+ "test": "bun run lint && bunx vitest",
34
+ "prepare": "bun run build && bunx husky install",
35
+ "release": "commit-and-tag-version"
36
+ },
37
+ "devDependencies": {
38
+ "@amplitude/analytics-browser": "^2.11.0",
39
+ "@amplitude/plugin-session-replay-browser": "^1.8.0",
40
+ "@sentry/react": "^10.49.0",
41
+ "@tanstack/react-query": "^5.99.2",
42
+ "@testing-library/jest-dom": "^5.17.0",
43
+ "@testing-library/react": "^14.0.0",
44
+ "@testing-library/user-event": "^14.5.1",
45
+ "@getsoren/biome-config-react": "^1.4.0",
46
+ "@getsoren/react-google-tag-manager": "^1.4.6",
47
+ "@types/react": "^19.0.0",
48
+ "@types/react-dom": "^19.0.0",
49
+ "@vitejs/plugin-react": "^6.0.1",
50
+ "axios": "^1.15.1",
51
+ "dayjs": "^1.11.20",
52
+ "husky": "^8.0.3",
53
+ "i18next": "^26.0.6",
54
+ "i18next-browser-languagedetector": "^8.2.1",
55
+ "jsdom": "^22.1.0",
56
+ "react": "^19.0.0",
57
+ "react-dom": "^19.0.0",
58
+ "react-i18next": "^17.0.4",
59
+ "react-router": "^7.14.2",
60
+ "typescript": "^5.8.3",
61
+ "unplugin-dts": "1.0.0-beta.6",
62
+ "vite": "8.0.9",
63
+ "vitest": "^1.6.1",
64
+ "commit-and-tag-version": "^12.6.0"
65
+ },
66
+ "peerDependencies": {
67
+ "axios": "*",
68
+ "@amplitude/analytics-browser": "*",
69
+ "@amplitude/plugin-session-replay-browser": "*",
70
+ "@sentry/react": "*",
71
+ "@tanstack/react-query": "*",
72
+ "@getsoren/react-google-tag-manager": "*",
73
+ "dayjs": "*",
74
+ "i18next": "*",
75
+ "i18next-browser-languagedetector": "*",
76
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
77
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
78
+ "react-i18next": "*",
79
+ "react-router": "*"
80
+ },
81
+ "peerDependenciesMeta": {
82
+ "@amplitude/analytics-browser": {
83
+ "optional": true
84
+ },
85
+ "@amplitude/plugin-session-replay-browser": {
86
+ "optional": true
87
+ },
88
+ "@sentry/react": {
89
+ "optional": true
90
+ },
91
+ "@tanstack/react-query": {
92
+ "optional": true
93
+ },
94
+ "@getsoren/react-google-tag-manager": {
95
+ "optional": true
96
+ },
97
+ "dayjs": {
98
+ "optional": true
99
+ },
100
+ "i18next": {
101
+ "optional": true
102
+ },
103
+ "i18next-browser-languagedetector": {
104
+ "optional": true
105
+ },
106
+ "react-i18next": {
107
+ "optional": true
108
+ },
109
+ "react-router": {
110
+ "optional": true
111
+ }
112
+ },
113
+ "commit-and-tag-version": {
114
+ "releaseCommitMessageFormat": "chore(release): {{currentTag}} [skip ci]",
115
+ "tagPrefix": ""
116
+ }
117
+ }