@intlayer/design-system 5.5.1 → 5.5.3

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.
@@ -7,16 +7,16 @@ export declare const useDictionaryDetailsSchema: (projectId: string) => z.ZodObj
7
7
  tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
8
8
  }, "strip", z.ZodTypeAny, {
9
9
  key: string;
10
- projectIds: string[];
11
10
  tags: string[];
11
+ projectIds: string[];
12
12
  title?: string | undefined;
13
13
  description?: string | undefined;
14
14
  }, {
15
15
  title?: string | undefined;
16
16
  key?: string | undefined;
17
17
  description?: string | undefined;
18
- projectIds?: string[] | undefined;
19
18
  tags?: string[] | undefined;
19
+ projectIds?: string[] | undefined;
20
20
  }>;
21
21
  export type DictionaryDetailsFormData = z.infer<ReturnType<typeof useDictionaryDetailsSchema>>;
22
22
  //# sourceMappingURL=useDictionaryDetailsSchema.d.ts.map
@@ -53,6 +53,7 @@ exports.useDeleteUser = hooks_intlayerAPIHooks.useDeleteUser;
53
53
  exports.useGetDictionaries = hooks_intlayerAPIHooks.useGetDictionaries;
54
54
  exports.useGetDictionariesKeys = hooks_intlayerAPIHooks.useGetDictionariesKeys;
55
55
  exports.useGetDictionary = hooks_intlayerAPIHooks.useGetDictionary;
56
+ exports.useGetEditorDictionaries = hooks_intlayerAPIHooks.useGetEditorDictionaries;
56
57
  exports.useGetOrganizations = hooks_intlayerAPIHooks.useGetOrganizations;
57
58
  exports.useGetPricing = hooks_intlayerAPIHooks.useGetPricing;
58
59
  exports.useGetProjects = hooks_intlayerAPIHooks.useGetProjects;
@@ -65,7 +66,7 @@ exports.useLogout = hooks_intlayerAPIHooks.useLogout;
65
66
  exports.usePushDictionaries = hooks_intlayerAPIHooks.usePushDictionaries;
66
67
  exports.useRefreshAccessKey = hooks_intlayerAPIHooks.useRefreshAccessKey;
67
68
  exports.useRegister = hooks_intlayerAPIHooks.useRegister;
68
- exports.useResetPassword = hooks_intlayerAPIHooks.useResetPassword;
69
+ exports.useSearchDoc = hooks_intlayerAPIHooks.useSearchDoc;
69
70
  exports.useSelectOrganization = hooks_intlayerAPIHooks.useSelectOrganization;
70
71
  exports.useSelectProject = hooks_intlayerAPIHooks.useSelectProject;
71
72
  exports.useTranslateJSONDeclaration = hooks_intlayerAPIHooks.useTranslateJSONDeclaration;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,7 +5,7 @@ import { useIsMounted } from "./useIsMounted.mjs";
5
5
  import { useScrollDetection } from "./useScrollDetection.mjs";
6
6
  import { useAsync } from "./useAsync/useAsync.mjs";
7
7
  import { AsyncStateProvider, useAsyncState } from "./useAsync/useAsyncStateStore.mjs";
8
- import { useAddDictionary, useAddNewAccessKey, useAddOrganization, useAddOrganizationMember, useAddProject, useAddTag, useAskDocQuestion, useAskResetPassword, useAuditContentDeclaration, useAuditContentDeclarationField, useAuditContentDeclarationMetadata, useAuditTag, useAutocomplete, useCancelSubscription, useChangePassword, useCheckIfUserHasPassword, useCreateUser, useDefineNewPassword, useDeleteAccessKey, useDeleteDictionary, useDeleteOrganization, useDeleteProject, useDeleteTag, useDeleteUser, useGetDictionaries, useGetDictionariesKeys, useGetDictionary, useGetOrganizations, useGetPricing, useGetProjects, useGetSubscription, useGetTags, useGetUserByAccount, useGetUsers, useLogin, useLogout, usePushDictionaries, useRefreshAccessKey, useRegister, useResetPassword, useSelectOrganization, useSelectProject, useTranslateJSONDeclaration, useUnselectOrganization, useUnselectProject, useUpdateDictionary, useUpdateOrganization, useUpdateOrganizationMembers, useUpdateProject, useUpdateProjectMembers, useUpdateTag, useUpdateUser, useVerifyEmail, useWriteDictionary } from "./intlayerAPIHooks.mjs";
8
+ import { useAddDictionary, useAddNewAccessKey, useAddOrganization, useAddOrganizationMember, useAddProject, useAddTag, useAskDocQuestion, useAskResetPassword, useAuditContentDeclaration, useAuditContentDeclarationField, useAuditContentDeclarationMetadata, useAuditTag, useAutocomplete, useCancelSubscription, useChangePassword, useCheckIfUserHasPassword, useCreateUser, useDefineNewPassword, useDeleteAccessKey, useDeleteDictionary, useDeleteOrganization, useDeleteProject, useDeleteTag, useDeleteUser, useGetDictionaries, useGetDictionariesKeys, useGetDictionary, useGetEditorDictionaries, useGetOrganizations, useGetPricing, useGetProjects, useGetSubscription, useGetTags, useGetUserByAccount, useGetUsers, useLogin, useLogout, usePushDictionaries, useRefreshAccessKey, useRegister, useSearchDoc, useSelectOrganization, useSelectProject, useTranslateJSONDeclaration, useUnselectOrganization, useUnselectProject, useUpdateDictionary, useUpdateOrganization, useUpdateOrganizationMembers, useUpdateProject, useUpdateProjectMembers, useUpdateTag, useUpdateUser, useVerifyEmail, useWriteDictionary } from "./intlayerAPIHooks.mjs";
9
9
  import { useItemSelector } from "./useItemSelector.mjs";
10
10
  import { useGetAllDictionaries } from "./useGetAllDictionaries.mjs";
11
11
  import { usePersistedStore } from "./usePersistedStore.mjs";
