@intlayer/api 6.1.6-canary.0 → 7.0.0-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 (117) hide show
  1. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  2. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +18 -55
  3. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  4. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +20 -58
  5. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  6. package/dist/cjs/distantDictionary/index.cjs +5 -25
  7. package/dist/cjs/fetcher.cjs +113 -89
  8. package/dist/cjs/fetcher.cjs.map +1 -1
  9. package/dist/cjs/getIntlayerAPI/ai.cjs +163 -188
  10. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  11. package/dist/cjs/getIntlayerAPI/dictionary.cjs +69 -117
  12. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  13. package/dist/cjs/getIntlayerAPI/editor.cjs +37 -74
  14. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  15. package/dist/cjs/getIntlayerAPI/index.cjs +27 -49
  16. package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
  17. package/dist/cjs/getIntlayerAPI/newsletter.cjs +40 -77
  18. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  19. package/dist/cjs/getIntlayerAPI/oAuth.cjs +26 -65
  20. package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
  21. package/dist/cjs/getIntlayerAPI/organization.cjs +93 -130
  22. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  23. package/dist/cjs/getIntlayerAPI/project.cjs +109 -154
  24. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  25. package/dist/cjs/getIntlayerAPI/search.cjs +22 -58
  26. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  27. package/dist/cjs/getIntlayerAPI/stripe.cjs +38 -77
  28. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  29. package/dist/cjs/getIntlayerAPI/tag.cjs +47 -86
  30. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  31. package/dist/cjs/getIntlayerAPI/user.cjs +79 -106
  32. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  33. package/dist/cjs/index.cjs +30 -49
  34. package/dist/cjs/proxy.cjs +90 -115
  35. package/dist/cjs/proxy.cjs.map +1 -1
  36. package/dist/cjs/types.cjs +0 -17
  37. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +17 -20
  38. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  39. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +19 -23
  40. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  41. package/dist/esm/distantDictionary/index.mjs +4 -3
  42. package/dist/esm/fetcher.mjs +111 -64
  43. package/dist/esm/fetcher.mjs.map +1 -1
  44. package/dist/esm/getIntlayerAPI/ai.mjs +160 -153
  45. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  46. package/dist/esm/getIntlayerAPI/dictionary.mjs +66 -82
  47. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  48. package/dist/esm/getIntlayerAPI/editor.mjs +34 -39
  49. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  50. package/dist/esm/getIntlayerAPI/index.mjs +16 -14
  51. package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
  52. package/dist/esm/getIntlayerAPI/newsletter.mjs +37 -42
  53. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  54. package/dist/esm/getIntlayerAPI/oAuth.mjs +23 -30
  55. package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
  56. package/dist/esm/getIntlayerAPI/organization.mjs +90 -95
  57. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  58. package/dist/esm/getIntlayerAPI/project.mjs +106 -119
  59. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  60. package/dist/esm/getIntlayerAPI/search.mjs +19 -23
  61. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  62. package/dist/esm/getIntlayerAPI/stripe.mjs +35 -42
  63. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  64. package/dist/esm/getIntlayerAPI/tag.mjs +44 -51
  65. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  66. package/dist/esm/getIntlayerAPI/user.mjs +76 -71
  67. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  68. package/dist/esm/index.mjs +16 -15
  69. package/dist/esm/proxy.mjs +89 -90
  70. package/dist/esm/proxy.mjs.map +1 -1
  71. package/dist/esm/types.mjs +0 -1
  72. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +8 -3
  73. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
  74. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +8 -3
  75. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
  76. package/dist/types/distantDictionary/index.d.ts +3 -3
  77. package/dist/types/fetcher.d.ts +14 -11
  78. package/dist/types/fetcher.d.ts.map +1 -1
  79. package/dist/types/getIntlayerAPI/ai.d.ts +22 -18
  80. package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
  81. package/dist/types/getIntlayerAPI/dictionary.d.ts +16 -12
  82. package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
  83. package/dist/types/getIntlayerAPI/editor.d.ts +11 -7
  84. package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
  85. package/dist/types/getIntlayerAPI/index.d.ts +30 -27
  86. package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
  87. package/dist/types/getIntlayerAPI/newsletter.d.ts +11 -7
  88. package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
  89. package/dist/types/getIntlayerAPI/oAuth.d.ts +8 -5
  90. package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
  91. package/dist/types/getIntlayerAPI/organization.d.ts +18 -13
  92. package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
  93. package/dist/types/getIntlayerAPI/project.d.ts +19 -15
  94. package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
  95. package/dist/types/getIntlayerAPI/search.d.ts +9 -5
  96. package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
  97. package/dist/types/getIntlayerAPI/stripe.d.ts +11 -7
  98. package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
  99. package/dist/types/getIntlayerAPI/tag.d.ts +12 -8
  100. package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
  101. package/dist/types/getIntlayerAPI/user.d.ts +16 -12
  102. package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
  103. package/dist/types/index.d.ts +16 -15
  104. package/dist/types/proxy.d.ts +10 -5
  105. package/dist/types/proxy.d.ts.map +1 -1
  106. package/dist/types/types.d.ts +13 -12
  107. package/dist/types/types.d.ts.map +1 -1
  108. package/package.json +29 -38
  109. package/LICENSE +0 -202
  110. package/dist/cjs/distantDictionary/index.cjs.map +0 -1
  111. package/dist/cjs/index.cjs.map +0 -1
  112. package/dist/cjs/types.cjs.map +0 -1
  113. package/dist/esm/distantDictionary/index.mjs.map +0 -1
  114. package/dist/esm/index.mjs.map +0 -1
  115. package/dist/esm/types.mjs.map +0 -1
  116. package/dist/types/distantDictionary/index.d.ts.map +0 -1
  117. package/dist/types/index.d.ts.map +0 -1
