@514labs/moose-lib 0.6.437 → 0.6.438

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.mjs CHANGED
@@ -4434,8 +4434,6 @@ function defineQueryModel(config) {
4434
4434
  dimensions,
4435
4435
  metrics,
4436
4436
  columns: columnDefs,
4437
- dimensionNames,
4438
- metricNames,
4439
4437
  columnNames,
4440
4438
  query: async (request, client) => {
4441
4439
  const result = await client.execute(toSql(request));
@@ -4523,6 +4521,14 @@ function camelToSnake(s) {
4523
4521
  function titleFromName(name) {
4524
4522
  return name.replace(/^query_/, "Query ").replace(/^list_/, "List ").replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
4525
4523
  }
4524
+ function buildEnumDescription(metadata) {
4525
+ const entries = Object.entries(metadata);
4526
+ if (entries.length === 0) return void 0;
4527
+ const lines = entries.map(([name, def]) => {
4528
+ return def.description ? `- ${name}: ${def.description}` : `- ${name}`;
4529
+ });
4530
+ return lines.join("\n");
4531
+ }
4526
4532
  function zodBaseType(inputType) {
4527
4533
  if (inputType === "number") return z.number();
4528
4534
  return z.string();
@@ -4560,13 +4566,19 @@ function createModelTool(model, options = {}) {
4560
4566
  const requiredSet = new Set(requiredFilters);
4561
4567
  const schema = {};
4562
4568
  const filterParamMap = {};
4563
- if (model.dimensionNames.length > 0) {
4564
- const names = model.dimensionNames;
4565
- schema.dimensions = z.array(z.enum(names)).optional();
4566
- }
4567
- if (model.metricNames.length > 0) {
4568
- const names = model.metricNames;
4569
- schema.metrics = z.array(z.enum(names)).optional();
4569
+ const dimensionNames = Object.keys(model.dimensions ?? {});
4570
+ if (dimensionNames.length > 0) {
4571
+ const names = dimensionNames;
4572
+ const desc = buildEnumDescription(model.dimensions);
4573
+ const dimSchema = z.array(z.enum(names)).optional();
4574
+ schema.dimensions = desc ? dimSchema.describe(desc) : dimSchema;
4575
+ }
4576
+ const metricNames = Object.keys(model.metrics ?? {});
4577
+ if (metricNames.length > 0) {
4578
+ const names = metricNames;
4579
+ const desc = buildEnumDescription(model.metrics);
4580
+ const metSchema = z.array(z.enum(names)).optional();
4581
+ schema.metrics = desc ? metSchema.describe(desc) : metSchema;
4570
4582
  }
4571
4583
  if (model.columnNames.length > 0) {
4572
4584
  const names = model.columnNames;
@@ -4590,9 +4602,10 @@ function createModelTool(model, options = {}) {
4590
4602
  paramType = baseType;
4591
4603
  }
4592
4604
  if (requiredSet.has(filterName) && op === "eq") {
4593
- schema[paramName] = paramType;
4605
+ schema[paramName] = filterDef.description ? paramType.describe(filterDef.description) : paramType;
4594
4606
  } else {
4595
- schema[paramName] = paramType.optional();
4607
+ const opt = paramType.optional();
4608
+ schema[paramName] = filterDef.description ? opt.describe(filterDef.description) : opt;
4596
4609
  }
4597
4610
  filterParamMap[paramName] = { filterName, op };
4598
4611
  }
@@ -4600,10 +4613,10 @@ function createModelTool(model, options = {}) {
4600
4613
  schema.limit = z.number().min(1).max(maxLimit).default(defaultLimit).optional();
4601
4614
  function buildRequest(params) {
4602
4615
  const request = {};
4603
- if (model.dimensionNames.length > 0) {
4616
+ if (dimensionNames.length > 0) {
4604
4617
  request.dimensions = params.dimensions ?? mergedDefaults.dimensions;
4605
4618
  }
4606
- if (model.metricNames.length > 0) {
4619
+ if (metricNames.length > 0) {
4607
4620
  request.metrics = params.metrics ?? mergedDefaults.metrics;
4608
4621
  }
4609
4622
  if (model.columnNames.length > 0) {