@@ -49,6 +49,7 @@ export {
49
49
  useGetDictionaries,
50
50
  useGetDictionariesKeys,
51
51
  useGetDictionary,
52
+ useGetEditorDictionaries,
52
53
  useGetElementOrWindow,
53
54
  useGetOrganizations,
54
55
  useGetPricing,
@@ -67,9 +68,9 @@ export {
67
68
  usePushDictionaries,
68
69
  useRefreshAccessKey,
69
70
  useRegister,
70
- useResetPassword,
71
71
  u as useScrollBlockage,
72
72
  useScrollDetection,
73
+ useSearchDoc,
73
74
  useSelectOrganization,
74
75
  useSelectProject,
75
76
  useTranslateJSONDeclaration,
@@ -88,7 +88,6 @@ const useAskResetPassword = (args) => useAppAsync(
88
88
  hooks_useIntlayerAPI.useIntlayerAuth().auth.askResetPassword,
89
89
  args
90
90
  );
91
- const useResetPassword = (args) => useAppAsync("resetPassword", hooks_useIntlayerAPI.useIntlayerAuth().auth.resetPassword, args);
92
91
  const useDefineNewPassword = (args) => useAppAsync(
93
92
  "defineNewPassword",
94
93
  hooks_useIntlayerAPI.useIntlayerAuth().auth.defineNewPassword,
@@ -454,11 +453,17 @@ const useAuditTag = (args) => useAppAsync("auditTag", hooks_useIntlayerAPI.useIn
454
453
  });
455
454
  const useAskDocQuestion = (args) => useAppAsync("askDocQuestion", hooks_useIntlayerAPI.useIntlayerAuth().ai.askDocQuestion, args);
456
455
  const useAutocomplete = (args) => useAppAsync("autocomplete", hooks_useIntlayerAPI.useIntlayerAuth().ai.autocomplete, args);
456
+ const useSearchDoc = (args) => useAppAsync("searchDoc", hooks_useIntlayerAPI.useIntlayerAuth().search.searchDoc, args);
457
457
  const useWriteDictionary = (args) => useEditorAsync(
458
458
  "writeDictionary",
459
459
  hooks_useIntlayerAPI.useIntlayerAuth().editor.writeDictionary,
460
460
  args
461
461
  );
462
+ const useGetEditorDictionaries = (args) => useEditorAsync("getDictionaries", hooks_useIntlayerAPI.useIntlayerAuth().editor.getDictionaries, {
463
+ store: true,
464
+ cache: true,
465
+ ...args
466
+ });
462
467
  exports.useAddDictionary = useAddDictionary;
463
468
  exports.useAddNewAccessKey = useAddNewAccessKey;
464
469
  exports.useAddOrganization = useAddOrganization;
@@ -486,6 +491,7 @@ exports.useDeleteUser = useDeleteUser;
486
491
  exports.useGetDictionaries = useGetDictionaries;
487
492
  exports.useGetDictionariesKeys = useGetDictionariesKeys;
488
493
  exports.useGetDictionary = useGetDictionary;
494
+ exports.useGetEditorDictionaries = useGetEditorDictionaries;
489
495
  exports.useGetOrganizations = useGetOrganizations;
490
496
  exports.useGetPricing = useGetPricing;
491
497
  exports.useGetProjects = useGetProjects;
@@ -498,7 +504,7 @@ exports.useLogout = useLogout;
498
504
  exports.usePushDictionaries = usePushDictionaries;
499
505
  exports.useRefreshAccessKey = useRefreshAccessKey;
500
506
  exports.useRegister = useRegister;
501
- exports.useResetPassword = useResetPassword;
507
+ exports.useSearchDoc = useSearchDoc;
502
508
  exports.useSelectOrganization = useSelectOrganization;
503
509
  exports.useSelectProject = useSelectProject;
504
510
  exports.useTranslateJSONDeclaration = useTranslateJSONDeclaration;
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerAPIHooks.cjs","sources":["../../src/hooks/intlayerAPIHooks.ts"],"sourcesContent":["'use client';\n\nimport type { IntlayerAPI } from '@intlayer/api';\nimport { useConfiguration } from '@intlayer/editor-react';\nimport { useAuth } from '../components/Auth/useAuth/index';\nimport { useToast } from '../components/Toaster';\nimport { type UseAsyncOptions, useAsync } from './useAsync/useAsync';\nimport { useIntlayerAuth } from './useIntlayerAPI';\n\n/**\n * Hook to handle error logging and toast notifications\n */\nconst useErrorHandling = <T extends UseAsyncOptions<any>>(options: T): T => {\n const { toast } = useToast();\n\n return {\n ...options,\n onError: (errorMessage) => {\n let error;\n\n // If json is valid, parse it\n try {\n if (typeof errorMessage === 'undefined') return;\n\n error = JSON.parse(errorMessage);\n } catch (e) {\n // If json is not valid, set error to the original errorMessage\n\n error = errorMessage;\n }\n\n // render toast for each error if there is more than one\n // otherwise render the toast with the error message\n [error]\n .flatMap((error) => error)\n .forEach((error) =>\n toast({\n title:\n (process.env.NODE_ENV === 'production'\n ? error.title\n : error.code) ?? 'Error',\n description: error.message ?? errorMessage ?? 'An error occurred',\n variant: 'error',\n })\n );\n options.onError?.(errorMessage);\n },\n onSuccess: (data) => {\n if (data?.message)\n toast({\n title: data.message,\n description: data.description,\n variant: 'success',\n });\n options.onSuccess?.(data);\n },\n };\n};\n\ntype AuthEnableOptions = {\n requireUser?: boolean;\n requireProject?: boolean;\n requireOrganization?: boolean;\n};\n\n/**\n * Hook to enable authentication\n */\nconst useAuthEnable = <T extends UseAsyncOptions<any>>(\n options: T,\n { requireUser, requireProject, requireOrganization }: AuthEnableOptions = {}\n): T => {\n const configuration = useConfiguration();\n const { csrfToken, oAuth2AccessToken, session } = useAuth({\n intlayerConfiguration: configuration,\n });\n\n const isEnabledOption = options?.enable ?? true;\n const user = session ? session.user : oAuth2AccessToken?.user;\n\n const organization = session\n ? session.organization\n : oAuth2AccessToken?.organization;\n\n const project = session ? session.project : oAuth2AccessToken?.project;\n\n const isUserEnabled = requireUser ? Boolean(user) : true;\n\n const isProjectEnabled = requireProject ? Boolean(project) : true;\n\n const isOrganizationEnabled = requireOrganization\n ? Boolean(organization)\n : true;\n\n const isCSRFEnabled =\n Boolean(csrfToken) ||\n // If auth using session, csrf token is not required\n (!session && Boolean(oAuth2AccessToken));\n\n const isEnabled =\n isEnabledOption &&\n isUserEnabled &&\n isProjectEnabled &&\n isOrganizationEnabled &&\n isCSRFEnabled;\n\n return {\n ...options,\n enable: isEnabled,\n };\n};\n\nconst useAppAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>,\n authOptions?: AuthEnableOptions\n) => {\n // Enhance options using custom hooks\n const optionsWithAuth = useAuthEnable(options ?? {}, authOptions);\n\n const optionsWithErrorHandling = useErrorHandling(optionsWithAuth);\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\nconst useEditorAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n) => {\n const optionsWithErrorHandling = useErrorHandling(options ?? {});\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\n/**\n * Auth\n */\n\nexport const useLogin = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['login']>\n) =>\n useAppAsync('login', useIntlayerAuth().auth.login, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useRegister = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['register']>\n) =>\n useAppAsync('register', useIntlayerAuth().auth.register, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useLogout = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['logout']>\n) =>\n useAppAsync('logout', useIntlayerAuth().auth.logout, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useChangePassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['changePassword']>\n) => useAppAsync('changePassword', useIntlayerAuth().auth.changePassword, args);\nexport const useAskResetPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['askResetPassword']>\n) =>\n useAppAsync(\n 'askResetPassword',\n useIntlayerAuth().auth.askResetPassword,\n args\n );\nexport const useResetPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['resetPassword']>\n) => useAppAsync('resetPassword', useIntlayerAuth().auth.resetPassword, args);\nexport const useDefineNewPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['defineNewPassword']>\n) =>\n useAppAsync(\n 'defineNewPassword',\n useIntlayerAuth().auth.defineNewPassword,\n args\n );\nexport const useCheckIfUserHasPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['checkIfUserHasPassword']>\n) =>\n useAppAsync(\n 'checkIfUserHasPassword',\n useIntlayerAuth().auth.checkIfUserHasPassword,\n args,\n {\n requireUser: true,\n }\n );\nexport const useVerifyEmail = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['verifyEmail']>\n) => useAppAsync('verifyEmail', useIntlayerAuth().auth.verifyEmail, args);\n\nexport const useGetUserByAccount = (\n args?: UseAsyncOptions<IntlayerAPI['user']['getUserByAccount']>\n) =>\n useAppAsync(\n 'getUserByAccount',\n useIntlayerAuth().user.getUserByAccount,\n args\n );\n\n/**\n * User\n */\n\nexport const useGetUsers = (\n args?: UseAsyncOptions<IntlayerAPI['user']['getUsers']>\n) =>\n useAppAsync(\n 'getUsers',\n useIntlayerAuth().user.getUsers,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\nexport const useCreateUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['createUser']>\n) =>\n useAppAsync('createUser', useIntlayerAuth().user.createUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\nexport const useUpdateUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['updateUser']>\n) =>\n useAppAsync('updateUser', useIntlayerAuth().user.updateUser, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useDeleteUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['deleteUser']>\n) =>\n useAppAsync('deleteUser', useIntlayerAuth().user.deleteUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\n\n/**\n * Organization\n */\n\nexport const useGetOrganizations = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['getOrganizations']>\n) =>\n useAppAsync(\n 'getOrganizations',\n useIntlayerAuth().organization.getOrganizations,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\n\nexport const useAddOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['addOrganization']>\n) =>\n useAppAsync(\n 'addOrganization',\n useIntlayerAuth().organization.addOrganization,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useUpdateOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['updateOrganization']>\n) =>\n useAppAsync(\n 'updateOrganization',\n useIntlayerAuth().organization.updateOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useUpdateOrganizationMembers = (\n args?: UseAsyncOptions<\n IntlayerAPI['organization']['updateOrganizationMembers']\n >\n) =>\n useAppAsync(\n 'updateOrganizationMembers',\n useIntlayerAuth().organization.updateOrganizationMembers,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\nexport const useAddOrganizationMember = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['addOrganizationMember']>\n) =>\n useAppAsync(\n 'addOrganizationMember',\n useIntlayerAuth().organization.addOrganizationMember,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\nexport const useDeleteOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['deleteOrganization']>\n) =>\n useAppAsync(\n 'deleteOrganization',\n useIntlayerAuth().organization.deleteOrganization,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\nexport const useSelectOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['selectOrganization']>\n) =>\n useAppAsync(\n 'selectOrganization',\n useIntlayerAuth().organization.selectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useUnselectOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['unselectOrganization']>\n) =>\n useAppAsync(\n 'unselectOrganization',\n useIntlayerAuth().organization.unselectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\n/**\n * Project\n */\n\nexport const useGetProjects = (\n args?: UseAsyncOptions<IntlayerAPI['project']['getProjects']>\n) =>\n useAppAsync(\n 'getProjects',\n useIntlayerAuth().project.getProjects,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\nexport const useAddProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['addProject']>\n) =>\n useAppAsync('addProject', useIntlayerAuth().project.addProject, {\n invalidateQueries: ['getProjects'],\n ...args,\n });\nexport const useUpdateProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['updateProject']>\n) =>\n useAppAsync('updateProject', useIntlayerAuth().project.updateProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useUpdateProjectMembers = (\n args?: UseAsyncOptions<IntlayerAPI['project']['updateProjectMembers']>\n) =>\n useAppAsync(\n 'updateProjectMembers',\n useIntlayerAuth().project.updateProjectMembers,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useDeleteProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['deleteProject']>\n) =>\n useAppAsync('deleteProject', useIntlayerAuth().project.deleteProject, {\n invalidateQueries: ['getProjects', 'getSession'],\n ...args,\n });\nexport const useSelectProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['selectProject']>\n) =>\n useAppAsync('selectProject', useIntlayerAuth().project.selectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useUnselectProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['unselectProject']>\n) =>\n useAppAsync('unselectProject', useIntlayerAuth().project.unselectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useAddNewAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['addNewAccessKey']>\n) =>\n useAppAsync('addNewAccessKey', useIntlayerAuth().project.addNewAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useDeleteAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['deleteAccessKey']>\n) =>\n useAppAsync('deleteAccessKey', useIntlayerAuth().project.deleteAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useRefreshAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['refreshAccessKey']>\n) =>\n useAppAsync('refreshAccessKey', useIntlayerAuth().project.refreshAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\n/**\n * Dictionary\n */\n\nexport const useGetDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionaries']>\n) =>\n useAppAsync(\n 'getDictionaries',\n useIntlayerAuth().dictionary.getDictionaries,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionariesKeys = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionariesKeys']>\n) =>\n useAppAsync(\n 'getDictionariesKeys',\n useIntlayerAuth().dictionary.getDictionariesKeys,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionary']>\n) =>\n useAppAsync(\n 'getDictionary',\n useIntlayerAuth().dictionary.getDictionary,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\nexport const useAddDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['addDictionary']>\n) =>\n useAppAsync('addDictionary', useIntlayerAuth().dictionary.addDictionary, {\n invalidateQueries: ['getDictionaries', 'getDictionariesKeys'],\n ...args,\n });\n\nexport const usePushDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['pushDictionaries']>\n) =>\n useAppAsync(\n 'pushDictionaries',\n useIntlayerAuth().dictionary.pushDictionaries,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\nexport const useUpdateDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['updateDictionary']>\n) =>\n useAppAsync(\n 'updateDictionary',\n useIntlayerAuth().dictionary.updateDictionary,\n {\n invalidateQueries: ['getDictionaries', 'getDictionary'],\n ...args,\n }\n );\nexport const useDeleteDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['deleteDictionary']>\n) =>\n useAppAsync(\n 'deleteDictionary',\n useIntlayerAuth().dictionary.deleteDictionary,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\n\n/**\n * Tag\n */\n\nexport const useGetTags = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['getTags']>\n) =>\n useAppAsync(\n 'getTags',\n useIntlayerAuth().tag.getTags,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\nexport const useAddTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['addTag']>\n) =>\n useAppAsync('addTag', useIntlayerAuth().tag.addTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\nexport const useUpdateTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['updateTag']>\n) =>\n useAppAsync('updateTag', useIntlayerAuth().tag.updateTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\nexport const useDeleteTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['deleteTag']>\n) =>\n useAppAsync('deleteTag', useIntlayerAuth().tag.deleteTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\n\n/**\n * Stripe\n */\n\nexport const useGetPricing = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['getPricing']>\n) =>\n useAppAsync('getPricing', useIntlayerAuth().stripe.getPricing, {\n store: true,\n cache: true,\n ...args,\n });\n\nexport const useGetSubscription = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['getSubscription']>\n) =>\n useAppAsync(\n 'getSubscription',\n useIntlayerAuth().stripe.getSubscription,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useCancelSubscription = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['cancelSubscription']>\n) =>\n useAppAsync(\n 'cancelSubscription',\n useIntlayerAuth().stripe.cancelSubscription,\n { invalidateQueries: ['getSession'], ...args },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\n/**\n * AI\n */\n\nexport const useTranslateJSONDeclaration = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['translateJSON']>\n) =>\n useAppAsync('translateJSON', useIntlayerAuth().ai.translateJSON, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n\nexport const useAuditContentDeclaration = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclaration']>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclaration,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationMetadata = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclarationMetadata']>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclarationMetadata,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationField = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclarationField']>\n) =>\n useAppAsync(\n 'auditContentDeclarationField',\n useIntlayerAuth().ai.auditContentDeclarationField,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditTag = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditTag']>\n) =>\n useAppAsync('auditTag', useIntlayerAuth().ai.auditTag, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n\nexport const useAskDocQuestion = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['askDocQuestion']>\n) => useAppAsync('askDocQuestion', useIntlayerAuth().ai.askDocQuestion, args);\n\nexport const useAutocomplete = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['autocomplete']>\n) => useAppAsync('autocomplete', useIntlayerAuth().ai.autocomplete, args);\n\n/**\n * Editor\n */\n\nexport const useWriteDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['editor']['writeDictionary']>\n) =>\n useEditorAsync(\n 'writeDictionary',\n useIntlayerAuth().editor.writeDictionary,\n args\n );\n"],"names":["useToast","error","useConfiguration","useAuth","useAsync","useIntlayerAuth"],"mappings":";;;;;;;;;;;AAYA,MAAM,mBAAmB,CAAiC,YAAkB;AACpE,QAAA,EAAE,MAAM,IAAIA,qCAAS;AAEpB,SAAA;AAAA,IACL,GAAG;AAAA,IACH,SAAS,CAAC,iBAAiB;AACrB,UAAA;AAGA,UAAA;AACE,YAAA,OAAO,iBAAiB,YAAa;AAEjC,gBAAA,KAAK,MAAM,YAAY;AAAA,eACxB,GAAG;AAGF,gBAAA;AAAA,MAAA;AAKV,OAAC,KAAK,EACH,QAAQ,CAACC,WAAUA,MAAK,EACxB;AAAA,QAAQ,CAACA,WACR,MAAM;AAAA,UACJ,QACG,2BAAY,aAAa,eACtBA,OAAM,QACNA,OAAM,SAAS;AAAA,UACrB,aAAaA,OAAM,WAAW,gBAAgB;AAAA,UAC9C,SAAS;AAAA,QACV,CAAA;AAAA,MACH;AACF,cAAQ,UAAU,YAAY;AAAA,IAChC;AAAA,IACA,WAAW,CAAC,SAAS;AACnB,UAAI,MAAM;AACF,cAAA;AAAA,UACJ,OAAO,KAAK;AAAA,UACZ,aAAa,KAAK;AAAA,UAClB,SAAS;AAAA,QAAA,CACV;AACH,cAAQ,YAAY,IAAI;AAAA,IAAA;AAAA,EAE5B;AACF;AAWA,MAAM,gBAAgB,CACpB,SACA,EAAE,aAAa,gBAAgB,oBAA2C,IAAA,OACpE;AACN,QAAM,gBAAgBC,YAAAA,iBAAiB;AACvC,QAAM,EAAE,WAAW,mBAAmB,QAAA,IAAYC,8BAAAA,QAAQ;AAAA,IACxD,uBAAuB;AAAA,EAAA,CACxB;AAEK,QAAA,kBAAkB,SAAS,UAAU;AAC3C,QAAM,OAAO,UAAU,QAAQ,OAAO,mBAAmB;AAEzD,QAAM,eAAe,UACjB,QAAQ,eACR,mBAAmB;AAEvB,Q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,GAAG;AAAA,EACrB;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,EAAA;AAEpB;AAEW,MAAA,qCAAqC,CAChD,SAEA;AAAA,EACE;AAAA,EACAA,qBAAA,gBAAA,EAAkB,GAAG;AAAA,EACrB;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,EAAA;AAEpB;AAEW,MAAA,kCAAkC,CAC7C,SAEA;AAAA,EACE;AAAA,EACAA,qBAAA,gBAAA,EAAkB,GAAG;AAAA,EACrB;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,EAAA;AAEpB;AAEW,MAAA,cAAc,CACzB,SAEA,YAAY,YAAYA,qBAAAA,kBAAkB,GAAG,UAAU,MAAM;AAAA,EAC3D,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAClB,CAAC;AAEU,MAAA,oBAAoB,CAC/B,SACG,YAAY,kBAAkBA,qBAAAA,kBAAkB,GAAG,gBAAgB,IAAI;AAE/D,MAAA,kBAAkB,CAC7B,SACG,YAAY,gBAAgBA,qBAAAA,kBAAkB,GAAG,cAAc,IAAI;AAM3D,MAAA,qBAAqB,CAChC,SAEA;AAAA,EACE;AAAA,EACAA,qBAAA,gBAAA,EAAkB,OAAO;AAAA,EACzB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"intlayerAPIHooks.cjs","sources":["../../src/hooks/intlayerAPIHooks.ts"],"sourcesContent":["'use client';\n\nimport type { IntlayerAPI } from '@intlayer/api';\nimport { useConfiguration } from '@intlayer/editor-react';\nimport { useAuth } from '../components/Auth/useAuth/index';\nimport { useToast } from '../components/Toaster';\nimport { type UseAsyncOptions, useAsync } from './useAsync/useAsync';\nimport { useIntlayerAuth } from './useIntlayerAPI';\n\n/**\n * Hook to handle error logging and toast notifications\n */\nconst useErrorHandling = <T extends UseAsyncOptions<any>>(options: T): T => {\n const { toast } = useToast();\n\n return {\n ...options,\n onError: (errorMessage) => {\n let error;\n\n // If json is valid, parse it\n try {\n if (typeof errorMessage === 'undefined') return;\n\n error = JSON.parse(errorMessage);\n } catch (e) {\n // If json is not valid, set error to the original errorMessage\n\n error = errorMessage;\n }\n\n // render toast for each error if there is more than one\n // otherwise render the toast with the error message\n [error]\n .flatMap((error) => error)\n .forEach((error) =>\n toast({\n title:\n (process.env.NODE_ENV === 'production'\n ? error.title\n : error.code) ?? 'Error',\n description: error.message ?? errorMessage ?? 'An error occurred',\n variant: 'error',\n })\n );\n options.onError?.(errorMessage);\n },\n onSuccess: (data) => {\n if (data?.message)\n toast({\n title: data.message,\n description: data.description,\n variant: 'success',\n });\n options.onSuccess?.(data);\n },\n };\n};\n\ntype AuthEnableOptions = {\n requireUser?: boolean;\n requireProject?: boolean;\n requireOrganization?: boolean;\n};\n\n/**\n * Hook to enable authentication\n */\nconst useAuthEnable = <T extends UseAsyncOptions<any>>(\n options: T,\n { requireUser, requireProject, requireOrganization }: AuthEnableOptions = {}\n): T => {\n const configuration = useConfiguration();\n const { csrfToken, oAuth2AccessToken, session } = useAuth({\n intlayerConfiguration: configuration,\n });\n\n const isEnabledOption = options?.enable ?? true;\n const user = session ? session.user : oAuth2AccessToken?.user;\n\n const organization = session\n ? session.organization\n : oAuth2AccessToken?.organization;\n\n const project = session ? session.project : oAuth2AccessToken?.project;\n\n const isUserEnabled = requireUser ? Boolean(user) : true;\n\n const isProjectEnabled = requireProject ? Boolean(project) : true;\n\n const isOrganizationEnabled = requireOrganization\n ? Boolean(organization)\n : true;\n\n const isCSRFEnabled =\n Boolean(csrfToken) ||\n // If auth using session, csrf token is not required\n (!session && Boolean(oAuth2AccessToken));\n\n const isEnabled =\n isEnabledOption &&\n isUserEnabled &&\n isProjectEnabled &&\n isOrganizationEnabled &&\n isCSRFEnabled;\n\n return {\n ...options,\n enable: isEnabled,\n };\n};\n\nconst useAppAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>,\n authOptions?: AuthEnableOptions\n) => {\n // Enhance options using custom hooks\n const optionsWithAuth = useAuthEnable(options ?? {}, authOptions);\n\n const optionsWithErrorHandling = useErrorHandling(optionsWithAuth);\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\nconst useEditorAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n) => {\n const optionsWithErrorHandling = useErrorHandling(options ?? {});\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\n/**\n * Auth\n */\n\nexport const useLogin = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['login']>\n) =>\n useAppAsync('login', useIntlayerAuth().auth.login, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useRegister = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['register']>\n) =>\n useAppAsync('register', useIntlayerAuth().auth.register, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useLogout = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['logout']>\n) =>\n useAppAsync('logout', useIntlayerAuth().auth.logout, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useChangePassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['changePassword']>\n) => useAppAsync('changePassword', useIntlayerAuth().auth.changePassword, args);\n\nexport const useAskResetPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['askResetPassword']>\n) =>\n useAppAsync(\n 'askResetPassword',\n useIntlayerAuth().auth.askResetPassword,\n args\n );\n\nexport const useDefineNewPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['defineNewPassword']>\n) =>\n useAppAsync(\n 'defineNewPassword',\n useIntlayerAuth().auth.defineNewPassword,\n args\n );\n\nexport const useCheckIfUserHasPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['checkIfUserHasPassword']>\n) =>\n useAppAsync(\n 'checkIfUserHasPassword',\n useIntlayerAuth().auth.checkIfUserHasPassword,\n args,\n {\n requireUser: true,\n }\n );\n\nexport const useVerifyEmail = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['verifyEmail']>\n) => useAppAsync('verifyEmail', useIntlayerAuth().auth.verifyEmail, args);\n\nexport const useGetUserByAccount = (\n args?: UseAsyncOptions<IntlayerAPI['user']['getUserByAccount']>\n) =>\n useAppAsync(\n 'getUserByAccount',\n useIntlayerAuth().user.getUserByAccount,\n args\n );\n\n/**\n * User\n */\n\nexport const useGetUsers = (\n args?: UseAsyncOptions<IntlayerAPI['user']['getUsers']>\n) =>\n useAppAsync(\n 'getUsers',\n useIntlayerAuth().user.getUsers,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\n\nexport const useCreateUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['createUser']>\n) =>\n useAppAsync('createUser', useIntlayerAuth().user.createUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\n\nexport const useUpdateUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['updateUser']>\n) =>\n useAppAsync('updateUser', useIntlayerAuth().user.updateUser, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useDeleteUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['deleteUser']>\n) =>\n useAppAsync('deleteUser', useIntlayerAuth().user.deleteUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\n\n/**\n * Organization\n */\n\nexport const useGetOrganizations = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['getOrganizations']>\n) =>\n useAppAsync(\n 'getOrganizations',\n useIntlayerAuth().organization.getOrganizations,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\n\nexport const useAddOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['addOrganization']>\n) =>\n useAppAsync(\n 'addOrganization',\n useIntlayerAuth().organization.addOrganization,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\n\nexport const useUpdateOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['updateOrganization']>\n) =>\n useAppAsync(\n 'updateOrganization',\n useIntlayerAuth().organization.updateOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\nexport const useUpdateOrganizationMembers = (\n args?: UseAsyncOptions<\n IntlayerAPI['organization']['updateOrganizationMembers']\n >\n) =>\n useAppAsync(\n 'updateOrganizationMembers',\n useIntlayerAuth().organization.updateOrganizationMembers,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\n\nexport const useAddOrganizationMember = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['addOrganizationMember']>\n) =>\n useAppAsync(\n 'addOrganizationMember',\n useIntlayerAuth().organization.addOrganizationMember,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\n\nexport const useDeleteOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['deleteOrganization']>\n) =>\n useAppAsync(\n 'deleteOrganization',\n useIntlayerAuth().organization.deleteOrganization,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\n\nexport const useSelectOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['selectOrganization']>\n) =>\n useAppAsync(\n 'selectOrganization',\n useIntlayerAuth().organization.selectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\nexport const useUnselectOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['unselectOrganization']>\n) =>\n useAppAsync(\n 'unselectOrganization',\n useIntlayerAuth().organization.unselectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\n/**\n * Project\n */\n\nexport const useGetProjects = (\n args?: UseAsyncOptions<IntlayerAPI['project']['getProjects']>\n) =>\n useAppAsync(\n 'getProjects',\n useIntlayerAuth().project.getProjects,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useAddProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['addProject']>\n) =>\n useAppAsync('addProject', useIntlayerAuth().project.addProject, {\n invalidateQueries: ['getProjects'],\n ...args,\n });\n\nexport const useUpdateProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['updateProject']>\n) =>\n useAppAsync('updateProject', useIntlayerAuth().project.updateProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useUpdateProjectMembers = (\n args?: UseAsyncOptions<IntlayerAPI['project']['updateProjectMembers']>\n) =>\n useAppAsync(\n 'updateProjectMembers',\n useIntlayerAuth().project.updateProjectMembers,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\nexport const useDeleteProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['deleteProject']>\n) =>\n useAppAsync('deleteProject', useIntlayerAuth().project.deleteProject, {\n invalidateQueries: ['getProjects', 'getSession'],\n ...args,\n });\n\nexport const useSelectProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['selectProject']>\n) =>\n useAppAsync('selectProject', useIntlayerAuth().project.selectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useUnselectProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['unselectProject']>\n) =>\n useAppAsync('unselectProject', useIntlayerAuth().project.unselectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useAddNewAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['addNewAccessKey']>\n) =>\n useAppAsync('addNewAccessKey', useIntlayerAuth().project.addNewAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useDeleteAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['deleteAccessKey']>\n) =>\n useAppAsync('deleteAccessKey', useIntlayerAuth().project.deleteAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useRefreshAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['refreshAccessKey']>\n) =>\n useAppAsync('refreshAccessKey', useIntlayerAuth().project.refreshAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\n/**\n * Dictionary\n */\n\nexport const useGetDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionaries']>\n) =>\n useAppAsync(\n 'getDictionaries',\n useIntlayerAuth().dictionary.getDictionaries,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionariesKeys = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionariesKeys']>\n) =>\n useAppAsync(\n 'getDictionariesKeys',\n useIntlayerAuth().dictionary.getDictionariesKeys,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionary']>\n) =>\n useAppAsync(\n 'getDictionary',\n useIntlayerAuth().dictionary.getDictionary,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAddDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['addDictionary']>\n) =>\n useAppAsync('addDictionary', useIntlayerAuth().dictionary.addDictionary, {\n invalidateQueries: ['getDictionaries', 'getDictionariesKeys'],\n ...args,\n });\n\nexport const usePushDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['pushDictionaries']>\n) =>\n useAppAsync(\n 'pushDictionaries',\n useIntlayerAuth().dictionary.pushDictionaries,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\n\nexport const useUpdateDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['updateDictionary']>\n) =>\n useAppAsync(\n 'updateDictionary',\n useIntlayerAuth().dictionary.updateDictionary,\n {\n invalidateQueries: ['getDictionaries', 'getDictionary'],\n ...args,\n }\n );\n\nexport const useDeleteDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['deleteDictionary']>\n) =>\n useAppAsync(\n 'deleteDictionary',\n useIntlayerAuth().dictionary.deleteDictionary,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\n\n/**\n * Tag\n */\n\nexport const useGetTags = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['getTags']>\n) =>\n useAppAsync(\n 'getTags',\n useIntlayerAuth().tag.getTags,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useAddTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['addTag']>\n) =>\n useAppAsync('addTag', useIntlayerAuth().tag.addTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\n\nexport const useUpdateTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['updateTag']>\n) =>\n useAppAsync('updateTag', useIntlayerAuth().tag.updateTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\n\nexport const useDeleteTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['deleteTag']>\n) =>\n useAppAsync('deleteTag', useIntlayerAuth().tag.deleteTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\n\n/**\n * Stripe\n */\n\nexport const useGetPricing = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['getPricing']>\n) =>\n useAppAsync('getPricing', useIntlayerAuth().stripe.getPricing, {\n store: true,\n cache: true,\n ...args,\n });\n\nexport const useGetSubscription = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['getSubscription']>\n) =>\n useAppAsync(\n 'getSubscription',\n useIntlayerAuth().stripe.getSubscription,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useCancelSubscription = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['cancelSubscription']>\n) =>\n useAppAsync(\n 'cancelSubscription',\n useIntlayerAuth().stripe.cancelSubscription,\n { invalidateQueries: ['getSession'], ...args },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\n/**\n * AI\n */\n\nexport const useTranslateJSONDeclaration = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['translateJSON']>\n) =>\n useAppAsync('translateJSON', useIntlayerAuth().ai.translateJSON, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n\nexport const useAuditContentDeclaration = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclaration']>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclaration,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationMetadata = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclarationMetadata']>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclarationMetadata,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationField = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclarationField']>\n) =>\n useAppAsync(\n 'auditContentDeclarationField',\n useIntlayerAuth().ai.auditContentDeclarationField,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditTag = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditTag']>\n) =>\n useAppAsync('auditTag', useIntlayerAuth().ai.auditTag, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n\nexport const useAskDocQuestion = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['askDocQuestion']>\n) => useAppAsync('askDocQuestion', useIntlayerAuth().ai.askDocQuestion, args);\n\nexport const useAutocomplete = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['autocomplete']>\n) => useAppAsync('autocomplete', useIntlayerAuth().ai.autocomplete, args);\n\n/**\n * Search\n */\n\nexport const useSearchDoc = (\n args?: UseAsyncOptions<IntlayerAPI['search']['searchDoc']>\n) => useAppAsync('searchDoc', useIntlayerAuth().search.searchDoc, args);\n\n/**\n * Editor\n */\n\nexport const useWriteDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['editor']['writeDictionary']>\n) =>\n useEditorAsync(\n 'writeDictionary',\n useIntlayerAuth().editor.writeDictionary,\n args\n );\n\nexport const useGetEditorDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['editor']['getDictionaries']>\n) =>\n useEditorAsync('getDictionaries', useIntlayerAuth().editor.getDictionaries, {\n store: true,\n cache: true,\n ...args,\n });\n"],"names":["useToast","error","useConfiguration","useAuth","useAsync","useIntlayerAuth"],"mappings":";;;;;;;;;;;AAYA,MAAM,mBAAmB,CAAiC,YAAkB;AACpE,QAAA,EAAE,MAAM,IAAIA,qCAAS;AAEpB,SAAA;AAAA,IACL,GAAG;AAAA,IACH,SAAS,CAAC,iBAAiB;AACrB,UAAA;AAGA,UAAA;AAC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AG;AAAA,EACrB;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,EAAA;AAEpB;AAEW,MAAA,cAAc,CACzB,SAEA,YAAY,YAAYA,qBAAAA,kBAAkB,GAAG,UAAU,MAAM;AAAA,EAC3D,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAClB,CAAC;AAEU,MAAA,oBAAoB,CAC/B,SACG,YAAY,kBAAkBA,qBAAAA,kBAAkB,GAAG,gBAAgB,IAAI;AAE/D,MAAA,kBAAkB,CAC7B,SACG,YAAY,gBAAgBA,qBAAAA,kBAAkB,GAAG,cAAc,IAAI;AAM3D,MAAA,eAAe,CAC1B,SACG,YAAY,aAAaA,qBAAAA,kBAAkB,OAAO,WAAW,IAAI;AAMzD,MAAA,qBAAqB,CAChC,SAEA;AAAA,EACE;AAAA,EACAA,qBAAA,gBAAA,EAAkB,OAAO;AAAA,EACzB;AACF;AAEW,MAAA,2BAA2B,CACtC,SAEA,eAAe,mBAAmBA,qCAAgB,EAAE,OAAO,iBAAiB;AAAA,EAC1E,OAAO;AAAA,EACP,OAAO;AAAA,EACP,GAAG;AACL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -8,7 +8,6 @@ export declare const useRegister: (args?: UseAsyncOptions<IntlayerAPI["auth"]["r
8
8
  export declare const useLogout: (args?: UseAsyncOptions<IntlayerAPI["auth"]["logout"]>) => import('./useAsync').UseAsyncResult<"logout", (otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<void>>;
9
9
  export declare const useChangePassword: (args?: UseAsyncOptions<IntlayerAPI["auth"]["changePassword"]>) => import('./useAsync').UseAsyncResult<"changePassword", (data: import('@intlayer/backend').UpdatePasswordBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').UpdatePasswordResult>>;
10
10
  export declare const useAskResetPassword: (args?: UseAsyncOptions<IntlayerAPI["auth"]["askResetPassword"]>) => import('./useAsync').UseAsyncResult<"askResetPassword", (email: import('@intlayer/backend').AskResetPasswordBody["email"], otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').AskResetPasswordResult>>;
11
- export declare const useResetPassword: (args?: UseAsyncOptions<IntlayerAPI["auth"]["resetPassword"]>) => import('./useAsync').UseAsyncResult<"resetPassword", (params: ResetPasswordParams, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<ResetPasswordResult>>;
12
11
  export declare const useDefineNewPassword: (args?: UseAsyncOptions<IntlayerAPI["auth"]["defineNewPassword"]>) => import('./useAsync').UseAsyncResult<"defineNewPassword", (data: import('@intlayer/backend').DefinePasswordBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').DefinePasswordResult>>;
13
12
  export declare const useCheckIfUserHasPassword: (args?: UseAsyncOptions<IntlayerAPI["auth"]["checkIfUserHasPassword"]>) => import('./useAsync').UseAsyncResult<"checkIfUserHasPassword", (otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').CheckIfUserHasPasswordResult>>;
14
13
  export declare const useVerifyEmail: (args?: UseAsyncOptions<IntlayerAPI["auth"]["verifyEmail"]>) => import('./useAsync').UseAsyncResult<"verifyEmail", ({ userId, secret }: import('@intlayer/backend').ValidEmailParams, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').ValidEmailResult>>;
@@ -70,15 +69,20 @@ export declare const useCancelSubscription: (args?: UseAsyncOptions<IntlayerAPI[
70
69
  /**
71
70
  * AI
72
71
  */
73
- export declare const useTranslateJSONDeclaration: (args?: UseAsyncOptions<IntlayerAPI["ai"]["translateJSON"]>) => import('./useAsync').UseAsyncResult<"translateJSON", (body?: TranslateJSONResultBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').TranslateJSONResult>>;
72
+ export declare const useTranslateJSONDeclaration: (args?: UseAsyncOptions<IntlayerAPI["ai"]["translateJSON"]>) => import('./useAsync').UseAsyncResult<"translateJSON", (body?: import('@intlayer/backend').TranslateJSONBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').TranslateJSONResult>>;
74
73
  export declare const useAuditContentDeclaration: (args?: UseAsyncOptions<IntlayerAPI["ai"]["auditContentDeclaration"]>) => import('./useAsync').UseAsyncResult<"auditContentDeclaration", (body?: import('@intlayer/backend').AuditContentDeclarationBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').AuditContentDeclarationResult>>;
75
74
  export declare const useAuditContentDeclarationMetadata: (args?: UseAsyncOptions<IntlayerAPI["ai"]["auditContentDeclarationMetadata"]>) => import('./useAsync').UseAsyncResult<"auditContentDeclaration", (body?: import('@intlayer/backend').AuditContentDeclarationMetadataBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').AuditContentDeclarationMetadataResult>>;
76
75
  export declare const useAuditContentDeclarationField: (args?: UseAsyncOptions<IntlayerAPI["ai"]["auditContentDeclarationField"]>) => import('./useAsync').UseAsyncResult<"auditContentDeclarationField", (body?: import('@intlayer/backend').AuditContentDeclarationFieldBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').AuditContentDeclarationFieldResult>>;
77
76
  export declare const useAuditTag: (args?: UseAsyncOptions<IntlayerAPI["ai"]["auditTag"]>) => import('./useAsync').UseAsyncResult<"auditTag", (body?: import('@intlayer/backend').AuditTagBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').AuditTagResult>>;
78
77
  export declare const useAskDocQuestion: (args?: UseAsyncOptions<IntlayerAPI["ai"]["askDocQuestion"]>) => import('./useAsync').UseAsyncResult<"askDocQuestion", (body?: import('@intlayer/api').AskDocQuestionBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<void>>;
79
78
  export declare const useAutocomplete: (args?: UseAsyncOptions<IntlayerAPI["ai"]["autocomplete"]>) => import('./useAsync').UseAsyncResult<"autocomplete", (body?: import('@intlayer/backend').AutocompleteBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').AutocompleteResponse>>;
79
+ /**
80
+ * Search
81
+ */
82
+ export declare const useSearchDoc: (args?: UseAsyncOptions<IntlayerAPI["search"]["searchDoc"]>) => import('./useAsync').UseAsyncResult<"searchDoc", (params?: import('@intlayer/backend').SearchDocUtilParams, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('@intlayer/backend').SearchDocUtilResult>>;
80
83
  /**
81
84
  * Editor
82
85
  */
83
- export declare const useWriteDictionary: (args?: UseAsyncOptions<IntlayerAPI["editor"]["writeDictionary"]>) => import('./useAsync').UseAsyncResult<"writeDictionary", (dictionary: WriteContentDeclarationBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<WriteContentDeclarationResult>>;
86
+ export declare const useWriteDictionary: (args?: UseAsyncOptions<IntlayerAPI["editor"]["writeDictionary"]>) => import('./useAsync').UseAsyncResult<"writeDictionary", (dictionary: import('intlayer-editor').WriteContentDeclarationBody, otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<import('intlayer-editor').WriteContentDeclarationResult>>;
87
+ export declare const useGetEditorDictionaries: (args?: UseAsyncOptions<IntlayerAPI["editor"]["getDictionaries"]>) => import('./useAsync').UseAsyncResult<"getDictionaries", (otherOptions?: import('@intlayer/api').FetcherOptions) => Promise<Record<string, any>>>;
84
88
  //# sourceMappingURL=intlayerAPIHooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerAPIHooks.d.ts","sourceRoot":"","sources":["../../src/hooks/intlayerAPIHooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAIjD,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,qBAAqB,CAAC;AA0IrE;;GAEG;AAEH,eAAO,MAAM,QAAQ,GACnB,OAAO,eAAe,CAAC,WAAW,CAAC,MA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,CAAC,CAAC,qNAMnD,CAAC;AAEL,eAAO,MAAM,iBAAiB,GAC5B,OAAO,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,CAAC,uLACgB,CAAC;AAE9E,eAAO,MAAM,eAAe,GAC1B,OAAO,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,mOACc,CAAC;AAE1E;;GAEG;AAEH,eAAO,MAAM,YAAY,GACvB,OAAO,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,oOACW,CAAC;AAExE;;GAEG;AAEH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAAC,2PAM/D,CAAC;AAEJ,eAAO,MAAM,wBAAwB,GACnC,OAAO,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAAC,oJAM9D,CAAC"}
@@ -86,7 +86,6 @@ const useAskResetPassword = (args) => useAppAsync(
86
86
  useIntlayerAuth().auth.askResetPassword,
87
87
  args
88
88
  );
89
- const useResetPassword = (args) => useAppAsync("resetPassword", useIntlayerAuth().auth.resetPassword, args);
90
89
  const useDefineNewPassword = (args) => useAppAsync(
91
90
  "defineNewPassword",
92
91
  useIntlayerAuth().auth.defineNewPassword,
@@ -452,11 +451,17 @@ const useAuditTag = (args) => useAppAsync("auditTag", useIntlayerAuth().ai.audit
452
451
  });
453
452
  const useAskDocQuestion = (args) => useAppAsync("askDocQuestion", useIntlayerAuth().ai.askDocQuestion, args);
454
453
  const useAutocomplete = (args) => useAppAsync("autocomplete", useIntlayerAuth().ai.autocomplete, args);
454
+ const useSearchDoc = (args) => useAppAsync("searchDoc", useIntlayerAuth().search.searchDoc, args);
455
455
  const useWriteDictionary = (args) => useEditorAsync(
456
456
  "writeDictionary",
457
457
  useIntlayerAuth().editor.writeDictionary,
458
458
  args
459
459
  );
460
+ const useGetEditorDictionaries = (args) => useEditorAsync("getDictionaries", useIntlayerAuth().editor.getDictionaries, {
461
+ store: true,
462
+ cache: true,
463
+ ...args
464
+ });
460
465
  export {
461
466
  useAddDictionary,
462
467
  useAddNewAccessKey,
@@ -485,6 +490,7 @@ export {
485
490
  useGetDictionaries,
486
491
  useGetDictionariesKeys,
487
492
  useGetDictionary,
493
+ useGetEditorDictionaries,
488
494
  useGetOrganizations,
489
495
  useGetPricing,
490
496
  useGetProjects,
@@ -497,7 +503,7 @@ export {
497
503
  usePushDictionaries,
498
504
  useRefreshAccessKey,
499
505
  useRegister,
500
- useResetPassword,
506
+ useSearchDoc,
501
507
  useSelectOrganization,
502
508
  useSelectProject,
503
509
  useTranslateJSONDeclaration,
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerAPIHooks.mjs","sources":["../../src/hooks/intlayerAPIHooks.ts"],"sourcesContent":["'use client';\n\nimport type { IntlayerAPI } from '@intlayer/api';\nimport { useConfiguration } from '@intlayer/editor-react';\nimport { useAuth } from '../components/Auth/useAuth/index';\nimport { useToast } from '../components/Toaster';\nimport { type UseAsyncOptions, useAsync } from './useAsync/useAsync';\nimport { useIntlayerAuth } from './useIntlayerAPI';\n\n/**\n * Hook to handle error logging and toast notifications\n */\nconst useErrorHandling = <T extends UseAsyncOptions<any>>(options: T): T => {\n const { toast } = useToast();\n\n return {\n ...options,\n onError: (errorMessage) => {\n let error;\n\n // If json is valid, parse it\n try {\n if (typeof errorMessage === 'undefined') return;\n\n error = JSON.parse(errorMessage);\n } catch (e) {\n // If json is not valid, set error to the original errorMessage\n\n error = errorMessage;\n }\n\n // render toast for each error if there is more than one\n // otherwise render the toast with the error message\n [error]\n .flatMap((error) => error)\n .forEach((error) =>\n toast({\n title:\n (process.env.NODE_ENV === 'production'\n ? error.title\n : error.code) ?? 'Error',\n description: error.message ?? errorMessage ?? 'An error occurred',\n variant: 'error',\n })\n );\n options.onError?.(errorMessage);\n },\n onSuccess: (data) => {\n if (data?.message)\n toast({\n title: data.message,\n description: data.description,\n variant: 'success',\n });\n options.onSuccess?.(data);\n },\n };\n};\n\ntype AuthEnableOptions = {\n requireUser?: boolean;\n requireProject?: boolean;\n requireOrganization?: boolean;\n};\n\n/**\n * Hook to enable authentication\n */\nconst useAuthEnable = <T extends UseAsyncOptions<any>>(\n options: T,\n { requireUser, requireProject, requireOrganization }: AuthEnableOptions = {}\n): T => {\n const configuration = useConfiguration();\n const { csrfToken, oAuth2AccessToken, session } = useAuth({\n intlayerConfiguration: configuration,\n });\n\n const isEnabledOption = options?.enable ?? true;\n const user = session ? session.user : oAuth2AccessToken?.user;\n\n const organization = session\n ? session.organization\n : oAuth2AccessToken?.organization;\n\n const project = session ? session.project : oAuth2AccessToken?.project;\n\n const isUserEnabled = requireUser ? Boolean(user) : true;\n\n const isProjectEnabled = requireProject ? Boolean(project) : true;\n\n const isOrganizationEnabled = requireOrganization\n ? Boolean(organization)\n : true;\n\n const isCSRFEnabled =\n Boolean(csrfToken) ||\n // If auth using session, csrf token is not required\n (!session && Boolean(oAuth2AccessToken));\n\n const isEnabled =\n isEnabledOption &&\n isUserEnabled &&\n isProjectEnabled &&\n isOrganizationEnabled &&\n isCSRFEnabled;\n\n return {\n ...options,\n enable: isEnabled,\n };\n};\n\nconst useAppAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>,\n authOptions?: AuthEnableOptions\n) => {\n // Enhance options using custom hooks\n const optionsWithAuth = useAuthEnable(options ?? {}, authOptions);\n\n const optionsWithErrorHandling = useErrorHandling(optionsWithAuth);\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\nconst useEditorAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n) => {\n const optionsWithErrorHandling = useErrorHandling(options ?? {});\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\n/**\n * Auth\n */\n\nexport const useLogin = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['login']>\n) =>\n useAppAsync('login', useIntlayerAuth().auth.login, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useRegister = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['register']>\n) =>\n useAppAsync('register', useIntlayerAuth().auth.register, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useLogout = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['logout']>\n) =>\n useAppAsync('logout', useIntlayerAuth().auth.logout, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useChangePassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['changePassword']>\n) => useAppAsync('changePassword', useIntlayerAuth().auth.changePassword, args);\nexport const useAskResetPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['askResetPassword']>\n) =>\n useAppAsync(\n 'askResetPassword',\n useIntlayerAuth().auth.askResetPassword,\n args\n );\nexport const useResetPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['resetPassword']>\n) => useAppAsync('resetPassword', useIntlayerAuth().auth.resetPassword, args);\nexport const useDefineNewPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['defineNewPassword']>\n) =>\n useAppAsync(\n 'defineNewPassword',\n useIntlayerAuth().auth.defineNewPassword,\n args\n );\nexport const useCheckIfUserHasPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['checkIfUserHasPassword']>\n) =>\n useAppAsync(\n 'checkIfUserHasPassword',\n useIntlayerAuth().auth.checkIfUserHasPassword,\n args,\n {\n requireUser: true,\n }\n );\nexport const useVerifyEmail = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['verifyEmail']>\n) => useAppAsync('verifyEmail', useIntlayerAuth().auth.verifyEmail, args);\n\nexport const useGetUserByAccount = (\n args?: UseAsyncOptions<IntlayerAPI['user']['getUserByAccount']>\n) =>\n useAppAsync(\n 'getUserByAccount',\n useIntlayerAuth().user.getUserByAccount,\n args\n );\n\n/**\n * User\n */\n\nexport const useGetUsers = (\n args?: UseAsyncOptions<IntlayerAPI['user']['getUsers']>\n) =>\n useAppAsync(\n 'getUsers',\n useIntlayerAuth().user.getUsers,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\nexport const useCreateUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['createUser']>\n) =>\n useAppAsync('createUser', useIntlayerAuth().user.createUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\nexport const useUpdateUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['updateUser']>\n) =>\n useAppAsync('updateUser', useIntlayerAuth().user.updateUser, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useDeleteUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['deleteUser']>\n) =>\n useAppAsync('deleteUser', useIntlayerAuth().user.deleteUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\n\n/**\n * Organization\n */\n\nexport const useGetOrganizations = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['getOrganizations']>\n) =>\n useAppAsync(\n 'getOrganizations',\n useIntlayerAuth().organization.getOrganizations,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\n\nexport const useAddOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['addOrganization']>\n) =>\n useAppAsync(\n 'addOrganization',\n useIntlayerAuth().organization.addOrganization,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\nexport const useUpdateOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['updateOrganization']>\n) =>\n useAppAsync(\n 'updateOrganization',\n useIntlayerAuth().organization.updateOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useUpdateOrganizationMembers = (\n args?: UseAsyncOptions<\n IntlayerAPI['organization']['updateOrganizationMembers']\n >\n) =>\n useAppAsync(\n 'updateOrganizationMembers',\n useIntlayerAuth().organization.updateOrganizationMembers,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\nexport const useAddOrganizationMember = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['addOrganizationMember']>\n) =>\n useAppAsync(\n 'addOrganizationMember',\n useIntlayerAuth().organization.addOrganizationMember,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\nexport const useDeleteOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['deleteOrganization']>\n) =>\n useAppAsync(\n 'deleteOrganization',\n useIntlayerAuth().organization.deleteOrganization,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\nexport const useSelectOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['selectOrganization']>\n) =>\n useAppAsync(\n 'selectOrganization',\n useIntlayerAuth().organization.selectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useUnselectOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['unselectOrganization']>\n) =>\n useAppAsync(\n 'unselectOrganization',\n useIntlayerAuth().organization.unselectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\n/**\n * Project\n */\n\nexport const useGetProjects = (\n args?: UseAsyncOptions<IntlayerAPI['project']['getProjects']>\n) =>\n useAppAsync(\n 'getProjects',\n useIntlayerAuth().project.getProjects,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\nexport const useAddProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['addProject']>\n) =>\n useAppAsync('addProject', useIntlayerAuth().project.addProject, {\n invalidateQueries: ['getProjects'],\n ...args,\n });\nexport const useUpdateProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['updateProject']>\n) =>\n useAppAsync('updateProject', useIntlayerAuth().project.updateProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useUpdateProjectMembers = (\n args?: UseAsyncOptions<IntlayerAPI['project']['updateProjectMembers']>\n) =>\n useAppAsync(\n 'updateProjectMembers',\n useIntlayerAuth().project.updateProjectMembers,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\nexport const useDeleteProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['deleteProject']>\n) =>\n useAppAsync('deleteProject', useIntlayerAuth().project.deleteProject, {\n invalidateQueries: ['getProjects', 'getSession'],\n ...args,\n });\nexport const useSelectProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['selectProject']>\n) =>\n useAppAsync('selectProject', useIntlayerAuth().project.selectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useUnselectProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['unselectProject']>\n) =>\n useAppAsync('unselectProject', useIntlayerAuth().project.unselectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useAddNewAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['addNewAccessKey']>\n) =>\n useAppAsync('addNewAccessKey', useIntlayerAuth().project.addNewAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useDeleteAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['deleteAccessKey']>\n) =>\n useAppAsync('deleteAccessKey', useIntlayerAuth().project.deleteAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\nexport const useRefreshAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['refreshAccessKey']>\n) =>\n useAppAsync('refreshAccessKey', useIntlayerAuth().project.refreshAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\n/**\n * Dictionary\n */\n\nexport const useGetDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionaries']>\n) =>\n useAppAsync(\n 'getDictionaries',\n useIntlayerAuth().dictionary.getDictionaries,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionariesKeys = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionariesKeys']>\n) =>\n useAppAsync(\n 'getDictionariesKeys',\n useIntlayerAuth().dictionary.getDictionariesKeys,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionary']>\n) =>\n useAppAsync(\n 'getDictionary',\n useIntlayerAuth().dictionary.getDictionary,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\nexport const useAddDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['addDictionary']>\n) =>\n useAppAsync('addDictionary', useIntlayerAuth().dictionary.addDictionary, {\n invalidateQueries: ['getDictionaries', 'getDictionariesKeys'],\n ...args,\n });\n\nexport const usePushDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['pushDictionaries']>\n) =>\n useAppAsync(\n 'pushDictionaries',\n useIntlayerAuth().dictionary.pushDictionaries,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\nexport const useUpdateDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['updateDictionary']>\n) =>\n useAppAsync(\n 'updateDictionary',\n useIntlayerAuth().dictionary.updateDictionary,\n {\n invalidateQueries: ['getDictionaries', 'getDictionary'],\n ...args,\n }\n );\nexport const useDeleteDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['deleteDictionary']>\n) =>\n useAppAsync(\n 'deleteDictionary',\n useIntlayerAuth().dictionary.deleteDictionary,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\n\n/**\n * Tag\n */\n\nexport const useGetTags = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['getTags']>\n) =>\n useAppAsync(\n 'getTags',\n useIntlayerAuth().tag.getTags,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\nexport const useAddTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['addTag']>\n) =>\n useAppAsync('addTag', useIntlayerAuth().tag.addTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\nexport const useUpdateTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['updateTag']>\n) =>\n useAppAsync('updateTag', useIntlayerAuth().tag.updateTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\nexport const useDeleteTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['deleteTag']>\n) =>\n useAppAsync('deleteTag', useIntlayerAuth().tag.deleteTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\n\n/**\n * Stripe\n */\n\nexport const useGetPricing = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['getPricing']>\n) =>\n useAppAsync('getPricing', useIntlayerAuth().stripe.getPricing, {\n store: true,\n cache: true,\n ...args,\n });\n\nexport const useGetSubscription = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['getSubscription']>\n) =>\n useAppAsync(\n 'getSubscription',\n useIntlayerAuth().stripe.getSubscription,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useCancelSubscription = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['cancelSubscription']>\n) =>\n useAppAsync(\n 'cancelSubscription',\n useIntlayerAuth().stripe.cancelSubscription,\n { invalidateQueries: ['getSession'], ...args },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\n/**\n * AI\n */\n\nexport const useTranslateJSONDeclaration = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['translateJSON']>\n) =>\n useAppAsync('translateJSON', useIntlayerAuth().ai.translateJSON, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n\nexport const useAuditContentDeclaration = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclaration']>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclaration,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationMetadata = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclarationMetadata']>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclarationMetadata,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationField = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclarationField']>\n) =>\n useAppAsync(\n 'auditContentDeclarationField',\n useIntlayerAuth().ai.auditContentDeclarationField,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditTag = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditTag']>\n) =>\n useAppAsync('auditTag', useIntlayerAuth().ai.auditTag, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n\nexport const useAskDocQuestion = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['askDocQuestion']>\n) => useAppAsync('askDocQuestion', useIntlayerAuth().ai.askDocQuestion, args);\n\nexport const useAutocomplete = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['autocomplete']>\n) => useAppAsync('autocomplete', useIntlayerAuth().ai.autocomplete, args);\n\n/**\n * Editor\n */\n\nexport const useWriteDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['editor']['writeDictionary']>\n) =>\n useEditorAsync(\n 'writeDictionary',\n useIntlayerAuth().editor.writeDictionary,\n args\n );\n"],"names":["error"],"mappings":";;;;;;;;;AAYA,MAAM,mBAAmB,CAAiC,YAAkB;AACpE,QAAA,EAAE,MAAM,IAAI,SAAS;AAEpB,SAAA;AAAA,IACL,GAAG;AAAA,IACH,SAAS,CAAC,iBAAiB;AACrB,UAAA;AAGA,UAAA;AACE,YAAA,OAAO,iBAAiB,YAAa;AAEjC,gBAAA,KAAK,MAAM,YAAY;AAAA,eACxB,GAAG;AAGF,gBAAA;AAAA,MAAA;AAKV,OAAC,KAAK,EACH,QAAQ,CAACA,WAAUA,MAAK,EACxB;AAAA,QAAQ,CAACA,WACR,MAAM;AAAA,UACJ,QACG,2BAAY,aAAa,eACtBA,OAAM,QACNA,OAAM,SAAS;AAAA,UACrB,aAAaA,OAAM,WAAW,gBAAgB;AAAA,UAC9C,SAAS;AAAA,QACV,CAAA;AAAA,MACH;AACF,cAAQ,UAAU,YAAY;AAAA,IAChC;AAAA,IACA,WAAW,CAAC,SAAS;AACnB,UAAI,MAAM;AACF,cAAA;AAAA,UACJ,OAAO,KAAK;AAAA,UACZ,aAAa,KAAK;AAAA,UAClB,SAAS;AAAA,QAAA,CACV;AACH,cAAQ,YAAY,IAAI;AAAA,IAAA;AAAA,EAE5B;AACF;AAWA,MAAM,gBAAgB,CACpB,SACA,EAAE,aAAa,gBAAgB,oBAA2C,IAAA,OACpE;AACN,QAAM,gBAAgB,iBAAiB;AACvC,QAAM,EAAE,WAAW,mBAAmB,QAAA,IAAY,QAAQ;AAAA,IACxD,uBAAuB;AAAA,EAAA,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A;AAAA,EACE;AAAA,EACA,gBAAA,EAAkB,GAAG;AAAA,EACrB;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,EAAA;AAEpB;AAEW,MAAA,kCAAkC,CAC7C,SAEA;AAAA,EACE;AAAA,EACA,gBAAA,EAAkB,GAAG;AAAA,EACrB;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,EAAA;AAEpB;AAEW,MAAA,cAAc,CACzB,SAEA,YAAY,YAAY,kBAAkB,GAAG,UAAU,MAAM;AAAA,EAC3D,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAClB,CAAC;AAEU,MAAA,oBAAoB,CAC/B,SACG,YAAY,kBAAkB,kBAAkB,GAAG,gBAAgB,IAAI;AAE/D,MAAA,kBAAkB,CAC7B,SACG,YAAY,gBAAgB,kBAAkB,GAAG,cAAc,IAAI;AAM3D,MAAA,qBAAqB,CAChC,SAEA;AAAA,EACE;AAAA,EACA,gBAAA,EAAkB,OAAO;AAAA,EACzB;AACF;"}
1
+ {"version":3,"file":"intlayerAPIHooks.mjs","sources":["../../src/hooks/intlayerAPIHooks.ts"],"sourcesContent":["'use client';\n\nimport type { IntlayerAPI } from '@intlayer/api';\nimport { useConfiguration } from '@intlayer/editor-react';\nimport { useAuth } from '../components/Auth/useAuth/index';\nimport { useToast } from '../components/Toaster';\nimport { type UseAsyncOptions, useAsync } from './useAsync/useAsync';\nimport { useIntlayerAuth } from './useIntlayerAPI';\n\n/**\n * Hook to handle error logging and toast notifications\n */\nconst useErrorHandling = <T extends UseAsyncOptions<any>>(options: T): T => {\n const { toast } = useToast();\n\n return {\n ...options,\n onError: (errorMessage) => {\n let error;\n\n // If json is valid, parse it\n try {\n if (typeof errorMessage === 'undefined') return;\n\n error = JSON.parse(errorMessage);\n } catch (e) {\n // If json is not valid, set error to the original errorMessage\n\n error = errorMessage;\n }\n\n // render toast for each error if there is more than one\n // otherwise render the toast with the error message\n [error]\n .flatMap((error) => error)\n .forEach((error) =>\n toast({\n title:\n (process.env.NODE_ENV === 'production'\n ? error.title\n : error.code) ?? 'Error',\n description: error.message ?? errorMessage ?? 'An error occurred',\n variant: 'error',\n })\n );\n options.onError?.(errorMessage);\n },\n onSuccess: (data) => {\n if (data?.message)\n toast({\n title: data.message,\n description: data.description,\n variant: 'success',\n });\n options.onSuccess?.(data);\n },\n };\n};\n\ntype AuthEnableOptions = {\n requireUser?: boolean;\n requireProject?: boolean;\n requireOrganization?: boolean;\n};\n\n/**\n * Hook to enable authentication\n */\nconst useAuthEnable = <T extends UseAsyncOptions<any>>(\n options: T,\n { requireUser, requireProject, requireOrganization }: AuthEnableOptions = {}\n): T => {\n const configuration = useConfiguration();\n const { csrfToken, oAuth2AccessToken, session } = useAuth({\n intlayerConfiguration: configuration,\n });\n\n const isEnabledOption = options?.enable ?? true;\n const user = session ? session.user : oAuth2AccessToken?.user;\n\n const organization = session\n ? session.organization\n : oAuth2AccessToken?.organization;\n\n const project = session ? session.project : oAuth2AccessToken?.project;\n\n const isUserEnabled = requireUser ? Boolean(user) : true;\n\n const isProjectEnabled = requireProject ? Boolean(project) : true;\n\n const isOrganizationEnabled = requireOrganization\n ? Boolean(organization)\n : true;\n\n const isCSRFEnabled =\n Boolean(csrfToken) ||\n // If auth using session, csrf token is not required\n (!session && Boolean(oAuth2AccessToken));\n\n const isEnabled =\n isEnabledOption &&\n isUserEnabled &&\n isProjectEnabled &&\n isOrganizationEnabled &&\n isCSRFEnabled;\n\n return {\n ...options,\n enable: isEnabled,\n };\n};\n\nconst useAppAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>,\n authOptions?: AuthEnableOptions\n) => {\n // Enhance options using custom hooks\n const optionsWithAuth = useAuthEnable(options ?? {}, authOptions);\n\n const optionsWithErrorHandling = useErrorHandling(optionsWithAuth);\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\nconst useEditorAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n) => {\n const optionsWithErrorHandling = useErrorHandling(options ?? {});\n\n // Call the main useAsync hook with enhanced options\n return useAsync(key, asyncFunction, optionsWithErrorHandling);\n};\n\n/**\n * Auth\n */\n\nexport const useLogin = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['login']>\n) =>\n useAppAsync('login', useIntlayerAuth().auth.login, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useRegister = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['register']>\n) =>\n useAppAsync('register', useIntlayerAuth().auth.register, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useLogout = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['logout']>\n) =>\n useAppAsync('logout', useIntlayerAuth().auth.logout, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useChangePassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['changePassword']>\n) => useAppAsync('changePassword', useIntlayerAuth().auth.changePassword, args);\n\nexport const useAskResetPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['askResetPassword']>\n) =>\n useAppAsync(\n 'askResetPassword',\n useIntlayerAuth().auth.askResetPassword,\n args\n );\n\nexport const useDefineNewPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['defineNewPassword']>\n) =>\n useAppAsync(\n 'defineNewPassword',\n useIntlayerAuth().auth.defineNewPassword,\n args\n );\n\nexport const useCheckIfUserHasPassword = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['checkIfUserHasPassword']>\n) =>\n useAppAsync(\n 'checkIfUserHasPassword',\n useIntlayerAuth().auth.checkIfUserHasPassword,\n args,\n {\n requireUser: true,\n }\n );\n\nexport const useVerifyEmail = (\n args?: UseAsyncOptions<IntlayerAPI['auth']['verifyEmail']>\n) => useAppAsync('verifyEmail', useIntlayerAuth().auth.verifyEmail, args);\n\nexport const useGetUserByAccount = (\n args?: UseAsyncOptions<IntlayerAPI['user']['getUserByAccount']>\n) =>\n useAppAsync(\n 'getUserByAccount',\n useIntlayerAuth().user.getUserByAccount,\n args\n );\n\n/**\n * User\n */\n\nexport const useGetUsers = (\n args?: UseAsyncOptions<IntlayerAPI['user']['getUsers']>\n) =>\n useAppAsync(\n 'getUsers',\n useIntlayerAuth().user.getUsers,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\n\nexport const useCreateUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['createUser']>\n) =>\n useAppAsync('createUser', useIntlayerAuth().user.createUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\n\nexport const useUpdateUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['updateUser']>\n) =>\n useAppAsync('updateUser', useIntlayerAuth().user.updateUser, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useDeleteUser = (\n args?: UseAsyncOptions<IntlayerAPI['user']['deleteUser']>\n) =>\n useAppAsync('deleteUser', useIntlayerAuth().user.deleteUser, {\n invalidateQueries: ['getUsers'],\n ...args,\n });\n\n/**\n * Organization\n */\n\nexport const useGetOrganizations = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['getOrganizations']>\n) =>\n useAppAsync(\n 'getOrganizations',\n useIntlayerAuth().organization.getOrganizations,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n }\n );\n\nexport const useAddOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['addOrganization']>\n) =>\n useAppAsync(\n 'addOrganization',\n useIntlayerAuth().organization.addOrganization,\n {\n invalidateQueries: ['getOrganizations'],\n ...args,\n }\n );\n\nexport const useUpdateOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['updateOrganization']>\n) =>\n useAppAsync(\n 'updateOrganization',\n useIntlayerAuth().organization.updateOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\nexport const useUpdateOrganizationMembers = (\n args?: UseAsyncOptions<\n IntlayerAPI['organization']['updateOrganizationMembers']\n >\n) =>\n useAppAsync(\n 'updateOrganizationMembers',\n useIntlayerAuth().organization.updateOrganizationMembers,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\n\nexport const useAddOrganizationMember = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['addOrganizationMember']>\n) =>\n useAppAsync(\n 'addOrganizationMember',\n useIntlayerAuth().organization.addOrganizationMember,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\n\nexport const useDeleteOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['deleteOrganization']>\n) =>\n useAppAsync(\n 'deleteOrganization',\n useIntlayerAuth().organization.deleteOrganization,\n {\n invalidateQueries: ['getOrganizations', 'getSession'],\n ...args,\n }\n );\n\nexport const useSelectOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['selectOrganization']>\n) =>\n useAppAsync(\n 'selectOrganization',\n useIntlayerAuth().organization.selectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\nexport const useUnselectOrganization = (\n args?: UseAsyncOptions<IntlayerAPI['organization']['unselectOrganization']>\n) =>\n useAppAsync(\n 'unselectOrganization',\n useIntlayerAuth().organization.unselectOrganization,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\n/**\n * Project\n */\n\nexport const useGetProjects = (\n args?: UseAsyncOptions<IntlayerAPI['project']['getProjects']>\n) =>\n useAppAsync(\n 'getProjects',\n useIntlayerAuth().project.getProjects,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useAddProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['addProject']>\n) =>\n useAppAsync('addProject', useIntlayerAuth().project.addProject, {\n invalidateQueries: ['getProjects'],\n ...args,\n });\n\nexport const useUpdateProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['updateProject']>\n) =>\n useAppAsync('updateProject', useIntlayerAuth().project.updateProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useUpdateProjectMembers = (\n args?: UseAsyncOptions<IntlayerAPI['project']['updateProjectMembers']>\n) =>\n useAppAsync(\n 'updateProjectMembers',\n useIntlayerAuth().project.updateProjectMembers,\n {\n invalidateQueries: ['getSession'],\n ...args,\n }\n );\n\nexport const useDeleteProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['deleteProject']>\n) =>\n useAppAsync('deleteProject', useIntlayerAuth().project.deleteProject, {\n invalidateQueries: ['getProjects', 'getSession'],\n ...args,\n });\n\nexport const useSelectProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['selectProject']>\n) =>\n useAppAsync('selectProject', useIntlayerAuth().project.selectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useUnselectProject = (\n args?: UseAsyncOptions<IntlayerAPI['project']['unselectProject']>\n) =>\n useAppAsync('unselectProject', useIntlayerAuth().project.unselectProject, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useAddNewAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['addNewAccessKey']>\n) =>\n useAppAsync('addNewAccessKey', useIntlayerAuth().project.addNewAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useDeleteAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['deleteAccessKey']>\n) =>\n useAppAsync('deleteAccessKey', useIntlayerAuth().project.deleteAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\nexport const useRefreshAccessKey = (\n args?: UseAsyncOptions<IntlayerAPI['project']['refreshAccessKey']>\n) =>\n useAppAsync('refreshAccessKey', useIntlayerAuth().project.refreshAccessKey, {\n invalidateQueries: ['getSession'],\n ...args,\n });\n\n/**\n * Dictionary\n */\n\nexport const useGetDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionaries']>\n) =>\n useAppAsync(\n 'getDictionaries',\n useIntlayerAuth().dictionary.getDictionaries,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionariesKeys = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionariesKeys']>\n) =>\n useAppAsync(\n 'getDictionariesKeys',\n useIntlayerAuth().dictionary.getDictionariesKeys,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useGetDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['getDictionary']>\n) =>\n useAppAsync(\n 'getDictionary',\n useIntlayerAuth().dictionary.getDictionary,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAddDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['addDictionary']>\n) =>\n useAppAsync('addDictionary', useIntlayerAuth().dictionary.addDictionary, {\n invalidateQueries: ['getDictionaries', 'getDictionariesKeys'],\n ...args,\n });\n\nexport const usePushDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['pushDictionaries']>\n) =>\n useAppAsync(\n 'pushDictionaries',\n useIntlayerAuth().dictionary.pushDictionaries,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\n\nexport const useUpdateDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['updateDictionary']>\n) =>\n useAppAsync(\n 'updateDictionary',\n useIntlayerAuth().dictionary.updateDictionary,\n {\n invalidateQueries: ['getDictionaries', 'getDictionary'],\n ...args,\n }\n );\n\nexport const useDeleteDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['dictionary']['deleteDictionary']>\n) =>\n useAppAsync(\n 'deleteDictionary',\n useIntlayerAuth().dictionary.deleteDictionary,\n {\n invalidateQueries: [\n 'getDictionaries',\n 'getDictionary',\n 'getDictionariesKeys',\n ],\n ...args,\n }\n );\n\n/**\n * Tag\n */\n\nexport const useGetTags = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['getTags']>\n) =>\n useAppAsync(\n 'getTags',\n useIntlayerAuth().tag.getTags,\n {\n cache: true,\n store: true,\n retryLimit: 3,\n autoFetch: true,\n revalidation: true,\n revalidateTime: 5 * 60 * 1000, // 5 minutes\n ...args,\n },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useAddTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['addTag']>\n) =>\n useAppAsync('addTag', useIntlayerAuth().tag.addTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\n\nexport const useUpdateTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['updateTag']>\n) =>\n useAppAsync('updateTag', useIntlayerAuth().tag.updateTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\n\nexport const useDeleteTag = (\n args?: UseAsyncOptions<IntlayerAPI['tag']['deleteTag']>\n) =>\n useAppAsync('deleteTag', useIntlayerAuth().tag.deleteTag, {\n invalidateQueries: ['getTags'],\n ...args,\n });\n\n/**\n * Stripe\n */\n\nexport const useGetPricing = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['getPricing']>\n) =>\n useAppAsync('getPricing', useIntlayerAuth().stripe.getPricing, {\n store: true,\n cache: true,\n ...args,\n });\n\nexport const useGetSubscription = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['getSubscription']>\n) =>\n useAppAsync(\n 'getSubscription',\n useIntlayerAuth().stripe.getSubscription,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\nexport const useCancelSubscription = (\n args?: UseAsyncOptions<IntlayerAPI['stripe']['cancelSubscription']>\n) =>\n useAppAsync(\n 'cancelSubscription',\n useIntlayerAuth().stripe.cancelSubscription,\n { invalidateQueries: ['getSession'], ...args },\n {\n requireUser: true,\n requireOrganization: true,\n }\n );\n\n/**\n * AI\n */\n\nexport const useTranslateJSONDeclaration = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['translateJSON']>\n) =>\n useAppAsync('translateJSON', useIntlayerAuth().ai.translateJSON, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n\nexport const useAuditContentDeclaration = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclaration']>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclaration,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationMetadata = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclarationMetadata']>\n) =>\n useAppAsync(\n 'auditContentDeclaration',\n useIntlayerAuth().ai.auditContentDeclarationMetadata,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditContentDeclarationField = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditContentDeclarationField']>\n) =>\n useAppAsync(\n 'auditContentDeclarationField',\n useIntlayerAuth().ai.auditContentDeclarationField,\n args,\n {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n }\n );\n\nexport const useAuditTag = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['auditTag']>\n) =>\n useAppAsync('auditTag', useIntlayerAuth().ai.auditTag, args, {\n requireUser: true,\n requireOrganization: true,\n requireProject: true,\n });\n\nexport const useAskDocQuestion = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['askDocQuestion']>\n) => useAppAsync('askDocQuestion', useIntlayerAuth().ai.askDocQuestion, args);\n\nexport const useAutocomplete = (\n args?: UseAsyncOptions<IntlayerAPI['ai']['autocomplete']>\n) => useAppAsync('autocomplete', useIntlayerAuth().ai.autocomplete, args);\n\n/**\n * Search\n */\n\nexport const useSearchDoc = (\n args?: UseAsyncOptions<IntlayerAPI['search']['searchDoc']>\n) => useAppAsync('searchDoc', useIntlayerAuth().search.searchDoc, args);\n\n/**\n * Editor\n */\n\nexport const useWriteDictionary = (\n args?: UseAsyncOptions<IntlayerAPI['editor']['writeDictionary']>\n) =>\n useEditorAsync(\n 'writeDictionary',\n useIntlayerAuth().editor.writeDictionary,\n args\n );\n\nexport const useGetEditorDictionaries = (\n args?: UseAsyncOptions<IntlayerAPI['editor']['getDictionaries']>\n) =>\n useEditorAsync('getDictionaries', useIntlayerAuth().editor.getDictionaries, {\n store: true,\n cache: true,\n ...args,\n });\n"],"names":["error"],"mappings":";;;;;;;;;AAYA,MAAM,mBAAmB,CAAiC,YAAkB;AACpE,QAAA,EAAE,MAAM,IAAI,SAAS;AAEpB,SAAA;AAAA,IACL,GAAG;AAAA,IACH,SAAS,CAAC,iBAAiB;AACrB,UAAA;AAGA,UAAA;AACE,YAAA,OAAO,iBAAiB,YAAa;AAEjC,gBAAA,KAAK,MAAM,YAAY;AAAA,eACxB,GAAG;AAGF,gBAAA;AAAA,MAAA;AAKV,OAAC,KAAK,EACH,QAAQ,CAACA,WAAUA,MAAK,EACxB;AAAA,QAAQ,CAACA,WACR,MAAM;AAAA,UACJ,QACG,2BAAY,aAAa,eACtBA,OAAM,QACNA,OAAM,SAAS;AAAA,UACrB,aAAaA,OAAM,WAAW,gBAAgB;AAAA,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mB,gBAAgB,EAAE,OAAO,iBAAiB;AAAA,EAC1E,OAAO;AAAA,EACP,OAAO;AAAA,EACP,GAAG;AACL,CAAC;"}
@@ -207,6 +207,11 @@ const useAsync = (key, asyncFunction, options) => {
207
207
  data: data2
208
208
  });
209
209
  };
210
+ const abort = () => {
211
+ if (controllerRef.current) {
212
+ controllerRef.current.abort();
213
+ }
214
+ };
210
215
  const memoResult = {
211
216
  isFetched,
212
217
  isInvalidated,
@@ -224,7 +229,8 @@ const useAsync = (key, asyncFunction, options) => {
224
229
  [key]: execute,
225
230
  // Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)
226
231
  revalidate,
227
- setData: setDataMemo
232
+ setData: setDataMemo,
233
+ abort
228
234
  };
229
235
  ReactExports.useEffect(
230
236
  () => () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useAsync.cjs","sources":["../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\nimport { useAsyncState } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n isWaitingData: boolean;\n isRevalidating: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n errorCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function\n store?: boolean; // Store the result of the function in local storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getArgs = (args?: any[]): any[] =>\n args ? (Array.isArray(args) ? args : [args]) : [];\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n getArgs(args).length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n *\n * ```tsx\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n * ```\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = getArgs(options?.args ?? []);\n\n // Using a custom hook to manage state specific to asynchronous operations\n const { getStates, setQueryState, setQueriesState, makeQueryInError } =\n useAsyncState();\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any[]>(args);\n\n const controllerRef = useRef<AbortController | null>(null);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled,\n error,\n isSuccess,\n isInvalidated,\n data,\n errorCount,\n } = getStates(keyWithArgs);\n\n /**\n * FETCH FUNCTION\n *\n * Manage parallel fetching across multiple instances of the hook\n * Manage state updates on success and error\n * Manage eventual invalidation of other queries\n */\n const fetch: T = (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n /**\n * ABORT CONTROLLER\n *\n * cancel an unnecessary request.\n * For example, if a user navigates away from a page or triggers a new request that makes the previous one obsolete, you can abort the previous fetch\n */\n if (controllerRef.current) {\n // Abort the previous request\n controllerRef.current.abort();\n }\n\n // Create a new AbortController\n const controller = new AbortController();\n controllerRef.current = controller;\n\n /**\n * PENDING PROMISES\n *\n * This logic ensures that if two parts of your application trigger the same request simultaneously,\n * only one network call is made, and both receive the same result.\n */\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setQueryState(keyWithArgs, { isLoading: true });\n let response = null;\n\n await asyncFunction(...args)\n .then((result) => {\n response = result;\n\n setQueryState(keyWithArgs, {\n data: result,\n errorCount: 0,\n isLoading: false,\n isFetched: true,\n fetchedDateTime: new Date(),\n isSuccess: true,\n isInvalidated: false,\n error: null,\n });\n\n onSuccess?.(result);\n\n // Invalidate other queries if necessary\n if (invalidateQueries.length > 0) {\n setQueriesState(invalidateQueries, {\n isInvalidated: true,\n });\n }\n\n // Update other queries if necessary\n if (updateQueries.length > 0) {\n setQueriesState(updateQueries, {\n data: result,\n });\n }\n\n // Store the result in local storage\n if (storeEnabled) {\n localStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n })\n .catch((error) => {\n console.error({ error });\n const msg = error instanceof Error ? error.message : String(error);\n\n makeQueryInError(keyWithArgs, msg);\n onError?.(error.message);\n })\n .finally(() => {\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n\n return await promise;\n }) as T;\n\n /**\n * REVALIDATE FUNCTION\n *\n * Wrap core function to handle revalidation\n * Handle arguments caching\n *\n */\n const revalidate: T = (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n\n if (args) {\n // Revalidation arguments can be different from the initial fetch arguments\n // If arguments are provided, store/update them for future periodic revalidation\n\n storedArgsRef.current = getArgs(args);\n }\n\n return await fetch(...storedArgsRef.current);\n }) as T;\n\n /**\n * EXECUTION FUNCTION\n *\n * Wrap revalidation function\n * If data is valid return it directly to avoid fetching again\n */\n const execute: T = (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n\n const shouldReturnData =\n !isInvalidated && // If data are invalidated, we should refetch to revalidate the data\n isSuccess &&\n cacheEnabled &&\n data;\n\n if (shouldReturnData) return data; // Data are already fetched and should be returned directly. Avoid fetching again.\n\n return await revalidate(...args);\n }) as T;\n\n /**\n * HANDLE SYNCHRONIZATION HOOKS DISACTIVATION\n *\n * If one instance of the hook is disabled, the other instances should be disabled too.\n * This is to prevent inconsistencies in the state of the hook.\n */\n useEffect(() => {\n if (enabled !== isEnabled) {\n setQueryState(keyWithArgs, {\n isEnabled,\n });\n }\n }, [enabled, isEnabled, keyWithArgs]);\n\n /**\n * HANDLE LOCAL STORAGE LOADING\n *\n * If store is enabled, load data from local storage\n */\n useEffect(() => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!storeEnabled) return; // Hook should not use local storage\n if (isInvalidated || isFetched || data) return; // Hook have been already mounted and fetched or invalidated\n\n const storedData = localStorage.getItem(keyWithArgs);\n\n // Wrap parsing in a try-catch block to handle invalid JSON data\n try {\n if (storedData) {\n setQueryState(keyWithArgs, {\n data: JSON.parse(storedData),\n });\n }\n } catch (error) {\n console.error(error);\n }\n }, [\n storeEnabled,\n keyWithArgs,\n isFetched,\n isInvalidated,\n isEnabled,\n enabled,\n data,\n ]);\n\n /**\n * HANDLE AUTO-FETCH ON HOOK MOUNT\n *\n * If autoFetch is enabled, fetch the data when the hook is mounted\n */\n useEffect(() => {\n if (!autoFetch) return; // Auto-fetch is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isFetched && !isInvalidated) return; // Hook have already fetched or invalidated\n if (isLoading) return; // Fetch is already in progress\n\n fetch(...storedArgsRef.current);\n }, [\n autoFetch,\n isEnabled,\n enabled,\n isFetched,\n isInvalidated,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE RETRY\n *\n * If fetching fails, retry the fetch after a certain time\n */\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount > retryLimit;\n\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!isRetryEnabled) return; // Retry is disabled\n if (isRetryLimitReached) return; // Retry limit has been reached\n if (!(cacheEnabled || storeEnabled)) return; // Useless to retry if caching is disabled\n if (isLoading) return; // Fetch is already in progress\n if (isSuccess) return; // Hook has already fetched successfully\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, retryTime);\n\n return () => clearTimeout(timeout);\n }, [\n isEnabled,\n errorCount,\n retryLimit,\n enabled,\n retryTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE PERIODIC REVALIDATION\n *\n * If revalidation is enabled, revalidate the data periodically\n */\n useEffect(() => {\n if (!revalidationEnabled || revalidateTime <= 0) return; // Revalidation is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n if (!isSuccess || !fetchedDateTime) return; // Should retry either of revalidate\n if (!(cacheEnabled || storeEnabled)) return; // Useless to revalidate if caching is disabled\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, revalidateTime);\n\n return () => clearTimeout(timeout);\n }, [\n revalidationEnabled,\n revalidateTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isEnabled,\n enabled,\n fetch,\n ]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = (data: Awaited<ReturnType<T> | null>) => {\n setQueryState(keyWithArgs, {\n data,\n });\n };\n\n // Memoization to prevent unnecessary re-renders\n const memoResult = {\n isFetched,\n isInvalidated,\n error,\n data,\n errorCount,\n isSuccess,\n isEnabled,\n isDisabled: !isEnabled,\n isLoading,\n isWaitingData: isLoading && !isFetched && !data, // Check if the data is still being fetched. Stay at true during revalidation or if data are stored in local storage\n isRevalidating: isLoading && isFetched, // Check if the data is valid and is being revalidated\n [key]: execute, // Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)\n revalidate,\n setData: setDataMemo,\n };\n\n useEffect(\n () => () => {\n // Clean up the controller on unmount\n if (controllerRef.current) {\n controllerRef.current.abort();\n }\n },\n []\n );\n\n // Return the hook's result, including all state and control functions\n return memoResult as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["useAsyncState","useRef","args","keyWithArgs","error","useEffect","data"],"mappings":";;;;;AAMA,MAAM,sCAAsB,IAAI;AAoChC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,+BAA+B;AACrC,MAAM,0BAA0B,IAAI,KAAK;AACzC,MAAM,qBAAqB,IAAI,KAAK;AAQpC,MAAM,UAAU,CAAC,SACf,OAAQ,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI,IAAK,CAAC;AAElD,MAAM,iBAAiB,CAAC,KAAa,SACnC,QAAQ,IAAI,EAAE,SAAS,IAAI,GAAG,GAAG,IAAI,KAAK,UAAU,IAAI,CAAC,KAAK;AAwCzD,MAAM,WAAW,CAItB,KACA,eACA,YACyB;AAEnB,QAAA,aAAa,SAAS,cAAc;AACpC,QAAA,YAAY,SAAS,aAAa;AAClC,QAAA,YAAY,SAAS,aAAa;AAClC,QAAA,eAAe,SAAS,SAAS;AACjC,QAAA,eAAe,SAAS,SAAS;AACjC,QAAA,UAAU,SAAS,UAAU;AAC7B,QAAA,sBACJ,SAAS,gBAAgB;AACrB,QAAA,iBAAiB,SAAS,kBAAkB;AAC5C,QAAA,gBAAgB,SAAS,iBAA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,QAAA,EAAE,gBAAgB,cAAe;AAE/B,UAAA,UAAU,WAAW,MAAM;AACzB,YAAA,GAAG,cAAc,OAAO;AAAA,OAC7B,cAAc;AAEV,WAAA,MAAM,aAAa,OAAO;AAAA,EAAA,GAChC;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAGK,QAAA,cAAc,CAACC,UAAwC;AAC3D,kBAAc,aAAa;AAAA,MACzB,MAAAA;AAAAA,IAAA,CACD;AAAA,EACH;AAGA,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,CAAC;AAAA,IACb;AAAA,IACA,eAAe,aAAa,CAAC,aAAa,CAAC;AAAA;AAAA,IAC3C,gBAAgB,aAAa;AAAA;AAAA,IAC7B,CAAC,GAAG,GAAG;AAAA;AAAA,IACP;AAAA,IACA,SAAS;AAAA,EACX;AAEAD,eAAA;AAAA,IACE,MAAM,MAAM;AAEV,UAAI,cAAc,SAAS;AACzB,sBAAc,QAAQ,MAAM;AAAA,MAAA;AAAA,IAEhC;AAAA,IACA,CAAA;AAAA,EACF;AAGO,SAAA;AACT;;"}
1
+ {"version":3,"file":"useAsync.cjs","sources":["../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\nimport { useAsyncState } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n isWaitingData: boolean;\n isRevalidating: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n errorCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n abort: () => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function\n store?: boolean; // Store the result of the function in local storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n abort?: () => void; // Abort the request\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getArgs = (args?: any[]): any[] =>\n args ? (Array.isArray(args) ? args : [args]) : [];\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n getArgs(args).length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n *\n * ```tsx\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n * ```\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = getArgs(options?.args ?? []);\n\n // Using a custom hook to manage state specific to asynchronous operations\n const { getStates, setQueryState, setQueriesState, makeQueryInError } =\n useAsyncState();\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any[]>(args);\n\n const controllerRef = useRef<AbortController | null>(null);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled,\n error,\n isSuccess,\n isInvalidated,\n data,\n errorCount,\n } = getStates(keyWithArgs);\n\n /**\n * FETCH FUNCTION\n *\n * Manage parallel fetching across multiple instances of the hook\n * Manage state updates on success and error\n * Manage eventual invalidation of other queries\n */\n const fetch: T = (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n /**\n * ABORT CONTROLLER\n *\n * cancel an unnecessary request.\n * For example, if a user navigates away from a page or triggers a new request that makes the previous one obsolete, you can abort the previous fetch\n */\n if (controllerRef.current) {\n // Abort the previous request\n controllerRef.current.abort();\n }\n\n // Create a new AbortController\n const controller = new AbortController();\n controllerRef.current = controller;\n\n /**\n * PENDING PROMISES\n *\n * This logic ensures that if two parts of your application trigger the same request simultaneously,\n * only one network call is made, and both receive the same result.\n */\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setQueryState(keyWithArgs, { isLoading: true });\n let response = null;\n\n await asyncFunction(...args)\n .then((result) => {\n response = result;\n\n setQueryState(keyWithArgs, {\n data: result,\n errorCount: 0,\n isLoading: false,\n isFetched: true,\n fetchedDateTime: new Date(),\n isSuccess: true,\n isInvalidated: false,\n error: null,\n });\n\n onSuccess?.(result);\n\n // Invalidate other queries if necessary\n if (invalidateQueries.length > 0) {\n setQueriesState(invalidateQueries, {\n isInvalidated: true,\n });\n }\n\n // Update other queries if necessary\n if (updateQueries.length > 0) {\n setQueriesState(updateQueries, {\n data: result,\n });\n }\n\n // Store the result in local storage\n if (storeEnabled) {\n localStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n })\n .catch((error) => {\n console.error({ error });\n const msg = error instanceof Error ? error.message : String(error);\n\n makeQueryInError(keyWithArgs, msg);\n onError?.(error.message);\n })\n .finally(() => {\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n\n return await promise;\n }) as T;\n\n /**\n * REVALIDATE FUNCTION\n *\n * Wrap core function to handle revalidation\n * Handle arguments caching\n *\n */\n const revalidate: T = (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n\n if (args) {\n // Revalidation arguments can be different from the initial fetch arguments\n // If arguments are provided, store/update them for future periodic revalidation\n\n storedArgsRef.current = getArgs(args);\n }\n\n return await fetch(...storedArgsRef.current);\n }) as T;\n\n /**\n * EXECUTION FUNCTION\n *\n * Wrap revalidation function\n * If data is valid return it directly to avoid fetching again\n */\n const execute: T = (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n\n const shouldReturnData =\n !isInvalidated && // If data are invalidated, we should refetch to revalidate the data\n isSuccess &&\n cacheEnabled &&\n data;\n\n if (shouldReturnData) return data; // Data are already fetched and should be returned directly. Avoid fetching again.\n\n return await revalidate(...args);\n }) as T;\n\n /**\n * HANDLE SYNCHRONIZATION HOOKS DISACTIVATION\n *\n * If one instance of the hook is disabled, the other instances should be disabled too.\n * This is to prevent inconsistencies in the state of the hook.\n */\n useEffect(() => {\n if (enabled !== isEnabled) {\n setQueryState(keyWithArgs, {\n isEnabled,\n });\n }\n }, [enabled, isEnabled, keyWithArgs]);\n\n /**\n * HANDLE LOCAL STORAGE LOADING\n *\n * If store is enabled, load data from local storage\n */\n useEffect(() => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!storeEnabled) return; // Hook should not use local storage\n if (isInvalidated || isFetched || data) return; // Hook have been already mounted and fetched or invalidated\n\n const storedData = localStorage.getItem(keyWithArgs);\n\n // Wrap parsing in a try-catch block to handle invalid JSON data\n try {\n if (storedData) {\n setQueryState(keyWithArgs, {\n data: JSON.parse(storedData),\n });\n }\n } catch (error) {\n console.error(error);\n }\n }, [\n storeEnabled,\n keyWithArgs,\n isFetched,\n isInvalidated,\n isEnabled,\n enabled,\n data,\n ]);\n\n /**\n * HANDLE AUTO-FETCH ON HOOK MOUNT\n *\n * If autoFetch is enabled, fetch the data when the hook is mounted\n */\n useEffect(() => {\n if (!autoFetch) return; // Auto-fetch is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isFetched && !isInvalidated) return; // Hook have already fetched or invalidated\n if (isLoading) return; // Fetch is already in progress\n\n fetch(...storedArgsRef.current);\n }, [\n autoFetch,\n isEnabled,\n enabled,\n isFetched,\n isInvalidated,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE RETRY\n *\n * If fetching fails, retry the fetch after a certain time\n */\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount > retryLimit;\n\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!isRetryEnabled) return; // Retry is disabled\n if (isRetryLimitReached) return; // Retry limit has been reached\n if (!(cacheEnabled || storeEnabled)) return; // Useless to retry if caching is disabled\n if (isLoading) return; // Fetch is already in progress\n if (isSuccess) return; // Hook has already fetched successfully\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, retryTime);\n\n return () => clearTimeout(timeout);\n }, [\n isEnabled,\n errorCount,\n retryLimit,\n enabled,\n retryTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE PERIODIC REVALIDATION\n *\n * If revalidation is enabled, revalidate the data periodically\n */\n useEffect(() => {\n if (!revalidationEnabled || revalidateTime <= 0) return; // Revalidation is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n if (!isSuccess || !fetchedDateTime) return; // Should retry either of revalidate\n if (!(cacheEnabled || storeEnabled)) return; // Useless to revalidate if caching is disabled\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, revalidateTime);\n\n return () => clearTimeout(timeout);\n }, [\n revalidationEnabled,\n revalidateTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isEnabled,\n enabled,\n fetch,\n ]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = (data: Awaited<ReturnType<T> | null>) => {\n setQueryState(keyWithArgs, {\n data,\n });\n };\n\n const abort = () => {\n if (controllerRef.current) {\n controllerRef.current.abort();\n }\n };\n\n // Memoization to prevent unnecessary re-renders\n const memoResult = {\n isFetched,\n isInvalidated,\n error,\n data,\n errorCount,\n isSuccess,\n isEnabled,\n isDisabled: !isEnabled,\n isLoading,\n isWaitingData: isLoading && !isFetched && !data, // Check if the data is still being fetched. Stay at true during revalidation or if data are stored in local storage\n isRevalidating: isLoading && isFetched, // Check if the data is valid and is being revalidated\n [key]: execute, // Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)\n revalidate,\n setData: setDataMemo,\n abort,\n };\n\n useEffect(\n () => () => {\n // Clean up the controller on unmount\n if (controllerRef.current) {\n controllerRef.current.abort();\n }\n },\n []\n );\n\n // Return the hook's result, including all state and control functions\n return memoResult as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["useAsyncState","useRef","args","keyWithArgs","error","useEffect","data"],"mappings":";;;;;AAMA,MAAM,sCAAsB,IAAI;AAsChC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,+BAA+B;AACrC,MAAM,0BAA0B,IAAI,KAAK;AACzC,MAAM,qBAAqB,IAAI,KAAK;AAQpC,MAAM,UAAU,CAAC,SACf,OAAQ,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI,IAAK,CAAC;AAElD,MAAM,iBAAiB,CAAC,KAAa,SACnC,QAAQ,IAAI,EAAE,SAAS,IAA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Q,MAAM;AAAA,MAAA;AAAA,IAEhC;AAAA,IACA,CAAA;AAAA,EACF;AAGO,SAAA;AACT;;"}
@@ -11,6 +11,7 @@ type UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {
11
11
  errorCount: number;
12
12
  revalidate: T;
13
13
  setData: (data: Awaited<ReturnType<T> | null>) => void;
14
+ abort: () => void;
14
15
  };
15
16
  export type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {
16
17
  retryLimit?: number;
@@ -25,6 +26,7 @@ export type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {
25
26
  updateQueries?: string[];
26
27
  onSuccess?: (data: Awaited<ReturnType<T>>) => void;
27
28
  onError?: (error: string) => void;
29
+ abort?: () => void;
28
30
  args?: Parameters<T>;
29
31
  };
30
32
  export type UseAsyncResult<U extends string, T extends (...args: any[]) => Promise<any>> = UseAsyncResultBase<T> & Record<U, T>;
@@ -1 +1 @@
1
- {"version":3,"file":"useAsync.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAsync/useAsync.ts"],"names":[],"mappings":"AASA,KAAK,kBAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,IAAI;IACpE,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,CAAC,CAAC;IACd,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CA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,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACnD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CACtB,CAAC;AAaF,MAAM,MAAM,cAAc,CACxB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,IACxC,kBAAkB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAQzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,QAAQ,GACnB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAE1C,KAAK,CAAC,EACN,eAAe,CAAC,EAChB,UAAU,eAAe,CAAC,CAAC,CAAC,KAC3B,cAAc,CAAC,CAAC,EAAE,CAAC,CAoWrB,CAAC"}
@@ -205,6 +205,11 @@ const useAsync = (key, asyncFunction, options) => {
205
205
  data: data2
206
206
  });
207
207
  };
208
+ const abort = () => {
209
+ if (controllerRef.current) {
210
+ controllerRef.current.abort();
211
+ }
212
+ };
208
213
  const memoResult = {
209
214
  isFetched,
210
215
  isInvalidated,
@@ -222,7 +227,8 @@ const useAsync = (key, asyncFunction, options) => {
222
227
  [key]: execute,
223
228
  // Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)
224
229
  revalidate,
225
- setData: setDataMemo
230
+ setData: setDataMemo,
231
+ abort
226
232
  };
227
233
  useEffect(
228
234
  () => () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useAsync.mjs","sources":["../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\nimport { useAsyncState } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n isWaitingData: boolean;\n isRevalidating: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n errorCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function\n store?: boolean; // Store the result of the function in local storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getArgs = (args?: any[]): any[] =>\n args ? (Array.isArray(args) ? args : [args]) : [];\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n getArgs(args).length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n *\n * ```tsx\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n * ```\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = getArgs(options?.args ?? []);\n\n // Using a custom hook to manage state specific to asynchronous operations\n const { getStates, setQueryState, setQueriesState, makeQueryInError } =\n useAsyncState();\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any[]>(args);\n\n const controllerRef = useRef<AbortController | null>(null);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled,\n error,\n isSuccess,\n isInvalidated,\n data,\n errorCount,\n } = getStates(keyWithArgs);\n\n /**\n * FETCH FUNCTION\n *\n * Manage parallel fetching across multiple instances of the hook\n * Manage state updates on success and error\n * Manage eventual invalidation of other queries\n */\n const fetch: T = (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n /**\n * ABORT CONTROLLER\n *\n * cancel an unnecessary request.\n * For example, if a user navigates away from a page or triggers a new request that makes the previous one obsolete, you can abort the previous fetch\n */\n if (controllerRef.current) {\n // Abort the previous request\n controllerRef.current.abort();\n }\n\n // Create a new AbortController\n const controller = new AbortController();\n controllerRef.current = controller;\n\n /**\n * PENDING PROMISES\n *\n * This logic ensures that if two parts of your application trigger the same request simultaneously,\n * only one network call is made, and both receive the same result.\n */\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setQueryState(keyWithArgs, { isLoading: true });\n let response = null;\n\n await asyncFunction(...args)\n .then((result) => {\n response = result;\n\n setQueryState(keyWithArgs, {\n data: result,\n errorCount: 0,\n isLoading: false,\n isFetched: true,\n fetchedDateTime: new Date(),\n isSuccess: true,\n isInvalidated: false,\n error: null,\n });\n\n onSuccess?.(result);\n\n // Invalidate other queries if necessary\n if (invalidateQueries.length > 0) {\n setQueriesState(invalidateQueries, {\n isInvalidated: true,\n });\n }\n\n // Update other queries if necessary\n if (updateQueries.length > 0) {\n setQueriesState(updateQueries, {\n data: result,\n });\n }\n\n // Store the result in local storage\n if (storeEnabled) {\n localStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n })\n .catch((error) => {\n console.error({ error });\n const msg = error instanceof Error ? error.message : String(error);\n\n makeQueryInError(keyWithArgs, msg);\n onError?.(error.message);\n })\n .finally(() => {\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n\n return await promise;\n }) as T;\n\n /**\n * REVALIDATE FUNCTION\n *\n * Wrap core function to handle revalidation\n * Handle arguments caching\n *\n */\n const revalidate: T = (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n\n if (args) {\n // Revalidation arguments can be different from the initial fetch arguments\n // If arguments are provided, store/update them for future periodic revalidation\n\n storedArgsRef.current = getArgs(args);\n }\n\n return await fetch(...storedArgsRef.current);\n }) as T;\n\n /**\n * EXECUTION FUNCTION\n *\n * Wrap revalidation function\n * If data is valid return it directly to avoid fetching again\n */\n const execute: T = (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n\n const shouldReturnData =\n !isInvalidated && // If data are invalidated, we should refetch to revalidate the data\n isSuccess &&\n cacheEnabled &&\n data;\n\n if (shouldReturnData) return data; // Data are already fetched and should be returned directly. Avoid fetching again.\n\n return await revalidate(...args);\n }) as T;\n\n /**\n * HANDLE SYNCHRONIZATION HOOKS DISACTIVATION\n *\n * If one instance of the hook is disabled, the other instances should be disabled too.\n * This is to prevent inconsistencies in the state of the hook.\n */\n useEffect(() => {\n if (enabled !== isEnabled) {\n setQueryState(keyWithArgs, {\n isEnabled,\n });\n }\n }, [enabled, isEnabled, keyWithArgs]);\n\n /**\n * HANDLE LOCAL STORAGE LOADING\n *\n * If store is enabled, load data from local storage\n */\n useEffect(() => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!storeEnabled) return; // Hook should not use local storage\n if (isInvalidated || isFetched || data) return; // Hook have been already mounted and fetched or invalidated\n\n const storedData = localStorage.getItem(keyWithArgs);\n\n // Wrap parsing in a try-catch block to handle invalid JSON data\n try {\n if (storedData) {\n setQueryState(keyWithArgs, {\n data: JSON.parse(storedData),\n });\n }\n } catch (error) {\n console.error(error);\n }\n }, [\n storeEnabled,\n keyWithArgs,\n isFetched,\n isInvalidated,\n isEnabled,\n enabled,\n data,\n ]);\n\n /**\n * HANDLE AUTO-FETCH ON HOOK MOUNT\n *\n * If autoFetch is enabled, fetch the data when the hook is mounted\n */\n useEffect(() => {\n if (!autoFetch) return; // Auto-fetch is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isFetched && !isInvalidated) return; // Hook have already fetched or invalidated\n if (isLoading) return; // Fetch is already in progress\n\n fetch(...storedArgsRef.current);\n }, [\n autoFetch,\n isEnabled,\n enabled,\n isFetched,\n isInvalidated,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE RETRY\n *\n * If fetching fails, retry the fetch after a certain time\n */\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount > retryLimit;\n\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!isRetryEnabled) return; // Retry is disabled\n if (isRetryLimitReached) return; // Retry limit has been reached\n if (!(cacheEnabled || storeEnabled)) return; // Useless to retry if caching is disabled\n if (isLoading) return; // Fetch is already in progress\n if (isSuccess) return; // Hook has already fetched successfully\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, retryTime);\n\n return () => clearTimeout(timeout);\n }, [\n isEnabled,\n errorCount,\n retryLimit,\n enabled,\n retryTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE PERIODIC REVALIDATION\n *\n * If revalidation is enabled, revalidate the data periodically\n */\n useEffect(() => {\n if (!revalidationEnabled || revalidateTime <= 0) return; // Revalidation is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n if (!isSuccess || !fetchedDateTime) return; // Should retry either of revalidate\n if (!(cacheEnabled || storeEnabled)) return; // Useless to revalidate if caching is disabled\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, revalidateTime);\n\n return () => clearTimeout(timeout);\n }, [\n revalidationEnabled,\n revalidateTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isEnabled,\n enabled,\n fetch,\n ]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = (data: Awaited<ReturnType<T> | null>) => {\n setQueryState(keyWithArgs, {\n data,\n });\n };\n\n // Memoization to prevent unnecessary re-renders\n const memoResult = {\n isFetched,\n isInvalidated,\n error,\n data,\n errorCount,\n isSuccess,\n isEnabled,\n isDisabled: !isEnabled,\n isLoading,\n isWaitingData: isLoading && !isFetched && !data, // Check if the data is still being fetched. Stay at true during revalidation or if data are stored in local storage\n isRevalidating: isLoading && isFetched, // Check if the data is valid and is being revalidated\n [key]: execute, // Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)\n revalidate,\n setData: setDataMemo,\n };\n\n useEffect(\n () => () => {\n // Clean up the controller on unmount\n if (controllerRef.current) {\n controllerRef.current.abort();\n }\n },\n []\n );\n\n // Return the hook's result, including all state and control functions\n return memoResult as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["args","keyWithArgs","error","data"],"mappings":";;;AAMA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,CAAC,aAAa,CAAC;AAAA;AAAA,IAC3C,gBAAgB,aAAa;AAAA;AAAA,IAC7B,CAAC,GAAG,GAAG;AAAA;AAAA,IACP;AAAA,IACA,SAAS;AAAA,EACX;AAEA;AAAA,IACE,MAAM,MAAM;AAEV,UAAI,cAAc,SAAS;AACzB,sBAAc,QAAQ,MAAM;AAAA,MAAA;AAAA,IAEhC;AAAA,IACA,CAAA;AAAA,EACF;AAGO,SAAA;AACT;"}
1
+ {"version":3,"file":"useAsync.mjs","sources":["../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\nimport { useAsyncState } from './useAsyncStateStore';\n\n// Pending promises cache to prevent parallel requests when multiple components use the hook\nconst pendingPromises = new Map();\n\n// Defines the base structure for the result of the custom hook.\ntype UseAsyncResultBase<T extends (...args: any[]) => Promise<any>> = {\n isFetched: boolean;\n isLoading: boolean;\n isInvalidated: boolean;\n isSuccess: boolean;\n isDisabled: boolean;\n isWaitingData: boolean;\n isRevalidating: boolean;\n error: string | null;\n data: Awaited<ReturnType<T>> | null;\n errorCount: number;\n revalidate: T;\n setData: (data: Awaited<ReturnType<T> | null>) => void;\n abort: () => void;\n};\n\n// Options type for the hook, allowing customization of behavior.\nexport type UseAsyncOptions<T extends (...args: any[]) => Promise<any>> = {\n retryLimit?: number; // The number of times the hook should retry the function on failure before giving up\n retryTime?: number; // Time in milliseconds for retrying the data\n cache?: boolean; // Cache the result of the function\n store?: boolean; // Store the result of the function in local storage\n enable?: boolean; // Enable the hook\n autoFetch?: boolean; // Automatically fetch the data when the hook is mounted\n revalidation?: boolean; // Enable revalidation\n revalidateTime?: number; // Time in milliseconds for revalidating the data\n invalidateQueries?: string[]; // Invalidate other queries when the data is updated\n updateQueries?: string[]; // Update other queries when the data is updated\n onSuccess?: (data: Awaited<ReturnType<T>>) => void; // Callback function that is called when the asynchronous function resolves successfully\n onError?: (error: string) => void; // Callback function that is called when the asynchronous function rejects or encounters an error\n abort?: () => void; // Abort the request\n args?: Parameters<T>; // Arguments to pass to the asynchronous function\n};\n\n// Default values for the hook's options\nconst DEFAULT_CACHE_ENABLED = false;\nconst DEFAULT_STORE_ENABLED = false;\nconst DEFAULT_ENABLED = true;\nconst DEFAULT_AUTO_FETCH = false;\nconst DEFAULT_RETRY_LIMIT = 1;\nconst DEFAULT_REVALIDATION_ENABLED = false;\nconst DEFAULT_REVALIDATE_TIME = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_RETRY_TIME = 5 * 60 * 1000; // 5 minutes\n\n// The main hook type that includes the async function along with its additional properties.\nexport type UseAsyncResult<\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n> = UseAsyncResultBase<T> & Record<U, T>;\n\nconst getArgs = (args?: any[]): any[] =>\n args ? (Array.isArray(args) ? args : [args]) : [];\n\nconst getKeyWithArgs = (key: string, args: any[]) =>\n getArgs(args).length > 0 ? `${key}/${JSON.stringify(args)}` : key;\n\n/**\n * A custom React hook that manages asynchronous operations, providing easy-to-use states and controls over fetching, caching, and retry mechanisms.\n * This hook abstracts away the complexity of handling loading, error, and success states for any asynchronous function.\n *\n *\n * ```tsx\n * // Example of using useAsync to manage fetching user data from an API.\n * const fetchUserData = async (userId) => {\n * const response = await fetch(`/api/users/${userId}`);\n * if (!response.ok) throw new Error('Failed to fetch');\n * return await response.json();\n * };\n *\n * const UserDetails = ({ userId }) => {\n * const {\n * isLoading,\n * data,\n * error,\n * revalidate,\n * } = useAsync('userDetails', fetchUserData, {\n * cache: true,\n * revalidateTime: 60000, // 1 minute\n * autoFetch: true,\n * onSuccess: (data) => console.log('User data fetched successfully:', data),\n * onError: (error) => console.error('Error fetching user data:', error),\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error}</div>;\n * return (\n * <div>\n * <h1>{data.name}</h1>\n * <button onClick={() => revalidate()}>Refresh</button>\n * </div>\n * );\n * };\n * ```\n */\nexport const useAsync = <\n U extends string,\n T extends (...args: any[]) => Promise<any>,\n>(\n key: U,\n asyncFunction: T,\n options?: UseAsyncOptions<T>\n): UseAsyncResult<U, T> => {\n // Resolving optional parameters with default values\n const retryLimit = options?.retryLimit ?? DEFAULT_RETRY_LIMIT;\n const autoFetch = options?.autoFetch ?? DEFAULT_AUTO_FETCH;\n const retryTime = options?.retryTime ?? DEFAULT_RETRY_TIME;\n const cacheEnabled = options?.cache ?? DEFAULT_CACHE_ENABLED;\n const storeEnabled = options?.store ?? DEFAULT_STORE_ENABLED;\n const enabled = options?.enable ?? DEFAULT_ENABLED;\n const revalidationEnabled =\n options?.revalidation ?? DEFAULT_REVALIDATION_ENABLED;\n const revalidateTime = options?.revalidateTime ?? DEFAULT_REVALIDATE_TIME;\n const updateQueries = options?.updateQueries ?? [];\n const invalidateQueries = options?.invalidateQueries ?? [];\n const onSuccess = options?.onSuccess;\n const onError = options?.onError;\n const args = getArgs(options?.args ?? []);\n\n // Using a custom hook to manage state specific to asynchronous operations\n const { getStates, setQueryState, setQueriesState, makeQueryInError } =\n useAsyncState();\n\n // Storing the last arguments used to call the async function\n const storedArgsRef = useRef<any[]>(args);\n\n const controllerRef = useRef<AbortController | null>(null);\n\n // Apply different key for different requests\n const keyWithArgs = getKeyWithArgs(key, storedArgsRef.current);\n\n // Retrieving the current state of async operations using the same custom hook\n const {\n isFetched,\n fetchedDateTime,\n isLoading,\n isEnabled,\n error,\n isSuccess,\n isInvalidated,\n data,\n errorCount,\n } = getStates(keyWithArgs);\n\n /**\n * FETCH FUNCTION\n *\n * Manage parallel fetching across multiple instances of the hook\n * Manage state updates on success and error\n * Manage eventual invalidation of other queries\n */\n const fetch: T = (async (...args) => {\n const keyWithArgs = getKeyWithArgs(key, args);\n\n /**\n * ABORT CONTROLLER\n *\n * cancel an unnecessary request.\n * For example, if a user navigates away from a page or triggers a new request that makes the previous one obsolete, you can abort the previous fetch\n */\n if (controllerRef.current) {\n // Abort the previous request\n controllerRef.current.abort();\n }\n\n // Create a new AbortController\n const controller = new AbortController();\n controllerRef.current = controller;\n\n /**\n * PENDING PROMISES\n *\n * This logic ensures that if two parts of your application trigger the same request simultaneously,\n * only one network call is made, and both receive the same result.\n */\n if (pendingPromises.has(keyWithArgs)) {\n // Return the existing pending promise\n return pendingPromises.get(keyWithArgs);\n }\n\n const promise = (async () => {\n setQueryState(keyWithArgs, { isLoading: true });\n let response = null;\n\n await asyncFunction(...args)\n .then((result) => {\n response = result;\n\n setQueryState(keyWithArgs, {\n data: result,\n errorCount: 0,\n isLoading: false,\n isFetched: true,\n fetchedDateTime: new Date(),\n isSuccess: true,\n isInvalidated: false,\n error: null,\n });\n\n onSuccess?.(result);\n\n // Invalidate other queries if necessary\n if (invalidateQueries.length > 0) {\n setQueriesState(invalidateQueries, {\n isInvalidated: true,\n });\n }\n\n // Update other queries if necessary\n if (updateQueries.length > 0) {\n setQueriesState(updateQueries, {\n data: result,\n });\n }\n\n // Store the result in local storage\n if (storeEnabled) {\n localStorage.setItem(keyWithArgs, JSON.stringify(result));\n }\n })\n .catch((error) => {\n console.error({ error });\n const msg = error instanceof Error ? error.message : String(error);\n\n makeQueryInError(keyWithArgs, msg);\n onError?.(error.message);\n })\n .finally(() => {\n // Remove the pending promise from the cache\n pendingPromises.delete(keyWithArgs);\n });\n\n return response;\n })();\n\n // Store the pending promise in the cache\n pendingPromises.set(keyWithArgs, promise);\n\n return await promise;\n }) as T;\n\n /**\n * REVALIDATE FUNCTION\n *\n * Wrap core function to handle revalidation\n * Handle arguments caching\n *\n */\n const revalidate: T = (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n\n if (args) {\n // Revalidation arguments can be different from the initial fetch arguments\n // If arguments are provided, store/update them for future periodic revalidation\n\n storedArgsRef.current = getArgs(args);\n }\n\n return await fetch(...storedArgsRef.current);\n }) as T;\n\n /**\n * EXECUTION FUNCTION\n *\n * Wrap revalidation function\n * If data is valid return it directly to avoid fetching again\n */\n const execute: T = (async (...args) => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n\n const shouldReturnData =\n !isInvalidated && // If data are invalidated, we should refetch to revalidate the data\n isSuccess &&\n cacheEnabled &&\n data;\n\n if (shouldReturnData) return data; // Data are already fetched and should be returned directly. Avoid fetching again.\n\n return await revalidate(...args);\n }) as T;\n\n /**\n * HANDLE SYNCHRONIZATION HOOKS DISACTIVATION\n *\n * If one instance of the hook is disabled, the other instances should be disabled too.\n * This is to prevent inconsistencies in the state of the hook.\n */\n useEffect(() => {\n if (enabled !== isEnabled) {\n setQueryState(keyWithArgs, {\n isEnabled,\n });\n }\n }, [enabled, isEnabled, keyWithArgs]);\n\n /**\n * HANDLE LOCAL STORAGE LOADING\n *\n * If store is enabled, load data from local storage\n */\n useEffect(() => {\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!storeEnabled) return; // Hook should not use local storage\n if (isInvalidated || isFetched || data) return; // Hook have been already mounted and fetched or invalidated\n\n const storedData = localStorage.getItem(keyWithArgs);\n\n // Wrap parsing in a try-catch block to handle invalid JSON data\n try {\n if (storedData) {\n setQueryState(keyWithArgs, {\n data: JSON.parse(storedData),\n });\n }\n } catch (error) {\n console.error(error);\n }\n }, [\n storeEnabled,\n keyWithArgs,\n isFetched,\n isInvalidated,\n isEnabled,\n enabled,\n data,\n ]);\n\n /**\n * HANDLE AUTO-FETCH ON HOOK MOUNT\n *\n * If autoFetch is enabled, fetch the data when the hook is mounted\n */\n useEffect(() => {\n if (!autoFetch) return; // Auto-fetch is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isFetched && !isInvalidated) return; // Hook have already fetched or invalidated\n if (isLoading) return; // Fetch is already in progress\n\n fetch(...storedArgsRef.current);\n }, [\n autoFetch,\n isEnabled,\n enabled,\n isFetched,\n isInvalidated,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE RETRY\n *\n * If fetching fails, retry the fetch after a certain time\n */\n useEffect(() => {\n const isRetryEnabled = errorCount > 0 && retryLimit > 0;\n const isRetryLimitReached = errorCount > retryLimit;\n\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (!isRetryEnabled) return; // Retry is disabled\n if (isRetryLimitReached) return; // Retry limit has been reached\n if (!(cacheEnabled || storeEnabled)) return; // Useless to retry if caching is disabled\n if (isLoading) return; // Fetch is already in progress\n if (isSuccess) return; // Hook has already fetched successfully\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, retryTime);\n\n return () => clearTimeout(timeout);\n }, [\n isEnabled,\n errorCount,\n retryLimit,\n enabled,\n retryTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n isLoading,\n fetch,\n ]);\n\n /**\n * HANDLE PERIODIC REVALIDATION\n *\n * If revalidation is enabled, revalidate the data periodically\n */\n useEffect(() => {\n if (!revalidationEnabled || revalidateTime <= 0) return; // Revalidation is disabled\n if (!isEnabled || !enabled) return; // Hook is disabled\n if (isLoading) return; // Fetch is already in progress\n if (!isSuccess || !fetchedDateTime) return; // Should retry either of revalidate\n if (!(cacheEnabled || storeEnabled)) return; // Useless to revalidate if caching is disabled\n\n const timeout = setTimeout(() => {\n fetch(...storedArgsRef.current);\n }, revalidateTime);\n\n return () => clearTimeout(timeout);\n }, [\n revalidationEnabled,\n revalidateTime,\n cacheEnabled,\n storeEnabled,\n isSuccess,\n fetchedDateTime,\n isLoading,\n isEnabled,\n enabled,\n fetch,\n ]);\n\n // Memoization of the setData function to prevent unnecessary re-renders\n const setDataMemo = (data: Awaited<ReturnType<T> | null>) => {\n setQueryState(keyWithArgs, {\n data,\n });\n };\n\n const abort = () => {\n if (controllerRef.current) {\n controllerRef.current.abort();\n }\n };\n\n // Memoization to prevent unnecessary re-renders\n const memoResult = {\n isFetched,\n isInvalidated,\n error,\n data,\n errorCount,\n isSuccess,\n isEnabled,\n isDisabled: !isEnabled,\n isLoading,\n isWaitingData: isLoading && !isFetched && !data, // Check if the data is still being fetched. Stay at true during revalidation or if data are stored in local storage\n isRevalidating: isLoading && isFetched, // Check if the data is valid and is being revalidated\n [key]: execute, // Name the execute function as the given key to avoid conflicts with other hooks (e.g. `const { fetchUser } = useAsync('fetchUser', () => fetchUserFunction());`)\n revalidate,\n setData: setDataMemo,\n abort,\n };\n\n useEffect(\n () => () => {\n // Clean up the controller on unmount\n if (controllerRef.current) {\n controllerRef.current.abort();\n }\n },\n []\n );\n\n // Return the hook's result, including all state and control functions\n return memoResult as UseAsyncResultBase<T> & Record<U, T>;\n};\n"],"names":["args","keyWithArgs","error","data"],"mappings":";;;AAMA,MAAM,sCAAsB,IAAI;AAsChC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,+BAA+B;AACrC,MAAM,0BAA0B,IAAI,KAAK;AACzC,MAAM,qBAAqB,IAAI,KAAK;AAQpC,MAAM,UAAU,CAAC,SACf,OAAQ,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI,IAAK,CAAC;AAElD,MAAM,iBAAiB,CAAC,KAAa,SACnC,QAAQ,IAAI,EAAE,SAAS,IAAI,GAAG,GAAG,IAAI,KAAK,UAAU,IAAI,CAAC,KAAK;AAwCzD,MAAM,WAAW,CAItB,KACA,eACA,YACyB;AAEnB,QAAA,aAAa,SAAS,cAAc;AACpC,QAAA,YAAY,SAAS,aAAa;AAClC,QAAA,YAAY,SAAS,aAAa;AAClC,QAAA,eAAe,SAAS,SAAS;AACjC,QAAA,eAAe,SAAS,SAAS;AACjC,QAAA,UAAU,SAAS,UAAU;AAC7B,QAAA,sBACJ,SAAS,gBAAgB;AACrB,QAAA,iBAAiB,SAAS,kBAAkB;AAC5C,QAAA,gBAAgB,SAAS,iBAAiB,CAAC;AAC3C,QAAA,oBAAoB,SAAS,qBAAqB,CAAC;AACzD,QAAM,YAAY,SAAS;AAC3B,QAAM,UAAU,SAAS;AACzB,QAAM,OAAO,QAAQ,SAAS,QAAQ,CAAA,CAAE;AAGxC,QAAM,EAAE,WAAW,eAAe,iB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,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAGK,QAAA,cAAc,CAACC,UAAwC;AAC3D,kBAAc,aAAa;AAAA,MACzB,MAAAA;AAAAA,IAAA,CACD;AAAA,EACH;AAEA,QAAM,QAAQ,MAAM;AAClB,QAAI,cAAc,SAAS;AACzB,oBAAc,QAAQ,MAAM;AAAA,IAAA;AAAA,EAEhC;AAGA,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,CAAC;AAAA,IACb;AAAA,IACA,eAAe,aAAa,CAAC,aAAa,CAAC;AAAA;AAAA,IAC3C,gBAAgB,aAAa;AAAA;AAAA,IAC7B,CAAC,GAAG,GAAG;AAAA;AAAA,IACP;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF;AAEA;AAAA,IACE,MAAM,MAAM;AAEV,UAAI,cAAc,SAAS;AACzB,sBAAc,QAAQ,MAAM;AAAA,MAAA;AAAA,IAEhC;AAAA,IACA,CAAA;AAAA,EACF;AAGO,SAAA;AACT;"}
@@ -44,7 +44,6 @@ export declare const useIntlayerAuth: (props?: UseIntlayerAuthProps) => {
44
44
  getLoginWithGoogleURL: (params: import('@intlayer/backend').GoogleLoginQueryParams) => string;
45
45
  register: (user: import('@intlayer/backend').RegisterBody, query?: import('@intlayer/backend').RegisterQuery, otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').RegisterResult>;
46
46
  logout: (otherOptions?: FetcherOptions) => Promise<void>;
47
- resetPassword: (params: ResetPasswordParams, otherOptions?: FetcherOptions) => Promise<ResetPasswordResult>;
48
47
  defineNewPassword: (data: import('@intlayer/backend').DefinePasswordBody, otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').DefinePasswordResult>;
49
48
  askResetPassword: (email: import('@intlayer/backend').AskResetPasswordBody["email"], otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').AskResetPasswordResult>;
50
49
  checkIfUserHasPassword: (otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').CheckIfUserHasPasswordResult>;
@@ -71,7 +70,7 @@ export declare const useIntlayerAuth: (props?: UseIntlayerAuthProps) => {
71
70
  cancelSubscription: (otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').GetCheckoutSessionResult>;
72
71
  };
73
72
  ai: {
74
- translateJSON: (body?: TranslateJSONResultBody, otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').TranslateJSONResult>;
73
+ translateJSON: (body?: import('@intlayer/backend').TranslateJSONBody, otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').TranslateJSONResult>;
75
74
  auditContentDeclaration: (body?: import('@intlayer/backend').AuditContentDeclarationBody, otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').AuditContentDeclarationResult>;
76
75
  auditContentDeclarationField: (body?: import('@intlayer/backend').AuditContentDeclarationFieldBody, otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').AuditContentDeclarationFieldResult>;
77
76
  auditContentDeclarationMetadata: (body?: import('@intlayer/backend').AuditContentDeclarationMetadataBody, otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').AuditContentDeclarationMetadataResult>;
@@ -85,9 +84,13 @@ export declare const useIntlayerAuth: (props?: UseIntlayerAuthProps) => {
85
84
  updateTag: (tagId: import('@intlayer/backend').UpdateTagParams["tagId"], tag: import('@intlayer/backend').UpdateTagBody, otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').UpdateTagResult>;
86
85
  deleteTag: (tagId: import('@intlayer/backend').DeleteTagParams["tagId"], otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').DeleteTagResult>;
87
86
  };
87
+ search: {
88
+ searchDoc: (params?: import('@intlayer/backend').SearchDocUtilParams, otherOptions?: FetcherOptions) => Promise<import('@intlayer/backend').SearchDocUtilResult>;
89
+ };
88
90
  editor: {
89
- getConfiguration: (otherOptions?: FetcherOptions) => Promise<GetConfigurationResult>;
90
- writeDictionary: (dictionary: WriteContentDeclarationBody, otherOptions?: FetcherOptions) => Promise<WriteContentDeclarationResult>;
91
+ getDictionaries: (otherOptions?: FetcherOptions) => Promise<Record<string, any>>;
92
+ getConfiguration: (otherOptions?: FetcherOptions) => Promise<import('intlayer-editor').GetConfigurationResult>;
93
+ writeDictionary: (dictionary: import('intlayer-editor').WriteContentDeclarationBody, otherOptions?: FetcherOptions) => Promise<import('intlayer-editor').WriteContentDeclarationResult>;
91
94
  };
92
95
  };
93
96
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayerAPI.d.ts","sourceRoot":"","sources":["../../src/hooks/useIntlayerAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAI9D,KAAK,oBAAoB,GAAG;IAC1B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,qBAAqB,CAAC,EAAE,cAAc,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,oBAAoB;;kCAJ1D,CAAD,kEACsC,CAAC;0HAOR,CAAC;qGAQ/B,CAAF;yGAS8B,CAAC;2GAAkM,CAAC;iHAAqM,CAAC;yCAAoI,CAAC;gIAAoN,CAAC;2CAA+H,CAAC;;;6BAAyI,CAAC,6DAA6D,CAAC;sFAAmK,CAAC;4FAAwK,CAAC;uGAAsL,CAAC;+HAAqN,CAAC;oCAA8H,CAAC;4GAA2L,CAAC;sCAAqH,CAAC;kGAAmL,CAAC;6GAAgM,CAAC;+GAAkM,CAAC;;;mFAA0L,CAAC;0BAAsG,CAAC,0DAA0D,CAAC;mGAA6K,CAAC;6MAA0R,CAAC;uGAAyL,CAAC;mFAAmK,CAAC;iDAA6H,CAAC;;;yEAAwK,CAAC;;;wEAA6V,CAAC,yDAAyD,CAAC;6BAAuG,CAAC;gCAAmE,mBAAoB,cAAc,CAAC,6BAA6B,mBAAmB;8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design system, including UI components used in the Intlayer editor, website, and visual editor/CMS.",
6
6
  "keywords": [
@@ -78,12 +78,12 @@
78
78
  "tailwind-merge": "^3.0.2",
79
79
  "zod": "^3.24.2",
80
80
  "zustand": "^4.5.6",
81
- "@intlayer/config": "5.5.1",
82
- "@intlayer/api": "5.5.1",
83
- "@intlayer/dictionaries-entry": "5.5.1",
84
- "@intlayer/core": "5.5.1",
85
- "@intlayer/editor-react": "5.5.1",
86
- "react-intlayer": "5.5.1"
81
+ "@intlayer/api": "5.5.3",
82
+ "@intlayer/editor-react": "5.5.3",
83
+ "@intlayer/config": "5.5.3",
84
+ "@intlayer/dictionaries-entry": "5.5.3",
85
+ "@intlayer/core": "5.5.3",
86
+ "react-intlayer": "5.5.3"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@chromatic-com/storybook": "^3.2.6",
@@ -120,11 +120,11 @@
120
120
  "vite": "^6.3.1",
121
121
  "vite-plugin-dts": "^4.5.3",
122
122
  "vitest": "^3.0.9",
123
- "@intlayer/backend": "5.5.1",
123
+ "@intlayer/backend": "5.5.3",
124
124
  "@utils/eslint-config": "1.0.4",
125
125
  "@utils/ts-config": "1.0.4",
126
- "@utils/ts-config-types": "1.0.4",
127
- "@utils/tsup-config": "1.0.4"
126
+ "@utils/tsup-config": "1.0.4",
127
+ "@utils/ts-config-types": "1.0.4"
128
128
  },
129
129
  "peerDependencies": {
130
130
  "@monaco-editor/react": "^4.7.0",
@@ -135,13 +135,13 @@
135
135
  "react-dom": ">=16.0.0",
136
136
  "tailwind-merge": "^3.0.2",
137
137
  "zustand": "^4.5.6",
138
- "@intlayer/api": "5.5.1",
139
- "@intlayer/core": "5.5.1",
140
- "@intlayer/config": "5.5.1",
141
- "@intlayer/dictionaries-entry": "5.5.1",
142
- "@intlayer/editor-react": "5.5.1",
143
- "react-intlayer": "5.5.1",
144
- "intlayer": "5.5.1"
138
+ "@intlayer/config": "5.5.3",
139
+ "@intlayer/core": "5.5.3",
140
+ "@intlayer/dictionaries-entry": "5.5.3",
141
+ "@intlayer/editor-react": "5.5.3",
142
+ "@intlayer/api": "5.5.3",
143
+ "react-intlayer": "5.5.3",
144
+ "intlayer": "5.5.3"
145
145
  },
146
146
  "scripts": {
147
147
  "build": "pnpm build:package && pnpm build:css",