@@ -1,46 +1,39 @@
1
- import configuration from "@intlayer/config/built";
2
1
  import { fetcher } from "../fetcher.mjs";
2
+ import configuration from "@intlayer/config/built";
3
+
4
+ //#region src/getIntlayerAPI/stripe.ts
3
5
  const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
4
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;
5
- if (!backendURL) {
6
- throw new Error(
7
- "Backend URL is not defined in the Intlayer configuration."
8
- );
9
- }
10
- const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;
11
- const getPricing = async (body, otherOptions = {}) => await fetcher(
12
- `${STRIPE_API_ROUTE}/pricing`,
13
- authAPIOptions,
14
- otherOptions,
15
- {
16
- method: "POST",
17
- body
18
- }
19
- );
20
- const getSubscription = async (body, otherOptions = {}) => await fetcher(
21
- `${STRIPE_API_ROUTE}/create-subscription`,
22
- authAPIOptions,
23
- otherOptions,
24
- {
25
- method: "POST",
26
- body
27
- }
28
- );
29
- const cancelSubscription = async (otherOptions = {}) => await fetcher(
30
- `${STRIPE_API_ROUTE}/cancel-subscription`,
31
- authAPIOptions,
32
- otherOptions,
33
- {
34
- method: "POST"
35
- }
36
- );
37
- return {
38
- getPricing,
39
- getSubscription,
40
- cancelSubscription
41
- };
42
- };
43
- export {
44
- getStripeAPI
6
+ const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
8
+ const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;
9
+ /**
10
+ * Get a pricing plan calculated for a given promotion code.
11
+ * @param body - Pricing plan body.
12
+ */
13
+ const getPricing = async (body, otherOptions = {}) => await fetcher(`${STRIPE_API_ROUTE}/pricing`, authAPIOptions, otherOptions, {
14
+ method: "POST",
15
+ body
16
+ });
17
+ /**
18
+ * Retrieves a checkout session.
19
+ * @param body - Checkout session body.
20
+ */
21
+ const getSubscription = async (body, otherOptions = {}) => await fetcher(`${STRIPE_API_ROUTE}/create-subscription`, authAPIOptions, otherOptions, {
22
+ method: "POST",
23
+ body
24
+ });
25
+ /**
26
+ * Cancels a subscription.
27
+ * @param body - Checkout session body.
28
+ */
29
+ const cancelSubscription = async (otherOptions = {}) => await fetcher(`${STRIPE_API_ROUTE}/cancel-subscription`, authAPIOptions, otherOptions, { method: "POST" });
30
+ return {
31
+ getPricing,
32
+ getSubscription,
33
+ cancelSubscription
34
+ };
45
35
  };
