lingo.dev 0.92.15 → 0.92.17

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/build/cli.cjs CHANGED
@@ -26,36 +26,65 @@ function getSettings(explicitApiKey) {
26
26
  _envVarsInfo();
27
27
  return {
28
28
  auth: {
29
- apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _31 => _31.auth, 'optionalAccess', _32 => _32.apiKey]) || defaults.auth.apiKey,
30
- apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _33 => _33.auth, 'optionalAccess', _34 => _34.apiUrl]) || defaults.auth.apiUrl,
31
- webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _35 => _35.auth, 'optionalAccess', _36 => _36.webUrl]) || defaults.auth.webUrl
29
+ apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _34 => _34.auth, 'optionalAccess', _35 => _35.apiKey]) || defaults.auth.apiKey,
30
+ apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _36 => _36.auth, 'optionalAccess', _37 => _37.apiUrl]) || defaults.auth.apiUrl,
31
+ webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _38 => _38.auth, 'optionalAccess', _39 => _39.webUrl]) || defaults.auth.webUrl
32
+ },
33
+ llm: {
34
+ openaiApiKey: env.OPENAI_API_KEY || _optionalChain([systemFile, 'access', _40 => _40.llm, 'optionalAccess', _41 => _41.openaiApiKey]),
35
+ anthropicApiKey: env.ANTHROPIC_API_KEY || _optionalChain([systemFile, 'access', _42 => _42.llm, 'optionalAccess', _43 => _43.anthropicApiKey]),
36
+ groqApiKey: env.GROQ_API_KEY || _optionalChain([systemFile, 'access', _44 => _44.llm, 'optionalAccess', _45 => _45.groqApiKey])
32
37
  }
33
38
  };
34
39
  }
35
40
  function saveSettings(settings) {
36
41
  _saveSystemFile(settings);
37
42
  }
43
+ function loadSystemSettings() {
44
+ return _loadSystemFile();
45
+ }
46
+ var flattenZodObject = (schema, prefix = "") => {
47
+ return Object.entries(schema.shape).flatMap(([key, value]) => {
48
+ const newPrefix = prefix ? `${prefix}.${key}` : key;
49
+ if (value instanceof _zod2.default.ZodObject) {
50
+ return flattenZodObject(value, newPrefix);
51
+ }
52
+ return [newPrefix];
53
+ });
54
+ };
38
55
  var SettingsSchema = _zod2.default.object({
39
56
  auth: _zod2.default.object({
40
57
  apiKey: _zod2.default.string(),
41
58
  apiUrl: _zod2.default.string(),
42
59
  webUrl: _zod2.default.string()
60
+ }),
61
+ llm: _zod2.default.object({
62
+ openaiApiKey: _zod2.default.string().optional(),
63
+ anthropicApiKey: _zod2.default.string().optional(),
64
+ groqApiKey: _zod2.default.string().optional()
43
65
  })
44
66
  });
67
+ var SETTINGS_KEYS = flattenZodObject(
68
+ SettingsSchema
69
+ );
45
70
  function _loadDefaults() {
46
71
  return {
47
72
  auth: {
48
73
  apiKey: "",
49
74
  apiUrl: "https://engine.lingo.dev",
50
75
  webUrl: "https://lingo.dev"
51
- }
76
+ },
77
+ llm: {}
52
78
  };
53
79
  }
54
80
  function _loadEnv() {
55
81
  return _zod2.default.object({
56
82
  LINGODOTDEV_API_KEY: _zod2.default.string().optional(),
57
83
  LINGODOTDEV_API_URL: _zod2.default.string().optional(),
58
- LINGODOTDEV_WEB_URL: _zod2.default.string().optional()
84
+ LINGODOTDEV_WEB_URL: _zod2.default.string().optional(),
85
+ OPENAI_API_KEY: _zod2.default.string().optional(),
86
+ ANTHROPIC_API_KEY: _zod2.default.string().optional(),
87
+ GROQ_API_KEY: _zod2.default.string().optional()
59
88
  }).passthrough().parse(process.env);
60
89
  }
61
90
  function _loadSystemFile() {
@@ -67,6 +96,11 @@ function _loadSystemFile() {
67
96
  apiKey: _zod2.default.string().optional(),
68
97
  apiUrl: _zod2.default.string().optional(),
69
98
  webUrl: _zod2.default.string().optional()
99
+ }).optional(),
100
+ llm: _zod2.default.object({
101
+ openaiApiKey: _zod2.default.string().optional(),
102
+ anthropicApiKey: _zod2.default.string().optional(),
103
+ groqApiKey: _zod2.default.string().optional()
70
104
  }).optional()
71
105
  }).passthrough().parse(data);
72
106
  }
@@ -99,17 +133,41 @@ Please use LINGODOTDEV_API_KEY instead.
99
133
  function _envVarsInfo() {
100
134
  const env = _loadEnv();
101
135
  const systemFile = _loadSystemFile();
102
- if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _37 => _37.auth, 'optionalAccess', _38 => _38.apiKey])) {
136
+ if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _46 => _46.auth, 'optionalAccess', _47 => _47.apiKey])) {
137
+ console.info(
138
+ "\x1B[36m%s\x1B[0m",
139
+ `\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from user config`
140
+ );
141
+ }
142
+ if (env.OPENAI_API_KEY && _optionalChain([systemFile, 'access', _48 => _48.llm, 'optionalAccess', _49 => _49.openaiApiKey])) {
103
143
  console.info(
104
144
  "\x1B[36m%s\x1B[0m",
105
- `\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from login flow (saved in .lingodotdevrc)`
145
+ `\u2139\uFE0F Using OPENAI_API_KEY env var instead of key from user config.`
146
+ );
147
+ }
148
+ if (env.ANTHROPIC_API_KEY && _optionalChain([systemFile, 'access', _50 => _50.llm, 'optionalAccess', _51 => _51.anthropicApiKey])) {
149
+ console.info(
150
+ "\x1B[36m%s\x1B[0m",
151
+ `\u2139\uFE0F Using ANTHROPIC_API_KEY env var instead of key from user config`
152
+ );
153
+ }
154
+ if (env.GROQ_API_KEY && _optionalChain([systemFile, 'access', _52 => _52.llm, 'optionalAccess', _53 => _53.groqApiKey])) {
155
+ console.info(
156
+ "\x1B[36m%s\x1B[0m",
157
+ `\u2139\uFE0F Using GROQ_API_KEY env var instead of key from user config`
106
158
  );
107
159
  }
108
160
  if (env.LINGODOTDEV_API_URL) {
109
- console.info("\x1B[36m%s\x1B[0m", `\u2139\uFE0F Using LINGODOTDEV_API_URL: ${env.LINGODOTDEV_API_URL}`);
161
+ console.info(
162
+ "\x1B[36m%s\x1B[0m",
163
+ `\u2139\uFE0F Using LINGODOTDEV_API_URL: ${env.LINGODOTDEV_API_URL}`
164
+ );
110
165
  }
111
166
  if (env.LINGODOTDEV_WEB_URL) {
112
- console.info("\x1B[36m%s\x1B[0m", `\u2139\uFE0F Using LINGODOTDEV_WEB_URL: ${env.LINGODOTDEV_WEB_URL}`);
167
+ console.info(
168
+ "\x1B[36m%s\x1B[0m",
169
+ `\u2139\uFE0F Using LINGODOTDEV_WEB_URL: ${env.LINGODOTDEV_WEB_URL}`
170
+ );
113
171
  }
114
172
  }
115
173
 
@@ -154,7 +212,7 @@ function createAuthenticator(params) {
154
212
  });
