@tarileo/avileo-catalog-cli 0.2.2 → 0.3.1
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 +24 -8
- package/dist/index.js +759 -193
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14675,6 +14675,7 @@ var AgentHttpClient = class {
|
|
|
14675
14675
|
headers: {
|
|
14676
14676
|
...formData || options.body === void 0 ? {} : { "content-type": "application/json" },
|
|
14677
14677
|
...operationId ? { "idempotency-key": operationId } : {},
|
|
14678
|
+
...options.approvalId ? { "x-avileo-approval-id": options.approvalId } : {},
|
|
14678
14679
|
...this.#apiKey ? { "x-avileo-agent-key": this.#apiKey } : {}
|
|
14679
14680
|
},
|
|
14680
14681
|
body,
|
|
@@ -14728,16 +14729,19 @@ var AGENT_CAPABILITY_ACTIONS = [
|
|
|
14728
14729
|
"assets:read",
|
|
14729
14730
|
"assets:write",
|
|
14730
14731
|
"inventory:read",
|
|
14731
|
-
"inventory:write"
|
|
14732
|
+
"inventory:write",
|
|
14733
|
+
"payments:read",
|
|
14734
|
+
"payments:write"
|
|
14732
14735
|
];
|
|
14733
14736
|
var AgentCapabilityActionSchema = external_exports.enum(AGENT_CAPABILITY_ACTIONS);
|
|
14734
|
-
var
|
|
14737
|
+
var AGENT_KEY_MODES = ["read", "mutate"];
|
|
14738
|
+
var AgentKeyModeSchema = external_exports.enum(AGENT_KEY_MODES);
|
|
14739
|
+
var AGENT_KEY_READ_ACTIONS = [
|
|
14735
14740
|
"business:read",
|
|
14736
14741
|
"catalog:read",
|
|
14737
|
-
"catalog:write",
|
|
14738
14742
|
"assets:read",
|
|
14739
|
-
"
|
|
14740
|
-
"
|
|
14743
|
+
"inventory:read",
|
|
14744
|
+
"payments:read"
|
|
14741
14745
|
];
|
|
14742
14746
|
var AgentGrantedActionsSchema = external_exports.array(AgentCapabilityActionSchema).min(1).max(AGENT_CAPABILITY_ACTIONS.length).refine((actions) => new Set(actions).size === actions.length, {
|
|
14743
14747
|
message: "Las capacidades no pueden repetirse"
|
|
@@ -14909,7 +14913,7 @@ var AgentStorefrontDtoSchema = external_exports.object({
|
|
|
14909
14913
|
}).strict();
|
|
14910
14914
|
var AgentBusinessDtoSchema = external_exports.object({
|
|
14911
14915
|
name: nonEmptyTextSchema.max(255),
|
|
14912
|
-
businessMode: external_exports.
|
|
14916
|
+
businessMode: external_exports.string().trim().min(1).max(50),
|
|
14913
14917
|
currency: external_exports.string().trim().length(3),
|
|
14914
14918
|
isActive: external_exports.literal(true),
|
|
14915
14919
|
tenantState: external_exports.literal("active"),
|
|
@@ -15140,14 +15144,178 @@ var AgentCatalogImportResultDtoSchema = external_exports.object({
|
|
|
15140
15144
|
updatedAt: timestampSchema,
|
|
15141
15145
|
completedAt: timestampSchema.nullable()
|
|
15142
15146
|
}).strict();
|
|
15147
|
+
var AGENT_OPERATION_NAMES = [
|
|
15148
|
+
"catalog.products.create",
|
|
15149
|
+
"catalog.products.update",
|
|
15150
|
+
"catalog.products.deactivate",
|
|
15151
|
+
"catalog.variants.create",
|
|
15152
|
+
"catalog.variants.reorder",
|
|
15153
|
+
"catalog.variants.update",
|
|
15154
|
+
"catalog.variants.deactivate",
|
|
15155
|
+
"catalog.categories.create",
|
|
15156
|
+
"catalog.categories.update",
|
|
15157
|
+
"catalog.categories.delete",
|
|
15158
|
+
"catalog.tags.create",
|
|
15159
|
+
"catalog.tags.update",
|
|
15160
|
+
"catalog.tags.delete",
|
|
15161
|
+
"catalog.assets.upload",
|
|
15162
|
+
"catalog.assets.import",
|
|
15163
|
+
"catalog.inventory.adjust",
|
|
15164
|
+
"catalog.inventory.set",
|
|
15165
|
+
"catalog.imports.preview",
|
|
15166
|
+
"catalog.imports.apply",
|
|
15167
|
+
"business.profile.update",
|
|
15168
|
+
"catalog.client_keys.create"
|
|
15169
|
+
];
|
|
15170
|
+
var AgentOperationNameSchema = external_exports.enum(AGENT_OPERATION_NAMES);
|
|
15171
|
+
var AGENT_OPERATION_STATES = [
|
|
15172
|
+
"awaiting_approval",
|
|
15173
|
+
"approved",
|
|
15174
|
+
"rejected",
|
|
15175
|
+
"succeeded",
|
|
15176
|
+
"failed",
|
|
15177
|
+
"expired",
|
|
15178
|
+
"conflict"
|
|
15179
|
+
];
|
|
15180
|
+
var AgentOperationStateSchema = external_exports.enum(AGENT_OPERATION_STATES);
|
|
15181
|
+
var AgentOperationProposalInputSchema = external_exports.object({
|
|
15182
|
+
operationName: AgentOperationNameSchema,
|
|
15183
|
+
payload: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
15184
|
+
}).strict();
|
|
15185
|
+
var AgentOperationProposalDtoSchema = external_exports.object({
|
|
15186
|
+
id: uuidSchema,
|
|
15187
|
+
operationName: AgentOperationNameSchema,
|
|
15188
|
+
state: external_exports.literal("awaiting_approval"),
|
|
15189
|
+
input: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
15190
|
+
summary: nonEmptyTextSchema.max(500),
|
|
15191
|
+
diff: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
15192
|
+
approvalUrl: external_exports.string().url(),
|
|
15193
|
+
createdAt: timestampSchema,
|
|
15194
|
+
expiresAt: timestampSchema
|
|
15195
|
+
}).strict();
|
|
15196
|
+
var AgentOperationStatusDtoSchema = external_exports.object({
|
|
15197
|
+
id: uuidSchema,
|
|
15198
|
+
operationName: AgentOperationNameSchema,
|
|
15199
|
+
state: AgentOperationStateSchema,
|
|
15200
|
+
input: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
15201
|
+
summary: nonEmptyTextSchema.max(500),
|
|
15202
|
+
diff: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
15203
|
+
approvalUrl: external_exports.string().url(),
|
|
15204
|
+
result: external_exports.record(external_exports.string(), external_exports.unknown()).nullable(),
|
|
15205
|
+
error: external_exports.record(external_exports.string(), external_exports.unknown()).nullable(),
|
|
15206
|
+
approvedAt: timestampSchema.nullable(),
|
|
15207
|
+
rejectedAt: timestampSchema.nullable(),
|
|
15208
|
+
completedAt: timestampSchema.nullable(),
|
|
15209
|
+
createdAt: timestampSchema,
|
|
15210
|
+
updatedAt: timestampSchema,
|
|
15211
|
+
expiresAt: timestampSchema
|
|
15212
|
+
}).strict();
|
|
15213
|
+
var AgentOperationProposalEnvelopeSchema = external_exports.object({
|
|
15214
|
+
success: external_exports.literal(true),
|
|
15215
|
+
data: AgentOperationProposalDtoSchema
|
|
15216
|
+
}).strict();
|
|
15217
|
+
var AgentOperationStatusEnvelopeSchema = external_exports.object({
|
|
15218
|
+
success: external_exports.literal(true),
|
|
15219
|
+
data: AgentOperationStatusDtoSchema
|
|
15220
|
+
}).strict();
|
|
15221
|
+
var AgentOperationApplyEnvelopeSchema = external_exports.object({
|
|
15222
|
+
success: external_exports.literal(true),
|
|
15223
|
+
data: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
15224
|
+
}).strict();
|
|
15225
|
+
var AGENT_PAYMENT_LINK_STATUSES = [
|
|
15226
|
+
"awaiting_payment",
|
|
15227
|
+
"verifying",
|
|
15228
|
+
"under_review",
|
|
15229
|
+
"confirmed",
|
|
15230
|
+
"rejected",
|
|
15231
|
+
"expired",
|
|
15232
|
+
"cancelled"
|
|
15233
|
+
];
|
|
15234
|
+
var AgentPaymentLinkStatusSchema = external_exports.enum(AGENT_PAYMENT_LINK_STATUSES);
|
|
15235
|
+
var AGENT_PAYMENT_LINK_EXPECTED_METHODS = [
|
|
15236
|
+
"yape",
|
|
15237
|
+
"plin",
|
|
15238
|
+
"transferencia",
|
|
15239
|
+
"any"
|
|
15240
|
+
];
|
|
15241
|
+
var AgentPaymentLinkExpectedMethodSchema = external_exports.enum(AGENT_PAYMENT_LINK_EXPECTED_METHODS);
|
|
15242
|
+
var AGENT_PAYMENT_LINK_CONFIRMED_BY = ["ai", "gateway", "manual", "platform"];
|
|
15243
|
+
var AgentPaymentLinkConfirmedBySchema = external_exports.enum(AGENT_PAYMENT_LINK_CONFIRMED_BY);
|
|
15244
|
+
var AgentPaymentLinkExtractionDtoSchema = external_exports.object({
|
|
15245
|
+
provider: external_exports.enum(["yape", "plin", "bbva_transfer", "unknown"]),
|
|
15246
|
+
/** Detected amount in soles (major units), or null when illegible. */
|
|
15247
|
+
detectedAmount: external_exports.number().nonnegative().multipleOf(0.01).nullable(),
|
|
15248
|
+
currency: external_exports.string().length(3).nullable(),
|
|
15249
|
+
operationNumber: external_exports.string().nullable(),
|
|
15250
|
+
paidAt: timestampSchema.nullable(),
|
|
15251
|
+
payerName: external_exports.string().nullable(),
|
|
15252
|
+
recipientName: external_exports.string().nullable(),
|
|
15253
|
+
confidence: external_exports.enum(["high", "medium", "low"]),
|
|
15254
|
+
signals: external_exports.array(external_exports.string())
|
|
15255
|
+
}).strict();
|
|
15256
|
+
var AgentCreatePaymentLinkInputSchema = external_exports.object({
|
|
15257
|
+
/** Amount in soles (major units); the backend stores amountMinor. */
|
|
15258
|
+
amount: external_exports.number().positive().multipleOf(0.01).max(1e6),
|
|
15259
|
+
currency: external_exports.string().trim().length(3).optional(),
|
|
15260
|
+
concept: nonEmptyTextSchema.max(200).optional(),
|
|
15261
|
+
expectedMethod: AgentPaymentLinkExpectedMethodSchema.optional(),
|
|
15262
|
+
expiresInHours: external_exports.number().int().min(1).max(720).optional(),
|
|
15263
|
+
customerPhone: nonEmptyTextSchema.max(20).optional(),
|
|
15264
|
+
idempotencyKey: nonEmptyTextSchema.max(80).optional()
|
|
15265
|
+
}).strict();
|
|
15266
|
+
var AgentPaymentLinkBaseDtoSchema = external_exports.object({
|
|
15267
|
+
id: uuidSchema,
|
|
15268
|
+
/** Requested amount in soles (major units). */
|
|
15269
|
+
amount: external_exports.number().positive().multipleOf(0.01),
|
|
15270
|
+
currency: external_exports.string().length(3),
|
|
15271
|
+
concept: external_exports.string().nullable(),
|
|
15272
|
+
expectedMethod: AgentPaymentLinkExpectedMethodSchema,
|
|
15273
|
+
status: AgentPaymentLinkStatusSchema,
|
|
15274
|
+
confirmedBy: AgentPaymentLinkConfirmedBySchema.nullable(),
|
|
15275
|
+
extraction: AgentPaymentLinkExtractionDtoSchema.nullable(),
|
|
15276
|
+
expiresAt: timestampSchema,
|
|
15277
|
+
createdAt: timestampSchema,
|
|
15278
|
+
confirmedAt: timestampSchema.nullable().optional()
|
|
15279
|
+
}).strict();
|
|
15280
|
+
var AgentPaymentLinkDtoSchema = AgentPaymentLinkBaseDtoSchema.extend({
|
|
15281
|
+
/** Persisted links can never recover the plaintext token URL. */
|
|
15282
|
+
url: external_exports.null()
|
|
15283
|
+
}).strict();
|
|
15284
|
+
var AgentCreatedPaymentLinkDtoSchema = external_exports.discriminatedUnion("replayed", [
|
|
15285
|
+
AgentPaymentLinkBaseDtoSchema.extend({
|
|
15286
|
+
url: external_exports.string().url(),
|
|
15287
|
+
replayed: external_exports.literal(false)
|
|
15288
|
+
}).strict(),
|
|
15289
|
+
AgentPaymentLinkBaseDtoSchema.extend({
|
|
15290
|
+
url: external_exports.null(),
|
|
15291
|
+
replayed: external_exports.literal(true)
|
|
15292
|
+
}).strict()
|
|
15293
|
+
]);
|
|
15294
|
+
var isoDateOrTimestampSchema = external_exports.union([
|
|
15295
|
+
external_exports.string().date(),
|
|
15296
|
+
external_exports.string().datetime({ offset: true })
|
|
15297
|
+
]);
|
|
15298
|
+
var AgentPaymentLinkFilterInputSchema = AgentPaginationInputSchema.extend({
|
|
15299
|
+
status: AgentPaymentLinkStatusSchema.optional(),
|
|
15300
|
+
from: isoDateOrTimestampSchema.optional(),
|
|
15301
|
+
to: isoDateOrTimestampSchema.optional()
|
|
15302
|
+
}).strict();
|
|
15303
|
+
var AgentPaymentLinkPageSchema = external_exports.object({
|
|
15304
|
+
items: external_exports.array(AgentPaymentLinkDtoSchema),
|
|
15305
|
+
total: external_exports.number().int().nonnegative()
|
|
15306
|
+
}).strict();
|
|
15143
15307
|
var AGENT_DEVICE_AUTH_STATUSES = ["pending", "approved", "denied", "expired"];
|
|
15144
|
-
var AGENT_DEVICE_AUTH_DEFAULT_PERMISSIONS = [
|
|
15308
|
+
var AGENT_DEVICE_AUTH_DEFAULT_PERMISSIONS = [
|
|
15309
|
+
...AGENT_KEY_READ_ACTIONS
|
|
15310
|
+
];
|
|
15145
15311
|
function parsePollResponse(value) {
|
|
15146
15312
|
if (!AGENT_DEVICE_AUTH_STATUSES.includes(value.status)) {
|
|
15147
15313
|
throw new Error("La API de Avileo devolvi\xF3 un estado de autorizaci\xF3n inv\xE1lido");
|
|
15148
15314
|
}
|
|
15149
15315
|
if (value.permissions) {
|
|
15150
|
-
const parsed = value.permissions.map(
|
|
15316
|
+
const parsed = value.permissions.map(
|
|
15317
|
+
(permission) => AgentCapabilityActionSchema.parse(permission)
|
|
15318
|
+
);
|
|
15151
15319
|
return { ...value, permissions: parsed };
|
|
15152
15320
|
}
|
|
15153
15321
|
return value;
|
|
@@ -15165,10 +15333,13 @@ var AvileoAgentDeviceAuthClient = class {
|
|
|
15165
15333
|
}
|
|
15166
15334
|
async poll(deviceCode) {
|
|
15167
15335
|
if (!deviceCode.trim()) throw new Error("deviceCode es obligatorio");
|
|
15168
|
-
const result = await this.http.request(
|
|
15169
|
-
|
|
15170
|
-
|
|
15171
|
-
|
|
15336
|
+
const result = await this.http.request(
|
|
15337
|
+
"/api/v1/agent-auth/device/poll",
|
|
15338
|
+
{
|
|
15339
|
+
method: "POST",
|
|
15340
|
+
body: { deviceCode }
|
|
15341
|
+
}
|
|
15342
|
+
);
|
|
15172
15343
|
return parsePollResponse(result);
|
|
15173
15344
|
}
|
|
15174
15345
|
};
|
|
@@ -15191,6 +15362,9 @@ var AgentBusinessResource = class {
|
|
|
15191
15362
|
get() {
|
|
15192
15363
|
return this.http.request("/api/v1/agent/business");
|
|
15193
15364
|
}
|
|
15365
|
+
profile() {
|
|
15366
|
+
return this.http.request("/api/v1/agent/business/profile");
|
|
15367
|
+
}
|
|
15194
15368
|
};
|
|
15195
15369
|
var AgentProductsResource = class {
|
|
15196
15370
|
constructor(http) {
|
|
@@ -15203,24 +15377,26 @@ var AgentProductsResource = class {
|
|
|
15203
15377
|
get(productId) {
|
|
15204
15378
|
return this.http.request(`/api/v1/agent/catalog/products/${encodeURIComponent(productId)}`);
|
|
15205
15379
|
}
|
|
15206
|
-
create(input) {
|
|
15380
|
+
create(input, approvalId) {
|
|
15207
15381
|
return this.http.request("/api/v1/agent/catalog/products", {
|
|
15208
15382
|
method: "POST",
|
|
15209
15383
|
body: input,
|
|
15210
|
-
mutation: true
|
|
15384
|
+
mutation: true,
|
|
15385
|
+
approvalId
|
|
15211
15386
|
});
|
|
15212
15387
|
}
|
|
15213
|
-
update(productId, input) {
|
|
15388
|
+
update(productId, input, approvalId) {
|
|
15214
15389
|
return this.http.request(`/api/v1/agent/catalog/products/${encodeURIComponent(productId)}`, {
|
|
15215
15390
|
method: "PATCH",
|
|
15216
15391
|
body: input,
|
|
15217
|
-
mutation: true
|
|
15392
|
+
mutation: true,
|
|
15393
|
+
approvalId
|
|
15218
15394
|
});
|
|
15219
15395
|
}
|
|
15220
|
-
deactivate(productId) {
|
|
15396
|
+
deactivate(productId, approvalId) {
|
|
15221
15397
|
return this.http.request(
|
|
15222
15398
|
`/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/deactivate`,
|
|
15223
|
-
{ method: "POST", mutation: true }
|
|
15399
|
+
{ method: "POST", mutation: true, approvalId }
|
|
15224
15400
|
);
|
|
15225
15401
|
}
|
|
15226
15402
|
};
|
|
@@ -15237,29 +15413,30 @@ var AgentVariantsResource = class {
|
|
|
15237
15413
|
get(variantId) {
|
|
15238
15414
|
return this.http.request(`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}`);
|
|
15239
15415
|
}
|
|
15240
|
-
create(productId, input) {
|
|
15416
|
+
create(productId, input, approvalId) {
|
|
15241
15417
|
return this.http.request(
|
|
15242
15418
|
`/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/variants`,
|
|
15243
|
-
{ method: "POST", body: input, mutation: true }
|
|
15419
|
+
{ method: "POST", body: input, mutation: true, approvalId }
|
|
15244
15420
|
);
|
|
15245
15421
|
}
|
|
15246
|
-
update(variantId, input) {
|
|
15422
|
+
update(variantId, input, approvalId) {
|
|
15247
15423
|
return this.http.request(`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}`, {
|
|
15248
15424
|
method: "PATCH",
|
|
15249
15425
|
body: input,
|
|
15250
|
-
mutation: true
|
|
15426
|
+
mutation: true,
|
|
15427
|
+
approvalId
|
|
15251
15428
|
});
|
|
15252
15429
|
}
|
|
15253
|
-
deactivate(variantId) {
|
|
15430
|
+
deactivate(variantId, approvalId) {
|
|
15254
15431
|
return this.http.request(
|
|
15255
15432
|
`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/deactivate`,
|
|
15256
|
-
{ method: "POST", mutation: true }
|
|
15433
|
+
{ method: "POST", mutation: true, approvalId }
|
|
15257
15434
|
);
|
|
15258
15435
|
}
|
|
15259
|
-
reorder(productId, input) {
|
|
15436
|
+
reorder(productId, input, approvalId) {
|
|
15260
15437
|
return this.http.request(
|
|
15261
15438
|
`/api/v1/agent/catalog/products/${encodeURIComponent(productId)}/variants/reorder`,
|
|
15262
|
-
{ method: "POST", body: input, mutation: true }
|
|
15439
|
+
{ method: "POST", body: input, mutation: true, approvalId }
|
|
15263
15440
|
);
|
|
15264
15441
|
}
|
|
15265
15442
|
};
|
|
@@ -15274,24 +15451,27 @@ var AgentCategoriesResource = class {
|
|
|
15274
15451
|
get(categoryId) {
|
|
15275
15452
|
return this.http.request(`/api/v1/agent/catalog/categories/${encodeURIComponent(categoryId)}`);
|
|
15276
15453
|
}
|
|
15277
|
-
create(input) {
|
|
15454
|
+
create(input, approvalId) {
|
|
15278
15455
|
return this.http.request("/api/v1/agent/catalog/categories", {
|
|
15279
15456
|
method: "POST",
|
|
15280
15457
|
body: input,
|
|
15281
|
-
mutation: true
|
|
15458
|
+
mutation: true,
|
|
15459
|
+
approvalId
|
|
15282
15460
|
});
|
|
15283
15461
|
}
|
|
15284
|
-
update(categoryId, input) {
|
|
15462
|
+
update(categoryId, input, approvalId) {
|
|
15285
15463
|
return this.http.request(`/api/v1/agent/catalog/categories/${encodeURIComponent(categoryId)}`, {
|
|
15286
15464
|
method: "PATCH",
|
|
15287
15465
|
body: input,
|
|
15288
|
-
mutation: true
|
|
15466
|
+
mutation: true,
|
|
15467
|
+
approvalId
|
|
15289
15468
|
});
|
|
15290
15469
|
}
|
|
15291
|
-
delete(categoryId) {
|
|
15470
|
+
delete(categoryId, approvalId) {
|
|
15292
15471
|
return this.http.request(`/api/v1/agent/catalog/categories/${encodeURIComponent(categoryId)}`, {
|
|
15293
15472
|
method: "DELETE",
|
|
15294
|
-
mutation: true
|
|
15473
|
+
mutation: true,
|
|
15474
|
+
approvalId
|
|
15295
15475
|
});
|
|
15296
15476
|
}
|
|
15297
15477
|
};
|
|
@@ -15306,24 +15486,27 @@ var AgentTagsResource = class {
|
|
|
15306
15486
|
get(tagId) {
|
|
15307
15487
|
return this.http.request(`/api/v1/agent/catalog/tags/${encodeURIComponent(tagId)}`);
|
|
15308
15488
|
}
|
|
15309
|
-
create(input) {
|
|
15489
|
+
create(input, approvalId) {
|
|
15310
15490
|
return this.http.request("/api/v1/agent/catalog/tags", {
|
|
15311
15491
|
method: "POST",
|
|
15312
15492
|
body: input,
|
|
15313
|
-
mutation: true
|
|
15493
|
+
mutation: true,
|
|
15494
|
+
approvalId
|
|
15314
15495
|
});
|
|
15315
15496
|
}
|
|
15316
|
-
update(tagId, input) {
|
|
15497
|
+
update(tagId, input, approvalId) {
|
|
15317
15498
|
return this.http.request(`/api/v1/agent/catalog/tags/${encodeURIComponent(tagId)}`, {
|
|
15318
15499
|
method: "PATCH",
|
|
15319
15500
|
body: input,
|
|
15320
|
-
mutation: true
|
|
15501
|
+
mutation: true,
|
|
15502
|
+
approvalId
|
|
15321
15503
|
});
|
|
15322
15504
|
}
|
|
15323
|
-
delete(tagId) {
|
|
15505
|
+
delete(tagId, approvalId) {
|
|
15324
15506
|
return this.http.request(`/api/v1/agent/catalog/tags/${encodeURIComponent(tagId)}`, {
|
|
15325
15507
|
method: "DELETE",
|
|
15326
|
-
mutation: true
|
|
15508
|
+
mutation: true,
|
|
15509
|
+
approvalId
|
|
15327
15510
|
});
|
|
15328
15511
|
}
|
|
15329
15512
|
};
|
|
@@ -15338,20 +15521,22 @@ var AgentAssetsResource = class {
|
|
|
15338
15521
|
get(assetId) {
|
|
15339
15522
|
return this.http.request(`/api/v1/agent/catalog/assets/${encodeURIComponent(assetId)}`);
|
|
15340
15523
|
}
|
|
15341
|
-
upload(file2) {
|
|
15524
|
+
upload(file2, approvalId) {
|
|
15342
15525
|
const body = new FormData();
|
|
15343
15526
|
body.set("file", file2);
|
|
15344
15527
|
return this.http.request("/api/v1/agent/catalog/assets/upload", {
|
|
15345
15528
|
method: "POST",
|
|
15346
15529
|
body,
|
|
15347
|
-
mutation: true
|
|
15530
|
+
mutation: true,
|
|
15531
|
+
approvalId
|
|
15348
15532
|
});
|
|
15349
15533
|
}
|
|
15350
|
-
importFromUrl(input) {
|
|
15534
|
+
importFromUrl(input, approvalId) {
|
|
15351
15535
|
return this.http.request("/api/v1/agent/catalog/assets/import", {
|
|
15352
15536
|
method: "POST",
|
|
15353
15537
|
body: input,
|
|
15354
|
-
mutation: true
|
|
15538
|
+
mutation: true,
|
|
15539
|
+
approvalId
|
|
15355
15540
|
});
|
|
15356
15541
|
}
|
|
15357
15542
|
};
|
|
@@ -15370,16 +15555,16 @@ var AgentInventoryResource = class {
|
|
|
15370
15555
|
`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory/movements${queryString(filters)}`
|
|
15371
15556
|
);
|
|
15372
15557
|
}
|
|
15373
|
-
adjust(variantId, input) {
|
|
15558
|
+
adjust(variantId, input, approvalId) {
|
|
15374
15559
|
return this.http.request(
|
|
15375
15560
|
`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory/adjust`,
|
|
15376
|
-
{ method: "POST", body: input, mutation: true }
|
|
15561
|
+
{ method: "POST", body: input, mutation: true, approvalId }
|
|
15377
15562
|
);
|
|
15378
15563
|
}
|
|
15379
|
-
set(variantId, input) {
|
|
15564
|
+
set(variantId, input, approvalId) {
|
|
15380
15565
|
return this.http.request(
|
|
15381
15566
|
`/api/v1/agent/catalog/variants/${encodeURIComponent(variantId)}/inventory`,
|
|
15382
|
-
{ method: "PUT", body: input, mutation: true }
|
|
15567
|
+
{ method: "PUT", body: input, mutation: true, approvalId }
|
|
15383
15568
|
);
|
|
15384
15569
|
}
|
|
15385
15570
|
};
|
|
@@ -15395,27 +15580,88 @@ var AgentImportsResource = class {
|
|
|
15395
15580
|
mutation: true
|
|
15396
15581
|
});
|
|
15397
15582
|
}
|
|
15398
|
-
apply(importId) {
|
|
15399
|
-
return this.http.request(
|
|
15583
|
+
apply(importId, approvalId) {
|
|
15584
|
+
return this.http.request(
|
|
15585
|
+
`/api/v1/agent/catalog/imports/${encodeURIComponent(importId)}/apply`,
|
|
15586
|
+
{
|
|
15587
|
+
method: "POST",
|
|
15588
|
+
mutation: true,
|
|
15589
|
+
approvalId
|
|
15590
|
+
}
|
|
15591
|
+
);
|
|
15592
|
+
}
|
|
15593
|
+
get(importId) {
|
|
15594
|
+
return this.http.request(`/api/v1/agent/catalog/imports/${encodeURIComponent(importId)}`);
|
|
15595
|
+
}
|
|
15596
|
+
};
|
|
15597
|
+
var AgentOperationsResource = class {
|
|
15598
|
+
constructor(http) {
|
|
15599
|
+
this.http = http;
|
|
15600
|
+
}
|
|
15601
|
+
http;
|
|
15602
|
+
propose(input) {
|
|
15603
|
+
return this.http.request("/api/v1/agent/operations", {
|
|
15400
15604
|
method: "POST",
|
|
15605
|
+
body: input,
|
|
15401
15606
|
mutation: true
|
|
15402
15607
|
});
|
|
15403
15608
|
}
|
|
15404
|
-
|
|
15405
|
-
return this.
|
|
15609
|
+
proposeClientKey(name) {
|
|
15610
|
+
return this.propose({
|
|
15611
|
+
operationName: "catalog.client_keys.create",
|
|
15612
|
+
payload: name === void 0 ? {} : { name }
|
|
15613
|
+
});
|
|
15614
|
+
}
|
|
15615
|
+
get(operationId) {
|
|
15616
|
+
return this.http.request(`/api/v1/agent/operations/${encodeURIComponent(operationId)}`);
|
|
15617
|
+
}
|
|
15618
|
+
apply(operationId) {
|
|
15619
|
+
return this.http.request(`/api/v1/agent/operations/${encodeURIComponent(operationId)}/apply`, {
|
|
15620
|
+
method: "POST",
|
|
15621
|
+
mutation: true,
|
|
15622
|
+
approvalId: operationId
|
|
15623
|
+
});
|
|
15624
|
+
}
|
|
15625
|
+
};
|
|
15626
|
+
var AgentPaymentLinksResource = class {
|
|
15627
|
+
constructor(http) {
|
|
15628
|
+
this.http = http;
|
|
15629
|
+
}
|
|
15630
|
+
http;
|
|
15631
|
+
/**
|
|
15632
|
+
* Creates a payment link. `amount` is in soles (major units); the backend
|
|
15633
|
+
* converts it to minor units — never convert it here. The URL is only
|
|
15634
|
+
* non-null for the initial create response.
|
|
15635
|
+
*/
|
|
15636
|
+
create(input) {
|
|
15637
|
+
return this.http.request("/api/v1/agent/payment-links", {
|
|
15638
|
+
method: "POST",
|
|
15639
|
+
body: input,
|
|
15640
|
+
mutation: true
|
|
15641
|
+
}).then((response) => AgentCreatedPaymentLinkDtoSchema.parse(response));
|
|
15642
|
+
}
|
|
15643
|
+
/** Fetches a persisted link; `url` is always `null`. */
|
|
15644
|
+
get(paymentLinkId) {
|
|
15645
|
+
return this.http.request(`/api/v1/agent/payment-links/${encodeURIComponent(paymentLinkId)}`).then((response) => AgentPaymentLinkDtoSchema.parse(response));
|
|
15646
|
+
}
|
|
15647
|
+
/** Lists persisted links; every item has `url: null`. */
|
|
15648
|
+
list(filter = {}) {
|
|
15649
|
+
return this.http.request(`/api/v1/agent/payment-links${queryString(filter)}`).then((response) => AgentPaymentLinkPageSchema.parse(response));
|
|
15406
15650
|
}
|
|
15407
15651
|
};
|
|
15408
15652
|
function createAvileoAgent(config2) {
|
|
15409
15653
|
const http = new AgentHttpClient(config2);
|
|
15410
15654
|
return {
|
|
15411
15655
|
business: new AgentBusinessResource(http),
|
|
15656
|
+
operations: new AgentOperationsResource(http),
|
|
15412
15657
|
products: new AgentProductsResource(http),
|
|
15413
15658
|
variants: new AgentVariantsResource(http),
|
|
15414
15659
|
categories: new AgentCategoriesResource(http),
|
|
15415
15660
|
tags: new AgentTagsResource(http),
|
|
15416
15661
|
assets: new AgentAssetsResource(http),
|
|
15417
15662
|
inventory: new AgentInventoryResource(http),
|
|
15418
|
-
imports: new AgentImportsResource(http)
|
|
15663
|
+
imports: new AgentImportsResource(http),
|
|
15664
|
+
paymentLinks: new AgentPaymentLinksResource(http)
|
|
15419
15665
|
};
|
|
15420
15666
|
}
|
|
15421
15667
|
|
|
@@ -15554,7 +15800,8 @@ function emitFailure(failure) {
|
|
|
15554
15800
|
function exitCodeFor(error51) {
|
|
15555
15801
|
const candidate = error51;
|
|
15556
15802
|
if (candidate.retryable) return 2;
|
|
15557
|
-
if (candidate.status === 409 || /CONFLICT|IDEMPOTENCY|VERSION/.test(candidate.code ?? ""))
|
|
15803
|
+
if (candidate.status === 409 || /CONFLICT|IDEMPOTENCY|VERSION/.test(candidate.code ?? ""))
|
|
15804
|
+
return 4;
|
|
15558
15805
|
if (candidate.status === 401 || candidate.status === 403 || candidate.status === 422 || /AUTH|PERMISSION|VALIDATION|UNSUPPORTED|QUOTA|POLICY/.test(candidate.code ?? "")) {
|
|
15559
15806
|
return 3;
|
|
15560
15807
|
}
|
|
@@ -15576,40 +15823,15 @@ function redact(value) {
|
|
|
15576
15823
|
return Object.fromEntries(
|
|
15577
15824
|
Object.entries(value).map(([key, item]) => [
|
|
15578
15825
|
key,
|
|
15579
|
-
/(?:api.?key|authorization|secret|token|password)/i.test(key) ? "[REDACTED]" : redact(item)
|
|
15826
|
+
/(?:agent.?key|api.?key|authorization|secret|token|password)/i.test(key) ? "[REDACTED]" : redact(item)
|
|
15580
15827
|
])
|
|
15581
15828
|
);
|
|
15582
15829
|
}
|
|
15583
15830
|
return value;
|
|
15584
15831
|
}
|
|
15585
15832
|
|
|
15586
|
-
// src/commands/
|
|
15587
|
-
|
|
15588
|
-
const business = root.command("business").description("Consulta el negocio vinculado a la clave agente");
|
|
15589
|
-
business.command("show").description("Muestra las capacidades seguras del negocio").action(async () => {
|
|
15590
|
-
emitSuccess(await getClient().business.get());
|
|
15591
|
-
});
|
|
15592
|
-
}
|
|
15593
|
-
|
|
15594
|
-
// src/commands/catalog.ts
|
|
15595
|
-
import { basename } from "path";
|
|
15596
|
-
import { readFile, stat } from "fs/promises";
|
|
15597
|
-
function requireId(value, name) {
|
|
15598
|
-
if (!value.trim()) throw new CliProtocolError("CLI_VALIDATION_ERROR", `${name} es obligatorio`);
|
|
15599
|
-
return value;
|
|
15600
|
-
}
|
|
15601
|
-
async function readMutationInput(path) {
|
|
15602
|
-
let parsed;
|
|
15603
|
-
try {
|
|
15604
|
-
parsed = JSON.parse(await readFile(path, "utf8"));
|
|
15605
|
-
} catch {
|
|
15606
|
-
throw new CliProtocolError("CLI_INPUT_ERROR", "No se pudo leer un objeto JSON desde --from");
|
|
15607
|
-
}
|
|
15608
|
-
if (!parsed || Array.isArray(parsed) || typeof parsed !== "object") {
|
|
15609
|
-
throw new CliProtocolError("CLI_VALIDATION_ERROR", "--from debe contener un objeto JSON");
|
|
15610
|
-
}
|
|
15611
|
-
return normalizeInput(parsed);
|
|
15612
|
-
}
|
|
15833
|
+
// src/commands/mutation.ts
|
|
15834
|
+
import { readFile } from "fs/promises";
|
|
15613
15835
|
function normalizeInput(value) {
|
|
15614
15836
|
const forbidden = {
|
|
15615
15837
|
businessId: true,
|
|
@@ -15632,12 +15854,17 @@ function normalizeInput(value) {
|
|
|
15632
15854
|
};
|
|
15633
15855
|
return visit(value);
|
|
15634
15856
|
}
|
|
15635
|
-
function
|
|
15636
|
-
|
|
15637
|
-
|
|
15638
|
-
|
|
15639
|
-
|
|
15640
|
-
|
|
15857
|
+
async function readMutationInput(path) {
|
|
15858
|
+
let parsed;
|
|
15859
|
+
try {
|
|
15860
|
+
parsed = JSON.parse(await readFile(path, "utf8"));
|
|
15861
|
+
} catch {
|
|
15862
|
+
throw new CliProtocolError("CLI_INPUT_ERROR", "No se pudo leer un objeto JSON desde --from");
|
|
15863
|
+
}
|
|
15864
|
+
if (!parsed || Array.isArray(parsed) || typeof parsed !== "object") {
|
|
15865
|
+
throw new CliProtocolError("CLI_VALIDATION_ERROR", "--from debe contener un objeto JSON");
|
|
15866
|
+
}
|
|
15867
|
+
return normalizeInput(parsed);
|
|
15641
15868
|
}
|
|
15642
15869
|
function localResult(input, current) {
|
|
15643
15870
|
if (current === void 0) return { validated: "local", input };
|
|
@@ -15647,12 +15874,60 @@ function localResult(input, current) {
|
|
|
15647
15874
|
);
|
|
15648
15875
|
return { validated: "local", current, changes };
|
|
15649
15876
|
}
|
|
15877
|
+
|
|
15878
|
+
// src/commands/business.ts
|
|
15879
|
+
function profileValues(profile) {
|
|
15880
|
+
const values = profile.values;
|
|
15881
|
+
if (!values || Array.isArray(values) || typeof values !== "object") return {};
|
|
15882
|
+
return values;
|
|
15883
|
+
}
|
|
15884
|
+
function registerBusinessCommands(root, getClient) {
|
|
15885
|
+
const business = root.command("business").description("Consulta el negocio vinculado a la clave agente");
|
|
15886
|
+
business.command("show").description("Muestra las capacidades seguras del negocio").action(async () => {
|
|
15887
|
+
emitSuccess(await getClient().business.get());
|
|
15888
|
+
});
|
|
15889
|
+
const profile = business.command("profile").description("Consulta o propone cambios al perfil del negocio");
|
|
15890
|
+
profile.command("show").description("Muestra campos, valores y completitud del perfil").action(async () => {
|
|
15891
|
+
emitSuccess(await getClient().business.profile());
|
|
15892
|
+
});
|
|
15893
|
+
profile.command("update").description("Previsualiza o propone cambios al perfil").requiredOption("--from <json-file>", "Valores de perfil en un objeto JSON").option("--apply", "Crea una propuesta para aprobaci\xF3n en Avileo").action(async (options, command) => {
|
|
15894
|
+
const values = await readMutationInput(options.from);
|
|
15895
|
+
if (!command.optsWithGlobals().apply) {
|
|
15896
|
+
const current = await getClient().business.profile();
|
|
15897
|
+
emitSuccess(localResult(values, profileValues(current)));
|
|
15898
|
+
return;
|
|
15899
|
+
}
|
|
15900
|
+
emitSuccess(
|
|
15901
|
+
await getClient().operations.propose({
|
|
15902
|
+
operationName: "business.profile.update",
|
|
15903
|
+
payload: { values }
|
|
15904
|
+
})
|
|
15905
|
+
);
|
|
15906
|
+
});
|
|
15907
|
+
}
|
|
15908
|
+
|
|
15909
|
+
// src/commands/catalog.ts
|
|
15910
|
+
import { createHash } from "crypto";
|
|
15911
|
+
import { readFile as readFile2, stat } from "fs/promises";
|
|
15912
|
+
import { basename, extname } from "path";
|
|
15913
|
+
function requireId(value, name) {
|
|
15914
|
+
if (!value.trim()) throw new CliProtocolError("CLI_VALIDATION_ERROR", `${name} es obligatorio`);
|
|
15915
|
+
return value;
|
|
15916
|
+
}
|
|
15917
|
+
function withMutationOptions(command, includeFrom = true) {
|
|
15918
|
+
if (includeFrom) command.requiredOption("--from <json-file>", "Objeto JSON estructurado");
|
|
15919
|
+
return command.option("--apply", "Solicita aprobaci\xF3n o ejecuta una mutaci\xF3n aprobada").option("--approval-id <uuid>", "Aprobaci\xF3n emitida por Avileo");
|
|
15920
|
+
}
|
|
15921
|
+
function wantsApply(command) {
|
|
15922
|
+
return Boolean(command.optsWithGlobals().apply);
|
|
15923
|
+
}
|
|
15650
15924
|
function addListOptions(command) {
|
|
15651
15925
|
return command.option("--search <text>").option("--category-id <id>").option("--active <true|false>", "Filtra por estado activo", parseBoolean).option("--limit <number>", "M\xE1ximo de resultados", parseInteger).option("--offset <number>", "Desplazamiento", parseInteger);
|
|
15652
15926
|
}
|
|
15653
15927
|
function parseInteger(value) {
|
|
15654
15928
|
const result = Number(value);
|
|
15655
|
-
if (!Number.isInteger(result) || result < 0)
|
|
15929
|
+
if (!Number.isInteger(result) || result < 0)
|
|
15930
|
+
throw new CliProtocolError("CLI_VALIDATION_ERROR", "Se esperaba un entero no negativo");
|
|
15656
15931
|
return result;
|
|
15657
15932
|
}
|
|
15658
15933
|
function parseBoolean(value) {
|
|
@@ -15660,12 +15935,17 @@ function parseBoolean(value) {
|
|
|
15660
15935
|
if (value === "false") return false;
|
|
15661
15936
|
throw new CliProtocolError("CLI_VALIDATION_ERROR", "Se esperaba true o false");
|
|
15662
15937
|
}
|
|
15663
|
-
async function applyOrPreview(command, input, run, current) {
|
|
15664
|
-
if (wantsApply(command)) {
|
|
15665
|
-
emitSuccess(await
|
|
15938
|
+
async function applyOrPreview(command, input, getClient, operationName, payload, run, current) {
|
|
15939
|
+
if (!wantsApply(command)) {
|
|
15940
|
+
emitSuccess(localResult(input, current ? await current() : void 0));
|
|
15666
15941
|
return;
|
|
15667
15942
|
}
|
|
15668
|
-
|
|
15943
|
+
const rawApprovalId = command.optsWithGlobals().approvalId;
|
|
15944
|
+
if (typeof rawApprovalId === "string") {
|
|
15945
|
+
emitSuccess(await run(requireId(rawApprovalId, "approvalId")));
|
|
15946
|
+
return;
|
|
15947
|
+
}
|
|
15948
|
+
emitSuccess(await getClient().operations.propose({ operationName, payload }));
|
|
15669
15949
|
}
|
|
15670
15950
|
function registerCatalogCommands(root, getClient) {
|
|
15671
15951
|
const catalog = root.command("catalog").description("Gestiona recursos de cat\xE1logo de Avileo");
|
|
@@ -15680,165 +15960,363 @@ function registerCatalogCommands(root, getClient) {
|
|
|
15680
15960
|
function registerProductCommands(catalog, getClient) {
|
|
15681
15961
|
const product = catalog.command("product");
|
|
15682
15962
|
addListOptions(product.command("list")).action(async (options) => {
|
|
15683
|
-
const {
|
|
15684
|
-
|
|
15963
|
+
const {
|
|
15964
|
+
active: isActive,
|
|
15965
|
+
categoryId,
|
|
15966
|
+
...filters
|
|
15967
|
+
} = options;
|
|
15968
|
+
emitSuccess(
|
|
15969
|
+
await getClient().products.list({
|
|
15970
|
+
...filters,
|
|
15971
|
+
...categoryId ? { categoryId } : {},
|
|
15972
|
+
...isActive === void 0 ? {} : { isActive }
|
|
15973
|
+
})
|
|
15974
|
+
);
|
|
15685
15975
|
});
|
|
15686
|
-
product.command("get <productId>").action(async (productId) =>
|
|
15687
|
-
|
|
15688
|
-
const input = await readMutationInput(options.from);
|
|
15689
|
-
await applyOrPreview(command, input, () => getClient().products.create(input));
|
|
15976
|
+
product.command("get <productId>").action(async (productId) => {
|
|
15977
|
+
emitSuccess(await getClient().products.get(requireId(productId, "productId")));
|
|
15690
15978
|
});
|
|
15691
|
-
withMutationOptions(product.command("
|
|
15692
|
-
const id = requireId(productId, "productId");
|
|
15979
|
+
withMutationOptions(product.command("create")).action(async (options, command) => {
|
|
15693
15980
|
const input = await readMutationInput(options.from);
|
|
15694
|
-
await applyOrPreview(
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
|
|
15981
|
+
await applyOrPreview(
|
|
15982
|
+
command,
|
|
15983
|
+
input,
|
|
15984
|
+
getClient,
|
|
15985
|
+
"catalog.products.create",
|
|
15986
|
+
{ body: input },
|
|
15987
|
+
(approvalId) => getClient().products.create(input, approvalId)
|
|
15988
|
+
);
|
|
15700
15989
|
});
|
|
15990
|
+
withMutationOptions(product.command("update <productId>")).action(
|
|
15991
|
+
async (productId, options, command) => {
|
|
15992
|
+
const id = requireId(productId, "productId");
|
|
15993
|
+
const input = await readMutationInput(options.from);
|
|
15994
|
+
await applyOrPreview(
|
|
15995
|
+
command,
|
|
15996
|
+
input,
|
|
15997
|
+
getClient,
|
|
15998
|
+
"catalog.products.update",
|
|
15999
|
+
{ productId: id, body: input },
|
|
16000
|
+
(approvalId) => getClient().products.update(id, input, approvalId),
|
|
16001
|
+
() => getClient().products.get(id)
|
|
16002
|
+
);
|
|
16003
|
+
}
|
|
16004
|
+
);
|
|
16005
|
+
withMutationOptions(product.command("deactivate <productId>"), false).action(
|
|
16006
|
+
async (productId, _options, command) => {
|
|
16007
|
+
const id = requireId(productId, "productId");
|
|
16008
|
+
await applyOrPreview(
|
|
16009
|
+
command,
|
|
16010
|
+
{ isActive: false },
|
|
16011
|
+
getClient,
|
|
16012
|
+
"catalog.products.deactivate",
|
|
16013
|
+
{ productId: id },
|
|
16014
|
+
(approvalId) => getClient().products.deactivate(id, approvalId),
|
|
16015
|
+
() => getClient().products.get(id)
|
|
16016
|
+
);
|
|
16017
|
+
}
|
|
16018
|
+
);
|
|
15701
16019
|
}
|
|
15702
16020
|
function registerVariantCommands(catalog, getClient) {
|
|
15703
16021
|
const variant = catalog.command("variant");
|
|
15704
|
-
variant.command("list <productId>").action(async (productId) =>
|
|
15705
|
-
|
|
15706
|
-
withMutationOptions(variant.command("create <productId>")).action(async (productId, options, command) => {
|
|
15707
|
-
const input = await readMutationInput(options.from);
|
|
15708
|
-
await applyOrPreview(command, input, () => getClient().variants.create(requireId(productId, "productId"), input));
|
|
16022
|
+
variant.command("list <productId>").action(async (productId) => {
|
|
16023
|
+
emitSuccess(await getClient().variants.list(requireId(productId, "productId")));
|
|
15709
16024
|
});
|
|
15710
|
-
|
|
15711
|
-
|
|
15712
|
-
const input = await readMutationInput(options.from);
|
|
15713
|
-
await applyOrPreview(command, input, () => getClient().variants.update(id, input), () => getClient().variants.get(id));
|
|
15714
|
-
});
|
|
15715
|
-
withMutationOptions(variant.command("deactivate <variantId>"), false).action(async (variantId, _options, command) => {
|
|
15716
|
-
const id = requireId(variantId, "variantId");
|
|
15717
|
-
const input = { isActive: false };
|
|
15718
|
-
await applyOrPreview(command, input, () => getClient().variants.deactivate(id), () => getClient().variants.get(id));
|
|
15719
|
-
});
|
|
15720
|
-
withMutationOptions(variant.command("reorder <productId>")).action(async (productId, options, command) => {
|
|
15721
|
-
const id = requireId(productId, "productId");
|
|
15722
|
-
const input = await readMutationInput(options.from);
|
|
15723
|
-
await applyOrPreview(command, input, () => getClient().variants.reorder(id, input), () => getClient().variants.list(id));
|
|
16025
|
+
variant.command("get <variantId>").action(async (variantId) => {
|
|
16026
|
+
emitSuccess(await getClient().variants.get(requireId(variantId, "variantId")));
|
|
15724
16027
|
});
|
|
16028
|
+
withMutationOptions(variant.command("create <productId>")).action(
|
|
16029
|
+
async (productId, options, command) => {
|
|
16030
|
+
const id = requireId(productId, "productId");
|
|
16031
|
+
const input = await readMutationInput(options.from);
|
|
16032
|
+
await applyOrPreview(
|
|
16033
|
+
command,
|
|
16034
|
+
input,
|
|
16035
|
+
getClient,
|
|
16036
|
+
"catalog.variants.create",
|
|
16037
|
+
{ productId: id, body: input },
|
|
16038
|
+
(approvalId) => getClient().variants.create(id, input, approvalId)
|
|
16039
|
+
);
|
|
16040
|
+
}
|
|
16041
|
+
);
|
|
16042
|
+
withMutationOptions(variant.command("update <variantId>")).action(
|
|
16043
|
+
async (variantId, options, command) => {
|
|
16044
|
+
const id = requireId(variantId, "variantId");
|
|
16045
|
+
const input = await readMutationInput(options.from);
|
|
16046
|
+
await applyOrPreview(
|
|
16047
|
+
command,
|
|
16048
|
+
input,
|
|
16049
|
+
getClient,
|
|
16050
|
+
"catalog.variants.update",
|
|
16051
|
+
{ variantId: id, body: input },
|
|
16052
|
+
(approvalId) => getClient().variants.update(id, input, approvalId),
|
|
16053
|
+
() => getClient().variants.get(id)
|
|
16054
|
+
);
|
|
16055
|
+
}
|
|
16056
|
+
);
|
|
16057
|
+
withMutationOptions(variant.command("deactivate <variantId>"), false).action(
|
|
16058
|
+
async (variantId, _options, command) => {
|
|
16059
|
+
const id = requireId(variantId, "variantId");
|
|
16060
|
+
await applyOrPreview(
|
|
16061
|
+
command,
|
|
16062
|
+
{ isActive: false },
|
|
16063
|
+
getClient,
|
|
16064
|
+
"catalog.variants.deactivate",
|
|
16065
|
+
{ variantId: id },
|
|
16066
|
+
(approvalId) => getClient().variants.deactivate(id, approvalId),
|
|
16067
|
+
() => getClient().variants.get(id)
|
|
16068
|
+
);
|
|
16069
|
+
}
|
|
16070
|
+
);
|
|
16071
|
+
withMutationOptions(variant.command("reorder <productId>")).action(
|
|
16072
|
+
async (productId, options, command) => {
|
|
16073
|
+
const id = requireId(productId, "productId");
|
|
16074
|
+
const input = await readMutationInput(options.from);
|
|
16075
|
+
await applyOrPreview(
|
|
16076
|
+
command,
|
|
16077
|
+
input,
|
|
16078
|
+
getClient,
|
|
16079
|
+
"catalog.variants.reorder",
|
|
16080
|
+
{ productId: id, body: input },
|
|
16081
|
+
(approvalId) => getClient().variants.reorder(id, input, approvalId),
|
|
16082
|
+
() => getClient().variants.list(id)
|
|
16083
|
+
);
|
|
16084
|
+
}
|
|
16085
|
+
);
|
|
15725
16086
|
}
|
|
15726
16087
|
function registerCategoryCommands(catalog, getClient) {
|
|
15727
16088
|
const category = catalog.command("category");
|
|
15728
16089
|
category.command("list").action(async () => emitSuccess(await getClient().categories.list()));
|
|
15729
|
-
category.command("get <categoryId>").action(async (categoryId) =>
|
|
15730
|
-
|
|
15731
|
-
const input = await readMutationInput(options.from);
|
|
15732
|
-
await applyOrPreview(command, input, () => getClient().categories.create(input));
|
|
16090
|
+
category.command("get <categoryId>").action(async (categoryId) => {
|
|
16091
|
+
emitSuccess(await getClient().categories.get(requireId(categoryId, "categoryId")));
|
|
15733
16092
|
});
|
|
15734
|
-
withMutationOptions(category.command("
|
|
15735
|
-
const id = requireId(categoryId, "categoryId");
|
|
16093
|
+
withMutationOptions(category.command("create")).action(async (options, command) => {
|
|
15736
16094
|
const input = await readMutationInput(options.from);
|
|
15737
|
-
await applyOrPreview(
|
|
15738
|
-
|
|
15739
|
-
|
|
15740
|
-
|
|
15741
|
-
|
|
16095
|
+
await applyOrPreview(
|
|
16096
|
+
command,
|
|
16097
|
+
input,
|
|
16098
|
+
getClient,
|
|
16099
|
+
"catalog.categories.create",
|
|
16100
|
+
{ body: input },
|
|
16101
|
+
(approvalId) => getClient().categories.create(input, approvalId)
|
|
16102
|
+
);
|
|
15742
16103
|
});
|
|
16104
|
+
withMutationOptions(category.command("update <categoryId>")).action(
|
|
16105
|
+
async (categoryId, options, command) => {
|
|
16106
|
+
const id = requireId(categoryId, "categoryId");
|
|
16107
|
+
const input = await readMutationInput(options.from);
|
|
16108
|
+
await applyOrPreview(
|
|
16109
|
+
command,
|
|
16110
|
+
input,
|
|
16111
|
+
getClient,
|
|
16112
|
+
"catalog.categories.update",
|
|
16113
|
+
{ categoryId: id, body: input },
|
|
16114
|
+
(approvalId) => getClient().categories.update(id, input, approvalId),
|
|
16115
|
+
() => getClient().categories.get(id)
|
|
16116
|
+
);
|
|
16117
|
+
}
|
|
16118
|
+
);
|
|
16119
|
+
withMutationOptions(category.command("delete <categoryId>"), false).action(
|
|
16120
|
+
async (categoryId, _options, command) => {
|
|
16121
|
+
const id = requireId(categoryId, "categoryId");
|
|
16122
|
+
await applyOrPreview(
|
|
16123
|
+
command,
|
|
16124
|
+
{ delete: true },
|
|
16125
|
+
getClient,
|
|
16126
|
+
"catalog.categories.delete",
|
|
16127
|
+
{ categoryId: id },
|
|
16128
|
+
(approvalId) => getClient().categories.delete(id, approvalId),
|
|
16129
|
+
() => getClient().categories.get(id)
|
|
16130
|
+
);
|
|
16131
|
+
}
|
|
16132
|
+
);
|
|
15743
16133
|
}
|
|
15744
16134
|
function registerTagCommands(catalog, getClient) {
|
|
15745
16135
|
const tag = catalog.command("tag");
|
|
15746
16136
|
tag.command("list").action(async () => emitSuccess(await getClient().tags.list()));
|
|
15747
|
-
tag.command("get <tagId>").action(async (tagId) =>
|
|
16137
|
+
tag.command("get <tagId>").action(async (tagId) => {
|
|
16138
|
+
emitSuccess(await getClient().tags.get(requireId(tagId, "tagId")));
|
|
16139
|
+
});
|
|
15748
16140
|
withMutationOptions(tag.command("create")).action(async (options, command) => {
|
|
15749
16141
|
const input = await readMutationInput(options.from);
|
|
15750
|
-
await applyOrPreview(
|
|
16142
|
+
await applyOrPreview(
|
|
16143
|
+
command,
|
|
16144
|
+
input,
|
|
16145
|
+
getClient,
|
|
16146
|
+
"catalog.tags.create",
|
|
16147
|
+
{ body: input },
|
|
16148
|
+
(approvalId) => getClient().tags.create(input, approvalId)
|
|
16149
|
+
);
|
|
15751
16150
|
});
|
|
15752
16151
|
withMutationOptions(tag.command("update <tagId>")).action(async (tagId, options, command) => {
|
|
15753
16152
|
const id = requireId(tagId, "tagId");
|
|
15754
16153
|
const input = await readMutationInput(options.from);
|
|
15755
|
-
await applyOrPreview(
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
|
|
16154
|
+
await applyOrPreview(
|
|
16155
|
+
command,
|
|
16156
|
+
input,
|
|
16157
|
+
getClient,
|
|
16158
|
+
"catalog.tags.update",
|
|
16159
|
+
{ tagId: id, body: input },
|
|
16160
|
+
(approvalId) => getClient().tags.update(id, input, approvalId),
|
|
16161
|
+
() => getClient().tags.get(id)
|
|
16162
|
+
);
|
|
15760
16163
|
});
|
|
16164
|
+
withMutationOptions(tag.command("delete <tagId>"), false).action(
|
|
16165
|
+
async (tagId, _options, command) => {
|
|
16166
|
+
const id = requireId(tagId, "tagId");
|
|
16167
|
+
await applyOrPreview(
|
|
16168
|
+
command,
|
|
16169
|
+
{ delete: true },
|
|
16170
|
+
getClient,
|
|
16171
|
+
"catalog.tags.delete",
|
|
16172
|
+
{ tagId: id },
|
|
16173
|
+
(approvalId) => getClient().tags.delete(id, approvalId),
|
|
16174
|
+
() => getClient().tags.get(id)
|
|
16175
|
+
);
|
|
16176
|
+
}
|
|
16177
|
+
);
|
|
15761
16178
|
}
|
|
15762
16179
|
function registerAssetCommands(catalog, getClient) {
|
|
15763
16180
|
const asset = catalog.command("asset");
|
|
15764
16181
|
asset.command("list").option("--search <text>").option("--limit <number>", "M\xE1ximo de resultados", parseInteger).option("--offset <number>", "Desplazamiento", parseInteger).action(async (options) => emitSuccess(await getClient().assets.list(options)));
|
|
15765
|
-
asset.command("get <assetId>").action(async (assetId) =>
|
|
15766
|
-
|
|
16182
|
+
asset.command("get <assetId>").action(async (assetId) => {
|
|
16183
|
+
emitSuccess(await getClient().assets.get(requireId(assetId, "assetId")));
|
|
16184
|
+
});
|
|
16185
|
+
withMutationOptions(
|
|
16186
|
+
asset.command("upload").requiredOption("--file <path>", "Archivo local"),
|
|
16187
|
+
false
|
|
16188
|
+
).action(async (options, command) => {
|
|
15767
16189
|
const filePath = options.file;
|
|
15768
16190
|
const fileStat = await stat(filePath);
|
|
15769
|
-
if (!fileStat.isFile())
|
|
16191
|
+
if (!fileStat.isFile()) {
|
|
16192
|
+
throw new CliProtocolError("CLI_VALIDATION_ERROR", "--file debe apuntar a un archivo");
|
|
16193
|
+
}
|
|
15770
16194
|
if (!wantsApply(command)) {
|
|
15771
|
-
emitSuccess({
|
|
16195
|
+
emitSuccess({
|
|
16196
|
+
validated: "local",
|
|
16197
|
+
file: basename(filePath),
|
|
16198
|
+
sizeBytes: fileStat.size
|
|
16199
|
+
});
|
|
16200
|
+
return;
|
|
16201
|
+
}
|
|
16202
|
+
const extension = extname(filePath).toLowerCase();
|
|
16203
|
+
const mimeType = extension === ".jpg" || extension === ".jpeg" ? "image/jpeg" : extension === ".png" ? "image/png" : extension === ".webp" ? "image/webp" : void 0;
|
|
16204
|
+
if (!mimeType) {
|
|
16205
|
+
throw new CliProtocolError(
|
|
16206
|
+
"CLI_VALIDATION_ERROR",
|
|
16207
|
+
"Solo se permiten im\xE1genes JPEG, PNG o WebP"
|
|
16208
|
+
);
|
|
16209
|
+
}
|
|
16210
|
+
const contents = await readFile2(filePath);
|
|
16211
|
+
const file2 = new File([contents], basename(filePath), { type: mimeType });
|
|
16212
|
+
const rawApprovalId = command.optsWithGlobals().approvalId;
|
|
16213
|
+
if (typeof rawApprovalId === "string") {
|
|
16214
|
+
emitSuccess(await getClient().assets.upload(file2, requireId(rawApprovalId, "approvalId")));
|
|
15772
16215
|
return;
|
|
15773
16216
|
}
|
|
15774
|
-
|
|
15775
|
-
|
|
16217
|
+
emitSuccess(
|
|
16218
|
+
await getClient().operations.propose({
|
|
16219
|
+
operationName: "catalog.assets.upload",
|
|
16220
|
+
payload: {
|
|
16221
|
+
filename: file2.name,
|
|
16222
|
+
mimeType: file2.type,
|
|
16223
|
+
sizeBytes: file2.size,
|
|
16224
|
+
contentHash: createHash("sha256").update(contents).digest("hex")
|
|
16225
|
+
}
|
|
16226
|
+
})
|
|
16227
|
+
);
|
|
15776
16228
|
});
|
|
15777
16229
|
withMutationOptions(asset.command("import-url")).action(async (options, command) => {
|
|
15778
16230
|
const input = await readMutationInput(options.from);
|
|
15779
|
-
await applyOrPreview(
|
|
16231
|
+
await applyOrPreview(
|
|
16232
|
+
command,
|
|
16233
|
+
input,
|
|
16234
|
+
getClient,
|
|
16235
|
+
"catalog.assets.import",
|
|
16236
|
+
input,
|
|
16237
|
+
(approvalId) => getClient().assets.importFromUrl(input, approvalId)
|
|
16238
|
+
);
|
|
15780
16239
|
});
|
|
15781
16240
|
}
|
|
15782
16241
|
function registerInventoryCommands(catalog, getClient) {
|
|
15783
16242
|
const inventory = catalog.command("inventory");
|
|
15784
|
-
inventory.command("get <variantId>").action(async (variantId) =>
|
|
15785
|
-
|
|
15786
|
-
withMutationOptions(inventory.command("adjust <variantId>")).action(async (variantId, options, command) => {
|
|
15787
|
-
const id = requireId(variantId, "variantId");
|
|
15788
|
-
const input = await readMutationInput(options.from);
|
|
15789
|
-
await applyOrPreview(command, input, () => getClient().inventory.adjust(id, input), () => getClient().inventory.get(id));
|
|
16243
|
+
inventory.command("get <variantId>").action(async (variantId) => {
|
|
16244
|
+
emitSuccess(await getClient().inventory.get(requireId(variantId, "variantId")));
|
|
15790
16245
|
});
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
|
|
16246
|
+
inventory.command("movements <variantId>").option("--reason <reason>").option("--limit <number>", "M\xE1ximo de resultados", parseInteger).option("--offset <number>", "Desplazamiento", parseInteger).action(async (variantId, options) => {
|
|
16247
|
+
emitSuccess(
|
|
16248
|
+
await getClient().inventory.listMovements(requireId(variantId, "variantId"), options)
|
|
16249
|
+
);
|
|
15795
16250
|
});
|
|
15796
|
-
|
|
15797
|
-
async
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15802
|
-
|
|
15803
|
-
|
|
15804
|
-
"
|
|
15805
|
-
|
|
16251
|
+
withMutationOptions(inventory.command("adjust <variantId>")).action(
|
|
16252
|
+
async (variantId, options, command) => {
|
|
16253
|
+
const id = requireId(variantId, "variantId");
|
|
16254
|
+
const input = await readMutationInput(options.from);
|
|
16255
|
+
await applyOrPreview(
|
|
16256
|
+
command,
|
|
16257
|
+
input,
|
|
16258
|
+
getClient,
|
|
16259
|
+
"catalog.inventory.adjust",
|
|
16260
|
+
{ variantId: id, body: input },
|
|
16261
|
+
(approvalId) => getClient().inventory.adjust(id, input, approvalId),
|
|
16262
|
+
() => getClient().inventory.get(id)
|
|
15806
16263
|
);
|
|
15807
16264
|
}
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
16265
|
+
);
|
|
16266
|
+
withMutationOptions(inventory.command("set <variantId>")).action(
|
|
16267
|
+
async (variantId, options, command) => {
|
|
16268
|
+
const id = requireId(variantId, "variantId");
|
|
16269
|
+
const input = await readMutationInput(options.from);
|
|
16270
|
+
await applyOrPreview(
|
|
16271
|
+
command,
|
|
16272
|
+
input,
|
|
16273
|
+
getClient,
|
|
16274
|
+
"catalog.inventory.set",
|
|
16275
|
+
{ variantId: id, body: input },
|
|
16276
|
+
(approvalId) => getClient().inventory.set(id, input, approvalId),
|
|
16277
|
+
() => getClient().inventory.get(id)
|
|
16278
|
+
);
|
|
15811
16279
|
}
|
|
15812
|
-
|
|
15813
|
-
|
|
16280
|
+
);
|
|
16281
|
+
}
|
|
16282
|
+
function rejectLocalFileSources(value) {
|
|
16283
|
+
if (Array.isArray(value)) {
|
|
16284
|
+
for (const item of value) rejectLocalFileSources(item);
|
|
16285
|
+
return;
|
|
16286
|
+
}
|
|
16287
|
+
if (!value || typeof value !== "object") return;
|
|
16288
|
+
const source = value;
|
|
16289
|
+
if (source.kind === "file") {
|
|
16290
|
+
throw new CliProtocolError(
|
|
16291
|
+
"CLI_VALIDATION_ERROR",
|
|
16292
|
+
"Sube cada imagen local con catalog asset upload, apru\xE9bala y usa su assetId"
|
|
15814
16293
|
);
|
|
15815
|
-
return { kind: "asset", assetId: asset.id };
|
|
15816
16294
|
}
|
|
15817
|
-
|
|
15818
|
-
await Promise.all(
|
|
15819
|
-
Object.entries(source).map(async ([key, nested]) => [
|
|
15820
|
-
key,
|
|
15821
|
-
await resolveLocalFileSources(nested, client)
|
|
15822
|
-
])
|
|
15823
|
-
)
|
|
15824
|
-
);
|
|
16295
|
+
for (const nested of Object.values(source)) rejectLocalFileSources(nested);
|
|
15825
16296
|
}
|
|
15826
16297
|
function registerImportCommands(catalog, getClient) {
|
|
15827
16298
|
const imports = catalog.command("import");
|
|
15828
16299
|
imports.command("preview").requiredOption("--from <json-file>", "Lista estructurada para vista previa").action(async (options) => {
|
|
15829
16300
|
const input = await readMutationInput(options.from);
|
|
15830
|
-
|
|
15831
|
-
emitSuccess(await getClient().imports.preview(
|
|
16301
|
+
rejectLocalFileSources(input);
|
|
16302
|
+
emitSuccess(await getClient().imports.preview(input));
|
|
15832
16303
|
});
|
|
15833
|
-
imports.command("apply <importId>")
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
16304
|
+
withMutationOptions(imports.command("apply <importId>"), false).action(
|
|
16305
|
+
async (importId, _options, command) => {
|
|
16306
|
+
const id = requireId(importId, "importId");
|
|
16307
|
+
await applyOrPreview(
|
|
16308
|
+
command,
|
|
16309
|
+
{ importId: id, action: "apply" },
|
|
16310
|
+
getClient,
|
|
16311
|
+
"catalog.imports.apply",
|
|
16312
|
+
{ importId: id },
|
|
16313
|
+
(approvalId) => getClient().imports.apply(id, approvalId)
|
|
16314
|
+
);
|
|
15838
16315
|
}
|
|
15839
|
-
|
|
16316
|
+
);
|
|
16317
|
+
imports.command("status <importId>").action(async (importId) => {
|
|
16318
|
+
emitSuccess(await getClient().imports.get(requireId(importId, "importId")));
|
|
15840
16319
|
});
|
|
15841
|
-
imports.command("status <importId>").action(async (importId) => emitSuccess(await getClient().imports.get(requireId(importId, "importId"))));
|
|
15842
16320
|
}
|
|
15843
16321
|
|
|
15844
16322
|
// src/commands/auth.ts
|
|
@@ -15870,6 +16348,57 @@ function safeFinalResult(start, browserOpened, result) {
|
|
|
15870
16348
|
function sleep(milliseconds) {
|
|
15871
16349
|
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
15872
16350
|
}
|
|
16351
|
+
function readAgentKeyFromTty(prompt = "Agent Key de Avileo: ") {
|
|
16352
|
+
if (!process.stdin.isTTY || !process.stderr.isTTY) {
|
|
16353
|
+
throw new CliProtocolError(
|
|
16354
|
+
"CLI_CONFIGURATION_ERROR",
|
|
16355
|
+
"auth configure requiere una terminal interactiva; usa AVILEO_AGENT_API_KEY en CI/CD"
|
|
16356
|
+
);
|
|
16357
|
+
}
|
|
16358
|
+
return new Promise((resolve, reject) => {
|
|
16359
|
+
let value = "";
|
|
16360
|
+
const input = process.stdin;
|
|
16361
|
+
const output = process.stderr;
|
|
16362
|
+
const wasRaw = input.isRaw;
|
|
16363
|
+
const cleanup = () => {
|
|
16364
|
+
input.removeListener("data", onData);
|
|
16365
|
+
input.pause();
|
|
16366
|
+
if (wasRaw !== void 0) input.setRawMode(Boolean(wasRaw));
|
|
16367
|
+
};
|
|
16368
|
+
const finish = (result) => {
|
|
16369
|
+
cleanup();
|
|
16370
|
+
output.write("\n");
|
|
16371
|
+
if (result instanceof Error) reject(result);
|
|
16372
|
+
else resolve(result);
|
|
16373
|
+
};
|
|
16374
|
+
const onData = (chunk) => {
|
|
16375
|
+
for (const character of String(chunk)) {
|
|
16376
|
+
if (character === "") {
|
|
16377
|
+
finish(
|
|
16378
|
+
new CliProtocolError(
|
|
16379
|
+
"CLI_CONFIGURATION_ERROR",
|
|
16380
|
+
"Configuraci\xF3n cancelada por el usuario"
|
|
16381
|
+
)
|
|
16382
|
+
);
|
|
16383
|
+
return;
|
|
16384
|
+
}
|
|
16385
|
+
if (character === "\r" || character === "\n") {
|
|
16386
|
+
finish(value);
|
|
16387
|
+
return;
|
|
16388
|
+
}
|
|
16389
|
+
if (character === "\x7F" || character === "\b") {
|
|
16390
|
+
value = value.slice(0, -1);
|
|
16391
|
+
continue;
|
|
16392
|
+
}
|
|
16393
|
+
value += character;
|
|
16394
|
+
}
|
|
16395
|
+
};
|
|
16396
|
+
output.write(prompt);
|
|
16397
|
+
input.setRawMode(true);
|
|
16398
|
+
input.resume();
|
|
16399
|
+
input.on("data", onData);
|
|
16400
|
+
});
|
|
16401
|
+
}
|
|
15873
16402
|
async function openWithExecutable(command, args) {
|
|
15874
16403
|
return new Promise((resolve) => {
|
|
15875
16404
|
const child = spawn(command, args, { stdio: "ignore", shell: false, detached: true });
|
|
@@ -15937,6 +16466,21 @@ async function login(options) {
|
|
|
15937
16466
|
}
|
|
15938
16467
|
throw new CliProtocolError("CLI_AUTH_TIMEOUT", "La autorizaci\xF3n expir\xF3 antes de ser aprobada");
|
|
15939
16468
|
}
|
|
16469
|
+
async function configure(options) {
|
|
16470
|
+
const apiKey = await options.readSecret("Agent Key de Avileo (no se mostrar\xE1): ");
|
|
16471
|
+
saveLocalCredential(
|
|
16472
|
+
{
|
|
16473
|
+
apiKey,
|
|
16474
|
+
...options.env.AVILEO_AGENT_BASE_URL?.trim() ? { baseUrl: options.env.AVILEO_AGENT_BASE_URL.trim() } : {}
|
|
16475
|
+
},
|
|
16476
|
+
options.env
|
|
16477
|
+
);
|
|
16478
|
+
emitSuccess({
|
|
16479
|
+
configured: true,
|
|
16480
|
+
source: "local",
|
|
16481
|
+
credentialPath: localCredentialPath(options.env)
|
|
16482
|
+
});
|
|
16483
|
+
}
|
|
15940
16484
|
async function status(options) {
|
|
15941
16485
|
const credential = resolveCredential(options.env);
|
|
15942
16486
|
if (!credential) {
|
|
@@ -15948,7 +16492,7 @@ async function status(options) {
|
|
|
15948
16492
|
try {
|
|
15949
16493
|
business = await options.getClient().business.get();
|
|
15950
16494
|
} catch (error51) {
|
|
15951
|
-
const code = error51.code;
|
|
16495
|
+
const code = error51 && typeof error51 === "object" && "code" in error51 ? error51.code : void 0;
|
|
15952
16496
|
businessLookupError = typeof code === "string" ? code : "LOOKUP_FAILED";
|
|
15953
16497
|
}
|
|
15954
16498
|
emitSuccess({
|
|
@@ -15970,6 +16514,7 @@ async function logout(options) {
|
|
|
15970
16514
|
}
|
|
15971
16515
|
function registerAuthCommands(root, options) {
|
|
15972
16516
|
const auth = root.command("auth").description("Conecta la CLI con Avileo sin copiar claves en el chat");
|
|
16517
|
+
auth.command("configure").description("Guarda una Agent Key existente sin mostrarla en pantalla").action(() => configure(options));
|
|
15973
16518
|
auth.command("login").description("Autoriza esta CLI mediante un link temporal").action(() => login(options));
|
|
15974
16519
|
auth.command("status").description("Muestra el estado de la credencial sin revelar secretos").action(() => status(options));
|
|
15975
16520
|
auth.command("logout").description("Elimina solamente la credencial local").action(() => logout(options));
|
|
@@ -15996,11 +16541,32 @@ function createProgram(options = {}) {
|
|
|
15996
16541
|
env: options.env ?? process.env,
|
|
15997
16542
|
deviceAuthFactory: options.deviceAuthFactory ?? createAvileoAgentDeviceAuth,
|
|
15998
16543
|
openBrowser: options.openBrowser ?? openVerificationUri,
|
|
16544
|
+
readSecret: options.readSecret ?? readAgentKeyFromTty,
|
|
15999
16545
|
getClient,
|
|
16000
16546
|
json: () => Boolean(program.opts().json)
|
|
16001
16547
|
});
|
|
16002
16548
|
registerBusinessCommands(program, getClient);
|
|
16003
16549
|
registerCatalogCommands(program, getClient);
|
|
16550
|
+
const operation = program.command("operation").description("Consulta y aplica operaciones aprobadas en Avileo");
|
|
16551
|
+
operation.command("status <id>").description("Consulta el estado de una operaci\xF3n").action(async (id) => {
|
|
16552
|
+
if (!id.trim()) {
|
|
16553
|
+
throw new CliProtocolError("CLI_VALIDATION_ERROR", "id es obligatorio");
|
|
16554
|
+
}
|
|
16555
|
+
emitSuccess(await getClient().operations.get(id));
|
|
16556
|
+
});
|
|
16557
|
+
operation.command("apply <id>").description("Aplica una operaci\xF3n aprobada").action(async (id) => {
|
|
16558
|
+
if (!id.trim()) {
|
|
16559
|
+
throw new CliProtocolError("CLI_VALIDATION_ERROR", "id es obligatorio");
|
|
16560
|
+
}
|
|
16561
|
+
emitSuccess(await getClient().operations.apply(id));
|
|
16562
|
+
});
|
|
16563
|
+
program.command("catalog-key").description("Gestiona la Client Key p\xFAblica del cat\xE1logo").command("create").requiredOption("--name <name>", "Nombre visible de la Client Key").description("Propone crear una Client Key para aprobaci\xF3n en Avileo").action(async (options2) => {
|
|
16564
|
+
const name = options2.name.trim();
|
|
16565
|
+
if (!name) {
|
|
16566
|
+
throw new CliProtocolError("CLI_VALIDATION_ERROR", "name es obligatorio");
|
|
16567
|
+
}
|
|
16568
|
+
emitSuccess(await getClient().operations.proposeClientKey(name));
|
|
16569
|
+
});
|
|
16004
16570
|
const parseAsync3 = program.parseAsync.bind(program);
|
|
16005
16571
|
program.parseAsync = (async (...args) => {
|
|
16006
16572
|
try {
|