36
+
37
+ //#endregion
38
+ export { getStripeAPI };
46
39
  //# sourceMappingURL=stripe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/stripe.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\nimport type {\n GetCheckoutSessionBody,\n GetCheckoutSessionResult,\n GetPricingBody,\n GetPricingResult,\n} from '../types';\n\nexport const getStripeAPI = (\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 STRIPE_API_ROUTE = `${backendURL}/api/stripe`;\n\n /**\n * Get a pricing plan calculated for a given promotion code.\n * @param body - Pricing plan body.\n */\n const getPricing = async (\n body?: GetPricingBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPricingResult>(\n `${STRIPE_API_ROUTE}/pricing`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Retrieves a checkout session.\n * @param body - Checkout session body.\n */\n const getSubscription = async (\n body?: GetCheckoutSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/create-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Cancels a subscription.\n * @param body - Checkout session body.\n */\n const cancelSubscription = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/cancel-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getPricing,\n getSubscription,\n cancelSubscription,\n };\n};\n"],"mappings":"AAAA,OAAO,mBAAmB;AAE1B,SAAS,eAAoC;AAQtC,MAAM,eAAe,CAC1B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,cAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,mBAAmB,GAAG,UAAU;AAMtC,QAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,gBAAgB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAMF,QAAM,kBAAkB,OACtB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,gBAAgB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAMF,QAAM,qBAAqB,OAAO,eAA+B,CAAC,MAChE,MAAM;AAAA,IACJ,GAAG,gBAAgB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"stripe.mjs","names":[],"sources":["../../../src/getIntlayerAPI/stripe.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n GetCheckoutSessionBody,\n GetCheckoutSessionResult,\n GetPricingBody,\n GetPricingResult,\n} from '../types';\n\nexport const getStripeAPI = (\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 STRIPE_API_ROUTE = `${backendURL}/api/stripe`;\n\n /**\n * Get a pricing plan calculated for a given promotion code.\n * @param body - Pricing plan body.\n */\n const getPricing = async (\n body?: GetPricingBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPricingResult>(\n `${STRIPE_API_ROUTE}/pricing`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Retrieves a checkout session.\n * @param body - Checkout session body.\n */\n const getSubscription = async (\n body?: GetCheckoutSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/create-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Cancels a subscription.\n * @param body - Checkout session body.\n */\n const cancelSubscription = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/cancel-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getPricing,\n getSubscription,\n cancelSubscription,\n };\n};\n"],"mappings":";;;;AAUA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,mBAAmB,GAAG,WAAW;;;;;CAMvC,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,WACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;;CAMH,MAAM,kBAAkB,OACtB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,iBAAiB,uBACpB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;;CAMH,MAAM,qBAAqB,OAAO,eAA+B,EAAE,KACjE,MAAM,QACJ,GAAG,iBAAiB,uBACpB,gBACA,cACA,EACE,QAAQ,QACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACD"}
@@ -1,55 +1,48 @@
1
- import configuration from "@intlayer/config/built";
2
1
  import { fetcher } from "../fetcher.mjs";
2
+ import configuration from "@intlayer/config/built";
3
+
4
+ //#region src/getIntlayerAPI/tag.ts
3
5
  const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
