UNPKG

@intlayer/chokidar

Version:

Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.

49 lines 2.21 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var fetchDistantDictionaryKeys_exports = {}; __export(fetchDistantDictionaryKeys_exports, { fetchDistantDictionaryKeys: () => fetchDistantDictionaryKeys }); module.exports = __toCommonJS(fetchDistantDictionaryKeys_exports); var import_api = require("@intlayer/api"); var import_config = require("@intlayer/config"); const fetchDistantDictionaryKeys = async (configuration = (0, import_config.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 = (0, import_api.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; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { fetchDistantDictionaryKeys }); //# sourceMappingURL=fetchDistantDictionaryKeys.cjs.map