@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.cjs.js +29 -45
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +30 -46
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/attachments/voice-adapter.d.ts +1 -1
- package/dist/src/components/ui/autoform/index.d.ts +0 -1
- package/dist/src/components/ui/autoform/utils.d.ts +2 -1
- package/dist/src/components/ui/autoform/zodProvider/index.d.ts +6 -4
- package/dist/src/domains/agents/components/chat-threads.d.ts +1 -1
- package/dist/src/domains/workflows/context/workflow-run-context.d.ts +1 -1
- package/dist/src/domains/workflows/runs/workflow-runs.d.ts +1 -1
- package/package.json +8 -8
package/dist/index.cjs.js
CHANGED
|
@@ -56,7 +56,8 @@ const z = require('zod');
|
|
|
56
56
|
const react$3 = require('@autoform/react');
|
|
57
57
|
const CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
58
58
|
const reactDayPicker = require('react-day-picker');
|
|
59
|
-
const
|
|
59
|
+
const v4 = require('@autoform/zod/v4');
|
|
60
|
+
const v3 = require('zod/v3');
|
|
60
61
|
const reactCodeBlock = require('react-code-block');
|
|
61
62
|
const reactQuery = require('@tanstack/react-query');
|
|
62
63
|
|
|
@@ -12972,48 +12973,28 @@ function inferFieldType(schema, fieldConfig) {
|
|
|
12972
12973
|
if (schema instanceof z.z.ZodObject) return "object";
|
|
12973
12974
|
if (schema instanceof z.z.ZodNumber) return "number";
|
|
12974
12975
|
if (schema instanceof z.z.ZodBoolean) return "boolean";
|
|
12975
|
-
if (schema instanceof z.z.
|
|
12976
|
-
|
|
12976
|
+
if (schema instanceof z.z.ZodString) {
|
|
12977
|
+
const checks = schema._zod.def.checks || [];
|
|
12978
|
+
const hasDateTimeCheck = checks.some(
|
|
12979
|
+
//@ts-expect-error - zod string_format check has format property
|
|
12980
|
+
(check) => check._zod.def.check === "string_format" && check._zod.def.format === "datetime"
|
|
12981
|
+
);
|
|
12982
|
+
if (hasDateTimeCheck) return "date";
|
|
12983
|
+
return "string";
|
|
12984
|
+
}
|
|
12977
12985
|
if (schema instanceof z.z.ZodEnum) return "select";
|
|
12978
|
-
if (schema instanceof
|
|
12986
|
+
if (schema instanceof v3.z.ZodNativeEnum) return "select";
|
|
12979
12987
|
if (schema instanceof z.z.ZodArray) return "array";
|
|
12980
12988
|
if (schema instanceof z.z.ZodRecord) return "record";
|
|
12981
12989
|
return "string";
|
|
12982
12990
|
}
|
|
12983
12991
|
|
|
12984
|
-
function extractNumberConstraints(schema) {
|
|
12985
|
-
const constraints = {};
|
|
12986
|
-
let baseSchema = getBaseSchema(schema);
|
|
12987
|
-
if (baseSchema._def && baseSchema._def.checks) {
|
|
12988
|
-
for (const check of baseSchema._def.checks) {
|
|
12989
|
-
if (check.kind === "min" && check.inclusive) {
|
|
12990
|
-
constraints.min = check.value;
|
|
12991
|
-
} else if (check.kind === "max" && check.inclusive) {
|
|
12992
|
-
constraints.max = check.value;
|
|
12993
|
-
} else if (check.kind === "multipleOf") {
|
|
12994
|
-
constraints.step = check.value;
|
|
12995
|
-
}
|
|
12996
|
-
}
|
|
12997
|
-
}
|
|
12998
|
-
return constraints;
|
|
12999
|
-
}
|
|
13000
12992
|
function parseField(key, schema) {
|
|
13001
12993
|
const baseSchema = getBaseSchema(schema);
|
|
13002
|
-
|
|
12994
|
+
const fieldConfig = v4.getFieldConfigInZodStack(schema);
|
|
13003
12995
|
const type = inferFieldType(baseSchema, fieldConfig);
|
|
13004
|
-
const defaultValue =
|
|
13005
|
-
|
|
13006
|
-
const constraints = extractNumberConstraints(schema);
|
|
13007
|
-
if (Object.keys(constraints).length > 0) {
|
|
13008
|
-
if (!fieldConfig) {
|
|
13009
|
-
fieldConfig = {};
|
|
13010
|
-
}
|
|
13011
|
-
if (typeof fieldConfig === "object") {
|
|
13012
|
-
fieldConfig.inputProps = { ...fieldConfig?.inputProps, ...constraints };
|
|
13013
|
-
}
|
|
13014
|
-
}
|
|
13015
|
-
}
|
|
13016
|
-
const options = baseSchema._def?.values;
|
|
12996
|
+
const defaultValue = v4.getDefaultValueInZodStack(schema);
|
|
12997
|
+
const options = baseSchema._zod.def?.entries;
|
|
13017
12998
|
let optionValues = [];
|
|
13018
12999
|
if (options) {
|
|
13019
13000
|
if (!Array.isArray(options)) {
|
|
@@ -13023,16 +13004,16 @@ function parseField(key, schema) {
|
|
|
13023
13004
|
}
|
|
13024
13005
|
}
|
|
13025
13006
|
let subSchema = [];
|
|
13026
|
-
if (baseSchema instanceof z.z.ZodObject) {
|
|
13007
|
+
if (baseSchema instanceof v3.z.ZodObject || baseSchema instanceof z.z.ZodObject) {
|
|
13027
13008
|
subSchema = Object.entries(baseSchema.shape).map(([key2, field]) => parseField(key2, field));
|
|
13028
13009
|
}
|
|
13029
|
-
if (baseSchema instanceof z.z.ZodArray) {
|
|
13030
|
-
subSchema = [parseField("0", baseSchema.
|
|
13010
|
+
if (baseSchema instanceof v3.z.ZodArray || baseSchema instanceof z.z.ZodArray) {
|
|
13011
|
+
subSchema = [parseField("0", baseSchema._zod.def.element)];
|
|
13031
13012
|
}
|
|
13032
13013
|
return {
|
|
13033
13014
|
key,
|
|
13034
13015
|
type,
|
|
13035
|
-
required: !schema.
|
|
13016
|
+
required: !schema.optional(),
|
|
13036
13017
|
default: defaultValue,
|
|
13037
13018
|
description: baseSchema.description,
|
|
13038
13019
|
fieldConfig,
|
|
@@ -13041,26 +13022,29 @@ function parseField(key, schema) {
|
|
|
13041
13022
|
};
|
|
13042
13023
|
}
|
|
13043
13024
|
function getBaseSchema(schema) {
|
|
13044
|
-
if ("innerType" in schema.
|
|
13045
|
-
return getBaseSchema(schema.
|
|
13025
|
+
if ("innerType" in schema._zod.def) {
|
|
13026
|
+
return getBaseSchema(schema._zod.def.innerType);
|
|
13046
13027
|
}
|
|
13047
|
-
if ("schema" in schema.
|
|
13048
|
-
return getBaseSchema(schema.
|
|
13028
|
+
if ("schema" in schema._zod.def) {
|
|
13029
|
+
return getBaseSchema(schema._zod.def.schema);
|
|
13049
13030
|
}
|
|
13050
13031
|
return schema;
|
|
13051
13032
|
}
|
|
13052
13033
|
function parseSchema(schema) {
|
|
13053
|
-
const
|
|
13054
|
-
const shape = objectSchema.shape;
|
|
13034
|
+
const shape = schema.shape;
|
|
13055
13035
|
const fields = Object.entries(shape).map(([key, field]) => parseField(key, field));
|
|
13056
13036
|
return { fields };
|
|
13057
13037
|
}
|
|
13058
|
-
class CustomZodProvider extends
|
|
13038
|
+
class CustomZodProvider extends v4.ZodProvider {
|
|
13059
13039
|
_schema;
|
|
13060
13040
|
constructor(schema) {
|
|
13061
13041
|
super(schema);
|
|
13062
13042
|
this._schema = schema;
|
|
13063
13043
|
}
|
|
13044
|
+
validateSchema(values) {
|
|
13045
|
+
const result = super.validateSchema(values);
|
|
13046
|
+
return result;
|
|
13047
|
+
}
|
|
13064
13048
|
parseSchema() {
|
|
13065
13049
|
return parseSchema(this._schema);
|
|
13066
13050
|
}
|