4
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;
5
- if (!backendURL) {
6
- throw new Error(
7
- "Backend URL is not defined in the Intlayer configuration."
8
- );
9
- }
10
- const PROJECT_API_ROUTE = `${backendURL}/api/tag`;
11
- const getTags = async (filters, otherOptions = {}) => await fetcher(
12
- PROJECT_API_ROUTE,
13
- authAPIOptions,
14
- otherOptions,
15
- {
16
- params: filters
17
- }
18
- );
19
- const addTag = async (tag, otherOptions = {}) => await fetcher(
20
- `${PROJECT_API_ROUTE}`,
21
- authAPIOptions,
22
- otherOptions,
23
- {
24
- method: "POST",
25
- body: tag
26
- }
27
- );
28
- const updateTag = async (tagId, tag, otherOptions = {}) => await fetcher(
29
- `${PROJECT_API_ROUTE}/${tagId}`,
30
- authAPIOptions,
31
- otherOptions,
32
- {
33
- method: "PUT",
34
- body: tag
35
- }
36
- );
37
- const deleteTag = async (tagId, otherOptions = {}) => await fetcher(
38
- `${PROJECT_API_ROUTE}/${tagId}`,
39
- authAPIOptions,
40
- otherOptions,
41
- {
42
- method: "DELETE"
43
- }
44
- );
45
- return {
46
- getTags,
47
- addTag,
48
- updateTag,
49
- deleteTag
50
- };
51
- };
52
- export {
53
- getTagAPI
6
+ const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
8
+ const PROJECT_API_ROUTE = `${backendURL}/api/tag`;
9
+ /**
10
+ * Retrieves a list of tags based on filters and pagination.
11
+ * @param filters - Filters and pagination options.
12
+ */
13
+ const getTags = async (filters, otherOptions = {}) => await fetcher(PROJECT_API_ROUTE, authAPIOptions, otherOptions, {
14
+ cache: "no-store",
15
+ params: filters
16
+ });
17
+ /**
18
+ * Adds a new tag to the database.
19
+ * @param tag - Tag data.
20
+ */
21
+ const addTag = async (tag, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
22
+ method: "POST",
23
+ body: tag
24
+ });
25
+ /**
26
+ * Updates an existing tag in the database.
27
+ * @param tag - Updated tag data.
28
+ */
29
+ const updateTag = async (tagId, tag, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, {
30
+ method: "PUT",
31
+ body: tag
32
+ });
33
+ /**
34
+ * Deletes a tag from the database by its ID.
35
+ * @param tagId - Tag ID.
36
+ */
37
+ const deleteTag = async (tagId, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, { method: "DELETE" });
38
+ return {
39
+ getTags,
40
+ addTag,
41
+ updateTag,
42
+ deleteTag
43
+ };
54
44
  };
45
+
46
+ //#endregion
47
+ export { getTagAPI };
55
48
  //# sourceMappingURL=tag.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/tag.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } 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 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":"AAAA,OAAO,mBAAmB;AAE1B,SAAS,eAAoC;AAatC,MAAM,YAAY,CACvB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,cAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,oBAAoB,GAAG,UAAU;AAMvC,QAAM,UAAU,OACd,SACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,SAAS,OAAO,KAAiB,eAA+B,CAAC,MACrE,MAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,YAAY,OAChB,OACA,KACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,KAAK;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,YAAY,OAChB,OAEA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,KAAK;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"tag.mjs","names":[],"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,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,oBAAoB,GAAG,WAAW;;;;;CAMxC,MAAM,UAAU,OACd,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,SAAS,OAAO,KAAiB,eAA+B,EAAE,KACtE,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OACA,KACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OAEA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA,EACE,QAAQ,UACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -1,75 +1,80 @@
1
- import configuration from "@intlayer/config/built";
2
1
  import { fetcher } from "../fetcher.mjs";
2
+ import configuration from "@intlayer/config/built";
3
+
4
+ //#region src/getIntlayerAPI/user.ts
3
5
  const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
