@sortlist/cli 0.41.0 → 0.42.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/index.js CHANGED
@@ -1253,6 +1253,11 @@ function enumListOf(type) {
1253
1253
  const inner = unwrap2(listless.ofType);
1254
1254
  return isEnumType2(inner) ? inner : null;
1255
1255
  }
1256
+ function enumOf(type) {
1257
+ const listless = isNonNullType2(type) ? type.ofType : type;
1258
+ if (isListType2(listless)) return null;
1259
+ return isEnumType2(listless) ? listless : null;
1260
+ }
1256
1261
  function commonPrefix(values) {
1257
1262
  if (values.length < 2) return "";
1258
1263
  let prefix = values[0];
@@ -1260,28 +1265,46 @@ function commonPrefix(values) {
1260
1265
  const cut = prefix.lastIndexOf("_");
1261
1266
  return cut === -1 ? "" : prefix.slice(0, cut + 1);
1262
1267
  }
1268
+ function matchEnumValue(part, names, prefix) {
1269
+ const wanted = part.trim().replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
1270
+ return names.find((name) => name === wanted || name === `${prefix}${wanted}`);
1271
+ }
1272
+ function spellableValues(names, prefix) {
1273
+ return names.map(
1274
+ (name) => name.slice(prefix.length).toLowerCase().replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
1275
+ );
1276
+ }
1263
1277
  function coerceEnumList(raw, enumType, flagName) {
1264
1278
  const names = enumType.getValues().map((value) => value.name);
1265
1279
  if (raw.trim() === "all") return names;
1266
1280
  if (raw.trim() === "none") return [];
1267
1281
  const prefix = commonPrefix(names);
1268
1282
  return raw.split(",").filter((part) => part.trim() !== "").map((part) => {
1269
- const wanted = part.trim().replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
1270
- const match = names.find((name) => name === wanted || name === `${prefix}${wanted}`);
1283
+ const match = matchEnumValue(part, names, prefix);
1271
1284
  if (match === void 0) {
1272
- const short = names.map(
1273
- (name) => name.slice(prefix.length).toLowerCase().replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
1274
- );
1275
1285
  throw new Error(
1276
- `--${flagName} does not know "${part.trim()}". One or more of: ${short.join(", ")}, all, or none.`
1286
+ `--${flagName} does not know "${part.trim()}". One or more of: ${spellableValues(names, prefix).join(", ")}, all, or none.`
1277
1287
  );
1278
1288
  }
1279
1289
  return match;
1280
1290
  });
1281
1291
  }
1292
+ function coerceEnum(raw, enumType, flagName) {
1293
+ const names = enumType.getValues().map((value) => value.name);
1294
+ const prefix = commonPrefix(names);
1295
+ const match = matchEnumValue(raw, names, prefix);
1296
+ if (match === void 0) {
1297
+ throw new Error(
1298
+ `--${flagName} does not know "${raw.trim()}". One of: ${spellableValues(names, prefix).join(", ")}.`
1299
+ );
1300
+ }
1301
+ return match;
1302
+ }
1282
1303
  function coerceValue(raw, type, flagName) {
1283
1304
  const enumList = enumListOf(type);
1284
1305
  if (enumList && !raw.trim().startsWith("[")) return coerceEnumList(raw, enumList, flagName);
1306
+ const enumValue = enumOf(type);
1307
+ if (enumValue) return coerceEnum(raw, enumValue, flagName);
1285
1308
  if (isStructuredInput(type)) {
1286
1309
  try {
1287
1310
  return JSON.parse(raw);
@@ -1610,7 +1633,11 @@ var API_SCOPES = [
1610
1633
  "signals/*:read",
1611
1634
  "billing/*:*",
1612
1635
  "billing/*:read",
1613
- "billing/offer:*"
1636
+ "billing/offer:*",
1637
+ "outreach/*:*",
1638
+ "outreach/*:read",
1639
+ "hermes/*:*",
1640
+ "hermes/*:read"
1614
1641
  ];
1615
1642
  var DEFAULT_SCOPE = `openid profile email offline_access ${API_SCOPES.join(" ")}`;
1616
1643
  function sleep(ms) {