@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
25 lines • 1.08 kB
JavaScript
import { getIntlayerAPI } from "@intlayer/api";
import { getConfiguration } from "@intlayer/config";
const fetchDistantDictionaryKeys = async (configuration = getConfiguration()) => {
const { clientId, clientSecret } = configuration.editor;
if (!clientId || !clientSecret) {
throw new Error(
"Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
);
}
const intlayerAPI = getIntlayerAPI(void 0, configuration);
const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
const getDictionariesKeysResult = await intlayerAPI.dictionary.getDictionariesKeys({
headers: { Authorization: `Bearer ${oAuth2AccessToken}` }
});
if (!getDictionariesKeysResult.data) {
throw new Error("No distant dictionaries found");
}
const distantDictionariesKeys = getDictionariesKeysResult.data;
return distantDictionariesKeys;
};
export {
fetchDistantDictionaryKeys
};
//# sourceMappingURL=fetchDistantDictionaryKeys.mjs.map