@tarileo/avileo-catalog-cli 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -5,7 +5,7 @@ The Avileo tenant-agent command line interface for a registered `tienda` catalog
5
5
  For a first-time human connection, use the temporary device authorization link:
6
6
 
7
7
  ```sh
8
- npx --yes @tarileo/avileo-catalog-cli@0.2.0 auth login --json
8
+ npx --yes @tarileo/avileo-catalog-cli@0.2.2 auth login --json
9
9
  ```
10
10
 
11
11
  The CLI prints only the verification URI, user code and status, opens the link
package/dist/index.js CHANGED
@@ -14557,7 +14557,7 @@ var AgentImportError = class extends AgentError {
14557
14557
  };
14558
14558
  var AgentNetworkError = class extends AgentError {
14559
14559
  };
14560
- var AVILEO_AGENT_API_URL = "https://api.avileo.com";
14560
+ var AVILEO_AGENT_API_URL = "https://avileo.theelena.me";
14561
14561
  function configuredApiKey(config2) {
14562
14562
  if (!("apiKey" in config2)) return void 0;
14563
14563
  const apiKey = config2.apiKey.trim();
@@ -15433,7 +15433,11 @@ function normalizeAgentKey(value, message) {
15433
15433
  function localCredentialPath(env = process.env) {
15434
15434
  const configured = env.AVILEO_AGENT_CONFIG_PATH?.trim();
15435
15435
  if (configured) return configured;
15436
- return join(env.XDG_CONFIG_HOME?.trim() || join(homedir(), ".config"), "avileo", "credentials.json");
15436
+ return join(
15437
+ env.XDG_CONFIG_HOME?.trim() || join(homedir(), ".config"),
15438
+ "avileo",
15439
+ "credentials.json"
15440
+ );
15437
15441
  }
15438
15442
  function readLocalCredential(env = process.env) {
15439
15443
  let parsed;
@@ -15457,7 +15461,10 @@ function resolveCredential(env = process.env) {
15457
15461
  const environmentValue = env.AVILEO_AGENT_API_KEY;
15458
15462
  if (environmentValue !== void 0) {
15459
15463
  return {
15460
- apiKey: normalizeAgentKey(environmentValue, "AVILEO_AGENT_API_KEY no es una Agent Key v\xE1lida"),
15464
+ apiKey: normalizeAgentKey(
15465
+ environmentValue,
15466
+ "AVILEO_AGENT_API_KEY no es una Agent Key v\xE1lida"
15467
+ ),
15461
15468
  source: "environment",
15462
15469
  ...env.AVILEO_AGENT_BASE_URL?.trim() ? { baseUrl: env.AVILEO_AGENT_BASE_URL.trim() } : {}
15463
15470
  };
@@ -15471,7 +15478,10 @@ function resolveCredential(env = process.env) {
15471
15478
  };
15472
15479
  }
15473
15480
  function saveLocalCredential(credential, env = process.env) {
15474
- const apiKey = normalizeAgentKey(credential.apiKey, "Solo se pueden guardar Agent Keys de Avileo");
15481
+ const apiKey = normalizeAgentKey(
15482
+ credential.apiKey,
15483
+ "Solo se pueden guardar Agent Keys de Avileo"
15484
+ );
15475
15485
  const path = localCredentialPath(env);
15476
15486
  mkdirSync(dirname(path), { recursive: true, mode: 448 });
15477
15487
  const temporaryPath = `${path}.${randomUUID()}.tmp`;
@@ -15878,7 +15888,10 @@ async function openVerificationUri(uri) {
15878
15888
  return false;
15879
15889
  }
15880
15890
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return false;
15881
- const candidates = process.platform === "darwin" ? [["open", [parsed.toString()]]] : process.platform === "win32" ? [["explorer.exe", [parsed.toString()]]] : [["xdg-open", [parsed.toString()]], ["open", [parsed.toString()]]];
15891
+ const candidates = process.platform === "darwin" ? [["open", [parsed.toString()]]] : process.platform === "win32" ? [["explorer.exe", [parsed.toString()]]] : [
15892
+ ["xdg-open", [parsed.toString()]],
15893
+ ["open", [parsed.toString()]]
15894
+ ];
15882
15895
  for (const [command, args] of candidates) {
15883
15896
  if (await openWithExecutable(command, args)) return true;
15884
15897
  }
@@ -15889,12 +15902,10 @@ async function login(options) {
15889
15902
  const deviceAuth = options.deviceAuthFactory(baseUrl ? { baseUrl } : {});
15890
15903
  const start = await deviceAuth.start({ name: "Avileo CLI" });
15891
15904
  const browserOpened = await options.openBrowser(start.verificationUri);
15892
- if (!options.json()) {
15893
- process.stderr.write(
15894
- `Abr\xED ${start.verificationUri} y confirma el c\xF3digo ${start.userCode}. Esperando aprobaci\xF3n\u2026
15905
+ process.stderr.write(
15906
+ `Abr\xED ${start.verificationUri} y confirma el c\xF3digo ${start.userCode}. Esperando aprobaci\xF3n\u2026
15895
15907
  `
15896
- );
15897
- }
15908
+ );
15898
15909
  const expiresAt = Date.parse(start.expiresAt);
15899
15910
  const deadline = Number.isFinite(expiresAt) ? expiresAt : Date.now() + 10 * 60 * 1e3;
15900
15911
  while (Date.now() < deadline) {
@@ -15909,12 +15920,18 @@ async function login(options) {
15909
15920
  return;
15910
15921
  }
15911
15922
  if (!result.agentKey || !result.keyId || !result.businessId) {
15912
- throw new CliProtocolError("CLI_AUTH_ERROR", "La autorizaci\xF3n aprobada no devolvi\xF3 una credencial v\xE1lida");
15923
+ throw new CliProtocolError(
15924
+ "CLI_AUTH_ERROR",
15925
+ "La autorizaci\xF3n aprobada no devolvi\xF3 una credencial v\xE1lida"
15926
+ );
15913
15927
  }
15914
- saveLocalCredential({
15915
- apiKey: result.agentKey,
15916
- ...baseUrl ? { baseUrl } : {}
15917
- }, options.env);
15928
+ saveLocalCredential(
15929
+ {
15930
+ apiKey: result.agentKey,
15931
+ ...baseUrl ? { baseUrl } : {}
15932
+ },
15933
+ options.env
15934
+ );
15918
15935
  emitSuccess(safeFinalResult(start, browserOpened, result));
15919
15936
  return;
15920
15937
  }
@@ -15963,7 +15980,10 @@ function createProgram(options = {}) {
15963
15980
  const program = new Command();
15964
15981
  let client;
15965
15982
  const getClient = options.getClient ?? (() => {
15966
- client ??= createClientFromEnvironment({ env: options.env, clientFactory: options.clientFactory });
15983
+ client ??= createClientFromEnvironment({
15984
+ env: options.env,
15985
+ clientFactory: options.clientFactory
15986
+ });
15967
15987
  return client;
15968
15988
  });
15969
15989
  program.name("avileo").description("CLI seguro para el cat\xE1logo de un negocio Avileo").option("--json", "Emite la envoltura JSON versionada para automatizaci\xF3n");
@@ -15986,7 +16006,8 @@ function createProgram(options = {}) {
15986
16006
  try {
15987
16007
  return await parseAsync3(...args);
15988
16008
  } catch (error51) {
15989
- if (error51 instanceof CommanderError && error51.code === "commander.helpDisplayed") return program;
16009
+ if (error51 instanceof CommanderError && error51.code === "commander.helpDisplayed")
16010
+ return program;
15990
16011
  emitFailure(toFailure(error51));
15991
16012
  process.exitCode = exitCodeFor(error51);
15992
16013
  return program;