@intlayer/api 7.5.9 → 7.5.11

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 (60) hide show
  1. package/README.md +9 -2
  2. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +1 -1
  3. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  4. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +1 -1
  5. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  6. package/dist/cjs/getIntlayerAPI/bitbucket.cjs +74 -0
  7. package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -0
  8. package/dist/cjs/getIntlayerAPI/github.cjs +74 -0
  9. package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -0
  10. package/dist/cjs/getIntlayerAPI/gitlab.cjs +88 -0
  11. package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -0
  12. package/dist/cjs/getIntlayerAPI/index.cjs +6 -0
  13. package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
  14. package/dist/cjs/getIntlayerAPI/project.cjs +33 -1
  15. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  16. package/dist/cjs/index.cjs +2 -0
  17. package/dist/cjs/proxy.cjs +1 -0
  18. package/dist/cjs/proxy.cjs.map +1 -1
  19. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +1 -1
  20. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  21. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +1 -1
  22. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  23. package/dist/esm/getIntlayerAPI/bitbucket.mjs +72 -0
  24. package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -0
  25. package/dist/esm/getIntlayerAPI/github.mjs +72 -0
  26. package/dist/esm/getIntlayerAPI/github.mjs.map +1 -0
  27. package/dist/esm/getIntlayerAPI/gitlab.mjs +86 -0
  28. package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -0
  29. package/dist/esm/getIntlayerAPI/index.mjs +6 -0
  30. package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
  31. package/dist/esm/getIntlayerAPI/project.mjs +33 -1
  32. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  33. package/dist/esm/index.mjs +2 -1
  34. package/dist/esm/proxy.mjs +1 -0
  35. package/dist/esm/proxy.mjs.map +1 -1
  36. package/dist/types/getIntlayerAPI/ai.d.ts +1 -1
  37. package/dist/types/getIntlayerAPI/bitbucket.d.ts +81 -0
  38. package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -0
  39. package/dist/types/getIntlayerAPI/dictionary.d.ts +1 -1
  40. package/dist/types/getIntlayerAPI/github.d.ts +65 -0
  41. package/dist/types/getIntlayerAPI/github.d.ts.map +1 -0
  42. package/dist/types/getIntlayerAPI/gitlab.d.ts +70 -0
  43. package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -0
  44. package/dist/types/getIntlayerAPI/index.d.ts +6 -0
  45. package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
  46. package/dist/types/getIntlayerAPI/newsletter.d.ts +1 -1
  47. package/dist/types/getIntlayerAPI/oAuth.d.ts +0 -1
  48. package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
  49. package/dist/types/getIntlayerAPI/organization.d.ts +1 -1
  50. package/dist/types/getIntlayerAPI/project.d.ts +5 -1
  51. package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
  52. package/dist/types/getIntlayerAPI/search.d.ts +1 -1
  53. package/dist/types/getIntlayerAPI/stripe.d.ts +1 -1
  54. package/dist/types/getIntlayerAPI/tag.d.ts +1 -1
  55. package/dist/types/getIntlayerAPI/user.d.ts +1 -1
  56. package/dist/types/index.d.ts +3 -2
  57. package/dist/types/proxy.d.ts.map +1 -1
  58. package/dist/types/types.d.ts +2 -2
  59. package/dist/types/types.d.ts.map +1 -1
  60. package/package.json +5 -4
package/README.md CHANGED
@@ -5,8 +5,11 @@
5
5
  </p>
6
6
 
7
7
  <h1 align="center">
8
- <strong> Intlayer : an Open-source, per-component i18n toolkit with AI-powered translation & CMS.</strong>
8
+ <strong>Per-component i18n</strong>
9
9
  </h1>
10
+ <h2 align="center">
11
+ <strong>AI-powered translation. Visual Editor. Multilingual CMS.</strong>
12
+ </h2>
10
13
 
11
14
  <br />
12
15
 
@@ -24,6 +27,8 @@
24
27
  <a href="https://github.com/aymericzip/intlayer/blob/main/LICENSE" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/license/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="license"/></a>
25
28
  <a href="https://github.com/aymericzip/intlayer/commits/main" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/last-commit/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="last commit"/>
26
29
  </a>
30
+ <a href="https://www.bountyhub.dev/en/bounty/view/a2f24259-80ae-4a19-82e7-288718fba449/adapt-markdown-parser-in-a-custom-packages" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/badge/Bounties-on%20BountyHub-yellow?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="Bounties on BountyHub"/>
31
+ </a>
27
32
  </p>
28
33
 