155
213
  if (res.ok) {
156
214
  const payload = await res.json();
157
- if (!_optionalChain([payload, 'optionalAccess', _39 => _39.email])) {
215
+ if (!_optionalChain([payload, 'optionalAccess', _54 => _54.email])) {
158
216
  return null;
159
217
  }
160
218
  return {
@@ -774,7 +832,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
774
832
  });
775
833
  const auth2 = await newAuthenticator.whoami();
776
834
  if (auth2) {
777
- _ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _40 => _40.email])}`);
835
+ _ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _55 => _55.email])}`);
778
836
  } else {
779
837
  _ora2.default.call(void 0, ).fail("Authentication failed.");
780
838
  }
@@ -859,7 +917,7 @@ function getBuckets(i18nConfig) {
859
917
  const includeItems = bucketEntry.include.map(
860
918
  (item) => resolveBucketItem(item)
861
919
  );
862
- const excludeItems = _optionalChain([bucketEntry, 'access', _41 => _41.exclude, 'optionalAccess', _42 => _42.map, 'call', _43 => _43(
920
+ const excludeItems = _optionalChain([bucketEntry, 'access', _56 => _56.exclude, 'optionalAccess', _57 => _57.map, 'call', _58 => _58(
863
921
  (item) => resolveBucketItem(item)
864
922
  )]);
865
923
  const config = {
@@ -897,7 +955,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
897
955
  delimiter: pattern.delimiter
898
956
  }))
899
957
  );
900
- const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _44 => _44.flatMap, 'call', _45 => _45(
958
+ const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _59 => _59.flatMap, 'call', _60 => _60(
901
959
  (pattern) => expandPlaceholderedGlob(
902
960
  pattern.path,
903
961
  __spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)
@@ -1017,6 +1075,123 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
1017
1075
  // src/cli/cmd/show/index.ts
1018
1076
  var show_default = new (0, _interactivecommander.Command)().command("show").description("Prints out the current configuration").helpOption("-h, --help", "Show help").addCommand(config_default).addCommand(locale_default).addCommand(files_default);
1019
1077
 
1078
+ // src/cli/cmd/config/index.ts
1079
+
1080
+
1081
+ // src/cli/cmd/config/set.ts
1082
+
1083
+ var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
1084
+ var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
1085
+
1086
+ var set_default = new (0, _interactivecommander.Command)().name("set").description("Set a configuration key to a value").addHelpText("afterAll", `
1087
+ Available keys:
1088
+ ${SETTINGS_KEYS.join("\n ")}`).argument("<key>", "Configuration key to set").argument("<value>", "New value").helpOption("-h, --help", "Show help").action(async (key, value) => {
1089
+ if (!SETTINGS_KEYS.includes(key)) {
1090
+ console.error(
1091
+ _dedent2.default`
1092
+ ${_chalk2.default.red("\u2716")} Unknown configuration key: ${_chalk2.default.bold(key)}
1093
+ Run ${_chalk2.default.dim("lingo.dev config set --help")} to see available keys.
1094
+ `
1095
+ );
1096
+ process.exitCode = 1;
1097
+ return;
1098
+ }
1099
+ const current = loadSystemSettings();
1100
+ const updated = _lodash2.default.cloneDeep(current);
1101
+ _lodash2.default.set(updated, key, value);
1102
+ try {
1103
+ saveSettings(updated);
1104
+ console.log(`${_chalk2.default.green("\u2714")} Set ${_chalk2.default.bold(key)}`);
1105
+ } catch (err) {
1106
+ console.error(
1107
+ _chalk2.default.red(
1108
+ `\u2716 Failed to save configuration: ${_chalk2.default.dim(
1109
+ err instanceof Error ? err.message : String(err)
1110
+ )}`
1111
+ )
1112
+ );
1113
+ process.exitCode = 1;
1114
+ }
1115
+ });
1116
+
1117
+ // src/cli/cmd/config/unset.ts
1118
+
1119
+
1120
+
1121
+
1122
+ var unset_default = new (0, _interactivecommander.Command)().name("unset").description("Remove a configuration key").addHelpText("afterAll", `
1123
+ Available keys:
1124
+ ${SETTINGS_KEYS.join("\n ")}`).argument("<key>", "Configuration key to remove").helpOption("-h, --help", "Show help").action(async (key) => {
1125
+ if (!SETTINGS_KEYS.includes(key)) {
1126
+ console.error(
1127
+ _dedent2.default`
1128
+ ${_chalk2.default.red("\u2716")} Unknown configuration key: ${_chalk2.default.bold(key)}
1129
+ Run ${_chalk2.default.dim("lingo.dev config unset --help")} to see available keys.
1130
+ `
1131
+ );
1132
+ process.exitCode = 1;
1133
+ return;
1134
+ }
1135
+ const settings = loadSystemSettings();
1136
+ const currentValue = _lodash2.default.get(settings, key);
1137
+ if (!_lodash2.default.trim(String(currentValue || ""))) {
1138
+ console.log(`${_chalk2.default.cyan("\u2139")} ${_chalk2.default.bold(key)} is not set.`);
1139
+ return;
1140
+ } else {
1141
+ const updated = _lodash2.default.cloneDeep(settings);
1142
+ _lodash2.default.unset(updated, key);
1143
+ try {
1144
+ saveSettings(updated);
1145
+ console.log(
1146
+ `${_chalk2.default.green("\u2714")} Removed configuration key ${_chalk2.default.bold(key)}`
1147
+ );
1148
+ } catch (err) {
1149
+ console.error(
1150
+ _chalk2.default.red(
1151
+ `\u2716 Failed to save configuration: ${_chalk2.default.dim(
1152
+ err instanceof Error ? err.message : String(err)
1153
+ )}`
1154
+ )
1155
+ );
1156
+ process.exitCode = 1;
1157
+ }
1158
+ }
1159
+ });
1160
+
1161
+ // src/cli/cmd/config/get.ts
1162
+
1163
+
1164
+
1165
+
1166
+ var get_default = new (0, _interactivecommander.Command)().name("get").description("Get the value of a configuration key").addHelpText("afterAll", `
1167
+ Available keys:
1168
+ ${SETTINGS_KEYS.join("\n ")}`).argument("<key>", "Configuration key").helpOption("-h, --help", "Show help").action(async (key) => {
1169
+ if (!SETTINGS_KEYS.includes(key)) {
1170
+ console.error(
1171
+ _dedent2.default`
1172
+ ${_chalk2.default.red("\u2716")} Unknown configuration key: ${_chalk2.default.bold(key)}
1173
+ Run ${_chalk2.default.dim("lingo.dev config get --help")} to see available keys.
1174
+ `
1175
+ );
1176
+ process.exitCode = 1;
1177
+ return;
1178
+ }
1179
+ const settings = loadSystemSettings();
1180
+ const value = _lodash2.default.get(settings, key);
1181
+ if (!value) {
1182
+ console.log(`${_chalk2.default.cyan("\u2139")} ${_chalk2.default.bold(key)} is not set.`);
1183
+ return;
1184
+ }
1185
+ if (typeof value === "object") {
1186
+ console.log(JSON.stringify(value, null, 2));
1187
+ } else {
1188
+ console.log(value);
1189
+ }
1190
+ });
1191
+
1192
+ // src/cli/cmd/config/index.ts
1193
+ var config_default2 = new (0, _interactivecommander.Command)().command("config").description("Manage Lingo.dev CLI configuration").helpOption("-h, --help", "Show help").addCommand(set_default).addCommand(unset_default).addCommand(get_default);
1194
+
1020
1195
  // src/cli/cmd/i18n.ts
1021
1196
 
1022
1197
 
@@ -1033,12 +1208,12 @@ function composeLoaders(...loaders) {
1033
1208
  return {
1034
1209
  init: async () => {
1035
1210
  for (const loader of loaders) {
1036
- await _optionalChain([loader, 'access', _46 => _46.init, 'optionalCall', _47 => _47()]);
1211
+ await _optionalChain([loader, 'access', _61 => _61.init, 'optionalCall', _62 => _62()]);
1037
1212
  }
1038
1213
  },
1039
1214
  setDefaultLocale(locale) {
1040
1215
  for (const loader of loaders) {
1041
- _optionalChain([loader, 'access', _48 => _48.setDefaultLocale, 'optionalCall', _49 => _49(locale)]);
1216
+ _optionalChain([loader, 'access', _63 => _63.setDefaultLocale, 'optionalCall', _64 => _64(locale)]);
1042
1217
  }
1043
1218
  return this;
1044
1219
  },
@@ -1071,7 +1246,7 @@ function createLoader(lDefinition) {
1071
1246
  if (state.initCtx) {
1072
1247
  return state.initCtx;
1073
1248
  }
1074
- state.initCtx = await _optionalChain([lDefinition, 'access', _50 => _50.init, 'optionalCall', _51 => _51()]);
1249
+ state.initCtx = await _optionalChain([lDefinition, 'access', _65 => _65.init, 'optionalCall', _66 => _66()]);
1075
1250
  return state.initCtx;
1076
1251
  },
1077
1252
  setDefaultLocale(locale) {
@@ -1096,7 +1271,8 @@ function createLoader(lDefinition) {
1096
1271
  locale,
1097
1272
  input2,
1098
1273
  state.initCtx,
1099
- state.defaultLocale
1274
+ state.defaultLocale,
1275
+ state.originalInput
1100
1276
  );
1101
1277
  state.pullOutput = result;
1102
1278
  return result;
@@ -1175,7 +1351,7 @@ function createNormalizeLoader() {
1175
1351
  return normalized;
1176
1352
  },
1177
1353
  push: async (locale, data, originalInput) => {
1178
- const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _52 => _52.keysMap]), () => ( {}));
1354
+ const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _67 => _67.keysMap]), () => ( {}));
1179
1355
  const input2 = mapDenormalizedKeys(data, keysMap);
1180
1356
  const denormalized = _flat.unflatten.call(void 0, input2, {
1181
1357
  delimiter: "/",
@@ -1249,7 +1425,7 @@ function createTextFileLoader(pathPattern) {
1249
1425
  const trimmedResult = result.trim();
1250
1426
  return trimmedResult;
1251
1427
  },
1252
- async push(locale, data, _30, originalLocale) {
1428
+ async push(locale, data, _33, originalLocale) {
1253
1429
  const draftPath = pathPattern.replaceAll("[locale]", locale);
1254
1430
  const finalPath = path12.default.resolve(draftPath);
1255
1431
  const dirPath = path12.default.dirname(finalPath);
@@ -1278,8 +1454,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
1278
1454
  if (!templateData) {
1279
1455
  templateData = await readFileForLocale(pathPattern, originalLocale);
1280
1456
  }
1281
- if (_optionalChain([templateData, 'optionalAccess', _53 => _53.match, 'call', _54 => _54(/[\r\n]$/)])) {
1282
- const ending = _optionalChain([templateData, 'optionalAccess', _55 => _55.includes, 'call', _56 => _56("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _57 => _57.includes, 'call', _58 => _58("\r")]) ? "\r" : "\n";
1457
+ if (_optionalChain([templateData, 'optionalAccess', _68 => _68.match, 'call', _69 => _69(/[\r\n]$/)])) {
1458
+ const ending = _optionalChain([templateData, 'optionalAccess', _70 => _70.includes, 'call', _71 => _71("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _72 => _72.includes, 'call', _73 => _73("\r")]) ? "\r" : "\n";
1283
1459
  return ending;
1284
1460
  }
1285
1461
  return "";
@@ -1621,7 +1797,7 @@ function createHtmlLoader() {
1621
1797
  break;
1622
1798
  }
1623
1799
  const siblings = Array.from(parent.childNodes).filter(
1624
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _59 => _59.textContent, 'optionalAccess', _60 => _60.trim, 'call', _61 => _61()])
1800
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _74 => _74.textContent, 'optionalAccess', _75 => _75.trim, 'call', _76 => _76()])
1625
1801
  );
1626
1802
  const index = siblings.indexOf(current);
1627
1803
  if (index !== -1) {
@@ -1656,11 +1832,11 @@ function createHtmlLoader() {
1656
1832
  result[getPath(element, attr)] = value;
1657
1833
  }
1658
1834
  });
1659
- Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _62 => _62.textContent, 'optionalAccess', _63 => _63.trim, 'call', _64 => _64()])).forEach(processNode);
1835
+ Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _77 => _77.textContent, 'optionalAccess', _78 => _78.trim, 'call', _79 => _79()])).forEach(processNode);
1660
1836
  }
