@tarileo/avileo-catalog-cli 0.1.2 → 0.1.4

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
@@ -3,8 +3,445 @@
3
3
  // src/program.ts
4
4
  import { Command, CommanderError } from "commander";
5
5
 
6
+ // ../sdk/dist/agent.js
7
+ var AgentError = class extends Error {
8
+ code;
9
+ status;
10
+ details;
11
+ requestId;
12
+ retryable;
13
+ constructor(message, options) {
14
+ super(message);
15
+ this.name = new.target.name;
16
+ this.code = options.code;
17
+ this.status = options.status;
18
+ this.details = options.details;
19
+ this.requestId = options.requestId;
20
+ this.retryable = options.retryable ?? false;
21
+ }
22
+ };
23
+ var AgentAuthenticationError = class extends AgentError {
24
+ };
25
+ var AgentPermissionError = class extends AgentError {
26
+ };
27
+ var AgentUnsupportedModeError = class extends AgentError {
28
+ };
29
+ var AgentUnsupportedCapabilityError = class extends AgentError {
30
+ };
31
+ var AgentValidationError = class extends AgentError {
32
+ };
33
+ var AgentConflictError = class extends AgentError {
34
+ };
35
+ var AgentQuotaError = class extends AgentError {
36
+ };
37
+ var AgentImportError = class extends AgentError {
38
+ };
39
+ var AgentNetworkError = class extends AgentError {
40
+ };
41
+ var AVILEO_AGENT_API_URL = "https://api.avileo.com";
42
+ function isObject(value) {
43
+ return value !== null && typeof value === "object";
44
+ }
45
+ function errorPayload(value) {
46
+ if (!isObject(value) || value.success !== false || !isObject(value.error)) return null;
47
+ const { code, message, details, requestId } = value.error;
48
+ if (typeof code !== "string" || typeof message !== "string") return null;
49
+ return {
50
+ code,
51
+ message,
52
+ ...details === void 0 ? {} : { details },
53
+ ...typeof requestId === "string" ? { requestId } : {}
54
+ };
55
+ }
56
+ function successPayload(value) {
57
+ return isObject(value) && value.success === true && "data" in value;
58
+ }
59
+ function retryAfterMs(value) {
60
+ if (!value) return void 0;
61
+ const seconds = Number(value);
62
+ if (Number.isFinite(seconds) && seconds >= 0) return Math.min(seconds * 1e3, 5e3);
63
+ const timestamp = Date.parse(value);
64
+ if (Number.isNaN(timestamp)) return void 0;
65
+ return Math.min(Math.max(0, timestamp - Date.now()), 5e3);
66
+ }
67
+ function retryDelayMs(attempt, response) {
68
+ const defaultDelay = attempt === 0 ? 250 : 1e3;
69
+ const retryAfter = response ? retryAfterMs(response.headers.get("retry-after")) : void 0;
70
+ return retryAfter !== void 0 && retryAfter > defaultDelay ? retryAfter : defaultDelay;
71
+ }
72
+ function isRetryableStatus(status) {
73
+ return status === 408 || status === 429 || status === 502 || status === 503 || status === 504;
74
+ }
75
+ function requestIdFrom(response, payload) {
76
+ return payload?.requestId ?? response.headers.get("x-request-id") ?? void 0;
77
+ }
78
+ function agentError(response, payload) {
79
+ const code = payload?.code ?? "AGENT_REQUEST_FAILED";
80
+ const message = payload?.message ?? "La API de Avileo devolvi\xF3 una respuesta inv\xE1lida";
81
+ const options = {
82
+ code,
83
+ status: response.status,
84
+ ...payload?.details === void 0 ? {} : { details: payload.details },
85
+ ...requestIdFrom(response, payload) === void 0 ? {} : { requestId: requestIdFrom(response, payload) },
86
+ retryable: isRetryableStatus(response.status)
87
+ };
88
+ if (response.status === 401 || code === "UNAUTHORIZED") {
89
+ return new AgentAuthenticationError(message, options);
90
+ }
91
+ if (code === "UNSUPPORTED_MODE" || code === "AGENT_UNSUPPORTED_MODE") {
92
+ return new AgentUnsupportedModeError(message, options);
93
+ }
94
+ if (code === "CAPABILITY_DISABLED" || code === "UNSUPPORTED_CAPABILITY") {
95
+ return new AgentUnsupportedCapabilityError(message, options);
96
+ }
97
+ if (response.status === 403 || code === "FORBIDDEN") {
98
+ return new AgentPermissionError(message, options);
99
+ }
100
+ if (response.status === 400 || response.status === 422 || code === "VALIDATION_ERROR") {
101
+ return new AgentValidationError(message, options);
102
+ }
103
+ if (response.status === 409 || code.startsWith("AGENT_OPERATION_") || code === "CONFLICT") {
104
+ return new AgentConflictError(message, options);
105
+ }
106
+ if (response.status === 402 || code === "TOO_MANY_REQUESTS" || code.includes("QUOTA") || code.includes("LIMIT")) {
107
+ return new AgentQuotaError(message, options);
108
+ }
109
+ if (code.startsWith("AGENT_IMPORT") || code === "AGENT_CREDENTIAL_CHANGED") {
110
+ return new AgentImportError(message, options);
111
+ }
112
+ return new AgentError(message, options);
113
+ }
114
+ function createAbortSignal(timeoutMs) {
115
+ if (!timeoutMs) return { cancel() {
116
+ } };
117
+ const controller = new AbortController();
118
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
119
+ return { signal: controller.signal, cancel: () => clearTimeout(timer) };
120
+ }
121
+ var AgentHttpClient = class {
122
+ #apiKey;
123
+ #baseUrl;
124
+ #fetchImpl;
125
+ #timeoutMs;
126
+ constructor(config) {
127
+ if (!config.apiKey.trim()) {
128
+ throw new AgentValidationError("apiKey es obligatorio", {
129
+ code: "INVALID_AGENT_CONFIG",
130
+ status: 0
131
+ });
132
+ }
133
+ this.#apiKey = config.apiKey;
134
+ this.#baseUrl = (config.baseUrl ?? AVILEO_AGENT_API_URL).replace(/\/$/, "");
135
+ this.#fetchImpl = config.fetch ?? fetch;
136
+ this.#timeoutMs = config.timeoutMs;
137
+ }
138
+ request(path, options = {}) {
139
+ return this.perform(path, options, options.mutation ? crypto.randomUUID() : void 0);
140
+ }
141
+ async perform(path, options, operationId) {
142
+ const url = `${this.#baseUrl}${path}`;
143
+ const formData = options.body instanceof FormData ? options.body : void 0;
144
+ const body = options.body === void 0 ? void 0 : formData ?? JSON.stringify(options.body);
145
+ for (let attempt = 0; attempt < 3; attempt += 1) {
146
+ const abort = createAbortSignal(this.#timeoutMs);
147
+ let response;
148
+ try {
149
+ response = await this.#fetchImpl(url, {
150
+ method: options.method ?? "GET",
151
+ headers: {
152
+ ...formData || options.body === void 0 ? {} : { "content-type": "application/json" },
153
+ ...operationId ? { "idempotency-key": operationId } : {},
154
+ "x-avileo-agent-key": this.#apiKey
155
+ },
156
+ body,
157
+ signal: abort.signal
158
+ });
159
+ } catch {
160
+ abort.cancel();
161
+ if (attempt < 2) {
162
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs(attempt)));
163
+ continue;
164
+ }
165
+ throw new AgentNetworkError("No se pudo conectar con la API de Avileo", {
166
+ code: "NETWORK_ERROR",
167
+ status: 0,
168
+ retryable: true
169
+ });
170
+ }
171
+ abort.cancel();
172
+ if (isRetryableStatus(response.status) && attempt < 2) {
173
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs(attempt, response)));
174
+ continue;
175
+ }
176
+ let payload;
177
+ try {
178
+ payload = await response.json();
179
+ } catch {
180
+ throw new AgentError("La API de Avileo devolvi\xF3 una respuesta inv\xE1lida", {
181
+ code: "INVALID_RESPONSE",
182
+ status: response.status,
183
+ requestId: response.headers.get("x-request-id") ?? void 0,
184
+ retryable: isRetryableStatus(response.status)
185
+ });
186
+ }
187
+ const failure = errorPayload(payload);
188
+ if (failure || !response.ok || !successPayload(payload)) {
189
+ throw agentError(response, failure);
190
+ }
191
+ return payload.data;
192
+ }
193
+ throw new AgentNetworkError("No se pudo conectar con la API de Avileo", {
194
+ code: "NETWORK_ERROR",
195
+ status: 0,
196
+ retryable: true
197
+ });
198
+ }
199
+ };
200
+ function queryString(input) {
201
+ const query = new URLSearchParams();
202
+ for (const [key, value] of Object.entries(input)) {
203
+ if (value !== void 0) query.set(key, String(value));
204
+ }
205
+ const serialized = query.toString();
206
+ return serialized ? `?${serialized}` : "";
207
+ }
208
+ var AgentBusinessResource = class {
209
+ constructor(http) {
210
+ this.http = http;
211
+ }
212
+ http;
213
+ get() {
214
+ return this.http.request("/api/v1/agent/business");
215
+ }
216
+ };
217
+ var AgentProductsResource = class {
218
+ constructor(http) {
219
+ this.http = http;
220
+ }
221
+ http;
222
+ list(filters = {}) {
223
+ return this.http.request(`/api/v1/agent/catalog/products${queryString(filters)}`);
224
+ }
225
+ get(productId) {
226
+ return this.http.request(`/api/v1/agent/catalog/products/${encodeURIComponent(productId)}`);
227
+ }
228
+ create(input) {
229
+ return this.http.request("/api/v1/agent/catalog/products", {
230
+ method: "POST",
231
+ body: input,
232
+ mutation: true
233
+ });
234
+ }
235
+ update(productId, input) {
236
+ return this.http.request(`/api/v1/agent/catalog/products/${encodeURIComponent(productId)}`, {
237
+ method: "PATCH",
238
+ body: input,
239
+ mutation: true
240
+ });
241
+ }
242
+ deactivate(productId) {
243
+ return this.http.request(
244
+ `/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/deactivate`,
245
+ { method: "POST", mutation: true }
246
+ );
247
+ }
248
+ };
249
+ var AgentVariantsResource = class {
250
+ constructor(http) {
251
+ this.http = http;
252
+ }
253
+ http;
254
+ list(productId) {
255
+ return this.http.request(
256
+ `/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/variants`
257
+ );
258
+ }
259
+ get(variantId) {
260
+ return this.http.request(`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}`);
261
+ }
262
+ create(productId, input) {
263
+ return this.http.request(
264
+ `/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/variants`,
265
+ { method: "POST", body: input, mutation: true }
266
+ );
267
+ }
268
+ update(variantId, input) {
269
+ return this.http.request(`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}`, {
270
+ method: "PATCH",
271
+ body: input,
272
+ mutation: true
273
+ });
274
+ }
275
+ deactivate(variantId) {
276
+ return this.http.request(
277
+ `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/deactivate`,
278
+ { method: "POST", mutation: true }
279
+ );
280
+ }
281
+ reorder(productId, input) {
282
+ return this.http.request(
283
+ `/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/variants/reorder`,
284
+ { method: "POST", body: input, mutation: true }
285
+ );
286
+ }
287
+ };
288
+ var AgentCategoriesResource = class {
289
+ constructor(http) {
290
+ this.http = http;
291
+ }
292
+ http;
293
+ list() {
294
+ return this.http.request("/api/v1/agent/catalog/categories");
295
+ }
296
+ get(categoryId) {
297
+ return this.http.request(`/api/v1/agent/catalog/categories/${encodeURIComponent(categoryId)}`);
298
+ }
299
+ create(input) {
300
+ return this.http.request("/api/v1/agent/catalog/categories", {
301
+ method: "POST",
302
+ body: input,
303
+ mutation: true
304
+ });
305
+ }
306
+ update(categoryId, input) {
307
+ return this.http.request(`/api/v1/agent/catalog/categories/${encodeURIComponent(categoryId)}`, {
308
+ method: "PATCH",
309
+ body: input,
310
+ mutation: true
311
+ });
312
+ }
313
+ delete(categoryId) {
314
+ return this.http.request(`/api/v1/agent/catalog/categories/${encodeURIComponent(categoryId)}`, {
315
+ method: "DELETE",
316
+ mutation: true
317
+ });
318
+ }
319
+ };
320
+ var AgentTagsResource = class {
321
+ constructor(http) {
322
+ this.http = http;
323
+ }
324
+ http;
325
+ list() {
326
+ return this.http.request("/api/v1/agent/catalog/tags");
327
+ }
328
+ get(tagId) {
329
+ return this.http.request(`/api/v1/agent/catalog/tags/${encodeURIComponent(tagId)}`);
330
+ }
331
+ create(input) {
332
+ return this.http.request("/api/v1/agent/catalog/tags", {
333
+ method: "POST",
334
+ body: input,
335
+ mutation: true
336
+ });
337
+ }
338
+ update(tagId, input) {
339
+ return this.http.request(`/api/v1/agent/catalog/tags/${encodeURIComponent(tagId)}`, {
340
+ method: "PATCH",
341
+ body: input,
342
+ mutation: true
343
+ });
344
+ }
345
+ delete(tagId) {
346
+ return this.http.request(`/api/v1/agent/catalog/tags/${encodeURIComponent(tagId)}`, {
347
+ method: "DELETE",
348
+ mutation: true
349
+ });
350
+ }
351
+ };
352
+ var AgentAssetsResource = class {
353
+ constructor(http) {
354
+ this.http = http;
355
+ }
356
+ http;
357
+ list(filters = {}) {
358
+ return this.http.request(`/api/v1/agent/catalog/assets${queryString(filters)}`);
359
+ }
360
+ get(assetId) {
361
+ return this.http.request(`/api/v1/agent/catalog/assets/${encodeURIComponent(assetId)}`);
362
+ }
363
+ upload(file) {
364
+ const body = new FormData();
365
+ body.set("file", file);
366
+ return this.http.request("/api/v1/agent/catalog/assets/upload", {
367
+ method: "POST",
368
+ body,
369
+ mutation: true
370
+ });
371
+ }
372
+ importFromUrl(input) {
373
+ return this.http.request("/api/v1/agent/catalog/assets/import", {
374
+ method: "POST",
375
+ body: input,
376
+ mutation: true
377
+ });
378
+ }
379
+ };
380
+ var AgentInventoryResource = class {
381
+ constructor(http) {
382
+ this.http = http;
383
+ }
384
+ http;
385
+ get(variantId) {
386
+ return this.http.request(
387
+ `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory`
388
+ );
389
+ }
390
+ listMovements(variantId, filters = {}) {
391
+ return this.http.request(
392
+ `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory/movements${queryString(filters)}`
393
+ );
394
+ }
395
+ adjust(variantId, input) {
396
+ return this.http.request(
397
+ `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory/adjust`,
398
+ { method: "POST", body: input, mutation: true }
399
+ );
400
+ }
401
+ set(variantId, input) {
402
+ return this.http.request(
403
+ `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory`,
404
+ { method: "PUT", body: input, mutation: true }
405
+ );
406
+ }
407
+ };
408
+ var AgentImportsResource = class {
409
+ constructor(http) {
410
+ this.http = http;
411
+ }
412
+ http;
413
+ preview(input) {
414
+ return this.http.request("/api/v1/agent/catalog/imports/preview", {
415
+ method: "POST",
416
+ body: input,
417
+ mutation: true
418
+ });
419
+ }
420
+ apply(importId) {
421
+ return this.http.request(`/api/v1/agent/catalog/imports/${encodeURIComponent(importId)}/apply`, {
422
+ method: "POST",
423
+ mutation: true
424
+ });
425
+ }
426
+ get(importId) {
427
+ return this.http.request(`/api/v1/agent/catalog/imports/${encodeURIComponent(importId)}`);
428
+ }
429
+ };
430
+ function createAvileoAgent(config) {
431
+ const http = new AgentHttpClient(config);
432
+ return {
433
+ business: new AgentBusinessResource(http),
434
+ products: new AgentProductsResource(http),
435
+ variants: new AgentVariantsResource(http),
436
+ categories: new AgentCategoriesResource(http),
437
+ tags: new AgentTagsResource(http),
438
+ assets: new AgentAssetsResource(http),
439
+ inventory: new AgentInventoryResource(http),
440
+ imports: new AgentImportsResource(http)
441
+ };
442
+ }
443
+
6
444
  // src/config.ts