4
- const backendURL = intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;
5
- if (!backendURL) {
6
- throw new Error(
7
- "Backend URL is not defined in the Intlayer configuration."
8
- );
9
- }
10
- const USER_API_ROUTE = `${backendURL}/api/user`;
11
- const getUsers = async (filters, otherOptions = {}) => await fetcher(
12
- USER_API_ROUTE,
13
- authAPIOptions,
14
- otherOptions,
15
- {
16
- params: filters
17
- }
18
- );
19
- const getUserById = async (userId, otherOptions = {}) => await fetcher(
20
- `${USER_API_ROUTE}/${userId}`,
21
- authAPIOptions,
22
- otherOptions
23
- );
24
- const getUserByEmail = async (email, otherOptions = {}) => await fetcher(
25
- `${USER_API_ROUTE}/email/${email}`,
26
- authAPIOptions,
27
- otherOptions
28
- );
29
- const getUserByAccount = async (providerAccountId, provider, otherOptions = {}) => await fetcher(
30
- `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,
31
- authAPIOptions,
32
- otherOptions
33
- );
34
- const createUser = async (user, otherOptions = {}) => await fetcher(
35
- `${USER_API_ROUTE}/`,
36
- authAPIOptions,
37
- otherOptions,
38
- {
39
- method: "POST",
40
- body: user
41
- }
42
- );
43
- const updateUser = async (user, otherOptions = {}) => await fetcher(
44
- `${USER_API_ROUTE}`,
45
- authAPIOptions,
46
- otherOptions,
47
- {
48
- method: "PUT",
49
- body: user
50
- }
51
- );
52
- const deleteUser = async (userId, otherOptions = {}) => await fetcher(
53
- `${USER_API_ROUTE}/${userId}`,
54
- authAPIOptions,
55
- otherOptions,
56
- {
57
- method: "DELETE"
58
- }
59
- );
60
- const getVerifyEmailStatusURL = (userId) => `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;
61
- return {
62
- createUser,
63
- getUsers,
64
- getUserById,
65
- getUserByAccount,
66
- getUserByEmail,
67
- updateUser,
68
- deleteUser,
69
- getVerifyEmailStatusURL
70
- };
71
- };
72
- export {
73
- getUserAPI
6
+ const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;
7
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
8
+ const USER_API_ROUTE = `${backendURL}/api/user`;
9
+ /**
10
+ * Retrieves a list of users based on filters and pagination.
11
+ * @param filters - Filters and pagination options.
12
+ * @returns List of users.
13
+ */
14
+ const getUsers = async (filters, otherOptions = {}) => await fetcher(USER_API_ROUTE, authAPIOptions, otherOptions, {
15
+ cache: "no-store",
16
+ params: filters
17
+ });
18
+ /**
19
+ * Retrieves a user by ID.
20
+ * @param userId - User ID.
21
+ * @returns User object.
22
+ */
23
+ const getUserById = async (userId, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/${userId}`, authAPIOptions, otherOptions, { cache: "no-store" });
24
+ /**
25
+ * Retrieves a user by email.
26
+ * @param email - User email.
27
+ * @returns User object.
28
+ */
29
+ const getUserByEmail = async (email, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/email/${email}`, authAPIOptions, otherOptions, { cache: "no-store" });
30
+ /**
31
+ * Retrieves a user by account.
32
+ * @param providerAccountId - The provider account ID.
33
+ * @param provider - The provider of the account.
34
+ */
35
+ const getUserByAccount = async (providerAccountId, provider, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/account/${provider}/${providerAccountId}`, authAPIOptions, otherOptions, { cache: "no-store" });
36
+ /**
37
+ * Creates a new user.
38
+ * @param user - User credentials.
39
+ * @returns User object.
40
+ */
41
+ const createUser = async (user, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/`, authAPIOptions, otherOptions, {
42
+ method: "POST",
43
+ body: user
44
+ });
45
+ /**
46
+ * Updates the user with the provided data.
47
+ * @param user - Updated user data.
48
+ * @returns User object.
49
+ */
50
+ const updateUser = async (user, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}`, authAPIOptions, otherOptions, {
51
+ method: "PUT",
52
+ body: user
53
+ });
54
+ /**
55
+ * Deletes a user with the provided ID.
56
+ * @param userId - User ID.
57
+ * @returns User object.
58
+ */
59
+ const deleteUser = async (userId, otherOptions = {}) => await fetcher(`${USER_API_ROUTE}/${userId}`, authAPIOptions, otherOptions, { method: "DELETE" });
60
+ /**
61
+ * Gets the verify email status URL to use in the SSE.
62
+ * @param userId - User ID.
63
+ * @returns The verify email status URL.
64
+ */
65
+ const getVerifyEmailStatusURL = (userId) => `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;
66
+ return {
67
+ createUser,
68
+ getUsers,
69
+ getUserById,
70
+ getUserByAccount,
71
+ getUserByEmail,
72
+ updateUser,
73
+ deleteUser,
74
+ getVerifyEmailStatusURL
75
+ };
74
76
  };