1661
1837
  };
1662
- Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _65 => _65.textContent, 'optionalAccess', _66 => _66.trim, 'call', _67 => _67()])).forEach(processNode);
1663
- Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _68 => _68.textContent, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70()])).forEach(processNode);
1838
+ Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _80 => _80.textContent, 'optionalAccess', _81 => _81.trim, 'call', _82 => _82()])).forEach(processNode);
1839
+ Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _83 => _83.textContent, 'optionalAccess', _84 => _84.trim, 'call', _85 => _85()])).forEach(processNode);
1664
1840
  return result;
1665
1841
  },
1666
1842
  async push(locale, data, originalInput) {
@@ -1682,7 +1858,7 @@ function createHtmlLoader() {
1682
1858
  for (let i = 0; i < indices.length; i++) {
1683
1859
  const index = parseInt(indices[i]);
1684
1860
  const siblings = Array.from(parent.childNodes).filter(
1685
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _71 => _71.textContent, 'optionalAccess', _72 => _72.trim, 'call', _73 => _73()])
1861
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _86 => _86.textContent, 'optionalAccess', _87 => _87.trim, 'call', _88 => _88()])
1686
1862
  );
1687
1863
  if (index >= siblings.length) {
1688
1864
  if (i === indices.length - 1) {
@@ -1733,7 +1909,7 @@ function createMarkdownLoader() {
1733
1909
  yaml: yamlEngine
1734
1910
  }
1735
1911
  });
