@tarileo/avileo-catalog-cli 0.3.16 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19963,7 +19963,11 @@ var AGENT_CAPABILITY_ACTIONS = [
19963
19963
  "inventory:write",
19964
19964
  "payments:read",
19965
19965
  "payments:write",
19966
- "sales:read"
19966
+ "sales:read",
19967
+ "appointments:read",
19968
+ "appointments:write",
19969
+ "storefront:read",
19970
+ "storefront:write"
19967
19971
  ];
19968
19972
  var AgentCapabilityActionSchema = external_exports.enum(AGENT_CAPABILITY_ACTIONS);
19969
19973
  var AGENT_KEY_MODES = ["read", "mutate"];
@@ -19974,7 +19978,9 @@ var AGENT_KEY_READ_ACTIONS = [
19974
19978
  "assets:read",
19975
19979
  "inventory:read",
19976
19980
  "payments:read",
19977
- "sales:read"
19981
+ "sales:read",
19982
+ "appointments:read",
19983
+ "storefront:read"
19978
19984
  ];
19979
19985
  var AgentGrantedActionsSchema = external_exports.array(AgentCapabilityActionSchema).min(1).max(AGENT_CAPABILITY_ACTIONS.length).refine((actions) => new Set(actions).size === actions.length, {
19980
19986
  message: "Las capacidades no pueden repetirse"
@@ -20601,6 +20607,95 @@ var AgentCatalogImportResultDtoSchema = external_exports.object({
20601
20607
  error: AgentCatalogImportErrorDtoSchema.nullable().optional(),
20602
20608
  items: external_exports.array(AgentCatalogImportItemResultDtoSchema).max(100).optional()
20603
20609
  }).strict();
20610
+ var AgentAppointmentServiceDtoSchema = external_exports.object({
20611
+ id: uuidSchema,
20612
+ name: nonEmptyTextSchema.max(255),
20613
+ description: external_exports.string().trim().max(1e4).nullable(),
20614
+ defaultDurationMinutes: external_exports.number().int().positive(),
20615
+ price: external_exports.number().nonnegative().nullable(),
20616
+ imageAssetId: uuidSchema.nullable(),
20617
+ requiresPrepayment: external_exports.boolean(),
20618
+ publicVisible: external_exports.boolean(),
20619
+ isActive: external_exports.boolean(),
20620
+ createdAt: timestampSchema,
20621
+ updatedAt: timestampSchema
20622
+ }).strict();
20623
+ var AgentCreateAppointmentServiceInputSchema = external_exports.object({
20624
+ name: nonEmptyTextSchema.max(255),
20625
+ description: external_exports.string().trim().max(1e4).optional(),
20626
+ defaultDurationMinutes: external_exports.number().int().min(5),
20627
+ price: external_exports.number().nonnegative().optional(),
20628
+ imageAssetId: uuidSchema.nullable().optional(),
20629
+ requiresPrepayment: external_exports.boolean().optional(),
20630
+ publicVisible: external_exports.boolean().optional()
20631
+ }).strict();
20632
+ var AgentUpdateAppointmentServiceInputSchema = external_exports.object({
20633
+ name: nonEmptyTextSchema.max(255).optional(),
20634
+ description: external_exports.string().trim().max(1e4).optional(),
20635
+ defaultDurationMinutes: external_exports.number().int().min(5).optional(),
20636
+ price: external_exports.number().nonnegative().optional(),
20637
+ imageAssetId: uuidSchema.nullable().optional(),
20638
+ requiresPrepayment: external_exports.boolean().optional(),
20639
+ publicVisible: external_exports.boolean().optional(),
20640
+ isActive: external_exports.boolean().optional()
20641
+ }).strict().refine((value) => Object.keys(value).length > 0, {
20642
+ message: "Debes indicar al menos un campo a actualizar"
20643
+ });
20644
+ var AgentAppointmentProfessionalDtoSchema = external_exports.object({
20645
+ id: uuidSchema,
20646
+ businessUserId: uuidSchema.nullable(),
20647
+ collaboratorId: uuidSchema.nullable(),
20648
+ displayName: nonEmptyTextSchema.max(160),
20649
+ specialty: external_exports.string().trim().max(120).nullable(),
20650
+ color: external_exports.string().trim().max(20).nullable(),
20651
+ defaultAppointmentDurationMinutes: external_exports.number().int().positive().nullable(),
20652
+ publicBookingEnabled: external_exports.boolean(),
20653
+ isActive: external_exports.boolean(),
20654
+ createdAt: timestampSchema,
20655
+ updatedAt: timestampSchema
20656
+ }).strict();
20657
+ var AgentCreateAppointmentProfessionalInputSchema = external_exports.object({
20658
+ businessUserId: uuidSchema.optional(),
20659
+ collaboratorId: uuidSchema.optional(),
20660
+ createWithoutAccess: external_exports.boolean().optional(),
20661
+ displayName: nonEmptyTextSchema.max(160),
20662
+ specialty: external_exports.string().trim().max(120).optional(),
20663
+ color: external_exports.string().trim().max(20).optional(),
20664
+ defaultAppointmentDurationMinutes: external_exports.number().int().min(5).optional(),
20665
+ publicBookingEnabled: external_exports.boolean().optional()
20666
+ }).strict();
20667
+ var AgentUpdateAppointmentProfessionalInputSchema = external_exports.object({
20668
+ displayName: nonEmptyTextSchema.max(160).optional(),
20669
+ specialty: external_exports.string().trim().max(120).nullable().optional(),
20670
+ color: external_exports.string().trim().max(20).nullable().optional(),
20671
+ defaultAppointmentDurationMinutes: external_exports.number().int().min(5).optional(),
20672
+ publicBookingEnabled: external_exports.boolean().optional(),
20673
+ isActive: external_exports.boolean().optional()
20674
+ }).strict().refine((value) => Object.keys(value).length > 0, {
20675
+ message: "Debes indicar al menos un campo a actualizar"
20676
+ });
20677
+ var AgentAppointmentWeeklyWindowSchema = external_exports.object({
20678
+ weekday: external_exports.number().int().min(0).max(6),
20679
+ startTime: external_exports.string().regex(/^\d{2}:\d{2}$/, "Formato HH:mm"),
20680
+ endTime: external_exports.string().regex(/^\d{2}:\d{2}$/, "Formato HH:mm")
20681
+ }).strict();
20682
+ var AgentSetAppointmentAvailabilityInputSchema = external_exports.object({
20683
+ weekly: external_exports.array(AgentAppointmentWeeklyWindowSchema).max(50)
20684
+ }).strict();
20685
+ var AgentAppointmentAvailabilityExceptionSchema = external_exports.object({
20686
+ date: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Formato YYYY-MM-DD"),
20687
+ type: external_exports.enum(["blocked", "extra_available"]),
20688
+ startTime: external_exports.string().regex(/^\d{2}:\d{2}$/, "Formato HH:mm").optional(),
20689
+ endTime: external_exports.string().regex(/^\d{2}:\d{2}$/, "Formato HH:mm").optional(),
20690
+ reason: external_exports.string().trim().max(255).optional()
20691
+ }).strict();
20692
+ var AgentSetAppointmentAvailabilityExceptionsInputSchema = external_exports.object({
20693
+ exceptions: external_exports.array(AgentAppointmentAvailabilityExceptionSchema).max(200)
20694
+ }).strict();
20695
+ var AgentSetStorefrontPublicationInputSchema = external_exports.object({
20696
+ enabled: external_exports.boolean(),
20697
+ slug: external_exports.string().trim().min(3).max(100).optional()
20698
+ }).strict();
20604
20699
  var AGENT_OPERATION_NAMES = [
20605
20700
  "catalog.products.create",
20606
20701
  "catalog.products.update",
@@ -20623,7 +20718,16 @@ var AGENT_OPERATION_NAMES = [
20623
20718
  "catalog.imports.preview",
20624
20719
  "catalog.imports.apply",
20625
20720
  "business.profile.update",
20626
- "catalog.client_keys.create"
20721
+ "catalog.client_keys.create",
20722
+ "appointments.services.create",
20723
+ "appointments.services.update",
20724
+ "appointments.services.deactivate",
20725
+ "appointments.professionals.create",
20726
+ "appointments.professionals.update",
20727
+ "appointments.professionals.deactivate",
20728
+ "appointments.availability.set",
20729
+ "appointments.availability.exceptions.set",
20730
+ "storefront.publication.set"
20627
20731
  ];
20628
20732
  var AgentOperationNameSchema = external_exports.enum(AGENT_OPERATION_NAMES);
20629
20733
  var AGENT_OPERATION_STATES = [
@@ -21240,6 +21344,41 @@ var AgentOperationsResource = class {
21240
21344
  });
21241
21345
  }
21242
21346
  };
21347
+ var AgentAppointmentsResource = class {
21348
+ constructor(http) {
21349
+ this.http = http;
21350
+ }
21351
+ http;
21352
+ listServices(includeInactive = false) {
21353
+ return this.http.request(
21354
+ `/api/v1/agent/appointments/services${queryString({ includeInactive: includeInactive || void 0 })}`
21355
+ );
21356
+ }
21357
+ listProfessionals(includeInactive = false) {
21358
+ return this.http.request(
21359
+ `/api/v1/agent/appointments/professionals${queryString({ includeInactive: includeInactive || void 0 })}`
21360
+ );
21361
+ }
21362
+ getAvailability(professionalId) {
21363
+ return this.http.request(
21364
+ `/api/v1/agent/appointments/professionals/${encodeURIComponent(professionalId)}/availability`
21365
+ );
21366
+ }
21367
+ getAgenda(date5, professionalId) {
21368
+ return this.http.request(
21369
+ `/api/v1/agent/appointments/agenda${queryString({ date: date5, professionalId })}`
21370
+ );
21371
+ }
21372
+ };
21373
+ var AgentStorefrontResource = class {
21374
+ constructor(http) {
21375
+ this.http = http;
21376
+ }
21377
+ http;
21378
+ getPublication() {
21379
+ return this.http.request("/api/v1/agent/storefront/publication");
21380
+ }
21381
+ };
21243
21382
  var AgentPaymentMethodListSchema = external_exports.array(AgentPaymentMethodDtoSchema);
21244
21383
  var AgentPaymentMethodsResource = class {
21245
21384
  constructor(http) {
@@ -21332,6 +21471,8 @@ function createAvileoAgent(config2) {
21332
21471
  assets: new AgentAssetsResource(http),
21333
21472
  inventory: new AgentInventoryResource(http),
21334
21473
  imports: new AgentImportsResource(http),
21474
+ appointments: new AgentAppointmentsResource(http),
21475
+ storefront: new AgentStorefrontResource(http),
21335
21476
  paymentLinks: new AgentPaymentLinksResource(http),
21336
21477
  paymentMethods: new AgentPaymentMethodsResource(http)
21337
21478
  };
@@ -21859,6 +22000,20 @@ function localResult(input2, current) {
21859
22000
  );
21860
22001
  return { validated: "local", current, changes };
21861
22002
  }
22003
+ function requireId(value, name) {
22004
+ if (!value.trim()) throw new CliProtocolError("CLI_VALIDATION_ERROR", `${name} es obligatorio`);
22005
+ return value;
22006
+ }
22007
+ function wantsApply(command) {
22008
+ return Boolean(command.optsWithGlobals().apply);
22009
+ }
22010
+ function withMutationOptions(command, includeFrom = true) {
22011
+ if (includeFrom) command.requiredOption("--from <json-file>", "Objeto JSON estructurado");
22012
+ return command.option(
22013
+ "--apply",
22014
+ "Crea una propuesta para aprobaci\xF3n en Avileo (apl\xEDcala luego con `operation apply <id>`)"
22015
+ );
22016
+ }
21862
22017
 
21863
22018
  // src/commands/business.ts
21864
22019
  function profileValues(profile) {
@@ -22110,15 +22265,15 @@ function approvedProductUpdate(operation, approvalId, productId) {
22110
22265
  }
22111
22266
 
22112
22267
  // src/commands/catalog.ts
22113
- function requireId(value, name) {
22268
+ function requireId2(value, name) {
22114
22269
  if (!value.trim()) throw new CliProtocolError("CLI_VALIDATION_ERROR", `${name} es obligatorio`);
22115
22270
  return value;
22116
22271
  }
22117
- function withMutationOptions(command, includeFrom = true) {
22272
+ function withMutationOptions2(command, includeFrom = true) {
22118
22273
  if (includeFrom) command.requiredOption("--from <json-file>", "Objeto JSON estructurado");
22119
22274
  return command.option("--apply", "Solicita aprobaci\xF3n o ejecuta una mutaci\xF3n aprobada").option("--approval-id <uuid>", "Aprobaci\xF3n emitida por Avileo");
22120
22275
  }
22121
- function wantsApply(command) {
22276
+ function wantsApply2(command) {
22122
22277
  return Boolean(command.optsWithGlobals().apply);
22123
22278
  }
22124
22279
  function addListOptions(command) {
@@ -22136,13 +22291,13 @@ function parseBoolean(value) {
22136
22291
  throw new CliProtocolError("CLI_VALIDATION_ERROR", "Se esperaba true o false");
22137
22292
  }
22138
22293
  async function applyOrPreview(command, input2, getClient, operationName, payload, run, current) {
22139
- if (!wantsApply(command)) {
22294
+ if (!wantsApply2(command)) {
22140
22295
  emitSuccess(localResult(input2, current ? await current() : void 0));
22141
22296
  return;
22142
22297
  }
22143
22298
  const rawApprovalId = command.optsWithGlobals().approvalId;
22144
22299
  if (typeof rawApprovalId === "string") {
22145
- emitSuccess(await run(requireId(rawApprovalId, "approvalId")));
22300
+ emitSuccess(await run(requireId2(rawApprovalId, "approvalId")));
22146
22301
  return;
22147
22302
  }
22148
22303
  emitSuccess(await getClient().operations.propose({ operationName, payload }));
@@ -22174,9 +22329,9 @@ function registerProductCommands(catalog, getClient) {
22174
22329
  );
22175
22330
  });
22176
22331
  product.command("get <productId>").action(async (productId) => {
22177
- emitSuccess(await getClient().products.get(requireId(productId, "productId")));
22332
+ emitSuccess(await getClient().products.get(requireId2(productId, "productId")));
22178
22333
  });
22179
- withMutationOptions(product.command("create")).action(async (options, command) => {
22334
+ withMutationOptions2(product.command("create")).action(async (options, command) => {
22180
22335
  const input2 = await readMutationInput(options.from);
22181
22336
  await applyOrPreview(
22182
22337
  command,
@@ -22187,15 +22342,15 @@ function registerProductCommands(catalog, getClient) {
22187
22342
  (approvalId) => getClient().products.create(input2, approvalId)
22188
22343
  );
22189
22344
  });
22190
- withMutationOptions(
22345
+ withMutationOptions2(
22191
22346
  product.command("update <productId>").option("--from <json-file>", "Objeto JSON estructurado"),
22192
22347
  false
22193
22348
  ).action(async (productId, options, command) => {
22194
- const id = requireId(productId, "productId");
22349
+ const id = requireId2(productId, "productId");
22195
22350
  const { approvalId: rawApprovalId } = command.optsWithGlobals();
22196
- const approvalId = typeof rawApprovalId === "string" ? requireId(rawApprovalId, "approvalId") : void 0;
22351
+ const approvalId = typeof rawApprovalId === "string" ? requireId2(rawApprovalId, "approvalId") : void 0;
22197
22352
  if (!options.from) {
22198
- if (!wantsApply(command) || !approvalId) {
22353
+ if (!wantsApply2(command) || !approvalId) {
22199
22354
  throw new CliProtocolError(
22200
22355
  "CLI_VALIDATION_ERROR",
22201
22356
  "--from es obligatorio salvo al aplicar con --apply --approval-id"
@@ -22209,7 +22364,7 @@ function registerProductCommands(catalog, getClient) {
22209
22364
  }
22210
22365
  const input2 = await readMutationInput(options.from);
22211
22366
  const prepared = await prepareProductUpdate(input2, options.from, approvalId === void 0);
22212
- if (wantsApply(command) && !approvalId) {
22367
+ if (wantsApply2(command) && !approvalId) {
22213
22368
  const uploaded = /* @__PURE__ */ new Map();
22214
22369
  for (const [placeholder, file2] of prepared.files) {
22215
22370
  const image = await getClient().products.uploadImage(file2);
@@ -22235,9 +22390,9 @@ function registerProductCommands(catalog, getClient) {
22235
22390
  () => getClient().products.get(id)
22236
22391
  );
22237
22392
  });
22238
- withMutationOptions(product.command("deactivate <productId>"), false).action(
22393
+ withMutationOptions2(product.command("deactivate <productId>"), false).action(
22239
22394
  async (productId, _options, command) => {
22240
- const id = requireId(productId, "productId");
22395
+ const id = requireId2(productId, "productId");
22241
22396
  await applyOrPreview(
22242
22397
  command,
22243
22398
  { isActive: false },
@@ -22253,14 +22408,14 @@ function registerProductCommands(catalog, getClient) {
22253
22408
  function registerVariantCommands(catalog, getClient) {
22254
22409
  const variant = catalog.command("variant");
22255
22410
  variant.command("list <productId>").action(async (productId) => {
22256
- emitSuccess(await getClient().variants.list(requireId(productId, "productId")));
22411
+ emitSuccess(await getClient().variants.list(requireId2(productId, "productId")));
22257
22412
  });
22258
22413
  variant.command("get <variantId>").action(async (variantId) => {
22259
- emitSuccess(await getClient().variants.get(requireId(variantId, "variantId")));
22414
+ emitSuccess(await getClient().variants.get(requireId2(variantId, "variantId")));
22260
22415
  });
22261
- withMutationOptions(variant.command("create <productId>")).action(
22416
+ withMutationOptions2(variant.command("create <productId>")).action(
22262
22417
  async (productId, options, command) => {
22263
- const id = requireId(productId, "productId");
22418
+ const id = requireId2(productId, "productId");
22264
22419
  const input2 = await readMutationInput(options.from);
22265
22420
  await applyOrPreview(
22266
22421
  command,
@@ -22272,9 +22427,9 @@ function registerVariantCommands(catalog, getClient) {
22272
22427
  );
22273
22428
  }
22274
22429
  );
22275
- withMutationOptions(variant.command("update <variantId>")).action(
22430
+ withMutationOptions2(variant.command("update <variantId>")).action(
22276
22431
  async (variantId, options, command) => {
22277
- const id = requireId(variantId, "variantId");
22432
+ const id = requireId2(variantId, "variantId");
22278
22433
  const input2 = await readMutationInput(options.from);
22279
22434
  await applyOrPreview(
22280
22435
  command,
@@ -22287,9 +22442,9 @@ function registerVariantCommands(catalog, getClient) {
22287
22442
  );
22288
22443
  }
22289
22444
  );
22290
- withMutationOptions(variant.command("deactivate <variantId>"), false).action(
22445
+ withMutationOptions2(variant.command("deactivate <variantId>"), false).action(
22291
22446
  async (variantId, _options, command) => {
22292
- const id = requireId(variantId, "variantId");
22447
+ const id = requireId2(variantId, "variantId");
22293
22448
  await applyOrPreview(
22294
22449
  command,
22295
22450
  { isActive: false },
@@ -22301,9 +22456,9 @@ function registerVariantCommands(catalog, getClient) {
22301
22456
  );
22302
22457
  }
22303
22458
  );
22304
- withMutationOptions(variant.command("reorder <productId>")).action(
22459
+ withMutationOptions2(variant.command("reorder <productId>")).action(
22305
22460
  async (productId, options, command) => {
22306
- const id = requireId(productId, "productId");
22461
+ const id = requireId2(productId, "productId");
22307
22462
  const input2 = await readMutationInput(options.from);
22308
22463
  await applyOrPreview(
22309
22464
  command,
@@ -22321,9 +22476,9 @@ function registerCategoryCommands(catalog, getClient) {
22321
22476
  const category = catalog.command("category");
22322
22477
  category.command("list").action(async () => emitSuccess(await getClient().categories.list()));
22323
22478
  category.command("get <categoryId>").action(async (categoryId) => {
22324
- emitSuccess(await getClient().categories.get(requireId(categoryId, "categoryId")));
22479
+ emitSuccess(await getClient().categories.get(requireId2(categoryId, "categoryId")));
22325
22480
  });
22326
- withMutationOptions(category.command("create")).action(async (options, command) => {
22481
+ withMutationOptions2(category.command("create")).action(async (options, command) => {
22327
22482
  const input2 = await readMutationInput(options.from);
22328
22483
  await applyOrPreview(
22329
22484
  command,
@@ -22334,9 +22489,9 @@ function registerCategoryCommands(catalog, getClient) {
22334
22489
  (approvalId) => getClient().categories.create(input2, approvalId)
22335
22490
  );
22336
22491
  });
22337
- withMutationOptions(category.command("update <categoryId>")).action(
22492
+ withMutationOptions2(category.command("update <categoryId>")).action(
22338
22493
  async (categoryId, options, command) => {
22339
- const id = requireId(categoryId, "categoryId");
22494
+ const id = requireId2(categoryId, "categoryId");
22340
22495
  const input2 = await readMutationInput(options.from);
22341
22496
  await applyOrPreview(
22342
22497
  command,
@@ -22349,9 +22504,9 @@ function registerCategoryCommands(catalog, getClient) {
22349
22504
  );
22350
22505
  }
22351
22506
  );
22352
- withMutationOptions(category.command("delete <categoryId>"), false).action(
22507
+ withMutationOptions2(category.command("delete <categoryId>"), false).action(
22353
22508
  async (categoryId, _options, command) => {
22354
- const id = requireId(categoryId, "categoryId");
22509
+ const id = requireId2(categoryId, "categoryId");
22355
22510
  await applyOrPreview(
22356
22511
  command,
22357
22512
  { delete: true },
@@ -22368,9 +22523,9 @@ function registerTagCommands(catalog, getClient) {
22368
22523
  const tag = catalog.command("tag");
22369
22524
  tag.command("list").action(async () => emitSuccess(await getClient().tags.list()));
22370
22525
  tag.command("get <tagId>").action(async (tagId) => {
22371
- emitSuccess(await getClient().tags.get(requireId(tagId, "tagId")));
22526
+ emitSuccess(await getClient().tags.get(requireId2(tagId, "tagId")));
22372
22527
  });
22373
- withMutationOptions(tag.command("create")).action(async (options, command) => {
22528
+ withMutationOptions2(tag.command("create")).action(async (options, command) => {
22374
22529
  const input2 = await readMutationInput(options.from);
22375
22530
  await applyOrPreview(
22376
22531
  command,
@@ -22381,8 +22536,8 @@ function registerTagCommands(catalog, getClient) {
22381
22536
  (approvalId) => getClient().tags.create(input2, approvalId)
22382
22537
  );
22383
22538
  });
22384
- withMutationOptions(tag.command("update <tagId>")).action(async (tagId, options, command) => {
22385
- const id = requireId(tagId, "tagId");
22539
+ withMutationOptions2(tag.command("update <tagId>")).action(async (tagId, options, command) => {
22540
+ const id = requireId2(tagId, "tagId");
22386
22541
  const input2 = await readMutationInput(options.from);
22387
22542
  await applyOrPreview(
22388
22543
  command,
@@ -22394,9 +22549,9 @@ function registerTagCommands(catalog, getClient) {
22394
22549
  () => getClient().tags.get(id)
22395
22550
  );
22396
22551
  });
22397
- withMutationOptions(tag.command("delete <tagId>"), false).action(
22552
+ withMutationOptions2(tag.command("delete <tagId>"), false).action(
22398
22553
  async (tagId, _options, command) => {
22399
- const id = requireId(tagId, "tagId");
22554
+ const id = requireId2(tagId, "tagId");
22400
22555
  await applyOrPreview(
22401
22556
  command,
22402
22557
  { delete: true },
@@ -22419,12 +22574,12 @@ function registerAssetCommands(catalog, getClient) {
22419
22574
  emitSuccess(await getClient().assets.list(parsed.data));
22420
22575
  });
22421
22576
  asset.command("get <assetId>").action(async (assetId) => {
22422
- emitSuccess(await getClient().assets.get(requireId(assetId, "assetId")));
22577
+ emitSuccess(await getClient().assets.get(requireId2(assetId, "assetId")));
22423
22578
  });
22424
- withMutationOptions(
22579
+ withMutationOptions2(
22425
22580
  asset.command("update <assetId>").option("--diff", "Incluye la ficha actual")
22426
22581
  ).action(async (assetId, options, command) => {
22427
- const id = requireId(assetId, "assetId");
22582
+ const id = requireId2(assetId, "assetId");
22428
22583
  const parsed = AssetMetadataUpdateInputSchema.safeParse(await readMutationInput(options.from));
22429
22584
  if (!parsed.success) {
22430
22585
  throw new CliProtocolError(
@@ -22443,7 +22598,7 @@ function registerAssetCommands(catalog, getClient) {
22443
22598
  options.diff ? () => getClient().assets.get(id) : void 0
22444
22599
  );
22445
22600
  });
22446
- withMutationOptions(
22601
+ withMutationOptions2(
22447
22602
  asset.command("upload").requiredOption("--file <path>", "Archivo local"),
22448
22603
  false
22449
22604
  ).action(async (options, command) => {
@@ -22452,7 +22607,7 @@ function registerAssetCommands(catalog, getClient) {
22452
22607
  if (!fileStat.isFile()) {
22453
22608
  throw new CliProtocolError("CLI_VALIDATION_ERROR", "--file debe apuntar a un archivo");
22454
22609
  }
22455
- if (!wantsApply(command)) {
22610
+ if (!wantsApply2(command)) {
22456
22611
  emitSuccess({
22457
22612
  validated: "local",
22458
22613
  file: basename3(filePath),
@@ -22472,7 +22627,7 @@ function registerAssetCommands(catalog, getClient) {
22472
22627
  const file2 = new File([contents], basename3(filePath), { type: mimeType });
22473
22628
  const rawApprovalId = command.optsWithGlobals().approvalId;
22474
22629
  if (typeof rawApprovalId === "string") {
22475
- emitSuccess(await getClient().assets.upload(file2, requireId(rawApprovalId, "approvalId")));
22630
+ emitSuccess(await getClient().assets.upload(file2, requireId2(rawApprovalId, "approvalId")));
22476
22631
  return;
22477
22632
  }
22478
22633
  emitSuccess(
@@ -22487,7 +22642,7 @@ function registerAssetCommands(catalog, getClient) {
22487
22642
  })
22488
22643
  );
22489
22644
  });
22490
- withMutationOptions(asset.command("import-url")).action(async (options, command) => {
22645
+ withMutationOptions2(asset.command("import-url")).action(async (options, command) => {
22491
22646
  const input2 = await readMutationInput(options.from);
22492
22647
  await applyOrPreview(
22493
22648
  command,
@@ -22502,16 +22657,16 @@ function registerAssetCommands(catalog, getClient) {
22502
22657
  function registerInventoryCommands(catalog, getClient) {
22503
22658
  const inventory = catalog.command("inventory");
22504
22659
  inventory.command("get <variantId>").action(async (variantId) => {
22505
- emitSuccess(await getClient().inventory.get(requireId(variantId, "variantId")));
22660
+ emitSuccess(await getClient().inventory.get(requireId2(variantId, "variantId")));
22506
22661
  });
22507
22662
  inventory.command("movements <variantId>").option("--reason <reason>").option("--limit <number>", "M\xE1ximo de resultados", parseInteger).option("--offset <number>", "Desplazamiento", parseInteger).action(async (variantId, options) => {
22508
22663
  emitSuccess(
22509
- await getClient().inventory.listMovements(requireId(variantId, "variantId"), options)
22664
+ await getClient().inventory.listMovements(requireId2(variantId, "variantId"), options)
22510
22665
  );
22511
22666
  });
22512
- withMutationOptions(inventory.command("adjust <variantId>")).action(
22667
+ withMutationOptions2(inventory.command("adjust <variantId>")).action(
22513
22668
  async (variantId, options, command) => {
22514
- const id = requireId(variantId, "variantId");
22669
+ const id = requireId2(variantId, "variantId");
22515
22670
  const input2 = await readMutationInput(options.from);
22516
22671
  await applyOrPreview(
22517
22672
  command,
@@ -22524,9 +22679,9 @@ function registerInventoryCommands(catalog, getClient) {
22524
22679
  );
22525
22680
  }
22526
22681
  );
22527
- withMutationOptions(inventory.command("set <variantId>")).action(
22682
+ withMutationOptions2(inventory.command("set <variantId>")).action(
22528
22683
  async (variantId, options, command) => {
22529
- const id = requireId(variantId, "variantId");
22684
+ const id = requireId2(variantId, "variantId");
22530
22685
  const input2 = await readMutationInput(options.from);
22531
22686
  await applyOrPreview(
22532
22687
  command,
@@ -22548,9 +22703,9 @@ function registerImportCommands(catalog, getClient) {
22548
22703
  const prepared = await prepareCatalogImport(input2, options.from, client.imports);
22549
22704
  emitSuccess(await client.imports.preview(prepared));
22550
22705
  });
22551
- withMutationOptions(imports.command("apply <importId>"), false).action(
22706
+ withMutationOptions2(imports.command("apply <importId>"), false).action(
22552
22707
  async (importId, _options, command) => {
22553
- const id = requireId(importId, "importId");
22708
+ const id = requireId2(importId, "importId");
22554
22709
  await applyOrPreview(
22555
22710
  command,
22556
22711
  { importId: id, action: "apply" },
@@ -22563,7 +22718,244 @@ function registerImportCommands(catalog, getClient) {
22563
22718
  );
22564
22719
  imports.command("example").description("Imprime el payload can\xF3nico de una importaci\xF3n").action(() => emitSuccess(CATALOG_IMPORT_EXAMPLE));
22565
22720
  imports.command("status <importId>").action(async (importId) => {
22566
- emitSuccess(await getClient().imports.get(requireId(importId, "importId")));
22721
+ emitSuccess(await getClient().imports.get(requireId2(importId, "importId")));
22722
+ });
22723
+ }
22724
+
22725
+ // src/commands/appointments.ts
22726
+ async function proposeOrPreview(command, getClient, operationName, input2, payload, current) {
22727
+ if (!wantsApply(command)) {
22728
+ emitSuccess(localResult(input2, current ? await current() : void 0));
22729
+ return;
22730
+ }
22731
+ emitSuccess(
22732
+ await getClient().operations.propose({
22733
+ operationName,
22734
+ payload
22735
+ })
22736
+ );
22737
+ }
22738
+ function requireDateFormat(value, name) {
22739
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
22740
+ throw new CliProtocolError("CLI_VALIDATION_ERROR", `${name} debe tener el formato YYYY-MM-DD`);
22741
+ }
22742
+ return value;
22743
+ }
22744
+ function datesInRange(from, to) {
22745
+ const start = /* @__PURE__ */ new Date(`${from}T00:00:00Z`);
22746
+ const end = /* @__PURE__ */ new Date(`${to}T00:00:00Z`);
22747
+ if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime())) {
22748
+ throw new CliProtocolError("CLI_VALIDATION_ERROR", "Fechas inv\xE1lidas");
22749
+ }
22750
+ if (end < start) {
22751
+ throw new CliProtocolError("CLI_VALIDATION_ERROR", "--to no puede ser anterior a --date");
22752
+ }
22753
+ const maxDays = 31;
22754
+ const dates = [];
22755
+ const cursor = new Date(start);
22756
+ while (cursor <= end) {
22757
+ dates.push(cursor.toISOString().slice(0, 10));
22758
+ cursor.setUTCDate(cursor.getUTCDate() + 1);
22759
+ if (dates.length > maxDays) {
22760
+ throw new CliProtocolError(
22761
+ "CLI_VALIDATION_ERROR",
22762
+ `El rango entre --date y --to no puede superar ${maxDays} d\xEDas`
22763
+ );
22764
+ }
22765
+ }
22766
+ return dates;
22767
+ }
22768
+ async function findService(getClient, serviceId) {
22769
+ const services = await getClient().appointments.listServices(true);
22770
+ const match = services.find((service) => service.id === serviceId);
22771
+ if (!match) {
22772
+ throw new CliProtocolError("CLI_NOT_FOUND", `No se encontr\xF3 el servicio ${serviceId}`);
22773
+ }
22774
+ return match;
22775
+ }
22776
+ async function findProfessional(getClient, professionalId) {
22777
+ const professionals = await getClient().appointments.listProfessionals(true);
22778
+ const match = professionals.find((professional) => professional.id === professionalId);
22779
+ if (!match) {
22780
+ throw new CliProtocolError("CLI_NOT_FOUND", `No se encontr\xF3 el profesional ${professionalId}`);
22781
+ }
22782
+ return match;
22783
+ }
22784
+ function registerServiceCommands(root, getClient) {
22785
+ const services = root.command("services").description("Consulta y gestiona los servicios de citas del negocio");
22786
+ services.command("list").option("--include-inactive", "Incluye servicios desactivados").action(async (options) => {
22787
+ emitSuccess(await getClient().appointments.listServices(Boolean(options.includeInactive)));
22788
+ });
22789
+ services.command("show <serviceId>").action(async (serviceId) => {
22790
+ emitSuccess(await findService(getClient, requireId(serviceId, "serviceId")));
22791
+ });
22792
+ withMutationOptions(services.command("create")).action(async (options, command) => {
22793
+ const input2 = await readMutationInput(options.from);
22794
+ await proposeOrPreview(command, getClient, "appointments.services.create", input2, {
22795
+ body: input2
22796
+ });
22797
+ });
22798
+ withMutationOptions(services.command("update <serviceId>")).action(
22799
+ async (serviceId, options, command) => {
22800
+ const id = requireId(serviceId, "serviceId");
22801
+ const input2 = await readMutationInput(options.from);
22802
+ await proposeOrPreview(
22803
+ command,
22804
+ getClient,
22805
+ "appointments.services.update",
22806
+ input2,
22807
+ { serviceId: id, body: input2 },
22808
+ () => findService(getClient, id)
22809
+ );
22810
+ }
22811
+ );
22812
+ withMutationOptions(services.command("deactivate <serviceId>"), false).action(
22813
+ async (serviceId, _options, command) => {
22814
+ const id = requireId(serviceId, "serviceId");
22815
+ await proposeOrPreview(
22816
+ command,
22817
+ getClient,
22818
+ "appointments.services.deactivate",
22819
+ { isActive: false },
22820
+ { serviceId: id },
22821
+ () => findService(getClient, id)
22822
+ );
22823
+ }
22824
+ );
22825
+ }
22826
+ function registerProfessionalCommands(root, getClient) {
22827
+ const professionals = root.command("professionals").description("Consulta y gestiona los profesionales de citas del negocio");
22828
+ professionals.command("list").option("--include-inactive", "Incluye profesionales desactivados").action(async (options) => {
22829
+ emitSuccess(
22830
+ await getClient().appointments.listProfessionals(Boolean(options.includeInactive))
22831
+ );
22832
+ });
22833
+ professionals.command("show <professionalId>").action(async (professionalId) => {
22834
+ emitSuccess(await findProfessional(getClient, requireId(professionalId, "professionalId")));
22835
+ });
22836
+ withMutationOptions(professionals.command("create")).action(async (options, command) => {
22837
+ const input2 = await readMutationInput(options.from);
22838
+ await proposeOrPreview(command, getClient, "appointments.professionals.create", input2, {
22839
+ body: input2
22840
+ });
22841
+ });
22842
+ withMutationOptions(professionals.command("update <professionalId>")).action(
22843
+ async (professionalId, options, command) => {
22844
+ const id = requireId(professionalId, "professionalId");
22845
+ const input2 = await readMutationInput(options.from);
22846
+ await proposeOrPreview(
22847
+ command,
22848
+ getClient,
22849
+ "appointments.professionals.update",
22850
+ input2,
22851
+ { professionalId: id, body: input2 },
22852
+ () => findProfessional(getClient, id)
22853
+ );
22854
+ }
22855
+ );
22856
+ withMutationOptions(professionals.command("deactivate <professionalId>"), false).action(
22857
+ async (professionalId, _options, command) => {
22858
+ const id = requireId(professionalId, "professionalId");
22859
+ await proposeOrPreview(
22860
+ command,
22861
+ getClient,
22862
+ "appointments.professionals.deactivate",
22863
+ { isActive: false },
22864
+ { professionalId: id },
22865
+ () => findProfessional(getClient, id)
22866
+ );
22867
+ }
22868
+ );
22869
+ }
22870
+ function registerAvailabilityCommands(root, getClient) {
22871
+ const availability = root.command("availability").description("Consulta y reemplaza el horario y las excepciones de un profesional");
22872
+ availability.command("show <professionalId>").action(async (professionalId) => {
22873
+ emitSuccess(
22874
+ await getClient().appointments.getAvailability(requireId(professionalId, "professionalId"))
22875
+ );
22876
+ });
22877
+ withMutationOptions(availability.command("set <professionalId>")).action(
22878
+ async (professionalId, options, command) => {
22879
+ const id = requireId(professionalId, "professionalId");
22880
+ const input2 = await readMutationInput(options.from);
22881
+ await proposeOrPreview(
22882
+ command,
22883
+ getClient,
22884
+ "appointments.availability.set",
22885
+ input2,
22886
+ { professionalId: id, body: input2 },
22887
+ () => getClient().appointments.getAvailability(id)
22888
+ );
22889
+ }
22890
+ );
22891
+ withMutationOptions(availability.command("exceptions-set <professionalId>")).action(
22892
+ async (professionalId, options, command) => {
22893
+ const id = requireId(professionalId, "professionalId");
22894
+ const input2 = await readMutationInput(options.from);
22895
+ await proposeOrPreview(
22896
+ command,
22897
+ getClient,
22898
+ "appointments.availability.exceptions.set",
22899
+ input2,
22900
+ { professionalId: id, body: input2 },
22901
+ () => getClient().appointments.getAvailability(id)
22902
+ );
22903
+ }
22904
+ );
22905
+ }
22906
+ function registerAgendaCommand(root, getClient) {
22907
+ root.command("agenda").description("Consulta la agenda de citas de un d\xEDa o un rango de d\xEDas").requiredOption("--date <YYYY-MM-DD>", "Fecha inicial").option("--to <YYYY-MM-DD>", "Fecha final (inclusive); por defecto igual a --date").option("--professional-id <id>", "Filtra por un profesional").action(async (options) => {
22908
+ const from = requireDateFormat(options.date, "--date");
22909
+ const to = options.to ? requireDateFormat(options.to, "--to") : from;
22910
+ const dates = datesInRange(from, to);
22911
+ const client = getClient();
22912
+ const byDate = {};
22913
+ for (const date5 of dates) {
22914
+ byDate[date5] = await client.appointments.getAgenda(date5, options.professionalId);
22915
+ }
22916
+ emitSuccess(dates.length === 1 ? byDate[from] : byDate);
22917
+ });
22918
+ }
22919
+ function registerAppointmentsCommands(root, getClient) {
22920
+ registerServiceCommands(root, getClient);
22921
+ registerProfessionalCommands(root, getClient);
22922
+ registerAvailabilityCommands(root, getClient);
22923
+ registerAgendaCommand(root, getClient);
22924
+ }
22925
+
22926
+ // src/commands/storefront.ts
22927
+ function registerStorefrontCommands(root, getClient) {
22928
+ const storefront = root.command("storefront").description("Consulta y publica la tienda p\xFAblica de citas");
22929
+ storefront.command("status").description("Muestra el estado, slug y disposici\xF3n de publicaci\xF3n de la tienda").action(async () => {
22930
+ emitSuccess(await getClient().storefront.getPublication());
22931
+ });
22932
+ storefront.command("publish").description("Previsualiza o propone publicar la tienda con un slug").option("--slug <slug>", "Slug p\xFAblico deseado (3-100 caracteres)").option(
22933
+ "--apply",
22934
+ "Crea una propuesta para aprobaci\xF3n en Avileo (apl\xEDcala luego con `operation apply <id>`)"
22935
+ ).action(async (options, command) => {
22936
+ const input2 = { enabled: true, ...options.slug ? { slug: options.slug } : {} };
22937
+ await proposeOrPreview(
22938
+ command,
22939
+ getClient,
22940
+ "storefront.publication.set",
22941
+ input2,
22942
+ input2,
22943
+ () => getClient().storefront.getPublication()
22944
+ );
22945
+ });
22946
+ storefront.command("unpublish").description("Previsualiza o propone despublicar la tienda").option(
22947
+ "--apply",
22948
+ "Crea una propuesta para aprobaci\xF3n en Avileo (apl\xEDcala luego con `operation apply <id>`)"
22949
+ ).action(async (_options, command) => {
22950
+ const input2 = { enabled: false };
22951
+ await proposeOrPreview(
22952
+ command,
22953
+ getClient,
22954
+ "storefront.publication.set",
22955
+ input2,
22956
+ input2,
22957
+ () => getClient().storefront.getPublication()
22958
+ );
22567
22959
  });
22568
22960
  }
22569
22961
 
@@ -23109,6 +23501,8 @@ function createProgram(options = {}) {
23109
23501
  registerBusinessCommands(program, getClient);
23110
23502
  registerSalesCommands(program, getClient);
23111
23503
  registerCatalogCommands(program, getClient);
23504
+ registerAppointmentsCommands(program, getClient);
23505
+ registerStorefrontCommands(program, getClient);
23112
23506
  const operation = program.command("operation").description("Consulta y aplica operaciones aprobadas en Avileo");
23113
23507
  registerOperationBatchCommands(operation, getClient);
23114
23508
  operation.command("status <id>").description("Consulta el estado de una operaci\xF3n").action(async (id) => {