@intlayer/api 7.0.7 → 7.0.8-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.
- package/dist/cjs/getIntlayerAPI/index.cjs +3 -1
- package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/proxy.cjs +2 -1
- package/dist/cjs/proxy.cjs.map +1 -1
- package/dist/esm/getIntlayerAPI/index.mjs +3 -1
- package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/proxy.mjs +2 -1
- package/dist/esm/proxy.mjs.map +1 -1
- package/dist/types/getIntlayerAPI/index.d.ts +2 -0
- package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/proxy.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -2
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_getIntlayerAPI_ai = require('./ai.cjs');
|
|
2
|
+
const require_getIntlayerAPI_audit = require('./audit.cjs');
|
|
2
3
|
const require_getIntlayerAPI_dictionary = require('./dictionary.cjs');
|
|
3
4
|
const require_getIntlayerAPI_editor = require('./editor.cjs');
|
|
4
5
|
const require_getIntlayerAPI_newsletter = require('./newsletter.cjs');
|
|
@@ -22,7 +23,8 @@ const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => ({
|
|
|
22
23
|
tag: require_getIntlayerAPI_tag.getTagAPI(authAPIOptions, intlayerConfig),
|
|
23
24
|
search: require_getIntlayerAPI_search.getSearchAPI(authAPIOptions, intlayerConfig),
|
|
24
25
|
editor: require_getIntlayerAPI_editor.getEditorAPI(authAPIOptions, intlayerConfig),
|
|
25
|
-
newsletter: require_getIntlayerAPI_newsletter.getNewsletterAPI(authAPIOptions, intlayerConfig)
|
|
26
|
+
newsletter: require_getIntlayerAPI_newsletter.getNewsletterAPI(authAPIOptions, intlayerConfig),
|
|
27
|
+
audit: require_getIntlayerAPI_audit.getAuditAPI(authAPIOptions, intlayerConfig)
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["getOrganizationAPI","getProjectAPI","getUserAPI","getOAuthAPI","getDictionaryAPI","getStripeAPI","getAiAPI","getTagAPI","getSearchAPI","getEditorAPI","getNewsletterAPI"],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\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}\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});\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":"
|
|
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"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_fetcher = require('./fetcher.cjs');
|
|
2
2
|
const require_getIntlayerAPI_ai = require('./getIntlayerAPI/ai.cjs');
|
|
3
|
+
const require_getIntlayerAPI_audit = require('./getIntlayerAPI/audit.cjs');
|
|
3
4
|
const require_getIntlayerAPI_dictionary = require('./getIntlayerAPI/dictionary.cjs');
|
|
4
5
|
const require_getIntlayerAPI_editor = require('./getIntlayerAPI/editor.cjs');
|
|
5
6
|
const require_getIntlayerAPI_oAuth = require('./getIntlayerAPI/oAuth.cjs');
|
|
@@ -18,6 +19,7 @@ exports.fetchDistantDictionary = require_distantDictionary_fetchDistantDictionar
|
|
|
18
19
|
exports.fetcher = require_fetcher.fetcher;
|
|
19
20
|
exports.fetcherOptions = require_fetcher.fetcherOptions;
|
|
20
21
|
exports.getAiAPI = require_getIntlayerAPI_ai.getAiAPI;
|
|
22
|
+
exports.getAuditAPI = require_getIntlayerAPI_audit.getAuditAPI;
|
|
21
23
|
exports.getDictionaryAPI = require_getIntlayerAPI_dictionary.getDictionaryAPI;
|
|
22
24
|
exports.getEditorAPI = require_getIntlayerAPI_editor.getEditorAPI;
|
|
23
25
|
exports.getIntlayerAPI = require_getIntlayerAPI_index.getIntlayerAPI;
|
package/dist/cjs/proxy.cjs
CHANGED
|
@@ -90,7 +90,8 @@ const getIntlayerAPIProxy = (_baseAuthOptions = {}, intlayerConfig) => {
|
|
|
90
90
|
tag: wrapSection(baseApi.tag),
|
|
91
91
|
search: wrapSection(baseApi.search),
|
|
92
92
|
editor: wrapSection(baseApi.editor),
|
|
93
|
-
newsletter: wrapSection(baseApi.newsletter)
|
|
93
|
+
newsletter: wrapSection(baseApi.newsletter),
|
|
94
|
+
audit: wrapSection(baseApi.audit)
|
|
94
95
|
};
|
|
95
96
|
};
|
|
96
97
|
|
package/dist/cjs/proxy.cjs.map
CHANGED
|
@@ -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 } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;AAcA,MAAM,gBAAgB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AI,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;
|
|
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,GACp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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,4 +1,5 @@
|
|
|
1
1
|
import { getAiAPI } from "./ai.mjs";
|
|
2
|
+
import { getAuditAPI } from "./audit.mjs";
|
|
2
3
|
import { getDictionaryAPI } from "./dictionary.mjs";
|
|
3
4
|
import { getEditorAPI } from "./editor.mjs";
|
|
4
5
|
import { getNewsletterAPI } from "./newsletter.mjs";
|
|
@@ -22,7 +23,8 @@ const getIntlayerAPI = (authAPIOptions = {}, intlayerConfig) => ({
|
|
|
22
23
|
tag: getTagAPI(authAPIOptions, intlayerConfig),
|
|
23
24
|
search: getSearchAPI(authAPIOptions, intlayerConfig),
|
|
24
25
|
editor: getEditorAPI(authAPIOptions, intlayerConfig),
|
|
25
|
-
newsletter: getNewsletterAPI(authAPIOptions, intlayerConfig)
|
|
26
|
+
newsletter: getNewsletterAPI(authAPIOptions, intlayerConfig),
|
|
27
|
+
audit: getAuditAPI(authAPIOptions, intlayerConfig)
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport type { FetcherOptions } from '../fetcher';\nimport { getAiAPI } from './ai';\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}\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});\n\nexport type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"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,cAAc,mBAAmB,gBAAgB,eAAe;CAChE,SAAS,cAAc,gBAAgB,eAAe;CACtD,MAAM,WAAW,gBAAgB,eAAe;CAChD,OAAO,YAAY,eAAe;CAClC,YAAY,iBAAiB,gBAAgB,eAAe;CAC5D,QAAQ,aAAa,gBAAgB,eAAe;CACpD,IAAI,SAAS,gBAAgB,eAAe;CAC5C,KAAK,UAAU,gBAAgB,eAAe;CAC9C,QAAQ,aAAa,gBAAgB,eAAe;CACpD,QAAQ,aAAa,gBAAgB,eAAe;CACpD,YAAY,iBAAiB,gBAAgB,eAAe;CAC5D,OAAO,YAAY,gBAAgB,eAAe;CACnD"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fetcher, fetcherOptions } from "./fetcher.mjs";
|
|
2
2
|
import { getAiAPI } from "./getIntlayerAPI/ai.mjs";
|
|
3
|
+
import { getAuditAPI } from "./getIntlayerAPI/audit.mjs";
|
|
3
4
|
import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
|
|
4
5
|
import { getEditorAPI } from "./getIntlayerAPI/editor.mjs";
|
|
5
6
|
import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
|
|
@@ -13,4 +14,4 @@ import { getIntlayerAPIProxy } from "./proxy.mjs";
|
|
|
13
14
|
import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.mjs";
|
|
14
15
|
import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
|
|
15
16
|
|
|
16
|
-
export { fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getDictionaryAPI, getEditorAPI, getIntlayerAPI, getIntlayerAPIProxy, getOAuthAPI, getOrganizationAPI, getProjectAPI, getStripeAPI, getTagAPI, getUserAPI };
|
|
17
|
+
export { fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAuditAPI, getDictionaryAPI, getEditorAPI, getIntlayerAPI, getIntlayerAPIProxy, getOAuthAPI, getOrganizationAPI, getProjectAPI, getStripeAPI, getTagAPI, getUserAPI };
|
package/dist/esm/proxy.mjs
CHANGED
|
@@ -90,7 +90,8 @@ const getIntlayerAPIProxy = (_baseAuthOptions = {}, intlayerConfig) => {
|
|
|
90
90
|
tag: wrapSection(baseApi.tag),
|
|
91
91
|
search: wrapSection(baseApi.search),
|
|
92
92
|
editor: wrapSection(baseApi.editor),
|
|
93
|
-
newsletter: wrapSection(baseApi.newsletter)
|
|
93
|
+
newsletter: wrapSection(baseApi.newsletter),
|
|
94
|
+
audit: wrapSection(baseApi.audit)
|
|
94
95
|
};
|
|
95
96
|
};
|
|
96
97
|
|
package/dist/esm/proxy.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.mjs","names":["currentAccessToken: string | undefined","currentExpiryTs: number | undefined","pendingRefresh: Promise<void> | undefined","authOptionsRef: FetcherOptions"],"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 } 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,MAA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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;
|
|
1
|
+
{"version":3,"file":"proxy.mjs","names":["currentAccessToken: string | undefined","currentExpiryTs: number | undefined","pendingRefresh: Promise<void> | undefined","authOptionsRef: FetcherOptions"],"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,i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,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,5 +1,6 @@
|
|
|
1
1
|
import { FetcherOptions } from "../fetcher.js";
|
|
2
2
|
import { getAiAPI } from "./ai.js";
|
|
3
|
+
import { getAuditAPI } from "./audit.js";
|
|
3
4
|
import { getDictionaryAPI } from "./dictionary.js";
|
|
4
5
|
import { getEditorAPI } from "./editor.js";
|
|
5
6
|
import { getNewsletterAPI } from "./newsletter.js";
|
|
@@ -25,6 +26,7 @@ interface IntlayerAPIReturn {
|
|
|
25
26
|
search: ReturnType<typeof getSearchAPI>;
|
|
26
27
|
editor: ReturnType<typeof getEditorAPI>;
|
|
27
28
|
newsletter: ReturnType<typeof getNewsletterAPI>;
|
|
29
|
+
audit: ReturnType<typeof getAuditAPI>;
|
|
28
30
|
}
|
|
29
31
|
declare const getIntlayerAPI: (authAPIOptions?: FetcherOptions, intlayerConfig?: IntlayerConfig) => IntlayerAPIReturn;
|
|
30
32
|
type IntlayerAPI = ReturnType<typeof getIntlayerAPI>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/getIntlayerAPI/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;UAeU,iBAAA;gBACM,kBAAkB;EADxB,OAAA,EAEC,UAFD,CAAiB,OAEE,aAFF,CAAA;EACO,IAAA,EAE1B,UAF0B,CAAA,OAER,UAFQ,CAAA;EAAlB,KAAA,EAGP,UAHO,CAAA,OAGW,WAHX,CAAA;EACa,UAAA,EAGf,UAHe,CAAA,OAGG,gBAHH,CAAA;EAAlB,MAAA,EAID,UAJC,CAAA,OAIiB,YAJjB,CAAA;EACe,EAAA,EAIpB,UAJoB,CAAA,OAIF,QAJE,CAAA;EAAlB,GAAA,EAKD,UALC,CAAA,OAKiB,SALjB,CAAA;EACmB,MAAA,EAKjB,UALiB,CAAA,OAKC,YALD,CAAA;EAAlB,MAAA,EAMC,UAND,CAAA,OAMmB,YANnB,CAAA;EACuB,UAAA,EAMlB,UANkB,CAAA,OAMA,gBANA,CAAA;EAAlB,KAAA,EAOL,UAPK,CAAA,OAOa,WAPb,CAAA;;AACJ,cASG,cATH,EAAA,CAAA,cAAA,CAAA,EAUQ,cAVR,EAAA,cAAA,CAAA,EAWS,cAXT,EAAA,GAYP,iBAZO;AACc,KA0BZ,WAAA,GAAc,UA1BF,CAAA,OA0BoB,cA1BpB,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { AIOptions, AIProvider, AddDictionaryBody, AddDictionaryResult, AddNewAccessKeyBody, AddNewAccessKeyResponse, AddOrganizationBody, AddOrganizationMemberBody, AddOrganizationMemberResult, AddOrganizationResult, AddProjectBody, AddProjectResult, AddTagBody, AddTagResult, AskDocQuestionResult, AskResetPasswordBody, AskResetPasswordResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationFieldResult, AuditContentDeclarationMetadataBody, AuditContentDeclarationMetadataResult, AuditContentDeclarationResult, AuditTagBody, AuditTagResult, AuthClient, AutocompleteBody, AutocompleteResponse, ChatCompletionRequestMessage, CheckIfUserHasPasswordResult, CreateSessionBody, CreateSessionResult, CreateUserBody, CreateUserResult, CustomQueryBody, CustomQueryResult, DefinePasswordBody, DefinePasswordResult, DeleteAccessKeyBody, DeleteAccessKeyResponse, DeleteDictionaryParam, DeleteDictionaryResult, DeleteOrganizationResult, DeleteProjectResult, DeleteTagParams, DeleteTagResult, DictionaryAPI, GetCheckoutSessionBody, GetCheckoutSessionResult, GetConfigurationResult, GetDictionariesKeysResult, GetDictionariesParams, GetDictionariesResult, GetDictionariesUpdateTimestampResult, GetDictionaryParams, GetDictionaryQuery, GetDictionaryResult, GetDiscussionsParams, GetDiscussionsResult, GetEditorDictionariesResult, GetOAuth2TokenBody, GetOAuth2TokenResult, GetOrganizationParam, GetOrganizationResult, GetOrganizationsParams, GetOrganizationsResult, GetPricingBody, GetPricingResult, GetProjectsParams, GetProjectsResult, GetSessionInformationQuery, GetSessionInformationResult, GetTagsParams, GetTagsResult, GetUserByAccountParams, GetUserByAccountResult, GetUserByEmailParams, GetUserByEmailResult, GetUserByIdParams, GetUserByIdResult, GetUsersParams, GetUsersResult, GithubLoginQueryParams, GoogleLoginQueryParams, LoginBody, LoginResult, Messages, NewsletterSubscriptionBody, NewsletterSubscriptionResult, NewsletterUnsubscriptionBody, PushDictionariesBody, PushDictionariesResult, PushProjectConfigurationBody, PushProjectConfigurationResult, RefreshAccessKeyBody, RefreshAccessKeyResponse, RegisterBody, RegisterQuery, RegisterResult, SearchDocUtilParams, SearchDocUtilResult, SelectOrganizationParam, SelectOrganizationResult, SelectProjectParam, SelectProjectResult, SetCSRFTokenResult, TranslateJSONBody, TranslateJSONResult, UnselectOrganizationResult, UnselectProjectResult, UpdateDictionaryBody, UpdateDictionaryParam, UpdateDictionaryResult, UpdateOrganizationBody, UpdateOrganizationMembersBody, UpdateOrganizationMembersResult, UpdateOrganizationResult, UpdatePasswordBody, UpdatePasswordResult, UpdateProjectBody, UpdateProjectMembersBody, UpdateProjectMembersResult, UpdateProjectResult, UpdateTagBody, UpdateTagParams, UpdateTagResult, UpdateUserBody, UpdateUserResult, UserAPI, ValidEmailParams, ValidEmailResult, WriteContentDeclarationBody, WriteContentDeclarationResult } from "./types.js";
|
|
1
|
+
import { AIOptions, AIProvider, AddDictionaryBody, AddDictionaryResult, AddNewAccessKeyBody, AddNewAccessKeyResponse, AddOrganizationBody, AddOrganizationMemberBody, AddOrganizationMemberResult, AddOrganizationResult, AddProjectBody, AddProjectResult, AddTagBody, AddTagResult, AskDocQuestionResult, AskResetPasswordBody, AskResetPasswordResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationFieldResult, AuditContentDeclarationMetadataBody, AuditContentDeclarationMetadataResult, AuditContentDeclarationResult, AuditTagBody, AuditTagResult, AuthClient, AutocompleteBody, AutocompleteResponse, ChatCompletionRequestMessage, CheckIfUserHasPasswordResult, CreateAuditBody, CreateAuditResult, CreateSessionBody, CreateSessionResult, CreateUserBody, CreateUserResult, CustomQueryBody, CustomQueryResult, DefinePasswordBody, DefinePasswordResult, DeleteAccessKeyBody, DeleteAccessKeyResponse, DeleteDictionaryParam, DeleteDictionaryResult, DeleteOrganizationResult, DeleteProjectResult, DeleteTagParams, DeleteTagResult, DictionaryAPI, GetAuditByIdParams, GetAuditByIdResult, GetAuditsParams, GetAuditsResult, GetCheckoutSessionBody, GetCheckoutSessionResult, GetConfigurationResult, GetDictionariesKeysResult, GetDictionariesParams, GetDictionariesResult, GetDictionariesUpdateTimestampResult, GetDictionaryParams, GetDictionaryQuery, GetDictionaryResult, GetDiscussionsParams, GetDiscussionsResult, GetEditorDictionariesResult, GetOAuth2TokenBody, GetOAuth2TokenResult, GetOrganizationParam, GetOrganizationResult, GetOrganizationsParams, GetOrganizationsResult, GetPricingBody, GetPricingResult, GetProjectsParams, GetProjectsResult, GetSessionInformationQuery, GetSessionInformationResult, GetTagsParams, GetTagsResult, GetUserByAccountParams, GetUserByAccountResult, GetUserByEmailParams, GetUserByEmailResult, GetUserByIdParams, GetUserByIdResult, GetUsersParams, GetUsersResult, GithubLoginQueryParams, GoogleLoginQueryParams, LoginBody, LoginResult, Messages, NewsletterSubscriptionBody, NewsletterSubscriptionResult, NewsletterUnsubscriptionBody, PushDictionariesBody, PushDictionariesResult, PushProjectConfigurationBody, PushProjectConfigurationResult, RefreshAccessKeyBody, RefreshAccessKeyResponse, RegisterBody, RegisterQuery, RegisterResult, SearchDocUtilParams, SearchDocUtilResult, SelectOrganizationParam, SelectOrganizationResult, SelectProjectParam, SelectProjectResult, SetCSRFTokenResult, TranslateJSONBody, TranslateJSONResult, UnselectOrganizationResult, UnselectProjectResult, UpdateDictionaryBody, UpdateDictionaryParam, UpdateDictionaryResult, UpdateOrganizationBody, UpdateOrganizationMembersBody, UpdateOrganizationMembersResult, UpdateOrganizationResult, UpdatePasswordBody, UpdatePasswordResult, UpdateProjectBody, UpdateProjectMembersBody, UpdateProjectMembersResult, UpdateProjectResult, UpdateTagBody, UpdateTagParams, UpdateTagResult, UpdateUserBody, UpdateUserResult, UserAPI, ValidEmailParams, ValidEmailResult, WriteContentDeclarationBody, WriteContentDeclarationResult } from "./types.js";
|
|
2
2
|
import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.js";
|
|
3
3
|
import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.js";
|
|
4
|
+
import "./distantDictionary/index.js";
|
|
4
5
|
import { FetcherOptions, fetcher, fetcherOptions } from "./fetcher.js";
|
|
5
6
|
import { AskDocQuestionBody, getAiAPI } from "./getIntlayerAPI/ai.js";
|
|
7
|
+
import { getAuditAPI } from "./getIntlayerAPI/audit.js";
|
|
6
8
|
import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.js";
|
|
7
9
|
import { getEditorAPI } from "./getIntlayerAPI/editor.js";
|
|
8
10
|
import { getOAuthAPI } from "./getIntlayerAPI/oAuth.js";
|
|
@@ -13,4 +15,4 @@ import { getTagAPI } from "./getIntlayerAPI/tag.js";
|
|
|
13
15
|
import { getUserAPI } from "./getIntlayerAPI/user.js";
|
|
14
16
|
import { IntlayerAPI, getIntlayerAPI } from "./getIntlayerAPI/index.js";
|
|
15
17
|
import { IntlayerAPIProxy, getIntlayerAPIProxy } from "./proxy.js";
|
|
16
|
-
export { AIOptions, AIProvider, AddDictionaryBody, AddDictionaryResult, AddNewAccessKeyBody, AddNewAccessKeyResponse, AddOrganizationBody, AddOrganizationMemberBody, AddOrganizationMemberResult, AddOrganizationResult, AddProjectBody, AddProjectResult, AddTagBody, AddTagResult, AskDocQuestionBody, AskDocQuestionResult, AskResetPasswordBody, AskResetPasswordResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationFieldResult, AuditContentDeclarationMetadataBody, AuditContentDeclarationMetadataResult, AuditContentDeclarationResult, AuditTagBody, AuditTagResult, AuthClient, AutocompleteBody, AutocompleteResponse, ChatCompletionRequestMessage, CheckIfUserHasPasswordResult, CreateSessionBody, CreateSessionResult, CreateUserBody, CreateUserResult, CustomQueryBody, CustomQueryResult, DefinePasswordBody, DefinePasswordResult, DeleteAccessKeyBody, DeleteAccessKeyResponse, DeleteDictionaryParam, DeleteDictionaryResult, DeleteOrganizationResult, DeleteProjectResult, DeleteTagParams, DeleteTagResult, DictionaryAPI, FetcherOptions, GetCheckoutSessionBody, GetCheckoutSessionResult, GetConfigurationResult, GetDictionariesKeysResult, GetDictionariesParams, GetDictionariesResult, GetDictionariesUpdateTimestampResult, GetDictionaryParams, GetDictionaryQuery, GetDictionaryResult, GetDiscussionsParams, GetDiscussionsResult, GetEditorDictionariesResult, GetOAuth2TokenBody, GetOAuth2TokenResult, GetOrganizationParam, GetOrganizationResult, GetOrganizationsParams, GetOrganizationsResult, GetPricingBody, GetPricingResult, GetProjectsParams, GetProjectsResult, GetSessionInformationQuery, GetSessionInformationResult, GetTagsParams, GetTagsResult, GetUserByAccountParams, GetUserByAccountResult, GetUserByEmailParams, GetUserByEmailResult, GetUserByIdParams, GetUserByIdResult, GetUsersParams, GetUsersResult, GithubLoginQueryParams, GoogleLoginQueryParams, IntlayerAPI, IntlayerAPIProxy, LoginBody, LoginResult, Messages, NewsletterSubscriptionBody, NewsletterSubscriptionResult, NewsletterUnsubscriptionBody, PushDictionariesBody, PushDictionariesResult, PushProjectConfigurationBody, PushProjectConfigurationResult, RefreshAccessKeyBody, RefreshAccessKeyResponse, RegisterBody, RegisterQuery, RegisterResult, SearchDocUtilParams, SearchDocUtilResult, SelectOrganizationParam, SelectOrganizationResult, SelectProjectParam, SelectProjectResult, SetCSRFTokenResult, TranslateJSONBody, TranslateJSONResult, UnselectOrganizationResult, UnselectProjectResult, UpdateDictionaryBody, UpdateDictionaryParam, UpdateDictionaryResult, UpdateOrganizationBody, UpdateOrganizationMembersBody, UpdateOrganizationMembersResult, UpdateOrganizationResult, UpdatePasswordBody, UpdatePasswordResult, UpdateProjectBody, UpdateProjectMembersBody, UpdateProjectMembersResult, UpdateProjectResult, UpdateTagBody, UpdateTagParams, UpdateTagResult, UpdateUserBody, UpdateUserResult, UserAPI, ValidEmailParams, ValidEmailResult, WriteContentDeclarationBody, WriteContentDeclarationResult, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getDictionaryAPI, getEditorAPI, getIntlayerAPI, getIntlayerAPIProxy, getOAuthAPI, getOrganizationAPI, getProjectAPI, getStripeAPI, getTagAPI, getUserAPI };
|
|
18
|
+
export { AIOptions, AIProvider, AddDictionaryBody, AddDictionaryResult, AddNewAccessKeyBody, AddNewAccessKeyResponse, AddOrganizationBody, AddOrganizationMemberBody, AddOrganizationMemberResult, AddOrganizationResult, AddProjectBody, AddProjectResult, AddTagBody, AddTagResult, AskDocQuestionBody, AskDocQuestionResult, AskResetPasswordBody, AskResetPasswordResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationFieldResult, AuditContentDeclarationMetadataBody, AuditContentDeclarationMetadataResult, AuditContentDeclarationResult, AuditTagBody, AuditTagResult, AuthClient, AutocompleteBody, AutocompleteResponse, ChatCompletionRequestMessage, CheckIfUserHasPasswordResult, CreateAuditBody, CreateAuditResult, CreateSessionBody, CreateSessionResult, CreateUserBody, CreateUserResult, CustomQueryBody, CustomQueryResult, DefinePasswordBody, DefinePasswordResult, DeleteAccessKeyBody, DeleteAccessKeyResponse, DeleteDictionaryParam, DeleteDictionaryResult, DeleteOrganizationResult, DeleteProjectResult, DeleteTagParams, DeleteTagResult, DictionaryAPI, FetcherOptions, GetAuditByIdParams, GetAuditByIdResult, GetAuditsParams, GetAuditsResult, GetCheckoutSessionBody, GetCheckoutSessionResult, GetConfigurationResult, GetDictionariesKeysResult, GetDictionariesParams, GetDictionariesResult, GetDictionariesUpdateTimestampResult, GetDictionaryParams, GetDictionaryQuery, GetDictionaryResult, GetDiscussionsParams, GetDiscussionsResult, GetEditorDictionariesResult, GetOAuth2TokenBody, GetOAuth2TokenResult, GetOrganizationParam, GetOrganizationResult, GetOrganizationsParams, GetOrganizationsResult, GetPricingBody, GetPricingResult, GetProjectsParams, GetProjectsResult, GetSessionInformationQuery, GetSessionInformationResult, GetTagsParams, GetTagsResult, GetUserByAccountParams, GetUserByAccountResult, GetUserByEmailParams, GetUserByEmailResult, GetUserByIdParams, GetUserByIdResult, GetUsersParams, GetUsersResult, GithubLoginQueryParams, GoogleLoginQueryParams, IntlayerAPI, IntlayerAPIProxy, LoginBody, LoginResult, Messages, NewsletterSubscriptionBody, NewsletterSubscriptionResult, NewsletterUnsubscriptionBody, PushDictionariesBody, PushDictionariesResult, PushProjectConfigurationBody, PushProjectConfigurationResult, RefreshAccessKeyBody, RefreshAccessKeyResponse, RegisterBody, RegisterQuery, RegisterResult, SearchDocUtilParams, SearchDocUtilResult, SelectOrganizationParam, SelectOrganizationResult, SelectProjectParam, SelectProjectResult, SetCSRFTokenResult, TranslateJSONBody, TranslateJSONResult, UnselectOrganizationResult, UnselectProjectResult, UpdateDictionaryBody, UpdateDictionaryParam, UpdateDictionaryResult, UpdateOrganizationBody, UpdateOrganizationMembersBody, UpdateOrganizationMembersResult, UpdateOrganizationResult, UpdatePasswordBody, UpdatePasswordResult, UpdateProjectBody, UpdateProjectMembersBody, UpdateProjectMembersResult, UpdateProjectResult, UpdateTagBody, UpdateTagParams, UpdateTagResult, UpdateUserBody, UpdateUserResult, UserAPI, ValidEmailParams, ValidEmailResult, WriteContentDeclarationBody, WriteContentDeclarationResult, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAuditAPI, getDictionaryAPI, getEditorAPI, getIntlayerAPI, getIntlayerAPIProxy, getOAuthAPI, getOrganizationAPI, getProjectAPI, getStripeAPI, getTagAPI, getUserAPI };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAqDA;;;;;
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAqDA;;;;;AAoGA;cApGa,yCACO,iCACD,mBAChB;KAiGS,gBAAA,GAAmB,kBAAkB"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AIOptions as AIOptions$1, AIProvider, AddDictionaryBody, AddDictionaryResult, AddNewAccessKeyBody, AddNewAccessKeyResponse, AddOrganizationBody, AddOrganizationMemberBody, AddOrganizationMemberResult, AddOrganizationResult, AddProjectBody, AddProjectResult, AddTagBody, AddTagResult, AskDocQuestionResult, AskResetPasswordBody, AskResetPasswordResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationFieldResult, AuditContentDeclarationMetadataBody, AuditContentDeclarationMetadataResult, AuditContentDeclarationResult, AuditTagBody, AuditTagResult, AuthClient, AutocompleteResponse, ChatCompletionRequestMessage, CheckIfUserHasPasswordResult, CreateSessionBody, CreateSessionResult, CreateUserBody, CreateUserResult, CustomQueryBody, CustomQueryResult, DefinePasswordBody, DefinePasswordResult, DeleteAccessKeyBody, DeleteAccessKeyResponse, DeleteDictionaryParam, DeleteDictionaryResult, DeleteOrganizationResult, DeleteProjectResult, DeleteTagParams, DeleteTagResult, DictionaryAPI, GetCheckoutSessionBody, GetCheckoutSessionResult, GetDictionariesKeysResult, GetDictionariesParams, GetDictionariesResult, GetDictionariesUpdateTimestampResult, GetDictionaryParams, GetDictionaryQuery, GetDictionaryResult, GetDiscussionsParams, GetDiscussionsResult, GetOAuth2TokenBody, GetOAuth2TokenResult, GetOrganizationParam, GetOrganizationResult, GetOrganizationsParams, GetOrganizationsResult, GetPricingBody, GetPricingResult, GetProjectsParams, GetProjectsResult, GetSessionInformationQuery, GetSessionInformationResult, GetTagsParams, GetTagsResult, GetUserByAccountParams, GetUserByAccountResult, GetUserByEmailParams, GetUserByEmailResult, GetUserByIdParams, GetUserByIdResult, GetUsersParams, GetUsersResult, GithubLoginQueryParams, GoogleLoginQueryParams, LoginBody, LoginResult, Messages, NewsletterSubscriptionBody, NewsletterSubscriptionResult, NewsletterUnsubscriptionBody, PushDictionariesBody, PushDictionariesResult, PushProjectConfigurationBody, PushProjectConfigurationResult, RefreshAccessKeyBody, RefreshAccessKeyResponse, RegisterBody, RegisterQuery, RegisterResult, SearchDocUtilParams, SearchDocUtilResult, SelectOrganizationParam, SelectOrganizationResult, SelectProjectParam, SelectProjectResult, SetCSRFTokenResult, TranslateJSONBody, TranslateJSONResult, UnselectOrganizationResult, UnselectProjectResult, UpdateDictionaryBody, UpdateDictionaryParam, UpdateDictionaryResult, UpdateOrganizationBody, UpdateOrganizationMembersBody, UpdateOrganizationMembersResult, UpdateOrganizationResult, UpdatePasswordBody, UpdatePasswordResult, UpdateProjectBody, UpdateProjectMembersBody, UpdateProjectMembersResult, UpdateProjectResult, UpdateTagBody, UpdateTagParams, UpdateTagResult, UpdateUserBody, UpdateUserResult, UserAPI, ValidEmailParams, ValidEmailResult } from "@intlayer/backend";
|
|
1
|
+
import { AIOptions as AIOptions$1, AIProvider, AddDictionaryBody, AddDictionaryResult, AddNewAccessKeyBody, AddNewAccessKeyResponse, AddOrganizationBody, AddOrganizationMemberBody, AddOrganizationMemberResult, AddOrganizationResult, AddProjectBody, AddProjectResult, AddTagBody, AddTagResult, AskDocQuestionResult, AskResetPasswordBody, AskResetPasswordResult, AuditContentDeclarationBody, AuditContentDeclarationFieldBody, AuditContentDeclarationFieldResult, AuditContentDeclarationMetadataBody, AuditContentDeclarationMetadataResult, AuditContentDeclarationResult, AuditTagBody, AuditTagResult, AuthClient, AutocompleteResponse, ChatCompletionRequestMessage, CheckIfUserHasPasswordResult, CreateAuditBody, CreateAuditResult, CreateSessionBody, CreateSessionResult, CreateUserBody, CreateUserResult, CustomQueryBody, CustomQueryResult, DefinePasswordBody, DefinePasswordResult, DeleteAccessKeyBody, DeleteAccessKeyResponse, DeleteDictionaryParam, DeleteDictionaryResult, DeleteOrganizationResult, DeleteProjectResult, DeleteTagParams, DeleteTagResult, DictionaryAPI, GetAuditByIdParams, GetAuditByIdResult, GetAuditsParams, GetAuditsResult, GetCheckoutSessionBody, GetCheckoutSessionResult, GetDictionariesKeysResult, GetDictionariesParams, GetDictionariesResult, GetDictionariesUpdateTimestampResult, GetDictionaryParams, GetDictionaryQuery, GetDictionaryResult, GetDiscussionsParams, GetDiscussionsResult, GetOAuth2TokenBody, GetOAuth2TokenResult, GetOrganizationParam, GetOrganizationResult, GetOrganizationsParams, GetOrganizationsResult, GetPricingBody, GetPricingResult, GetProjectsParams, GetProjectsResult, GetSessionInformationQuery, GetSessionInformationResult, GetTagsParams, GetTagsResult, GetUserByAccountParams, GetUserByAccountResult, GetUserByEmailParams, GetUserByEmailResult, GetUserByIdParams, GetUserByIdResult, GetUsersParams, GetUsersResult, GithubLoginQueryParams, GoogleLoginQueryParams, LoginBody, LoginResult, Messages, NewsletterSubscriptionBody, NewsletterSubscriptionResult, NewsletterUnsubscriptionBody, PushDictionariesBody, PushDictionariesResult, PushProjectConfigurationBody, PushProjectConfigurationResult, RefreshAccessKeyBody, RefreshAccessKeyResponse, RegisterBody, RegisterQuery, RegisterResult, SearchDocUtilParams, SearchDocUtilResult, SelectOrganizationParam, SelectOrganizationResult, SelectProjectParam, SelectProjectResult, SetCSRFTokenResult, TranslateJSONBody, TranslateJSONResult, UnselectOrganizationResult, UnselectProjectResult, UpdateDictionaryBody, UpdateDictionaryParam, UpdateDictionaryResult, UpdateOrganizationBody, UpdateOrganizationMembersBody, UpdateOrganizationMembersResult, UpdateOrganizationResult, UpdatePasswordBody, UpdatePasswordResult, UpdateProjectBody, UpdateProjectMembersBody, UpdateProjectMembersResult, UpdateProjectResult, UpdateTagBody, UpdateTagParams, UpdateTagResult, UpdateUserBody, UpdateUserResult, UserAPI, ValidEmailParams, ValidEmailResult } from "@intlayer/backend";
|
|
2
2
|
import { GetConfigurationResult, GetEditorDictionariesResult, WriteContentDeclarationBody, WriteContentDeclarationResult } from "intlayer-editor";
|
|
3
3
|
|
|
4
4
|
//#region src/types.d.ts
|
|
@@ -11,5 +11,5 @@ type AutocompleteBody = {
|
|
|
11
11
|
contextAfter?: string;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
14
|
-
export { type AIOptions$1 as AIOptions, type AIProvider, type AddDictionaryBody, type AddDictionaryResult, type AddNewAccessKeyBody, type AddNewAccessKeyResponse, type AddOrganizationBody, type AddOrganizationMemberBody, type AddOrganizationMemberResult, type AddOrganizationResult, type AddProjectBody, type AddProjectResult, type AddTagBody, type AddTagResult, type AskDocQuestionResult, type AskResetPasswordBody, type AskResetPasswordResult, type AuditContentDeclarationBody, type AuditContentDeclarationFieldBody, type AuditContentDeclarationFieldResult, type AuditContentDeclarationMetadataBody, type AuditContentDeclarationMetadataResult, type AuditContentDeclarationResult, type AuditTagBody, type AuditTagResult, type AuthClient, type AutocompleteBody, type AutocompleteResponse, type ChatCompletionRequestMessage, type CheckIfUserHasPasswordResult, type CreateSessionBody, type CreateSessionResult, type CreateUserBody, type CreateUserResult, type CustomQueryBody, type CustomQueryResult, type DefinePasswordBody, type DefinePasswordResult, type DeleteAccessKeyBody, type DeleteAccessKeyResponse, type DeleteDictionaryParam, type DeleteDictionaryResult, type DeleteOrganizationResult, type DeleteProjectResult, type DeleteTagParams, type DeleteTagResult, type DictionaryAPI, type GetCheckoutSessionBody, type GetCheckoutSessionResult, type GetConfigurationResult, type GetDictionariesKeysResult, type GetDictionariesParams, type GetDictionariesResult, type GetDictionariesUpdateTimestampResult, type GetDictionaryParams, type GetDictionaryQuery, type GetDictionaryResult, type GetDiscussionsParams, type GetDiscussionsResult, type GetEditorDictionariesResult, type GetOAuth2TokenBody, type GetOAuth2TokenResult, type GetOrganizationParam, type GetOrganizationResult, type GetOrganizationsParams, type GetOrganizationsResult, type GetPricingBody, type GetPricingResult, type GetProjectsParams, type GetProjectsResult, type GetSessionInformationQuery, type GetSessionInformationResult, type GetTagsParams, type GetTagsResult, type GetUserByAccountParams, type GetUserByAccountResult, type GetUserByEmailParams, type GetUserByEmailResult, type GetUserByIdParams, type GetUserByIdResult, type GetUsersParams, type GetUsersResult, type GithubLoginQueryParams, type GoogleLoginQueryParams, type LoginBody, type LoginResult, type Messages, type NewsletterSubscriptionBody, type NewsletterSubscriptionResult, type NewsletterUnsubscriptionBody, type PushDictionariesBody, type PushDictionariesResult, type PushProjectConfigurationBody, type PushProjectConfigurationResult, type RefreshAccessKeyBody, type RefreshAccessKeyResponse, type RegisterBody, type RegisterQuery, type RegisterResult, type SearchDocUtilParams, type SearchDocUtilResult, type SelectOrganizationParam, type SelectOrganizationResult, type SelectProjectParam, type SelectProjectResult, type SetCSRFTokenResult, type TranslateJSONBody, type TranslateJSONResult, type UnselectOrganizationResult, type UnselectProjectResult, type UpdateDictionaryBody, type UpdateDictionaryParam, type UpdateDictionaryResult, type UpdateOrganizationBody, type UpdateOrganizationMembersBody, type UpdateOrganizationMembersResult, type UpdateOrganizationResult, type UpdatePasswordBody, type UpdatePasswordResult, type UpdateProjectBody, type UpdateProjectMembersBody, type UpdateProjectMembersResult, type UpdateProjectResult, type UpdateTagBody, type UpdateTagParams, type UpdateTagResult, type UpdateUserBody, type UpdateUserResult, type UserAPI, type ValidEmailParams, type ValidEmailResult, type WriteContentDeclarationBody, type WriteContentDeclarationResult };
|
|
14
|
+
export { type AIOptions$1 as AIOptions, type AIProvider, type AddDictionaryBody, type AddDictionaryResult, type AddNewAccessKeyBody, type AddNewAccessKeyResponse, type AddOrganizationBody, type AddOrganizationMemberBody, type AddOrganizationMemberResult, type AddOrganizationResult, type AddProjectBody, type AddProjectResult, type AddTagBody, type AddTagResult, type AskDocQuestionResult, type AskResetPasswordBody, type AskResetPasswordResult, type AuditContentDeclarationBody, type AuditContentDeclarationFieldBody, type AuditContentDeclarationFieldResult, type AuditContentDeclarationMetadataBody, type AuditContentDeclarationMetadataResult, type AuditContentDeclarationResult, type AuditTagBody, type AuditTagResult, type AuthClient, type AutocompleteBody, type AutocompleteResponse, type ChatCompletionRequestMessage, type CheckIfUserHasPasswordResult, type CreateAuditBody, type CreateAuditResult, type CreateSessionBody, type CreateSessionResult, type CreateUserBody, type CreateUserResult, type CustomQueryBody, type CustomQueryResult, type DefinePasswordBody, type DefinePasswordResult, type DeleteAccessKeyBody, type DeleteAccessKeyResponse, type DeleteDictionaryParam, type DeleteDictionaryResult, type DeleteOrganizationResult, type DeleteProjectResult, type DeleteTagParams, type DeleteTagResult, type DictionaryAPI, type GetAuditByIdParams, type GetAuditByIdResult, type GetAuditsParams, type GetAuditsResult, type GetCheckoutSessionBody, type GetCheckoutSessionResult, type GetConfigurationResult, type GetDictionariesKeysResult, type GetDictionariesParams, type GetDictionariesResult, type GetDictionariesUpdateTimestampResult, type GetDictionaryParams, type GetDictionaryQuery, type GetDictionaryResult, type GetDiscussionsParams, type GetDiscussionsResult, type GetEditorDictionariesResult, type GetOAuth2TokenBody, type GetOAuth2TokenResult, type GetOrganizationParam, type GetOrganizationResult, type GetOrganizationsParams, type GetOrganizationsResult, type GetPricingBody, type GetPricingResult, type GetProjectsParams, type GetProjectsResult, type GetSessionInformationQuery, type GetSessionInformationResult, type GetTagsParams, type GetTagsResult, type GetUserByAccountParams, type GetUserByAccountResult, type GetUserByEmailParams, type GetUserByEmailResult, type GetUserByIdParams, type GetUserByIdResult, type GetUsersParams, type GetUsersResult, type GithubLoginQueryParams, type GoogleLoginQueryParams, type LoginBody, type LoginResult, type Messages, type NewsletterSubscriptionBody, type NewsletterSubscriptionResult, type NewsletterUnsubscriptionBody, type PushDictionariesBody, type PushDictionariesResult, type PushProjectConfigurationBody, type PushProjectConfigurationResult, type RefreshAccessKeyBody, type RefreshAccessKeyResponse, type RegisterBody, type RegisterQuery, type RegisterResult, type SearchDocUtilParams, type SearchDocUtilResult, type SelectOrganizationParam, type SelectOrganizationResult, type SelectProjectParam, type SelectProjectResult, type SetCSRFTokenResult, type TranslateJSONBody, type TranslateJSONResult, type UnselectOrganizationResult, type UnselectProjectResult, type UpdateDictionaryBody, type UpdateDictionaryParam, type UpdateDictionaryResult, type UpdateOrganizationBody, type UpdateOrganizationMembersBody, type UpdateOrganizationMembersResult, type UpdateOrganizationResult, type UpdatePasswordBody, type UpdatePasswordResult, type UpdateProjectBody, type UpdateProjectMembersBody, type UpdateProjectMembersResult, type UpdateProjectResult, type UpdateTagBody, type UpdateTagParams, type UpdateTagResult, type UpdateUserBody, type UpdateUserResult, type UserAPI, type ValidEmailParams, type ValidEmailResult, type WriteContentDeclarationBody, type WriteContentDeclarationResult };
|
|
15
15
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";;;;;KAuJY,gBAAA;;cAEE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/api",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.8-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "SDK for interacting with the Intlayer API, enabling content auditing, and managing organizations, projects, and users.",
|
|
6
6
|
"keywords": [
|
|
@@ -69,23 +69,23 @@
|
|
|
69
69
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@intlayer/config": "7.0.
|
|
72
|
+
"@intlayer/config": "7.0.8-canary.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@types/node": "24.
|
|
76
|
-
"@utils/ts-config": "7.0.
|
|
77
|
-
"@utils/ts-config-types": "7.0.
|
|
78
|
-
"@utils/tsdown-config": "7.0.
|
|
79
|
-
"rimraf": "6.0
|
|
80
|
-
"tsdown": "0.
|
|
75
|
+
"@types/node": "24.10.0",
|
|
76
|
+
"@utils/ts-config": "7.0.8-canary.0",
|
|
77
|
+
"@utils/ts-config-types": "7.0.8-canary.0",
|
|
78
|
+
"@utils/tsdown-config": "7.0.8-canary.0",
|
|
79
|
+
"rimraf": "6.1.0",
|
|
80
|
+
"tsdown": "0.16.0",
|
|
81
81
|
"typescript": "5.9.3",
|
|
82
|
-
"vitest": "4.0.
|
|
82
|
+
"vitest": "4.0.7"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
-
"@intlayer/backend": "7.0.
|
|
86
|
-
"@intlayer/config": "7.0.
|
|
87
|
-
"@intlayer/types": "7.0.
|
|
88
|
-
"intlayer-editor": "7.0.
|
|
85
|
+
"@intlayer/backend": "7.0.8-canary.0",
|
|
86
|
+
"@intlayer/config": "7.0.8-canary.0",
|
|
87
|
+
"@intlayer/types": "7.0.8-canary.0",
|
|
88
|
+
"intlayer-editor": "7.0.8-canary.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependenciesMeta": {
|
|
91
91
|
"@intlayer/backend": {
|