| 1366 | * @since 4.0.0 |
| 1367 | */ |
| 1368 | export function toStandardJSONSchemaV1<S extends Constraint>( |
| 1369 | self: S |
| 1370 | ): StandardJSONSchemaV1<S["Encoded"], S["Type"]> & S { |
| 1371 | const jsonSchema: StandardJSONSchemaV1.Props<S["Encoded"], S["Type"]>["jsonSchema"] = { |
| 1372 | input(options) { |
| 1373 | return toBaseStandardJSONSchemaV1(self, options.target) |
| 1374 | }, |
| 1375 | output(options) { |
| 1376 | return toBaseStandardJSONSchemaV1(toType(self), options.target) |
| 1377 | } |
| 1378 | } |
| 1379 | if ("~standard" in self) { |
| 1380 | const out = self as any |
| 1381 | if ("jsonSchema" in out["~standard"]) return out |
| 1382 | Object.assign(out["~standard"], { jsonSchema }) |
| 1383 | return out |
| 1384 | } else { |
| 1385 | return Object.assign(self, { |
| 1386 | "~standard": { |
| 1387 | version: 1, |
| 1388 | vendor: "effect", |
| 1389 | jsonSchema |
| 1390 | } as const |
| 1391 | }) |
| 1392 | } |
| 1393 | } |
| 1394 | |
| 1395 | /** |
| 1396 | * Creates a type guard function that checks if a value conforms to a given |