1736
- const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _74 => _74.trim, 'call', _75 => _75()]), () => ( ""))).filter(Boolean);
1912
+ const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _89 => _89.trim, 'call', _90 => _90()]), () => ( ""))).filter(Boolean);
1737
1913
  return {
1738
1914
  ...Object.fromEntries(
1739
1915
  sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
@@ -1745,7 +1921,7 @@ function createMarkdownLoader() {
1745
1921
  const frontmatter = Object.fromEntries(
1746
1922
  Object.entries(data).filter(([key]) => key.startsWith(FM_ATTR_PREFIX)).map(([key, value]) => [key.replace(FM_ATTR_PREFIX, ""), value])
1747
1923
  );
1748
- let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _76 => _76.trim, 'call', _77 => _77()]), () => ( ""))).filter(Boolean).join("\n\n");
1924
+ let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _91 => _91.trim, 'call', _92 => _92()]), () => ( ""))).filter(Boolean).join("\n\n");
1749
1925
  if (Object.keys(frontmatter).length > 0) {
1750
1926
  content = `
1751
1927
  ${content}`;
@@ -1778,7 +1954,7 @@ function createPropertiesLoader() {
1778
1954
  return result;
1779
1955
  },
1780
1956
  async push(locale, payload) {
1781
- const result = Object.entries(payload).filter(([_30, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1957
+ const result = Object.entries(payload).filter(([_33, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
1782
1958
  return result;
1783
1959
  }
1784
1960
  });
@@ -1789,7 +1965,7 @@ function isSkippableLine(line) {
1789
1965
  function parsePropertyLine(line) {
1790
1966
  const [key, ...valueParts] = line.split("=");
1791
1967
  return {
1792
- key: _optionalChain([key, 'optionalAccess', _78 => _78.trim, 'call', _79 => _79()]) || "",
1968
+ key: _optionalChain([key, 'optionalAccess', _93 => _93.trim, 'call', _94 => _94()]) || "",
1793
1969
  value: valueParts.join("=").trim()
1794
1970
  };
1795
1971
  }
@@ -1875,7 +2051,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1875
2051
  if (rootTranslationEntity.shouldTranslate === false) {
1876
2052
  continue;
1877
2053
  }
1878
- const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _80 => _80.localizations, 'optionalAccess', _81 => _81[locale]]);
2054
+ const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _95 => _95.localizations, 'optionalAccess', _96 => _96[locale]]);
1879
2055
  if (langTranslationEntity) {
1880
2056
  if ("stringUnit" in langTranslationEntity) {
1881
2057
  resultData[translationKey] = langTranslationEntity.stringUnit.value;
@@ -1884,7 +2060,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1884
2060
  resultData[translationKey] = {};
1885
2061
  const pluralForms = langTranslationEntity.variations.plural;
1886
2062
  for (const form in pluralForms) {
1887
- if (_optionalChain([pluralForms, 'access', _82 => _82[form], 'optionalAccess', _83 => _83.stringUnit, 'optionalAccess', _84 => _84.value])) {
2063
+ if (_optionalChain([pluralForms, 'access', _97 => _97[form], 'optionalAccess', _98 => _98.stringUnit, 'optionalAccess', _99 => _99.value])) {
1888
2064
  resultData[translationKey][form] = pluralForms[form].stringUnit.value;
1889
2065
  }
1890
2066
  }
@@ -1907,7 +2083,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
1907
2083
  const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
1908
2084
  if (typeof value === "string") {
1909
2085
  langDataToMerge.strings[key] = {
1910
- extractionState: _optionalChain([originalInput, 'optionalAccess', _85 => _85.strings, 'optionalAccess', _86 => _86[key], 'optionalAccess', _87 => _87.extractionState]),
2086
+ extractionState: _optionalChain([originalInput, 'optionalAccess', _100 => _100.strings, 'optionalAccess', _101 => _101[key], 'optionalAccess', _102 => _102.extractionState]),
1911
2087
  localizations: {
1912
2088
  [locale]: {
1913
2089
  stringUnit: {
@@ -2045,10 +2221,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
2045
2221
  }
2046
2222
  }
2047
2223
  return false;
2048
- }).map(([key, _30]) => key);
2049
- const result = _lodash2.default.omitBy(input2, (_30, key) => passthroughKeys.includes(key));
2224
+ }).map(([key, _33]) => key);
2225
+ const result = _lodash2.default.omitBy(input2, (_33, key) => passthroughKeys.includes(key));
2050
2226
  if (returnUnlocalizedKeys) {
2051
- result.unlocalizable = _lodash2.default.omitBy(input2, (_30, key) => !passthroughKeys.includes(key));
2227
+ result.unlocalizable = _lodash2.default.omitBy(input2, (_33, key) => !passthroughKeys.includes(key));
2052
2228
  }
2053
2229
  return result;
2054
2230
  },
@@ -2087,7 +2263,7 @@ function createPoDataLoader(params) {
2087
2263
  Object.entries(entries).forEach(([msgid, entry]) => {
2088
2264
  if (msgid && entry.msgid) {
2089
2265
  const context = entry.msgctxt || "";
2090
- const fullEntry = _optionalChain([parsedPo, 'access', _88 => _88.translations, 'access', _89 => _89[context], 'optionalAccess', _90 => _90[msgid]]);
2266
+ const fullEntry = _optionalChain([parsedPo, 'access', _103 => _103.translations, 'access', _104 => _104[context], 'optionalAccess', _105 => _105[msgid]]);
2091
2267
  if (fullEntry) {
2092
2268
  result[msgid] = fullEntry;
2093
2269
  }
@@ -2097,8 +2273,8 @@ function createPoDataLoader(params) {
2097
2273
  return result;
2098
2274
  },
2099
2275
  async push(locale, data, originalInput, originalLocale, pullInput) {
2100
- const currentSections = _optionalChain([pullInput, 'optionalAccess', _91 => _91.split, 'call', _92 => _92("\n\n"), 'access', _93 => _93.filter, 'call', _94 => _94(Boolean)]) || [];
2101
- const originalSections = _optionalChain([originalInput, 'optionalAccess', _95 => _95.split, 'call', _96 => _96("\n\n"), 'access', _97 => _97.filter, 'call', _98 => _98(Boolean)]) || [];
2276
+ const currentSections = _optionalChain([pullInput, 'optionalAccess', _106 => _106.split, 'call', _107 => _107("\n\n"), 'access', _108 => _108.filter, 'call', _109 => _109(Boolean)]) || [];
2277
+ const originalSections = _optionalChain([originalInput, 'optionalAccess', _110 => _110.split, 'call', _111 => _111("\n\n"), 'access', _112 => _112.filter, 'call', _113 => _113(Boolean)]) || [];
2102
2278
  const result = originalSections.map((section) => {
2103
2279
  const sectionPo = _gettextparser2.default.po.parse(section);
2104
2280
  const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
@@ -2163,8 +2339,8 @@ function createPoContentLoader() {
2163
2339
  {
2164
2340
  ...entry,
2165
2341
  msgstr: [
2166
- _optionalChain([data, 'access', _99 => _99[entry.msgid], 'optionalAccess', _100 => _100.singular]),
2167
- _optionalChain([data, 'access', _101 => _101[entry.msgid], 'optionalAccess', _102 => _102.plural]) || null
2342
+ _optionalChain([data, 'access', _114 => _114[entry.msgid], 'optionalAccess', _115 => _115.singular]),
2343
+ _optionalChain([data, 'access', _116 => _116[entry.msgid], 'optionalAccess', _117 => _117.plural]) || null
2168
2344
  ].filter(Boolean)
2169
2345
  }
2170
2346
  ]).fromPairs().value();
@@ -2411,7 +2587,7 @@ function createDatoClient(params) {
2411
2587
  only_valid: "true",
2412
2588
  ids: !records.length ? void 0 : records.join(",")
2413
2589
  }
2414
- }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _103 => _103.response, 'optionalAccess', _104 => _104.body, 'optionalAccess', _105 => _105.data, 'optionalAccess', _106 => _106[0]]) || error));
2590
+ }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _118 => _118.response, 'optionalAccess', _119 => _119.body, 'optionalAccess', _120 => _120.data, 'optionalAccess', _121 => _121[0]]) || error));
2415
2591
  },
2416
2592
  findRecordsForModel: async (modelId, records) => {
2417
2593
  try {
@@ -2421,9 +2597,9 @@ function createDatoClient(params) {
2421
2597
  filter: {
2422
2598
  type: modelId,
2423
2599
  only_valid: "true",
2424
- ids: !_optionalChain([records, 'optionalAccess', _107 => _107.length]) ? void 0 : records.join(",")
2600
+ ids: !_optionalChain([records, 'optionalAccess', _122 => _122.length]) ? void 0 : records.join(",")
2425
2601
  }
2426
- }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _108 => _108.response, 'optionalAccess', _109 => _109.body, 'optionalAccess', _110 => _110.data, 'optionalAccess', _111 => _111[0]]) || error));
2602
+ }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _123 => _123.response, 'optionalAccess', _124 => _124.body, 'optionalAccess', _125 => _125.data, 'optionalAccess', _126 => _126[0]]) || error));
2427
2603
  return result;
