@intlayer/api 8.1.2 → 8.1.3-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  2. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +1 -20
  3. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  4. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +1 -22
  5. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  6. package/dist/cjs/distantDictionary/index.cjs +1 -6
  7. package/dist/cjs/fetcher.cjs +1 -122
  8. package/dist/cjs/fetcher.cjs.map +1 -1
  9. package/dist/cjs/getIntlayerAPI/ai.cjs +2 -166
  10. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  11. package/dist/cjs/getIntlayerAPI/audit.cjs +1 -41
  12. package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
  13. package/dist/cjs/getIntlayerAPI/bitbucket.cjs +1 -74
  14. package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
  15. package/dist/cjs/getIntlayerAPI/dictionary.cjs +1 -72
  16. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  17. package/dist/cjs/getIntlayerAPI/editor.cjs +1 -40
  18. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  19. package/dist/cjs/getIntlayerAPI/github.cjs +1 -74
  20. package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
  21. package/dist/cjs/getIntlayerAPI/gitlab.cjs +1 -88
  22. package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
  23. package/dist/cjs/getIntlayerAPI/index.cjs +1 -38
  24. package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
  25. package/dist/cjs/getIntlayerAPI/newsletter.cjs +1 -43
  26. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  27. package/dist/cjs/getIntlayerAPI/oAuth.cjs +1 -29
  28. package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
  29. package/dist/cjs/getIntlayerAPI/organization.cjs +1 -96
  30. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  31. package/dist/cjs/getIntlayerAPI/project.cjs +1 -144
  32. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  33. package/dist/cjs/getIntlayerAPI/search.cjs +1 -25
  34. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  35. package/dist/cjs/getIntlayerAPI/stripe.cjs +1 -41
  36. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  37. package/dist/cjs/getIntlayerAPI/tag.cjs +1 -50
  38. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  39. package/dist/cjs/getIntlayerAPI/user.cjs +1 -82
  40. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  41. package/dist/cjs/index.cjs +1 -43
  42. package/dist/cjs/proxy.cjs +1 -101
  43. package/dist/cjs/proxy.cjs.map +1 -1
  44. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +1 -19
  45. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  46. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +1 -21
  47. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  48. package/dist/esm/distantDictionary/index.mjs +1 -4
  49. package/dist/esm/fetcher.mjs +1 -119
  50. package/dist/esm/fetcher.mjs.map +1 -1
  51. package/dist/esm/getIntlayerAPI/ai.mjs +2 -163
  52. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  53. package/dist/esm/getIntlayerAPI/audit.mjs +1 -38
  54. package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
  55. package/dist/esm/getIntlayerAPI/bitbucket.mjs +1 -71
  56. package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
  57. package/dist/esm/getIntlayerAPI/dictionary.mjs +1 -69
  58. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  59. package/dist/esm/getIntlayerAPI/editor.mjs +1 -37
  60. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  61. package/dist/esm/getIntlayerAPI/github.mjs +1 -71
  62. package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
  63. package/dist/esm/getIntlayerAPI/gitlab.mjs +1 -85
  64. package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
  65. package/dist/esm/getIntlayerAPI/index.mjs +1 -37
  66. package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
  67. package/dist/esm/getIntlayerAPI/newsletter.mjs +1 -40
  68. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  69. package/dist/esm/getIntlayerAPI/oAuth.mjs +1 -26
  70. package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
  71. package/dist/esm/getIntlayerAPI/organization.mjs +1 -93
  72. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  73. package/dist/esm/getIntlayerAPI/project.mjs +1 -141
  74. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  75. package/dist/esm/getIntlayerAPI/search.mjs +1 -22
  76. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  77. package/dist/esm/getIntlayerAPI/stripe.mjs +1 -38
  78. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  79. package/dist/esm/getIntlayerAPI/tag.mjs +1 -47
  80. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  81. package/dist/esm/getIntlayerAPI/user.mjs +1 -79
  82. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  83. package/dist/esm/index.mjs +1 -22
  84. package/dist/esm/proxy.mjs +1 -100
  85. package/dist/esm/proxy.mjs.map +1 -1
  86. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"tag.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/tag.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddTagBody,\n AddTagResult,\n DeleteTagParams,\n DeleteTagResult,\n GetTagsParams,\n GetTagsResult,\n UpdateTagBody,\n UpdateTagParams,\n UpdateTagResult,\n} from '../types';\n\nexport const getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/tag`;\n\n /**\n * Retrieves a list of tags based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getTags = async (\n filters?: GetTagsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetTagsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Adds a new tag to the database.\n * @param tag - Tag data.\n */\n const addTag = async (tag: AddTagBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<AddTagResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: tag,\n }\n );\n\n /**\n * Updates an existing tag in the database.\n * @param tag - Updated tag data.\n */\n const updateTag = async (\n tagId: UpdateTagParams['tagId'],\n tag: UpdateTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: tag,\n }\n );\n\n /**\n * Deletes a tag from the database by its ID.\n * @param tagId - Tag ID.\n */\n const deleteTag = async (\n tagId: DeleteTagParams['tagId'],\n\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n getTags,\n addTag,\n updateTag,\n deleteTag,\n };\n};\n"],"mappings":";;;;;;;AAeA,MAAa,aACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,gCAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,oBAAoB,GAAG,WAAW;;;;;CAMxC,MAAM,UAAU,OACd,SACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,SAAS,OAAO,KAAiB,eAA+B,EAAE,KACtE,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OACA,KACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OAEA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA,EACE,QAAQ,UACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"tag.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/tag.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddTagBody,\n AddTagResult,\n DeleteTagParams,\n DeleteTagResult,\n GetTagsParams,\n GetTagsResult,\n UpdateTagBody,\n UpdateTagParams,\n UpdateTagResult,\n} from '../types';\n\nexport const getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/tag`;\n\n /**\n * Retrieves a list of tags based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getTags = async (\n filters?: GetTagsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetTagsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Adds a new tag to the database.\n * @param tag - Tag data.\n */\n const addTag = async (tag: AddTagBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<AddTagResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: tag,\n }\n );\n\n /**\n * Updates an existing tag in the database.\n * @param tag - Updated tag data.\n */\n const updateTag = async (\n tagId: UpdateTagParams['tagId'],\n tag: UpdateTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: tag,\n }\n );\n\n /**\n * Deletes a tag from the database by its ID.\n * @param tagId - Tag ID.\n */\n const deleteTag = async (\n tagId: DeleteTagParams['tagId'],\n\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n getTags,\n addTag,\n updateTag,\n deleteTag,\n };\n};\n"],"mappings":"2MAeA,MAAa,GACX,EAAiC,EAAE,CACnC,IACG,CACH,IAAM,EACJ,GAAgB,QAAQ,YAAcA,EAAAA,SAAe,QAAQ,WAE/D,GAAI,CAAC,EACH,MAAU,MACR,4DACD,CAGH,IAAM,EAAoB,GAAG,EAAW,UAyExC,MAAO,CACL,QApEc,MACd,EACA,EAA+B,EAAE,GAEjC,MAAMC,EAAAA,QACJ,EACA,EACA,EACA,CACE,MAAO,WAEP,OAAQ,EACT,CACF,CAwDD,OAlDa,MAAO,EAAiB,EAA+B,EAAE,GACtE,MAAMA,EAAAA,QACJ,GAAG,IACH,EACA,EACA,CACE,OAAQ,OACR,KAAM,EACP,CACF,CA0CD,UApCgB,MAChB,EACA,EACA,EAA+B,EAAE,GAEjC,MAAMA,EAAAA,QACJ,GAAG,EAAkB,GAAG,IACxB,EACA,EACA,CACE,OAAQ,MACR,KAAM,EACP,CACF,CAwBD,UAlBgB,MAChB,EAEA,EAA+B,EAAE,GAEjC,MAAMA,EAAAA,QACJ,GAAG,EAAkB,GAAG,IACxB,EACA,EACA,CACE,OAAQ,SACT,CACF,CAOF"}
@@ -1,83 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_fetcher = require('../fetcher.cjs');
4
- let _intlayer_config_built = require("@intlayer/config/built");
5
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
6
-
7
- //#region src/getIntlayerAPI/user.ts
8
- const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
9
- const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.default?.editor?.backendURL;
10
- if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
11
- const USER_API_ROUTE = `${backendURL}/api/user`;
12
- /**
13
- * Retrieves a list of users based on filters and pagination.
14
- * @param filters - Filters and pagination options.
15
- * @returns List of users.
16
- */
17
- const getUsers = async (filters, otherOptions = {}) => await require_fetcher.fetcher(USER_API_ROUTE, authAPIOptions, otherOptions, {
18
- cache: "no-store",
19
- params: filters
20
- });
21
- /**
22
- * Retrieves a user by ID.
23
- * @param userId - User ID.
24
- * @returns User object.
25
- */
26
- const getUserById = async (userId, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/${userId}`, authAPIOptions, otherOptions, { cache: "no-store" });
27
- /**
28
- * Retrieves a user by email.
29
- * @param email - User email.
30
- * @returns User object.
31
- */
32
- const getUserByEmail = async (email, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/email/${email}`, authAPIOptions, otherOptions, { cache: "no-store" });
33
- /**
34
- * Retrieves a user by account.
35
- * @param providerAccountId - The provider account ID.
36
- * @param provider - The provider of the account.
37
- */
38
- const getUserByAccount = async (providerAccountId, provider, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/account/${provider}/${providerAccountId}`, authAPIOptions, otherOptions, { cache: "no-store" });
39
- /**
40
- * Creates a new user.
41
- * @param user - User credentials.
42
- * @returns User object.
43
- */
44
- const createUser = async (user, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/`, authAPIOptions, otherOptions, {
45
- method: "POST",
46
- body: user
47
- });
48
- /**
49
- * Updates the user with the provided data.
50
- * @param user - Updated user data.
51
- * @returns User object.
52
- */
53
- const updateUser = async (user, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}`, authAPIOptions, otherOptions, {
54
- method: "PUT",
55
- body: user
56
- });
57
- /**
58
- * Deletes a user with the provided ID.
59
- * @param userId - User ID.
60
- * @returns User object.
61
- */
62
- const deleteUser = async (userId, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/${userId}`, authAPIOptions, otherOptions, { method: "DELETE" });
63
- /**
64
- * Gets the verify email status URL to use in the SSE.
65
- * @param userId - User ID.
66
- * @returns The verify email status URL.
67
- */
68
- const getVerifyEmailStatusURL = (userId) => `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;
69
- return {
70
- createUser,
71
- getUsers,
72
- getUserById,
73
- getUserByAccount,
74
- getUserByEmail,
75
- updateUser,
76
- deleteUser,
77
- getVerifyEmailStatusURL
78
- };
79
- };
80
-
81
- //#endregion
82
- exports.getUserAPI = getUserAPI;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../fetcher.cjs`);let n=require(`@intlayer/config/built`);n=e.__toESM(n);const r=(e={},r)=>{let i=r?.editor?.backendURL??n.default?.editor?.backendURL;if(!i)throw Error(`Backend URL is not defined in the Intlayer configuration.`);let a=`${i}/api/user`;return{createUser:async(n,r={})=>await t.fetcher(`${a}/`,e,r,{method:`POST`,body:n}),getUsers:async(n,r={})=>await t.fetcher(a,e,r,{cache:`no-store`,params:n}),getUserById:async(n,r={})=>await t.fetcher(`${a}/${n}`,e,r,{cache:`no-store`}),getUserByAccount:async(n,r,i={})=>await t.fetcher(`${a}/account/${r}/${n}`,e,i,{cache:`no-store`}),getUserByEmail:async(n,r={})=>await t.fetcher(`${a}/email/${n}`,e,r,{cache:`no-store`}),updateUser:async(n,r={})=>await t.fetcher(`${a}`,e,r,{method:`PUT`,body:n}),deleteUser:async(n,r={})=>await t.fetcher(`${a}/${n}`,e,r,{method:`DELETE`}),getVerifyEmailStatusURL:e=>`${a}/verify-email-status/${String(e)}`}};exports.getUserAPI=r;
83
2
  //# sourceMappingURL=user.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n CreateUserBody,\n CreateUserResult,\n GetUserByAccountParams,\n GetUserByAccountResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n UpdateUserBody,\n UpdateUserResult,\n UserAPI,\n} from '../types';\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const USER_API_ROUTE = `${backendURL}/api/user`;\n\n /**\n * Retrieves a list of users based on filters and pagination.\n * @param filters - Filters and pagination options.\n * @returns List of users.\n */\n const getUsers = async (\n filters?: GetUsersParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUsersResult>(\n USER_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves a user by ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const getUserById = async (\n userId: GetUserByIdParams['userId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByIdResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by email.\n * @param email - User email.\n * @returns User object.\n */\n const getUserByEmail = async (\n email: GetUserByEmailParams['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByEmailResult>(\n `${USER_API_ROUTE}/email/${email}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by account.\n * @param providerAccountId - The provider account ID.\n * @param provider - The provider of the account.\n */\n const getUserByAccount = async (\n providerAccountId: GetUserByAccountParams['providerAccountId'],\n provider: GetUserByAccountParams['provider'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByAccountResult>(\n `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Creates a new user.\n * @param user - User credentials.\n * @returns User object.\n */\n const createUser = async (\n user: CreateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateUserResult>(\n `${USER_API_ROUTE}/`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Updates the user with the provided data.\n * @param user - Updated user data.\n * @returns User object.\n */\n const updateUser = async (\n user: UpdateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: user,\n }\n );\n\n /**\n * Deletes a user with the provided ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const deleteUser = async (\n userId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['id']) =>\n `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n return {\n createUser,\n getUsers,\n getUserById,\n getUserByAccount,\n getUserByEmail,\n updateUser,\n deleteUser,\n getVerifyEmailStatusURL,\n };\n};\n"],"mappings":";;;;;;;AAmBA,MAAa,cACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,gCAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,iBAAiB,GAAG,WAAW;;;;;;CAOrC,MAAM,WAAW,OACf,SACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,gBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;;CAOH,MAAM,cAAc,OAClB,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,iBAAiB,OACrB,OACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,eAAe,SAAS,SAC3B,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,mBAAmB,OACvB,mBACA,UACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,eAAe,WAAW,SAAS,GAAG,qBACzC,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,eAAe,IAClB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,QACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,QAAQ,UACT,CACF;;;;;;CAOH,MAAM,2BAA2B,WAC/B,GAAG,eAAe,uBAAuB,OAAO,OAAO;AAEzD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"user.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n CreateUserBody,\n CreateUserResult,\n GetUserByAccountParams,\n GetUserByAccountResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n UpdateUserBody,\n UpdateUserResult,\n UserAPI,\n} from '../types';\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const USER_API_ROUTE = `${backendURL}/api/user`;\n\n /**\n * Retrieves a list of users based on filters and pagination.\n * @param filters - Filters and pagination options.\n * @returns List of users.\n */\n const getUsers = async (\n filters?: GetUsersParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUsersResult>(\n USER_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves a user by ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const getUserById = async (\n userId: GetUserByIdParams['userId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByIdResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by email.\n * @param email - User email.\n * @returns User object.\n */\n const getUserByEmail = async (\n email: GetUserByEmailParams['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByEmailResult>(\n `${USER_API_ROUTE}/email/${email}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by account.\n * @param providerAccountId - The provider account ID.\n * @param provider - The provider of the account.\n */\n const getUserByAccount = async (\n providerAccountId: GetUserByAccountParams['providerAccountId'],\n provider: GetUserByAccountParams['provider'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByAccountResult>(\n `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Creates a new user.\n * @param user - User credentials.\n * @returns User object.\n */\n const createUser = async (\n user: CreateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateUserResult>(\n `${USER_API_ROUTE}/`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Updates the user with the provided data.\n * @param user - Updated user data.\n * @returns User object.\n */\n const updateUser = async (\n user: UpdateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: user,\n }\n );\n\n /**\n * Deletes a user with the provided ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const deleteUser = async (\n userId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['id']) =>\n `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n return {\n createUser,\n getUsers,\n getUserById,\n getUserByAccount,\n getUserByEmail,\n updateUser,\n deleteUser,\n getVerifyEmailStatusURL,\n };\n};\n"],"mappings":"2MAmBA,MAAa,GACX,EAAiC,EAAE,CACnC,IACG,CACH,IAAM,EACJ,GAAgB,QAAQ,YAAcA,EAAAA,SAAe,QAAQ,WAE/D,GAAI,CAAC,EACH,MAAU,MACR,4DACD,CAGH,IAAM,EAAiB,GAAG,EAAW,WA6IrC,MAAO,CACL,WA5DiB,MACjB,EACA,EAA+B,EAAE,GAEjC,MAAMC,EAAAA,QACJ,GAAG,EAAe,GAClB,EACA,EACA,CACE,OAAQ,OACR,KAAM,EACP,CACF,CAiDD,SAxIe,MACf,EACA,EAA+B,EAAE,GAEjC,MAAMA,EAAAA,QACJ,EACA,EACA,EACA,CACE,MAAO,WAEP,OAAQ,EACT,CACF,CA4HD,YArHkB,MAClB,EACA,EAA+B,EAAE,GAEjC,MAAMA,EAAAA,QACJ,GAAG,EAAe,GAAG,IACrB,EACA,EACA,CACE,MAAO,WACR,CACF,CA2GD,iBAlFuB,MACvB,EACA,EACA,EAA+B,EAAE,GAEjC,MAAMA,EAAAA,QACJ,GAAG,EAAe,WAAW,EAAS,GAAG,IACzC,EACA,EACA,CACE,MAAO,WACR,CACF,CAuED,eArGqB,MACrB,EACA,EAA+B,EAAE,GAEjC,MAAMA,EAAAA,QACJ,GAAG,EAAe,SAAS,IAC3B,EACA,EACA,CACE,MAAO,WACR,CACF,CA2FD,WA9CiB,MACjB,EACA,EAA+B,EAAE,GAEjC,MAAMA,EAAAA,QACJ,GAAG,IACH,EACA,EACA,CACE,OAAQ,MACR,KAAM,EACP,CACF,CAmCD,WA5BiB,MACjB,EACA,EAA+B,EAAE,GAEjC,MAAMA,EAAAA,QACJ,GAAG,EAAe,GAAG,IACrB,EACA,EACA,CACE,OAAQ,SACT,CACF,CAkBD,wBAX+B,GAC/B,GAAG,EAAe,uBAAuB,OAAO,EAAO,GAWxD"}
