@synova-cloud/sdk 1.9.2 → 2.0.0
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 +235 -512
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +180 -386
- package/dist/index.d.ts +180 -386
- package/dist/index.js +231 -491
- package/dist/index.js.map +1 -1
- package/package.json +28 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON Schema primitive types
|
|
3
3
|
*/
|
|
4
|
-
type TJsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array';
|
|
4
|
+
type TJsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
5
5
|
/**
|
|
6
6
|
* JSON Schema string formats
|
|
7
7
|
* @see https://json-schema.org/understanding-json-schema/reference/string#built-in-formats
|
|
@@ -38,41 +38,117 @@ interface IJsonSchema {
|
|
|
38
38
|
oneOf?: IJsonSchema[];
|
|
39
39
|
not?: IJsonSchema;
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Interface for schema adapters that convert various schema libraries to JSON Schema
|
|
44
|
+
*/
|
|
45
|
+
interface ISchemaAdapter<TSchema = unknown> {
|
|
46
|
+
/**
|
|
47
|
+
* Check if this adapter can handle the given schema
|
|
48
|
+
*/
|
|
49
|
+
canHandle(schema: unknown): schema is TSchema;
|
|
50
|
+
/**
|
|
51
|
+
* Convert the schema to JSON Schema format
|
|
52
|
+
*/
|
|
53
|
+
toJsonSchema(schema: TSchema): IJsonSchema;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Schema type identifier
|
|
58
|
+
*/
|
|
59
|
+
type TSchemaType = 'zod' | 'yup' | 'joi' | 'json-schema' | 'unknown';
|
|
60
|
+
/**
|
|
61
|
+
* Zod-like schema interface
|
|
62
|
+
*/
|
|
63
|
+
interface IZodLike {
|
|
64
|
+
_def: {
|
|
65
|
+
typeName: string;
|
|
66
|
+
};
|
|
67
|
+
safeParse: unknown;
|
|
68
|
+
}
|
|
41
69
|
/**
|
|
42
|
-
*
|
|
70
|
+
* Yup-like schema interface
|
|
43
71
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
readonly DEFAULT: "synova:schema:default";
|
|
48
|
-
readonly FORMAT: "synova:schema:format";
|
|
49
|
-
readonly ARRAY_ITEM_TYPE: "synova:schema:arrayItemType";
|
|
50
|
-
readonly NULLABLE: "synova:schema:nullable";
|
|
51
|
-
readonly ENUM: "synova:schema:enum";
|
|
52
|
-
readonly MIN_LENGTH: "synova:schema:minLength";
|
|
53
|
-
readonly MAX_LENGTH: "synova:schema:maxLength";
|
|
54
|
-
readonly PATTERN: "synova:schema:pattern";
|
|
55
|
-
readonly MINIMUM: "synova:schema:minimum";
|
|
56
|
-
readonly MAXIMUM: "synova:schema:maximum";
|
|
57
|
-
readonly EXCLUSIVE_MINIMUM: "synova:schema:exclusiveMinimum";
|
|
58
|
-
readonly EXCLUSIVE_MAXIMUM: "synova:schema:exclusiveMaximum";
|
|
59
|
-
readonly MULTIPLE_OF: "synova:schema:multipleOf";
|
|
60
|
-
readonly MIN_ITEMS: "synova:schema:minItems";
|
|
61
|
-
readonly MAX_ITEMS: "synova:schema:maxItems";
|
|
62
|
-
readonly UNIQUE_ITEMS: "synova:schema:uniqueItems";
|
|
63
|
-
readonly ADDITIONAL_PROPERTIES: "synova:schema:additionalProperties";
|
|
64
|
-
};
|
|
72
|
+
interface IYupLike {
|
|
73
|
+
__isYupSchema__: true;
|
|
74
|
+
}
|
|
65
75
|
/**
|
|
66
|
-
*
|
|
76
|
+
* Joi-like schema interface
|
|
67
77
|
*/
|
|
68
|
-
interface
|
|
69
|
-
|
|
70
|
-
additionalProperties?: boolean;
|
|
78
|
+
interface IJoiLike {
|
|
79
|
+
describe: () => unknown;
|
|
71
80
|
}
|
|
72
81
|
/**
|
|
73
|
-
*
|
|
82
|
+
* Supported schema input types.
|
|
83
|
+
* Provides better type hints while maintaining flexibility.
|
|
84
|
+
*/
|
|
85
|
+
type TSchemaInput = IJsonSchema | IZodLike | IYupLike | IJoiLike | unknown;
|
|
86
|
+
/**
|
|
87
|
+
* Schema resolver that converts various schema libraries to JSON Schema.
|
|
88
|
+
* Supports Zod, Yup, Joi, and raw JSON Schema.
|
|
74
89
|
*/
|
|
75
|
-
|
|
90
|
+
declare class SchemaResolver {
|
|
91
|
+
private static adapters;
|
|
92
|
+
/**
|
|
93
|
+
* Register a custom adapter.
|
|
94
|
+
*
|
|
95
|
+
* @param adapter - The adapter to register
|
|
96
|
+
* @param position - Where to insert: 'first' adds at the beginning,
|
|
97
|
+
* 'last' adds before JsonSchemaAdapter (fallback)
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* SchemaResolver.registerAdapter(new MyCustomAdapter(), 'first');
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
static registerAdapter(adapter: ISchemaAdapter, position?: 'first' | 'last'): void;
|
|
105
|
+
/**
|
|
106
|
+
* Reset adapters to default configuration.
|
|
107
|
+
* Removes all custom adapters.
|
|
108
|
+
*/
|
|
109
|
+
static resetAdapters(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Resolve a schema input to JSON Schema format.
|
|
112
|
+
*
|
|
113
|
+
* @param schema - Schema from Zod, Yup, Joi, or raw JSON Schema
|
|
114
|
+
* @returns JSON Schema representation
|
|
115
|
+
* @throws Error if schema type is not supported
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* // Zod
|
|
120
|
+
* const zodSchema = z.object({ title: z.string() });
|
|
121
|
+
* const jsonSchema = SchemaResolver.resolve(zodSchema);
|
|
122
|
+
*
|
|
123
|
+
* // Yup
|
|
124
|
+
* const yupSchema = yup.object({ title: yup.string().required() });
|
|
125
|
+
* const jsonSchema = SchemaResolver.resolve(yupSchema);
|
|
126
|
+
*
|
|
127
|
+
* // Joi
|
|
128
|
+
* const joiSchema = Joi.object({ title: Joi.string() });
|
|
129
|
+
* const jsonSchema = SchemaResolver.resolve(joiSchema);
|
|
130
|
+
*
|
|
131
|
+
* // Raw JSON Schema (passthrough)
|
|
132
|
+
* const rawSchema = { type: 'object', properties: { title: { type: 'string' } } };
|
|
133
|
+
* const jsonSchema = SchemaResolver.resolve(rawSchema);
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
static resolve(schema: TSchemaInput): IJsonSchema;
|
|
137
|
+
/**
|
|
138
|
+
* Check if a schema is supported.
|
|
139
|
+
*
|
|
140
|
+
* @param schema - Schema to check
|
|
141
|
+
* @returns true if the schema is supported
|
|
142
|
+
*/
|
|
143
|
+
static isSupported(schema: unknown): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Get the type of a schema.
|
|
146
|
+
*
|
|
147
|
+
* @param schema - Schema to identify
|
|
148
|
+
* @returns Schema type identifier
|
|
149
|
+
*/
|
|
150
|
+
static getSchemaType(schema: unknown): TSchemaType;
|
|
151
|
+
}
|
|
76
152
|
|
|
77
153
|
type TSynovaMessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
78
154
|
type TSynovaResponseType = 'message' | 'tool_calls' | 'image' | 'audio' | 'error';
|
|
@@ -177,8 +253,8 @@ interface ISynovaExecuteOptions {
|
|
|
177
253
|
metadata?: Record<string, string>;
|
|
178
254
|
/** Model parameters (temperature, maxTokens, topP, topK, etc.) */
|
|
179
255
|
parameters?: Record<string, unknown>;
|
|
180
|
-
/**
|
|
181
|
-
responseSchema?:
|
|
256
|
+
/** Schema for structured output (Zod, Yup, Joi, or raw JSON Schema) */
|
|
257
|
+
responseSchema?: TSchemaInput;
|
|
182
258
|
/** Session ID for trace grouping (enables multi-call trace view in observability) */
|
|
183
259
|
sessionId?: string;
|
|
184
260
|
}
|
|
@@ -473,15 +549,6 @@ declare class HttpClient {
|
|
|
473
549
|
private log;
|
|
474
550
|
}
|
|
475
551
|
|
|
476
|
-
/**
|
|
477
|
-
* Execute options with optional responseClass for typed responses
|
|
478
|
-
*/
|
|
479
|
-
interface ISynovaExecuteTypedOptions<T> extends Omit<ISynovaExecuteOptions, 'responseSchema'> {
|
|
480
|
-
/** Class to use for response typing and schema generation */
|
|
481
|
-
responseClass: TClassConstructor<T>;
|
|
482
|
-
/** Enable class-validator validation (default: true) */
|
|
483
|
-
validate?: boolean;
|
|
484
|
-
}
|
|
485
552
|
declare class PromptsResource {
|
|
486
553
|
private readonly http;
|
|
487
554
|
constructor(http: HttpClient);
|
|
@@ -490,26 +557,36 @@ declare class PromptsResource {
|
|
|
490
557
|
*/
|
|
491
558
|
get(promptId: string, options?: ISynovaGetPromptOptions): Promise<ISynovaPrompt>;
|
|
492
559
|
/**
|
|
493
|
-
* Execute a prompt with typed response
|
|
560
|
+
* Execute a prompt with typed response using responseSchema
|
|
494
561
|
*
|
|
495
562
|
* @example
|
|
496
563
|
* ```ts
|
|
497
|
-
* // With
|
|
498
|
-
* const
|
|
564
|
+
* // With Zod schema
|
|
565
|
+
* const schema = z.object({ title: z.string() });
|
|
566
|
+
* const result = await client.prompts.execute<z.infer<typeof schema>>('prm_abc123', {
|
|
567
|
+
* provider: 'openai',
|
|
568
|
+
* model: 'gpt-4o',
|
|
569
|
+
* responseSchema: schema,
|
|
570
|
+
* });
|
|
571
|
+
* console.log(result.title); // Typed as string
|
|
572
|
+
*
|
|
573
|
+
* // With raw JSON Schema
|
|
574
|
+
* const result = await client.prompts.execute<{ title: string }>('prm_abc123', {
|
|
499
575
|
* provider: 'openai',
|
|
500
576
|
* model: 'gpt-4o',
|
|
501
|
-
*
|
|
577
|
+
* responseSchema: { type: 'object', properties: { title: { type: 'string' } } },
|
|
502
578
|
* });
|
|
503
|
-
* console.log(topic.title); // Typed as string
|
|
504
579
|
* ```
|
|
505
580
|
*/
|
|
506
|
-
execute<T>(promptId: string, options:
|
|
581
|
+
execute<T>(promptId: string, options: ISynovaExecuteOptions & {
|
|
582
|
+
responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
|
|
583
|
+
}): Promise<T>;
|
|
507
584
|
/**
|
|
508
585
|
* Execute a prompt
|
|
509
586
|
*
|
|
510
587
|
* @example
|
|
511
588
|
* ```ts
|
|
512
|
-
* // Without
|
|
589
|
+
* // Without responseSchema - returns ISynovaExecuteResponse
|
|
513
590
|
* const result = await client.prompts.execute('prm_abc123', {
|
|
514
591
|
* provider: 'openai',
|
|
515
592
|
* model: 'gpt-4o',
|
|
@@ -523,7 +600,9 @@ declare class PromptsResource {
|
|
|
523
600
|
/**
|
|
524
601
|
* Execute a prompt by tag with typed response
|
|
525
602
|
*/
|
|
526
|
-
executeByTag<T>(promptId: string, tag: string, options:
|
|
603
|
+
executeByTag<T>(promptId: string, tag: string, options: ISynovaExecuteOptions & {
|
|
604
|
+
responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
|
|
605
|
+
}): Promise<T>;
|
|
527
606
|
/**
|
|
528
607
|
* Execute a prompt by tag
|
|
529
608
|
*/
|
|
@@ -531,24 +610,13 @@ declare class PromptsResource {
|
|
|
531
610
|
/**
|
|
532
611
|
* Execute a prompt by version with typed response
|
|
533
612
|
*/
|
|
534
|
-
executeByVersion<T>(promptId: string, version: string, options:
|
|
613
|
+
executeByVersion<T>(promptId: string, version: string, options: ISynovaExecuteOptions & {
|
|
614
|
+
responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
|
|
615
|
+
}): Promise<T>;
|
|
535
616
|
/**
|
|
536
617
|
* Execute a prompt by version
|
|
537
618
|
*/
|
|
538
619
|
executeByVersion(promptId: string, version: string, options: ISynovaExecuteOptions): Promise<ISynovaExecuteResponse>;
|
|
539
|
-
/**
|
|
540
|
-
* Execute raw request without typed response
|
|
541
|
-
* @throws {ExecutionSynovaError} If LLM returns an error
|
|
542
|
-
*/
|
|
543
|
-
private executeRaw;
|
|
544
|
-
/**
|
|
545
|
-
* Execute with typed response class
|
|
546
|
-
*/
|
|
547
|
-
private executeTyped;
|
|
548
|
-
/**
|
|
549
|
-
* Validate object using class-validator
|
|
550
|
-
*/
|
|
551
|
-
private validateObject;
|
|
552
620
|
}
|
|
553
621
|
|
|
554
622
|
declare class ModelsResource {
|
|
@@ -889,349 +957,75 @@ declare class ExecutionSynovaError extends SynovaError {
|
|
|
889
957
|
readonly details?: ISynovaExecutionError['details'];
|
|
890
958
|
constructor(error: ISynovaExecutionError);
|
|
891
959
|
}
|
|
892
|
-
/**
|
|
893
|
-
* Validation violation details
|
|
894
|
-
*/
|
|
895
|
-
interface IValidationViolation {
|
|
896
|
-
property: string;
|
|
897
|
-
constraints: Record<string, string>;
|
|
898
|
-
value?: unknown;
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* Error thrown when LLM response fails class-validator validation
|
|
902
|
-
*/
|
|
903
|
-
declare class ValidationSynovaError extends SynovaError {
|
|
904
|
-
readonly violations: IValidationViolation[];
|
|
905
|
-
constructor(violations: IValidationViolation[]);
|
|
906
|
-
}
|
|
907
960
|
|
|
908
961
|
/**
|
|
909
|
-
*
|
|
910
|
-
*
|
|
911
|
-
* @example
|
|
912
|
-
* ```typescript
|
|
913
|
-
* import { ClassSchema, Description, Example, SchemaMin, SchemaMax } from '@synova-cloud/sdk';
|
|
914
|
-
*
|
|
915
|
-
* class User {
|
|
916
|
-
* @Description('User ID')
|
|
917
|
-
* @Example('usr_123')
|
|
918
|
-
* id: string;
|
|
919
|
-
*
|
|
920
|
-
* @Description('User age')
|
|
921
|
-
* @SchemaMin(0)
|
|
922
|
-
* @SchemaMax(150)
|
|
923
|
-
* age: number;
|
|
924
|
-
* }
|
|
925
|
-
*
|
|
926
|
-
* const schema = ClassSchema.generate(User);
|
|
927
|
-
* ```
|
|
962
|
+
* Passthrough adapter for raw JSON Schema objects.
|
|
963
|
+
* Transforms `nullable: true` to `type: ["...", "null"]` recursively.
|
|
928
964
|
*/
|
|
929
|
-
declare class
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
static generate<T>(targetClass: TClassConstructor<T>, options?: IGenerateSchemaOptions): IJsonSchema;
|
|
934
|
-
/**
|
|
935
|
-
* Get all properties with their schemas
|
|
936
|
-
*/
|
|
937
|
-
private static getProperties;
|
|
965
|
+
declare class JsonSchemaAdapter implements ISchemaAdapter<IJsonSchema> {
|
|
966
|
+
private static readonly VALID_JSON_SCHEMA_TYPES;
|
|
967
|
+
canHandle(schema: unknown): schema is IJsonSchema;
|
|
968
|
+
toJsonSchema(schema: IJsonSchema): IJsonSchema;
|
|
938
969
|
/**
|
|
939
|
-
*
|
|
970
|
+
* Recursively transform `nullable: true` to `type: ["...", "null"]`
|
|
940
971
|
*/
|
|
941
|
-
private
|
|
942
|
-
/**
|
|
943
|
-
* Get property names from our decorator metadata
|
|
944
|
-
*/
|
|
945
|
-
private static getDecoratorProperties;
|
|
946
|
-
/**
|
|
947
|
-
* Get JSON Schema for a single property
|
|
948
|
-
*/
|
|
949
|
-
private static getPropertySchema;
|
|
950
|
-
/**
|
|
951
|
-
* Get base schema from TypeScript type
|
|
952
|
-
*/
|
|
953
|
-
private static getBaseTypeSchema;
|
|
954
|
-
/**
|
|
955
|
-
* Get schema for array items
|
|
956
|
-
*/
|
|
957
|
-
private static getArrayItemSchema;
|
|
958
|
-
/**
|
|
959
|
-
* Apply class-validator constraints to schema
|
|
960
|
-
*/
|
|
961
|
-
private static applyClassValidatorConstraints;
|
|
962
|
-
/**
|
|
963
|
-
* Apply a single class-validator constraint
|
|
964
|
-
*/
|
|
965
|
-
private static applyValidationConstraint;
|
|
966
|
-
/**
|
|
967
|
-
* Apply our decorator metadata to schema.
|
|
968
|
-
* Our decorators take precedence over class-validator if both are used.
|
|
969
|
-
*/
|
|
970
|
-
private static applyDecoratorMetadata;
|
|
971
|
-
/**
|
|
972
|
-
* Get required properties (properties without @IsOptional)
|
|
973
|
-
*/
|
|
974
|
-
private static getRequiredProperties;
|
|
972
|
+
private transformNullable;
|
|
975
973
|
}
|
|
976
974
|
|
|
977
975
|
/**
|
|
978
|
-
*
|
|
979
|
-
* Helps LLMs understand the expected content.
|
|
980
|
-
*
|
|
981
|
-
* @example
|
|
982
|
-
* ```typescript
|
|
983
|
-
* class Article {
|
|
984
|
-
* @Description('SEO-optimized article title, 50-60 characters')
|
|
985
|
-
* title: string;
|
|
986
|
-
* }
|
|
987
|
-
* ```
|
|
988
|
-
*/
|
|
989
|
-
declare function Description(description: string): PropertyDecorator;
|
|
990
|
-
/**
|
|
991
|
-
* Adds example values to the property schema.
|
|
992
|
-
* Helps LLMs understand the expected format.
|
|
993
|
-
*
|
|
994
|
-
* @example
|
|
995
|
-
* ```typescript
|
|
996
|
-
* class Article {
|
|
997
|
-
* @Example('How to Optimize SQL Queries', '10 Tips for Better Code')
|
|
998
|
-
* title: string;
|
|
999
|
-
* }
|
|
1000
|
-
* ```
|
|
1001
|
-
*/
|
|
1002
|
-
declare function Example(...examples: unknown[]): PropertyDecorator;
|
|
1003
|
-
/**
|
|
1004
|
-
* Sets the default value for the property.
|
|
1005
|
-
*
|
|
1006
|
-
* @example
|
|
1007
|
-
* ```typescript
|
|
1008
|
-
* class Settings {
|
|
1009
|
-
* @Default('en')
|
|
1010
|
-
* language: string;
|
|
1011
|
-
* }
|
|
1012
|
-
* ```
|
|
1013
|
-
*/
|
|
1014
|
-
declare function Default(value: unknown): PropertyDecorator;
|
|
1015
|
-
/**
|
|
1016
|
-
* Sets the type of array items.
|
|
1017
|
-
* Required since TypeScript loses array item types at runtime.
|
|
1018
|
-
*
|
|
1019
|
-
* @example
|
|
1020
|
-
* ```typescript
|
|
1021
|
-
* class Article {
|
|
1022
|
-
* @ArrayItems(String)
|
|
1023
|
-
* keywords: string[];
|
|
1024
|
-
*
|
|
1025
|
-
* @ArrayItems(Comment)
|
|
1026
|
-
* comments: Comment[];
|
|
1027
|
-
* }
|
|
1028
|
-
* ```
|
|
1029
|
-
*/
|
|
1030
|
-
declare function ArrayItems(itemType: TClassConstructor | StringConstructor | NumberConstructor | BooleanConstructor): PropertyDecorator;
|
|
1031
|
-
/**
|
|
1032
|
-
* Sets semantic format for string (email, uri, uuid, date-time, etc.).
|
|
1033
|
-
*
|
|
1034
|
-
* @example
|
|
1035
|
-
* ```typescript
|
|
1036
|
-
* class User {
|
|
1037
|
-
* @Format('email')
|
|
1038
|
-
* email: string;
|
|
1039
|
-
*
|
|
1040
|
-
* @Format('date-time')
|
|
1041
|
-
* createdAt: string;
|
|
1042
|
-
* }
|
|
1043
|
-
* ```
|
|
1044
|
-
*/
|
|
1045
|
-
declare function Format(format: TJsonSchemaFormat): PropertyDecorator;
|
|
1046
|
-
/**
|
|
1047
|
-
* Marks the property as nullable (can be null).
|
|
1048
|
-
*
|
|
1049
|
-
* @example
|
|
1050
|
-
* ```typescript
|
|
1051
|
-
* class User {
|
|
1052
|
-
* @Nullable()
|
|
1053
|
-
* middleName: string | null;
|
|
1054
|
-
* }
|
|
1055
|
-
* ```
|
|
1056
|
-
*/
|
|
1057
|
-
declare function Nullable(): PropertyDecorator;
|
|
1058
|
-
/**
|
|
1059
|
-
* Sets minimum string length.
|
|
1060
|
-
*
|
|
1061
|
-
* @example
|
|
1062
|
-
* ```typescript
|
|
1063
|
-
* class User {
|
|
1064
|
-
* @SchemaMinLength(3)
|
|
1065
|
-
* username: string;
|
|
1066
|
-
* }
|
|
1067
|
-
* ```
|
|
1068
|
-
*/
|
|
1069
|
-
declare function SchemaMinLength(length: number): PropertyDecorator;
|
|
1070
|
-
/**
|
|
1071
|
-
* Sets maximum string length.
|
|
1072
|
-
*
|
|
1073
|
-
* @example
|
|
1074
|
-
* ```typescript
|
|
1075
|
-
* class User {
|
|
1076
|
-
* @SchemaMaxLength(100)
|
|
1077
|
-
* bio: string;
|
|
1078
|
-
* }
|
|
1079
|
-
* ```
|
|
1080
|
-
*/
|
|
1081
|
-
declare function SchemaMaxLength(length: number): PropertyDecorator;
|
|
1082
|
-
/**
|
|
1083
|
-
* Sets regex pattern for string validation.
|
|
1084
|
-
*
|
|
1085
|
-
* @example
|
|
1086
|
-
* ```typescript
|
|
1087
|
-
* class User {
|
|
1088
|
-
* @SchemaPattern('^[a-z0-9_]+$')
|
|
1089
|
-
* username: string;
|
|
1090
|
-
* }
|
|
1091
|
-
* ```
|
|
1092
|
-
*/
|
|
1093
|
-
declare function SchemaPattern(pattern: string): PropertyDecorator;
|
|
1094
|
-
/**
|
|
1095
|
-
* Sets minimum value (inclusive).
|
|
1096
|
-
*
|
|
1097
|
-
* @example
|
|
1098
|
-
* ```typescript
|
|
1099
|
-
* class Product {
|
|
1100
|
-
* @SchemaMin(0)
|
|
1101
|
-
* price: number;
|
|
1102
|
-
* }
|
|
1103
|
-
* ```
|
|
1104
|
-
*/
|
|
1105
|
-
declare function SchemaMin(value: number): PropertyDecorator;
|
|
1106
|
-
/**
|
|
1107
|
-
* Sets maximum value (inclusive).
|
|
1108
|
-
*
|
|
1109
|
-
* @example
|
|
1110
|
-
* ```typescript
|
|
1111
|
-
* class Rating {
|
|
1112
|
-
* @SchemaMax(5)
|
|
1113
|
-
* score: number;
|
|
1114
|
-
* }
|
|
1115
|
-
* ```
|
|
1116
|
-
*/
|
|
1117
|
-
declare function SchemaMax(value: number): PropertyDecorator;
|
|
1118
|
-
/**
|
|
1119
|
-
* Sets minimum value (exclusive).
|
|
1120
|
-
*
|
|
1121
|
-
* @example
|
|
1122
|
-
* ```typescript
|
|
1123
|
-
* class Discount {
|
|
1124
|
-
* @ExclusiveMin(0) // must be > 0
|
|
1125
|
-
* percentage: number;
|
|
1126
|
-
* }
|
|
1127
|
-
* ```
|
|
1128
|
-
*/
|
|
1129
|
-
declare function ExclusiveMin(value: number): PropertyDecorator;
|
|
1130
|
-
/**
|
|
1131
|
-
* Sets maximum value (exclusive).
|
|
1132
|
-
*
|
|
1133
|
-
* @example
|
|
1134
|
-
* ```typescript
|
|
1135
|
-
* class Probability {
|
|
1136
|
-
* @ExclusiveMax(1) // must be < 1
|
|
1137
|
-
* value: number;
|
|
1138
|
-
* }
|
|
1139
|
-
* ```
|
|
976
|
+
* Zod schema type definition
|
|
1140
977
|
*/
|
|
1141
|
-
|
|
978
|
+
interface IZodSchema {
|
|
979
|
+
_def: {
|
|
980
|
+
typeName: string;
|
|
981
|
+
};
|
|
982
|
+
safeParse: (data: unknown) => {
|
|
983
|
+
success: boolean;
|
|
984
|
+
};
|
|
985
|
+
}
|
|
1142
986
|
/**
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1145
|
-
* @example
|
|
1146
|
-
* ```typescript
|
|
1147
|
-
* class Currency {
|
|
1148
|
-
* @MultipleOf(0.01)
|
|
1149
|
-
* amount: number;
|
|
1150
|
-
* }
|
|
1151
|
-
* ```
|
|
987
|
+
* Adapter for Zod schemas.
|
|
988
|
+
* Uses zod-to-json-schema for conversion.
|
|
1152
989
|
*/
|
|
1153
|
-
declare
|
|
990
|
+
declare class ZodAdapter implements ISchemaAdapter<IZodSchema> {
|
|
991
|
+
canHandle(schema: unknown): schema is IZodSchema;
|
|
992
|
+
toJsonSchema(schema: IZodSchema): IJsonSchema;
|
|
993
|
+
}
|
|
994
|
+
|
|
1154
995
|
/**
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
* @example
|
|
1158
|
-
* ```typescript
|
|
1159
|
-
* class Order {
|
|
1160
|
-
* @SchemaMinItems(1)
|
|
1161
|
-
* items: OrderItem[];
|
|
1162
|
-
* }
|
|
1163
|
-
* ```
|
|
996
|
+
* Yup schema type definition
|
|
1164
997
|
*/
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
*
|
|
1169
|
-
* @example
|
|
1170
|
-
* ```typescript
|
|
1171
|
-
* class Article {
|
|
1172
|
-
* @SchemaMaxItems(10)
|
|
1173
|
-
* tags: string[];
|
|
1174
|
-
* }
|
|
1175
|
-
* ```
|
|
1176
|
-
*/
|
|
1177
|
-
declare function SchemaMaxItems(count: number): PropertyDecorator;
|
|
998
|
+
interface IYupSchema {
|
|
999
|
+
__isYupSchema__: boolean;
|
|
1000
|
+
}
|
|
1178
1001
|
/**
|
|
1179
|
-
*
|
|
1002
|
+
* Adapter for Yup schemas.
|
|
1003
|
+
* Uses @sodaru/yup-to-json-schema for conversion.
|
|
1180
1004
|
*
|
|
1181
|
-
* @
|
|
1182
|
-
* ```typescript
|
|
1183
|
-
* class User {
|
|
1184
|
-
* @SchemaUniqueItems()
|
|
1185
|
-
* roles: string[];
|
|
1186
|
-
* }
|
|
1187
|
-
* ```
|
|
1005
|
+
* @see https://github.com/jquense/yup/blob/master/src/schema.ts
|
|
1188
1006
|
*/
|
|
1189
|
-
declare
|
|
1007
|
+
declare class YupAdapter implements ISchemaAdapter<IYupSchema> {
|
|
1008
|
+
canHandle(schema: unknown): schema is IYupSchema;
|
|
1009
|
+
toJsonSchema(schema: IYupSchema): IJsonSchema;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1190
1012
|
/**
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1193
|
-
* @example
|
|
1194
|
-
* ```typescript
|
|
1195
|
-
* class User {
|
|
1196
|
-
* @SchemaEnum(['admin', 'user', 'guest'])
|
|
1197
|
-
* role: string;
|
|
1198
|
-
* }
|
|
1199
|
-
* ```
|
|
1200
|
-
*
|
|
1201
|
-
* With TypeScript enum:
|
|
1202
|
-
* ```typescript
|
|
1203
|
-
* enum Status { Active = 'active', Inactive = 'inactive' }
|
|
1204
|
-
*
|
|
1205
|
-
* class User {
|
|
1206
|
-
* @SchemaEnum(Object.values(Status))
|
|
1207
|
-
* status: Status;
|
|
1208
|
-
* }
|
|
1209
|
-
* ```
|
|
1013
|
+
* Joi schema type definition
|
|
1210
1014
|
*/
|
|
1211
|
-
|
|
1015
|
+
interface IJoiSchema {
|
|
1016
|
+
describe: () => {
|
|
1017
|
+
type: string;
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1212
1020
|
/**
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1216
|
-
* For arrays, applies to array items instead of the array itself.
|
|
1217
|
-
*
|
|
1218
|
-
* @param value - `true` for any value type, or a schema to constrain value types
|
|
1021
|
+
* Adapter for Joi schemas.
|
|
1022
|
+
* Uses joi-to-json for conversion.
|
|
1219
1023
|
*
|
|
1220
|
-
* @
|
|
1221
|
-
* ```typescript
|
|
1222
|
-
* class Response {
|
|
1223
|
-
* @AdditionalProperties(true) // any value type
|
|
1224
|
-
* metadata: Record<string, unknown>;
|
|
1225
|
-
*
|
|
1226
|
-
* @AdditionalProperties({ type: 'string' }) // only string values
|
|
1227
|
-
* labels: Record<string, string>;
|
|
1228
|
-
*
|
|
1229
|
-
* @ArrayItems(Object)
|
|
1230
|
-
* @AdditionalProperties(true) // applies to each array item
|
|
1231
|
-
* pipeline: Record<string, unknown>[];
|
|
1232
|
-
* }
|
|
1233
|
-
* ```
|
|
1024
|
+
* @see https://joi.dev/api/#isschemaschema-options
|
|
1234
1025
|
*/
|
|
1235
|
-
declare
|
|
1026
|
+
declare class JoiAdapter implements ISchemaAdapter<IJoiSchema> {
|
|
1027
|
+
canHandle(schema: unknown): schema is IJoiSchema;
|
|
1028
|
+
toJsonSchema(schema: IJoiSchema): IJsonSchema;
|
|
1029
|
+
}
|
|
1236
1030
|
|
|
1237
|
-
export {
|
|
1031
|
+
export { ApiSynovaError, AuthSynovaError, ExecutionSynovaError, type IJsonSchema, type ISchemaAdapter, type ISynovaConfig, type ISynovaCreateSpanOptions, type ISynovaEndSpanOptions, type ISynovaExecuteOptions, type ISynovaExecuteResponse, type ISynovaExecutionError, type ISynovaExecutionErrorDetails, type ISynovaExecutionUsage, type ISynovaFileAttachment, type ISynovaFileThumbnails, type ISynovaGetPromptOptions, type ISynovaListModelsOptions, type ISynovaLogger, type ISynovaMessage, type ISynovaModel, type ISynovaModelCapabilities, type ISynovaModelLimits, type ISynovaModelPricing, type ISynovaModelsResponse, type ISynovaPrompt, type ISynovaPromptVariable, type ISynovaProvider, type ISynovaProviderResponse, type ISynovaRetryConfig, type ISynovaSpan, type ISynovaSpanData, type ISynovaToolCall, type ISynovaToolResult, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, type ISynovaWrapOptions, type ISynovaWrapToolOptions, JoiAdapter, JsonSchemaAdapter, NetworkSynovaError, NotFoundSynovaError, RateLimitSynovaError, SchemaResolver, ServerSynovaError, SynovaCloudSdk, SynovaError, type TJsonSchemaFormat, type TJsonSchemaType, type TSchemaInput, type TSchemaType, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, type TSynovaSpanLevel, type TSynovaSpanStatus, type TSynovaSpanType, type TSynovaUsageType, TimeoutSynovaError, YupAdapter, ZodAdapter };
|