7
- import { createAvileoAgent } from "@tarileo/avileo-sdk/agent";
8
445
  function createClientFromEnvironment({
9
446
  env = process.env,
10
447
  clientFactory = createAvileoAgent
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/program.ts","../src/config.ts","../src/output.ts","../src/commands/business.ts","../src/commands/catalog.ts","../src/index.ts"],"sourcesContent":["import { Command, CommanderError } from 'commander';\nimport type { AvileoAgentClient } from '@tarileo/avileo-sdk/agent';\nimport { createClientFromEnvironment, type AgentClientFactory } from './config';\nimport { registerBusinessCommands } from './commands/business';\nimport { registerCatalogCommands } from './commands/catalog';\nimport { CliProtocolError, emitFailure, exitCodeFor, toFailure } from './output';\n\nexport interface CreateProgramOptions {\n env?: NodeJS.ProcessEnv;\n clientFactory?: AgentClientFactory;\n getClient?: () => AvileoAgentClient;\n}\n\nexport function createProgram(options: CreateProgramOptions = {}): Command {\n const program = new Command();\n let client: AvileoAgentClient | undefined;\n const getClient = options.getClient ?? (() => {\n client ??= createClientFromEnvironment({ env: options.env, clientFactory: options.clientFactory });\n return client;\n });\n\n program\n .name('avileo')\n .description('CLI seguro para el catálogo de un negocio Avileo')\n .option('--json', 'Emite la envoltura JSON versionada para automatización');\n\n // Commander diagnostics would otherwise violate the one-envelope stderr contract.\n program.configureOutput({ writeErr: () => undefined });\n program.exitOverride((error) => {\n if (error.code === 'commander.helpDisplayed') return;\n throw new CliProtocolError('CLI_USAGE_ERROR', error.message);\n });\n\n registerBusinessCommands(program, getClient);\n registerCatalogCommands(program, getClient);\n\n const parseAsync = program.parseAsync.bind(program);\n program.parseAsync = (async (...args: Parameters<Command['parseAsync']>) => {\n try {\n return await parseAsync(...args);\n } catch (error) {\n if (error instanceof CommanderError && error.code === 'commander.helpDisplayed') return program;\n emitFailure(toFailure(error));\n process.exitCode = exitCodeFor(error);\n return program;\n }\n }) as Command['parseAsync'];\n\n return program;\n}\n","import { createAvileoAgent, type AvileoAgentClient } from '@tarileo/avileo-sdk/agent';\n\nexport type AgentClientFactory = (config: {\n apiKey: string;\n baseUrl?: string;\n}) => AvileoAgentClient;\n\nexport interface CliConfigDependencies {\n env?: NodeJS.ProcessEnv;\n clientFactory?: AgentClientFactory;\n}\n\nexport function createClientFromEnvironment({\n env = process.env,\n clientFactory = createAvileoAgent,\n}: CliConfigDependencies = {}): AvileoAgentClient {\n const apiKey = env.AVILEO_AGENT_API_KEY?.trim();\n if (!apiKey) {\n throw new CliConfigurationError('AVILEO_AGENT_API_KEY es obligatorio');\n }\n\n const baseUrl = env.AVILEO_AGENT_BASE_URL?.trim();\n return clientFactory({ apiKey, ...(baseUrl ? { baseUrl } : {}) });\n}\n\nexport class CliConfigurationError extends Error {\n readonly code = 'CLI_CONFIGURATION_ERROR';\n\n constructor(message: string) {\n super(message);\n this.name = 'CliConfigurationError';\n }\n}\n","export interface CliFailure {\n code: string;\n message: string;\n requestId?: string;\n retryable?: boolean;\n details?: unknown;\n}\n\nexport class CliProtocolError extends Error {\n readonly code: string;\n readonly details?: unknown;\n\n constructor(code: string, message: string, details?: unknown) {\n super(message);\n this.name = 'CliProtocolError';\n this.code = code;\n this.details = details;\n }\n}\n\nexport function emitSuccess(data: unknown): void {\n process.stdout.write(`${JSON.stringify({ version: 1, ok: true, data: redact(data) })}\\n`);\n}\n\nexport function emitFailure(failure: CliFailure): void {\n const error = redact({\n code: failure.code,\n message: failure.message,\n ...(failure.requestId ? { requestId: failure.requestId } : {}),\n ...(failure.retryable === undefined ? {} : { retryable: failure.retryable }),\n ...(failure.details === undefined ? {} : { details: failure.details }),\n }) as CliFailure;\n process.stderr.write(`${JSON.stringify({ version: 1, ok: false, error })}\\n`);\n}\n\nexport function exitCodeFor(error: unknown): number {\n const candidate = error as { code?: string; status?: number; retryable?: boolean };\n if (candidate.retryable) return 2;\n if (candidate.status === 409 || /CONFLICT|IDEMPOTENCY|VERSION/.test(candidate.code ?? '')) return 4;\n if (\n candidate.status === 401 ||\n candidate.status === 403 ||\n candidate.status === 422 ||\n /AUTH|PERMISSION|VALIDATION|UNSUPPORTED|QUOTA|POLICY/.test(candidate.code ?? '')\n ) {\n return 3;\n }\n return 1;\n}\n\nexport function toFailure(error: unknown): CliFailure {\n const candidate = error as {\n code?: unknown;\n message?: unknown;\n requestId?: unknown;\n retryable?: unknown;\n details?: unknown;\n };\n return {\n code: typeof candidate?.code === 'string' ? candidate.code : 'CLI_ERROR',\n message: typeof candidate?.message === 'string' ? candidate.message : 'Error inesperado',\n ...(typeof candidate?.requestId === 'string' ? { requestId: candidate.requestId } : {}),\n ...(typeof candidate?.retryable === 'boolean' ? { retryable: candidate.retryable } : {}),\n ...(candidate?.details === undefined ? {} : { details: candidate.details }),\n };\n}\n\nfunction redact(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(redact);\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>).map(([key, item]) => [\n key,\n /(?:api.?key|authorization|secret|token|password)/i.test(key) ? '[REDACTED]' : redact(item),\n ]),\n );\n }\n return value;\n}\n","import type { Command } from 'commander';\nimport type { AvileoAgentClient } from '@tarileo/avileo-sdk/agent';\nimport { emitSuccess } from '../output';\n\nexport function registerBusinessCommands(root: Command, getClient: () => AvileoAgentClient): void {\n const business = root.command('business').description('Consulta el negocio vinculado a la clave agente');\n business\n .command('show')\n .description('Muestra las capacidades seguras del negocio')\n .action(async () => {\n emitSuccess(await getClient().business.get());\n });\n}\n","import { basename } from 'node:path';\nimport { readFile, stat } from 'node:fs/promises';\nimport type { Command } from 'commander';\nimport type { AvileoAgentClient } from '@tarileo/avileo-sdk/agent';\nimport { CliProtocolError, emitSuccess } from '../output';\n\ntype JsonObject = Record<string, unknown>;\ntype ClientFactory = () => AvileoAgentClient;\n\nfunction requireId(value: string, name: string): string {\n if (!value.trim()) throw new CliProtocolError('CLI_VALIDATION_ERROR', `${name} es obligatorio`);\n return value;\n}\n\nasync function readMutationInput(path: string): Promise<JsonObject> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(await readFile(path, 'utf8'));\n } catch {\n throw new CliProtocolError('CLI_INPUT_ERROR', 'No se pudo leer un objeto JSON desde --from');\n }\n if (!parsed || Array.isArray(parsed) || typeof parsed !== 'object') {\n throw new CliProtocolError('CLI_VALIDATION_ERROR', '--from debe contener un objeto JSON');\n }\n return normalizeInput(parsed as JsonObject);\n}\n\nfunction normalizeInput(value: JsonObject): JsonObject {\n const forbidden: Record<string, true> = {\n businessId: true,\n idempotencyKey: true,\n apiKey: true,\n agentKey: true,\n authorization: true,\n };\n const visit = (item: unknown): unknown => {\n if (Array.isArray(item)) return item.map(visit);\n if (!item || typeof item !== 'object') return item;\n return Object.fromEntries(\n Object.entries(item as JsonObject).map(([key, nested]) => {\n if (\n forbidden[key] ||\n /(?:api.?key|agent.?key|authorization|secret|token|password|idempotency)/i.test(key)\n ) {\n throw new CliProtocolError('CLI_VALIDATION_ERROR', `El campo ${key} no está permitido`);\n }\n return [key, visit(nested)];\n }),\n );\n };\n return visit(value) as JsonObject;\n}\n\nfunction withMutationOptions(command: Command, includeFrom = true): Command {\n if (includeFrom) command.requiredOption('--from <json-file>', 'Objeto JSON estructurado');\n return command.option('--apply', 'Ejecuta la mutación después de validarla localmente');\n}\n\nfunction wantsApply(command: Command): boolean {\n return Boolean(command.optsWithGlobals().apply);\n}\n\nfunction localResult(input: JsonObject, current?: unknown): JsonObject {\n if (current === undefined) return { validated: 'local', input };\n const source = current as Record<string, unknown>;\n const changes = Object.fromEntries(\n Object.entries(input).map(([key, after]) => [key, { before: source[key], after }]),\n );\n return { validated: 'local', current, changes };\n}\n\nfunction addListOptions(command: Command): Command {\n return command\n .option('--search <text>')\n .option('--category-id <id>')\n .option('--active <true|false>', 'Filtra por estado activo', parseBoolean)\n .option('--limit <number>', 'Máximo de resultados', parseInteger)\n .option('--offset <number>', 'Desplazamiento', parseInteger);\n}\n\nfunction parseInteger(value: string): number {\n const result = Number(value);\n if (!Number.isInteger(result) || result < 0) throw new CliProtocolError('CLI_VALIDATION_ERROR', 'Se esperaba un entero no negativo');\n return result;\n}\n\nfunction parseBoolean(value: string): boolean {\n if (value === 'true') return true;\n if (value === 'false') return false;\n throw new CliProtocolError('CLI_VALIDATION_ERROR', 'Se esperaba true o false');\n}\n\nasync function applyOrPreview(\n command: Command,\n input: JsonObject,\n run: () => Promise<unknown>,\n current?: () => Promise<unknown>,\n): Promise<void> {\n if (wantsApply(command)) {\n emitSuccess(await run());\n return;\n }\n emitSuccess(localResult(input, current ? await current() : undefined));\n}\n\nexport function registerCatalogCommands(root: Command, getClient: ClientFactory): void {\n const catalog = root.command('catalog').description('Gestiona recursos de catálogo de Avileo');\n registerProductCommands(catalog, getClient);\n registerVariantCommands(catalog, getClient);\n registerCategoryCommands(catalog, getClient);\n registerTagCommands(catalog, getClient);\n registerAssetCommands(catalog, getClient);\n registerInventoryCommands(catalog, getClient);\n registerImportCommands(catalog, getClient);\n}\n\nfunction registerProductCommands(catalog: Command, getClient: ClientFactory): void {\n const product = catalog.command('product');\n addListOptions(product.command('list')).action(async (options) => {\n const { active: isActive, categoryId, ...filters } = options as JsonObject & { active?: boolean; categoryId?: string };\n emitSuccess(await getClient().products.list({ ...filters, ...(categoryId ? { categoryId } : {}), ...(isActive === undefined ? {} : { isActive }) }));\n });\n product.command('get <productId>').action(async (productId) => emitSuccess(await getClient().products.get(requireId(productId, 'productId'))));\n withMutationOptions(product.command('create')).action(async (options, command) => {\n const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().products.create(input as never));\n });\n withMutationOptions(product.command('update <productId>')).action(async (productId, options, command) => {\n const id = requireId(productId, 'productId'); const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().products.update(id, input as never), () => getClient().products.get(id));\n });\n withMutationOptions(product.command('deactivate <productId>'), false).action(async (productId, _options, command) => {\n const id = requireId(productId, 'productId'); const input = { isActive: false };\n await applyOrPreview(command, input, () => getClient().products.deactivate(id), () => getClient().products.get(id));\n });\n}\n\nfunction registerVariantCommands(catalog: Command, getClient: ClientFactory): void {\n const variant = catalog.command('variant');\n variant.command('list <productId>').action(async (productId) => emitSuccess(await getClient().variants.list(requireId(productId, 'productId'))));\n variant.command('get <variantId>').action(async (variantId) => emitSuccess(await getClient().variants.get(requireId(variantId, 'variantId'))));\n withMutationOptions(variant.command('create <productId>')).action(async (productId, options, command) => {\n const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().variants.create(requireId(productId, 'productId'), input as never));\n });\n withMutationOptions(variant.command('update <variantId>')).action(async (variantId, options, command) => {\n const id = requireId(variantId, 'variantId'); const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().variants.update(id, input as never), () => getClient().variants.get(id));\n });\n withMutationOptions(variant.command('deactivate <variantId>'), false).action(async (variantId, _options, command) => {\n const id = requireId(variantId, 'variantId'); const input = { isActive: false };\n await applyOrPreview(command, input, () => getClient().variants.deactivate(id), () => getClient().variants.get(id));\n });\n withMutationOptions(variant.command('reorder <productId>')).action(async (productId, options, command) => {\n const id = requireId(productId, 'productId'); const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().variants.reorder(id, input as never), () => getClient().variants.list(id));\n });\n}\n\nfunction registerCategoryCommands(catalog: Command, getClient: ClientFactory): void {\n const category = catalog.command('category');\n category.command('list').action(async () => emitSuccess(await getClient().categories.list()));\n category.command('get <categoryId>').action(async (categoryId) => emitSuccess(await getClient().categories.get(requireId(categoryId, 'categoryId'))));\n withMutationOptions(category.command('create')).action(async (options, command) => { const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().categories.create(input as never)); });\n withMutationOptions(category.command('update <categoryId>')).action(async (categoryId, options, command) => { const id = requireId(categoryId, 'categoryId'); const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().categories.update(id, input as never), () => getClient().categories.get(id)); });\n withMutationOptions(category.command('delete <categoryId>'), false).action(async (categoryId, _options, command) => { const id = requireId(categoryId, 'categoryId'); await applyOrPreview(command, { delete: true }, () => getClient().categories.delete(id), () => getClient().categories.get(id)); });\n}\n\nfunction registerTagCommands(catalog: Command, getClient: ClientFactory): void {\n const tag = catalog.command('tag');\n tag.command('list').action(async () => emitSuccess(await getClient().tags.list()));\n tag.command('get <tagId>').action(async (tagId) => emitSuccess(await getClient().tags.get(requireId(tagId, 'tagId'))));\n withMutationOptions(tag.command('create')).action(async (options, command) => { const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().tags.create(input as never)); });\n withMutationOptions(tag.command('update <tagId>')).action(async (tagId, options, command) => { const id = requireId(tagId, 'tagId'); const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().tags.update(id, input as never), () => getClient().tags.get(id)); });\n withMutationOptions(tag.command('delete <tagId>'), false).action(async (tagId, _options, command) => { const id = requireId(tagId, 'tagId'); await applyOrPreview(command, { delete: true }, () => getClient().tags.delete(id), () => getClient().tags.get(id)); });\n}\n\nfunction registerAssetCommands(catalog: Command, getClient: ClientFactory): void {\n const asset = catalog.command('asset');\n asset.command('list').option('--search <text>').option('--limit <number>', 'Máximo de resultados', parseInteger).option('--offset <number>', 'Desplazamiento', parseInteger).action(async (options) => emitSuccess(await getClient().assets.list(options)));\n asset.command('get <assetId>').action(async (assetId) => emitSuccess(await getClient().assets.get(requireId(assetId, 'assetId'))));\n asset.command('upload').requiredOption('--file <path>', 'Archivo local').option('--apply', 'Sube el archivo').action(async (options, command) => {\n const filePath = options.file as string; const fileStat = await stat(filePath); if (!fileStat.isFile()) throw new CliProtocolError('CLI_VALIDATION_ERROR', '--file debe apuntar a un archivo');\n if (!wantsApply(command)) { emitSuccess({ validated: 'local', file: basename(filePath), sizeBytes: fileStat.size }); return; }\n const file = new File([await readFile(filePath)], basename(filePath)); emitSuccess(await getClient().assets.upload(file));\n });\n withMutationOptions(asset.command('import-url')).action(async (options, command) => { const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().assets.importFromUrl(input as never)); });\n}\n\nfunction registerInventoryCommands(catalog: Command, getClient: ClientFactory): void {\n const inventory = catalog.command('inventory');\n inventory.command('get <variantId>').action(async (variantId) => emitSuccess(await getClient().inventory.get(requireId(variantId, 'variantId'))));\n inventory.command('movements <variantId>').option('--reason <reason>').option('--limit <number>', 'Máximo de resultados', parseInteger).option('--offset <number>', 'Desplazamiento', parseInteger).action(async (variantId, options) => emitSuccess(await getClient().inventory.listMovements(requireId(variantId, 'variantId'), options)));\n withMutationOptions(inventory.command('adjust <variantId>')).action(async (variantId, options, command) => { const id = requireId(variantId, 'variantId'); const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().inventory.adjust(id, input as never), () => getClient().inventory.get(id)); });\n withMutationOptions(inventory.command('set <variantId>')).action(async (variantId, options, command) => { const id = requireId(variantId, 'variantId'); const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().inventory.set(id, input as never), () => getClient().inventory.get(id)); });\n}\n\nasync function resolveLocalFileSources(value: unknown, client: AvileoAgentClient): Promise<unknown> {\n if (Array.isArray(value)) return Promise.all(value.map((item) => resolveLocalFileSources(item, client)));\n if (!value || typeof value !== 'object') return value;\n\n const source = value as JsonObject;\n if (source.kind === 'file') {\n if (typeof source.path !== 'string' || Object.keys(source).length !== 2) {\n throw new CliProtocolError(\n 'CLI_VALIDATION_ERROR',\n 'Una imagen local debe tener exactamente kind: \"file\" y path',\n );\n }\n const fileStat = await stat(source.path);\n if (!fileStat.isFile()) {\n throw new CliProtocolError('CLI_VALIDATION_ERROR', 'La ruta de imagen local debe apuntar a un archivo');\n }\n const asset = await client.assets.upload(\n new File([await readFile(source.path)], basename(source.path)),\n );\n return { kind: 'asset', assetId: asset.id };\n }\n\n return Object.fromEntries(\n await Promise.all(\n Object.entries(source).map(async ([key, nested]) => [\n key,\n await resolveLocalFileSources(nested, client),\n ]),\n ),\n );\n}\n\nfunction registerImportCommands(catalog: Command, getClient: ClientFactory): void {\n const imports = catalog.command('import');\n imports.command('preview').requiredOption('--from <json-file>', 'Lista estructurada para vista previa').action(async (options) => {\n const input = await readMutationInput(options.from);\n const normalizedInput = await resolveLocalFileSources(input, getClient()) as JsonObject;\n emitSuccess(await getClient().imports.preview(normalizedInput as never));\n });\n imports.command('apply <importId>').option('--apply', 'Encola la importación aprobada').action(async (importId, _options, command) => {\n const id = requireId(importId, 'importId');\n if (!wantsApply(command)) { emitSuccess({ validated: 'local', importId: id, action: 'apply' }); return; }\n emitSuccess(await getClient().imports.apply(id));\n });\n imports.command('status <importId>').action(async (importId) => emitSuccess(await getClient().imports.get(requireId(importId, 'importId'))));\n}\n","#!/usr/bin/env node\nimport { createProgram } from './program';\n\ncreateProgram().parseAsync(process.argv);\n"],"mappings":";;;AAAA,SAAS,SAAS,sBAAsB;;;ACAxC,SAAS,yBAAiD;AAYnD,SAAS,4BAA4B;AAAA,EAC1C,MAAM,QAAQ;AAAA,EACd,gBAAgB;AAClB,IAA2B,CAAC,GAAsB;AAChD,QAAM,SAAS,IAAI,sBAAsB,KAAK;AAC9C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,sBAAsB,qCAAqC;AAAA,EACvE;AAEA,QAAM,UAAU,IAAI,uBAAuB,KAAK;AAChD,SAAO,cAAc,EAAE,QAAQ,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC,EAAG,CAAC;AAClE;AAEO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EACtC,OAAO;AAAA,EAEhB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;ACxBO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACjC;AAAA,EACA;AAAA,EAET,YAAY,MAAc,SAAiB,SAAmB;AAC5D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,SAAS,YAAY,MAAqB;AAC/C,UAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,EAAE,SAAS,GAAG,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gBAAgB,EAAE,UAAU,MAAM,OAAU,CAAC;AACrD,UAAQ,aAAa,CAAC,UAAU;AAC9B,QAAI,MAAM,SAAS,0BAA2B;AAC9C,UAAM,IAAI,iBAAiB,mBAAmB,MAAM,OAAO;AAAA,EAC7D,CAAC;AAED,2BAAyB,SAAS,SAAS;AAC3C,0BAAwB,SAAS,SAAS;AAE1C,QAAM,aAAa,QAAQ,WAAW,KAAK,OAAO;AAClD,UAAQ,cAAc,UAAU,SAA4C;AAC1E,QAAI;AACF,aAAO,MAAM,WAAW,GAAG,IAAI;AAAA,IACjC,SAAS,OAAO;AACd,UAAI,iBAAiB,kBAAkB,MAAM,SAAS,0BAA2B,QAAO;AACxF,kBAAY,UAAU,KAAK,CAAC;AAC5B,cAAQ,WAAW,YAAY,KAAK;AACpC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;;;AK9CA,cAAc,EAAE,WAAW,QAAQ,IAAI;","names":[]}
1
+ {"version":3,"sources":["../src/program.ts","../../sdk/src/agent/errors.ts","../../sdk/src/agent/client.ts","../../sdk/src/agent/resources.ts","../../sdk/src/agent.ts","../src/config.ts","../src/output.ts","../src/commands/business.ts","../src/commands/catalog.ts","../src/index.ts"],"sourcesContent":["import { Command, CommanderError } from 'commander';\nimport type { AvileoAgentClient } from '@tarileo/avileo-sdk/agent';\nimport { createClientFromEnvironment, type AgentClientFactory } from './config';\nimport { registerBusinessCommands } from './commands/business';\nimport { registerCatalogCommands } from './commands/catalog';\nimport { CliProtocolError, emitFailure, exitCodeFor, toFailure } from './output';\n\nexport interface CreateProgramOptions {\n env?: NodeJS.ProcessEnv;\n clientFactory?: AgentClientFactory;\n getClient?: () => AvileoAgentClient;\n}\n\nexport function createProgram(options: CreateProgramOptions = {}): Command {\n const program = new Command();\n let client: AvileoAgentClient | undefined;\n const getClient = options.getClient ?? (() => {\n client ??= createClientFromEnvironment({ env: options.env, clientFactory: options.clientFactory });\n return client;\n });\n\n program\n .name('avileo')\n .description('CLI seguro para el catálogo de un negocio Avileo')\n .option('--json', 'Emite la envoltura JSON versionada para automatización');\n\n // Commander diagnostics would otherwise violate the one-envelope stderr contract.\n program.configureOutput({ writeErr: () => undefined });\n program.exitOverride((error) => {\n if (error.code === 'commander.helpDisplayed') return;\n throw new CliProtocolError('CLI_USAGE_ERROR', error.message);\n });\n\n registerBusinessCommands(program, getClient);\n registerCatalogCommands(program, getClient);\n\n const parseAsync = program.parseAsync.bind(program);\n program.parseAsync = (async (...args: Parameters<Command['parseAsync']>) => {\n try {\n return await parseAsync(...args);\n } catch (error) {\n if (error instanceof CommanderError && error.code === 'commander.helpDisplayed') return program;\n emitFailure(toFailure(error));\n process.exitCode = exitCodeFor(error);\n return program;\n }\n }) as Command['parseAsync'];\n\n return program;\n}\n","export interface AgentErrorOptions {\n code: string;\n status: number;\n details?: unknown;\n requestId?: string;\n retryable?: boolean;\n}\n\n/** Base error for the server-only tenant-agent SDK surface. */\nexport class AgentError extends Error {\n readonly code: string;\n readonly status: number;\n readonly details: unknown;\n readonly requestId: string | undefined;\n readonly retryable: boolean;\n\n constructor(message: string, options: AgentErrorOptions) {\n super(message);\n this.name = new.target.name;\n this.code = options.code;\n this.status = options.status;\n this.details = options.details;\n this.requestId = options.requestId;\n this.retryable = options.retryable ?? false;\n }\n}\n\nexport class AgentAuthenticationError extends AgentError {}\nexport class AgentPermissionError extends AgentError {}\nexport class AgentUnsupportedModeError extends AgentError {}\nexport class AgentUnsupportedCapabilityError extends AgentError {}\nexport class AgentValidationError extends AgentError {}\nexport class AgentConflictError extends AgentError {}\nexport class AgentQuotaError extends AgentError {}\nexport class AgentImportError extends AgentError {}\nexport class AgentNetworkError extends AgentError {}\n","import {\n AgentAuthenticationError,\n AgentConflictError,\n AgentError,\n AgentImportError,\n AgentNetworkError,\n AgentPermissionError,\n AgentQuotaError,\n AgentUnsupportedCapabilityError,\n AgentUnsupportedModeError,\n AgentValidationError,\n} from './errors';\n\nexport const AVILEO_AGENT_API_URL = 'https://api.avileo.com';\n\nexport interface AvileoAgentConfig {\n apiKey: string;\n baseUrl?: string;\n fetch?: typeof fetch;\n timeoutMs?: number;\n}\n\ntype RequestBody = unknown | FormData;\n\ninterface AgentRequestOptions {\n method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';\n body?: RequestBody;\n mutation?: boolean;\n}\n\ninterface AgentErrorPayload {\n code: string;\n message: string;\n details?: unknown;\n requestId?: string;\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object';\n}\n\nfunction errorPayload(value: unknown): AgentErrorPayload | null {\n if (!isObject(value) || value.success !== false || !isObject(value.error)) return null;\n const { code, message, details, requestId } = value.error;\n if (typeof code !== 'string' || typeof message !== 'string') return null;\n return {\n code,\n message,\n ...(details === undefined ? {} : { details }),\n ...(typeof requestId === 'string' ? { requestId } : {}),\n };\n}\n\nfunction successPayload(value: unknown): value is { success: true; data: unknown } {\n return isObject(value) && value.success === true && 'data' in value;\n}\n\nfunction retryAfterMs(value: string | null): number | undefined {\n if (!value) return undefined;\n const seconds = Number(value);\n if (Number.isFinite(seconds) && seconds >= 0) return Math.min(seconds * 1000, 5_000);\n\n const timestamp = Date.parse(value);\n if (Number.isNaN(timestamp)) return undefined;\n return Math.min(Math.max(0, timestamp - Date.now()), 5_000);\n}\n\nfunction retryDelayMs(attempt: number, response?: Response): number {\n const defaultDelay = attempt === 0 ? 250 : 1_000;\n const retryAfter = response ? retryAfterMs(response.headers.get('retry-after')) : undefined;\n return retryAfter !== undefined && retryAfter > defaultDelay ? retryAfter : defaultDelay;\n}\n\nfunction isRetryableStatus(status: number): boolean {\n return status === 408 || status === 429 || status === 502 || status === 503 || status === 504;\n}\n\nfunction requestIdFrom(response: Response, payload: AgentErrorPayload | null): string | undefined {\n return payload?.requestId ?? response.headers.get('x-request-id') ?? undefined;\n}\n\nfunction agentError(response: Response, payload: AgentErrorPayload | null): AgentError {\n const code = payload?.code ?? 'AGENT_REQUEST_FAILED';\n const message = payload?.message ?? 'La API de Avileo devolvió una respuesta inválida';\n const options = {\n code,\n status: response.status,\n ...(payload?.details === undefined ? {} : { details: payload.details }),\n ...(requestIdFrom(response, payload) === undefined\n ? {}\n : { requestId: requestIdFrom(response, payload) }),\n retryable: isRetryableStatus(response.status),\n };\n\n if (response.status === 401 || code === 'UNAUTHORIZED') {\n return new AgentAuthenticationError(message, options);\n }\n if (code === 'UNSUPPORTED_MODE' || code === 'AGENT_UNSUPPORTED_MODE') {\n return new AgentUnsupportedModeError(message, options);\n }\n if (code === 'CAPABILITY_DISABLED' || code === 'UNSUPPORTED_CAPABILITY') {\n return new AgentUnsupportedCapabilityError(message, options);\n }\n if (response.status === 403 || code === 'FORBIDDEN') {\n return new AgentPermissionError(message, options);\n }\n if (response.status === 400 || response.status === 422 || code === 'VALIDATION_ERROR') {\n return new AgentValidationError(message, options);\n }\n if (response.status === 409 || code.startsWith('AGENT_OPERATION_') || code === 'CONFLICT') {\n return new AgentConflictError(message, options);\n }\n if (\n response.status === 402 ||\n code === 'TOO_MANY_REQUESTS' ||\n code.includes('QUOTA') ||\n code.includes('LIMIT')\n ) {\n return new AgentQuotaError(message, options);\n }\n if (code.startsWith('AGENT_IMPORT') || code === 'AGENT_CREDENTIAL_CHANGED') {\n return new AgentImportError(message, options);\n }\n return new AgentError(message, options);\n}\n\nfunction createAbortSignal(timeoutMs: number | undefined): {\n signal?: AbortSignal;\n cancel(): void;\n} {\n if (!timeoutMs) return { cancel() {} };\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n return { signal: controller.signal, cancel: () => clearTimeout(timer) };\n}\n\n/** Internal transport: the agent key remains closure-only and cannot be overridden by a caller. */\nexport class AgentHttpClient {\n readonly #apiKey: string;\n readonly #baseUrl: string;\n readonly #fetchImpl: typeof fetch;\n readonly #timeoutMs: number | undefined;\n\n constructor(config: AvileoAgentConfig) {\n if (!config.apiKey.trim()) {\n throw new AgentValidationError('apiKey es obligatorio', {\n code: 'INVALID_AGENT_CONFIG',\n status: 0,\n });\n }\n this.#apiKey = config.apiKey;\n this.#baseUrl = (config.baseUrl ?? AVILEO_AGENT_API_URL).replace(/\\/$/, '');\n this.#fetchImpl = config.fetch ?? fetch;\n this.#timeoutMs = config.timeoutMs;\n }\n\n request<T>(path: string, options: AgentRequestOptions = {}): Promise<T> {\n return this.perform<T>(path, options, options.mutation ? crypto.randomUUID() : undefined);\n }\n\n private async perform<T>(\n path: string,\n options: AgentRequestOptions,\n operationId: string | undefined,\n ): Promise<T> {\n const url = `${this.#baseUrl}${path}`;\n const formData = options.body instanceof FormData ? options.body : undefined;\n const body: BodyInit | undefined =\n options.body === undefined ? undefined : formData ?? JSON.stringify(options.body);\n for (let attempt = 0; attempt < 3; attempt += 1) {\n const abort = createAbortSignal(this.#timeoutMs);\n let response: Response;\n try {\n response = await this.#fetchImpl(url, {\n method: options.method ?? 'GET',\n headers: {\n ...(formData || options.body === undefined ? {} : { 'content-type': 'application/json' }),\n ...(operationId ? { 'idempotency-key': operationId } : {}),\n 'x-avileo-agent-key': this.#apiKey,\n },\n body,\n signal: abort.signal,\n });\n } catch {\n abort.cancel();\n if (attempt < 2) {\n await new Promise<void>((resolve) => setTimeout(resolve, retryDelayMs(attempt)));\n continue;\n }\n throw new AgentNetworkError('No se pudo conectar con la API de Avileo', {\n code: 'NETWORK_ERROR',\n status: 0,\n retryable: true,\n });\n }\n abort.cancel();\n\n if (isRetryableStatus(response.status) && attempt < 2) {\n await new Promise<void>((resolve) => setTimeout(resolve, retryDelayMs(attempt, response)));\n continue;\n }\n\n let payload: unknown;\n try {\n payload = await response.json();\n } catch {\n throw new AgentError('La API de Avileo devolvió una respuesta inválida', {\n code: 'INVALID_RESPONSE',\n status: response.status,\n requestId: response.headers.get('x-request-id') ?? undefined,\n retryable: isRetryableStatus(response.status),\n });\n }\n\n const failure = errorPayload(payload);\n if (failure || !response.ok || !successPayload(payload)) {\n throw agentError(response, failure);\n }\n return payload.data as T;\n }\n\n throw new AgentNetworkError('No se pudo conectar con la API de Avileo', {\n code: 'NETWORK_ERROR',\n status: 0,\n retryable: true,\n });\n }\n}\n","import type {\n AgentAdjustInventoryInput,\n AgentAssetDto,\n AgentAssetFilterInput,\n AgentBusinessDto,\n AgentCatalogImportPreviewDto,\n AgentCatalogImportPreviewInput,\n AgentCatalogImportResultDto,\n AgentCatalogTagDto,\n AgentCategoryDto,\n AgentCreateCatalogTagInput,\n AgentCreateCategoryInput,\n AgentCreateProductInput,\n AgentCreateVariantInput,\n AgentImportAssetFromUrlInput,\n AgentInventoryMovementDto,\n AgentInventoryMovementFilterInput,\n AgentInventorySnapshotDto,\n AgentProductDto,\n AgentProductFilterInput,\n AgentReorderVariantsInput,\n AgentSetInventoryInput,\n AgentUpdateCatalogTagInput,\n AgentUpdateCategoryInput,\n AgentUpdateProductInput,\n AgentUpdateVariantInput,\n AgentVariantDto,\n} from '@avileo/shared/agent-contracts';\nimport type { AgentHttpClient } from './client';\n\nexport interface AgentPage<T> {\n items: T[];\n total: number;\n}\n\nexport interface AgentDeleteResult {\n id: string;\n}\n\nexport interface AgentVariantReorderResult {\n productId: string;\n variantIds: string[];\n}\n\nfunction queryString(input: Record<string, string | number | boolean | undefined>): string {\n const query = new URLSearchParams();\n for (const [key, value] of Object.entries(input)) {\n if (value !== undefined) query.set(key, String(value));\n }\n const serialized = query.toString();\n return serialized ? `?${serialized}` : '';\n}\n\nexport class AgentBusinessResource {\n constructor(private readonly http: AgentHttpClient) {}\n\n get(): Promise<AgentBusinessDto> {\n return this.http.request('/api/v1/agent/business');\n }\n}\n\nexport class AgentProductsResource {\n constructor(private readonly http: AgentHttpClient) {}\n\n list(filters: AgentProductFilterInput = {}): Promise<AgentProductDto[]> {\n return this.http.request(`/api/v1/agent/catalog/products${queryString(filters)}`);\n }\n\n get(productId: string): Promise<AgentProductDto> {\n return this.http.request(`/api/v1/agent/catalog/products/${encodeURIComponent(productId)}`);\n }\n\n create(input: AgentCreateProductInput): Promise<AgentProductDto> {\n return this.http.request('/api/v1/agent/catalog/products', {\n method: 'POST',\n body: input,\n mutation: true,\n });\n }\n\n update(productId: string, input: AgentUpdateProductInput): Promise<AgentProductDto> {\n return this.http.request(`/api/v1/agent/catalog/products/${encodeURIComponent(productId)}`, {\n method: 'PATCH',\n body: input,\n mutation: true,\n });\n }\n\n deactivate(productId: string): Promise<AgentProductDto> {\n return this.http.request(\n `/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/deactivate`,\n { method: 'POST', mutation: true },\n );\n }\n}\n\nexport class AgentVariantsResource {\n constructor(private readonly http: AgentHttpClient) {}\n\n list(productId: string): Promise<AgentVariantDto[]> {\n return this.http.request(\n `/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/variants`,\n );\n }\n\n get(variantId: string): Promise<AgentVariantDto> {\n return this.http.request(`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}`);\n }\n\n create(productId: string, input: AgentCreateVariantInput): Promise<AgentVariantDto> {\n return this.http.request(\n `/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/variants`,\n { method: 'POST', body: input, mutation: true },\n );\n }\n\n update(variantId: string, input: AgentUpdateVariantInput): Promise<AgentVariantDto> {\n return this.http.request(`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}`, {\n method: 'PATCH',\n body: input,\n mutation: true,\n });\n }\n\n deactivate(variantId: string): Promise<AgentVariantDto> {\n return this.http.request(\n `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/deactivate`,\n { method: 'POST', mutation: true },\n );\n }\n\n reorder(productId: string, input: AgentReorderVariantsInput): Promise<AgentVariantReorderResult> {\n return this.http.request(\n `/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/variants/reorder`,\n { method: 'POST', body: input, mutation: true },\n );\n }\n}\n\nexport class AgentCategoriesResource {\n constructor(private readonly http: AgentHttpClient) {}\n\n list(): Promise<AgentCategoryDto[]> {\n return this.http.request('/api/v1/agent/catalog/categories');\n }\n\n get(categoryId: string): Promise<AgentCategoryDto> {\n return this.http.request(`/api/v1/agent/catalog/categories/${encodeURIComponent(categoryId)}`);\n }\n\n create(input: AgentCreateCategoryInput): Promise<AgentCategoryDto> {\n return this.http.request('/api/v1/agent/catalog/categories', {\n method: 'POST',\n body: input,\n mutation: true,\n });\n }\n\n update(categoryId: string, input: AgentUpdateCategoryInput): Promise<AgentCategoryDto> {\n return this.http.request(`/api/v1/agent/catalog/categories/${encodeURIComponent(categoryId)}`, {\n method: 'PATCH',\n body: input,\n mutation: true,\n });\n }\n\n delete(categoryId: string): Promise<AgentDeleteResult> {\n return this.http.request(`/api/v1/agent/catalog/categories/${encodeURIComponent(categoryId)}`, {\n method: 'DELETE',\n mutation: true,\n });\n }\n}\n\nexport class AgentTagsResource {\n constructor(private readonly http: AgentHttpClient) {}\n\n list(): Promise<AgentCatalogTagDto[]> {\n return this.http.request('/api/v1/agent/catalog/tags');\n }\n\n get(tagId: string): Promise<AgentCatalogTagDto> {\n return this.http.request(`/api/v1/agent/catalog/tags/${encodeURIComponent(tagId)}`);\n }\n\n create(input: AgentCreateCatalogTagInput): Promise<AgentCatalogTagDto> {\n return this.http.request('/api/v1/agent/catalog/tags', {\n method: 'POST',\n body: input,\n mutation: true,\n });\n }\n\n update(tagId: string, input: AgentUpdateCatalogTagInput): Promise<AgentCatalogTagDto> {\n return this.http.request(`/api/v1/agent/catalog/tags/${encodeURIComponent(tagId)}`, {\n method: 'PATCH',\n body: input,\n mutation: true,\n });\n }\n\n delete(tagId: string): Promise<AgentDeleteResult> {\n return this.http.request(`/api/v1/agent/catalog/tags/${encodeURIComponent(tagId)}`, {\n method: 'DELETE',\n mutation: true,\n });\n }\n}\n\nexport class AgentAssetsResource {\n constructor(private readonly http: AgentHttpClient) {}\n\n list(filters: AgentAssetFilterInput = {}): Promise<AgentAssetDto[]> {\n return this.http.request(`/api/v1/agent/catalog/assets${queryString(filters)}`);\n }\n\n get(assetId: string): Promise<AgentAssetDto> {\n return this.http.request(`/api/v1/agent/catalog/assets/${encodeURIComponent(assetId)}`);\n }\n\n upload(file: File): Promise<AgentAssetDto> {\n const body = new FormData();\n body.set('file', file);\n return this.http.request('/api/v1/agent/catalog/assets/upload', {\n method: 'POST',\n body,\n mutation: true,\n });\n }\n\n importFromUrl(input: AgentImportAssetFromUrlInput): Promise<AgentAssetDto> {\n return this.http.request('/api/v1/agent/catalog/assets/import', {\n method: 'POST',\n body: input,\n mutation: true,\n });\n }\n}\n\nexport class AgentInventoryResource {\n constructor(private readonly http: AgentHttpClient) {}\n\n get(variantId: string): Promise<AgentInventorySnapshotDto> {\n return this.http.request(\n `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory`,\n );\n }\n\n listMovements(\n variantId: string,\n filters: AgentInventoryMovementFilterInput = {},\n ): Promise<AgentPage<AgentInventoryMovementDto>> {\n return this.http.request(\n `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory/movements${queryString(filters)}`,\n );\n }\n\n adjust(variantId: string, input: AgentAdjustInventoryInput): Promise<AgentInventorySnapshotDto> {\n return this.http.request(\n `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory/adjust`,\n { method: 'POST', body: input, mutation: true },\n );\n }\n\n set(variantId: string, input: AgentSetInventoryInput): Promise<AgentInventorySnapshotDto> {\n return this.http.request(\n `/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory`,\n { method: 'PUT', body: input, mutation: true },\n );\n }\n}\n\nexport class AgentImportsResource {\n constructor(private readonly http: AgentHttpClient) {}\n\n preview(input: AgentCatalogImportPreviewInput): Promise<AgentCatalogImportPreviewDto> {\n return this.http.request('/api/v1/agent/catalog/imports/preview', {\n method: 'POST',\n body: input,\n mutation: true,\n });\n }\n\n apply(importId: string): Promise<AgentCatalogImportResultDto> {\n return this.http.request(`/api/v1/agent/catalog/imports/${encodeURIComponent(importId)}/apply`, {\n method: 'POST',\n mutation: true,\n });\n }\n\n get(importId: string): Promise<AgentCatalogImportResultDto> {\n return this.http.request(`/api/v1/agent/catalog/imports/${encodeURIComponent(importId)}`);\n }\n}\n","import {\n AgentHttpClient,\n AVILEO_AGENT_API_URL,\n type AvileoAgentConfig,\n} from './agent/client';\nimport {\n AgentAssetsResource,\n AgentBusinessResource,\n AgentCategoriesResource,\n AgentImportsResource,\n AgentInventoryResource,\n AgentProductsResource,\n AgentTagsResource,\n AgentVariantsResource,\n} from './agent/resources';\n\nexport { AVILEO_AGENT_API_URL };\n\nexport interface AvileoAgentClient {\n business: AgentBusinessResource;\n products: AgentProductsResource;\n variants: AgentVariantsResource;\n categories: AgentCategoriesResource;\n tags: AgentTagsResource;\n assets: AgentAssetsResource;\n inventory: AgentInventoryResource;\n imports: AgentImportsResource;\n}\n\n/**\n * Creates the server-only facade for an Avileo tenant-agent credential.\n * The credential is retained by the transport closure and is never exposed\n * through this client or accepted by individual resource methods.\n */\nexport function createAvileoAgent(config: AvileoAgentConfig): AvileoAgentClient {\n const http = new AgentHttpClient(config);\n return {\n business: new AgentBusinessResource(http),\n products: new AgentProductsResource(http),\n variants: new AgentVariantsResource(http),\n categories: new AgentCategoriesResource(http),\n tags: new AgentTagsResource(http),\n assets: new AgentAssetsResource(http),\n inventory: new AgentInventoryResource(http),\n imports: new AgentImportsResource(http),\n };\n}\n\nexport type { AvileoAgentConfig };\nexport {\n AgentAuthenticationError,\n AgentConflictError,\n AgentError,\n AgentImportError,\n AgentNetworkError,\n AgentPermissionError,\n AgentQuotaError,\n AgentUnsupportedCapabilityError,\n AgentUnsupportedModeError,\n AgentValidationError,\n} from './agent/errors';\nexport type {\n AgentDeleteResult,\n AgentPage,\n AgentVariantReorderResult,\n} from './agent/resources';\nexport type {\n AgentAdjustInventoryInput,\n AgentAssetDto,\n AgentAssetFilterInput,\n AgentBusinessDto,\n AgentCatalogImportPreviewDto,\n AgentCatalogImportPreviewInput,\n AgentCatalogImportResultDto,\n AgentCatalogTagDto,\n AgentCategoryDto,\n AgentCreateCatalogTagInput,\n AgentCreateCategoryInput,\n AgentCreateProductInput,\n AgentCreateVariantInput,\n AgentImportAssetFromUrlInput,\n AgentInventoryMovementDto,\n AgentInventoryMovementFilterInput,\n AgentInventorySnapshotDto,\n AgentProductDto,\n AgentProductFilterInput,\n AgentReorderVariantsInput,\n AgentSetInventoryInput,\n AgentUpdateCatalogTagInput,\n AgentUpdateCategoryInput,\n AgentUpdateProductInput,\n AgentUpdateVariantInput,\n AgentVariantDto,\n} from '@avileo/shared/agent-contracts';\n","import { createAvileoAgent, type AvileoAgentClient } from '@tarileo/avileo-sdk/agent';\n\nexport type AgentClientFactory = (config: {\n apiKey: string;\n baseUrl?: string;\n}) => AvileoAgentClient;\n\nexport interface CliConfigDependencies {\n env?: NodeJS.ProcessEnv;\n clientFactory?: AgentClientFactory;\n}\n\nexport function createClientFromEnvironment({\n env = process.env,\n clientFactory = createAvileoAgent,\n}: CliConfigDependencies = {}): AvileoAgentClient {\n const apiKey = env.AVILEO_AGENT_API_KEY?.trim();\n if (!apiKey) {\n throw new CliConfigurationError('AVILEO_AGENT_API_KEY es obligatorio');\n }\n\n const baseUrl = env.AVILEO_AGENT_BASE_URL?.trim();\n return clientFactory({ apiKey, ...(baseUrl ? { baseUrl } : {}) });\n}\n\nexport class CliConfigurationError extends Error {\n readonly code = 'CLI_CONFIGURATION_ERROR';\n\n constructor(message: string) {\n super(message);\n this.name = 'CliConfigurationError';\n }\n}\n","export interface CliFailure {\n code: string;\n message: string;\n requestId?: string;\n retryable?: boolean;\n details?: unknown;\n}\n\nexport class CliProtocolError extends Error {\n readonly code: string;\n readonly details?: unknown;\n\n constructor(code: string, message: string, details?: unknown) {\n super(message);\n this.name = 'CliProtocolError';\n this.code = code;\n this.details = details;\n }\n}\n\nexport function emitSuccess(data: unknown): void {\n process.stdout.write(`${JSON.stringify({ version: 1, ok: true, data: redact(data) })}\\n`);\n}\n\nexport function emitFailure(failure: CliFailure): void {\n const error = redact({\n code: failure.code,\n message: failure.message,\n ...(failure.requestId ? { requestId: failure.requestId } : {}),\n ...(failure.retryable === undefined ? {} : { retryable: failure.retryable }),\n ...(failure.details === undefined ? {} : { details: failure.details }),\n }) as CliFailure;\n process.stderr.write(`${JSON.stringify({ version: 1, ok: false, error })}\\n`);\n}\n\nexport function exitCodeFor(error: unknown): number {\n const candidate = error as { code?: string; status?: number; retryable?: boolean };\n if (candidate.retryable) return 2;\n if (candidate.status === 409 || /CONFLICT|IDEMPOTENCY|VERSION/.test(candidate.code ?? '')) return 4;\n if (\n candidate.status === 401 ||\n candidate.status === 403 ||\n candidate.status === 422 ||\n /AUTH|PERMISSION|VALIDATION|UNSUPPORTED|QUOTA|POLICY/.test(candidate.code ?? '')\n ) {\n return 3;\n }\n return 1;\n}\n\nexport function toFailure(error: unknown): CliFailure {\n const candidate = error as {\n code?: unknown;\n message?: unknown;\n requestId?: unknown;\n retryable?: unknown;\n details?: unknown;\n };\n return {\n code: typeof candidate?.code === 'string' ? candidate.code : 'CLI_ERROR',\n message: typeof candidate?.message === 'string' ? candidate.message : 'Error inesperado',\n ...(typeof candidate?.requestId === 'string' ? { requestId: candidate.requestId } : {}),\n ...(typeof candidate?.retryable === 'boolean' ? { retryable: candidate.retryable } : {}),\n ...(candidate?.details === undefined ? {} : { details: candidate.details }),\n };\n}\n\nfunction redact(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(redact);\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>).map(([key, item]) => [\n key,\n /(?:api.?key|authorization|secret|token|password)/i.test(key) ? '[REDACTED]' : redact(item),\n ]),\n );\n }\n return value;\n}\n","import type { Command } from 'commander';\nimport type { AvileoAgentClient } from '@tarileo/avileo-sdk/agent';\nimport { emitSuccess } from '../output';\n\nexport function registerBusinessCommands(root: Command, getClient: () => AvileoAgentClient): void {\n const business = root.command('business').description('Consulta el negocio vinculado a la clave agente');\n business\n .command('show')\n .description('Muestra las capacidades seguras del negocio')\n .action(async () => {\n emitSuccess(await getClient().business.get());\n });\n}\n","import { basename } from 'node:path';\nimport { readFile, stat } from 'node:fs/promises';\nimport type { Command } from 'commander';\nimport type { AvileoAgentClient } from '@tarileo/avileo-sdk/agent';\nimport { CliProtocolError, emitSuccess } from '../output';\n\ntype JsonObject = Record<string, unknown>;\ntype ClientFactory = () => AvileoAgentClient;\n\nfunction requireId(value: string, name: string): string {\n if (!value.trim()) throw new CliProtocolError('CLI_VALIDATION_ERROR', `${name} es obligatorio`);\n return value;\n}\n\nasync function readMutationInput(path: string): Promise<JsonObject> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(await readFile(path, 'utf8'));\n } catch {\n throw new CliProtocolError('CLI_INPUT_ERROR', 'No se pudo leer un objeto JSON desde --from');\n }\n if (!parsed || Array.isArray(parsed) || typeof parsed !== 'object') {\n throw new CliProtocolError('CLI_VALIDATION_ERROR', '--from debe contener un objeto JSON');\n }\n return normalizeInput(parsed as JsonObject);\n}\n\nfunction normalizeInput(value: JsonObject): JsonObject {\n const forbidden: Record<string, true> = {\n businessId: true,\n idempotencyKey: true,\n apiKey: true,\n agentKey: true,\n authorization: true,\n };\n const visit = (item: unknown): unknown => {\n if (Array.isArray(item)) return item.map(visit);\n if (!item || typeof item !== 'object') return item;\n return Object.fromEntries(\n Object.entries(item as JsonObject).map(([key, nested]) => {\n if (\n forbidden[key] ||\n /(?:api.?key|agent.?key|authorization|secret|token|password|idempotency)/i.test(key)\n ) {\n throw new CliProtocolError('CLI_VALIDATION_ERROR', `El campo ${key} no está permitido`);\n }\n return [key, visit(nested)];\n }),\n );\n };\n return visit(value) as JsonObject;\n}\n\nfunction withMutationOptions(command: Command, includeFrom = true): Command {\n if (includeFrom) command.requiredOption('--from <json-file>', 'Objeto JSON estructurado');\n return command.option('--apply', 'Ejecuta la mutación después de validarla localmente');\n}\n\nfunction wantsApply(command: Command): boolean {\n return Boolean(command.optsWithGlobals().apply);\n}\n\nfunction localResult(input: JsonObject, current?: unknown): JsonObject {\n if (current === undefined) return { validated: 'local', input };\n const source = current as Record<string, unknown>;\n const changes = Object.fromEntries(\n Object.entries(input).map(([key, after]) => [key, { before: source[key], after }]),\n );\n return { validated: 'local', current, changes };\n}\n\nfunction addListOptions(command: Command): Command {\n return command\n .option('--search <text>')\n .option('--category-id <id>')\n .option('--active <true|false>', 'Filtra por estado activo', parseBoolean)\n .option('--limit <number>', 'Máximo de resultados', parseInteger)\n .option('--offset <number>', 'Desplazamiento', parseInteger);\n}\n\nfunction parseInteger(value: string): number {\n const result = Number(value);\n if (!Number.isInteger(result) || result < 0) throw new CliProtocolError('CLI_VALIDATION_ERROR', 'Se esperaba un entero no negativo');\n return result;\n}\n\nfunction parseBoolean(value: string): boolean {\n if (value === 'true') return true;\n if (value === 'false') return false;\n throw new CliProtocolError('CLI_VALIDATION_ERROR', 'Se esperaba true o false');\n}\n\nasync function applyOrPreview(\n command: Command,\n input: JsonObject,\n run: () => Promise<unknown>,\n current?: () => Promise<unknown>,\n): Promise<void> {\n if (wantsApply(command)) {\n emitSuccess(await run());\n return;\n }\n emitSuccess(localResult(input, current ? await current() : undefined));\n}\n\nexport function registerCatalogCommands(root: Command, getClient: ClientFactory): void {\n const catalog = root.command('catalog').description('Gestiona recursos de catálogo de Avileo');\n registerProductCommands(catalog, getClient);\n registerVariantCommands(catalog, getClient);\n registerCategoryCommands(catalog, getClient);\n registerTagCommands(catalog, getClient);\n registerAssetCommands(catalog, getClient);\n registerInventoryCommands(catalog, getClient);\n registerImportCommands(catalog, getClient);\n}\n\nfunction registerProductCommands(catalog: Command, getClient: ClientFactory): void {\n const product = catalog.command('product');\n addListOptions(product.command('list')).action(async (options) => {\n const { active: isActive, categoryId, ...filters } = options as JsonObject & { active?: boolean; categoryId?: string };\n emitSuccess(await getClient().products.list({ ...filters, ...(categoryId ? { categoryId } : {}), ...(isActive === undefined ? {} : { isActive }) }));\n });\n product.command('get <productId>').action(async (productId) => emitSuccess(await getClient().products.get(requireId(productId, 'productId'))));\n withMutationOptions(product.command('create')).action(async (options, command) => {\n const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().products.create(input as never));\n });\n withMutationOptions(product.command('update <productId>')).action(async (productId, options, command) => {\n const id = requireId(productId, 'productId'); const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().products.update(id, input as never), () => getClient().products.get(id));\n });\n withMutationOptions(product.command('deactivate <productId>'), false).action(async (productId, _options, command) => {\n const id = requireId(productId, 'productId'); const input = { isActive: false };\n await applyOrPreview(command, input, () => getClient().products.deactivate(id), () => getClient().products.get(id));\n });\n}\n\nfunction registerVariantCommands(catalog: Command, getClient: ClientFactory): void {\n const variant = catalog.command('variant');\n variant.command('list <productId>').action(async (productId) => emitSuccess(await getClient().variants.list(requireId(productId, 'productId'))));\n variant.command('get <variantId>').action(async (variantId) => emitSuccess(await getClient().variants.get(requireId(variantId, 'variantId'))));\n withMutationOptions(variant.command('create <productId>')).action(async (productId, options, command) => {\n const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().variants.create(requireId(productId, 'productId'), input as never));\n });\n withMutationOptions(variant.command('update <variantId>')).action(async (variantId, options, command) => {\n const id = requireId(variantId, 'variantId'); const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().variants.update(id, input as never), () => getClient().variants.get(id));\n });\n withMutationOptions(variant.command('deactivate <variantId>'), false).action(async (variantId, _options, command) => {\n const id = requireId(variantId, 'variantId'); const input = { isActive: false };\n await applyOrPreview(command, input, () => getClient().variants.deactivate(id), () => getClient().variants.get(id));\n });\n withMutationOptions(variant.command('reorder <productId>')).action(async (productId, options, command) => {\n const id = requireId(productId, 'productId'); const input = await readMutationInput(options.from);\n await applyOrPreview(command, input, () => getClient().variants.reorder(id, input as never), () => getClient().variants.list(id));\n });\n}\n\nfunction registerCategoryCommands(catalog: Command, getClient: ClientFactory): void {\n const category = catalog.command('category');\n category.command('list').action(async () => emitSuccess(await getClient().categories.list()));\n category.command('get <categoryId>').action(async (categoryId) => emitSuccess(await getClient().categories.get(requireId(categoryId, 'categoryId'))));\n withMutationOptions(category.command('create')).action(async (options, command) => { const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().categories.create(input as never)); });\n withMutationOptions(category.command('update <categoryId>')).action(async (categoryId, options, command) => { const id = requireId(categoryId, 'categoryId'); const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().categories.update(id, input as never), () => getClient().categories.get(id)); });\n withMutationOptions(category.command('delete <categoryId>'), false).action(async (categoryId, _options, command) => { const id = requireId(categoryId, 'categoryId'); await applyOrPreview(command, { delete: true }, () => getClient().categories.delete(id), () => getClient().categories.get(id)); });\n}\n\nfunction registerTagCommands(catalog: Command, getClient: ClientFactory): void {\n const tag = catalog.command('tag');\n tag.command('list').action(async () => emitSuccess(await getClient().tags.list()));\n tag.command('get <tagId>').action(async (tagId) => emitSuccess(await getClient().tags.get(requireId(tagId, 'tagId'))));\n withMutationOptions(tag.command('create')).action(async (options, command) => { const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().tags.create(input as never)); });\n withMutationOptions(tag.command('update <tagId>')).action(async (tagId, options, command) => { const id = requireId(tagId, 'tagId'); const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().tags.update(id, input as never), () => getClient().tags.get(id)); });\n withMutationOptions(tag.command('delete <tagId>'), false).action(async (tagId, _options, command) => { const id = requireId(tagId, 'tagId'); await applyOrPreview(command, { delete: true }, () => getClient().tags.delete(id), () => getClient().tags.get(id)); });\n}\n\nfunction registerAssetCommands(catalog: Command, getClient: ClientFactory): void {\n const asset = catalog.command('asset');\n asset.command('list').option('--search <text>').option('--limit <number>', 'Máximo de resultados', parseInteger).option('--offset <number>', 'Desplazamiento', parseInteger).action(async (options) => emitSuccess(await getClient().assets.list(options)));\n asset.command('get <assetId>').action(async (assetId) => emitSuccess(await getClient().assets.get(requireId(assetId, 'assetId'))));\n asset.command('upload').requiredOption('--file <path>', 'Archivo local').option('--apply', 'Sube el archivo').action(async (options, command) => {\n const filePath = options.file as string; const fileStat = await stat(filePath); if (!fileStat.isFile()) throw new CliProtocolError('CLI_VALIDATION_ERROR', '--file debe apuntar a un archivo');\n if (!wantsApply(command)) { emitSuccess({ validated: 'local', file: basename(filePath), sizeBytes: fileStat.size }); return; }\n const file = new File([await readFile(filePath)], basename(filePath)); emitSuccess(await getClient().assets.upload(file));\n });\n withMutationOptions(asset.command('import-url')).action(async (options, command) => { const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().assets.importFromUrl(input as never)); });\n}\n\nfunction registerInventoryCommands(catalog: Command, getClient: ClientFactory): void {\n const inventory = catalog.command('inventory');\n inventory.command('get <variantId>').action(async (variantId) => emitSuccess(await getClient().inventory.get(requireId(variantId, 'variantId'))));\n inventory.command('movements <variantId>').option('--reason <reason>').option('--limit <number>', 'Máximo de resultados', parseInteger).option('--offset <number>', 'Desplazamiento', parseInteger).action(async (variantId, options) => emitSuccess(await getClient().inventory.listMovements(requireId(variantId, 'variantId'), options)));\n withMutationOptions(inventory.command('adjust <variantId>')).action(async (variantId, options, command) => { const id = requireId(variantId, 'variantId'); const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().inventory.adjust(id, input as never), () => getClient().inventory.get(id)); });\n withMutationOptions(inventory.command('set <variantId>')).action(async (variantId, options, command) => { const id = requireId(variantId, 'variantId'); const input = await readMutationInput(options.from); await applyOrPreview(command, input, () => getClient().inventory.set(id, input as never), () => getClient().inventory.get(id)); });\n}\n\nasync function resolveLocalFileSources(value: unknown, client: AvileoAgentClient): Promise<unknown> {\n if (Array.isArray(value)) return Promise.all(value.map((item) => resolveLocalFileSources(item, client)));\n if (!value || typeof value !== 'object') return value;\n\n const source = value as JsonObject;\n if (source.kind === 'file') {\n if (typeof source.path !== 'string' || Object.keys(source).length !== 2) {\n throw new CliProtocolError(\n 'CLI_VALIDATION_ERROR',\n 'Una imagen local debe tener exactamente kind: \"file\" y path',\n );\n }\n const fileStat = await stat(source.path);\n if (!fileStat.isFile()) {\n throw new CliProtocolError('CLI_VALIDATION_ERROR', 'La ruta de imagen local debe apuntar a un archivo');\n }\n const asset = await client.assets.upload(\n new File([await readFile(source.path)], basename(source.path)),\n );\n return { kind: 'asset', assetId: asset.id };\n }\n\n return Object.fromEntries(\n await Promise.all(\n Object.entries(source).map(async ([key, nested]) => [\n key,\n await resolveLocalFileSources(nested, client),\n ]),\n ),\n );\n}\n\nfunction registerImportCommands(catalog: Command, getClient: ClientFactory): void {\n const imports = catalog.command('import');\n imports.command('preview').requiredOption('--from <json-file>', 'Lista estructurada para vista previa').action(async (options) => {\n const input = await readMutationInput(options.from);\n const normalizedInput = await resolveLocalFileSources(input, getClient()) as JsonObject;\n emitSuccess(await getClient().imports.preview(normalizedInput as never));\n });\n imports.command('apply <importId>').option('--apply', 'Encola la importación aprobada').action(async (importId, _options, command) => {\n const id = requireId(importId, 'importId');\n if (!wantsApply(command)) { emitSuccess({ validated: 'local', importId: id, action: 'apply' }); return; }\n emitSuccess(await getClient().imports.apply(id));\n });\n imports.command('status <importId>').action(async (importId) => emitSuccess(await getClient().imports.get(requireId(importId, 'importId'))));\n}\n","#!/usr/bin/env node\nimport { createProgram } from './program';\n\ncreateProgram().parseAsync(process.argv);\n"],"mappings":";;;AAAA,SAAS,SAAS,sBAAsB;;;ACSjC,IAAM,aAAN,cAAyB,MAAM;EAC3B;EACA;EACA;EACA;EACA;EAET,YAAY,SAAiB,SAA4B;AACvD,UAAM,OAAO;AACb,SAAK,OAAO,WAAW;AACvB,SAAK,OAAO,QAAQ;AACpB,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ;AACvB,SAAK,YAAY,QAAQ;AACzB,SAAK,YAAY,QAAQ,aAAa;EACxC;AACF;AAEO,IAAM,2BAAN,cAAuC,WAAW;AAAC;AACnD,IAAM,uBAAN,cAAmC,WAAW;AAAC;AAC/C,IAAM,4BAAN,cAAwC,WAAW;AAAC;AACpD,IAAM,kCAAN,cAA8C,WAAW;AAAC;AAC1D,IAAM,uBAAN,cAAmC,WAAW;AAAC;AAC/C,IAAM,qBAAN,cAAiC,WAAW;AAAC;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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarileo/avileo-catalog-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Safe command-line client for Avileo tenant catalog agents",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,10 +29,10 @@
29
29
  "node": ">=20"
30
30
  },
31
31
  "dependencies": {
32
- "@tarileo/avileo-sdk": "workspace:*",
33
32
  "commander": "^12.1.0"
34
33
  },
35
34
  "devDependencies": {
35
+ "@tarileo/avileo-sdk": "workspace:*",
36
36
  "@types/node": "^20.10.0",
37
37
  "tsup": "^8.5.1",
38
38
  "typescript": "^5",