@@ -1,43 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_fetcher = require('./fetcher.cjs');
3
- const require_getIntlayerAPI_ai = require('./getIntlayerAPI/ai.cjs');
4
- const require_getIntlayerAPI_audit = require('./getIntlayerAPI/audit.cjs');
5
- const require_getIntlayerAPI_bitbucket = require('./getIntlayerAPI/bitbucket.cjs');
6
- const require_getIntlayerAPI_dictionary = require('./getIntlayerAPI/dictionary.cjs');
7
- const require_getIntlayerAPI_editor = require('./getIntlayerAPI/editor.cjs');
8
- const require_getIntlayerAPI_github = require('./getIntlayerAPI/github.cjs');
9
- const require_getIntlayerAPI_gitlab = require('./getIntlayerAPI/gitlab.cjs');
10
- const require_getIntlayerAPI_newsletter = require('./getIntlayerAPI/newsletter.cjs');
11
- const require_getIntlayerAPI_oAuth = require('./getIntlayerAPI/oAuth.cjs');
12
- const require_getIntlayerAPI_organization = require('./getIntlayerAPI/organization.cjs');
13
- const require_getIntlayerAPI_project = require('./getIntlayerAPI/project.cjs');
14
- const require_getIntlayerAPI_search = require('./getIntlayerAPI/search.cjs');
15
- const require_getIntlayerAPI_stripe = require('./getIntlayerAPI/stripe.cjs');
16
- const require_getIntlayerAPI_tag = require('./getIntlayerAPI/tag.cjs');
17
- const require_getIntlayerAPI_user = require('./getIntlayerAPI/user.cjs');
18
- const require_getIntlayerAPI_index = require('./getIntlayerAPI/index.cjs');
19
- const require_proxy = require('./proxy.cjs');
20
- const require_distantDictionary_fetchDistantDictionaries = require('./distantDictionary/fetchDistantDictionaries.cjs');
21
- const require_distantDictionary_fetchDistantDictionary = require('./distantDictionary/fetchDistantDictionary.cjs');
22
-
23
- exports.fetchDistantDictionaries = require_distantDictionary_fetchDistantDictionaries.fetchDistantDictionaries;
24
- exports.fetchDistantDictionary = require_distantDictionary_fetchDistantDictionary.fetchDistantDictionary;
25
- exports.fetcher = require_fetcher.fetcher;
26
- exports.fetcherOptions = require_fetcher.fetcherOptions;
27
- exports.getAiAPI = require_getIntlayerAPI_ai.getAiAPI;
28
- exports.getAuditAPI = require_getIntlayerAPI_audit.getAuditAPI;
29
- exports.getBitbucketAPI = require_getIntlayerAPI_bitbucket.getBitbucketAPI;
30
- exports.getDictionaryAPI = require_getIntlayerAPI_dictionary.getDictionaryAPI;
31
- exports.getEditorAPI = require_getIntlayerAPI_editor.getEditorAPI;
32
- exports.getGithubAPI = require_getIntlayerAPI_github.getGithubAPI;
33
- exports.getGitlabAPI = require_getIntlayerAPI_gitlab.getGitlabAPI;
34
- exports.getIntlayerAPI = require_getIntlayerAPI_index.getIntlayerAPI;
35
- exports.getIntlayerAPIProxy = require_proxy.getIntlayerAPIProxy;
36
- exports.getNewsletterAPI = require_getIntlayerAPI_newsletter.getNewsletterAPI;
37
- exports.getOAuthAPI = require_getIntlayerAPI_oAuth.getOAuthAPI;
38
- exports.getOrganizationAPI = require_getIntlayerAPI_organization.getOrganizationAPI;
39
- exports.getProjectAPI = require_getIntlayerAPI_project.getProjectAPI;
40
- exports.getSearchAPI = require_getIntlayerAPI_search.getSearchAPI;
41
- exports.getStripeAPI = require_getIntlayerAPI_stripe.getStripeAPI;
42
- exports.getTagAPI = require_getIntlayerAPI_tag.getTagAPI;
43
- exports.getUserAPI = require_getIntlayerAPI_user.getUserAPI;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./fetcher.cjs`),t=require(`./getIntlayerAPI/ai.cjs`),n=require(`./getIntlayerAPI/audit.cjs`),r=require(`./getIntlayerAPI/bitbucket.cjs`),i=require(`./getIntlayerAPI/dictionary.cjs`),a=require(`./getIntlayerAPI/editor.cjs`),o=require(`./getIntlayerAPI/github.cjs`),s=require(`./getIntlayerAPI/gitlab.cjs`),c=require(`./getIntlayerAPI/newsletter.cjs`),l=require(`./getIntlayerAPI/oAuth.cjs`),u=require(`./getIntlayerAPI/organization.cjs`),d=require(`./getIntlayerAPI/project.cjs`),f=require(`./getIntlayerAPI/search.cjs`),p=require(`./getIntlayerAPI/stripe.cjs`),m=require(`./getIntlayerAPI/tag.cjs`),h=require(`./getIntlayerAPI/user.cjs`),g=require(`./getIntlayerAPI/index.cjs`),_=require(`./proxy.cjs`),v=require(`./distantDictionary/fetchDistantDictionaries.cjs`),y=require(`./distantDictionary/fetchDistantDictionary.cjs`);exports.fetchDistantDictionaries=v.fetchDistantDictionaries,exports.fetchDistantDictionary=y.fetchDistantDictionary,exports.fetcher=e.fetcher,exports.fetcherOptions=e.fetcherOptions,exports.getAiAPI=t.getAiAPI,exports.getAuditAPI=n.getAuditAPI,exports.getBitbucketAPI=r.getBitbucketAPI,exports.getDictionaryAPI=i.getDictionaryAPI,exports.getEditorAPI=a.getEditorAPI,exports.getGithubAPI=o.getGithubAPI,exports.getGitlabAPI=s.getGitlabAPI,exports.getIntlayerAPI=g.getIntlayerAPI,exports.getIntlayerAPIProxy=_.getIntlayerAPIProxy,exports.getNewsletterAPI=c.getNewsletterAPI,exports.getOAuthAPI=l.getOAuthAPI,exports.getOrganizationAPI=u.getOrganizationAPI,exports.getProjectAPI=d.getProjectAPI,exports.getSearchAPI=f.getSearchAPI,exports.getStripeAPI=p.getStripeAPI,exports.getTagAPI=m.getTagAPI,exports.getUserAPI=h.getUserAPI;
@@ -1,102 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_getIntlayerAPI_oAuth = require('./getIntlayerAPI/oAuth.cjs');
3
- const require_getIntlayerAPI_index = require('./getIntlayerAPI/index.cjs');
4
-
5
- //#region src/proxy.ts
6
- const ONE_MINUTE_MS = 6e4;
7
- /**
8
- * Returns the expiration timestamp in ms from an OAuth token-like object.
9
- */
10
- const getExpiryTimestamp = (token) => {
11
- if (!token) return void 0;
12
- const dateLike = token.accessTokenExpiresAt ?? token.expiresAt;
13
- if (dateLike) {
14
- const ts = typeof dateLike === "string" ? Date.parse(dateLike) : dateLike.getTime?.();
15
- if (typeof ts === "number" && Number.isFinite(ts)) return ts;
16
- }
17
- const seconds = token.expires_in ?? token.expiresIn;
18
- if (typeof seconds === "number" && Number.isFinite(seconds)) return Date.now() + seconds * 1e3;
19
- };
20
- let currentAccessToken;
21
- let currentExpiryTs;
22
- let pendingRefresh;
23
- /**
24
- * Build an auto-auth proxy around getIntlayerAPI that:
25
- * - Fetches an OAuth2 token when needed
26
- * - Injects Authorization header for each request
27
- * - Refreshes token proactively when near expiry
28
- *
29
- * The returned API matches the shape of getIntlayerAPI.
30
- */
31
- const getIntlayerAPIProxy = (_baseAuthOptions = {}, intlayerConfig) => {
32
- const authOptionsRef = { ..._baseAuthOptions };
33
- const hasCMSAuth = intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;
34
- const baseApi = require_getIntlayerAPI_index.getIntlayerAPI(authOptionsRef, intlayerConfig);
35
- const needsRefresh = () => {
36
- if (!currentAccessToken) return true;
37
- if (!currentExpiryTs) return false;
38
- return Date.now() + ONE_MINUTE_MS >= currentExpiryTs;
39
- };
40
- const refreshToken = async () => {
41
- const doRefresh = async () => {
42
- const tokenData = (await require_getIntlayerAPI_oAuth.getOAuthAPI(intlayerConfig).getOAuth2AccessToken())?.data;
43
- currentAccessToken = tokenData?.accessToken;
44
- currentExpiryTs = getExpiryTimestamp(tokenData);
45
- };
46
- if (!pendingRefresh) pendingRefresh = doRefresh().finally(() => {
47
- pendingRefresh = void 0;
48
- });
49
- await pendingRefresh;
50
- };
51
- const ensureValidToken = async () => {
52
- if (needsRefresh()) await refreshToken();
53
- };
54
- const applyAuthHeaderToRef = () => {
55
- if (!currentAccessToken) return;
56
- authOptionsRef.headers = {
57
- ...authOptionsRef.headers ?? {},
58
- Authorization: `Bearer ${currentAccessToken}`
59
- };
60
- };
61
- const wrapSection = (section, skipAuth = !hasCMSAuth) => {
62
- return new Proxy(section, { get(target, prop, receiver) {
63
- const value = Reflect.get(target, prop, receiver);
64
- if (typeof value === "function") return async (...args) => {
65
- if (!skipAuth) {
66
- await ensureValidToken();
67
- applyAuthHeaderToRef();
68
- }
69
- try {
70
- return await value.apply(target, args);
71
- } catch (err) {
72
- if (!skipAuth) {
73
- await refreshToken();
74
- applyAuthHeaderToRef();
75
- return await value.apply(target, args);
76
- }
77
- throw err;
78
- }
79
- };
80
- return value;
81
- } });
82
- };
83
- return {
84
- organization: wrapSection(baseApi.organization),
85
- project: wrapSection(baseApi.project),
86
- user: wrapSection(baseApi.user),
87
- oAuth: wrapSection(baseApi.oAuth, true),
88
- dictionary: wrapSection(baseApi.dictionary),
89
- stripe: wrapSection(baseApi.stripe),
90
- ai: wrapSection(baseApi.ai),
91
- tag: wrapSection(baseApi.tag),
92
- search: wrapSection(baseApi.search),
93
- editor: wrapSection(baseApi.editor),
94
- newsletter: wrapSection(baseApi.newsletter),
95
- github: wrapSection(baseApi.github),
96
- audit: wrapSection(baseApi.audit)
97
- };
98
- };
99
-
100
- //#endregion
101
- exports.getIntlayerAPIProxy = getIntlayerAPIProxy;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getIntlayerAPI/oAuth.cjs`),t=require(`./getIntlayerAPI/index.cjs`),n=e=>{if(!e)return;let t=e.accessTokenExpiresAt??e.expiresAt;if(t){let e=typeof t==`string`?Date.parse(t):t.getTime?.();if(typeof e==`number`&&Number.isFinite(e))return e}let n=e.expires_in??e.expiresIn;if(typeof n==`number`&&Number.isFinite(n))return Date.now()+n*1e3};let r,i,a;const o=(o={},s)=>{let c={...o},l=s?.editor?.clientId&&s?.editor?.clientSecret,u=t.getIntlayerAPI(c,s),d=()=>r?i?Date.now()+6e4>=i:!1:!0,f=async()=>{a||=(async()=>{let t=(await e.getOAuthAPI(s).getOAuth2AccessToken())?.data;r=t?.accessToken,i=n(t)})().finally(()=>{a=void 0}),await a},p=async()=>{d()&&await f()},m=()=>{r&&(c.headers={...c.headers??{},Authorization:`Bearer ${r}`})},h=(e,t=!l)=>new Proxy(e,{get(e,n,r){let i=Reflect.get(e,n,r);return typeof i==`function`?async(...n)=>{t||(await p(),m());try{return await i.apply(e,n)}catch(r){if(!t)return await f(),m(),await i.apply(e,n);throw r}}:i}});return{organization:h(u.organization),project:h(u.project),user:h(u.user),oAuth:h(u.oAuth,!0),dictionary:h(u.dictionary),stripe:h(u.stripe),ai:h(u.ai),tag:h(u.tag),search:h(u.search),editor:h(u.editor),newsletter:h(u.newsletter),github:h(u.github),audit:h(u.audit)}};exports.getIntlayerAPIProxy=o;
102
2
  //# sourceMappingURL=proxy.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.cjs","names":["getIntlayerAPI","getOAuthAPI"],"sources":["../../src/proxy.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from './fetcher';\nimport { getIntlayerAPI } from './getIntlayerAPI';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\n\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Returns the expiration timestamp in ms from an OAuth token-like object.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n if (dateLike) {\n const ts =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof ts === 'number' && Number.isFinite(ts)) return ts;\n }\n const seconds = token.expires_in ?? token.expiresIn;\n if (typeof seconds === 'number' && Number.isFinite(seconds)) {\n return Date.now() + seconds * 1000;\n }\n return undefined;\n};\n\nlet currentAccessToken: string | undefined;\nlet currentExpiryTs: number | undefined;\nlet pendingRefresh: Promise<void> | undefined;\n\n/**\n * Build an auto-auth proxy around getIntlayerAPI that:\n * - Fetches an OAuth2 token when needed\n * - Injects Authorization header for each request\n * - Refreshes token proactively when near expiry\n *\n * The returned API matches the shape of getIntlayerAPI.\n */\nexport const getIntlayerAPIProxy = (\n _baseAuthOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPI => {\n // Use a shared mutable auth options object captured by the API closures\n const authOptionsRef: FetcherOptions = { ..._baseAuthOptions };\n const hasCMSAuth =\n intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;\n const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);\n\n const needsRefresh = (): boolean => {\n if (!currentAccessToken) return true;\n if (!currentExpiryTs) return false; // If unknown, assume usable until failure\n\n return Date.now() + ONE_MINUTE_MS >= currentExpiryTs; // refresh 1 min before expiry\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async () => {\n const authApi = getOAuthAPI(intlayerConfig);\n const res = await authApi.getOAuth2AccessToken();\n const tokenData = res?.data as OAuthTokenLike | undefined;\n\n currentAccessToken = tokenData?.accessToken;\n currentExpiryTs = getExpiryTimestamp(tokenData);\n };\n\n if (!pendingRefresh) {\n pendingRefresh = doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n }\n await pendingRefresh;\n };\n\n const ensureValidToken = async () => {\n if (needsRefresh()) {\n await refreshToken();\n }\n };\n\n const applyAuthHeaderToRef = () => {\n if (!currentAccessToken) return;\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${currentAccessToken}`,\n } as HeadersInit;\n };\n\n const wrapSection = <T extends Record<string, unknown>>(\n section: T,\n skipAuth = !hasCMSAuth\n ): T => {\n return new Proxy(section, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === 'function') {\n // Wrap section method to inject token and headers\n return async (...args: unknown[]) => {\n if (!skipAuth) {\n await ensureValidToken();\n applyAuthHeaderToRef();\n }\n\n try {\n return await value.apply(target, args);\n } catch (err) {\n // Best-effort retry: if token might be stale, refresh once and retry\n if (!skipAuth) {\n await refreshToken();\n applyAuthHeaderToRef();\n return await value.apply(target, args);\n }\n throw err;\n }\n };\n }\n\n return value;\n },\n });\n };\n\n return {\n organization: wrapSection(baseApi.organization),\n project: wrapSection(baseApi.project),\n user: wrapSection(baseApi.user),\n oAuth: wrapSection(baseApi.oAuth, true), // do NOT inject auth for token endpoint\n dictionary: wrapSection(baseApi.dictionary),\n stripe: wrapSection(baseApi.stripe),\n ai: wrapSection(baseApi.ai),\n tag: wrapSection(baseApi.tag),\n search: wrapSection(baseApi.search),\n editor: wrapSection(baseApi.editor),\n newsletter: wrapSection(baseApi.newsletter),\n github: wrapSection(baseApi.github),\n audit: wrapSection(baseApi.audit),\n } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;;AAcA,MAAM,gBAAgB;;;;AAKtB,MAAM,sBACJ,UACuB;AACvB,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,WAAY,MAAM,wBAAwB,MAAM;AAItD,KAAI,UAAU;EACZ,MAAM,KACJ,OAAO,aAAa,WAChB,KAAK,MAAM,SAAS,GACpB,SAAS,WAAW;AAC1B,MAAI,OAAO,OAAO,YAAY,OAAO,SAAS,GAAG,CAAE,QAAO;;CAE5D,MAAM,UAAU,MAAM,cAAc,MAAM;AAC1C,KAAI,OAAO,YAAY,YAAY,OAAO,SAAS,QAAQ,CACzD,QAAO,KAAK,KAAK,GAAG,UAAU;;AAKlC,IAAI;AACJ,IAAI;AACJ,IAAI;;;;;;;;;AAUJ,MAAa,uBACX,mBAAmC,EAAE,EACrC,mBACgB;CAEhB,MAAM,iBAAiC,EAAE,GAAG,kBAAkB;CAC9D,MAAM,aACJ,gBAAgB,QAAQ,YAAY,gBAAgB,QAAQ;CAC9D,MAAM,UAAUA,4CAAe,gBAAgB,eAAe;CAE9D,MAAM,qBAA8B;AAClC,MAAI,CAAC,mBAAoB,QAAO;AAChC,MAAI,CAAC,gBAAiB,QAAO;AAE7B,SAAO,KAAK,KAAK,GAAG,iBAAiB;;CAGvC,MAAM,eAAe,YAA2B;EAC9C,MAAM,YAAY,YAAY;GAG5B,MAAM,aADM,MADIC,yCAAY,eAAe,CACjB,sBAAsB,GACzB;AAEvB,wBAAqB,WAAW;AAChC,qBAAkB,mBAAmB,UAAU;;AAGjD,MAAI,CAAC,eACH,kBAAiB,WAAW,CAAC,cAAc;AACzC,oBAAiB;IACjB;AAEJ,QAAM;;CAGR,MAAM,mBAAmB,YAAY;AACnC,MAAI,cAAc,CAChB,OAAM,cAAc;;CAIxB,MAAM,6BAA6B;AACjC,MAAI,CAAC,mBAAoB;AACzB,iBAAe,UAAU;GACvB,GAAI,eAAe,WAAW,EAAE;GAChC,eAAe,UAAU;GAC1B;;CAGH,MAAM,eACJ,SACA,WAAW,CAAC,eACN;AACN,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;GAC1B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAEjD,OAAI,OAAO,UAAU,WAEnB,QAAO,OAAO,GAAG,SAAoB;AACnC,QAAI,CAAC,UAAU;AACb,WAAM,kBAAkB;AACxB,2BAAsB;;AAGxB,QAAI;AACF,YAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;aAC/B,KAAK;AAEZ,SAAI,CAAC,UAAU;AACb,YAAM,cAAc;AACpB,4BAAsB;AACtB,aAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;;AAExC,WAAM;;;AAKZ,UAAO;KAEV,CAAC;;AAGJ,QAAO;EACL,cAAc,YAAY,QAAQ,aAAa;EAC/C,SAAS,YAAY,QAAQ,QAAQ;EACrC,MAAM,YAAY,QAAQ,KAAK;EAC/B,OAAO,YAAY,QAAQ,OAAO,KAAK;EACvC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACnC,IAAI,YAAY,QAAQ,GAAG;EAC3B,KAAK,YAAY,QAAQ,IAAI;EAC7B,QAAQ,YAAY,QAAQ,OAAO;EACnC,QAAQ,YAAY,QAAQ,OAAO;EACnC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACnC,OAAO,YAAY,QAAQ,MAAM;EAClC"}