77
+
78
+ //#endregion
79
+ export { getUserAPI };
75
80
  //# sourceMappingURL=user.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } 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 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\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\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\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":"AAAA,OAAO,mBAAmB;AAE1B,SAAS,eAAoC;AAiBtC,MAAM,aAAa,CACxB,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,cAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB,GAAG,UAAU;AAOpC,QAAM,WAAW,OACf,SACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAOF,QAAM,cAAc,OAClB,QACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,cAAc,IAAI,MAAM;AAAA,IAC3B;AAAA,IACA;AAAA,EACF;AAOF,QAAM,iBAAiB,OACrB,OACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,cAAc,UAAU,KAAK;AAAA,IAChC;AAAA,IACA;AAAA,EACF;AAOF,QAAM,mBAAmB,OACvB,mBACA,UACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,cAAc,YAAY,QAAQ,IAAI,iBAAiB;AAAA,IAC1D;AAAA,IACA;AAAA,EACF;AAOF,QAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAOF,QAAM,aAAa,OACjB,MACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAOF,QAAM,aAAa,OACjB,QACA,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,cAAc,IAAI,MAAM;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAOF,QAAM,0BAA0B,CAAC,WAC/B,GAAG,cAAc,wBAAwB,OAAO,MAAM,CAAC;AAEzD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"user.mjs","names":[],"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,cAAc,eAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,iBAAiB,GAAG,WAAW;;;;;;CAOrC,MAAM,WAAW,OACf,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,gBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;;CAOH,MAAM,cAAc,OAClB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,iBAAiB,OACrB,OACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,SAAS,SAC3B,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,mBAAmB,OACvB,mBACA,UACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,WAAW,SAAS,GAAG,qBACzC,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,IAClB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,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,15 +1,16 @@
1
- export * from "./distantDictionary/index.mjs";
2
- export * from "./fetcher.mjs";
3
- export * from "./getIntlayerAPI/index.mjs";
4
- export * from "./getIntlayerAPI/ai.mjs";
5
- export * from "./getIntlayerAPI/dictionary.mjs";
6
- export * from "./getIntlayerAPI/editor.mjs";
7
- export * from "./getIntlayerAPI/oAuth.mjs";
8
- export * from "./getIntlayerAPI/organization.mjs";
9
- export * from "./getIntlayerAPI/project.mjs";
10
- export * from "./getIntlayerAPI/stripe.mjs";
11
- export * from "./getIntlayerAPI/tag.mjs";
12
- export * from "./getIntlayerAPI/user.mjs";
13
- export * from "./proxy.mjs";
14
- export * from "./types.mjs";
15
- //# sourceMappingURL=index.mjs.map
1
+ import { fetcher, fetcherOptions } from "./fetcher.mjs";
2
+ import { getAiAPI } from "./getIntlayerAPI/ai.mjs";
3
+ import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
4
+ import { getEditorAPI } from "./getIntlayerAPI/editor.mjs";
5
+ import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
6
+ import { getOrganizationAPI } from "./getIntlayerAPI/organization.mjs";
7
+ import { getProjectAPI } from "./getIntlayerAPI/project.mjs";
8
+ import { getStripeAPI } from "./getIntlayerAPI/stripe.mjs";
9
+ import { getTagAPI } from "./getIntlayerAPI/tag.mjs";
10
+ import { getUserAPI } from "./getIntlayerAPI/user.mjs";
11
+ import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
12
+ import { getIntlayerAPIProxy } from "./proxy.mjs";
13
+ import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.mjs";
14
+ import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
15
+
16
+ export { fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getDictionaryAPI, getEditorAPI, getIntlayerAPI, getIntlayerAPIProxy, getOAuthAPI, getOrganizationAPI, getProjectAPI, getStripeAPI, getTagAPI, getUserAPI };
@@ -1,100 +1,99 @@
1
- import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
2
1
  import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
