@cayuse-test/react 1.0.2 → 1.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cayuse-test/react",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -10,33 +10,8 @@
10
10
  "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.js"
12
12
  },
13
- "./components": {
14
- "types": "./dist/components/index.d.ts",
15
- "import": "./dist/components/index.js"
16
- },
17
- "./hooks": {
18
- "types": "./dist/hooks/index.d.ts",
19
- "import": "./dist/hooks/index.js"
20
- },
21
- "./utils": {
22
- "types": "./dist/utils/index.d.ts",
23
- "import": "./dist/utils/index.js"
24
- },
25
- "./context/tenant": {
26
- "types": "./dist/context/tenant/index.d.ts",
27
- "import": "./dist/context/tenant/index.js"
28
- },
29
- "./globals/constants": {
30
- "types": "./dist/globals/constants/index.d.ts",
31
- "import": "./dist/globals/constants/index.js"
32
- },
33
- "./globals/css": {
34
- "types": "./dist/globals/css/index.d.ts",
35
- "import": "./dist/globals/css/index.js"
36
- },
37
- "./services/upload-s3": {
38
- "types": "./dist/services/upload-s3/index.d.ts",
39
- "import": "./dist/services/upload-s3/index.js"
13
+ "./css": {
14
+ "import": "./dist/index.css"
40
15
  },
41
16
  "./eslint-config/*": {
42
17
  "import": "./packages/eslint-config/*.js"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../packages/utils/auth/auth.tsx"],"sourcesContent":["import React, { useState, useEffect, useContext, useCallback } from 'react';\nimport { jwtDecode } from 'jwt-decode';\nimport { isNonEmptyString } from '@/utils/type-checks';\nimport { AUTH_DOMAIN } from '@/globals/constants';\n\ninterface User {\n\tusername: string;\n\ttenantId?: string;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t[key: string]: any;\n}\n\ninterface AuthContextValue {\n\tisAuthenticated: boolean;\n\tloading: boolean;\n\tuser: User | null;\n\tloginWithRedirect: (params: LoginParams) => void;\n\trefreshToken: () => Promise<boolean>;\n}\n\ninterface LoginParams {\n\ttenantId?: string;\n\tisGuest?: boolean;\n}\n\ninterface CayuseHeader {\n\tproduct: string;\n\thost: string;\n\tuserId: string;\n\tauthenticationToken: string;\n}\n\ninterface AuthProviderProps {\n\tchildren: React.ReactNode;\n\tPRODUCT_KEY: string;\n\tsetCayuseHeader: (header: CayuseHeader) => void;\n\ttokenRefreshUrl?: string;\n\tisGuest?: boolean;\n}\n\nexport const AuthContext = React.createContext<AuthContextValue | undefined>(\n\tundefined,\n);\n\nexport const useAuth = () => {\n\tconst context = useContext(AuthContext);\n\tif (!context) {\n\t\tthrow new Error('useAuth must be used within an AuthProvider');\n\t}\n\treturn context;\n};\n\nconst CAYUSE_LOGOUT_URL = `https://${AUTH_DOMAIN}/logout` as const;\nconst CAYUSE_LOGIN_URL = `https://${AUTH_DOMAIN}/authorize` as const;\nexport const ACCESS_TOKEN = 'fk_accessToken' as const;\nconst ACCESS_TOKEN_EXP = 'fk_accessTokenExp' as const;\n\nexport function loginWithRedirect({ tenantId, isGuest }: LoginParams): void {\n\tconst currentUrl = window.location.href;\n\tconst encodedUri = encodeURIComponent(currentUrl);\n\tlet url = `${CAYUSE_LOGIN_URL}?redirect_uri=${encodedUri}&response_type=TOKEN`;\n\n\tif (isNonEmptyString(tenantId)) {\n\t\turl += `&tenant_id=${tenantId}`;\n\t}\n\n\tif (isGuest) {\n\t\turl += '&guest=true';\n\t}\n\n\twindow.location.replace(url);\n}\n\nexport const AuthProvider: React.FC<AuthProviderProps> = ({\n\tchildren,\n\tPRODUCT_KEY,\n\tsetCayuseHeader,\n\ttokenRefreshUrl,\n\tisGuest,\n}) => {\n\tconst [isAuthenticated, setIsAuthenticated] = useState<boolean>(false);\n\tconst [loading, setLoading] = useState<boolean>(true);\n\tconst [user, setUser] = useState<User | null>(null);\n\tconst [accessToken, setAccessToken] = useState<string | null>(null);\n\tconst [refreshingToken, setRefreshingToken] = useState<boolean>(false);\n\n\tconst retrieveAccessTokenFromLocationHash = (): void => {\n\t\tconst { hash } = window.location;\n\n\t\tif (hash) {\n\t\t\tconst tokens = hash.substring(1, hash.length).split('&');\n\t\t\tfor (const token of tokens) {\n\t\t\t\tif (token) {\n\t\t\t\t\tconst [key, value] = token.split('=');\n\t\t\t\t\tif (key === 'access_token' && value) {\n\t\t\t\t\t\tconst newAccessToken = value;\n\t\t\t\t\t\tlocalStorage.setItem(ACCESS_TOKEN, newAccessToken);\n\t\t\t\t\t\tconst decodedToken = jwtDecode<{ exp: number }>(newAccessToken);\n\t\t\t\t\t\tlocalStorage.setItem(ACCESS_TOKEN_EXP, decodedToken.exp.toString());\n\t\t\t\t\t\tsetAccessToken(newAccessToken);\n\t\t\t\t\t\tsetIsAuthenticated(true);\n\n\t\t\t\t\t\tconst url = new URL(window.location.href);\n\t\t\t\t\t\twindow.history.replaceState(\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\tdocument.title,\n\t\t\t\t\t\t\turl.pathname + url.search,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\tconst isAccessTokenExpired = (): boolean => {\n\t\tconst accessTokenFromStorage = localStorage.getItem(ACCESS_TOKEN);\n\n\t\tif (!accessTokenFromStorage) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst accessTokenExpirationFromStorage = localStorage.getItem(ACCESS_TOKEN_EXP);\n\t\tlet timeUntilTokenExpires: number;\n\n\t\tif (accessTokenExpirationFromStorage) {\n\t\t\ttimeUntilTokenExpires =\n\t\t\t\tparseInt(accessTokenExpirationFromStorage, 10) -\n\t\t\t\tMath.floor(new Date().getTime() / 1000);\n\t\t} else {\n\t\t\tconst decodedToken = jwtDecode<{ exp: number }>(accessTokenFromStorage);\n\t\t\ttimeUntilTokenExpires =\n\t\t\t\tdecodedToken.exp - Math.floor(new Date().getTime() / 1000);\n\t\t}\n\n\t\treturn timeUntilTokenExpires < 60;\n\t};\n\n\tconst refreshTokenSilently = useCallback(async (): Promise<boolean> => {\n\t\tif (refreshingToken) return false;\n\n\t\ttry {\n\t\t\tsetRefreshingToken(true);\n\n\t\t\tlet refreshUrl = isNonEmptyString(tokenRefreshUrl)\n\t\t\t\t? tokenRefreshUrl!\n\t\t\t\t: `${window.location.protocol}//${window.location.host}/api/refresh-token`;\n\n\t\t\tif (user?.tenantId) {\n\t\t\t\trefreshUrl += `?tenant_id=${user.tenantId}`;\n\t\t\t}\n\n\t\t\tif (isGuest) {\n\t\t\t\trefreshUrl += refreshUrl.includes('?') ? '&guest=true' : '?guest=true';\n\t\t\t}\n\n\t\t\tif (!refreshUrl) {\n\t\t\t\tthrow new Error('Refresh URL is undefined');\n\t\t\t}\n\n\t\t\tconst response = await fetch(refreshUrl, {\n\t\t\t\tmethod: 'GET',\n\t\t\t\tcredentials: 'include',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\tAuthorization: `Bearer ${localStorage.getItem(ACCESS_TOKEN)}`,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error('Token refresh failed');\n\t\t\t}\n\n\t\t\tconst data: { access_token?: string } = await response.json();\n\n\t\t\tif (data.access_token) {\n\t\t\t\tlocalStorage.setItem(ACCESS_TOKEN, data.access_token);\n\t\t\t\tconst decodedToken = jwtDecode<{ exp: number }>(data.access_token);\n\t\t\t\tlocalStorage.setItem(ACCESS_TOKEN_EXP, decodedToken.exp.toString());\n\t\t\t\tsetAccessToken(data.access_token);\n\t\t\t\tsetIsAuthenticated(true);\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} catch (error) {\n\t\t\tconsole.error('Error refreshing token:', error);\n\t\t\treturn false;\n\t\t} finally {\n\t\t\tsetRefreshingToken(false);\n\t\t}\n\t}, [refreshingToken, tokenRefreshUrl, user, isGuest]);\n\n\tuseEffect(() => {\n\t\tconst initAuth = async (): Promise<void> => {\n\t\t\tif (window.location.hash.includes('access_token=')) {\n\t\t\t\tretrieveAccessTokenFromLocationHash();\n\t\t\t\tsetLoading(false);\n\t\t\t} else if (localStorage.getItem(ACCESS_TOKEN)) {\n\t\t\t\tif (isAccessTokenExpired()) {\n\t\t\t\t\tsetIsAuthenticated(false);\n\t\t\t\t\tsetLoading(false);\n\t\t\t\t} else {\n\t\t\t\t\tconst accessTokenFromStorage = localStorage.getItem(ACCESS_TOKEN)!;\n\t\t\t\t\tsetAccessToken(accessTokenFromStorage);\n\t\t\t\t\tsetIsAuthenticated(true);\n\t\t\t\t\tsetLoading(false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsetIsAuthenticated(false);\n\t\t\t\tsetLoading(false);\n\t\t\t}\n\t\t};\n\n\t\tinitAuth();\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (accessToken) {\n\t\t\tconst token = localStorage.getItem(ACCESS_TOKEN);\n\t\t\tif (isNonEmptyString(token) && token === accessToken) {\n\t\t\t\tconst decodedUser = jwtDecode<User>(token);\n\t\t\t\tsetIsAuthenticated(true);\n\t\t\t\tsetUser(decodedUser);\n\n\t\t\t\tconst host = window.location.origin;\n\t\t\t\tsetCayuseHeader({\n\t\t\t\t\tproduct: PRODUCT_KEY,\n\t\t\t\t\thost,\n\t\t\t\t\tuserId: decodedUser.username,\n\t\t\t\t\tauthenticationToken: token,\n\t\t\t\t});\n\t\t\t} else if (user?.tenantId) {\n\t\t\t\tloginWithRedirect({ tenantId: user.tenantId, isGuest });\n\t\t\t}\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [accessToken, isGuest]);\n\n\tuseEffect(() => {\n\t\tif (isAuthenticated) {\n\t\t\tconst interval = setInterval(async () => {\n\t\t\t\tif (isAccessTokenExpired()) {\n\t\t\t\t\tconst refreshed = await refreshTokenSilently();\n\t\t\t\t\tif (!refreshed) {\n\t\t\t\t\t\tsetAccessToken(null);\n\t\t\t\t\t\tlocalStorage.removeItem(ACCESS_TOKEN);\n\t\t\t\t\t\tlocalStorage.removeItem(ACCESS_TOKEN_EXP);\n\t\t\t\t\t\tsetIsAuthenticated(false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, 5_000);\n\n\t\t\treturn () => clearInterval(interval);\n\t\t}\n\t}, [isAuthenticated, refreshTokenSilently]);\n\n\tconst logout = useCallback((event: CustomEvent): void => {\n\t\tif (event.detail === '/logout') {\n\t\t\tsetAccessToken(null);\n\t\t\tlocalStorage.removeItem(ACCESS_TOKEN);\n\t\t\tlocalStorage.removeItem(ACCESS_TOKEN_EXP);\n\t\t\twindow.location.href = CAYUSE_LOGOUT_URL;\n\t\t}\n\t}, []) as EventListener;\n\n\tuseEffect(() => {\n\t\twindow.addEventListener('navigationChange', logout);\n\n\t\treturn () => window.removeEventListener('navigationChange', logout);\n\t}, [logout]);\n\n\t// Context value with proper typing\n\tconst contextValue: AuthContextValue = {\n\t\tisAuthenticated,\n\t\tloading,\n\t\tuser,\n\t\tloginWithRedirect: (params: LoginParams) =>\n\t\t\tloginWithRedirect({\n\t\t\t\t...params,\n\t\t\t\tisGuest: params.isGuest || isGuest,\n\t\t\t}),\n\t\trefreshToken: refreshTokenSilently,\n\t};\n\n\treturn (\n\t\t<AuthContext.Provider value={contextValue}>{children}</AuthContext.Provider>\n\t);\n};\n\nexport const withAuth = <P extends object>(\n\tComponent: React.ComponentType<P & { context: AuthContextValue }>,\n) => {\n\treturn (props: P) => (\n\t\t<AuthContext.Consumer>\n\t\t\t{(context) => <Component {...props} context={context!} />}\n\t\t</AuthContext.Consumer>\n\t);\n};\n"],"mappings":";;;;;;;;AAAA,OAAO,SAAS,UAAU,WAAW,YAAY,mBAAmB;AACpE,SAAS,iBAAiB;AA4RxB;AArPK,IAAM,cAAc,MAAM;AAAA,EAChC;AACD;AAEO,IAAM,UAAU,MAAM;AAC5B,Q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A,IAC5B,CAAC;AAAA,IACF,cAAc;AAAA,EACf;AAEA,SACC,oBAAC,YAAY,UAAZ,EAAqB,OAAO,cAAe,UAAS;AAEvD;AAEO,IAAM,WAAW,CACvB,cACI;AACJ,SAAO,CAAC,UACP,oBAAC,YAAY,UAAZ,EACC,WAAC,YAAY,oBAAC,aAAW,GAAG,OAAO,SAAmB,GACxD;AAEF;","names":[]}
@@ -1,193 +0,0 @@
1
- // packages/utils/type-checks/index.ts
2
- var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
3
- var isString = (value) => typeof value === "string";
4
- var isNumber = (value) => typeof value === "number";
5
- var isBool = (value) => typeof value === "boolean";
6
- var { isArray } = Array;
7
- var isNonEmptyArray = (value) => Array.isArray(value) && value.length > 0;
8
- var isNonEmptyMap = (value) => value instanceof Map && value.size > 0;
9
- var isFunction = (value) => typeof value === "function";
10
- var isObject = (object) => object && typeof object === "object";
11
- var isNonEmptyObject = (object) => object && isObject(object) && Object.keys(object).length > 0;
12
- var isObjectWithKey = (object, key) => isObject(object) && key in object;
13
- var isMap = (value) => isObject(value) && value instanceof Map;
14
- var isUrl = (string) => {
15
- try {
16
- return Boolean(new URL(string));
17
- } catch {
18
- return false;
19
- }
20
- };
21
-
22
- // packages/utils/http/constants.ts
23
- var ERROR_NOT_AUTHORIZED = "The action is not authorized. Please contact an administrator to check your permissions.";
24
- var ERROR_INTERNAL_SERVER_ERROR = "Internal server error";
25
- var ERROR_STATUS_CODE_400 = 400;
26
- var ERROR_STATUS_CODE_401 = 401;
27
- var ERROR_STATUS_CODE_403 = 403;
28
- var ERROR_STATUS_CODE_500 = 500;
29
- var ERROR_FORBIDDEN_FILE_EXTENSION = "FORBIDDEN_FILE_EXTENSION";
30
- var NODE_ENV = process.env.NODE_ENV;
31
- var APP_ENV = process.env.REACT_APP_ENVIRONMENT;
32
- var IS_DEV = NODE_ENV === "development" || NODE_ENV === "test" || APP_ENV === "develop";
33
- var IS_LIVE = !IS_DEV && APP_ENV === "live";
34
- var IS_PROD_SG = !IS_DEV && APP_ENV === "prod-sg";
35
- var PROD_ENV = IS_PROD_SG || IS_LIVE;
36
-
37
- // packages/utils/http/index.ts
38
- var notify = (
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- global.__CAYUSE__?.notify ?? (() => {
41
- console.error(
42
- "function is not defined. check is banner-notification package install"
43
- );
44
- })
45
- );
46
- var registerGetTokenSilently = (getTokenSilentlyFunction) => {
47
- global.__CAYUSE__ = global.__CAYUSE__ ?? {};
48
- if (isFunction(getTokenSilentlyFunction)) {
49
- global.__CAYUSE__.appGetTokenSilently = getTokenSilentlyFunction;
50
- }
51
- };
52
- var CayuseError = class extends Error {
53
- name;
54
- message;
55
- cause;
56
- response;
57
- meta;
58
- constructor(message, httpResponseObject = null) {
59
- super(message);
60
- this.name = "CayuseError";
61
- this.message = message;
62
- this.cause = httpResponseObject;
63
- this.response = httpResponseObject;
64
- this.meta = {
65
- spRequestId: httpResponseObject?.headers?.get("x-sp-request-id") ?? "",
66
- flowableDesignRequestId: httpResponseObject?.headers?.get("x-flowable-design-request-id") ?? "",
67
- flowableEngageRequestId: httpResponseObject?.headers?.get("x-flowable-engage-request-id") ?? ""
68
- };
69
- }
70
- };
71
- function isCayuseError(error) {
72
- return error instanceof CayuseError || error && error.name === "CayuseError" && error.message;
73
- }
74
- var checkErrorBody = async (error) => {
75
- const contentType = error.headers.get("Content-Type");
76
- if (contentType && contentType.includes("json")) {
77
- const errorBody = await error.json().catch(() => ({})) ?? {};
78
- if (errorBody.error === ERROR_FORBIDDEN_FILE_EXTENSION) {
79
- notify(errorBody.message ?? "", { type: "error" });
80
- }
81
- if (errorBody.message) {
82
- notify(errorBody.message, { type: "error" });
83
- }
84
- } else if (contentType && contentType.includes("text/plain")) {
85
- const text = await error.text();
86
- notify(text, { type: "error" });
87
- } else {
88
- notify(ERROR_NOT_AUTHORIZED, { type: "error" });
89
- }
90
- };
91
- var checkResponseStatus = async (response, notifyUponError) => {
92
- if (response.status === ERROR_STATUS_CODE_401 && notifyUponError) {
93
- notify("", { type: "login" });
94
- } else if ((response.status === ERROR_STATUS_CODE_403 || response.status === ERROR_STATUS_CODE_400) && notifyUponError) {
95
- await checkErrorBody(response);
96
- } else if (response.status === ERROR_STATUS_CODE_500) {
97
- const err = new CayuseError(ERROR_INTERNAL_SERVER_ERROR, response);
98
- if (notifyUponError) {
99
- notify(ERROR_INTERNAL_SERVER_ERROR, { type: "error" });
100
- }
101
- throw err;
102
- }
103
- if (!response.ok) {
104
- throw new CayuseError(response.statusText, response);
105
- }
106
- return response;
107
- };
108
- var fetchWithRetry = (url, options, args = {}) => {
109
- const { numRetries, attemptNumber, notifyUponError } = {
110
- numRetries: 2,
111
- attemptNumber: 1,
112
- notifyUponError: !PROD_ENV,
113
- ...args
114
- };
115
- const retryTimeoutInSeconds = Math.pow(2, attemptNumber - 1);
116
- return fetch(url, options).then((res) => checkResponseStatus(res, notifyUponError)).then((response) => {
117
- const contentType = response.headers.get("Content-Type");
118
- if (contentType && contentType.includes("json")) {
119
- return response.json().catch(() => ({}));
120
- }
121
- return response.text();
122
- }).catch((error) => {
123
- if (error.message === ERROR_INTERNAL_SERVER_ERROR) {
124
- if (numRetries === 0) {
125
- if (notifyUponError) {
126
- notify(error.message, { type: "error" });
127
- }
128
- throw error;
129
- }
130
- return new Promise((resolve) => {
131
- setTimeout(
132
- () => resolve(
133
- fetchWithRetry(url, options, {
134
- numRetries: numRetries - 1,
135
- attemptNumber: attemptNumber + 1,
136
- notifyUponError
137
- })
138
- ),
139
- retryTimeoutInSeconds * 1e3
140
- );
141
- });
142
- }
143
- throw error;
144
- });
145
- };
146
- var executeRequest = (url, options = {}, args = {}) => {
147
- const doFetch = (token) => {
148
- const allOptions = {
149
- ...options,
150
- headers: {
151
- ...options.headers || {},
152
- Authorization: `Bearer ${token}`,
153
- "X-IDP-New-Login": "true"
154
- }
155
- };
156
- if (options.method !== "GET" && !args.numRetries) {
157
- args.numRetries = 0;
158
- }
159
- return fetchWithRetry(url, allOptions, args);
160
- };
161
- let getTokenPromise = Promise.resolve("");
162
- if (isFunction(global.__CAYUSE__?.appGetTokenSilently)) {
163
- const returnValue = global.__CAYUSE__.appGetTokenSilently();
164
- getTokenPromise = returnValue instanceof Promise ? returnValue : Promise.resolve(returnValue);
165
- }
166
- return getTokenPromise.then((token) => doFetch(token));
167
- };
168
- var request = async (url, options = {}, args = {}) => {
169
- return executeRequest(url, options, args);
170
- };
171
-
172
- export {
173
- isNonEmptyString,
174
- isString,
175
- isNumber,
176
- isBool,
177
- isArray,
178
- isNonEmptyArray,
179
- isNonEmptyMap,
180
- isFunction,
181
- isObject,
182
- isNonEmptyObject,
183
- isObjectWithKey,
184
- isMap,
185
- isUrl,
186
- registerGetTokenSilently,
187
- CayuseError,
188
- isCayuseError,
189
- checkErrorBody,
190
- executeRequest,
191
- request
192
- };
193
- //# sourceMappingURL=chunk-SZMEZFAR.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../packages/utils/type-checks/index.ts","../packages/utils/http/constants.ts","../packages/utils/http/index.ts"],"sourcesContent":["export const isNonEmptyString = (value: unknown): value is string =>\n\ttypeof value === 'string' && value.length > 0;\n\nexport const isString = (value: unknown): value is string =>\n\ttypeof value === 'string';\n\nexport const isNumber = (value: unknown): value is number =>\n\ttypeof value === 'number';\n\nexport const isBool = (value: unknown): value is boolean =>\n\ttypeof value === 'boolean';\n\nexport const { isArray } = Array;\n\nexport const isNonEmptyArray = (value: unknown) =>\n\tArray.isArray(value) && value.length > 0;\n\nexport const isNonEmptyMap = (value: unknown) =>\n\tvalue instanceof Map && value.size > 0;\n\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\nexport const isObject = (object: object) => object && typeof object === 'object';\n\nexport const isNonEmptyObject = (object?: object) =>\n\tobject && isObject(object) && Object.keys(object).length > 0;\n\nexport const isObjectWithKey = <T extends object>(object: T, key: string) =>\n\tisObject(object) && key in object;\n\nexport const isMap = (value: object) => isObject(value) && value instanceof Map;\n\nexport const isUrl = (string: string) => {\n\ttry {\n\t\treturn Boolean(new URL(string));\n\t} catch {\n\t\treturn false;\n\t}\n};\n","export const ERROR_NOT_AUTHORIZED =\n\t'The action is not authorized. Please contact an administrator to check your permissions.';\nexport const ERROR_INTERNAL_SERVER_ERROR = 'Internal server error';\nexport const ERROR_STATUS_CODE_400 = 400;\nexport const ERROR_STATUS_CODE_401 = 401;\nexport const ERROR_STATUS_CODE_403 = 403;\nexport const ERROR_STATUS_CODE_500 = 500;\nexport const ERROR_FORBIDDEN_FILE_EXTENSION = 'FORBIDDEN_FILE_EXTENSION';\n\nconst NODE_ENV = process.env.NODE_ENV;\nconst APP_ENV = process.env.REACT_APP_ENVIRONMENT;\n\nconst IS_DEV =\n\tNODE_ENV === 'development' || NODE_ENV === 'test' || APP_ENV === 'develop';\nconst IS_LIVE = !IS_DEV && APP_ENV === 'live';\nconst IS_PROD_SG = !IS_DEV && APP_ENV === 'prod-sg';\n\nexport const PROD_ENV = IS_PROD_SG || IS_LIVE;\n","import { isFunction } from '@/utils/type-checks';\nimport {\n\tERROR_FORBIDDEN_FILE_EXTENSION,\n\tERROR_INTERNAL_SERVER_ERROR,\n\tERROR_NOT_AUTHORIZED,\n\tERROR_STATUS_CODE_400,\n\tERROR_STATUS_CODE_401,\n\tERROR_STATUS_CODE_403,\n\tERROR_STATUS_CODE_500,\n\tPROD_ENV,\n} from './constants.js';\n\ninterface CayuseGlobal {\n\tappGetTokenSilently?: () => string | Promise<string>;\n}\n\ndeclare global {\n\tvar global: typeof globalThis & {\n\t\t__CAYUSE__: CayuseGlobal | undefined;\n\t};\n}\n\nconst notify =\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t(global as any).__CAYUSE__?.notify ??\n\t(() => {\n\t\tconsole.error(\n\t\t\t'function is not defined. check is banner-notification package install',\n\t\t);\n\t});\n\n/**\n * Apps must \"register\" a global function to get tokens in the background using registerGetTokenSilently\n */\nexport const registerGetTokenSilently = (\n\tgetTokenSilentlyFunction: () => string | Promise<string>,\n): void => {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t(global as any).__CAYUSE__ = (global as any).__CAYUSE__ ?? {};\n\n\tif (isFunction(getTokenSilentlyFunction)) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t(global as any).__CAYUSE__.appGetTokenSilently = getTokenSilentlyFunction;\n\t}\n};\n\nexport class CayuseError extends Error {\n\tname: string;\n\tmessage: string;\n\tcause: Response | null;\n\tresponse: Response | null;\n\tmeta: {\n\t\tspRequestId: string;\n\t\tflowableDesignRequestId: string;\n\t\tflowableEngageRequestId: string;\n\t};\n\n\tconstructor(message: string, httpResponseObject: Response | null = null) {\n\t\tsuper(message);\n\n\t\tthis.name = 'CayuseError';\n\t\tthis.message = message;\n\t\tthis.cause = httpResponseObject;\n\t\tthis.response = httpResponseObject;\n\t\tthis.meta = {\n\t\t\tspRequestId: httpResponseObject?.headers?.get('x-sp-request-id') ?? '',\n\t\t\tflowableDesignRequestId:\n\t\t\t\thttpResponseObject?.headers?.get('x-flowable-design-request-id') ?? '',\n\t\t\tflowableEngageRequestId:\n\t\t\t\thttpResponseObject?.headers?.get('x-flowable-engage-request-id') ?? '',\n\t\t};\n\t}\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isCayuseError(error: any): error is CayuseError {\n\treturn (\n\t\terror instanceof CayuseError ||\n\t\t(error && error.name === 'CayuseError' && error.message)\n\t);\n}\n\nexport const checkErrorBody = async (error: Response): Promise<void> => {\n\tconst contentType = error.headers.get('Content-Type');\n\n\tif (contentType && contentType.includes('json')) {\n\t\tconst errorBody: { error?: string; message?: string } =\n\t\t\t(await error.json().catch(() => ({}))) ?? {};\n\n\t\tif (errorBody.error === ERROR_FORBIDDEN_FILE_EXTENSION) {\n\t\t\tnotify(errorBody.message ?? '', { type: 'error' });\n\t\t}\n\n\t\tif (errorBody.message) {\n\t\t\tnotify(errorBody.message, { type: 'error' });\n\t\t}\n\t} else if (contentType && contentType.includes('text/plain')) {\n\t\tconst text = await error.text();\n\t\tnotify(text, { type: 'error' });\n\t} else {\n\t\tnotify(ERROR_NOT_AUTHORIZED, { type: 'error' });\n\t}\n};\n\nconst checkResponseStatus = async (\n\tresponse: Response,\n\tnotifyUponError: boolean,\n): Promise<Response> => {\n\tif (response.status === ERROR_STATUS_CODE_401 && notifyUponError) {\n\t\tnotify('', { type: 'login' });\n\t} else if (\n\t\t(response.status === ERROR_STATUS_CODE_403 ||\n\t\t\tresponse.status === ERROR_STATUS_CODE_400) &&\n\t\tnotifyUponError\n\t) {\n\t\tawait checkErrorBody(response);\n\t} else if (response.status === ERROR_STATUS_CODE_500) {\n\t\tconst err = new CayuseError(ERROR_INTERNAL_SERVER_ERROR, response);\n\n\t\tif (notifyUponError) {\n\t\t\tnotify(ERROR_INTERNAL_SERVER_ERROR, { type: 'error' });\n\t\t}\n\t\tthrow err;\n\t}\n\n\tif (!response.ok) {\n\t\tthrow new CayuseError(response.statusText, response);\n\t}\n\n\treturn response;\n};\n\ninterface FetchArgs {\n\tnumRetries?: number;\n\tattemptNumber?: number;\n\tnotifyUponError?: boolean;\n}\n\nconst fetchWithRetry = (\n\turl: string,\n\toptions: RequestInit,\n\targs: FetchArgs = {},\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Promise<any> => {\n\tconst { numRetries, attemptNumber, notifyUponError } = {\n\t\tnumRetries: 2,\n\t\tattemptNumber: 1,\n\t\tnotifyUponError: !PROD_ENV,\n\t\t...args,\n\t};\n\n\tconst retryTimeoutInSeconds = Math.pow(2, attemptNumber - 1);\n\n\treturn fetch(url, options)\n\t\t.then((res) => checkResponseStatus(res, notifyUponError))\n\t\t.then((response) => {\n\t\t\tconst contentType = response.headers.get('Content-Type');\n\n\t\t\tif (contentType && contentType.includes('json')) {\n\t\t\t\treturn response.json().catch(() => ({}));\n\t\t\t}\n\t\t\treturn response.text();\n\t\t})\n\t\t.catch((error: CayuseError) => {\n\t\t\tif (error.message === ERROR_INTERNAL_SERVER_ERROR) {\n\t\t\t\tif (numRetries === 0) {\n\t\t\t\t\tif (notifyUponError) {\n\t\t\t\t\t\tnotify(error.message, { type: 'error' });\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\n\t\t\t\treturn new Promise((resolve) => {\n\t\t\t\t\tsetTimeout(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\tfetchWithRetry(url, options, {\n\t\t\t\t\t\t\t\t\tnumRetries: numRetries - 1,\n\t\t\t\t\t\t\t\t\tattemptNumber: attemptNumber + 1,\n\t\t\t\t\t\t\t\t\tnotifyUponError,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tretryTimeoutInSeconds * 1000,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n};\n\nexport const executeRequest = (\n\turl: string,\n\toptions: RequestInit = {},\n\targs: FetchArgs = {},\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Promise<any> => {\n\tconst doFetch = (token: string) => {\n\t\tconst allOptions: RequestInit = {\n\t\t\t...options,\n\t\t\theaders: {\n\t\t\t\t...(options.headers || {}),\n\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t'X-IDP-New-Login': 'true',\n\t\t\t},\n\t\t};\n\n\t\tif (options.method !== 'GET' && !args.numRetries) {\n\t\t\targs.numRetries = 0;\n\t\t}\n\n\t\treturn fetchWithRetry(url, allOptions, args);\n\t};\n\n\tlet getTokenPromise: Promise<string> = Promise.resolve('');\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tif (isFunction((global as any).__CAYUSE__?.appGetTokenSilently)) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst returnValue = (global as any).__CAYUSE__.appGetTokenSilently();\n\n\t\tgetTokenPromise =\n\t\t\treturnValue instanceof Promise ? returnValue : Promise.resolve(returnValue);\n\t}\n\n\treturn getTokenPromise.then((token) => doFetch(token));\n};\n\nexport const request = async (url: string, options = {}, args = {}) => {\n\treturn executeRequest(url, options, args);\n};\n"],"mappings":";AAAO,IAAM,mBAAmB,CAAC,UAChC,OAAO,UAAU,YAAY,MAAM,SAAS;AAEtC,IAAM,WAAW,CAAC,UACxB,OAAO,UAAU;AAEX,IAAM,WAAW,CAAC,UACxB,OAAO,UAAU;AAEX,IAAM,SAAS,CAAC,UACtB,OAAO,UAAU;AAEX,IAAM,EAAE,QAAQ,IAAI;AAEpB,IAAM,kBAAkB,CAAC,UAC/B,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS;AAEjC,IAAM,gBAAgB,CAAC,UAC7B,iBAAiB,OAAO,MAAM,OAAO;AAE/B,IAAM,aAAa,CAAC,UAAmB,OAAO,UAAU;AAExD,IAAM,WAAW,CAAC,WAAmB,UAAU,OAAO,WAAW;AAEjE,IAAM,mBAAmB,CAAC,WAChC,UAAU,SAAS,MAAM,KAAK,OAAO,KAAK,MAAM,EAAE,SAAS;AAErD,IAAM,kBAAkB,CAAmB,QAAW,QAC5D,SAAS,MAAM,KAAK,OAAO;AAErB,IAAM,QAAQ,CAAC,UAAkB,SAAS,KAAK,KAAK,iBAAiB;AAErE,IAAM,QAAQ,CAAC,WAAmB;AACxC,MAAI;AACH,WAAO,QAAQ,IAAI,IAAI,MAAM,CAAC;AAAA,EAC/B,QAAQ;AACP,WAAO;AAAA,EACR;AACD;;;ACtCO,IAAM,uBACZ;AACM,IAAM,8BAA8B;AACpC,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAC9B,IAAM,iCAAiC;AAE9C,IAAM,WAAW,QAAQ,IAAI;AAC7B,IAAM,UAAU,QAAQ,IAAI;AAE5B,IAAM,SACL,aAAa,iBAAiB,aAAa,UAAU,YAAY;AAClE,IAAM,UAAU,CAAC,UAAU,YAAY;AACvC,IAAM,aAAa,CAAC,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0 @@
1
- {"version":3,"sources":["../packages/hooks/use-file-uploader/uppy/constants.ts","../packages/hooks/use-file-uploader/uppy/api.ts","../packages/hooks/use-file-uploader/uppy/service.ts","../packages/hooks/use-click-outside/use-click-outside.tsx"],"sourcesContent":["export type UppyEvent =\n\t| 'file-added'\n\t| 'files-added'\n\t| 'file-removed'\n\t| 'upload'\n\t| 'progress'\n\t| 'preprocess-complete'\n\t| 'upload-progress'\n\t| 'upload-success'\n\t| 'complete'\n\t| 'error'\n\t| 'upload-error'\n\t| 'upload-retry'\n\t| 'retry-all'\n\t| 'info-visible'\n\t| 'info-hidden'\n\t| 'cancel-all'\n\t| 'restriction-failed'\n\t| 'reset-progress';\n\nexport const uppyEvents: UppyEvent[] = [\n\t'file-added',\n\t'files-added',\n\t'file-removed',\n\t'upload',\n\t'progress',\n\t'preprocess-complete',\n\t'upload-progress',\n\t'upload-success',\n\t'complete',\n\t'error',\n\t'upload-error',\n\t'upload-retry',\n\t'retry-all',\n\t'info-visible',\n\t'info-hidden',\n\t'cancel-all',\n\t'restriction-failed',\n\t'reset-progress',\n];\n\ninterface UppyState {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tplugins: { [key: string]: any };\n\terror: string;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tfiles: { [key: string]: any };\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcurrentUploads: { [key: string]: any };\n\tallowNewUpload: boolean;\n\tcapabilities: {\n\t\tuploadProgress: boolean;\n\t\tindividualCancellation: boolean;\n\t\tresumableUploads: boolean;\n\t};\n\ttotalProgress: number;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tmeta: { [key: string]: any };\n\tinfo: Array<{ type: string; message: string; details: string }>;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\trecoveredState: null | { [key: string]: any };\n}\n\nexport const uppyInitialState: UppyState = {\n\tplugins: {},\n\terror: '',\n\tfiles: {},\n\tcurrentUploads: {},\n\tallowNewUpload: true,\n\tcapabilities: {\n\t\tuploadProgress: true,\n\t\tindividualCancellation: true,\n\t\tresumableUploads: false,\n\t},\n\ttotalProgress: 0,\n\tmeta: {},\n\tinfo: [],\n\trecoveredState: null,\n};\n\nexport const MAX_FILE_SIZE_75_MB: number = 75 * Math.pow(1024, 2);\n\ninterface DefaultDictionary {\n\texeFileTypeRestriction: string;\n\t[key: string]: string;\n}\n\nexport const defaultDictionary: DefaultDictionary = {\n\texeFileTypeRestriction:\n\t\t'Attachments with filetype .exe cannot be accepted. Please try a different file type.',\n};\n","import { executeRequest } from '@/utils/http';\n\ninterface UploadUrlResponse {\n\tpreSignedUrl: string;\n\tuploadMetadataId: string;\n}\n\ninterface CompleteUploadResponse {\n\tcompletedAt: string;\n\tcreatedAt: string;\n\tfileName: string;\n\tfileSize: number;\n\tfinalizedAt: unknown;\n\tid: string;\n\ttenantId: string;\n\tuploadedBy: string;\n}\n\ninterface PersonDetails {\n\tid: string;\n\ttenantId: string;\n\tfirstName: string;\n\tlastName: string;\n\tfullName: string;\n\tmiddleName: string;\n\tcontactEmail: string;\n\tuserAccountId: string;\n}\n\ninterface UploadUrlRequestBody {\n\tfileName: string;\n\tfileSize: number;\n}\n\ninterface RequestOptions {\n\tsignal?: AbortSignal;\n}\n\nexport const api = {\n\tgetUploadURL: (\n\t\tbody: UploadUrlRequestBody,\n\t\toptions?: RequestOptions,\n\t): Promise<UploadUrlResponse> => {\n\t\tconst requestOptions = {\n\t\t\tmethod: 'POST',\n\t\t\tbody: JSON.stringify(body),\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tsignal: options?.signal,\n\t\t};\n\n\t\treturn executeRequest('/api/v2/attachments/upload', requestOptions);\n\t},\n\n\tcompleteUpload: (id: string): Promise<CompleteUploadResponse> => {\n\t\tconst requestOptions = {\n\t\t\tmethod: 'POST',\n\t\t};\n\n\t\treturn executeRequest(\n\t\t\t`/api/v2/attachments/upload/${id}/complete`,\n\t\t\trequestOptions,\n\t\t);\n\t},\n\n\tgetDownloadUrl: (id: string): Promise<string> => {\n\t\treturn executeRequest(`/api/v2/attachments/download?uploadMetadataId=${id}`);\n\t},\n\n\tgetPersonDetailsById: (\n\t\tid: string,\n\t): Promise<PersonDetails | { errors: unknown[] }> => {\n\t\treturn executeRequest(`/api/v2/person/user/${id}`);\n\t},\n};\n","import { v4 as uuidv4 } from 'uuid';\nimport Uppy from '@uppy/core';\nimport AwsS3 from '@uppy/aws-s3';\nimport { merge } from 'lodash-es';\n\nimport { MAX_FILE_SIZE_75_MB, uppyEvents, UppyEvent } from './constants.js';\nimport { api } from './api.js';\n\ninterface UppyDefaultOptions {\n\tautoProceed?: boolean;\n\trestrictions?: {\n\t\tmaxFileSize?: number;\n\t\tmaxNumberOfFiles?: number;\n\t\tallowedFileTypes?: string[] | null;\n\t};\n}\n\ninterface UppyFile {\n\tid: string;\n\tname: string;\n\tsize: number;\n\ttype: string;\n\tmeta: {\n\t\tuploadMetadataId: string;\n\t\tuploadedBy: string;\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t[key: string]: any;\n\t};\n}\n\ninterface UploadUrlResponse {\n\tpreSignedUrl: string;\n\tuploadMetadataId: string;\n}\n\ninterface CompleteUploadResponse {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t[k: string]: any;\n\tcompletedAt: string;\n\tcreatedAt: string;\n\tfileName: string;\n\tfileSize: number;\n\tfinalizedAt: unknown;\n\tid: string;\n\ttenantId: string;\n\tuploadedBy: string;\n}\n\ninterface PersonDetails {\n\tfirstName: string;\n\tlastName: string;\n}\n\nexport class UppyService {\n\tprivate instances: Map<string, Uppy> = new Map();\n\tprivate retryCount: number = 0;\n\tprivate defaultOptions: UppyDefaultOptions = {\n\t\tautoProceed: true,\n\t\trestrictions: {\n\t\t\tmaxFileSize: MAX_FILE_SIZE_75_MB,\n\t\t\tmaxNumberOfFiles: 9,\n\t\t\tallowedFileTypes: null,\n\t\t},\n\t};\n\n\tgetInstance(id: string): Uppy | null {\n\t\treturn this.instances.get(id) || null;\n\t}\n\n\tregister(options: UppyDefaultOptions): Uppy {\n\t\tconst id: string = uuidv4();\n\n\t\tconst getUploadParameters =\n\t\t\t(instanceId: string) =>\n\t\t\tasync (\n\t\t\t\tfile: UppyFile,\n\t\t\t\t_options: { signal?: AbortSignal },\n\t\t\t): Promise<{\n\t\t\t\tmethod: string;\n\t\t\t\turl: string;\n\t\t\t\tfields: Record<string, never>;\n\t\t\t\theaders: { 'Content-Type': string };\n\t\t\t}> => {\n\t\t\t\tconst response: UploadUrlResponse = await api.getUploadURL(\n\t\t\t\t\t{\n\t\t\t\t\t\tfileName: file.name,\n\t\t\t\t\t\tfileSize: file.size,\n\t\t\t\t\t},\n\t\t\t\t\t_options,\n\t\t\t\t);\n\n\t\t\t\tconst instance = this.getInstance(instanceId);\n\t\t\t\tif (instance) {\n\t\t\t\t\t// @ts-expect-error type mismatch\n\t\t\t\t\tinstance.setFileMeta(file.id, response);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl: response.preSignedUrl,\n\t\t\t\t\tfields: {},\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': file.type,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t};\n\n\t\tconst instance: Uppy = new Uppy(this.#getOptions(id, options)).use(AwsS3, {\n\t\t\t// @ts-expect-error type mismatch\n\t\t\tgetUploadParameters: getUploadParameters(id),\n\t\t});\n\n\t\tObject.defineProperty(instance, 'id', { value: id, enumerable: true });\n\n\t\tthis.instances.set(id, instance);\n\n\t\tthis.#subscribeOnEvents(id);\n\n\t\treturn instance;\n\t}\n\n\tdestroy(id: string): void {\n\t\tconst instance = this.getInstance(id);\n\t\t// @ts-expect-error type mismatch\n\t\tinstance?.close(() => this.instances.delete(id));\n\t}\n\n\tonAnyEvent(\n\t\tid: string,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\teventCallback: (eventName: UppyEvent, ...args: any[]) => void,\n\t): void {\n\t\tconst inst = this.getInstance(id);\n\t\tif (inst) {\n\t\t\tuppyEvents.forEach((event: UppyEvent) => {\n\t\t\t\tinst.on(\n\t\t\t\t\t// @ts-expect-error type mismatch\n\t\t\t\t\tevent,\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t(...args: any[]) => {\n\t\t\t\t\t\teventCallback(event, ...args);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t}\n\n\t#subscribeOnEvents(instanceId: string): void {\n\t\tconst instance = this.getInstance(instanceId);\n\t\tif (instance) {\n\t\t\t// @ts-expect-error type miss match\n\t\t\tinstance.on('upload-success', async (file: UppyFile) => {\n\t\t\t\tawait this.#completeUploading(instanceId, file);\n\t\t\t});\n\t\t}\n\t}\n\n\t#getOptions(\n\t\tid: string,\n\t\toptions: UppyDefaultOptions,\n\t): UppyDefaultOptions & { id: string; debug: boolean } {\n\t\treturn {\n\t\t\t...merge(this.defaultOptions, options),\n\t\t\tid,\n\t\t\tdebug: true,\n\t\t};\n\t}\n\n\tasync #completeUploading(instanceId: string, file: UppyFile): Promise<void> {\n\t\tconst instance = this.getInstance(instanceId);\n\t\tif (!instance) return;\n\n\t\ttry {\n\t\t\tconst completedResponse: CompleteUploadResponse = await api.completeUpload(\n\t\t\t\tfile.meta.uploadMetadataId,\n\t\t\t);\n\t\t\tinstance.setFileMeta(file.id, completedResponse);\n\n\t\t\tinstance.emit('complete', completedResponse);\n\n\t\t\tthis.#getDownloadUrl(instanceId, file.id);\n\t\t\tthis.#loadAdditionalFileMetadata(instanceId, file.id);\n\t\t} catch (error) {\n\t\t\t// @ts-expect-error type miss match\n\t\t\tinstance.emit('upload-error', file, error);\n\t\t}\n\t}\n\n\tasync #getDownloadUrl(instanceId: string, fileId: string): Promise<void> {\n\t\tconst instance = this.getInstance(instanceId);\n\t\tif (!instance) return;\n\n\t\ttry {\n\t\t\tconst file = instance.getFile(fileId);\n\t\t\tif (!file) return;\n\n\t\t\tconst downloadUrl: string = await api.getDownloadUrl(\n\t\t\t\tfile.meta.uploadMetadataId as string,\n\t\t\t);\n\n\t\t\tif (typeof downloadUrl === 'string') {\n\t\t\t\tinstance.setFileMeta(fileId, { downloadUrl });\n\t\t\t} else {\n\t\t\t\tinstance.emit('error', downloadUrl);\n\t\t\t}\n\n\t\t\tinstance.emit('complete', { downloadUrl });\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\tinstance.emit('error', error);\n\t\t}\n\t}\n\n\tasync #loadAdditionalFileMetadata(\n\t\tinstanceId: string,\n\t\tfileId: string,\n\t): Promise<void> {\n\t\tconst instance = this.getInstance(instanceId);\n\t\tif (!instance) return;\n\n\t\ttry {\n\t\t\tconst file = instance.getFile(fileId);\n\t\t\tif (!file) return;\n\n\t\t\tconst response: PersonDetails | { errors: unknown[] } =\n\t\t\t\tawait api.getPersonDetailsById(file.meta.uploadedBy as string);\n\n\t\t\tif ('firstName' in response) {\n\t\t\t\tinstance.setFileMeta(fileId, {\n\t\t\t\t\tuploadedByInfo: {\n\t\t\t\t\t\tfirstName: response.firstName,\n\t\t\t\t\t\tlastName: response.lastName,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\tinstance.emit('error', response as any);\n\t\t\t}\n\n\t\t\tinstance.emit('complete', {});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\tinstance.emit('error', error);\n\t\t}\n\t}\n}\n","import { useEffect, RefObject } from 'react';\n\nexport const useClickOutside = <T extends HTMLElement>(\n\telementRef: RefObject<T>,\n\tcallback: () => void,\n): void => {\n\tuseEffect(() => {\n\t\tconst handleClickOutside = (event: MouseEvent): void => {\n\t\t\tif (\n\t\t\t\telementRef &&\n\t\t\t\telementRef.current &&\n\t\t\t\t!elementRef.current.contains(event.target as Node)\n\t\t\t) {\n\t\t\t\tcallback();\n\t\t\t}\n\t\t};\n\n\t\tdocument.addEventListener('click', handleClickOutside, true);\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('click', handleClickOutside, true);\n\t\t};\n\t}, [elementRef, callback]);\n};\n"],"mappings":";;;;;AAoBO,IAAM,aAA0B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAwBO,IAAM,mBAA8B;AAAA,EAC1C,SAAS,CAAC;AAAA,EACV,OAAO;AAAA,EACP,OAAO,CAAC;AAAA,EACR,gBAAgB,CAAC;AAAA,EACjB,gBAAgB;AAAA,EAChB,cAAc;AAAA,IACb,gBAAgB;AAAA,IAChB,wBAAwB;AAAA,IACxB,kBAAkB;AAAA,EACnB;AAAA,EACA,eAAe;AAAA,EACf,MAAM,CAAC;AAAA,EACP,MAAM,CAAC;AAAA,EACP,gBAAgB;AACjB;AAEO,IAAM,sBAA8B,KAAK,KAAK,IAAI,MAAM,CAAC;AAOzD,IAAM,oBAAuC;AAAA,EACnD,wBACC;AACF;;;ACpDO,IAAM,MAAM;AAAA,EAClB,cAAc,CACb,MACA,YACgC;AAChC,UAAM,iBAAiB;AAAA,MACtB,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,IAAI;AAAA,MACzB,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,QAAQ,SAAS;AAAA,IAClB;AAEA,WAAO,eAAe,8BAA8B,cAAc;AAAA,EACnE;AAAA,EAEA,gBAAgB,CAAC,OAAgD;AAChE,UAAM,iBAAiB;AAAA,MACtB,QAAQ;AAAA,IACT;AAEA,WAAO;AAAA,MACN,8BAA8B,EAAE;AAAA,MAChC;AAAA,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