2428
2604
  } catch (_error) {
2429
2605
  throw new Error(
@@ -2437,9 +2613,9 @@ function createDatoClient(params) {
2437
2613
  },
2438
2614
  updateRecord: async (id, payload) => {
2439
2615
  try {
2440
- await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _112 => _112.response, 'optionalAccess', _113 => _113.body, 'optionalAccess', _114 => _114.data, 'optionalAccess', _115 => _115[0]]) || error));
2616
+ await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _127 => _127.response, 'optionalAccess', _128 => _128.body, 'optionalAccess', _129 => _129.data, 'optionalAccess', _130 => _130[0]]) || error));
2441
2617
  } catch (_error) {
2442
- if (_optionalChain([_error, 'optionalAccess', _116 => _116.attributes, 'optionalAccess', _117 => _117.details, 'optionalAccess', _118 => _118.message])) {
2618
+ if (_optionalChain([_error, 'optionalAccess', _131 => _131.attributes, 'optionalAccess', _132 => _132.details, 'optionalAccess', _133 => _133.message])) {
2443
2619
  throw new Error(
2444
2620
  [
2445
2621
  `${_error.attributes.details.message}`,
@@ -2460,9 +2636,9 @@ function createDatoClient(params) {
2460
2636
  },
2461
2637
  enableFieldLocalization: async (args) => {
2462
2638
  try {
2463
- await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _119 => _119.response, 'optionalAccess', _120 => _120.body, 'optionalAccess', _121 => _121.data, 'optionalAccess', _122 => _122[0]]) || error));
2639
+ await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _134 => _134.response, 'optionalAccess', _135 => _135.body, 'optionalAccess', _136 => _136.data, 'optionalAccess', _137 => _137[0]]) || error));
2464
2640
  } catch (_error) {
2465
- if (_optionalChain([_error, 'optionalAccess', _123 => _123.attributes, 'optionalAccess', _124 => _124.code]) === "NOT_FOUND") {
2641
+ if (_optionalChain([_error, 'optionalAccess', _138 => _138.attributes, 'optionalAccess', _139 => _139.code]) === "NOT_FOUND") {
2466
2642
  throw new Error(
2467
2643
  [
2468
2644
  `Field "${args.fieldId}" not found in model "${args.modelId}".`,
@@ -2470,7 +2646,7 @@ function createDatoClient(params) {
2470
2646
  ].join("\n\n")
2471
2647
  );
2472
2648
  }
2473
- if (_optionalChain([_error, 'optionalAccess', _125 => _125.attributes, 'optionalAccess', _126 => _126.details, 'optionalAccess', _127 => _127.message])) {
2649
+ if (_optionalChain([_error, 'optionalAccess', _140 => _140.attributes, 'optionalAccess', _141 => _141.details, 'optionalAccess', _142 => _142.message])) {
2474
2650
  throw new Error(
2475
2651
  [`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
2476
2652
  );
@@ -2536,7 +2712,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
2536
2712
  }
2537
2713
  }
2538
2714
  const records = await dato.findRecordsForModel(modelId);
2539
- const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _128 => _128.models, 'access', _129 => _129[modelId], 'optionalAccess', _130 => _130.records]) || [], project);
2715
+ const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _143 => _143.models, 'access', _144 => _144[modelId], 'optionalAccess', _145 => _145.records]) || [], project);
2540
2716
  const selectedRecords = await promptRecordSelection(modelName, recordChoices);
2541
2717
  result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
2542
2718
  updatedConfig.models[modelId].records = selectedRecords;
@@ -2548,14 +2724,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
2548
2724
  },
2549
2725
  async pull(locale, input2, initCtx) {
2550
2726
  const result = {};
2551
- for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _131 => _131.models]) || {})) {
2552
- let records = _optionalChain([initCtx, 'optionalAccess', _132 => _132.models, 'access', _133 => _133[modelId], 'access', _134 => _134.records]) || [];
2727
+ for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _146 => _146.models]) || {})) {
2728
+ let records = _optionalChain([initCtx, 'optionalAccess', _147 => _147.models, 'access', _148 => _148[modelId], 'access', _149 => _149.records]) || [];
2553
2729
  const recordIds = records.map((record) => record.id);
2554
2730
  records = await dato.findRecords(recordIds);
2555
2731
  console.log(`Fetched ${records.length} records for model ${modelId}`);
2556
2732
  if (records.length > 0) {
2557
2733
  result[modelId] = {
2558
- fields: _optionalChain([initCtx, 'optionalAccess', _135 => _135.models, 'optionalAccess', _136 => _136[modelId], 'optionalAccess', _137 => _137.fields]) || [],
2734
+ fields: _optionalChain([initCtx, 'optionalAccess', _150 => _150.models, 'optionalAccess', _151 => _151[modelId], 'optionalAccess', _152 => _152.fields]) || [],
2559
2735
  records
2560
2736
  };
2561
2737
  }
@@ -2614,7 +2790,7 @@ function createRecordChoices(records, selectedIds = [], project) {
2614
2790
  return records.map((record) => ({
2615
2791
  name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
2616
2792
  value: record.id,
2617
- checked: _optionalChain([selectedIds, 'optionalAccess', _138 => _138.includes, 'call', _139 => _139(record.id)])
2793
+ checked: _optionalChain([selectedIds, 'optionalAccess', _153 => _153.includes, 'call', _154 => _154(record.id)])
2618
2794
  }));
2619
2795
  }
2620
2796
  async function promptRecordSelection(modelName, choices) {
@@ -2881,7 +3057,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
2881
3057
  function createVttLoader() {
2882
3058
  return createLoader({
2883
3059
  async pull(locale, input2) {
2884
- const vtt = _optionalChain([_nodewebvtt2.default, 'access', _140 => _140.parse, 'call', _141 => _141(input2), 'optionalAccess', _142 => _142.cues]);
3060
+ const vtt = _optionalChain([_nodewebvtt2.default, 'access', _155 => _155.parse, 'call', _156 => _156(input2), 'optionalAccess', _157 => _157.cues]);
2885
3061
  if (Object.keys(vtt).length === 0) {
2886
3062
  return {};
2887
3063
  } else {
@@ -2922,11 +3098,12 @@ function createVariableLoader(params) {
2922
3098
  function variableExtractLoader(params) {
2923
3099
  const specifierPattern = getFormatSpecifierPattern(params.type);
2924
3100
  return createLoader({
2925
- pull: async (locale, input2) => {
3101
+ pull: async (locale, input2, initXtx, originalLocale, originalInput) => {
2926
3102
  const result = {};
2927
3103
  const inputValues = _lodash2.default.omitBy(input2, _lodash2.default.isEmpty);
2928
3104
  for (const [key, value] of Object.entries(inputValues)) {
2929
- const matches = value.match(specifierPattern) || [];
3105
+ const originalValue = originalInput[key];
3106
+ const matches = originalValue.match(specifierPattern) || [];
2930
3107
  result[key] = result[key] || {
2931
3108
  value,
2932
3109
  variables: []
@@ -2934,21 +3111,21 @@ function variableExtractLoader(params) {
2934
3111
  for (let i = 0; i < matches.length; i++) {
2935
3112
  const match = matches[i];
2936
3113
  const currentValue = result[key].value;
2937
- const newValue = _optionalChain([currentValue, 'optionalAccess', _143 => _143.replace, 'call', _144 => _144(match, `{variable:${i}}`)]);
3114
+ const newValue = _optionalChain([currentValue, 'optionalAccess', _158 => _158.replace, 'call', _159 => _159(match, `{variable:${i}}`)]);
2938
3115
  result[key].value = newValue;
2939
3116
  result[key].variables[i] = match;
2940
3117
  }
2941
3118
  }
2942
3119
  return result;
2943
3120
  },
2944
- push: async (locale, data) => {
3121
+ push: async (locale, data, originalInput, originalDefaultLocale, pullInput, pullOutput) => {
2945
3122
  const result = {};
2946
3123
  for (const [key, valueObj] of Object.entries(data)) {
2947
3124
  result[key] = valueObj.value;
2948
3125
  for (let i = 0; i < valueObj.variables.length; i++) {
2949
3126
  const variable = valueObj.variables[i];
2950
3127
  const currentValue = result[key];
2951
- const newValue = _optionalChain([currentValue, 'optionalAccess', _145 => _145.replace, 'call', _146 => _146(`{variable:${i}}`, variable)]);
3128
+ const newValue = _optionalChain([currentValue, 'optionalAccess', _160 => _160.replace, 'call', _161 => _161(`{variable:${i}}`, variable)]);
2952
3129
  result[key] = newValue;
2953
3130
  }
2954
3131
  }
@@ -2964,7 +3141,7 @@ function variableContentLoader() {
2964
3141
  },
2965
3142
  push: async (locale, data, originalInput, defaultLocale, pullInput) => {
2966
3143
  const result = _lodash2.default.cloneDeep(
2967
- pullInput || {}
3144
+ originalInput || {}
2968
3145
  );
2969
3146
  for (const [key, originalValueObj] of Object.entries(result)) {
2970
3147
  result[key] = {
@@ -2991,7 +3168,7 @@ function getFormatSpecifierPattern(type) {
2991
3168
 
2992
3169
  function createSyncLoader() {
2993
3170
  return createLoader({
2994
- async pull(locale, input2, originalInput) {
3171
+ async pull(locale, input2, initCtx, originalLocale, originalInput) {
2995
3172
  if (!originalInput) {
2996
3173
  return input2;
2997
3174
  }
@@ -3131,7 +3308,7 @@ function createVueJsonLoader() {
3131
3308
  return createLoader({
3132
3309
  pull: async (locale, input2, ctx) => {
3133
3310
  const parsed = parseVueFile(input2);
3134
- return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _147 => _147.i18n, 'optionalAccess', _148 => _148[locale]]), () => ( {}));
3311
+ return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _162 => _162.i18n, 'optionalAccess', _163 => _163[locale]]), () => ( {}));
3135
3312
  },
3136
3313
  push: async (locale, data, originalInput) => {
3137
3314
  const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
@@ -3312,7 +3489,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
3312
3489
  objectExpression.properties.forEach((prop) => {
3313
3490
  if (!t.isObjectProperty(prop)) return;
3314
3491
  const key = getPropertyKey(prop);
3315
- const incomingVal = _optionalChain([data, 'optionalAccess', _149 => _149[key]]);
3492
+ const incomingVal = _optionalChain([data, 'optionalAccess', _164 => _164[key]]);
3316
3493
  if (incomingVal === void 0) {
3317
3494
  return;
3318
3495
  }
@@ -3348,7 +3525,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
3348
3525
  let modified = false;
3349
3526
  arrayExpression.elements.forEach((element, index) => {
3350
3527
  if (!element) return;
3351
- const incomingVal = _optionalChain([incoming, 'optionalAccess', _150 => _150[index]]);
3528
+ const incomingVal = _optionalChain([incoming, 'optionalAccess', _165 => _165[index]]);
3352
3529
  if (incomingVal === void 0) return;
3353
3530
  if (t.isStringLiteral(element) && typeof incomingVal === "string") {
3354
3531
  if (element.value !== incomingVal) {
@@ -3624,7 +3801,7 @@ function createMdxSectionsSplit2Loader() {
3624
3801
  const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
3625
3802
  const result = {
3626
3803
  frontmatter: data.frontmatter,
3627
- codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _151 => _151.codePlaceholders]) || {},
3804
+ codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _166 => _166.codePlaceholders]) || {},
3628
3805
  content
3629
3806
  };
3630
3807
  return result;
@@ -3967,14 +4144,14 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
3967
4144
  }
3968
4145
 
3969
4146
  // src/cli/cmd/i18n.ts
3970
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
4147
+
3971
4148
  var _diff = require('diff');
3972
4149
 
3973
4150
  var _externaleditor = require('external-editor'); var _externaleditor2 = _interopRequireDefault(_externaleditor);
3974
4151
 
3975
4152
  // src/cli/processor/index.ts
3976
4153
 
3977
- var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
4154
+
3978
4155
 
3979
4156
  // src/cli/processor/lingo.ts
3980
4157
  var __sdk = require('@lingo.dev/_sdk');
@@ -4067,7 +4244,7 @@ function createBasicTranslator(model, systemPrompt) {
4067
4244
  ]
4068
4245
  });
4069
4246
  const result = JSON.parse(response.text);
4070
- return _optionalChain([result, 'optionalAccess', _152 => _152.data]) || {};
4247
+ return _optionalChain([result, 'optionalAccess', _167 => _167.data]) || {};
4071
4248
  }
4072
4249
  }
4073
4250
  function extractPayloadChunks(payload) {
@@ -4149,7 +4326,7 @@ function getPureModelProvider(provider) {
4149
4326
 
4150
4327
  ${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
4151
4328
  `;
4152
- switch (_optionalChain([provider, 'optionalAccess', _153 => _153.id])) {
4329
+ switch (_optionalChain([provider, 'optionalAccess', _168 => _168.id])) {
4153
4330
  case "openai":
4154
4331
  if (!process.env.OPENAI_API_KEY) {
4155
4332
  throw new Error(
@@ -4170,7 +4347,7 @@ function getPureModelProvider(provider) {
4170
4347
  apiKey: process.env.ANTHROPIC_API_KEY
4171
4348
  })(provider.model);
4172
4349
  default:
4173
- throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _154 => _154.id])));
4350
+ throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _169 => _169.id])));
4174
4351
  }
4175
4352
  }
