@tarileo/avileo-catalog-cli 0.3.15 → 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"
@@ -20273,9 +20279,12 @@ var AgentVariantDtoSchema = external_exports.object({
20273
20279
  createdAt: timestampSchema,
20274
20280
  updatedAt: timestampSchema
20275
20281
  }).strict();
20282
+ var AgentProductKindSchema = external_exports.enum(["product", "service"]);
20276
20283
  var AgentProductDtoSchema = external_exports.object({
20277
20284
  id: uuidSchema,
20278
20285
  name: nonEmptyTextSchema.max(255),
20286
+ /** Defaults to `product` so responses from servers that predate services still parse. */
20287
+ kind: AgentProductKindSchema.default("product"),
20279
20288
  description: external_exports.string().nullable(),
20280
20289
  category: AgentCategoryDtoSchema.nullable(),
20281
20290
  unit: UnitSlugSchema,
@@ -20394,6 +20403,7 @@ var AgentUpdateVariantInputSchema = external_exports.object({
20394
20403
  });
20395
20404
  var AgentCreateProductInputSchema = external_exports.object({
20396
20405
  name: nonEmptyTextSchema.max(255),
20406
+ kind: AgentProductKindSchema.optional(),
20397
20407
  categoryId: uuidSchema.optional(),
20398
20408
  unit: UnitSlugSchema,
20399
20409
  basePrice: nonNegativeDecimalStringSchema,
@@ -20407,6 +20417,7 @@ var AgentCreateProductInputSchema = external_exports.object({
20407
20417
  }).strict();
20408
20418
  var AgentUpdateProductInputSchema = external_exports.object({
20409
20419
  name: nonEmptyTextSchema.max(255).optional(),
20420
+ kind: AgentProductKindSchema.optional(),
20410
20421
  categoryId: uuidSchema.nullable().optional(),
20411
20422
  unit: UnitSlugSchema.optional(),
20412
20423
  basePrice: nonNegativeDecimalStringSchema.optional(),
@@ -20596,6 +20607,95 @@ var AgentCatalogImportResultDtoSchema = external_exports.object({
20596
20607
  error: AgentCatalogImportErrorDtoSchema.nullable().optional(),
20597
20608
  items: external_exports.array(AgentCatalogImportItemResultDtoSchema).max(100).optional()
20598
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();
20599
20699
  var AGENT_OPERATION_NAMES = [
20600
20700
  "catalog.products.create",
20601
20701
  "catalog.products.update",
@@ -20618,7 +20718,16 @@ var AGENT_OPERATION_NAMES = [
20618
20718
  "catalog.imports.preview",
20619
20719
  "catalog.imports.apply",
20620
20720
  "business.profile.update",
20621
- "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"
20622
20731
  ];
20623
20732
  var AgentOperationNameSchema = external_exports.enum(AGENT_OPERATION_NAMES);
20624
20733
  var AGENT_OPERATION_STATES = [
@@ -21235,6 +21344,41 @@ var AgentOperationsResource = class {
21235
21344
  });
21236
21345
  }
21237
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
+ };
21238
21382
  var AgentPaymentMethodListSchema = external_exports.array(AgentPaymentMethodDtoSchema);
21239
21383
  var AgentPaymentMethodsResource = class {
21240
21384
  constructor(http) {
@@ -21327,6 +21471,8 @@ function createAvileoAgent(config2) {
21327
21471
  assets: new AgentAssetsResource(http),
21328
21472
  inventory: new AgentInventoryResource(http),
21329
21473
  imports: new AgentImportsResource(http),
21474
+ appointments: new AgentAppointmentsResource(http),
21475
+ storefront: new AgentStorefrontResource(http),
21330
21476
  paymentLinks: new AgentPaymentLinksResource(http),
21331
21477
  paymentMethods: new AgentPaymentMethodsResource(http)
21332
21478
  };
@@ -21854,6 +22000,20 @@ function localResult(input2, current) {
21854
22000
  );
21855
22001
  return { validated: "local", current, changes };
21856
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
+ }
21857
22017
 
21858
22018
  // src/commands/business.ts
21859
22019
  function profileValues(profile) {
@@ -22105,15 +22265,15 @@ function approvedProductUpdate(operation, approvalId, productId) {
22105
22265
  }
22106
22266
 
22107
22267
  // src/commands/catalog.ts
22108
- function requireId(value, name) {
22268
+ function requireId2(value, name) {
22109
22269
  if (!value.trim()) throw new CliProtocolError("CLI_VALIDATION_ERROR", `${name} es obligatorio`);
22110
22270
  return value;
22111
22271
  }
22112
- function withMutationOptions(command, includeFrom = true) {
22272
+ function withMutationOptions2(command, includeFrom = true) {
22113
22273
  if (includeFrom) command.requiredOption("--from <json-file>", "Objeto JSON estructurado");
22114
22274
  return command.option("--apply", "Solicita aprobaci\xF3n o ejecuta una mutaci\xF3n aprobada").option("--approval-id <uuid>", "Aprobaci\xF3n emitida por Avileo");
22115
22275
  }
22116
- function wantsApply(command) {
22276
+ function wantsApply2(command) {
22117
22277
  return Boolean(command.optsWithGlobals().apply);
22118
22278
  }
22119
22279
  function addListOptions(command) {
@@ -22131,13 +22291,13 @@ function parseBoolean(value) {
22131
22291
  throw new CliProtocolError("CLI_VALIDATION_ERROR", "Se esperaba true o false");
22132
22292
  }
22133
22293
  async function applyOrPreview(command, input2, getClient, operationName, payload, run, current) {
22134
- if (!wantsApply(command)) {
22294
+ if (!wantsApply2(command)) {
22135
22295
  emitSuccess(localResult(input2, current ? await current() : void 0));
22136
22296
  return;
22137
22297
  }
22138
22298
  const rawApprovalId = command.optsWithGlobals().approvalId;
22139
22299
  if (typeof rawApprovalId === "string") {
22140
- emitSuccess(await run(requireId(rawApprovalId, "approvalId")));
22300
+ emitSuccess(await run(requireId2(rawApprovalId, "approvalId")));
22141
22301
  return;
22142
22302
  }
22143
22303
  emitSuccess(await getClient().operations.propose({ operationName, payload }));
@@ -22169,9 +22329,9 @@ function registerProductCommands(catalog, getClient) {
22169
22329
  );
22170
22330
  });
22171
22331
  product.command("get <productId>").action(async (productId) => {
22172
- emitSuccess(await getClient().products.get(requireId(productId, "productId")));
22332
+ emitSuccess(await getClient().products.get(requireId2(productId, "productId")));
22173
22333
  });
22174
- withMutationOptions(product.command("create")).action(async (options, command) => {
22334
+ withMutationOptions2(product.command("create")).action(async (options, command) => {
22175
22335
  const input2 = await readMutationInput(options.from);
22176
22336
  await applyOrPreview(
22177
22337
  command,
@@ -22182,15 +22342,15 @@ function registerProductCommands(catalog, getClient) {
22182
22342
  (approvalId) => getClient().products.create(input2, approvalId)
22183
22343
  );
22184
22344
  });
22185
- withMutationOptions(
22345
+ withMutationOptions2(
22186
22346
  product.command("update <productId>").option("--from <json-file>", "Objeto JSON estructurado"),
22187
22347
  false
22188
22348
  ).action(async (productId, options, command) => {
22189
- const id = requireId(productId, "productId");
22349
+ const id = requireId2(productId, "productId");
22190
22350
  const { approvalId: rawApprovalId } = command.optsWithGlobals();
22191
- const approvalId = typeof rawApprovalId === "string" ? requireId(rawApprovalId, "approvalId") : void 0;
22351
+ const approvalId = typeof rawApprovalId === "string" ? requireId2(rawApprovalId, "approvalId") : void 0;
22192
22352
  if (!options.from) {
22193
- if (!wantsApply(command) || !approvalId) {
22353
+ if (!wantsApply2(command) || !approvalId) {
22194
22354
  throw new CliProtocolError(
22195
22355
  "CLI_VALIDATION_ERROR",
22196
22356
  "--from es obligatorio salvo al aplicar con --apply --approval-id"
@@ -22204,7 +22364,7 @@ function registerProductCommands(catalog, getClient) {
22204
22364
  }
22205
22365
  const input2 = await readMutationInput(options.from);
22206
22366
  const prepared = await prepareProductUpdate(input2, options.from, approvalId === void 0);
22207
- if (wantsApply(command) && !approvalId) {
22367
+ if (wantsApply2(command) && !approvalId) {
22208
22368
  const uploaded = /* @__PURE__ */ new Map();
22209
22369
  for (const [placeholder, file2] of prepared.files) {
22210
22370
  const image = await getClient().products.uploadImage(file2);
@@ -22230,9 +22390,9 @@ function registerProductCommands(catalog, getClient) {
22230
22390
  () => getClient().products.get(id)
22231
22391
  );
22232
22392
  });
22233
- withMutationOptions(product.command("deactivate <productId>"), false).action(
22393
+ withMutationOptions2(product.command("deactivate <productId>"), false).action(
22234
22394
  async (productId, _options, command) => {
22235
- const id = requireId(productId, "productId");
22395
+ const id = requireId2(productId, "productId");
22236
22396
  await applyOrPreview(
22237
22397
  command,
22238
22398
  { isActive: false },
@@ -22248,14 +22408,14 @@ function registerProductCommands(catalog, getClient) {
22248
22408
  function registerVariantCommands(catalog, getClient) {
22249
22409
  const variant = catalog.command("variant");
22250
22410
  variant.command("list <productId>").action(async (productId) => {
22251
- emitSuccess(await getClient().variants.list(requireId(productId, "productId")));
22411
+ emitSuccess(await getClient().variants.list(requireId2(productId, "productId")));
22252
22412
  });
22253
22413
  variant.command("get <variantId>").action(async (variantId) => {
22254
- emitSuccess(await getClient().variants.get(requireId(variantId, "variantId")));
22414
+ emitSuccess(await getClient().variants.get(requireId2(variantId, "variantId")));
22255
22415
  });
22256
- withMutationOptions(variant.command("create <productId>")).action(
22416
+ withMutationOptions2(variant.command("create <productId>")).action(
22257
22417
  async (productId, options, command) => {
22258
- const id = requireId(productId, "productId");
22418
+ const id = requireId2(productId, "productId");
22259
22419
  const input2 = await readMutationInput(options.from);
22260
22420
  await applyOrPreview(
22261
22421
  command,
@@ -22267,9 +22427,9 @@ function registerVariantCommands(catalog, getClient) {
22267
22427
  );
22268
22428
  }
22269
22429
  );
22270
- withMutationOptions(variant.command("update <variantId>")).action(
22430
+ withMutationOptions2(variant.command("update <variantId>")).action(
22271
22431
  async (variantId, options, command) => {
22272
- const id = requireId(variantId, "variantId");
22432
+ const id = requireId2(variantId, "variantId");
22273
22433
  const input2 = await readMutationInput(options.from);
22274
22434
  await applyOrPreview(
22275
22435
  command,
@@ -22282,9 +22442,9 @@ function registerVariantCommands(catalog, getClient) {
22282
22442
  );
22283
22443
  }
22284
22444
  );
22285
- withMutationOptions(variant.command("deactivate <variantId>"), false).action(
22445
+ withMutationOptions2(variant.command("deactivate <variantId>"), false).action(
22286
22446
  async (variantId, _options, command) => {
22287
- const id = requireId(variantId, "variantId");
22447
+ const id = requireId2(variantId, "variantId");
22288
22448
  await applyOrPreview(
22289
22449
  command,
22290
22450
  { isActive: false },
@@ -22296,9 +22456,9 @@ function registerVariantCommands(catalog, getClient) {
22296
22456
  );
22297
22457
  }
22298
22458
  );
22299
- withMutationOptions(variant.command("reorder <productId>")).action(
22459
+ withMutationOptions2(variant.command("reorder <productId>")).action(
22300
22460
  async (productId, options, command) => {
22301
- const id = requireId(productId, "productId");
22461
+ const id = requireId2(productId, "productId");
22302
22462
  const input2 = await readMutationInput(options.from);
22303
22463
  await applyOrPreview(
22304
22464
  command,
@@ -22316,9 +22476,9 @@ function registerCategoryCommands(catalog, getClient) {
22316
22476
  const category = catalog.command("category");
22317
22477
  category.command("list").action(async () => emitSuccess(await getClient().categories.list()));
22318
22478
  category.command("get <categoryId>").action(async (categoryId) => {
22319
- emitSuccess(await getClient().categories.get(requireId(categoryId, "categoryId")));
22479
+ emitSuccess(await getClient().categories.get(requireId2(categoryId, "categoryId")));
22320
22480
  });
22321
- withMutationOptions(category.command("create")).action(async (options, command) => {
22481
+ withMutationOptions2(category.command("create")).action(async (options, command) => {
22322
22482
  const input2 = await readMutationInput(options.from);
22323
22483
  await applyOrPreview(
22324
22484
  command,
@@ -22329,9 +22489,9 @@ function registerCategoryCommands(catalog, getClient) {
22329
22489
  (approvalId) => getClient().categories.create(input2, approvalId)
22330
22490
  );
22331
22491
  });
22332
- withMutationOptions(category.command("update <categoryId>")).action(
22492
+ withMutationOptions2(category.command("update <categoryId>")).action(
22333
22493
  async (categoryId, options, command) => {
22334
- const id = requireId(categoryId, "categoryId");
22494
+ const id = requireId2(categoryId, "categoryId");
22335
22495
  const input2 = await readMutationInput(options.from);
22336
22496
  await applyOrPreview(
22337
22497
  command,
@@ -22344,9 +22504,9 @@ function registerCategoryCommands(catalog, getClient) {
22344
22504
  );
22345
22505
  }
22346
22506
  );
22347
- withMutationOptions(category.command("delete <categoryId>"), false).action(
22507
+ withMutationOptions2(category.command("delete <categoryId>"), false).action(
22348
22508
  async (categoryId, _options, command) => {
22349
- const id = requireId(categoryId, "categoryId");
22509
+ const id = requireId2(categoryId, "categoryId");
22350
22510
  await applyOrPreview(
22351
22511
  command,
22352
22512
  { delete: true },
@@ -22363,9 +22523,9 @@ function registerTagCommands(catalog, getClient) {
22363
22523
  const tag = catalog.command("tag");
22364
22524
  tag.command("list").action(async () => emitSuccess(await getClient().tags.list()));
22365
22525
  tag.command("get <tagId>").action(async (tagId) => {
22366
- emitSuccess(await getClient().tags.get(requireId(tagId, "tagId")));
22526
+ emitSuccess(await getClient().tags.get(requireId2(tagId, "tagId")));
22367
22527
  });
22368
- withMutationOptions(tag.command("create")).action(async (options, command) => {
22528
+ withMutationOptions2(tag.command("create")).action(async (options, command) => {
22369
22529
  const input2 = await readMutationInput(options.from);
22370
22530
  await applyOrPreview(
22371
22531
  command,
@@ -22376,8 +22536,8 @@ function registerTagCommands(catalog, getClient) {
22376
22536
  (approvalId) => getClient().tags.create(input2, approvalId)
22377
22537
  );
22378
22538
  });
22379
- withMutationOptions(tag.command("update <tagId>")).action(async (tagId, options, command) => {
22380
- const id = requireId(tagId, "tagId");
22539
+ withMutationOptions2(tag.command("update <tagId>")).action(async (tagId, options, command) => {
22540
+ const id = requireId2(tagId, "tagId");
22381
22541
  const input2 = await readMutationInput(options.from);
22382
22542
  await applyOrPreview(
22383
22543
  command,
@@ -22389,9 +22549,9 @@ function registerTagCommands(catalog, getClient) {
22389
22549
  () => getClient().tags.get(id)
22390
22550
  );
22391
22551
  });
22392
- withMutationOptions(tag.command("delete <tagId>"), false).action(
22552
+ withMutationOptions2(tag.command("delete <tagId>"), false).action(
22393
22553
  async (tagId, _options, command) => {
22394
- const id = requireId(tagId, "tagId");
22554
+ const id = requireId2(tagId, "tagId");
22395
22555
  await applyOrPreview(
22396
22556
  command,
22397
22557
  { delete: true },
@@ -22414,12 +22574,12 @@ function registerAssetCommands(catalog, getClient) {
22414
22574
  emitSuccess(await getClient().assets.list(parsed.data));
22415
22575
  });
22416
22576
  asset.command("get <assetId>").action(async (assetId) => {
22417
- emitSuccess(await getClient().assets.get(requireId(assetId, "assetId")));
22577
+ emitSuccess(await getClient().assets.get(requireId2(assetId, "assetId")));
22418
22578
  });
22419
- withMutationOptions(
22579
+ withMutationOptions2(
22420
22580
  asset.command("update <assetId>").option("--diff", "Incluye la ficha actual")
22421
22581
  ).action(async (assetId, options, command) => {
22422
- const id = requireId(assetId, "assetId");
22582
+ const id = requireId2(assetId, "assetId");
22423
22583
  const parsed = AssetMetadataUpdateInputSchema.safeParse(await readMutationInput(options.from));
22424
22584
  if (!parsed.success) {
22425
22585
  throw new CliProtocolError(
@@ -22438,7 +22598,7 @@ function registerAssetCommands(catalog, getClient) {
22438
22598
  options.diff ? () => getClient().assets.get(id) : void 0
22439
22599
  );
22440
22600
  });
22441
- withMutationOptions(
22601
+ withMutationOptions2(
22442
22602
  asset.command("upload").requiredOption("--file <path>", "Archivo local"),
22443
22603
  false
22444
22604
  ).action(async (options, command) => {
@@ -22447,7 +22607,7 @@ function registerAssetCommands(catalog, getClient) {
22447
22607
  if (!fileStat.isFile()) {
22448
22608
  throw new CliProtocolError("CLI_VALIDATION_ERROR", "--file debe apuntar a un archivo");
22449
22609
  }
22450
- if (!wantsApply(command)) {
22610
+ if (!wantsApply2(command)) {
22451
22611
  emitSuccess({
22452
22612
  validated: "local",
22453
22613
  file: basename3(filePath),
@@ -22467,7 +22627,7 @@ function registerAssetCommands(catalog, getClient) {
22467
22627
  const file2 = new File([contents], basename3(filePath), { type: mimeType });
22468
22628
  const rawApprovalId = command.optsWithGlobals().approvalId;
22469
22629
  if (typeof rawApprovalId === "string") {
22470
- emitSuccess(await getClient().assets.upload(file2, requireId(rawApprovalId, "approvalId")));
22630
+ emitSuccess(await getClient().assets.upload(file2, requireId2(rawApprovalId, "approvalId")));
22471
22631
  return;
22472
22632
  }
22473
22633
  emitSuccess(
@@ -22482,7 +22642,7 @@ function registerAssetCommands(catalog, getClient) {
22482
22642
  })
22483
22643
  );
22484
22644
  });
22485
- withMutationOptions(asset.command("import-url")).action(async (options, command) => {
22645
+ withMutationOptions2(asset.command("import-url")).action(async (options, command) => {
22486
22646
  const input2 = await readMutationInput(options.from);
22487
22647
  await applyOrPreview(
22488
22648
  command,
@@ -22497,16 +22657,16 @@ function registerAssetCommands(catalog, getClient) {
22497
22657
  function registerInventoryCommands(catalog, getClient) {
22498
22658
  const inventory = catalog.command("inventory");
22499
22659
  inventory.command("get <variantId>").action(async (variantId) => {
22500
- emitSuccess(await getClient().inventory.get(requireId(variantId, "variantId")));
22660
+ emitSuccess(await getClient().inventory.get(requireId2(variantId, "variantId")));
22501
22661
  });
22502
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) => {
22503
22663
  emitSuccess(
22504
- await getClient().inventory.listMovements(requireId(variantId, "variantId"), options)
22664
+ await getClient().inventory.listMovements(requireId2(variantId, "variantId"), options)
22505
22665
  );
22506
22666
  });
22507
- withMutationOptions(inventory.command("adjust <variantId>")).action(
22667
+ withMutationOptions2(inventory.command("adjust <variantId>")).action(
22508
22668
  async (variantId, options, command) => {
22509
- const id = requireId(variantId, "variantId");
22669
+ const id = requireId2(variantId, "variantId");
22510
22670
  const input2 = await readMutationInput(options.from);
22511
22671
  await applyOrPreview(
22512
22672
  command,
@@ -22519,9 +22679,9 @@ function registerInventoryCommands(catalog, getClient) {
22519
22679
  );
22520
22680
  }
22521
22681
  );
22522
- withMutationOptions(inventory.command("set <variantId>")).action(
22682
+ withMutationOptions2(inventory.command("set <variantId>")).action(
22523
22683
  async (variantId, options, command) => {
22524
- const id = requireId(variantId, "variantId");
22684
+ const id = requireId2(variantId, "variantId");
22525
22685
  const input2 = await readMutationInput(options.from);
22526
22686
  await applyOrPreview(
22527
22687
  command,
@@ -22543,9 +22703,9 @@ function registerImportCommands(catalog, getClient) {
22543
22703
  const prepared = await prepareCatalogImport(input2, options.from, client.imports);
22544
22704
  emitSuccess(await client.imports.preview(prepared));
22545
22705
  });
22546
- withMutationOptions(imports.command("apply <importId>"), false).action(
22706
+ withMutationOptions2(imports.command("apply <importId>"), false).action(
22547
22707
  async (importId, _options, command) => {
22548
- const id = requireId(importId, "importId");
22708
+ const id = requireId2(importId, "importId");
22549
22709
  await applyOrPreview(
22550
22710
  command,
22551
22711
  { importId: id, action: "apply" },
@@ -22558,7 +22718,244 @@ function registerImportCommands(catalog, getClient) {
22558
22718
  );
22559
22719
  imports.command("example").description("Imprime el payload can\xF3nico de una importaci\xF3n").action(() => emitSuccess(CATALOG_IMPORT_EXAMPLE));
22560
22720
  imports.command("status <importId>").action(async (importId) => {
22561
- 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
+ );
22562
22959
  });
22563
22960
  }
22564
22961
 
@@ -23104,6 +23501,8 @@ function createProgram(options = {}) {
23104
23501
  registerBusinessCommands(program, getClient);
23105
23502
  registerSalesCommands(program, getClient);
23106
23503
  registerCatalogCommands(program, getClient);
23504
+ registerAppointmentsCommands(program, getClient);
23505
+ registerStorefrontCommands(program, getClient);
23107
23506
  const operation = program.command("operation").description("Consulta y aplica operaciones aprobadas en Avileo");
23108
23507
  registerOperationBatchCommands(operation, getClient);
23109
23508
  operation.command("status <id>").description("Consulta el estado de una operaci\xF3n").action(async (id) => {