2
+ import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
3
+
4
+ //#region src/proxy.ts
3
5
  const ONE_MINUTE_MS = 6e4;
6
+ /**
7
+ * Returns the expiration timestamp in ms from an OAuth token-like object.
8
+ */
4
9
  const getExpiryTimestamp = (token) => {
5
- if (!token) return void 0;
6
- const dateLike = token.accessTokenExpiresAt ?? token.expiresAt;
7
- if (dateLike) {
8
- const ts = typeof dateLike === "string" ? Date.parse(dateLike) : dateLike.getTime?.();
9
- if (typeof ts === "number" && Number.isFinite(ts)) return ts;
10
- }
11
- const seconds = token.expires_in ?? token.expiresIn;
12
- if (typeof seconds === "number" && Number.isFinite(seconds)) {
13
- return Date.now() + seconds * 1e3;
14
- }
15
- return void 0;
10
+ if (!token) return void 0;
11
+ const dateLike = token.accessTokenExpiresAt ?? token.expiresAt;
12
+ if (dateLike) {
13
+ const ts = typeof dateLike === "string" ? Date.parse(dateLike) : dateLike.getTime?.();
14
+ if (typeof ts === "number" && Number.isFinite(ts)) return ts;
15
+ }
16
+ const seconds = token.expires_in ?? token.expiresIn;
17
+ if (typeof seconds === "number" && Number.isFinite(seconds)) return Date.now() + seconds * 1e3;
16
18
  };
17
19
  let currentAccessToken;
18
20
  let currentExpiryTs;
19
21
  let pendingRefresh;