4176
4353
 
@@ -4394,7 +4571,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4394
4571
  validateParams(i18nConfig, flags);
4395
4572
  ora.succeed("Localization configuration is valid");
4396
4573
  ora.start("Connecting to Lingo.dev Localization Engine...");
4397
- const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _155 => _155.provider]);
4574
+ const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _170 => _170.provider]);
4398
4575
  if (isByokMode) {
4399
4576
  authId = null;
4400
4577
  ora.succeed("Using external provider (BYOK mode)");
@@ -4408,16 +4585,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4408
4585
  flags
4409
4586
  });
4410
4587
  let buckets = getBuckets(i18nConfig);
4411
- if (_optionalChain([flags, 'access', _156 => _156.bucket, 'optionalAccess', _157 => _157.length])) {
4588
+ if (_optionalChain([flags, 'access', _171 => _171.bucket, 'optionalAccess', _172 => _172.length])) {
4412
4589
  buckets = buckets.filter(
4413
4590
  (bucket) => flags.bucket.includes(bucket.type)
4414
4591
  );
4415
4592
  }
4416
4593
  ora.succeed("Buckets retrieved");
4417
- if (_optionalChain([flags, 'access', _158 => _158.file, 'optionalAccess', _159 => _159.length])) {
4594
+ if (_optionalChain([flags, 'access', _173 => _173.file, 'optionalAccess', _174 => _174.length])) {
4418
4595
  buckets = buckets.map((bucket) => {
4419
4596
  const paths = bucket.paths.filter(
4420
- (path16) => flags.file.find((file) => _optionalChain([path16, 'access', _160 => _160.pathPattern, 'optionalAccess', _161 => _161.includes, 'call', _162 => _162(file)]))
4597
+ (path16) => flags.file.find((file) => _optionalChain([path16, 'access', _175 => _175.pathPattern, 'optionalAccess', _176 => _176.includes, 'call', _177 => _177(file)]))
4421
4598
  );
4422
4599
  return { ...bucket, paths };
4423
4600
  }).filter((bucket) => bucket.paths.length > 0);
@@ -4436,7 +4613,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4436
4613
  });
4437
4614
  }
4438
4615
  }
4439
- const targetLocales = _optionalChain([flags, 'access', _163 => _163.locale, 'optionalAccess', _164 => _164.length]) ? flags.locale : i18nConfig.locale.targets;
4616
+ const targetLocales = _optionalChain([flags, 'access', _178 => _178.locale, 'optionalAccess', _179 => _179.length]) ? flags.locale : i18nConfig.locale.targets;
4440
4617
  ora.start("Setting up localization cache...");
4441
4618
  const checkLockfileProcessor = createDeltaProcessor("");
4442
4619
  const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
@@ -4610,7 +4787,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
4610
4787
  if (flags.key) {
4611
4788
  processableData = _lodash2.default.pickBy(
4612
4789
  processableData,
4613
- (_30, key) => key === flags.key
4790
+ (_33, key) => key === flags.key
4614
4791
  );
4615
4792
  }