29
34
  ![Watch the video](https://github.com/aymericzip/intlayer/blob/main/docs/assets/demo_video.gif)
@@ -46,7 +51,7 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
46
51
  | Feature | Description |
47
52
  | --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
48
53
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
49
- | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.png?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
54
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
50
55
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
51
56
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
52
57
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
@@ -268,6 +273,8 @@ You can also follow us on :
268
273
 
269
274
  For more detailed guidelines on contributing to this project, please refer to the [`CONTRIBUTING.md`](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md) file. It contains essential information on our development process, commit message conventions, and release procedures. Your contributions are valuable to us, and we appreciate your efforts in making this project better!
270
275
 
276
+ Contribute on [GitHub](https://github.com/aymericzip/intlayer), [GitLab](https://gitlab.com/ay.pineau/intlayer), or [Bitbucket](https://bitbucket.org/intlayer/intlayer/).
277
+
271
278
  ### Thank You for the Support
272
279
 
273
280
  If you like Intlayer, give us a ⭐ on GitHub. It helps others discover the project! [See why GitHub Stars matter](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md#why-github-stars-matter-).
@@ -7,7 +7,7 @@ const require_proxy = require('../proxy.cjs');
7
7
  const fetchDistantDictionaries = async (intlayerConfig) => {
8
8
  try {
9
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://intlayer.org/dashboard/project.");
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
11
  return (await require_proxy.getIntlayerAPIProxy(void 0, intlayerConfig).dictionary.getDictionaries()).data;
12
12
  } catch (error) {
13
13
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.cjs","names":["getIntlayerAPIProxy"],"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://intlayer.org/dashboard/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,+GACD;AAUH,UAJ4B,MAHhBA,kCAAoB,QAAW,eAAe,CAGpB,WAAW,iBAAiB,EAElB;UAGzC,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
1
+ {"version":3,"file":"fetchDistantDictionaries.cjs","names":["getIntlayerAPIProxy"],"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,MAHhBA,kCAAoB,QAAW,eAAe,CAGpB,WAAW,iBAAiB,EAElB;UAGzC,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
@@ -7,7 +7,7 @@ const require_proxy = require('../proxy.cjs');
7
7
  const fetchDistantDictionary = async (dictionaryKey, intlayerConfig) => {
8
8
  try {
9
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://intlayer.org/dashboard/project.");
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
11
  const distantDictionary = (await require_proxy.getIntlayerAPIProxy(void 0, intlayerConfig).dictionary.getDictionary(dictionaryKey)).data;
12
12
  if (!distantDictionary) throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
13
13
  return distantDictionary;
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionary.cjs","names":["getIntlayerAPIProxy"],"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://intlayer.org/dashboard/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,+GACD;EASH,MAAM,qBAFJ,MAJUA,kCAAoB,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.cjs","names":["getIntlayerAPIProxy"],"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,MAJUA,kCAAoB,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"}
@@ -0,0 +1,74 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_fetcher = require('../fetcher.cjs');
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
5
+
6
+ //#region src/getIntlayerAPI/bitbucket.ts
7
+ const getBitbucketAPI = (authAPIOptions = {}, intlayerConfig) => {
8
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.default?.editor?.backendURL;
9
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
10
+ const BITBUCKET_API_ROUTE = `${backendURL}/api/bitbucket`;
11
+ /**
12
+ * Get Bitbucket OAuth authorization URL
13
+ * @param redirectUri - Redirect URI after OAuth authorization
14
+ */
15
+ const getAuthUrl = async (redirectUri, otherOptions = {}) => await require_fetcher.fetcher(`${BITBUCKET_API_ROUTE}/auth-url`, authAPIOptions, otherOptions, { params: { redirectUri } });
16
+ /**
17
+ * Exchange Bitbucket authorization code for access token
18
+ * @param code - Bitbucket authorization code
19
+ */
20
+ const authenticate = async (code, otherOptions = {}) => await require_fetcher.fetcher(`${BITBUCKET_API_ROUTE}/auth`, authAPIOptions, otherOptions, {
21
+ method: "POST",
22
+ body: { code }
23
+ });
24
+ /**
25
+ * Get user's Bitbucket repositories
26
+ * @param token - Optional Bitbucket access token. If not provided, backend will use session.
27
+ */
28
+ const getRepositories = async (token, otherOptions = {}) => await require_fetcher.fetcher(`${BITBUCKET_API_ROUTE}/repos`, authAPIOptions, otherOptions, { params: token ? { token } : void 0 });
29
+ /**
30
+ * Check if intlayer.config.ts exists in a Bitbucket repository
31
+ * @param token - Optional Bitbucket access token. If not provided, backend will use session.
32
+ * @param workspace - Bitbucket workspace slug
33
+ * @param repoSlug - Repository slug
34
+ * @param branch - Branch name (default: 'main')
35
+ */
36
+ const checkIntlayerConfig = async (token, workspace, repoSlug, branch = "main", otherOptions = {}) => await require_fetcher.fetcher(`${BITBUCKET_API_ROUTE}/check-config`, authAPIOptions, otherOptions, {
37
+ method: "POST",
38
+ body: {
39
+ token: token ?? void 0,
40
+ workspace,
41
+ repoSlug,
42
+ branch
43
+ }
44
+ });
45
+ /**
46
+ * Get intlayer.config.ts file contents from a Bitbucket repository
47
+ * @param token - Optional Bitbucket access token. If not provided, backend will use session.
48
+ * @param workspace - Bitbucket workspace slug
49
+ * @param repoSlug - Repository slug
50
+ * @param branch - Branch name (default: 'main')
51
+ * @param path - File path (default: 'intlayer.config.ts')
52
+ */
53
+ const getConfigFile = async (token, workspace, repoSlug, branch = "main", path = "intlayer.config.ts", otherOptions = {}) => await require_fetcher.fetcher(`${BITBUCKET_API_ROUTE}/get-config-file`, authAPIOptions, otherOptions, {
54
+ method: "POST",
55
+ body: {
56
+ token: token ?? void 0,
57
+ workspace,
58
+ repoSlug,
59
+ branch,
60
+ path
61
+ }
62
+ });
63
+ return {
64
+ getAuthUrl,
65
+ authenticate,
66
+ getRepositories,
67
+ checkIntlayerConfig,
68
+ getConfigFile
69
+ };
70
+ };
71
+
72
+ //#endregion
73
+ exports.getBitbucketAPI = getBitbucketAPI;
74
+ //# sourceMappingURL=bitbucket.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitbucket.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/bitbucket.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type BitbucketRepository = {\n uuid: string;\n name: string;\n full_name: string;\n slug: string;\n mainbranch?: {\n name: string;\n type: string;\n };\n links: {\n html: {\n href: string;\n };\n };\n workspace: {\n slug: string;\n name: string;\n uuid: string;\n };\n owner: {\n display_name: string;\n username?: string;\n uuid: string;\n };\n updated_on: string;\n is_private: boolean;\n};\n\nexport type BitbucketAuthCallbackBody = {\n code: string;\n};\n\nexport type BitbucketAuthCallbackResult = {\n data: {\n token: string;\n };\n};\n\nexport type BitbucketListReposResult = {\n data: BitbucketRepository[];\n};\n\nexport type BitbucketCheckConfigBody = {\n token?: string;\n workspace: string;\n repoSlug: string;\n branch?: string;\n};\n\nexport type BitbucketCheckConfigResult = {\n data: {\n hasConfig: boolean;\n configPaths: string[];\n };\n};\n\nexport type BitbucketGetConfigFileBody = {\n token?: string;\n workspace: string;\n repoSlug: string;\n branch?: string;\n path?: string;\n};\n\nexport type BitbucketGetConfigFileResult = {\n data: {\n content: string;\n };\n};\n\nexport type BitbucketGetAuthUrlResult = {\n data: {\n authUrl: string;\n };\n};\n\nexport const getBitbucketAPI = (\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 BITBUCKET_API_ROUTE = `${backendURL}/api/bitbucket`;\n\n /**\n * Get Bitbucket OAuth authorization URL\n * @param redirectUri - Redirect URI after OAuth authorization\n */\n const getAuthUrl = async (\n redirectUri: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<BitbucketGetAuthUrlResult>(\n `${BITBUCKET_API_ROUTE}/auth-url`,\n authAPIOptions,\n otherOptions,\n {\n params: { redirectUri },\n }\n );\n\n /**\n * Exchange Bitbucket authorization code for access token\n * @param code - Bitbucket authorization code\n */\n const authenticate = async (\n code: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<BitbucketAuthCallbackResult>(\n `${BITBUCKET_API_ROUTE}/auth`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { code },\n }\n );\n\n /**\n * Get user's Bitbucket repositories\n * @param token - Optional Bitbucket access token. If not provided, backend will use session.\n */\n const getRepositories = async (\n token?: string | null,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<BitbucketListReposResult>(\n `${BITBUCKET_API_ROUTE}/repos`,\n authAPIOptions,\n otherOptions,\n {\n params: token ? { token } : undefined,\n }\n );\n\n /**\n * Check if intlayer.config.ts exists in a Bitbucket repository\n * @param token - Optional Bitbucket access token. If not provided, backend will use session.\n * @param workspace - Bitbucket workspace slug\n * @param repoSlug - Repository slug\n * @param branch - Branch name (default: 'main')\n */\n const checkIntlayerConfig = async (\n token: string | null | undefined,\n workspace: string,\n repoSlug: string,\n branch: string = 'main',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<BitbucketCheckConfigResult>(\n `${BITBUCKET_API_ROUTE}/check-config`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { token: token ?? undefined, workspace, repoSlug, branch },\n }\n );\n\n /**\n * Get intlayer.config.ts file contents from a Bitbucket repository\n * @param token - Optional Bitbucket access token. If not provided, backend will use session.\n * @param workspace - Bitbucket workspace slug\n * @param repoSlug - Repository slug\n * @param branch - Branch name (default: 'main')\n * @param path - File path (default: 'intlayer.config.ts')\n */\n const getConfigFile = async (\n token: string | null | undefined,\n workspace: string,\n repoSlug: string,\n branch: string = 'main',\n path: string = 'intlayer.config.ts',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<BitbucketGetConfigFileResult>(\n `${BITBUCKET_API_ROUTE}/get-config-file`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: {\n token: token ?? undefined,\n workspace,\n repoSlug,\n branch,\n path,\n },\n }\n );\n\n return {\n getAuthUrl,\n authenticate,\n getRepositories,\n checkIntlayerConfig,\n getConfigFile,\n };\n};\n"],"mappings":";;;;;;AAgFA,MAAa,mBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,gCAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,sBAAsB,GAAG,WAAW;;;;;CAM1C,MAAM,aAAa,OACjB,aACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,GAAG,oBAAoB,YACvB,gBACA,cACA,EACE,QAAQ,EAAE,aAAa,EACxB,CACF;;;;;CAMH,MAAM,eAAe,OACnB,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,oBAAoB,QACvB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,MAAM;EACf,CACF;;;;;CAMH,MAAM,kBAAkB,OACtB,OACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,oBAAoB,SACvB,gBACA,cACA,EACE,QAAQ,QAAQ,EAAE,OAAO,GAAG,QAC7B,CACF;;;;;;;;CASH,MAAM,sBAAsB,OAC1B,OACA,WACA,UACA,SAAiB,QACjB,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,oBAAoB,gBACvB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GAAE,OAAO,SAAS;GAAW;GAAW;GAAU;GAAQ;EACjE,CACF;;;;;;;;;CAUH,MAAM,gBAAgB,OACpB,OACA,WACA,UACA,SAAiB,QACjB,OAAe,sBACf,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,oBAAoB,mBACvB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GACJ,OAAO,SAAS;GAChB;GACA;GACA;GACA;GACD;EACF,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACD"}
@@ -0,0 +1,74 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_fetcher = require('../fetcher.cjs');
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
5
+
6
+ //#region src/getIntlayerAPI/github.ts
7
+ const getGithubAPI = (authAPIOptions = {}, intlayerConfig) => {
8
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.default?.editor?.backendURL;
9
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
10
+ const GITHUB_API_ROUTE = `${backendURL}/api/github`;
11
+ /**
12
+ * Get GitHub OAuth authorization URL
13
+ * @param redirectUri - Redirect URI after OAuth authorization
14
+ */
15
+ const getAuthUrl = async (redirectUri, otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/auth-url`, authAPIOptions, otherOptions, { params: { redirectUri } });
16
+ /**
17
+ * Exchange GitHub authorization code for access token
18
+ * @param code - GitHub authorization code
19
+ */
20
+ const authenticate = async (code, otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/auth`, authAPIOptions, otherOptions, {
21
+ method: "POST",
22
+ body: { code }
23
+ });
24
+ /**
25
+ * Get user's GitHub repositories
26
+ * @param token - Optional GitHub access token. If not provided, backend will use session.
27
+ */
28
+ const getRepositories = async (token, otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/repos`, authAPIOptions, otherOptions, { params: token ? { token } : void 0 });
29
+ /**
30
+ * Check if intlayer.config.ts exists in a repository
31
+ * @param token - Optional GitHub access token. If not provided, backend will use session.
32
+ * @param owner - Repository owner
33
+ * @param repository - Repository name
34
+ * @param branch - Branch name (default: 'main')
35
+ */
36
+ const checkIntlayerConfig = async (token, owner, repository, branch = "main", otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/check-config`, authAPIOptions, otherOptions, {
37
+ method: "POST",
38
+ body: {
39
+ token: token ?? void 0,
40
+ owner,
41
+ repository,
42
+ branch
43
+ }
44
+ });
45
+ /**
46
+ * Get intlayer.config.ts file contents from a repository
47
+ * @param token - Optional GitHub access token. If not provided, backend will use session.
48
+ * @param owner - Repository owner
49
+ * @param repository - Repository name
50
+ * @param branch - Branch name (default: 'main')
51
+ * @param path - File path (default: 'intlayer.config.ts')
52
+ */
53
+ const getConfigFile = async (token, owner, repository, branch = "main", path = "intlayer.config.ts", otherOptions = {}) => await require_fetcher.fetcher(`${GITHUB_API_ROUTE}/get-config-file`, authAPIOptions, otherOptions, {
54
+ method: "POST",
55
+ body: {
56
+ token: token ?? void 0,
57
+ owner,
58
+ repository,
59
+ branch,
60
+ path
61
+ }
62
+ });
63
+ return {
64
+ getAuthUrl,
65
+ authenticate,
66
+ getRepositories,
67
+ checkIntlayerConfig,
68
+ getConfigFile
69
+ };
70
+ };
71
+
72
+ //#endregion
73
+ exports.getGithubAPI = getGithubAPI;
74
+ //# sourceMappingURL=github.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/github.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type GitHubRepository = {\n id: number;\n name: string;\n full_name: string;\n owner: {\n login: string;\n id: number;\n };\n html_url: string;\n default_branch: string;\n private: boolean;\n};\n\nexport type GitHubAuthCallbackBody = {\n code: string;\n};\n\nexport type GitHubAuthCallbackResult = {\n data: {\n token: string;\n };\n};\n\nexport type GitHubListReposResult = {\n data: GitHubRepository[];\n};\n\nexport type GitHubCheckConfigBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n};\n\nexport type GitHubCheckConfigResult = {\n data: {\n hasConfig: boolean;\n };\n};\n\nexport type GitHubGetConfigFileBody = {\n token?: string;\n owner: string;\n repository: string;\n branch?: string;\n path?: string;\n};\n\nexport type GitHubGetConfigFileResult = {\n data: {\n content: string;\n };\n};\n\nexport type GitHubGetAuthUrlResult = {\n data: {\n authUrl: string;\n };\n};\n\nexport const getGithubAPI = (\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 GITHUB_API_ROUTE = `${backendURL}/api/github`;\n\n /**\n * Get GitHub OAuth authorization URL\n * @param redirectUri - Redirect URI after OAuth authorization\n */\n const getAuthUrl = async (\n redirectUri: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubGetAuthUrlResult>(\n `${GITHUB_API_ROUTE}/auth-url`,\n authAPIOptions,\n otherOptions,\n {\n params: { redirectUri },\n }\n );\n\n /**\n * Exchange GitHub authorization code for access token\n * @param code - GitHub authorization code\n */\n const authenticate = async (\n code: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubAuthCallbackResult>(\n `${GITHUB_API_ROUTE}/auth`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { code },\n }\n );\n\n /**\n * Get user's GitHub repositories\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n */\n const getRepositories = async (\n token?: string | null,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubListReposResult>(\n `${GITHUB_API_ROUTE}/repos`,\n authAPIOptions,\n otherOptions,\n {\n params: token ? { token } : undefined,\n }\n );\n\n /**\n * Check if intlayer.config.ts exists in a repository\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n * @param owner - Repository owner\n * @param repository - Repository name\n * @param branch - Branch name (default: 'main')\n */\n const checkIntlayerConfig = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubCheckConfigResult>(\n `${GITHUB_API_ROUTE}/check-config`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { token: token ?? undefined, owner, repository, branch },\n }\n );\n\n /**\n * Get intlayer.config.ts file contents from a repository\n * @param token - Optional GitHub access token. If not provided, backend will use session.\n * @param owner - Repository owner\n * @param repository - Repository name\n * @param branch - Branch name (default: 'main')\n * @param path - File path (default: 'intlayer.config.ts')\n */\n const getConfigFile = async (\n token: string | null | undefined,\n owner: string,\n repository: string,\n branch: string = 'main',\n path: string = 'intlayer.config.ts',\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitHubGetConfigFileResult>(\n `${GITHUB_API_ROUTE}/get-config-file`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { token: token ?? undefined, owner, repository, branch, path },\n }\n );\n\n return {\n getAuthUrl,\n authenticate,\n getRepositories,\n checkIntlayerConfig,\n getConfigFile,\n };\n};\n"],"mappings":";;;;;;AAgEA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,gCAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,mBAAmB,GAAG,WAAW;;;;;CAMvC,MAAM,aAAa,OACjB,aACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EACE,QAAQ,EAAE,aAAa,EACxB,CACF;;;;;CAMH,MAAM,eAAe,OACnB,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,QACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,MAAM;EACf,CACF;;;;;CAMH,MAAM,kBAAkB,OACtB,OACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,SACpB,gBACA,cACA,EACE,QAAQ,QAAQ,EAAE,OAAO,GAAG,QAC7B,CACF;;;;;;;;CASH,MAAM,sBAAsB,OAC1B,OACA,OACA,YACA,SAAiB,QACjB,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,gBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;GAAQ;EAC/D,CACF;;;;;;;;;CAUH,MAAM,gBAAgB,OACpB,OACA,OACA,YACA,SAAiB,QACjB,OAAe,sBACf,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,mBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GAAE,OAAO,SAAS;GAAW;GAAO;GAAY;GAAQ;GAAM;EACrE,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACD"}
@@ -0,0 +1,88 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_fetcher = require('../fetcher.cjs');
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
5
+
6
+ //#region src/getIntlayerAPI/gitlab.ts
7
+ const getGitlabAPI = (authAPIOptions = {}, intlayerConfig) => {
8
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.default?.editor?.backendURL;
9
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
10
+ const GITLAB_API_ROUTE = `${backendURL}/api/gitlab`;
11
+ /**
12
+ * Get GitLab OAuth authorization URL
13
+ * @param redirectUri - Redirect URI after OAuth authorization
14
+ * @param instanceUrl - Custom GitLab instance URL (optional, for self-hosted)
15
+ */
16
+ const getAuthUrl = async (redirectUri, instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(`${GITLAB_API_ROUTE}/auth-url`, authAPIOptions, otherOptions, { params: {
17
+ redirectUri,
18
+ ...instanceUrl && { instanceUrl }
19
+ } });
20
+ /**
21
+ * Exchange GitLab authorization code for access token
22
+ * @param code - GitLab authorization code
23
+ * @param redirectUri - Redirect URI used in the authorization request
24
+ * @param instanceUrl - Custom GitLab instance URL (optional)
25
+ */
26
+ const authenticate = async (code, redirectUri, instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(`${GITLAB_API_ROUTE}/auth`, authAPIOptions, otherOptions, {
27
+ method: "POST",
28
+ body: {
29
+ code,
30
+ redirectUri,
31
+ instanceUrl
32
+ }
33
+ });
34
+ /**
35
+ * Get user's GitLab projects
36
+ * @param token - Optional GitLab access token. If not provided, backend will use session.
37
+ * @param instanceUrl - Custom GitLab instance URL (optional)
38
+ */
39
+ const getProjects = async (token, instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(`${GITLAB_API_ROUTE}/projects`, authAPIOptions, otherOptions, { params: {
40
+ ...token && { token },
41
+ ...instanceUrl && { instanceUrl }
42
+ } });
43
+ /**
44
+ * Check if intlayer.config.ts exists in a GitLab repository
45
+ * @param token - Optional GitLab access token. If not provided, backend will use session.
46
+ * @param projectId - GitLab project ID
47
+ * @param branch - Branch name (default: 'main')
48
+ * @param instanceUrl - Custom GitLab instance URL (optional)
49
+ */
50
+ const checkIntlayerConfig = async (token, projectId, branch = "main", instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(`${GITLAB_API_ROUTE}/check-config`, authAPIOptions, otherOptions, {
51
+ method: "POST",
52
+ body: {
53
+ token: token ?? void 0,
54
+ projectId,
55
+ branch,
56
+ ...instanceUrl && { instanceUrl }
57
+ }
58
+ });
59
+ /**
60
+ * Get intlayer.config.ts file contents from a GitLab repository
61
+ * @param token - Optional GitLab access token. If not provided, backend will use session.
62
+ * @param projectId - GitLab project ID
63
+ * @param branch - Branch name (default: 'main')
64
+ * @param path - File path (default: 'intlayer.config.ts')
65
+ * @param instanceUrl - Custom GitLab instance URL (optional)
66
+ */
67
+ const getConfigFile = async (token, projectId, branch = "main", path = "intlayer.config.ts", instanceUrl, otherOptions = {}) => await require_fetcher.fetcher(`${GITLAB_API_ROUTE}/get-config-file`, authAPIOptions, otherOptions, {
68
+ method: "POST",
69
+ body: {
70
+ token: token ?? void 0,
71
+ projectId,
72
+ branch,
73
+ path,
74
+ ...instanceUrl && { instanceUrl }
75
+ }
76
+ });
77
+ return {
78
+ getAuthUrl,
79
+ authenticate,
80
+ getProjects,
81
+ checkIntlayerConfig,
82
+ getConfigFile
83
+ };
84
+ };
85
+
86
+ //#endregion
87
+ exports.getGitlabAPI = getGitlabAPI;
88
+ //# sourceMappingURL=gitlab.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitlab.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/gitlab.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type GitLabProject = {\n id: number;\n name: string;\n path_with_namespace: string;\n web_url: string;\n default_branch: string;\n visibility: string;\n last_activity_at: string;\n namespace: {\n id: number;\n name: string;\n path: string;\n };\n};\n\nexport type GitLabAuthCallbackBody = {\n code: string;\n redirectUri: string;\n instanceUrl?: string;\n};\n\nexport type GitLabAuthCallbackResult = {\n data: {\n token: string;\n };\n};\n\nexport type GitLabListProjectsResult = {\n data: GitLabProject[];\n};\n\nexport type GitLabCheckConfigBody = {\n token?: string;\n projectId: number;\n branch?: string;\n instanceUrl?: string;\n};\n\nexport type GitLabCheckConfigResult = {\n data: {\n hasConfig: boolean;\n configPaths: string[];\n };\n};\n\nexport type GitLabGetConfigFileBody = {\n token?: string;\n projectId: number;\n branch?: string;\n path?: string;\n instanceUrl?: string;\n};\n\nexport type GitLabGetConfigFileResult = {\n data: {\n content: string;\n };\n};\n\nexport type GitLabGetAuthUrlResult = {\n data: {\n authUrl: string;\n };\n};\n\nexport const getGitlabAPI = (\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 GITLAB_API_ROUTE = `${backendURL}/api/gitlab`;\n\n /**\n * Get GitLab OAuth authorization URL\n * @param redirectUri - Redirect URI after OAuth authorization\n * @param instanceUrl - Custom GitLab instance URL (optional, for self-hosted)\n */\n const getAuthUrl = async (\n redirectUri: string,\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabGetAuthUrlResult>(\n `${GITLAB_API_ROUTE}/auth-url`,\n authAPIOptions,\n otherOptions,\n {\n params: { redirectUri, ...(instanceUrl && { instanceUrl }) },\n }\n );\n\n /**\n * Exchange GitLab authorization code for access token\n * @param code - GitLab authorization code\n * @param redirectUri - Redirect URI used in the authorization request\n * @param instanceUrl - Custom GitLab instance URL (optional)\n */\n const authenticate = async (\n code: string,\n redirectUri: string,\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabAuthCallbackResult>(\n `${GITLAB_API_ROUTE}/auth`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { code, redirectUri, instanceUrl },\n }\n );\n\n /**\n * Get user's GitLab projects\n * @param token - Optional GitLab access token. If not provided, backend will use session.\n * @param instanceUrl - Custom GitLab instance URL (optional)\n */\n const getProjects = async (\n token?: string | null,\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabListProjectsResult>(\n `${GITLAB_API_ROUTE}/projects`,\n authAPIOptions,\n otherOptions,\n {\n params: {\n ...(token && { token }),\n ...(instanceUrl && { instanceUrl }),\n },\n }\n );\n\n /**\n * Check if intlayer.config.ts exists in a GitLab repository\n * @param token - Optional GitLab access token. If not provided, backend will use session.\n * @param projectId - GitLab project ID\n * @param branch - Branch name (default: 'main')\n * @param instanceUrl - Custom GitLab instance URL (optional)\n */\n const checkIntlayerConfig = async (\n token: string | null | undefined,\n projectId: number,\n branch: string = 'main',\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabCheckConfigResult>(\n `${GITLAB_API_ROUTE}/check-config`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: {\n token: token ?? undefined,\n projectId,\n branch,\n ...(instanceUrl && { instanceUrl }),\n },\n }\n );\n\n /**\n * Get intlayer.config.ts file contents from a GitLab repository\n * @param token - Optional GitLab access token. If not provided, backend will use session.\n * @param projectId - GitLab project ID\n * @param branch - Branch name (default: 'main')\n * @param path - File path (default: 'intlayer.config.ts')\n * @param instanceUrl - Custom GitLab instance URL (optional)\n */\n const getConfigFile = async (\n token: string | null | undefined,\n projectId: number,\n branch: string = 'main',\n path: string = 'intlayer.config.ts',\n instanceUrl?: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GitLabGetConfigFileResult>(\n `${GITLAB_API_ROUTE}/get-config-file`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: {\n token: token ?? undefined,\n projectId,\n branch,\n path,\n ...(instanceUrl && { instanceUrl }),\n },\n }\n );\n\n return {\n getAuthUrl,\n authenticate,\n getProjects,\n checkIntlayerConfig,\n getConfigFile,\n };\n};\n"],"mappings":";;;;;;AAqEA,MAAa,gBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,gCAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,mBAAmB,GAAG,WAAW;;;;;;CAOvC,MAAM,aAAa,OACjB,aACA,aACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EACE,QAAQ;EAAE;EAAa,GAAI,eAAe,EAAE,aAAa;EAAG,EAC7D,CACF;;;;;;;CAQH,MAAM,eAAe,OACnB,MACA,aACA,aACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,QACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GAAE;GAAM;GAAa;GAAa;EACzC,CACF;;;;;;CAOH,MAAM,cAAc,OAClB,OACA,aACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,YACpB,gBACA,cACA,EACE,QAAQ;EACN,GAAI,SAAS,EAAE,OAAO;EACtB,GAAI,eAAe,EAAE,aAAa;EACnC,EACF,CACF;;;;;;;;CASH,MAAM,sBAAsB,OAC1B,OACA,WACA,SAAiB,QACjB,aACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,gBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GACJ,OAAO,SAAS;GAChB;GACA;GACA,GAAI,eAAe,EAAE,aAAa;GACnC;EACF,CACF;;;;;;;;;CAUH,MAAM,gBAAgB,OACpB,OACA,WACA,SAAiB,QACjB,OAAe,sBACf,aACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,iBAAiB,mBACpB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;GACJ,OAAO,SAAS;GAChB;GACA;GACA;GACA,GAAI,eAAe,EAAE,aAAa;GACnC;EACF,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACD"}
@@ -1,7 +1,10 @@
1
1
  const require_getIntlayerAPI_ai = require('./ai.cjs');
2
2
  const require_getIntlayerAPI_audit = require('./audit.cjs');
3
+ const require_getIntlayerAPI_bitbucket = require('./bitbucket.cjs');
3
4
  const require_getIntlayerAPI_dictionary = require('./dictionary.cjs');
4
5
  const require_getIntlayerAPI_editor = require('./editor.cjs');
6
+ const require_getIntlayerAPI_github = require('./github.cjs');
7
+ const require_getIntlayerAPI_gitlab = require('./gitlab.cjs');
5
8
  const require_getIntlayerAPI_newsletter = require('./newsletter.cjs');
6
9
  const require_getIntlayerAPI_oAuth = require('./oAuth.cjs');
7
10
  const require_getIntlayerAPI_organization = require('./organization.cjs');
@@ -24,6 +27,9 @@ const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => ({
24
27
  search: require_getIntlayerAPI_search.getSearchAPI(authAPIOptions, intlayerConfig),
25
28
  editor: require_getIntlayerAPI_editor.getEditorAPI(authAPIOptions, intlayerConfig),
26
29
  newsletter: require_getIntlayerAPI_newsletter.getNewsletterAPI(authAPIOptions, intlayerConfig),
30
+ github: require_getIntlayerAPI_github.getGithubAPI(authAPIOptions, intlayerConfig),
31
+ gitlab: require_getIntlayerAPI_gitlab.getGitlabAPI(authAPIOptions, intlayerConfig),
32
+ bitbucket: require_getIntlayerAPI_bitbucket.getBitbucketAPI(authAPIOptions, intlayerConfig),
27
33
  audit: require_getIntlayerAPI_audit.getAuditAPI(authAPIOptions, intlayerConfig)
28
34
  });
29
35
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["getOrganizationAPI","getProjectAPI","getUserAPI","getOAuthAPI","getDictionaryAPI","getStripeAPI","getAiAPI","getTagAPI","getSearchAPI","getEditorAPI","getNewsletterAPI","getAuditAPI"],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getAuditAPI } from './audit';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getSearchAPI } from './search';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n audit: ReturnType<typeof getAuditAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPIReturn => ({\n organization: getOrganizationAPI(authAPIOptions, intlayerConfig),\n project: getProjectAPI(authAPIOptions, intlayerConfig),\n user: getUserAPI(authAPIOptions, intlayerConfig),\n oAuth: getOAuthAPI(intlayerConfig),\n dictionary: getDictionaryAPI(authAPIOptions, intlayerConfig),\n stripe: getStripeAPI(authAPIOptions, intlayerConfig),\n ai: getAiAPI(authAPIOptions, intlayerConfig),\n tag: getTagAPI(authAPIOptions, intlayerConfig),\n search: getSearchAPI(authAPIOptions, intlayerConfig),\n editor: getEditorAPI(authAPIOptions, intlayerConfig),\n newsletter: getNewsletterAPI(authAPIOptions, intlayerConfig),\n audit: getAuditAPI(authAPIOptions, intlayerConfig),\n});\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAa,kBACX,iBAAiC,EAAE,EACnC,oBACuB;CACvB,cAAcA,uDAAmB,gBAAgB,eAAe;CAChE,SAASC,6CAAc,gBAAgB,eAAe;CACtD,MAAMC,uCAAW,gBAAgB,eAAe;CAChD,OAAOC,yCAAY,eAAe;CAClC,YAAYC,mDAAiB,gBAAgB,eAAe;CAC5D,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,IAAIC,mCAAS,gBAAgB,eAAe;CAC5C,KAAKC,qCAAU,gBAAgB,eAAe;CAC9C,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,YAAYC,mDAAiB,gBAAgB,eAAe;CAC5D,OAAOC,yCAAY,gBAAgB,eAAe;CACnD"}
1
+ {"version":3,"file":"index.cjs","names":["getOrganizationAPI","getProjectAPI","getUserAPI","getOAuthAPI","getDictionaryAPI","getStripeAPI","getAiAPI","getTagAPI","getSearchAPI","getEditorAPI","getNewsletterAPI","getGithubAPI","getGitlabAPI","getBitbucketAPI","getAuditAPI"],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\nimport { getAuditAPI } from './audit';\nimport { getBitbucketAPI } from './bitbucket';\nimport { getDictionaryAPI } from './dictionary';\nimport { getEditorAPI } from './editor';\nimport { getGithubAPI } from './github';\nimport { getGitlabAPI } from './gitlab';\nimport { getNewsletterAPI } from './newsletter';\nimport { getOAuthAPI } from './oAuth';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getSearchAPI } from './search';\nimport { getStripeAPI } from './stripe';\nimport { getTagAPI } from './tag';\nimport { getUserAPI } from './user';\n\ninterface IntlayerAPIReturn {\n organization: ReturnType<typeof getOrganizationAPI>;\n project: ReturnType<typeof getProjectAPI>;\n user: ReturnType<typeof getUserAPI>;\n oAuth: ReturnType<typeof getOAuthAPI>;\n dictionary: ReturnType<typeof getDictionaryAPI>;\n stripe: ReturnType<typeof getStripeAPI>;\n ai: ReturnType<typeof getAiAPI>;\n tag: ReturnType<typeof getTagAPI>;\n search: ReturnType<typeof getSearchAPI>;\n editor: ReturnType<typeof getEditorAPI>;\n newsletter: ReturnType<typeof getNewsletterAPI>;\n github: ReturnType<typeof getGithubAPI>;\n gitlab: ReturnType<typeof getGitlabAPI>;\n bitbucket: ReturnType<typeof getBitbucketAPI>;\n audit: ReturnType<typeof getAuditAPI>;\n}\n\nexport const getIntlayerAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n): IntlayerAPIReturn => ({\n organization: getOrganizationAPI(authAPIOptions, intlayerConfig),\n project: getProjectAPI(authAPIOptions, intlayerConfig),\n user: getUserAPI(authAPIOptions, intlayerConfig),\n oAuth: getOAuthAPI(intlayerConfig),\n dictionary: getDictionaryAPI(authAPIOptions, intlayerConfig),\n stripe: getStripeAPI(authAPIOptions, intlayerConfig),\n ai: getAiAPI(authAPIOptions, intlayerConfig),\n tag: getTagAPI(authAPIOptions, intlayerConfig),\n search: getSearchAPI(authAPIOptions, intlayerConfig),\n editor: getEditorAPI(authAPIOptions, intlayerConfig),\n newsletter: getNewsletterAPI(authAPIOptions, intlayerConfig),\n github: getGithubAPI(authAPIOptions, intlayerConfig),\n gitlab: getGitlabAPI(authAPIOptions, intlayerConfig),\n bitbucket: getBitbucketAPI(authAPIOptions, intlayerConfig),\n audit: getAuditAPI(authAPIOptions, intlayerConfig),\n});\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAa,kBACX,iBAAiC,EAAE,EACnC,oBACuB;CACvB,cAAcA,uDAAmB,gBAAgB,eAAe;CAChE,SAASC,6CAAc,gBAAgB,eAAe;CACtD,MAAMC,uCAAW,gBAAgB,eAAe;CAChD,OAAOC,yCAAY,eAAe;CAClC,YAAYC,mDAAiB,gBAAgB,eAAe;CAC5D,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,IAAIC,mCAAS,gBAAgB,eAAe;CAC5C,KAAKC,qCAAU,gBAAgB,eAAe;CAC9C,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,YAAYC,mDAAiB,gBAAgB,eAAe;CAC5D,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,QAAQC,2CAAa,gBAAgB,eAAe;CACpD,WAAWC,iDAAgB,gBAAgB,eAAe;CAC1D,OAAOC,yCAAY,gBAAgB,eAAe;CACnD"}
@@ -92,6 +92,34 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
92
92
  method: "PATCH",
93
93
  body: { clientId }
94
94
  });
95
+ /**
96
+ * Triggers CI builds for a project (Git provider pipelines and webhooks).
97
+ * @param otherOptions - Fetcher options.
98
+ * @returns The trigger results.
99
+ */
100
+ const triggerBuild = async (otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/build`, authAPIOptions, otherOptions, { method: "POST" });
101
+ /**
102
+ * Triggers a single webhook by index.
103
+ * @param webhookIndex - The index of the webhook to trigger.
104
+ * @param otherOptions - Fetcher options.
105
+ * @returns The trigger result.
106
+ */
107
+ const triggerWebhook = async (webhookIndex, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/webhook`, authAPIOptions, otherOptions, {
108
+ method: "POST",
109
+ body: { webhookIndex }
110
+ });
111
+ /**
112
+ * Get CI configuration status for the current project.
113
+ * @param otherOptions - Fetcher options.
114
+ * @returns The CI configuration status.
115
+ */
116
+ const getCIConfig = async (otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/ci`, authAPIOptions, otherOptions, { method: "GET" });
117
+ /**
118
+ * Push CI configuration file to the repository.
119
+ * @param otherOptions - Fetcher options.
120
+ * @returns Success status.
121
+ */
122
+ const pushCIConfig = async (otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/ci`, authAPIOptions, otherOptions, { method: "POST" });
95
123
  return {
96
124
  getProjects,
97
125
  addProject,
@@ -103,7 +131,11 @@ const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
103
131
  unselectProject,
104
132
  addNewAccessKey,
105
133
  deleteAccessKey,
106
- refreshAccessKey
134
+ refreshAccessKey,
135
+ triggerBuild,
136
+ triggerWebhook,
137
+ getCIConfig,
138
+ pushCIConfig
107
139
  };
108
140
  };
109
141
 
@@ -1 +1 @@
1
- {"version":3,"file":"project.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectsParams,\n GetProjectsResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n SelectProjectParam,\n SelectProjectResult,\n UnselectProjectResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '../types';\n\nexport const getProjectAPI = (\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/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\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 project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n };\n};\n"],"mappings":";;;;;;AA0BA,MAAa,iBACX,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,cAAc,OAClB,SACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,aAAa,OACjB,SACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,gBAAgB,OACpB,SACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,uBAAuB,OAC3B,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;CAKH,MAAM,2BAA2B,OAC/B,sBACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,iBACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,gBAAgB,OAAO,eAA+B,EAAE,KAC5D,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA,EACE,QAAQ,UACT,CACF;;;;;CAMH,MAAM,gBAAgB,OACpB,WACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,OAAO,UAAU,IACzC,gBACA,cACA,EACE,QAAQ,OACT,CACF;;;;;CAMH,MAAM,kBAAkB,OAAO,eAA+B,EAAE,KAC9D,MAAMA,wBACJ,GAAG,kBAAkB,UACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;;;;;;;CAQH,MAAM,kBAAkB,OACtB,WACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;;CAQH,MAAM,kBAAkB,OACtB,UACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;;;;;;;CAQH,MAAM,mBAAmB,OACvB,UACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"project.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetCIConfigResult,\n GetProjectsParams,\n GetProjectsResult,\n PushCIConfigResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n SelectProjectParam,\n SelectProjectResult,\n TriggerBuildResult,\n TriggerWebhookBody,\n TriggerWebhookResult,\n UnselectProjectResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '../types';\n\nexport const getProjectAPI = (\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/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\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 project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n /**\n * Triggers CI builds for a project (Git provider pipelines and webhooks).\n * @param otherOptions - Fetcher options.\n * @returns The trigger results.\n */\n const triggerBuild = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<TriggerBuildResult>(\n `${PROJECT_API_ROUTE}/build`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Triggers a single webhook by index.\n * @param webhookIndex - The index of the webhook to trigger.\n * @param otherOptions - Fetcher options.\n * @returns The trigger result.\n */\n const triggerWebhook = async (\n webhookIndex: TriggerWebhookBody['webhookIndex'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<TriggerWebhookResult>(\n `${PROJECT_API_ROUTE}/webhook`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { webhookIndex },\n }\n );\n\n /**\n * Get CI configuration status for the current project.\n * @param otherOptions - Fetcher options.\n * @returns The CI configuration status.\n */\n const getCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCIConfigResult>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Push CI configuration file to the repository.\n * @param otherOptions - Fetcher options.\n * @returns Success status.\n */\n const pushCIConfig = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<PushCIConfigResult>(\n `${PROJECT_API_ROUTE}/ci`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n triggerBuild,\n triggerWebhook,\n getCIConfig,\n pushCIConfig,\n };\n};\n"],"mappings":";;;;;;AA+BA,MAAa,iBACX,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,cAAc,OAClB,SACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,aAAa,OACjB,SACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,gBAAgB,OACpB,SACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,uBAAuB,OAC3B,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;CAKH,MAAM,2BAA2B,OAC/B,sBACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,iBACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,gBAAgB,OAAO,eAA+B,EAAE,KAC5D,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA,EACE,QAAQ,UACT,CACF;;;;;CAMH,MAAM,gBAAgB,OACpB,WACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,OAAO,UAAU,IACzC,gBACA,cACA,EACE,QAAQ,OACT,CACF;;;;;CAMH,MAAM,kBAAkB,OAAO,eAA+B,EAAE,KAC9D,MAAMA,wBACJ,GAAG,kBAAkB,UACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;;;;;;;CAQH,MAAM,kBAAkB,OACtB,WACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;;CAQH,MAAM,kBAAkB,OACtB,UACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;;;;;;;CAQH,MAAM,mBAAmB,OACvB,UACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;;;;;;CAOH,MAAM,eAAe,OAAO,eAA+B,EAAE,KAC3D,MAAMA,wBACJ,GAAG,kBAAkB,SACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;;;;;;;CAQH,MAAM,iBAAiB,OACrB,cACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,cAAc;EACvB,CACF;;;;;;CAOH,MAAM,cAAc,OAAO,eAA+B,EAAE,KAC1D,MAAMA,wBACJ,GAAG,kBAAkB,MACrB,gBACA,cACA,EACE,QAAQ,OACT,CACF;;;;;;CAOH,MAAM,eAAe,OAAO,eAA+B,EAAE,KAC3D,MAAMA,wBACJ,GAAG,kBAAkB,MACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -3,6 +3,7 @@ const require_getIntlayerAPI_ai = require('./getIntlayerAPI/ai.cjs');
3
3
  const require_getIntlayerAPI_audit = require('./getIntlayerAPI/audit.cjs');
4
4
  const require_getIntlayerAPI_dictionary = require('./getIntlayerAPI/dictionary.cjs');
5
5
  const require_getIntlayerAPI_editor = require('./getIntlayerAPI/editor.cjs');
6
+ const require_getIntlayerAPI_github = require('./getIntlayerAPI/github.cjs');
6
7
  const require_getIntlayerAPI_oAuth = require('./getIntlayerAPI/oAuth.cjs');
7
8
  const require_getIntlayerAPI_organization = require('./getIntlayerAPI/organization.cjs');
8
9
  const require_getIntlayerAPI_project = require('./getIntlayerAPI/project.cjs');
@@ -22,6 +23,7 @@ exports.getAiAPI = require_getIntlayerAPI_ai.getAiAPI;
22
23
  exports.getAuditAPI = require_getIntlayerAPI_audit.getAuditAPI;
23
24
  exports.getDictionaryAPI = require_getIntlayerAPI_dictionary.getDictionaryAPI;
24
25
  exports.getEditorAPI = require_getIntlayerAPI_editor.getEditorAPI;
26
+ exports.getGithubAPI = require_getIntlayerAPI_github.getGithubAPI;
25
27
  exports.getIntlayerAPI = require_getIntlayerAPI_index.getIntlayerAPI;
26
28
  exports.getIntlayerAPIProxy = require_proxy.getIntlayerAPIProxy;
27
29
  exports.getOAuthAPI = require_getIntlayerAPI_oAuth.getOAuthAPI;
@@ -91,6 +91,7 @@ const getIntlayerAPIProxy = (_baseAuthOptions = {}, intlayerConfig) => {
91
91
  search: wrapSection(baseApi.search),
92
92
  editor: wrapSection(baseApi.editor),
93
93
  newsletter: wrapSection(baseApi.newsletter),
94
+ github: wrapSection(baseApi.github),
94
95
  audit: wrapSection(baseApi.audit)
95
96
  };
96
97
  };
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.cjs","names":["currentAccessToken: string | undefined","currentExpiryTs: number | undefined","pendingRefresh: Promise<void> | undefined","authOptionsRef: FetcherOptions","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 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,IAAIA;AACJ,IAAIC;AACJ,IAAIC;;;;;;;;;AAUJ,MAAa,uBACX,mBAAmC,EAAE,EACrC,mBACgB;CAEhB,MAAMC,iBAAiC,EAAE,GAAG,kBAAkB;CAC9D,MAAM,aACJ,gBAAgB,QAAQ,YAAY,gBAAgB,QAAQ;CAC9D,MAAM,UAAUC,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,OAAO,YAAY,QAAQ,MAAM;EAClC"}
1
+ {"version":3,"file":"proxy.cjs","names":["currentAccessToken: string | undefined","currentExpiryTs: number | undefined","pendingRefresh: Promise<void> | undefined","authOptionsRef: FetcherOptions","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,IAAIA;AACJ,IAAIC;AACJ,IAAIC;;;;;;;;;AAUJ,MAAa,uBACX,mBAAmC,EAAE,EACrC,mBACgB;CAEhB,MAAMC,iBAAiC,EAAE,GAAG,kBAAkB;CAC9D,MAAM,aACJ,gBAAgB,QAAQ,YAAY,gBAAgB,QAAQ;CAC9D,MAAM,UAAUC,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"}
@@ -7,7 +7,7 @@ import { getIntlayerAPIProxy } from "../proxy.mjs";
7
7
  const fetchDistantDictionaries = async (intlayerConfig) => {
8
8
  try {
9
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://intlayer.org/dashboard/project.");
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
11
  return (await getIntlayerAPIProxy(void 0, intlayerConfig).dictionary.getDictionaries()).data;
12
12
  } catch (error) {
13
13
  console.error(error);
@@ -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://intlayer.org/dashboard/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,+GACD;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":";;;;;;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"}
@@ -7,7 +7,7 @@ import { getIntlayerAPIProxy } from "../proxy.mjs";
7
7
  const fetchDistantDictionary = async (dictionaryKey, intlayerConfig) => {
8
8
  try {
9
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://intlayer.org/dashboard/project.");
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
11
  const distantDictionary = (await getIntlayerAPIProxy(void 0, intlayerConfig).dictionary.getDictionary(dictionaryKey)).data;
12
12
  if (!distantDictionary) throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
13
13
  return distantDictionary;