Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import type { JsonSchema, JsonSchemaObject, Serializable } from '../types'; |
| 2 | |
| 3 | export const its = { |
| 4 | an: { |
| 5 | object: (x: JsonSchemaObject): x is JsonSchemaObject & { type: 'object' } => |
| 6 | x.type === 'object' || |
| 7 | (!x.type && |
| 8 | (x.properties !== undefined || |
| 9 | x.additionalProperties !== undefined || |
| 10 | x.patternProperties !== undefined)), |
| 11 | array: (x: JsonSchemaObject): x is JsonSchemaObject & { type: 'array' } => x.type === 'array', |
| 12 | anyOf: ( |
| 13 | x: JsonSchemaObject |
| 14 | ): x is JsonSchemaObject & { |
| 15 | anyOf: JsonSchema[]; |
| 16 | } => x.anyOf !== undefined, |
| 17 | allOf: ( |
| 18 | x: JsonSchemaObject |
| 19 | ): x is JsonSchemaObject & { |
| 20 | allOf: JsonSchema[]; |
| 21 | } => x.allOf !== undefined, |
| 22 | enum: ( |
| 23 | x: JsonSchemaObject |
| 24 | ): x is JsonSchemaObject & { |
| 25 | enum: Serializable | Serializable[]; |
| 26 | } => x.enum !== undefined, |
| 27 | }, |
| 28 | a: { |
| 29 | nullable: (x: JsonSchemaObject): x is JsonSchemaObject & { nullable: true } => |
| 30 | (x as unknown as { nullable: boolean }).nullable === true, |
| 31 | multipleType: (x: JsonSchemaObject): x is JsonSchemaObject & { type: string[] } => |
| 32 | Array.isArray(x.type), |
| 33 | not: ( |
| 34 | x: JsonSchemaObject |
| 35 | ): x is JsonSchemaObject & { |
| 36 | not: JsonSchema; |
| 37 | } => x.not !== undefined, |
| 38 | const: ( |
| 39 | x: JsonSchemaObject |
| 40 | ): x is JsonSchemaObject & { |
| 41 | const: Serializable; |
| 42 | } => x.const !== undefined, |
| 43 | primitive: <T extends 'string' | 'number' | 'integer' | 'boolean' | 'null'>( |
| 44 | x: JsonSchemaObject, |
| 45 | p: T |
| 46 | ): x is JsonSchemaObject & { type: T } => x.type === p, |
| 47 | conditional: ( |
| 48 | x: JsonSchemaObject |
| 49 | ): x is JsonSchemaObject & { |
| 50 | if: JsonSchema; |
| 51 | then: JsonSchema; |
| 52 | else: JsonSchema; |
| 53 | } => Boolean('if' in x && x.if && 'then' in x && 'else' in x && x.then && x.else), |
| 54 | oneOf: ( |
| 55 | x: JsonSchemaObject |
| 56 | ): x is JsonSchemaObject & { |
| 57 | oneOf: JsonSchema[]; |
| 58 | } => x.oneOf !== undefined, |
| 59 | }, |
| 60 | }; |