@mastra/voice-speechify 0.12.0 → 0.12.1-alpha.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/CHANGELOG.md +8 -0
- package/LICENSE.md +15 -0
- package/dist/_types/@internal_voice/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +9043 -0
- package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/base/index.d.ts +31 -0
- package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/logger/index.d.ts +217 -0
- package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/request-context/index.d.ts +147 -0
- package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/types/index.d.ts +3 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/ZodError.d.ts +164 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/errors.d.ts +5 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/external.d.ts +6 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/enumUtil.d.ts +8 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/errorUtil.d.ts +9 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/parseUtil.d.ts +78 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/partialUtil.d.ts +8 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/typeAliases.d.ts +2 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/util.d.ts +85 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/index.d.cts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/index.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/locales/en.d.ts +3 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/standard-schema.d.ts +102 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v3/types.d.ts +1034 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/checks.d.ts +1 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/coerce.d.ts +17 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/compat.d.ts +50 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/errors.d.ts +30 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/external.d.ts +16 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/from-json-schema.d.ts +12 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/index.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/iso.d.ts +22 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/parse.d.ts +31 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/schemas.d.ts +767 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/api.d.ts +325 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/checks.d.ts +278 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/core.d.ts +70 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/doc.d.ts +14 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/errors.d.ts +221 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/index.d.ts +16 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/json-schema-generator.d.ts +65 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/json-schema-processors.d.ts +49 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/json-schema.d.ts +88 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/parse.d.ts +49 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/regexes.d.ts +85 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/registries.d.ts +35 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/schemas.d.ts +1184 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/standard-schema.d.ts +126 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/to-json-schema.d.ts +114 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/util.d.ts +200 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/core/versions.d.ts +5 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/index.d.cts +3 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ar.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/az.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/be.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/bg.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ca.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/cs.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/da.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/de.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/el.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/en.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/eo.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/es.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/fa.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/fi.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/fr-CA.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/fr.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/he.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/hr.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/hu.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/hy.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/id.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/index.d.ts +52 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/is.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/it.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ja.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ka.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/kh.d.ts +5 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/km.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ko.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/lt.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/mk.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ms.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/nl.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/no.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ota.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/pl.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ps.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/pt.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ro.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ru.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/sl.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/sv.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ta.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/th.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/tr.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ua.d.ts +5 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/uk.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ur.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/uz.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/vi.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/yo.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/zh-CN.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/zh-TW.d.ts +4 -0
- package/dist/_types/@internal_voice/dist/index.d.ts +16 -0
- package/dist/_types/@internal_voice/dist/voice/aisdk/index.d.ts +3 -0
- package/dist/_types/@internal_voice/dist/voice/aisdk/speech.d.ts +23 -0
- package/dist/_types/@internal_voice/dist/voice/aisdk/transcription.d.ts +22 -0
- package/dist/_types/@internal_voice/dist/voice/composite-voice.d.ts +72 -0
- package/dist/_types/@internal_voice/dist/voice/default-voice.d.ts +13 -0
- package/dist/_types/@internal_voice/dist/voice/index.d.ts +5 -0
- package/dist/_types/@internal_voice/dist/voice/voice.d.ts +172 -0
- package/dist/docs/SKILL.md +15 -21
- package/dist/docs/{SOURCE_MAP.json → assets/SOURCE_MAP.json} +1 -1
- package/dist/docs/references/docs-agents-adding-voice.md +350 -0
- package/dist/docs/references/docs-voice-overview.md +1188 -0
- package/dist/docs/references/reference-voice-speechify.md +75 -0
- package/dist/index.cjs +260 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +259 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -13
- package/dist/docs/README.md +0 -32
- package/dist/docs/agents/01-adding-voice.md +0 -352
- package/dist/docs/voice/01-overview.md +0 -1019
- package/dist/docs/voice/02-reference.md +0 -62
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RegisteredLogger, IMastraLogger } from '../logger/index.js';
|
|
2
|
+
import 'node:stream';
|
|
3
|
+
|
|
4
|
+
declare class MastraBase {
|
|
5
|
+
#private;
|
|
6
|
+
component: RegisteredLogger;
|
|
7
|
+
protected logger: IMastraLogger;
|
|
8
|
+
name?: string;
|
|
9
|
+
constructor({ component, name, rawConfig, }: {
|
|
10
|
+
component?: RegisteredLogger;
|
|
11
|
+
name?: string;
|
|
12
|
+
rawConfig?: Record<string, unknown>;
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Returns the raw storage configuration this primitive was created from,
|
|
16
|
+
* or undefined if it was created from code.
|
|
17
|
+
*/
|
|
18
|
+
toRawConfig(): Record<string, unknown> | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Sets the raw storage configuration for this primitive.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
__setRawConfig(rawConfig: Record<string, unknown>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Set the logger for the agent
|
|
26
|
+
* @param logger
|
|
27
|
+
*/
|
|
28
|
+
__setLogger(logger: IMastraLogger): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { MastraBase };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { Transform } from 'node:stream';
|
|
2
|
+
|
|
3
|
+
declare const RegisteredLogger: {
|
|
4
|
+
readonly AGENT: "AGENT";
|
|
5
|
+
readonly OBSERVABILITY: "OBSERVABILITY";
|
|
6
|
+
readonly AUTH: "AUTH";
|
|
7
|
+
readonly BROWSER: "BROWSER";
|
|
8
|
+
readonly NETWORK: "NETWORK";
|
|
9
|
+
readonly WORKFLOW: "WORKFLOW";
|
|
10
|
+
readonly LLM: "LLM";
|
|
11
|
+
readonly TTS: "TTS";
|
|
12
|
+
readonly VOICE: "VOICE";
|
|
13
|
+
readonly VECTOR: "VECTOR";
|
|
14
|
+
readonly BUNDLER: "BUNDLER";
|
|
15
|
+
readonly DEPLOYER: "DEPLOYER";
|
|
16
|
+
readonly MEMORY: "MEMORY";
|
|
17
|
+
readonly STORAGE: "STORAGE";
|
|
18
|
+
readonly EMBEDDINGS: "EMBEDDINGS";
|
|
19
|
+
readonly MCP_SERVER: "MCP_SERVER";
|
|
20
|
+
readonly SERVER_CACHE: "SERVER_CACHE";
|
|
21
|
+
readonly SERVER: "SERVER";
|
|
22
|
+
readonly WORKSPACE: "WORKSPACE";
|
|
23
|
+
readonly CHANNEL: "CHANNEL";
|
|
24
|
+
};
|
|
25
|
+
type RegisteredLogger = (typeof RegisteredLogger)[keyof typeof RegisteredLogger];
|
|
26
|
+
declare const LogLevel: {
|
|
27
|
+
readonly DEBUG: "debug";
|
|
28
|
+
readonly INFO: "info";
|
|
29
|
+
readonly WARN: "warn";
|
|
30
|
+
readonly ERROR: "error";
|
|
31
|
+
readonly NONE: "silent";
|
|
32
|
+
};
|
|
33
|
+
type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
|
|
34
|
+
interface BaseLogMessage {
|
|
35
|
+
runId?: string;
|
|
36
|
+
msg: string;
|
|
37
|
+
level: LogLevel;
|
|
38
|
+
time: Date;
|
|
39
|
+
pid: number;
|
|
40
|
+
hostname: string;
|
|
41
|
+
name: string;
|
|
42
|
+
}
|
|
43
|
+
declare abstract class LoggerTransport extends Transform {
|
|
44
|
+
constructor(opts?: any);
|
|
45
|
+
listLogsByRunId(_args: {
|
|
46
|
+
runId: string;
|
|
47
|
+
fromDate?: Date;
|
|
48
|
+
toDate?: Date;
|
|
49
|
+
logLevel?: LogLevel;
|
|
50
|
+
filters?: Record<string, any>;
|
|
51
|
+
page?: number;
|
|
52
|
+
perPage?: number;
|
|
53
|
+
}): Promise<{
|
|
54
|
+
logs: BaseLogMessage[];
|
|
55
|
+
total: number;
|
|
56
|
+
page: number;
|
|
57
|
+
perPage: number;
|
|
58
|
+
hasMore: boolean;
|
|
59
|
+
}>;
|
|
60
|
+
listLogs(_args?: {
|
|
61
|
+
fromDate?: Date;
|
|
62
|
+
toDate?: Date;
|
|
63
|
+
logLevel?: LogLevel;
|
|
64
|
+
filters?: Record<string, any>;
|
|
65
|
+
returnPaginationResults?: boolean;
|
|
66
|
+
page?: number;
|
|
67
|
+
perPage?: number;
|
|
68
|
+
}): Promise<{
|
|
69
|
+
logs: BaseLogMessage[];
|
|
70
|
+
total: number;
|
|
71
|
+
page: number;
|
|
72
|
+
perPage: number;
|
|
73
|
+
hasMore: boolean;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
declare const createCustomTransport: (stream: Transform, listLogs?: LoggerTransport["listLogs"], listLogsByRunId?: LoggerTransport["listLogsByRunId"]) => LoggerTransport;
|
|
77
|
+
interface IMastraLogger {
|
|
78
|
+
debug(message: string, ...args: any[]): void;
|
|
79
|
+
info(message: string, ...args: any[]): void;
|
|
80
|
+
warn(message: string, ...args: any[]): void;
|
|
81
|
+
error(message: string, ...args: any[]): void;
|
|
82
|
+
trackException(error: Error, metadata?: Record<string, unknown>): void;
|
|
83
|
+
getTransports(): Map<string, LoggerTransport>;
|
|
84
|
+
listLogs(_transportId: string, _params?: {
|
|
85
|
+
fromDate?: Date;
|
|
86
|
+
toDate?: Date;
|
|
87
|
+
logLevel?: LogLevel;
|
|
88
|
+
filters?: Record<string, any>;
|
|
89
|
+
page?: number;
|
|
90
|
+
perPage?: number;
|
|
91
|
+
}): Promise<{
|
|
92
|
+
logs: BaseLogMessage[];
|
|
93
|
+
total: number;
|
|
94
|
+
page: number;
|
|
95
|
+
perPage: number;
|
|
96
|
+
hasMore: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
listLogsByRunId(_args: {
|
|
99
|
+
transportId: string;
|
|
100
|
+
runId: string;
|
|
101
|
+
fromDate?: Date;
|
|
102
|
+
toDate?: Date;
|
|
103
|
+
logLevel?: LogLevel;
|
|
104
|
+
filters?: Record<string, any>;
|
|
105
|
+
page?: number;
|
|
106
|
+
perPage?: number;
|
|
107
|
+
}): Promise<{
|
|
108
|
+
logs: BaseLogMessage[];
|
|
109
|
+
total: number;
|
|
110
|
+
page: number;
|
|
111
|
+
perPage: number;
|
|
112
|
+
hasMore: boolean;
|
|
113
|
+
}>;
|
|
114
|
+
}
|
|
115
|
+
declare abstract class MastraLogger implements IMastraLogger {
|
|
116
|
+
protected name: string;
|
|
117
|
+
protected level: LogLevel;
|
|
118
|
+
protected transports: Map<string, LoggerTransport>;
|
|
119
|
+
constructor(options?: {
|
|
120
|
+
name?: string;
|
|
121
|
+
level?: LogLevel;
|
|
122
|
+
transports?: Record<string, LoggerTransport>;
|
|
123
|
+
});
|
|
124
|
+
abstract debug(message: string, ...args: any[]): void;
|
|
125
|
+
abstract info(message: string, ...args: any[]): void;
|
|
126
|
+
abstract warn(message: string, ...args: any[]): void;
|
|
127
|
+
abstract error(message: string, ...args: any[]): void;
|
|
128
|
+
getTransports(): Map<string, LoggerTransport>;
|
|
129
|
+
trackException(_error: Error, _metadata?: Record<string, unknown>): void;
|
|
130
|
+
listLogs(transportId: string, params?: {
|
|
131
|
+
fromDate?: Date;
|
|
132
|
+
toDate?: Date;
|
|
133
|
+
logLevel?: LogLevel;
|
|
134
|
+
filters?: Record<string, any>;
|
|
135
|
+
page?: number;
|
|
136
|
+
perPage?: number;
|
|
137
|
+
}): Promise<{
|
|
138
|
+
logs: BaseLogMessage[];
|
|
139
|
+
total: number;
|
|
140
|
+
page: number;
|
|
141
|
+
perPage: number;
|
|
142
|
+
hasMore: boolean;
|
|
143
|
+
}>;
|
|
144
|
+
listLogsByRunId({ transportId, runId, fromDate, toDate, logLevel, filters, page, perPage, }: {
|
|
145
|
+
transportId: string;
|
|
146
|
+
runId: string;
|
|
147
|
+
fromDate?: Date;
|
|
148
|
+
toDate?: Date;
|
|
149
|
+
logLevel?: LogLevel;
|
|
150
|
+
filters?: Record<string, any>;
|
|
151
|
+
page?: number;
|
|
152
|
+
perPage?: number;
|
|
153
|
+
}): Promise<{
|
|
154
|
+
logs: BaseLogMessage[];
|
|
155
|
+
total: number;
|
|
156
|
+
page: number;
|
|
157
|
+
perPage: number;
|
|
158
|
+
hasMore: boolean;
|
|
159
|
+
}>;
|
|
160
|
+
}
|
|
161
|
+
type LogFilterContext = {
|
|
162
|
+
component?: RegisteredLogger;
|
|
163
|
+
level: LogLevel;
|
|
164
|
+
message: string;
|
|
165
|
+
args: unknown[];
|
|
166
|
+
};
|
|
167
|
+
type LogFilter = (ctx: LogFilterContext) => boolean;
|
|
168
|
+
interface ConsoleLoggerOptions {
|
|
169
|
+
name?: string;
|
|
170
|
+
level?: LogLevel;
|
|
171
|
+
component?: RegisteredLogger;
|
|
172
|
+
filter?: LogFilter;
|
|
173
|
+
}
|
|
174
|
+
declare class ConsoleLogger extends MastraLogger {
|
|
175
|
+
protected component?: RegisteredLogger;
|
|
176
|
+
protected filter?: LogFilter;
|
|
177
|
+
constructor(options?: ConsoleLoggerOptions);
|
|
178
|
+
child(componentOrBindings: RegisteredLogger | Record<string, unknown>): ConsoleLogger;
|
|
179
|
+
private shouldLog;
|
|
180
|
+
private prefix;
|
|
181
|
+
debug(message: string, ...args: any[]): void;
|
|
182
|
+
info(message: string, ...args: any[]): void;
|
|
183
|
+
warn(message: string, ...args: any[]): void;
|
|
184
|
+
error(message: string, ...args: any[]): void;
|
|
185
|
+
listLogs(_transportId: string, _params?: {
|
|
186
|
+
fromDate?: Date;
|
|
187
|
+
toDate?: Date;
|
|
188
|
+
logLevel?: LogLevel;
|
|
189
|
+
filters?: Record<string, any>;
|
|
190
|
+
page?: number;
|
|
191
|
+
perPage?: number;
|
|
192
|
+
}): Promise<{
|
|
193
|
+
logs: never[];
|
|
194
|
+
total: number;
|
|
195
|
+
page: number;
|
|
196
|
+
perPage: number;
|
|
197
|
+
hasMore: boolean;
|
|
198
|
+
}>;
|
|
199
|
+
listLogsByRunId(_args: {
|
|
200
|
+
transportId: string;
|
|
201
|
+
runId: string;
|
|
202
|
+
fromDate?: Date;
|
|
203
|
+
toDate?: Date;
|
|
204
|
+
logLevel?: LogLevel;
|
|
205
|
+
filters?: Record<string, any>;
|
|
206
|
+
page?: number;
|
|
207
|
+
perPage?: number;
|
|
208
|
+
}): Promise<{
|
|
209
|
+
logs: never[];
|
|
210
|
+
total: number;
|
|
211
|
+
page: number;
|
|
212
|
+
perPage: number;
|
|
213
|
+
hasMore: boolean;
|
|
214
|
+
}>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export { type BaseLogMessage, ConsoleLogger, type ConsoleLoggerOptions, type IMastraLogger, type LogFilter, type LogFilterContext, LogLevel, LoggerTransport, MastraLogger, RegisteredLogger, createCustomTransport };
|
package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/request-context/index.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
type RecordToTuple<T> = {
|
|
2
|
+
[K in keyof T]: [K, T[K]];
|
|
3
|
+
}[keyof T][];
|
|
4
|
+
/**
|
|
5
|
+
* Reserved key for setting resourceId from middleware.
|
|
6
|
+
* When set in RequestContext, this takes precedence over client-provided values
|
|
7
|
+
* for security (prevents attackers from hijacking another user's memory).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // In your auth middleware:
|
|
12
|
+
* const requestContext = c.get('requestContext');
|
|
13
|
+
* requestContext.set(MASTRA_RESOURCE_ID_KEY, authenticatedUser.id);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare const MASTRA_RESOURCE_ID_KEY = "mastra__resourceId";
|
|
17
|
+
/**
|
|
18
|
+
* Reserved key for setting threadId from middleware.
|
|
19
|
+
* When set in RequestContext, this takes precedence over client-provided values
|
|
20
|
+
* for security (prevents attackers from hijacking another user's memory).
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // In your auth middleware:
|
|
25
|
+
* const requestContext = c.get('requestContext');
|
|
26
|
+
* requestContext.set(MASTRA_THREAD_ID_KEY, threadId);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare const MASTRA_THREAD_ID_KEY = "mastra__threadId";
|
|
30
|
+
/**
|
|
31
|
+
* Reserved key for storing version overrides on RequestContext.
|
|
32
|
+
* When set, sub-agent delegation resolves versioned agents from these overrides.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* requestContext.set(MASTRA_VERSIONS_KEY, {
|
|
37
|
+
* agents: { 'researcher-agent': { versionId: '123' } },
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare const MASTRA_VERSIONS_KEY = "mastra__versions";
|
|
42
|
+
/**
|
|
43
|
+
* Reserved key for storing the raw auth token from the incoming request.
|
|
44
|
+
* Used by the editor to forward authentication when connecting to MCP servers
|
|
45
|
+
* that require the same auth as the Mastra server itself.
|
|
46
|
+
*/
|
|
47
|
+
declare const MASTRA_AUTH_TOKEN_KEY = "mastra__authToken";
|
|
48
|
+
type VersionSelector = {
|
|
49
|
+
versionId: string;
|
|
50
|
+
} | {
|
|
51
|
+
status: 'draft' | 'published';
|
|
52
|
+
};
|
|
53
|
+
type VersionOverrides = {
|
|
54
|
+
agents?: Record<string, VersionSelector>;
|
|
55
|
+
/** Fallback status for sub-agents (and future primitives) without an explicit entry. */
|
|
56
|
+
defaultStatus?: 'draft' | 'published';
|
|
57
|
+
};
|
|
58
|
+
declare function mergeVersionOverrides(base?: VersionOverrides, overrides?: VersionOverrides): VersionOverrides | undefined;
|
|
59
|
+
declare class RequestContext<Values extends Record<string, any> | unknown = unknown> {
|
|
60
|
+
private registry;
|
|
61
|
+
constructor(iterable?: Values extends Record<string, any> ? RecordToTuple<Partial<Values>> : Iterable<readonly [string, unknown]>);
|
|
62
|
+
/**
|
|
63
|
+
* set a value with strict typing if `Values` is a Record and the key exists in it.
|
|
64
|
+
*/
|
|
65
|
+
set<K extends Values extends Record<string, any> ? keyof Values : string>(key: K, value: Values extends Record<string, any> ? (K extends keyof Values ? Values[K] : never) : unknown): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get a value with its type
|
|
68
|
+
*/
|
|
69
|
+
get<K extends Values extends Record<string, any> ? keyof Values : string, R = Values extends Record<string, any> ? (K extends keyof Values ? Values[K] : never) : unknown>(key: K): R;
|
|
70
|
+
/**
|
|
71
|
+
* Check if a key exists in the container
|
|
72
|
+
*/
|
|
73
|
+
has<K extends Values extends Record<string, any> ? keyof Values : string>(key: K): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Delete a value by key
|
|
76
|
+
*/
|
|
77
|
+
delete<K extends Values extends Record<string, any> ? keyof Values : string>(key: K): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Clear all values from the container
|
|
80
|
+
*/
|
|
81
|
+
clear(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Get all keys in the container
|
|
84
|
+
*/
|
|
85
|
+
keys(): IterableIterator<Values extends Record<string, any> ? keyof Values : string>;
|
|
86
|
+
/**
|
|
87
|
+
* Get all values in the container
|
|
88
|
+
*/
|
|
89
|
+
values(): IterableIterator<Values extends Record<string, any> ? Values[keyof Values] : unknown>;
|
|
90
|
+
/**
|
|
91
|
+
* Get all entries in the container.
|
|
92
|
+
* Returns a discriminated union of tuples for proper type narrowing when iterating.
|
|
93
|
+
*/
|
|
94
|
+
entries(): IterableIterator<Values extends Record<string, any> ? {
|
|
95
|
+
[K in keyof Values]: [K, Values[K]];
|
|
96
|
+
}[keyof Values] : [string, unknown]>;
|
|
97
|
+
/**
|
|
98
|
+
* Get the size of the container
|
|
99
|
+
*/
|
|
100
|
+
size(): number;
|
|
101
|
+
/**
|
|
102
|
+
* Execute a function for each entry in the container.
|
|
103
|
+
* The callback receives properly typed key-value pairs.
|
|
104
|
+
*/
|
|
105
|
+
forEach<K extends Values extends Record<string, any> ? keyof Values : string>(callbackfn: (value: Values extends Record<string, any> ? (K extends keyof Values ? Values[K] : unknown) : unknown, key: K, map: Map<string, unknown>) => void): void;
|
|
106
|
+
/**
|
|
107
|
+
* Custom JSON serialization method.
|
|
108
|
+
* Converts the internal Map to a plain object for proper JSON serialization.
|
|
109
|
+
* Non-serializable values (functions, symbols, RPC proxies, in-value
|
|
110
|
+
* circular references, and values whose serialization re-enters this
|
|
111
|
+
* `toJSON` via cross-context back-references) are skipped to prevent
|
|
112
|
+
* serialization errors when storing to database.
|
|
113
|
+
*
|
|
114
|
+
* Reentry safety: if a stored value's `isSerializable` probe re-enters
|
|
115
|
+
* `toJSON()` on this same instance (through a chain of RequestContexts
|
|
116
|
+
* holding references to each other), we throw `CyclicRequestContextToJSONError`.
|
|
117
|
+
* Inner `isSerializable` calls re-throw the marker; the outermost
|
|
118
|
+
* `isSerializable` swallows it and filters the offending key, the same
|
|
119
|
+
* way it filters in-value circular references today.
|
|
120
|
+
*/
|
|
121
|
+
toJSON(): Record<string, any>;
|
|
122
|
+
/**
|
|
123
|
+
* Check if a value can be safely serialized to JSON.
|
|
124
|
+
*
|
|
125
|
+
* Re-throws `CyclicRequestContextToJSONError` when called from a nested
|
|
126
|
+
* `toJSON()` (`_toJSONDepth > 1`), so the marker propagates up to the
|
|
127
|
+
* outermost `toJSON()`'s `isSerializable`, which then swallows it and
|
|
128
|
+
* filters the offending key. This is what lets the outermost call return
|
|
129
|
+
* a clean JSON-safe dict for cross-context cycles.
|
|
130
|
+
*/
|
|
131
|
+
private isSerializable;
|
|
132
|
+
/**
|
|
133
|
+
* Get all values as a typed object for destructuring.
|
|
134
|
+
* Returns Record<string, any> when untyped, or the Values type when typed.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const ctx = new RequestContext<{ userId: string; apiKey: string }>();
|
|
139
|
+
* ctx.set('userId', 'user-123');
|
|
140
|
+
* ctx.set('apiKey', 'key-456');
|
|
141
|
+
* const { userId, apiKey } = ctx.all;
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
get all(): Values extends Record<string, any> ? Values : Record<string, any>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { MASTRA_AUTH_TOKEN_KEY, MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, MASTRA_VERSIONS_KEY, RequestContext, type VersionOverrides, type VersionSelector, mergeVersionOverrides };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { Primitive } from "./helpers/typeAliases.js";
|
|
2
|
+
import { util, type ZodParsedType } from "./helpers/util.js";
|
|
3
|
+
import type { TypeOf, ZodType } from "./index.js";
|
|
4
|
+
type allKeys<T> = T extends any ? keyof T : never;
|
|
5
|
+
export type inferFlattenedErrors<T extends ZodType<any, any, any>, U = string> = typeToFlattenedError<TypeOf<T>, U>;
|
|
6
|
+
export type typeToFlattenedError<T, U = string> = {
|
|
7
|
+
formErrors: U[];
|
|
8
|
+
fieldErrors: {
|
|
9
|
+
[P in allKeys<T>]?: U[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const ZodIssueCode: {
|
|
13
|
+
custom: "custom";
|
|
14
|
+
invalid_type: "invalid_type";
|
|
15
|
+
too_big: "too_big";
|
|
16
|
+
too_small: "too_small";
|
|
17
|
+
not_multiple_of: "not_multiple_of";
|
|
18
|
+
unrecognized_keys: "unrecognized_keys";
|
|
19
|
+
invalid_union: "invalid_union";
|
|
20
|
+
invalid_literal: "invalid_literal";
|
|
21
|
+
invalid_union_discriminator: "invalid_union_discriminator";
|
|
22
|
+
invalid_enum_value: "invalid_enum_value";
|
|
23
|
+
invalid_arguments: "invalid_arguments";
|
|
24
|
+
invalid_return_type: "invalid_return_type";
|
|
25
|
+
invalid_date: "invalid_date";
|
|
26
|
+
invalid_string: "invalid_string";
|
|
27
|
+
invalid_intersection_types: "invalid_intersection_types";
|
|
28
|
+
not_finite: "not_finite";
|
|
29
|
+
};
|
|
30
|
+
export type ZodIssueCode = keyof typeof ZodIssueCode;
|
|
31
|
+
export type ZodIssueBase = {
|
|
32
|
+
path: (string | number)[];
|
|
33
|
+
message?: string | undefined;
|
|
34
|
+
};
|
|
35
|
+
export interface ZodInvalidTypeIssue extends ZodIssueBase {
|
|
36
|
+
code: typeof ZodIssueCode.invalid_type;
|
|
37
|
+
expected: ZodParsedType;
|
|
38
|
+
received: ZodParsedType;
|
|
39
|
+
}
|
|
40
|
+
export interface ZodInvalidLiteralIssue extends ZodIssueBase {
|
|
41
|
+
code: typeof ZodIssueCode.invalid_literal;
|
|
42
|
+
expected: unknown;
|
|
43
|
+
received: unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface ZodUnrecognizedKeysIssue extends ZodIssueBase {
|
|
46
|
+
code: typeof ZodIssueCode.unrecognized_keys;
|
|
47
|
+
keys: string[];
|
|
48
|
+
}
|
|
49
|
+
export interface ZodInvalidUnionIssue extends ZodIssueBase {
|
|
50
|
+
code: typeof ZodIssueCode.invalid_union;
|
|
51
|
+
unionErrors: ZodError[];
|
|
52
|
+
}
|
|
53
|
+
export interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {
|
|
54
|
+
code: typeof ZodIssueCode.invalid_union_discriminator;
|
|
55
|
+
options: Primitive[];
|
|
56
|
+
}
|
|
57
|
+
export interface ZodInvalidEnumValueIssue extends ZodIssueBase {
|
|
58
|
+
received: string | number;
|
|
59
|
+
code: typeof ZodIssueCode.invalid_enum_value;
|
|
60
|
+
options: (string | number)[];
|
|
61
|
+
}
|
|
62
|
+
export interface ZodInvalidArgumentsIssue extends ZodIssueBase {
|
|
63
|
+
code: typeof ZodIssueCode.invalid_arguments;
|
|
64
|
+
argumentsError: ZodError;
|
|
65
|
+
}
|
|
66
|
+
export interface ZodInvalidReturnTypeIssue extends ZodIssueBase {
|
|
67
|
+
code: typeof ZodIssueCode.invalid_return_type;
|
|
68
|
+
returnTypeError: ZodError;
|
|
69
|
+
}
|
|
70
|
+
export interface ZodInvalidDateIssue extends ZodIssueBase {
|
|
71
|
+
code: typeof ZodIssueCode.invalid_date;
|
|
72
|
+
}
|
|
73
|
+
export type StringValidation = "email" | "url" | "emoji" | "uuid" | "nanoid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "date" | "time" | "duration" | "ip" | "cidr" | "base64" | "jwt" | "base64url" | {
|
|
74
|
+
includes: string;
|
|
75
|
+
position?: number | undefined;
|
|
76
|
+
} | {
|
|
77
|
+
startsWith: string;
|
|
78
|
+
} | {
|
|
79
|
+
endsWith: string;
|
|
80
|
+
};
|
|
81
|
+
export interface ZodInvalidStringIssue extends ZodIssueBase {
|
|
82
|
+
code: typeof ZodIssueCode.invalid_string;
|
|
83
|
+
validation: StringValidation;
|
|
84
|
+
}
|
|
85
|
+
export interface ZodTooSmallIssue extends ZodIssueBase {
|
|
86
|
+
code: typeof ZodIssueCode.too_small;
|
|
87
|
+
minimum: number | bigint;
|
|
88
|
+
inclusive: boolean;
|
|
89
|
+
exact?: boolean;
|
|
90
|
+
type: "array" | "string" | "number" | "set" | "date" | "bigint";
|
|
91
|
+
}
|
|
92
|
+
export interface ZodTooBigIssue extends ZodIssueBase {
|
|
93
|
+
code: typeof ZodIssueCode.too_big;
|
|
94
|
+
maximum: number | bigint;
|
|
95
|
+
inclusive: boolean;
|
|
96
|
+
exact?: boolean;
|
|
97
|
+
type: "array" | "string" | "number" | "set" | "date" | "bigint";
|
|
98
|
+
}
|
|
99
|
+
export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {
|
|
100
|
+
code: typeof ZodIssueCode.invalid_intersection_types;
|
|
101
|
+
}
|
|
102
|
+
export interface ZodNotMultipleOfIssue extends ZodIssueBase {
|
|
103
|
+
code: typeof ZodIssueCode.not_multiple_of;
|
|
104
|
+
multipleOf: number | bigint;
|
|
105
|
+
}
|
|
106
|
+
export interface ZodNotFiniteIssue extends ZodIssueBase {
|
|
107
|
+
code: typeof ZodIssueCode.not_finite;
|
|
108
|
+
}
|
|
109
|
+
export interface ZodCustomIssue extends ZodIssueBase {
|
|
110
|
+
code: typeof ZodIssueCode.custom;
|
|
111
|
+
params?: {
|
|
112
|
+
[k: string]: any;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export type DenormalizedError = {
|
|
116
|
+
[k: string]: DenormalizedError | string[];
|
|
117
|
+
};
|
|
118
|
+
export type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodInvalidLiteralIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidUnionDiscriminatorIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodNotFiniteIssue | ZodCustomIssue;
|
|
119
|
+
export type ZodIssue = ZodIssueOptionalMessage & {
|
|
120
|
+
fatal?: boolean | undefined;
|
|
121
|
+
message: string;
|
|
122
|
+
};
|
|
123
|
+
export declare const quotelessJson: (obj: any) => string;
|
|
124
|
+
type recursiveZodFormattedError<T> = T extends [any, ...any[]] ? {
|
|
125
|
+
[K in keyof T]?: ZodFormattedError<T[K]>;
|
|
126
|
+
} : T extends any[] ? {
|
|
127
|
+
[k: number]: ZodFormattedError<T[number]>;
|
|
128
|
+
} : T extends object ? {
|
|
129
|
+
[K in keyof T]?: ZodFormattedError<T[K]>;
|
|
130
|
+
} : unknown;
|
|
131
|
+
export type ZodFormattedError<T, U = string> = {
|
|
132
|
+
_errors: U[];
|
|
133
|
+
} & recursiveZodFormattedError<NonNullable<T>>;
|
|
134
|
+
export type inferFormattedError<T extends ZodType<any, any, any>, U = string> = ZodFormattedError<TypeOf<T>, U>;
|
|
135
|
+
export declare class ZodError<T = any> extends Error {
|
|
136
|
+
issues: ZodIssue[];
|
|
137
|
+
get errors(): ZodIssue[];
|
|
138
|
+
constructor(issues: ZodIssue[]);
|
|
139
|
+
format(): ZodFormattedError<T>;
|
|
140
|
+
format<U>(mapper: (issue: ZodIssue) => U): ZodFormattedError<T, U>;
|
|
141
|
+
static create: (issues: ZodIssue[]) => ZodError<any>;
|
|
142
|
+
static assert(value: unknown): asserts value is ZodError;
|
|
143
|
+
toString(): string;
|
|
144
|
+
get message(): string;
|
|
145
|
+
get isEmpty(): boolean;
|
|
146
|
+
addIssue: (sub: ZodIssue) => void;
|
|
147
|
+
addIssues: (subs?: ZodIssue[]) => void;
|
|
148
|
+
flatten(): typeToFlattenedError<T>;
|
|
149
|
+
flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;
|
|
150
|
+
get formErrors(): typeToFlattenedError<T, string>;
|
|
151
|
+
}
|
|
152
|
+
type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
|
|
153
|
+
export type IssueData = stripPath<ZodIssueOptionalMessage> & {
|
|
154
|
+
path?: (string | number)[];
|
|
155
|
+
fatal?: boolean | undefined;
|
|
156
|
+
};
|
|
157
|
+
export type ErrorMapCtx = {
|
|
158
|
+
defaultError: string;
|
|
159
|
+
data: any;
|
|
160
|
+
};
|
|
161
|
+
export type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
|
|
162
|
+
message: string;
|
|
163
|
+
};
|
|
164
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare namespace enumUtil {
|
|
2
|
+
type UnionToIntersectionFn<T> = (T extends unknown ? (k: () => T) => void : never) extends (k: infer Intersection) => void ? Intersection : never;
|
|
3
|
+
type GetUnionLast<T> = UnionToIntersectionFn<T> extends () => infer Last ? Last : never;
|
|
4
|
+
type UnionToTuple<T, Tuple extends unknown[] = []> = [T] extends [never] ? Tuple : UnionToTuple<Exclude<T, GetUnionLast<T>>, [GetUnionLast<T>, ...Tuple]>;
|
|
5
|
+
type CastToStringTuple<T> = T extends [string, ...string[]] ? T : never;
|
|
6
|
+
export type UnionToTupleString<T> = CastToStringTuple<UnionToTuple<T>>;
|
|
7
|
+
export {};
|
|
8
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError.js";
|
|
2
|
+
import type { ZodParsedType } from "./util.js";
|
|
3
|
+
export declare const makeIssue: (params: {
|
|
4
|
+
data: any;
|
|
5
|
+
path: (string | number)[];
|
|
6
|
+
errorMaps: ZodErrorMap[];
|
|
7
|
+
issueData: IssueData;
|
|
8
|
+
}) => ZodIssue;
|
|
9
|
+
export type ParseParams = {
|
|
10
|
+
path: (string | number)[];
|
|
11
|
+
errorMap: ZodErrorMap;
|
|
12
|
+
async: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type ParsePathComponent = string | number;
|
|
15
|
+
export type ParsePath = ParsePathComponent[];
|
|
16
|
+
export declare const EMPTY_PATH: ParsePath;
|
|
17
|
+
export interface ParseContext {
|
|
18
|
+
readonly common: {
|
|
19
|
+
readonly issues: ZodIssue[];
|
|
20
|
+
readonly contextualErrorMap?: ZodErrorMap | undefined;
|
|
21
|
+
readonly async: boolean;
|
|
22
|
+
};
|
|
23
|
+
readonly path: ParsePath;
|
|
24
|
+
readonly schemaErrorMap?: ZodErrorMap | undefined;
|
|
25
|
+
readonly parent: ParseContext | null;
|
|
26
|
+
readonly data: any;
|
|
27
|
+
readonly parsedType: ZodParsedType;
|
|
28
|
+
}
|
|
29
|
+
export type ParseInput = {
|
|
30
|
+
data: any;
|
|
31
|
+
path: (string | number)[];
|
|
32
|
+
parent: ParseContext;
|
|
33
|
+
};
|
|
34
|
+
export declare function addIssueToContext(ctx: ParseContext, issueData: IssueData): void;
|
|
35
|
+
export type ObjectPair = {
|
|
36
|
+
key: SyncParseReturnType<any>;
|
|
37
|
+
value: SyncParseReturnType<any>;
|
|
38
|
+
};
|
|
39
|
+
export declare class ParseStatus {
|
|
40
|
+
value: "aborted" | "dirty" | "valid";
|
|
41
|
+
dirty(): void;
|
|
42
|
+
abort(): void;
|
|
43
|
+
static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType;
|
|
44
|
+
static mergeObjectAsync(status: ParseStatus, pairs: {
|
|
45
|
+
key: ParseReturnType<any>;
|
|
46
|
+
value: ParseReturnType<any>;
|
|
47
|
+
}[]): Promise<SyncParseReturnType<any>>;
|
|
48
|
+
static mergeObjectSync(status: ParseStatus, pairs: {
|
|
49
|
+
key: SyncParseReturnType<any>;
|
|
50
|
+
value: SyncParseReturnType<any>;
|
|
51
|
+
alwaysSet?: boolean;
|
|
52
|
+
}[]): SyncParseReturnType;
|
|
53
|
+
}
|
|
54
|
+
export interface ParseResult {
|
|
55
|
+
status: "aborted" | "dirty" | "valid";
|
|
56
|
+
data: any;
|
|
57
|
+
}
|
|
58
|
+
export type INVALID = {
|
|
59
|
+
status: "aborted";
|
|
60
|
+
};
|
|
61
|
+
export declare const INVALID: INVALID;
|
|
62
|
+
export type DIRTY<T> = {
|
|
63
|
+
status: "dirty";
|
|
64
|
+
value: T;
|
|
65
|
+
};
|
|
66
|
+
export declare const DIRTY: <T>(value: T) => DIRTY<T>;
|
|
67
|
+
export type OK<T> = {
|
|
68
|
+
status: "valid";
|
|
69
|
+
value: T;
|
|
70
|
+
};
|
|
71
|
+
export declare const OK: <T>(value: T) => OK<T>;
|
|
72
|
+
export type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
|
|
73
|
+
export type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
|
|
74
|
+
export type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
|
|
75
|
+
export declare const isAborted: (x: ParseReturnType<any>) => x is INVALID;
|
|
76
|
+
export declare const isDirty: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
|
|
77
|
+
export declare const isValid: <T>(x: ParseReturnType<T>) => x is OK<T>;
|
|
78
|
+
export declare const isAsync: <T>(x: ParseReturnType<T>) => x is AsyncParseReturnType<T>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodRawShape, ZodTuple, ZodTupleItems, ZodTypeAny } from "../types.js";
|
|
2
|
+
export declare namespace partialUtil {
|
|
3
|
+
type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape> ? ZodObject<{
|
|
4
|
+
[k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>>;
|
|
5
|
+
}, T["_def"]["unknownKeys"], T["_def"]["catchall"]> : T extends ZodArray<infer Type, infer Card> ? ZodArray<DeepPartial<Type>, Card> : T extends ZodOptional<infer Type> ? ZodOptional<DeepPartial<Type>> : T extends ZodNullable<infer Type> ? ZodNullable<DeepPartial<Type>> : T extends ZodTuple<infer Items> ? {
|
|
6
|
+
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
|
|
7
|
+
} extends infer PI ? PI extends ZodTupleItems ? ZodTuple<PI> : never : never : T;
|
|
8
|
+
}
|