4616
4793
  if (flags.verbose) {
@@ -4780,12 +4957,12 @@ function validateParams(i18nConfig, flags) {
4780
4957
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
4781
4958
  docUrl: "bucketNotFound"
4782
4959
  });
4783
- } else if (_optionalChain([flags, 'access', _165 => _165.locale, 'optionalAccess', _166 => _166.some, 'call', _167 => _167((locale) => !i18nConfig.locale.targets.includes(locale))])) {
4960
+ } else if (_optionalChain([flags, 'access', _180 => _180.locale, 'optionalAccess', _181 => _181.some, 'call', _182 => _182((locale) => !i18nConfig.locale.targets.includes(locale))])) {
4784
4961
  throw new CLIError({
4785
4962
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
4786
4963
  docUrl: "localeTargetNotFound"
4787
4964
  });
4788
- } else if (_optionalChain([flags, 'access', _168 => _168.bucket, 'optionalAccess', _169 => _169.some, 'call', _170 => _170(
4965
+ } else if (_optionalChain([flags, 'access', _183 => _183.bucket, 'optionalAccess', _184 => _184.some, 'call', _185 => _185(
4789
4966
  (bucket) => !i18nConfig.buckets[bucket]
4790
4967
  )])) {
4791
4968
  throw new CLIError({
@@ -5113,7 +5290,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
5113
5290
  var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
5114
5291
 
5115
5292
 
5116
- var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_30, program) => {
5293
+ var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_33, program) => {
5117
5294
  const apiKey = program.args[0];
5118
5295
  const settings = getSettings(apiKey);
5119
5296
  if (!settings.auth.apiKey) {
@@ -5250,7 +5427,7 @@ var InBranchFlow = class extends IntegrationFlow {
5250
5427
  _child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
5251
5428
  _child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
5252
5429
  _child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
5253
- _optionalChain([this, 'access', _171 => _171.platformKit, 'optionalAccess', _172 => _172.gitConfig, 'call', _173 => _173()]);
5430
+ _optionalChain([this, 'access', _186 => _186.platformKit, 'optionalAccess', _187 => _187.gitConfig, 'call', _188 => _188()]);
5254
5431
  _child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
5255
5432
  _child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
5256
5433
  if (!processOwnCommits) {
@@ -5282,7 +5459,7 @@ var InBranchFlow = class extends IntegrationFlow {
5282
5459
  // src/cli/cmd/ci/flows/pull-request.ts
5283
5460
  var PullRequestFlow = class extends InBranchFlow {
5284
5461
  async preRun() {
5285
- const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _174 => _174()]);
5462
+ const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _189 => _189()]);
5286
5463
  if (!canContinue) {
5287
5464
  return false;
5288
5465
  }
@@ -5534,10 +5711,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
5534
5711
  repo_slug: this.platformConfig.repositoryName,
5535
5712
  state: "OPEN"
5536
5713
  }).then(({ data: { values } }) => {
5537
- return _optionalChain([values, 'optionalAccess', _175 => _175.find, 'call', _176 => _176(
5538
- ({ source, destination }) => _optionalChain([source, 'optionalAccess', _177 => _177.branch, 'optionalAccess', _178 => _178.name]) === branch && _optionalChain([destination, 'optionalAccess', _179 => _179.branch, 'optionalAccess', _180 => _180.name]) === this.platformConfig.baseBranchName
5714
+ return _optionalChain([values, 'optionalAccess', _190 => _190.find, 'call', _191 => _191(
5715
+ ({ source, destination }) => _optionalChain([source, 'optionalAccess', _192 => _192.branch, 'optionalAccess', _193 => _193.name]) === branch && _optionalChain([destination, 'optionalAccess', _194 => _194.branch, 'optionalAccess', _195 => _195.name]) === this.platformConfig.baseBranchName
5539
5716
  )]);
5540
- }).then((pr) => _optionalChain([pr, 'optionalAccess', _181 => _181.id]));
5717
+ }).then((pr) => _optionalChain([pr, 'optionalAccess', _196 => _196.id]));
5541
5718
  }
5542
5719
  async closePullRequest({ pullRequestNumber }) {
5543
5720
  await this.bb.repositories.declinePullRequest({
@@ -5633,7 +5810,7 @@ var GitHubPlatformKit = class extends PlatformKit {
5633
5810
  repo: this.platformConfig.repositoryName,
5634
5811
  base: this.platformConfig.baseBranchName,
5635
5812
  state: "open"
5636
- }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _182 => _182.number]));
5813
+ }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _197 => _197.number]));
5637
5814
  }
5638
5815
  async closePullRequest({ pullRequestNumber }) {
5639
5816
  await this.octokit.rest.pulls.update({
@@ -5760,7 +5937,7 @@ var GitlabPlatformKit = class extends PlatformKit {
5760
5937
  sourceBranch: branch,
5761
5938
  state: "opened"
5762
5939
  });
5763
- return _optionalChain([mergeRequests, 'access', _183 => _183[0], 'optionalAccess', _184 => _184.iid]);
5940
+ return _optionalChain([mergeRequests, 'access', _198 => _198[0], 'optionalAccess', _199 => _199.iid]);
5764
5941
  }
5765
5942
  async closePullRequest({
5766
5943
  pullRequestNumber
@@ -5844,7 +6021,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
5844
6021
  }
5845
6022
  const env = {
5846
6023
  LINGODOTDEV_API_KEY: settings.auth.apiKey,
5847
- LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _185 => _185.pullRequest, 'optionalAccess', _186 => _186.toString, 'call', _187 => _187()]) || "false",
6024
+ LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _200 => _200.pullRequest, 'optionalAccess', _201 => _201.toString, 'call', _202 => _202()]) || "false",
5848
6025
  ...options.commitMessage && {
5849
6026
  LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
5850
6027
  },
@@ -5864,7 +6041,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
5864
6041
  const { isPullRequestMode } = platformKit.config;
5865
6042
  ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
5866
6043
  const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
5867
- const canRun = await _optionalChain([flow, 'access', _188 => _188.preRun, 'optionalCall', _189 => _189()]);
6044
+ const canRun = await _optionalChain([flow, 'access', _203 => _203.preRun, 'optionalCall', _204 => _204()]);
5868
6045
  if (canRun === false) {
5869
6046
  return;
5870
6047
  }
@@ -5872,7 +6049,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
5872
6049
  if (!hasChanges) {
5873
6050
  return;
5874
6051
  }
5875
- await _optionalChain([flow, 'access', _190 => _190.postRun, 'optionalCall', _191 => _191()]);
6052
+ await _optionalChain([flow, 'access', _205 => _205.postRun, 'optionalCall', _206 => _206()]);
5876
6053
  });
5877
6054
 
5878
6055
  // src/cli/cmd/status.ts
@@ -5916,13 +6093,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
5916
6093
  flags
5917
6094
  });
5918
6095
  let buckets = getBuckets(i18nConfig);
5919
- if (_optionalChain([flags, 'access', _192 => _192.bucket, 'optionalAccess', _193 => _193.length])) {
6096
+ if (_optionalChain([flags, 'access', _207 => _207.bucket, 'optionalAccess', _208 => _208.length])) {
5920
6097
  buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
5921
6098
  }
5922
6099
  ora.succeed("Buckets retrieved");
5923
- if (_optionalChain([flags, 'access', _194 => _194.file, 'optionalAccess', _195 => _195.length])) {
6100
+ if (_optionalChain([flags, 'access', _209 => _209.file, 'optionalAccess', _210 => _210.length])) {
5924
6101
  buckets = buckets.map((bucket) => {
5925
- const paths = bucket.paths.filter((path16) => flags.file.find((file) => _optionalChain([path16, 'access', _196 => _196.pathPattern, 'optionalAccess', _197 => _197.match, 'call', _198 => _198(file)])));
6102
+ const paths = bucket.paths.filter((path16) => flags.file.find((file) => _optionalChain([path16, 'access', _211 => _211.pathPattern, 'optionalAccess', _212 => _212.match, 'call', _213 => _213(file)])));
5926
6103
  return { ...bucket, paths };
5927
6104
  }).filter((bucket) => bucket.paths.length > 0);
5928
6105
  if (buckets.length === 0) {
@@ -5938,7 +6115,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
5938
6115
  });
5939
6116
  }
5940
6117
  }