1
+ {"version":3,"file":"proxy.cjs","names":["getIntlayerAPI","getOAuthAPI"],"sources":["../../src/proxy.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from './fetcher';\nimport { getIntlayerAPI } from './getIntlayerAPI';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\n\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Returns the expiration timestamp in ms from an OAuth token-like object.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n if (dateLike) {\n const ts =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof ts === 'number' && Number.isFinite(ts)) return ts;\n }\n const seconds = token.expires_in ?? token.expiresIn;\n if (typeof seconds === 'number' && Number.isFinite(seconds)) {\n return Date.now() + seconds * 1000;\n }\n return undefined;\n};\n\nlet currentAccessToken: string | undefined;\nlet currentExpiryTs: number | undefined;\nlet pendingRefresh: Promise<void> | undefined;\n\n/**\n * Build an auto-auth proxy around getIntlayerAPI that:\n * - Fetches an OAuth2 token when needed\n * - Injects Authorization header for each request\n * - Refreshes token proactively when near expiry\n *\n * The returned API matches the shape of getIntlayerAPI.\n */\nexport const getIntlayerAPIProxy = (\n _baseAuthOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPI => {\n // Use a shared mutable auth options object captured by the API closures\n const authOptionsRef: FetcherOptions = { ..._baseAuthOptions };\n const hasCMSAuth =\n intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;\n const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);\n\n const needsRefresh = (): boolean => {\n if (!currentAccessToken) return true;\n if (!currentExpiryTs) return false; // If unknown, assume usable until failure\n\n return Date.now() + ONE_MINUTE_MS >= currentExpiryTs; // refresh 1 min before expiry\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async () => {\n const authApi = getOAuthAPI(intlayerConfig);\n const res = await authApi.getOAuth2AccessToken();\n const tokenData = res?.data as OAuthTokenLike | undefined;\n\n currentAccessToken = tokenData?.accessToken;\n currentExpiryTs = getExpiryTimestamp(tokenData);\n };\n\n if (!pendingRefresh) {\n pendingRefresh = doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n }\n await pendingRefresh;\n };\n\n const ensureValidToken = async () => {\n if (needsRefresh()) {\n await refreshToken();\n }\n };\n\n const applyAuthHeaderToRef = () => {\n if (!currentAccessToken) return;\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${currentAccessToken}`,\n } as HeadersInit;\n };\n\n const wrapSection = <T extends Record<string, unknown>>(\n section: T,\n skipAuth = !hasCMSAuth\n ): T => {\n return new Proxy(section, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === 'function') {\n // Wrap section method to inject token and headers\n return async (...args: unknown[]) => {\n if (!skipAuth) {\n await ensureValidToken();\n applyAuthHeaderToRef();\n }\n\n try {\n return await value.apply(target, args);\n } catch (err) {\n // Best-effort retry: if token might be stale, refresh once and retry\n if (!skipAuth) {\n await refreshToken();\n applyAuthHeaderToRef();\n return await value.apply(target, args);\n }\n throw err;\n }\n };\n }\n\n return value;\n },\n });\n };\n\n return {\n organization: wrapSection(baseApi.organization),\n project: wrapSection(baseApi.project),\n user: wrapSection(baseApi.user),\n oAuth: wrapSection(baseApi.oAuth, true), // do NOT inject auth for token endpoint\n dictionary: wrapSection(baseApi.dictionary),\n stripe: wrapSection(baseApi.stripe),\n ai: wrapSection(baseApi.ai),\n tag: wrapSection(baseApi.tag),\n search: wrapSection(baseApi.search),\n editor: wrapSection(baseApi.editor),\n newsletter: wrapSection(baseApi.newsletter),\n github: wrapSection(baseApi.github),\n audit: wrapSection(baseApi.audit),\n } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":"yJAmBM,EACJ,GACuB,CACvB,GAAI,CAAC,EAAO,OACZ,IAAM,EAAY,EAAM,sBAAwB,EAAM,UAItD,GAAI,EAAU,CACZ,IAAM,EACJ,OAAO,GAAa,SAChB,KAAK,MAAM,EAAS,CACpB,EAAS,WAAW,CAC1B,GAAI,OAAO,GAAO,UAAY,OAAO,SAAS,EAAG,CAAE,OAAO,EAE5D,IAAM,EAAU,EAAM,YAAc,EAAM,UAC1C,GAAI,OAAO,GAAY,UAAY,OAAO,SAAS,EAAQ,CACzD,OAAO,KAAK,KAAK,CAAG,EAAU,KAKlC,IAAI,EACA,EACA,EAUJ,MAAa,GACX,EAAmC,EAAE,CACrC,IACgB,CAEhB,IAAM,EAAiC,CAAE,GAAG,EAAkB,CACxD,EACJ,GAAgB,QAAQ,UAAY,GAAgB,QAAQ,aACxD,EAAUA,EAAAA,eAAe,EAAgB,EAAe,CAExD,MACC,EACA,EAEE,KAAK,KAAK,CAAG,KAAiB,EAFR,GADG,GAM5B,EAAe,SAA2B,CAU9C,AACE,KAVgB,SAAY,CAG5B,IAAM,GADM,MADIC,EAAAA,YAAY,EAAe,CACjB,sBAAsB,GACzB,KAEvB,EAAqB,GAAW,YAChC,EAAkB,EAAmB,EAAU,IAInB,CAAC,YAAc,CACzC,EAAiB,IAAA,IACjB,CAEJ,MAAM,GAGF,EAAmB,SAAY,CAC/B,GAAc,EAChB,MAAM,GAAc,EAIlB,MAA6B,CAC5B,IACL,EAAe,QAAU,CACvB,GAAI,EAAe,SAAW,EAAE,CAChC,cAAe,UAAU,IAC1B,GAGG,GACJ,EACA,EAAW,CAAC,IAEL,IAAI,MAAM,EAAS,CACxB,IAAI,EAAQ,EAAM,EAAU,CAC1B,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAM,EAAS,CAwBjD,OAtBI,OAAO,GAAU,WAEZ,MAAO,GAAG,IAAoB,CAC9B,IACH,MAAM,GAAkB,CACxB,GAAsB,EAGxB,GAAI,CACF,OAAO,MAAM,EAAM,MAAM,EAAQ,EAAK,OAC/B,EAAK,CAEZ,GAAI,CAAC,EAGH,OAFA,MAAM,GAAc,CACpB,GAAsB,CACf,MAAM,EAAM,MAAM,EAAQ,EAAK,CAExC,MAAM,IAKL,GAEV,CAAC,CAGJ,MAAO,CACL,aAAc,EAAY,EAAQ,aAAa,CAC/C,QAAS,EAAY,EAAQ,QAAQ,CACrC,KAAM,EAAY,EAAQ,KAAK,CAC/B,MAAO,EAAY,EAAQ,MAAO,GAAK,CACvC,WAAY,EAAY,EAAQ,WAAW,CAC3C,OAAQ,EAAY,EAAQ,OAAO,CACnC,GAAI,EAAY,EAAQ,GAAG,CAC3B,IAAK,EAAY,EAAQ,IAAI,CAC7B,OAAQ,EAAY,EAAQ,OAAO,CACnC,OAAQ,EAAY,EAAQ,OAAO,CACnC,WAAY,EAAY,EAAQ,WAAW,CAC3C,OAAQ,EAAY,EAAQ,OAAO,CACnC,MAAO,EAAY,EAAQ,MAAM,CAClC"}
@@ -1,20 +1,2 @@
1
- import { getIntlayerAPIProxy } from "../proxy.mjs";
2
-
3
- //#region src/distantDictionary/fetchDistantDictionaries.ts
4
- /**
5
- * Fetch distant dictionary
6
- */
7
- const fetchDistantDictionaries = async (intlayerConfig) => {
8
- try {
9
- const { clientId, clientSecret } = intlayerConfig.editor;
10
- if (!clientId || !clientSecret) throw new Error("Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.");
11
- return (await getIntlayerAPIProxy(void 0, intlayerConfig).dictionary.getDictionaries()).data;
12
- } catch (error) {
13
- console.error(error);
14
- return;
15
- }
16
- };
17
-
18
- //#endregion
19
- export { fetchDistantDictionaries };
1
+ import{getIntlayerAPIProxy as e}from"../proxy.mjs";const t=async t=>{try{let{clientId:n,clientSecret:r}=t.editor;if(!n||!r)throw Error(`Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.`);return(await e(void 0,t).dictionary.getDictionaries()).data}catch(e){console.error(e);return}};export{t as fetchDistantDictionaries};
20
2
  //# sourceMappingURL=fetchDistantDictionaries.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport { getIntlayerAPIProxy } from '../proxy';\nimport type { DictionaryAPI } from '../types';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI[] | null | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary list\n const getDictionaryResult = await api.dictionary.getDictionaries();\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;AAOA,MAAa,2BAA2B,OACtC,mBACgD;AAChD,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;AAUH,UAJ4B,MAHhB,oBAAoB,QAAW,eAAe,CAGpB,WAAW,iBAAiB,EAElB;UAGzC,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
1
+ {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport { getIntlayerAPIProxy } from '../proxy';\nimport type { DictionaryAPI } from '../types';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI[] | null | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary list\n const getDictionaryResult = await api.dictionary.getDictionaries();\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":"mDAOA,MAAa,EAA2B,KACtC,IACgD,CAChD,GAAI,CACF,GAAM,CAAE,WAAU,gBAAiB,EAAe,OAElD,GAAI,CAAC,GAAY,CAAC,EAChB,MAAU,MACR,yGACD,CAUH,OAJ4B,MAHhB,EAAoB,IAAA,GAAW,EAAe,CAGpB,WAAW,iBAAiB,EAElB,WAGzC,EAAO,CACd,QAAQ,MAAM,EAAM,CACpB"}
@@ -1,22 +1,2 @@
1
- import { getIntlayerAPIProxy } from "../proxy.mjs";
2
-
3
- //#region src/distantDictionary/fetchDistantDictionary.ts
4
- /**
5
- * Fetch distant dictionary
6
- */
7
- const fetchDistantDictionary = async (dictionaryKey, intlayerConfig) => {
8
- try {
9
- const { clientId, clientSecret } = intlayerConfig.editor;
10
- if (!clientId || !clientSecret) throw new Error("Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.");
11
- const distantDictionary = (await getIntlayerAPIProxy(void 0, intlayerConfig).dictionary.getDictionary(dictionaryKey)).data;
12
- if (!distantDictionary) throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
13
- return distantDictionary;
14
- } catch (error) {
15
- console.error(error);
16
- return;
17
- }
18
- };
19
-
20
- //#endregion
21
- export { fetchDistantDictionary };
1
+ import{getIntlayerAPIProxy as e}from"../proxy.mjs";const t=async(t,n)=>{try{let{clientId:r,clientSecret:i}=n.editor;if(!r||!i)throw Error(`Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.`);let a=(await e(void 0,n).dictionary.getDictionary(t)).data;if(!a)throw Error(`Dictionary ${t} not found on remote`);return a}catch(e){console.error(e);return}};export{t as fetchDistantDictionary};
22
2
  //# sourceMappingURL=fetchDistantDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionary.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport { getIntlayerAPIProxy } from '../proxy';\nimport type { DictionaryAPI } from '../types';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary\n const getDictionaryResult =\n await api.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;AAOA,MAAa,yBAAyB,OACpC,eACA,mBACuC;AACvC,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;EASH,MAAM,qBAFJ,MAJU,oBAAoB,QAAW,eAAe,CAI9C,WAAW,cAAc,cAAc,EAEL;AAE9C,MAAI,CAAC,kBACH,OAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;AAGpE,SAAO;UACA,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
1
+ {"version":3,"file":"fetchDistantDictionary.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport { getIntlayerAPIProxy } from '../proxy';\nimport type { DictionaryAPI } from '../types';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const api = getIntlayerAPIProxy(undefined, intlayerConfig);\n\n // Fetch the dictionary\n const getDictionaryResult =\n await api.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":"mDAOA,MAAa,EAAyB,MACpC,EACA,IACuC,CACvC,GAAI,CACF,GAAM,CAAE,WAAU,gBAAiB,EAAe,OAElD,GAAI,CAAC,GAAY,CAAC,EAChB,MAAU,MACR,yGACD,CASH,IAAM,GAFJ,MAJU,EAAoB,IAAA,GAAW,EAAe,CAI9C,WAAW,cAAc,EAAc,EAEL,KAE9C,GAAI,CAAC,EACH,MAAU,MAAM,cAAc,EAAc,sBAAsB,CAGpE,OAAO,QACA,EAAO,CACd,QAAQ,MAAM,EAAM,CACpB"}
@@ -1,4 +1 @@
1
- import { fetchDistantDictionaries } from "./fetchDistantDictionaries.mjs";
2
- import { fetchDistantDictionary } from "./fetchDistantDictionary.mjs";
3
-
4
- export { fetchDistantDictionaries, fetchDistantDictionary };
1
+ import{fetchDistantDictionaries as e}from"./fetchDistantDictionaries.mjs";import{fetchDistantDictionary as t}from"./fetchDistantDictionary.mjs";export{e as fetchDistantDictionaries,t as fetchDistantDictionary};
@@ -1,120 +1,2 @@
1
- //#region src/fetcher.ts
2
- /**
3
- * Default options for the fetcher function.
4
- * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',
5
- * and includes credentials in the request.
6
- */
7
- const fetcherOptions = {
8
- method: "GET",
9
- headers: { "Content-Type": "application/json" },
10
- credentials: "include"
11
- };
12
- /**
13
- * Utility function to remove properties with undefined values from an object.
14
- * This helps prevent sending undefined values in the request options.
15
- *
16
- * @param obj - The object to clean.
17
- * @returns The cleaned object without undefined values.
18
- */
19
- const removeUndefined = (obj) => {
20
- Object.keys(obj).forEach((key) => {
21
- if (obj[key] === void 0) delete obj[key];
22
- });
23
- return obj;
24
- };
25
- /**
26
- * Deeply merges an array of objects into a single object.
27
- * Later objects in the array overwrite properties of earlier ones.
28
- *
29
- * @template T - The type of objects being merged.
30
- * @param objects - An array of objects to merge.
31
- * @returns The merged object.
32
- */
33
- const deepMerge = (objects) => objects.reduce((acc, obj) => {
34
- const acc1 = acc ?? {};
35
- const obj1 = removeUndefined(obj ?? {});
36
- if (typeof acc1 === "object" && typeof obj1 === "object") return {
37
- ...acc1,
38
- ...obj1
39
- };
40
- return obj1 ?? acc1;
41
- }, {});
42
- /**
43
- * Fetcher function to make HTTP requests.
44
- * It merges default options with user-provided options,
45
- * handles query parameters and request body,
46
- * and returns the parsed JSON response.
47
- *
48
- * @template T - The expected type of the response data.
49
- * @param url - The endpoint URL.
50
- * @param options - Additional options to customize the request.
51
- * @returns A promise that resolves with the response data of type T.
52
- *
53
- * @example
54
- * ```typescript
55
- * // Making a GET request with query parameters
56
- * const data = await fetcher<MyResponseType>('https://api.example.com/data', {
57
- * params: { search: 'query' },
58
- * });
59
- *
60
- * // Making a POST request with a JSON body
61
- * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {
62
- * method: 'POST',
63
- * body: { key: 'value' },
64
- * });
65
- *
66
- * // Merge body, headers, and params
67
- * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {
68
- * method: 'POST',
69
- * body: { key: 'value' },
70
- * headers: { 'Content-Type': 'application/json' },
71
- * params: { search: 'query' },
72
- * },
73
- * {
74
- * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
75
- * params: { page: 1 },
76
- * });
77
- * ```
78
- *
79
- * Result:
80
- * ```typescript
81
- * {
82
- * method: 'POST',
83
- * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
84
- * params: { page: 1, search: 'query' },
85
- * body: { key: 'value' },
86
- * }
87
- * ```
88
- */
89
- const fetcher = async (url, ...options) => {
90
- const { signal } = new AbortController();
91
- let paramsString = "";
92
- let bodyString;
93
- const mergedOptions = deepMerge([fetcherOptions, ...options.map(({ body, params, headers, ...otherOptions }) => otherOptions)]);
94
- const mergedHeaders = deepMerge([fetcherOptions.headers, ...options.map((option) => option.headers)]);
95
- const params = deepMerge(options.map((option) => option.params));
96
- const method = mergedOptions.method;
97
- if (method !== "GET" && method !== "HEAD") {
98
- const body = deepMerge(options.map((option) => option.body));
99
- if (mergedHeaders?.["Content-Type"] === "application/x-www-form-urlencoded") bodyString = new URLSearchParams(body).toString();
100
- else bodyString = JSON.stringify(body);
101
- }
102
- if (Object.entries(params).length > 0) paramsString = `?${new URLSearchParams(params).toString()}`;
103
- const formattedOptions = {
104
- ...mergedOptions,
105
- headers: mergedHeaders,
106
- body: bodyString,
107
- signal
108
- };
109
- const urlResult = `${url}${paramsString}`;
110
- const response = await fetch(urlResult, formattedOptions);
111
- if (!response.ok) {
112
- const result = await response.json();
113
- throw new Error(JSON.stringify(result.error) ?? "An error occurred");
114
- }
115
- return await response.json();
116
- };
117
-
118
- //#endregion
119
- export { fetcher, fetcherOptions };
1
+ const e={method:`GET`,headers:{"Content-Type":`application/json`},credentials:`include`},t=e=>(Object.keys(e).forEach(t=>{e[t]===void 0&&delete e[t]}),e),n=e=>e.reduce((e,n)=>{let r=e??{},i=t(n??{});return typeof r==`object`&&typeof i==`object`?{...r,...i}:i??r},{}),r=async(t,...r)=>{let{signal:i}=new AbortController,a=``,o,s=n([e,...r.map(({body:e,params:t,headers:n,...r})=>r)]),c=n([e.headers,...r.map(e=>e.headers)]),l=n(r.map(e=>e.params)),u=s.method;if(u!==`GET`&&u!==`HEAD`){let e=n(r.map(e=>e.body));o=c?.[`Content-Type`]===`application/x-www-form-urlencoded`?new URLSearchParams(e).toString():JSON.stringify(e)}Object.entries(l).length>0&&(a=`?${new URLSearchParams(l).toString()}`);let d={...s,headers:c,body:o,signal:i},f=`${t}${a}`,p=await fetch(f,d);if(!p.ok){let e=await p.json();throw Error(JSON.stringify(e.error)??`An error occurred`)}return await p.json()};export{r as fetcher,e as fetcherOptions};
120
2
  //# sourceMappingURL=fetcher.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.mjs","names":[],"sources":["../../src/fetcher.ts"],"sourcesContent":["/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include',\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n const { signal } = new AbortController();\n\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n signal,\n };\n\n // Construct the full URL with query parameters\n const urlResult = `${url}${paramsString}`;\n\n // Make the HTTP request using fetch\n const response = await fetch(urlResult, formattedOptions);\n\n if (!response.ok) {\n const result = await response.json();\n\n // You can customize the error message or include more details\n throw new Error(JSON.stringify(result.error) ?? 'An error occurred');\n }\n return await response.json();\n};\n"],"mappings":";;;;;;AAwBA,MAAa,iBAAiC;CAC5C,QAAQ;CACR,SAAS,EACP,gBAAgB,oBACjB;CACD,aAAa;CACd;;;;;;;;AASD,MAAM,mBAAmB,QAAgB;AACvC,QAAO,KAAK,IAAI,CAAC,SAAS,QAAQ;AAChC,MAAI,IAAI,SAA6B,OACnC,QAAO,IAAI;GAEb;AACF,QAAO;;;;;;;;;;AAWT,MAAM,aAA+B,YACnC,QAAQ,QAAQ,KAAK,QAAQ;CAC3B,MAAM,OAAW,OAAO,EAAE;CAC1B,MAAM,OAAU,gBAAgB,OAAO,EAAE,CAAC;AAE1C,KAAI,OAAO,SAAS,YAAY,OAAO,SAAS,SAE9C,QAAO;EAAE,GAAG;EAAM,GAAG;EAAM;AAI7B,QAAO,QAAQ;GACd,EAAE,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDb,MAAa,UAAU,OACrB,KACA,GAAG,YACY;CACf,MAAM,EAAE,WAAW,IAAI,iBAAiB;CAGxC,IAAI,eAAe;CACnB,IAAI;CAQJ,MAAM,gBAAgB,UAAU,CAAC,gBAAgB,GAL5B,QAAQ,KAC1B,EAAE,MAAM,QAAQ,SAAS,GAAG,mBAAmB,aACjD,CAGgE,CAAC;CAGlE,MAAM,gBAAgB,UAAU,CAC9B,eAAe,SACf,GAAG,QAAQ,KAAK,WAAW,OAAO,QAAQ,CAC3C,CAAC;CAGF,MAAM,SAAS,UAAU,QAAQ,KAAK,WAAW,OAAO,OAAO,CAAC;CAEhE,MAAM,SAAS,cAAc;AAG7B,KAAI,WAAW,SAAS,WAAW,QAAQ;EAEzC,MAAM,OAAO,UAAU,QAAQ,KAAK,WAAW,OAAO,KAAK,CAAC;AAC5D,MACE,gBAAgB,oBAChB,oCAGA,cAAa,IAAI,gBACf,KACD,CAAC,UAAU;MAGZ,cAAa,KAAK,UAAU,KAAK;;AAKrC,KAAI,OAAO,QAAQ,OAAO,CAAC,SAAS,EAClC,gBAAe,IAAI,IAAI,gBACrB,OACD,CAAC,UAAU;CAId,MAAM,mBAAgC;EACpC,GAAG;EACH,SAAS;EACT,MAAM;EACN;EACD;CAGD,MAAM,YAAY,GAAG,MAAM;CAG3B,MAAM,WAAW,MAAM,MAAM,WAAW,iBAAiB;AAEzD,KAAI,CAAC,SAAS,IAAI;EAChB,MAAM,SAAS,MAAM,SAAS,MAAM;AAGpC,QAAM,IAAI,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,oBAAoB;;AAEtE,QAAO,MAAM,SAAS,MAAM"}
1
+ {"version":3,"file":"fetcher.mjs","names":[],"sources":["../../src/fetcher.ts"],"sourcesContent":["/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include',\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n const { signal } = new AbortController();\n\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n signal,\n };\n\n // Construct the full URL with query parameters\n const urlResult = `${url}${paramsString}`;\n\n // Make the HTTP request using fetch\n const response = await fetch(urlResult, formattedOptions);\n\n if (!response.ok) {\n const result = await response.json();\n\n // You can customize the error message or include more details\n throw new Error(JSON.stringify(result.error) ?? 'An error occurred');\n }\n return await response.json();\n};\n"],"mappings":"AAwBA,MAAa,EAAiC,CAC5C,OAAQ,MACR,QAAS,CACP,eAAgB,mBACjB,CACD,YAAa,UACd,CASK,EAAmB,IACvB,OAAO,KAAK,EAAI,CAAC,QAAS,GAAQ,CAC5B,EAAI,KAA6B,IAAA,IACnC,OAAO,EAAI,IAEb,CACK,GAWH,EAA+B,GACnC,EAAQ,QAAQ,EAAK,IAAQ,CAC3B,IAAM,EAAW,GAAO,EAAE,CACpB,EAAU,EAAgB,GAAO,EAAE,CAAC,CAQ1C,OANI,OAAO,GAAS,UAAY,OAAO,GAAS,SAEvC,CAAE,GAAG,EAAM,GAAG,EAAM,CAItB,GAAQ,GACd,EAAE,CAAM,CAiDA,EAAU,MACrB,EACA,GAAG,IACY,CACf,GAAM,CAAE,UAAW,IAAI,gBAGnB,EAAe,GACf,EAQE,EAAgB,EAAU,CAAC,EAAgB,GAL5B,EAAQ,KAC1B,CAAE,OAAM,SAAQ,UAAS,GAAG,KAAmB,EACjD,CAGgE,CAAC,CAG5D,EAAgB,EAAU,CAC9B,EAAe,QACf,GAAG,EAAQ,IAAK,GAAW,EAAO,QAAQ,CAC3C,CAAC,CAGI,EAAS,EAAU,EAAQ,IAAK,GAAW,EAAO,OAAO,CAAC,CAE1D,EAAS,EAAc,OAG7B,GAAI,IAAW,OAAS,IAAW,OAAQ,CAEzC,IAAM,EAAO,EAAU,EAAQ,IAAK,GAAW,EAAO,KAAK,CAAC,CAC5D,AAUE,EATA,IAAgB,kBAChB,oCAGa,IAAI,gBACf,EACD,CAAC,UAAU,CAGC,KAAK,UAAU,EAAK,CAKjC,OAAO,QAAQ,EAAO,CAAC,OAAS,IAClC,EAAe,IAAI,IAAI,gBACrB,EACD,CAAC,UAAU,IAId,IAAM,EAAgC,CACpC,GAAG,EACH,QAAS,EACT,KAAM,EACN,SACD,CAGK,EAAY,GAAG,IAAM,IAGrB,EAAW,MAAM,MAAM,EAAW,EAAiB,CAEzD,GAAI,CAAC,EAAS,GAAI,CAChB,IAAM,EAAS,MAAM,EAAS,MAAM,CAGpC,MAAU,MAAM,KAAK,UAAU,EAAO,MAAM,EAAI,oBAAoB,CAEtE,OAAO,MAAM,EAAS,MAAM"}