22
+ /**
23
+ * Build an auto-auth proxy around getIntlayerAPI that:
24
+ * - Fetches an OAuth2 token when needed
25
+ * - Injects Authorization header for each request
26
+ * - Refreshes token proactively when near expiry
27
+ *
28
+ * The returned API matches the shape of getIntlayerAPI.
29
+ */
20
30
  const getIntlayerAPIProxy = (_baseAuthOptions = {}, intlayerConfig) => {
21
- const authOptionsRef = { ..._baseAuthOptions };
22
- const hasCMSAuth = intlayerConfig?.editor.clientId && intlayerConfig?.editor.clientSecret;
23
- const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);
24
- const needsRefresh = () => {
25
- if (!currentAccessToken) return true;
26
- if (!currentExpiryTs) return false;
27
- return Date.now() + ONE_MINUTE_MS >= currentExpiryTs;
28
- };
29
- const refreshToken = async () => {
30
- const doRefresh = async () => {
31
- const authApi = getOAuthAPI(intlayerConfig);
32
- const res = await authApi.getOAuth2AccessToken();
33
- const tokenData = res?.data;
34
- currentAccessToken = tokenData?.accessToken;
35
- currentExpiryTs = getExpiryTimestamp(tokenData);
36
- };
37
- if (!pendingRefresh) {
38
- pendingRefresh = doRefresh().finally(() => {
39
- pendingRefresh = void 0;
40
- });
41
- }
42
- await pendingRefresh;
43
- };
44
- const ensureValidToken = async () => {
45
- if (needsRefresh()) {
46
- await refreshToken();
47
- }
48
- };
49
- const applyAuthHeaderToRef = () => {
50
- if (!currentAccessToken) return;
51
- authOptionsRef.headers = {
52
- ...authOptionsRef.headers ?? {},
53
- Authorization: `Bearer ${currentAccessToken}`
54
- };
55
- };
56
- const wrapSection = (section, skipAuth = !hasCMSAuth) => {
57
- return new Proxy(section, {
58
- get(target, prop, receiver) {
59
- const value = Reflect.get(target, prop, receiver);
60
- if (typeof value === "function") {
61
- return async (...args) => {
62
- if (!skipAuth) {
63
- await ensureValidToken();
64
- applyAuthHeaderToRef();
65
- }
66
- try {
67
- return await value.apply(target, args);
68
- } catch (err) {
69
- if (!skipAuth) {
70
- await refreshToken();
71
- applyAuthHeaderToRef();
72
- return await value.apply(target, args);
73
- }
74
- throw err;
75
- }
76
- };
77
- }
78
- return value;
79
- }
80
- });
81
- };
82
- return {
83
- organization: wrapSection(baseApi.organization),
84
- project: wrapSection(baseApi.project),
85
- user: wrapSection(baseApi.user),
86
- oAuth: wrapSection(baseApi.oAuth, true),
87
- // do NOT inject auth for token endpoint
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
- };
96
- };
97
- export {
98
- getIntlayerAPIProxy
31
+ const authOptionsRef = { ..._baseAuthOptions };
32
+ const hasCMSAuth = intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret;
33
+ const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);
34
+ const needsRefresh = () => {
35
+ if (!currentAccessToken) return true;
36
+ if (!currentExpiryTs) return false;
37
+ return Date.now() + ONE_MINUTE_MS >= currentExpiryTs;
38
+ };
39
+ const refreshToken = async () => {
40
+ const doRefresh = async () => {
41
+ const tokenData = (await getOAuthAPI(intlayerConfig).getOAuth2AccessToken())?.data;
42
+ currentAccessToken = tokenData?.accessToken;
43
+ currentExpiryTs = getExpiryTimestamp(tokenData);
44
+ };
45
+ if (!pendingRefresh) pendingRefresh = doRefresh().finally(() => {
46
+ pendingRefresh = void 0;
47
+ });
48
+ await pendingRefresh;
49
+ };
50
+ const ensureValidToken = async () => {
51
+ if (needsRefresh()) await refreshToken();
52
+ };
53
+ const applyAuthHeaderToRef = () => {
54
+ if (!currentAccessToken) return;
55
+ authOptionsRef.headers = {
56
+ ...authOptionsRef.headers ?? {},
57
+ Authorization: `Bearer ${currentAccessToken}`
58
+ };
59
+ };
60
+ const wrapSection = (section, skipAuth = !hasCMSAuth) => {
61
+ return new Proxy(section, { get(target, prop, receiver) {
62
+ const value = Reflect.get(target, prop, receiver);
63
+ if (typeof value === "function") return async (...args) => {
64
+ if (!skipAuth) {
65
+ await ensureValidToken();
66
+ applyAuthHeaderToRef();
67
+ }
68
+ try {
69
+ return await value.apply(target, args);
70
+ } catch (err) {
71
+ if (!skipAuth) {
72
+ await refreshToken();
73
+ applyAuthHeaderToRef();
74
+ return await value.apply(target, args);
75
+ }
76
+ throw err;
77
+ }
78
+ };
79
+ return value;
80
+ } });
81
+ };
82
+ return {
83
+ organization: wrapSection(baseApi.organization),
84
+ project: wrapSection(baseApi.project),
85
+ user: wrapSection(baseApi.user),
86
+ oAuth: wrapSection(baseApi.oAuth, true),
87
+ dictionary: wrapSection(baseApi.dictionary),
88
+ stripe: wrapSection(baseApi.stripe),
89
+ ai: wrapSection(baseApi.ai),
90
+ tag: wrapSection(baseApi.tag),
91
+ search: wrapSection(baseApi.search),
92
+ editor: wrapSection(baseApi.editor),
93
+ newsletter: wrapSection(baseApi.newsletter)
94
+ };
99
95
  };
96
+
97
+ //#endregion
98
+ export { getIntlayerAPIProxy };
100
99
  //# sourceMappingURL=proxy.mjs.map