5941
- const targetLocales = _optionalChain([flags, 'access', _199 => _199.locale, 'optionalAccess', _200 => _200.length]) ? flags.locale : i18nConfig.locale.targets;
6118
+ const targetLocales = _optionalChain([flags, 'access', _214 => _214.locale, 'optionalAccess', _215 => _215.length]) ? flags.locale : i18nConfig.locale.targets;
5942
6119
  let totalSourceKeyCount = 0;
5943
6120
  let uniqueKeysToTranslate = 0;
5944
6121
  let totalExistingTranslations = 0;
@@ -6279,12 +6456,12 @@ function validateParams2(i18nConfig, flags) {
6279
6456
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
6280
6457
  docUrl: "bucketNotFound"
6281
6458
  });
6282
- } else if (_optionalChain([flags, 'access', _201 => _201.locale, 'optionalAccess', _202 => _202.some, 'call', _203 => _203((locale) => !i18nConfig.locale.targets.includes(locale))])) {
6459
+ } else if (_optionalChain([flags, 'access', _216 => _216.locale, 'optionalAccess', _217 => _217.some, 'call', _218 => _218((locale) => !i18nConfig.locale.targets.includes(locale))])) {
6283
6460
  throw new CLIError({
6284
6461
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
6285
6462
  docUrl: "localeTargetNotFound"
6286
6463
  });
6287
- } else if (_optionalChain([flags, 'access', _204 => _204.bucket, 'optionalAccess', _205 => _205.some, 'call', _206 => _206((bucket) => !i18nConfig.buckets[bucket])])) {
6464
+ } else if (_optionalChain([flags, 'access', _219 => _219.bucket, 'optionalAccess', _220 => _220.some, 'call', _221 => _221((bucket) => !i18nConfig.buckets[bucket])])) {
6288
6465
  throw new CLIError({
6289
6466
  message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
6290
6467
  docUrl: "bucketNotFound"
@@ -6367,7 +6544,7 @@ async function renderHero() {
6367
6544
  // package.json
6368
6545
  var package_default = {
6369
6546
  name: "lingo.dev",
6370
- version: "0.92.15",
6547
+ version: "0.92.17",
6371
6548
  description: "Lingo.dev CLI",
6372
6549
  private: false,
6373
6550
  publishConfig: {
@@ -6582,7 +6759,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
6582
6759
  const response = await engine.whoami();
6583
6760
  return {
6584
6761
  authenticated: !!response,
6585
- username: _optionalChain([response, 'optionalAccess', _207 => _207.email])
6762
+ username: _optionalChain([response, 'optionalAccess', _222 => _222.email])
6586
6763
  };
6587
6764
  } catch (e3) {
6588
6765
  return { authenticated: false };
@@ -6767,14 +6944,14 @@ async function setup(input2) {
6767
6944
  throw new Error(
6768
6945
  "No buckets found in i18n.json. Please add at least one bucket containing i18n content."
6769
6946
  );
6770
- } else if (_optionalChain([ctx, 'access', _208 => _208.flags, 'access', _209 => _209.locale, 'optionalAccess', _210 => _210.some, 'call', _211 => _211(
6771
- (locale) => !_optionalChain([ctx, 'access', _212 => _212.config, 'optionalAccess', _213 => _213.locale, 'access', _214 => _214.targets, 'access', _215 => _215.includes, 'call', _216 => _216(locale)])
6947
+ } else if (_optionalChain([ctx, 'access', _223 => _223.flags, 'access', _224 => _224.locale, 'optionalAccess', _225 => _225.some, 'call', _226 => _226(
6948
+ (locale) => !_optionalChain([ctx, 'access', _227 => _227.config, 'optionalAccess', _228 => _228.locale, 'access', _229 => _229.targets, 'access', _230 => _230.includes, 'call', _231 => _231(locale)])
6772
6949
  )])) {
6773
6950
  throw new Error(
6774
6951
  `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list first and try again.`
6775
6952
  );
6776
- } else if (_optionalChain([ctx, 'access', _217 => _217.flags, 'access', _218 => _218.bucket, 'optionalAccess', _219 => _219.some, 'call', _220 => _220(
6777
- (bucket) => !_optionalChain([ctx, 'access', _221 => _221.config, 'optionalAccess', _222 => _222.buckets, 'access', _223 => _223[bucket]])
6953
+ } else if (_optionalChain([ctx, 'access', _232 => _232.flags, 'access', _233 => _233.bucket, 'optionalAccess', _234 => _234.some, 'call', _235 => _235(
6954
+ (bucket) => !_optionalChain([ctx, 'access', _236 => _236.config, 'optionalAccess', _237 => _237.buckets, 'access', _238 => _238[bucket]])
6778
6955
  )])) {
6779
6956
  throw new Error(
6780
6957
  `One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
@@ -6786,7 +6963,7 @@ async function setup(input2) {
6786
6963
  {
6787
6964
  title: "Selecting localization provider",
6788
6965
  task: async (ctx, task) => {
6789
- ctx.localizer = createLocalizer(_optionalChain([ctx, 'access', _224 => _224.config, 'optionalAccess', _225 => _225.provider]));
6966
+ ctx.localizer = createLocalizer(_optionalChain([ctx, 'access', _239 => _239.config, 'optionalAccess', _240 => _240.provider]));
6790
6967
  if (!ctx.localizer) {
6791
6968
  throw new Error(
6792
6969
  "Could not create localization provider. Please check your i18n.json configuration."
@@ -6972,7 +7149,7 @@ async function execute(input2) {
6972
7149
  const workerTasks = [];
6973
7150
  for (let i = 0; i < workersCount; i++) {
6974
7151
  const assignedTasks = ctx.tasks.filter(
6975
- (_30, idx) => idx % workersCount === i
7152
+ (_33, idx) => idx % workersCount === i
6976
7153
  );
6977
7154
  workerTasks.push(
6978
7155
  createWorkerTask({
@@ -7307,7 +7484,7 @@ ${_gradientstring.vice.call(void 0,
7307
7484
 
7308
7485
  Star the the repo :) https://github.com/LingoDotDev/lingo.dev
7309
7486
  `
7310
- ).version(`v${package_default.version}`, "-v, --version", "Show version").addCommand(init_default).interactive("-y, --no-interactive", "Disable interactive mode").addCommand(i18n_default).addCommand(auth_default).addCommand(show_default).addCommand(lockfile_default).addCommand(cleanup_default).addCommand(mcp_default).addCommand(ci_default).addCommand(status_default).addCommand(may_the_fourth_default, { hidden: true }).addCommand(run_default, { hidden: true }).exitOverride((err) => {
7487
+ ).version(`v${package_default.version}`, "-v, --version", "Show version").addCommand(init_default).interactive("-y, --no-interactive", "Disable interactive mode").addCommand(i18n_default).addCommand(auth_default).addCommand(show_default).addCommand(config_default2).addCommand(lockfile_default).addCommand(cleanup_default).addCommand(mcp_default).addCommand(ci_default).addCommand(status_default).addCommand(may_the_fourth_default, { hidden: true }).addCommand(run_default, { hidden: true }).exitOverride((err) => {
7311
7488
  if (err.code === "commander.helpDisplayed" || err.code === "commander.version" || err.code === "commander.help") {
7312
7489
  process.exit(0);
7313
7490
  }