@mastra/playground-ui 5.2.2-alpha.0 → 5.2.2-alpha.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/dist/index.es.js CHANGED
@@ -50,11 +50,12 @@ import { v4 } from '@lukeed/uuid';
50
50
  import { RuntimeContext as RuntimeContext$2 } from '@mastra/core/runtime-context';
51
51
  import jsonSchemaToZod from 'json-schema-to-zod';
52
52
  import { parse } from 'superjson';
53
- import z$1, { z, ZodObject } from 'zod';
53
+ import z$2, { z, ZodObject } from 'zod';
54
54
  import { AutoForm as AutoForm$1, buildZodFieldConfig } from '@autoform/react';
55
55
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
56
56
  import { DayPicker } from 'react-day-picker';
57
- import { ZodProvider, getFieldConfigInZodStack, getDefaultValueInZodStack } from '@autoform/zod';
57
+ import { ZodProvider, getFieldConfigInZodStack, getDefaultValueInZodStack } from '@autoform/zod/v4';
58
+ import { z as z$1 } from 'zod/v3';
58
59
  import { CodeBlock as CodeBlock$1 } from 'react-code-block';
59
60
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
60
61
  import './index.css';export * from '@tanstack/react-query';
@@ -12939,48 +12940,28 @@ function inferFieldType(schema, fieldConfig) {
12939
12940
  if (schema instanceof z.ZodObject) return "object";
12940
12941
  if (schema instanceof z.ZodNumber) return "number";
12941
12942
  if (schema instanceof z.ZodBoolean) return "boolean";
12942
- if (schema instanceof z.ZodDate || schema?.isDatetime || schema?.isDate) return "date";
12943
- if (schema instanceof z.ZodString) return "string";
12943
+ if (schema instanceof z.ZodString) {
12944
+ const checks = schema._zod.def.checks || [];
12945
+ const hasDateTimeCheck = checks.some(
12946
+ //@ts-expect-error - zod string_format check has format property
12947
+ (check) => check._zod.def.check === "string_format" && check._zod.def.format === "datetime"
12948
+ );
12949
+ if (hasDateTimeCheck) return "date";
12950
+ return "string";
12951
+ }
12944
12952
  if (schema instanceof z.ZodEnum) return "select";
12945
- if (schema instanceof z.ZodNativeEnum) return "select";
12953
+ if (schema instanceof z$1.ZodNativeEnum) return "select";
12946
12954
  if (schema instanceof z.ZodArray) return "array";
12947
12955
  if (schema instanceof z.ZodRecord) return "record";
12948
12956
  return "string";
12949
12957
  }
12950
12958
 
12951
- function extractNumberConstraints(schema) {
12952
- const constraints = {};
12953
- let baseSchema = getBaseSchema(schema);
12954
- if (baseSchema._def && baseSchema._def.checks) {
12955
- for (const check of baseSchema._def.checks) {
12956
- if (check.kind === "min" && check.inclusive) {
12957
- constraints.min = check.value;
12958
- } else if (check.kind === "max" && check.inclusive) {
12959
- constraints.max = check.value;
12960
- } else if (check.kind === "multipleOf") {
12961
- constraints.step = check.value;
12962
- }
12963
- }
12964
- }
12965
- return constraints;
12966
- }
12967
12959
  function parseField(key, schema) {
12968
12960
  const baseSchema = getBaseSchema(schema);
12969
- let fieldConfig = getFieldConfigInZodStack(schema);
12961
+ const fieldConfig = getFieldConfigInZodStack(schema);
12970
12962
  const type = inferFieldType(baseSchema, fieldConfig);
12971
12963
  const defaultValue = getDefaultValueInZodStack(schema);
12972
- if (type === "number" && baseSchema instanceof z.ZodNumber) {
12973
- const constraints = extractNumberConstraints(schema);
12974
- if (Object.keys(constraints).length > 0) {
12975
- if (!fieldConfig) {
12976
- fieldConfig = {};
12977
- }
12978
- if (typeof fieldConfig === "object") {
12979
- fieldConfig.inputProps = { ...fieldConfig?.inputProps, ...constraints };
12980
- }
12981
- }
12982
- }
12983
- const options = baseSchema._def?.values;
12964
+ const options = baseSchema._zod.def?.entries;
12984
12965
  let optionValues = [];
12985
12966
  if (options) {
12986
12967
  if (!Array.isArray(options)) {
@@ -12990,16 +12971,16 @@ function parseField(key, schema) {
12990
12971
  }
12991
12972
  }
12992
12973
  let subSchema = [];
12993
- if (baseSchema instanceof z.ZodObject) {
12974
+ if (baseSchema instanceof z$1.ZodObject || baseSchema instanceof z.ZodObject) {
12994
12975
  subSchema = Object.entries(baseSchema.shape).map(([key2, field]) => parseField(key2, field));
12995
12976
  }
12996
- if (baseSchema instanceof z.ZodArray) {
12997
- subSchema = [parseField("0", baseSchema._def.type)];
12977
+ if (baseSchema instanceof z$1.ZodArray || baseSchema instanceof z.ZodArray) {
12978
+ subSchema = [parseField("0", baseSchema._zod.def.element)];
12998
12979
  }
12999
12980
  return {
13000
12981
  key,
13001
12982
  type,
13002
- required: !schema.isOptional(),
12983
+ required: !schema.optional(),
13003
12984
  default: defaultValue,
13004
12985
  description: baseSchema.description,
13005
12986
  fieldConfig,
@@ -13008,17 +12989,16 @@ function parseField(key, schema) {
13008
12989
  };
13009
12990
  }
13010
12991
  function getBaseSchema(schema) {
13011
- if ("innerType" in schema._def) {
13012
- return getBaseSchema(schema._def.innerType);
12992
+ if ("innerType" in schema._zod.def) {
12993
+ return getBaseSchema(schema._zod.def.innerType);
13013
12994
  }
13014
- if ("schema" in schema._def) {
13015
- return getBaseSchema(schema._def.schema);
12995
+ if ("schema" in schema._zod.def) {
12996
+ return getBaseSchema(schema._zod.def.schema);
13016
12997
  }
13017
12998
  return schema;
13018
12999
  }
13019
13000
  function parseSchema(schema) {
13020
- const objectSchema = schema instanceof z.ZodEffects ? schema.innerType() : schema;
13021
- const shape = objectSchema.shape;
13001
+ const shape = schema.shape;
13022
13002
  const fields = Object.entries(shape).map(([key, field]) => parseField(key, field));
13023
13003
  return { fields };
13024
13004
  }
@@ -13028,6 +13008,10 @@ class CustomZodProvider extends ZodProvider {
13028
13008
  super(schema);
13029
13009
  this._schema = schema;
13030
13010
  }
13011
+ validateSchema(values) {
13012
+ const result = super.validateSchema(values);
13013
+ return result;
13014
+ }
13031
13015
  parseSchema() {
13032
13016
  return parseSchema(this._schema);
13033
13017
  }
@@ -13055,10 +13039,10 @@ function DynamicForm({
13055
13039
  }
13056
13040
  const normalizedSchema = (schema2) => {
13057
13041
  if (isEmptyZodObject(schema2)) {
13058
- return z$1.object({});
13042
+ return z$2.object({});
13059
13043
  }
13060
13044
  if (isNotZodObject) {
13061
- return z$1.object({
13045
+ return z$2.object({
13062
13046
  "​": schema2
13063
13047
  });
13064
13048
  }