fixparser-plugin-mcp 9.1.7-3e178996 → 9.1.7-525accda
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/build/cjs/MCPLocal.js +499 -1568
- package/build/cjs/MCPLocal.js.map +4 -4
- package/build/esm/MCPLocal.mjs +511 -1577
- package/build/esm/MCPLocal.mjs.map +4 -4
- package/build-examples/cjs/example_mcp_local.js +4 -5
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +4 -5
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +5 -4
package/build/cjs/MCPLocal.js
CHANGED
|
@@ -26,1266 +26,176 @@ module.exports = __toCommonJS(MCPLocal_exports);
|
|
|
26
26
|
var import_server = require("@modelcontextprotocol/sdk/server/index.js");
|
|
27
27
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
28
28
|
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
basePath: ["#"],
|
|
37
|
-
effectStrategy: "input",
|
|
38
|
-
pipeStrategy: "all",
|
|
39
|
-
dateStrategy: "format:date-time",
|
|
40
|
-
mapStrategy: "entries",
|
|
41
|
-
removeAdditionalStrategy: "passthrough",
|
|
42
|
-
allowedAdditionalProperties: true,
|
|
43
|
-
rejectedAdditionalProperties: false,
|
|
44
|
-
definitionPath: "definitions",
|
|
45
|
-
target: "jsonSchema7",
|
|
46
|
-
strictUnions: false,
|
|
47
|
-
definitions: {},
|
|
48
|
-
errorMessages: false,
|
|
49
|
-
markdownDescription: false,
|
|
50
|
-
patternStrategy: "escape",
|
|
51
|
-
applyRegexFlags: false,
|
|
52
|
-
emailStrategy: "format:email",
|
|
53
|
-
base64Strategy: "contentEncoding:base64",
|
|
54
|
-
nameStrategy: "ref"
|
|
55
|
-
};
|
|
56
|
-
var getDefaultOptions = (options) => typeof options === "string" ? {
|
|
57
|
-
...defaultOptions,
|
|
58
|
-
name: options
|
|
59
|
-
} : {
|
|
60
|
-
...defaultOptions,
|
|
61
|
-
...options
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
65
|
-
var getRefs = (options) => {
|
|
66
|
-
const _options = getDefaultOptions(options);
|
|
67
|
-
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
68
|
-
return {
|
|
69
|
-
..._options,
|
|
70
|
-
currentPath,
|
|
71
|
-
propertyPath: void 0,
|
|
72
|
-
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
|
|
73
|
-
def._def,
|
|
74
|
-
{
|
|
75
|
-
def: def._def,
|
|
76
|
-
path: [..._options.basePath, _options.definitionPath, name],
|
|
77
|
-
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
78
|
-
jsonSchema: void 0
|
|
79
|
-
}
|
|
80
|
-
]))
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
85
|
-
function addErrorMessage(res, key, errorMessage, refs) {
|
|
86
|
-
if (!refs?.errorMessages)
|
|
87
|
-
return;
|
|
88
|
-
if (errorMessage) {
|
|
89
|
-
res.errorMessage = {
|
|
90
|
-
...res.errorMessage,
|
|
91
|
-
[key]: errorMessage
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
96
|
-
res[key] = value;
|
|
97
|
-
addErrorMessage(res, key, errorMessage, refs);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
101
|
-
var import_zod4 = require("zod");
|
|
102
|
-
|
|
103
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
104
|
-
function parseAnyDef() {
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
109
|
-
var import_zod = require("zod");
|
|
110
|
-
function parseArrayDef(def, refs) {
|
|
111
|
-
const res = {
|
|
112
|
-
type: "array"
|
|
113
|
-
};
|
|
114
|
-
if (def.type?._def && def.type?._def?.typeName !== import_zod.ZodFirstPartyTypeKind.ZodAny) {
|
|
115
|
-
res.items = parseDef(def.type._def, {
|
|
116
|
-
...refs,
|
|
117
|
-
currentPath: [...refs.currentPath, "items"]
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
if (def.minLength) {
|
|
121
|
-
setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
122
|
-
}
|
|
123
|
-
if (def.maxLength) {
|
|
124
|
-
setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
125
|
-
}
|
|
126
|
-
if (def.exactLength) {
|
|
127
|
-
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
128
|
-
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
129
|
-
}
|
|
130
|
-
return res;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
134
|
-
function parseBigintDef(def, refs) {
|
|
135
|
-
const res = {
|
|
136
|
-
type: "integer",
|
|
137
|
-
format: "int64"
|
|
138
|
-
};
|
|
139
|
-
if (!def.checks)
|
|
140
|
-
return res;
|
|
141
|
-
for (const check of def.checks) {
|
|
142
|
-
switch (check.kind) {
|
|
143
|
-
case "min":
|
|
144
|
-
if (refs.target === "jsonSchema7") {
|
|
145
|
-
if (check.inclusive) {
|
|
146
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
147
|
-
} else {
|
|
148
|
-
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
if (!check.inclusive) {
|
|
152
|
-
res.exclusiveMinimum = true;
|
|
153
|
-
}
|
|
154
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
case "max":
|
|
158
|
-
if (refs.target === "jsonSchema7") {
|
|
159
|
-
if (check.inclusive) {
|
|
160
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
161
|
-
} else {
|
|
162
|
-
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
163
|
-
}
|
|
164
|
-
} else {
|
|
165
|
-
if (!check.inclusive) {
|
|
166
|
-
res.exclusiveMaximum = true;
|
|
167
|
-
}
|
|
168
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
169
|
-
}
|
|
170
|
-
break;
|
|
171
|
-
case "multipleOf":
|
|
172
|
-
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return res;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
180
|
-
function parseBooleanDef() {
|
|
181
|
-
return {
|
|
182
|
-
type: "boolean"
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
187
|
-
function parseBrandedDef(_def, refs) {
|
|
188
|
-
return parseDef(_def.type._def, refs);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
192
|
-
var parseCatchDef = (def, refs) => {
|
|
193
|
-
return parseDef(def.innerType._def, refs);
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
197
|
-
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
198
|
-
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
199
|
-
if (Array.isArray(strategy)) {
|
|
200
|
-
return {
|
|
201
|
-
anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
switch (strategy) {
|
|
205
|
-
case "string":
|
|
206
|
-
case "format:date-time":
|
|
207
|
-
return {
|
|
208
|
-
type: "string",
|
|
209
|
-
format: "date-time"
|
|
210
|
-
};
|
|
211
|
-
case "format:date":
|
|
212
|
-
return {
|
|
213
|
-
type: "string",
|
|
214
|
-
format: "date"
|
|
215
|
-
};
|
|
216
|
-
case "integer":
|
|
217
|
-
return integerDateParser(def, refs);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
var integerDateParser = (def, refs) => {
|
|
221
|
-
const res = {
|
|
222
|
-
type: "integer",
|
|
223
|
-
format: "unix-time"
|
|
224
|
-
};
|
|
225
|
-
if (refs.target === "openApi3") {
|
|
226
|
-
return res;
|
|
227
|
-
}
|
|
228
|
-
for (const check of def.checks) {
|
|
229
|
-
switch (check.kind) {
|
|
230
|
-
case "min":
|
|
231
|
-
setResponseValueAndErrors(
|
|
232
|
-
res,
|
|
233
|
-
"minimum",
|
|
234
|
-
check.value,
|
|
235
|
-
// This is in milliseconds
|
|
236
|
-
check.message,
|
|
237
|
-
refs
|
|
238
|
-
);
|
|
239
|
-
break;
|
|
240
|
-
case "max":
|
|
241
|
-
setResponseValueAndErrors(
|
|
242
|
-
res,
|
|
243
|
-
"maximum",
|
|
244
|
-
check.value,
|
|
245
|
-
// This is in milliseconds
|
|
246
|
-
check.message,
|
|
247
|
-
refs
|
|
248
|
-
);
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return res;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
256
|
-
function parseDefaultDef(_def, refs) {
|
|
257
|
-
return {
|
|
258
|
-
...parseDef(_def.innerType._def, refs),
|
|
259
|
-
default: _def.defaultValue()
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
264
|
-
function parseEffectsDef(_def, refs) {
|
|
265
|
-
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : {};
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
269
|
-
function parseEnumDef(def) {
|
|
270
|
-
return {
|
|
271
|
-
type: "string",
|
|
272
|
-
enum: Array.from(def.values)
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
277
|
-
var isJsonSchema7AllOfType = (type) => {
|
|
278
|
-
if ("type" in type && type.type === "string")
|
|
279
|
-
return false;
|
|
280
|
-
return "allOf" in type;
|
|
281
|
-
};
|
|
282
|
-
function parseIntersectionDef(def, refs) {
|
|
283
|
-
const allOf = [
|
|
284
|
-
parseDef(def.left._def, {
|
|
285
|
-
...refs,
|
|
286
|
-
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
287
|
-
}),
|
|
288
|
-
parseDef(def.right._def, {
|
|
289
|
-
...refs,
|
|
290
|
-
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
291
|
-
})
|
|
292
|
-
].filter((x) => !!x);
|
|
293
|
-
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : void 0;
|
|
294
|
-
const mergedAllOf = [];
|
|
295
|
-
allOf.forEach((schema) => {
|
|
296
|
-
if (isJsonSchema7AllOfType(schema)) {
|
|
297
|
-
mergedAllOf.push(...schema.allOf);
|
|
298
|
-
if (schema.unevaluatedProperties === void 0) {
|
|
299
|
-
unevaluatedProperties = void 0;
|
|
300
|
-
}
|
|
301
|
-
} else {
|
|
302
|
-
let nestedSchema = schema;
|
|
303
|
-
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
304
|
-
const { additionalProperties, ...rest } = schema;
|
|
305
|
-
nestedSchema = rest;
|
|
306
|
-
} else {
|
|
307
|
-
unevaluatedProperties = void 0;
|
|
308
|
-
}
|
|
309
|
-
mergedAllOf.push(nestedSchema);
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
return mergedAllOf.length ? {
|
|
313
|
-
allOf: mergedAllOf,
|
|
314
|
-
...unevaluatedProperties
|
|
315
|
-
} : void 0;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
319
|
-
function parseLiteralDef(def, refs) {
|
|
320
|
-
const parsedType = typeof def.value;
|
|
321
|
-
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
322
|
-
return {
|
|
323
|
-
type: Array.isArray(def.value) ? "array" : "object"
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
if (refs.target === "openApi3") {
|
|
327
|
-
return {
|
|
328
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
329
|
-
enum: [def.value]
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
return {
|
|
333
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
334
|
-
const: def.value
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
339
|
-
var import_zod2 = require("zod");
|
|
340
|
-
|
|
341
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
342
|
-
var emojiRegex = void 0;
|
|
343
|
-
var zodPatterns = {
|
|
344
|
-
/**
|
|
345
|
-
* `c` was changed to `[cC]` to replicate /i flag
|
|
346
|
-
*/
|
|
347
|
-
cuid: /^[cC][^\s-]{8,}$/,
|
|
348
|
-
cuid2: /^[0-9a-z]+$/,
|
|
349
|
-
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
350
|
-
/**
|
|
351
|
-
* `a-z` was added to replicate /i flag
|
|
352
|
-
*/
|
|
353
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
354
|
-
/**
|
|
355
|
-
* Constructed a valid Unicode RegExp
|
|
356
|
-
*
|
|
357
|
-
* Lazily instantiate since this type of regex isn't supported
|
|
358
|
-
* in all envs (e.g. React Native).
|
|
359
|
-
*
|
|
360
|
-
* See:
|
|
361
|
-
* https://github.com/colinhacks/zod/issues/2433
|
|
362
|
-
* Fix in Zod:
|
|
363
|
-
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
364
|
-
*/
|
|
365
|
-
emoji: () => {
|
|
366
|
-
if (emojiRegex === void 0) {
|
|
367
|
-
emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
29
|
+
var import_fixparser = require("fixparser");
|
|
30
|
+
var parseInputSchema = {
|
|
31
|
+
type: "object",
|
|
32
|
+
properties: {
|
|
33
|
+
fixString: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "FIX message string to parse"
|
|
368
36
|
}
|
|
369
|
-
return emojiRegex;
|
|
370
37
|
},
|
|
371
|
-
|
|
372
|
-
* Unused
|
|
373
|
-
*/
|
|
374
|
-
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
375
|
-
/**
|
|
376
|
-
* Unused
|
|
377
|
-
*/
|
|
378
|
-
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
379
|
-
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
380
|
-
/**
|
|
381
|
-
* Unused
|
|
382
|
-
*/
|
|
383
|
-
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
384
|
-
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
385
|
-
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
386
|
-
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
387
|
-
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
388
|
-
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
38
|
+
required: ["fixString"]
|
|
389
39
|
};
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (def.checks) {
|
|
395
|
-
for (const check of def.checks) {
|
|
396
|
-
switch (check.kind) {
|
|
397
|
-
case "min":
|
|
398
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
399
|
-
break;
|
|
400
|
-
case "max":
|
|
401
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
402
|
-
break;
|
|
403
|
-
case "email":
|
|
404
|
-
switch (refs.emailStrategy) {
|
|
405
|
-
case "format:email":
|
|
406
|
-
addFormat(res, "email", check.message, refs);
|
|
407
|
-
break;
|
|
408
|
-
case "format:idn-email":
|
|
409
|
-
addFormat(res, "idn-email", check.message, refs);
|
|
410
|
-
break;
|
|
411
|
-
case "pattern:zod":
|
|
412
|
-
addPattern(res, zodPatterns.email, check.message, refs);
|
|
413
|
-
break;
|
|
414
|
-
}
|
|
415
|
-
break;
|
|
416
|
-
case "url":
|
|
417
|
-
addFormat(res, "uri", check.message, refs);
|
|
418
|
-
break;
|
|
419
|
-
case "uuid":
|
|
420
|
-
addFormat(res, "uuid", check.message, refs);
|
|
421
|
-
break;
|
|
422
|
-
case "regex":
|
|
423
|
-
addPattern(res, check.regex, check.message, refs);
|
|
424
|
-
break;
|
|
425
|
-
case "cuid":
|
|
426
|
-
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
427
|
-
break;
|
|
428
|
-
case "cuid2":
|
|
429
|
-
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
430
|
-
break;
|
|
431
|
-
case "startsWith":
|
|
432
|
-
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
433
|
-
break;
|
|
434
|
-
case "endsWith":
|
|
435
|
-
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
436
|
-
break;
|
|
437
|
-
case "datetime":
|
|
438
|
-
addFormat(res, "date-time", check.message, refs);
|
|
439
|
-
break;
|
|
440
|
-
case "date":
|
|
441
|
-
addFormat(res, "date", check.message, refs);
|
|
442
|
-
break;
|
|
443
|
-
case "time":
|
|
444
|
-
addFormat(res, "time", check.message, refs);
|
|
445
|
-
break;
|
|
446
|
-
case "duration":
|
|
447
|
-
addFormat(res, "duration", check.message, refs);
|
|
448
|
-
break;
|
|
449
|
-
case "length":
|
|
450
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
451
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
452
|
-
break;
|
|
453
|
-
case "includes": {
|
|
454
|
-
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
455
|
-
break;
|
|
456
|
-
}
|
|
457
|
-
case "ip": {
|
|
458
|
-
if (check.version !== "v6") {
|
|
459
|
-
addFormat(res, "ipv4", check.message, refs);
|
|
460
|
-
}
|
|
461
|
-
if (check.version !== "v4") {
|
|
462
|
-
addFormat(res, "ipv6", check.message, refs);
|
|
463
|
-
}
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
466
|
-
case "base64url":
|
|
467
|
-
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
468
|
-
break;
|
|
469
|
-
case "jwt":
|
|
470
|
-
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
471
|
-
break;
|
|
472
|
-
case "cidr": {
|
|
473
|
-
if (check.version !== "v6") {
|
|
474
|
-
addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
475
|
-
}
|
|
476
|
-
if (check.version !== "v4") {
|
|
477
|
-
addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
478
|
-
}
|
|
479
|
-
break;
|
|
480
|
-
}
|
|
481
|
-
case "emoji":
|
|
482
|
-
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
483
|
-
break;
|
|
484
|
-
case "ulid": {
|
|
485
|
-
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
486
|
-
break;
|
|
487
|
-
}
|
|
488
|
-
case "base64": {
|
|
489
|
-
switch (refs.base64Strategy) {
|
|
490
|
-
case "format:binary": {
|
|
491
|
-
addFormat(res, "binary", check.message, refs);
|
|
492
|
-
break;
|
|
493
|
-
}
|
|
494
|
-
case "contentEncoding:base64": {
|
|
495
|
-
setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
496
|
-
break;
|
|
497
|
-
}
|
|
498
|
-
case "pattern:zod": {
|
|
499
|
-
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
break;
|
|
504
|
-
}
|
|
505
|
-
case "nanoid": {
|
|
506
|
-
addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
507
|
-
}
|
|
508
|
-
case "toLowerCase":
|
|
509
|
-
case "toUpperCase":
|
|
510
|
-
case "trim":
|
|
511
|
-
break;
|
|
512
|
-
default:
|
|
513
|
-
/* @__PURE__ */ ((_) => {
|
|
514
|
-
})(check);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
return res;
|
|
519
|
-
}
|
|
520
|
-
function escapeLiteralCheckValue(literal, refs) {
|
|
521
|
-
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
522
|
-
}
|
|
523
|
-
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
524
|
-
function escapeNonAlphaNumeric(source) {
|
|
525
|
-
let result = "";
|
|
526
|
-
for (let i = 0; i < source.length; i++) {
|
|
527
|
-
if (!ALPHA_NUMERIC.has(source[i])) {
|
|
528
|
-
result += "\\";
|
|
529
|
-
}
|
|
530
|
-
result += source[i];
|
|
531
|
-
}
|
|
532
|
-
return result;
|
|
533
|
-
}
|
|
534
|
-
function addFormat(schema, value, message, refs) {
|
|
535
|
-
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
536
|
-
if (!schema.anyOf) {
|
|
537
|
-
schema.anyOf = [];
|
|
538
|
-
}
|
|
539
|
-
if (schema.format) {
|
|
540
|
-
schema.anyOf.push({
|
|
541
|
-
format: schema.format,
|
|
542
|
-
...schema.errorMessage && refs.errorMessages && {
|
|
543
|
-
errorMessage: { format: schema.errorMessage.format }
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
delete schema.format;
|
|
547
|
-
if (schema.errorMessage) {
|
|
548
|
-
delete schema.errorMessage.format;
|
|
549
|
-
if (Object.keys(schema.errorMessage).length === 0) {
|
|
550
|
-
delete schema.errorMessage;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
schema.anyOf.push({
|
|
555
|
-
format: value,
|
|
556
|
-
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
557
|
-
});
|
|
558
|
-
} else {
|
|
559
|
-
setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
function addPattern(schema, regex, message, refs) {
|
|
563
|
-
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
564
|
-
if (!schema.allOf) {
|
|
565
|
-
schema.allOf = [];
|
|
566
|
-
}
|
|
567
|
-
if (schema.pattern) {
|
|
568
|
-
schema.allOf.push({
|
|
569
|
-
pattern: schema.pattern,
|
|
570
|
-
...schema.errorMessage && refs.errorMessages && {
|
|
571
|
-
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
delete schema.pattern;
|
|
575
|
-
if (schema.errorMessage) {
|
|
576
|
-
delete schema.errorMessage.pattern;
|
|
577
|
-
if (Object.keys(schema.errorMessage).length === 0) {
|
|
578
|
-
delete schema.errorMessage;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
schema.allOf.push({
|
|
583
|
-
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
584
|
-
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
585
|
-
});
|
|
586
|
-
} else {
|
|
587
|
-
setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
function stringifyRegExpWithFlags(regex, refs) {
|
|
591
|
-
if (!refs.applyRegexFlags || !regex.flags) {
|
|
592
|
-
return regex.source;
|
|
593
|
-
}
|
|
594
|
-
const flags = {
|
|
595
|
-
i: regex.flags.includes("i"),
|
|
596
|
-
m: regex.flags.includes("m"),
|
|
597
|
-
s: regex.flags.includes("s")
|
|
598
|
-
// `.` matches newlines
|
|
599
|
-
};
|
|
600
|
-
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
601
|
-
let pattern = "";
|
|
602
|
-
let isEscaped = false;
|
|
603
|
-
let inCharGroup = false;
|
|
604
|
-
let inCharRange = false;
|
|
605
|
-
for (let i = 0; i < source.length; i++) {
|
|
606
|
-
if (isEscaped) {
|
|
607
|
-
pattern += source[i];
|
|
608
|
-
isEscaped = false;
|
|
609
|
-
continue;
|
|
610
|
-
}
|
|
611
|
-
if (flags.i) {
|
|
612
|
-
if (inCharGroup) {
|
|
613
|
-
if (source[i].match(/[a-z]/)) {
|
|
614
|
-
if (inCharRange) {
|
|
615
|
-
pattern += source[i];
|
|
616
|
-
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
617
|
-
inCharRange = false;
|
|
618
|
-
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
619
|
-
pattern += source[i];
|
|
620
|
-
inCharRange = true;
|
|
621
|
-
} else {
|
|
622
|
-
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
623
|
-
}
|
|
624
|
-
continue;
|
|
625
|
-
}
|
|
626
|
-
} else if (source[i].match(/[a-z]/)) {
|
|
627
|
-
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
628
|
-
continue;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
if (flags.m) {
|
|
632
|
-
if (source[i] === "^") {
|
|
633
|
-
pattern += `(^|(?<=[\r
|
|
634
|
-
]))`;
|
|
635
|
-
continue;
|
|
636
|
-
} else if (source[i] === "$") {
|
|
637
|
-
pattern += `($|(?=[\r
|
|
638
|
-
]))`;
|
|
639
|
-
continue;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
if (flags.s && source[i] === ".") {
|
|
643
|
-
pattern += inCharGroup ? `${source[i]}\r
|
|
644
|
-
` : `[${source[i]}\r
|
|
645
|
-
]`;
|
|
646
|
-
continue;
|
|
647
|
-
}
|
|
648
|
-
pattern += source[i];
|
|
649
|
-
if (source[i] === "\\") {
|
|
650
|
-
isEscaped = true;
|
|
651
|
-
} else if (inCharGroup && source[i] === "]") {
|
|
652
|
-
inCharGroup = false;
|
|
653
|
-
} else if (!inCharGroup && source[i] === "[") {
|
|
654
|
-
inCharGroup = true;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
try {
|
|
658
|
-
new RegExp(pattern);
|
|
659
|
-
} catch {
|
|
660
|
-
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
661
|
-
return regex.source;
|
|
662
|
-
}
|
|
663
|
-
return pattern;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
667
|
-
function parseRecordDef(def, refs) {
|
|
668
|
-
if (refs.target === "openAi") {
|
|
669
|
-
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
670
|
-
}
|
|
671
|
-
if (refs.target === "openApi3" && def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodEnum) {
|
|
672
|
-
return {
|
|
673
|
-
type: "object",
|
|
674
|
-
required: def.keyType._def.values,
|
|
675
|
-
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
676
|
-
...acc,
|
|
677
|
-
[key]: parseDef(def.valueType._def, {
|
|
678
|
-
...refs,
|
|
679
|
-
currentPath: [...refs.currentPath, "properties", key]
|
|
680
|
-
}) ?? {}
|
|
681
|
-
}), {}),
|
|
682
|
-
additionalProperties: refs.rejectedAdditionalProperties
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
const schema = {
|
|
686
|
-
type: "object",
|
|
687
|
-
additionalProperties: parseDef(def.valueType._def, {
|
|
688
|
-
...refs,
|
|
689
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
690
|
-
}) ?? refs.allowedAdditionalProperties
|
|
691
|
-
};
|
|
692
|
-
if (refs.target === "openApi3") {
|
|
693
|
-
return schema;
|
|
694
|
-
}
|
|
695
|
-
if (def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
696
|
-
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
697
|
-
return {
|
|
698
|
-
...schema,
|
|
699
|
-
propertyNames: keyType
|
|
700
|
-
};
|
|
701
|
-
} else if (def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodEnum) {
|
|
702
|
-
return {
|
|
703
|
-
...schema,
|
|
704
|
-
propertyNames: {
|
|
705
|
-
enum: def.keyType._def.values
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
} else if (def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
709
|
-
const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
710
|
-
return {
|
|
711
|
-
...schema,
|
|
712
|
-
propertyNames: keyType
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
return schema;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
719
|
-
function parseMapDef(def, refs) {
|
|
720
|
-
if (refs.mapStrategy === "record") {
|
|
721
|
-
return parseRecordDef(def, refs);
|
|
722
|
-
}
|
|
723
|
-
const keys = parseDef(def.keyType._def, {
|
|
724
|
-
...refs,
|
|
725
|
-
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
726
|
-
}) || {};
|
|
727
|
-
const values = parseDef(def.valueType._def, {
|
|
728
|
-
...refs,
|
|
729
|
-
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
730
|
-
}) || {};
|
|
731
|
-
return {
|
|
732
|
-
type: "array",
|
|
733
|
-
maxItems: 125,
|
|
734
|
-
items: {
|
|
735
|
-
type: "array",
|
|
736
|
-
items: [keys, values],
|
|
737
|
-
minItems: 2,
|
|
738
|
-
maxItems: 2
|
|
739
|
-
}
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
744
|
-
function parseNativeEnumDef(def) {
|
|
745
|
-
const object = def.values;
|
|
746
|
-
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
747
|
-
return typeof object[object[key]] !== "number";
|
|
748
|
-
});
|
|
749
|
-
const actualValues = actualKeys.map((key) => object[key]);
|
|
750
|
-
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
751
|
-
return {
|
|
752
|
-
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
753
|
-
enum: actualValues
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
758
|
-
function parseNeverDef() {
|
|
759
|
-
return {
|
|
760
|
-
not: {}
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
765
|
-
function parseNullDef(refs) {
|
|
766
|
-
return refs.target === "openApi3" ? {
|
|
767
|
-
enum: ["null"],
|
|
768
|
-
nullable: true
|
|
769
|
-
} : {
|
|
770
|
-
type: "null"
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
775
|
-
var primitiveMappings = {
|
|
776
|
-
ZodString: "string",
|
|
777
|
-
ZodNumber: "number",
|
|
778
|
-
ZodBigInt: "integer",
|
|
779
|
-
ZodBoolean: "boolean",
|
|
780
|
-
ZodNull: "null"
|
|
781
|
-
};
|
|
782
|
-
function parseUnionDef(def, refs) {
|
|
783
|
-
if (refs.target === "openApi3")
|
|
784
|
-
return asAnyOf(def, refs);
|
|
785
|
-
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
786
|
-
if (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
|
|
787
|
-
const types = options.reduce((types2, x) => {
|
|
788
|
-
const type = primitiveMappings[x._def.typeName];
|
|
789
|
-
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
790
|
-
}, []);
|
|
791
|
-
return {
|
|
792
|
-
type: types.length > 1 ? types : types[0]
|
|
793
|
-
};
|
|
794
|
-
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
795
|
-
const types = options.reduce((acc, x) => {
|
|
796
|
-
const type = typeof x._def.value;
|
|
797
|
-
switch (type) {
|
|
798
|
-
case "string":
|
|
799
|
-
case "number":
|
|
800
|
-
case "boolean":
|
|
801
|
-
return [...acc, type];
|
|
802
|
-
case "bigint":
|
|
803
|
-
return [...acc, "integer"];
|
|
804
|
-
case "object":
|
|
805
|
-
if (x._def.value === null)
|
|
806
|
-
return [...acc, "null"];
|
|
807
|
-
case "symbol":
|
|
808
|
-
case "undefined":
|
|
809
|
-
case "function":
|
|
810
|
-
default:
|
|
811
|
-
return acc;
|
|
812
|
-
}
|
|
813
|
-
}, []);
|
|
814
|
-
if (types.length === options.length) {
|
|
815
|
-
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
816
|
-
return {
|
|
817
|
-
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
818
|
-
enum: options.reduce((acc, x) => {
|
|
819
|
-
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
820
|
-
}, [])
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
824
|
-
return {
|
|
40
|
+
var parseToJSONInputSchema = {
|
|
41
|
+
type: "object",
|
|
42
|
+
properties: {
|
|
43
|
+
fixString: {
|
|
825
44
|
type: "string",
|
|
826
|
-
|
|
827
|
-
...acc,
|
|
828
|
-
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
829
|
-
], [])
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
return asAnyOf(def, refs);
|
|
833
|
-
}
|
|
834
|
-
var asAnyOf = (def, refs) => {
|
|
835
|
-
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
836
|
-
...refs,
|
|
837
|
-
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
838
|
-
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
839
|
-
return anyOf.length ? { anyOf } : void 0;
|
|
840
|
-
};
|
|
841
|
-
|
|
842
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
843
|
-
function parseNullableDef(def, refs) {
|
|
844
|
-
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
845
|
-
if (refs.target === "openApi3") {
|
|
846
|
-
return {
|
|
847
|
-
type: primitiveMappings[def.innerType._def.typeName],
|
|
848
|
-
nullable: true
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
return {
|
|
852
|
-
type: [
|
|
853
|
-
primitiveMappings[def.innerType._def.typeName],
|
|
854
|
-
"null"
|
|
855
|
-
]
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
if (refs.target === "openApi3") {
|
|
859
|
-
const base2 = parseDef(def.innerType._def, {
|
|
860
|
-
...refs,
|
|
861
|
-
currentPath: [...refs.currentPath]
|
|
862
|
-
});
|
|
863
|
-
if (base2 && "$ref" in base2)
|
|
864
|
-
return { allOf: [base2], nullable: true };
|
|
865
|
-
return base2 && { ...base2, nullable: true };
|
|
866
|
-
}
|
|
867
|
-
const base = parseDef(def.innerType._def, {
|
|
868
|
-
...refs,
|
|
869
|
-
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
870
|
-
});
|
|
871
|
-
return base && { anyOf: [base, { type: "null" }] };
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
875
|
-
function parseNumberDef(def, refs) {
|
|
876
|
-
const res = {
|
|
877
|
-
type: "number"
|
|
878
|
-
};
|
|
879
|
-
if (!def.checks)
|
|
880
|
-
return res;
|
|
881
|
-
for (const check of def.checks) {
|
|
882
|
-
switch (check.kind) {
|
|
883
|
-
case "int":
|
|
884
|
-
res.type = "integer";
|
|
885
|
-
addErrorMessage(res, "type", check.message, refs);
|
|
886
|
-
break;
|
|
887
|
-
case "min":
|
|
888
|
-
if (refs.target === "jsonSchema7") {
|
|
889
|
-
if (check.inclusive) {
|
|
890
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
891
|
-
} else {
|
|
892
|
-
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
893
|
-
}
|
|
894
|
-
} else {
|
|
895
|
-
if (!check.inclusive) {
|
|
896
|
-
res.exclusiveMinimum = true;
|
|
897
|
-
}
|
|
898
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
899
|
-
}
|
|
900
|
-
break;
|
|
901
|
-
case "max":
|
|
902
|
-
if (refs.target === "jsonSchema7") {
|
|
903
|
-
if (check.inclusive) {
|
|
904
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
905
|
-
} else {
|
|
906
|
-
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
907
|
-
}
|
|
908
|
-
} else {
|
|
909
|
-
if (!check.inclusive) {
|
|
910
|
-
res.exclusiveMaximum = true;
|
|
911
|
-
}
|
|
912
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
913
|
-
}
|
|
914
|
-
break;
|
|
915
|
-
case "multipleOf":
|
|
916
|
-
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
917
|
-
break;
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
return res;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
924
|
-
var import_zod3 = require("zod");
|
|
925
|
-
function parseObjectDef(def, refs) {
|
|
926
|
-
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
927
|
-
const result = {
|
|
928
|
-
type: "object",
|
|
929
|
-
properties: {}
|
|
930
|
-
};
|
|
931
|
-
const required = [];
|
|
932
|
-
const shape = def.shape();
|
|
933
|
-
for (const propName in shape) {
|
|
934
|
-
let propDef = shape[propName];
|
|
935
|
-
if (propDef === void 0 || propDef._def === void 0) {
|
|
936
|
-
continue;
|
|
937
|
-
}
|
|
938
|
-
let propOptional = safeIsOptional(propDef);
|
|
939
|
-
if (propOptional && forceOptionalIntoNullable) {
|
|
940
|
-
if (propDef instanceof import_zod3.ZodOptional) {
|
|
941
|
-
propDef = propDef._def.innerType;
|
|
942
|
-
}
|
|
943
|
-
if (!propDef.isNullable()) {
|
|
944
|
-
propDef = propDef.nullable();
|
|
945
|
-
}
|
|
946
|
-
propOptional = false;
|
|
947
|
-
}
|
|
948
|
-
const parsedDef = parseDef(propDef._def, {
|
|
949
|
-
...refs,
|
|
950
|
-
currentPath: [...refs.currentPath, "properties", propName],
|
|
951
|
-
propertyPath: [...refs.currentPath, "properties", propName]
|
|
952
|
-
});
|
|
953
|
-
if (parsedDef === void 0) {
|
|
954
|
-
continue;
|
|
955
|
-
}
|
|
956
|
-
result.properties[propName] = parsedDef;
|
|
957
|
-
if (!propOptional) {
|
|
958
|
-
required.push(propName);
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
if (required.length) {
|
|
962
|
-
result.required = required;
|
|
963
|
-
}
|
|
964
|
-
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
965
|
-
if (additionalProperties !== void 0) {
|
|
966
|
-
result.additionalProperties = additionalProperties;
|
|
967
|
-
}
|
|
968
|
-
return result;
|
|
969
|
-
}
|
|
970
|
-
function decideAdditionalProperties(def, refs) {
|
|
971
|
-
if (def.catchall._def.typeName !== "ZodNever") {
|
|
972
|
-
return parseDef(def.catchall._def, {
|
|
973
|
-
...refs,
|
|
974
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
switch (def.unknownKeys) {
|
|
978
|
-
case "passthrough":
|
|
979
|
-
return refs.allowedAdditionalProperties;
|
|
980
|
-
case "strict":
|
|
981
|
-
return refs.rejectedAdditionalProperties;
|
|
982
|
-
case "strip":
|
|
983
|
-
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
function safeIsOptional(schema) {
|
|
987
|
-
try {
|
|
988
|
-
return schema.isOptional();
|
|
989
|
-
} catch {
|
|
990
|
-
return true;
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
995
|
-
var parseOptionalDef = (def, refs) => {
|
|
996
|
-
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
997
|
-
return parseDef(def.innerType._def, refs);
|
|
998
|
-
}
|
|
999
|
-
const innerSchema = parseDef(def.innerType._def, {
|
|
1000
|
-
...refs,
|
|
1001
|
-
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
1002
|
-
});
|
|
1003
|
-
return innerSchema ? {
|
|
1004
|
-
anyOf: [
|
|
1005
|
-
{
|
|
1006
|
-
not: {}
|
|
1007
|
-
},
|
|
1008
|
-
innerSchema
|
|
1009
|
-
]
|
|
1010
|
-
} : {};
|
|
1011
|
-
};
|
|
1012
|
-
|
|
1013
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
1014
|
-
var parsePipelineDef = (def, refs) => {
|
|
1015
|
-
if (refs.pipeStrategy === "input") {
|
|
1016
|
-
return parseDef(def.in._def, refs);
|
|
1017
|
-
} else if (refs.pipeStrategy === "output") {
|
|
1018
|
-
return parseDef(def.out._def, refs);
|
|
1019
|
-
}
|
|
1020
|
-
const a = parseDef(def.in._def, {
|
|
1021
|
-
...refs,
|
|
1022
|
-
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
1023
|
-
});
|
|
1024
|
-
const b = parseDef(def.out._def, {
|
|
1025
|
-
...refs,
|
|
1026
|
-
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
1027
|
-
});
|
|
1028
|
-
return {
|
|
1029
|
-
allOf: [a, b].filter((x) => x !== void 0)
|
|
1030
|
-
};
|
|
1031
|
-
};
|
|
1032
|
-
|
|
1033
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
1034
|
-
function parsePromiseDef(def, refs) {
|
|
1035
|
-
return parseDef(def.type._def, refs);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
1039
|
-
function parseSetDef(def, refs) {
|
|
1040
|
-
const items = parseDef(def.valueType._def, {
|
|
1041
|
-
...refs,
|
|
1042
|
-
currentPath: [...refs.currentPath, "items"]
|
|
1043
|
-
});
|
|
1044
|
-
const schema = {
|
|
1045
|
-
type: "array",
|
|
1046
|
-
uniqueItems: true,
|
|
1047
|
-
items
|
|
1048
|
-
};
|
|
1049
|
-
if (def.minSize) {
|
|
1050
|
-
setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
1051
|
-
}
|
|
1052
|
-
if (def.maxSize) {
|
|
1053
|
-
setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
1054
|
-
}
|
|
1055
|
-
return schema;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
1059
|
-
function parseTupleDef(def, refs) {
|
|
1060
|
-
if (def.rest) {
|
|
1061
|
-
return {
|
|
1062
|
-
type: "array",
|
|
1063
|
-
minItems: def.items.length,
|
|
1064
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
1065
|
-
...refs,
|
|
1066
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
1067
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
|
|
1068
|
-
additionalItems: parseDef(def.rest._def, {
|
|
1069
|
-
...refs,
|
|
1070
|
-
currentPath: [...refs.currentPath, "additionalItems"]
|
|
1071
|
-
})
|
|
1072
|
-
};
|
|
1073
|
-
} else {
|
|
1074
|
-
return {
|
|
1075
|
-
type: "array",
|
|
1076
|
-
minItems: def.items.length,
|
|
1077
|
-
maxItems: def.items.length,
|
|
1078
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
1079
|
-
...refs,
|
|
1080
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
1081
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
1087
|
-
function parseUndefinedDef() {
|
|
1088
|
-
return {
|
|
1089
|
-
not: {}
|
|
1090
|
-
};
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
1094
|
-
function parseUnknownDef() {
|
|
1095
|
-
return {};
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
1099
|
-
var parseReadonlyDef = (def, refs) => {
|
|
1100
|
-
return parseDef(def.innerType._def, refs);
|
|
1101
|
-
};
|
|
1102
|
-
|
|
1103
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
1104
|
-
var selectParser = (def, typeName, refs) => {
|
|
1105
|
-
switch (typeName) {
|
|
1106
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodString:
|
|
1107
|
-
return parseStringDef(def, refs);
|
|
1108
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNumber:
|
|
1109
|
-
return parseNumberDef(def, refs);
|
|
1110
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodObject:
|
|
1111
|
-
return parseObjectDef(def, refs);
|
|
1112
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodBigInt:
|
|
1113
|
-
return parseBigintDef(def, refs);
|
|
1114
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodBoolean:
|
|
1115
|
-
return parseBooleanDef();
|
|
1116
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodDate:
|
|
1117
|
-
return parseDateDef(def, refs);
|
|
1118
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodUndefined:
|
|
1119
|
-
return parseUndefinedDef();
|
|
1120
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNull:
|
|
1121
|
-
return parseNullDef(refs);
|
|
1122
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodArray:
|
|
1123
|
-
return parseArrayDef(def, refs);
|
|
1124
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodUnion:
|
|
1125
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
1126
|
-
return parseUnionDef(def, refs);
|
|
1127
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodIntersection:
|
|
1128
|
-
return parseIntersectionDef(def, refs);
|
|
1129
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodTuple:
|
|
1130
|
-
return parseTupleDef(def, refs);
|
|
1131
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodRecord:
|
|
1132
|
-
return parseRecordDef(def, refs);
|
|
1133
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodLiteral:
|
|
1134
|
-
return parseLiteralDef(def, refs);
|
|
1135
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodEnum:
|
|
1136
|
-
return parseEnumDef(def);
|
|
1137
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
1138
|
-
return parseNativeEnumDef(def);
|
|
1139
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNullable:
|
|
1140
|
-
return parseNullableDef(def, refs);
|
|
1141
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodOptional:
|
|
1142
|
-
return parseOptionalDef(def, refs);
|
|
1143
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodMap:
|
|
1144
|
-
return parseMapDef(def, refs);
|
|
1145
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodSet:
|
|
1146
|
-
return parseSetDef(def, refs);
|
|
1147
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodLazy:
|
|
1148
|
-
return () => def.getter()._def;
|
|
1149
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodPromise:
|
|
1150
|
-
return parsePromiseDef(def, refs);
|
|
1151
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNaN:
|
|
1152
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodNever:
|
|
1153
|
-
return parseNeverDef();
|
|
1154
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodEffects:
|
|
1155
|
-
return parseEffectsDef(def, refs);
|
|
1156
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodAny:
|
|
1157
|
-
return parseAnyDef();
|
|
1158
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodUnknown:
|
|
1159
|
-
return parseUnknownDef();
|
|
1160
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodDefault:
|
|
1161
|
-
return parseDefaultDef(def, refs);
|
|
1162
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodBranded:
|
|
1163
|
-
return parseBrandedDef(def, refs);
|
|
1164
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodReadonly:
|
|
1165
|
-
return parseReadonlyDef(def, refs);
|
|
1166
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodCatch:
|
|
1167
|
-
return parseCatchDef(def, refs);
|
|
1168
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodPipeline:
|
|
1169
|
-
return parsePipelineDef(def, refs);
|
|
1170
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodFunction:
|
|
1171
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodVoid:
|
|
1172
|
-
case import_zod4.ZodFirstPartyTypeKind.ZodSymbol:
|
|
1173
|
-
return void 0;
|
|
1174
|
-
default:
|
|
1175
|
-
return /* @__PURE__ */ ((_) => void 0)(typeName);
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
|
|
1179
|
-
// ../../node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
1180
|
-
function parseDef(def, refs, forceResolution = false) {
|
|
1181
|
-
const seenItem = refs.seen.get(def);
|
|
1182
|
-
if (refs.override) {
|
|
1183
|
-
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
1184
|
-
if (overrideResult !== ignoreOverride) {
|
|
1185
|
-
return overrideResult;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
if (seenItem && !forceResolution) {
|
|
1189
|
-
const seenSchema = get$ref(seenItem, refs);
|
|
1190
|
-
if (seenSchema !== void 0) {
|
|
1191
|
-
return seenSchema;
|
|
45
|
+
description: "FIX message string to parse"
|
|
1192
46
|
}
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
refs.seen.set(def, newItem);
|
|
1196
|
-
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
1197
|
-
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
1198
|
-
if (jsonSchema) {
|
|
1199
|
-
addMeta(def, refs, jsonSchema);
|
|
1200
|
-
}
|
|
1201
|
-
if (refs.postProcess) {
|
|
1202
|
-
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
1203
|
-
newItem.jsonSchema = jsonSchema;
|
|
1204
|
-
return postProcessResult;
|
|
1205
|
-
}
|
|
1206
|
-
newItem.jsonSchema = jsonSchema;
|
|
1207
|
-
return jsonSchema;
|
|
1208
|
-
}
|
|
1209
|
-
var get$ref = (item, refs) => {
|
|
1210
|
-
switch (refs.$refStrategy) {
|
|
1211
|
-
case "root":
|
|
1212
|
-
return { $ref: item.path.join("/") };
|
|
1213
|
-
case "relative":
|
|
1214
|
-
return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
1215
|
-
case "none":
|
|
1216
|
-
case "seen": {
|
|
1217
|
-
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
1218
|
-
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
1219
|
-
return {};
|
|
1220
|
-
}
|
|
1221
|
-
return refs.$refStrategy === "seen" ? {} : void 0;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
};
|
|
1225
|
-
var getRelativePath = (pathA, pathB) => {
|
|
1226
|
-
let i = 0;
|
|
1227
|
-
for (; i < pathA.length && i < pathB.length; i++) {
|
|
1228
|
-
if (pathA[i] !== pathB[i])
|
|
1229
|
-
break;
|
|
1230
|
-
}
|
|
1231
|
-
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
47
|
+
},
|
|
48
|
+
required: ["fixString"]
|
|
1232
49
|
};
|
|
1233
|
-
var
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
50
|
+
var newOrderSingleInputSchema = {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
clOrdID: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "Client Order ID"
|
|
56
|
+
},
|
|
57
|
+
handlInst: {
|
|
58
|
+
type: "string",
|
|
59
|
+
enum: ["1", "2", "3"],
|
|
60
|
+
default: import_fixparser.HandlInst.AutomatedExecutionNoIntervention,
|
|
61
|
+
description: 'Handling instruction (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Manual, "2" for Automated, "3" for AutomatedNoIntervention)'
|
|
62
|
+
},
|
|
63
|
+
quantity: {
|
|
64
|
+
type: "number",
|
|
65
|
+
description: "Order quantity"
|
|
66
|
+
},
|
|
67
|
+
price: {
|
|
68
|
+
type: "number",
|
|
69
|
+
description: "Order price"
|
|
70
|
+
},
|
|
71
|
+
ordType: {
|
|
72
|
+
type: "string",
|
|
73
|
+
enum: [
|
|
74
|
+
"1",
|
|
75
|
+
"2",
|
|
76
|
+
"3",
|
|
77
|
+
"4",
|
|
78
|
+
"5",
|
|
79
|
+
"6",
|
|
80
|
+
"7",
|
|
81
|
+
"8",
|
|
82
|
+
"9",
|
|
83
|
+
"A",
|
|
84
|
+
"B",
|
|
85
|
+
"C",
|
|
86
|
+
"D",
|
|
87
|
+
"E",
|
|
88
|
+
"F",
|
|
89
|
+
"G",
|
|
90
|
+
"H",
|
|
91
|
+
"I",
|
|
92
|
+
"J",
|
|
93
|
+
"K",
|
|
94
|
+
"L",
|
|
95
|
+
"M",
|
|
96
|
+
"P",
|
|
97
|
+
"Q",
|
|
98
|
+
"R",
|
|
99
|
+
"S"
|
|
100
|
+
],
|
|
101
|
+
default: import_fixparser.OrdType.Market,
|
|
102
|
+
description: 'Order type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Market, "2" for Limit, "3" for Stop)'
|
|
103
|
+
},
|
|
104
|
+
side: {
|
|
105
|
+
type: "string",
|
|
106
|
+
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
107
|
+
description: 'Order side (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Buy, "2" for Sell, "3" for BuyMinus, "4" for SellPlus, "5" for SellShort, "6" for SellShortExempt, "7" for Undisclosed, "8" for Cross, "9" for CrossShort, "A" for CrossShortExempt, "B" for AsDefined, "C" for Opposite, "D" for Subscribe, "E" for Redeem, "F" for Lend, "G" for Borrow, "H" for SellUndisclosed)'
|
|
108
|
+
},
|
|
109
|
+
symbol: {
|
|
110
|
+
type: "string",
|
|
111
|
+
description: "Trading symbol"
|
|
112
|
+
},
|
|
113
|
+
timeInForce: {
|
|
114
|
+
type: "string",
|
|
115
|
+
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
116
|
+
default: import_fixparser.TimeInForce.Day,
|
|
117
|
+
description: 'Time in force (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Day, "1" for Good Till Cancel, "2" for At Opening, "3" for Immediate or Cancel, "4" for Fill or Kill, "5" for Good Till Crossing, "6" for Good Till Date)'
|
|
1238
118
|
}
|
|
1239
|
-
}
|
|
1240
|
-
|
|
119
|
+
},
|
|
120
|
+
required: ["clOrdID", "quantity", "price", "side", "symbol"]
|
|
1241
121
|
};
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
122
|
+
var marketDataRequestInputSchema = {
|
|
123
|
+
type: "object",
|
|
124
|
+
properties: {
|
|
125
|
+
mdUpdateType: {
|
|
126
|
+
type: "string",
|
|
127
|
+
enum: ["0", "1"],
|
|
128
|
+
default: "0",
|
|
129
|
+
description: 'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for FullRefresh, "1" for IncrementalRefresh)'
|
|
130
|
+
},
|
|
131
|
+
symbol: {
|
|
132
|
+
type: "string",
|
|
133
|
+
description: "Trading symbol"
|
|
134
|
+
},
|
|
135
|
+
mdReqID: {
|
|
136
|
+
type: "string",
|
|
137
|
+
description: "Market data request ID"
|
|
138
|
+
},
|
|
139
|
+
subscriptionRequestType: {
|
|
140
|
+
type: "string",
|
|
141
|
+
enum: ["0", "1", "2"],
|
|
142
|
+
default: import_fixparser.SubscriptionRequestType.SnapshotAndUpdates,
|
|
143
|
+
description: 'Subscription request type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Snapshot + Updates, "1" for Snapshot, "2" for Unsubscribe)'
|
|
144
|
+
},
|
|
145
|
+
mdEntryType: {
|
|
146
|
+
type: "string",
|
|
147
|
+
enum: [
|
|
148
|
+
"0",
|
|
149
|
+
"1",
|
|
150
|
+
"2",
|
|
151
|
+
"3",
|
|
152
|
+
"4",
|
|
153
|
+
"5",
|
|
154
|
+
"6",
|
|
155
|
+
"7",
|
|
156
|
+
"8",
|
|
157
|
+
"9",
|
|
158
|
+
"A",
|
|
159
|
+
"B",
|
|
160
|
+
"C",
|
|
161
|
+
"D",
|
|
162
|
+
"E",
|
|
163
|
+
"F",
|
|
164
|
+
"G",
|
|
165
|
+
"H",
|
|
166
|
+
"J",
|
|
167
|
+
"K",
|
|
168
|
+
"L",
|
|
169
|
+
"M",
|
|
170
|
+
"N",
|
|
171
|
+
"O",
|
|
172
|
+
"P",
|
|
173
|
+
"Q",
|
|
174
|
+
"S",
|
|
175
|
+
"R",
|
|
176
|
+
"T",
|
|
177
|
+
"U",
|
|
178
|
+
"V",
|
|
179
|
+
"W",
|
|
180
|
+
"X",
|
|
181
|
+
"Y",
|
|
182
|
+
"Z",
|
|
183
|
+
"a",
|
|
184
|
+
"b",
|
|
185
|
+
"c",
|
|
186
|
+
"d",
|
|
187
|
+
"e",
|
|
188
|
+
"g",
|
|
189
|
+
"h",
|
|
190
|
+
"i",
|
|
191
|
+
"t"
|
|
192
|
+
],
|
|
193
|
+
default: import_fixparser.MDEntryType.Bid,
|
|
194
|
+
description: 'Market data entry type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Bid, "1" for Offer, "2" for Trade, "3" for Index Value, "4" for Opening Price)'
|
|
1274
195
|
}
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
1278
|
-
} else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
|
|
1279
|
-
combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
1280
|
-
}
|
|
1281
|
-
if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) {
|
|
1282
|
-
console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
1283
|
-
}
|
|
1284
|
-
return combined;
|
|
196
|
+
},
|
|
197
|
+
required: ["symbol", "mdReqID"]
|
|
1285
198
|
};
|
|
1286
|
-
|
|
1287
|
-
// src/MCPLocal.ts
|
|
1288
|
-
var import_fixparser = require("fixparser");
|
|
1289
199
|
var MCPLocal = class {
|
|
1290
200
|
logger;
|
|
1291
201
|
parser;
|
|
@@ -1295,23 +205,28 @@ var MCPLocal = class {
|
|
|
1295
205
|
version: "1.0.0"
|
|
1296
206
|
},
|
|
1297
207
|
{
|
|
1298
|
-
capabilities: {
|
|
208
|
+
capabilities: {
|
|
209
|
+
tools: {},
|
|
210
|
+
prompts: {},
|
|
211
|
+
resources: {}
|
|
212
|
+
}
|
|
1299
213
|
}
|
|
1300
214
|
);
|
|
1301
215
|
transport = new import_stdio.StdioServerTransport();
|
|
1302
216
|
onReady = void 0;
|
|
1303
217
|
pendingRequests = /* @__PURE__ */ new Map();
|
|
1304
218
|
constructor({ logger, onReady }) {
|
|
1305
|
-
if (logger
|
|
219
|
+
if (logger && !logger.silent) {
|
|
220
|
+
this.logger = logger;
|
|
221
|
+
}
|
|
1306
222
|
if (onReady) this.onReady = onReady;
|
|
1307
223
|
}
|
|
1308
224
|
async register(parser) {
|
|
1309
225
|
this.parser = parser;
|
|
226
|
+
if (parser.logger && !parser.logger.silent) {
|
|
227
|
+
this.logger = parser.logger;
|
|
228
|
+
}
|
|
1310
229
|
this.parser.addOnMessageCallback((message) => {
|
|
1311
|
-
this.logger?.log({
|
|
1312
|
-
level: "info",
|
|
1313
|
-
message: `FIXParser (MCP): (${parser.protocol?.toUpperCase()}): << received ${message.description}`
|
|
1314
|
-
});
|
|
1315
230
|
const msgType = message.messageType;
|
|
1316
231
|
if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser.Messages.ExecutionReport) {
|
|
1317
232
|
const idField = msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh ? message.getField(import_fixparser.Fields.MDReqID) : message.getField(import_fixparser.Fields.ClOrdID);
|
|
@@ -1327,7 +242,6 @@ var MCPLocal = class {
|
|
|
1327
242
|
}
|
|
1328
243
|
}
|
|
1329
244
|
});
|
|
1330
|
-
this.logger = parser.logger;
|
|
1331
245
|
this.addWorkflows();
|
|
1332
246
|
await this.server.connect(this.transport);
|
|
1333
247
|
if (this.onReady) {
|
|
@@ -1349,149 +263,49 @@ var MCPLocal = class {
|
|
|
1349
263
|
});
|
|
1350
264
|
return;
|
|
1351
265
|
}
|
|
266
|
+
const validateArgs = (args, schema) => {
|
|
267
|
+
const result = {};
|
|
268
|
+
for (const [key, propSchema] of Object.entries(schema.properties || {})) {
|
|
269
|
+
const prop = propSchema;
|
|
270
|
+
const value = args?.[key];
|
|
271
|
+
if (prop.required && (value === void 0 || value === null)) {
|
|
272
|
+
throw new Error(`Required property '${key}' is missing`);
|
|
273
|
+
}
|
|
274
|
+
if (value !== void 0) {
|
|
275
|
+
result[key] = value;
|
|
276
|
+
} else if (prop.default !== void 0) {
|
|
277
|
+
result[key] = prop.default;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return result;
|
|
281
|
+
};
|
|
282
|
+
this.server.setRequestHandler(import_types.ListResourcesRequestSchema, async () => {
|
|
283
|
+
return {
|
|
284
|
+
resources: []
|
|
285
|
+
};
|
|
286
|
+
});
|
|
1352
287
|
this.server.setRequestHandler(import_types.ListToolsRequestSchema, async () => {
|
|
1353
288
|
return {
|
|
1354
289
|
tools: [
|
|
1355
290
|
{
|
|
1356
291
|
name: "parse",
|
|
1357
292
|
description: "Parses a FIX message and describes it in plain language",
|
|
1358
|
-
inputSchema:
|
|
1359
|
-
import_zod5.z.object({
|
|
1360
|
-
fixString: import_zod5.z.string().describe("FIX message string to parse")
|
|
1361
|
-
}),
|
|
1362
|
-
{ name: "ParseInput" }
|
|
1363
|
-
)
|
|
293
|
+
inputSchema: parseInputSchema
|
|
1364
294
|
},
|
|
1365
295
|
{
|
|
1366
296
|
name: "parseToJSON",
|
|
1367
297
|
description: "Parses a FIX message into JSON",
|
|
1368
|
-
inputSchema:
|
|
1369
|
-
import_zod5.z.object({
|
|
1370
|
-
fixString: import_zod5.z.string().describe("FIX message string to parse")
|
|
1371
|
-
}),
|
|
1372
|
-
{ name: "ParseToJSONInput" }
|
|
1373
|
-
)
|
|
298
|
+
inputSchema: parseToJSONInputSchema
|
|
1374
299
|
},
|
|
1375
300
|
{
|
|
1376
301
|
name: "newOrderSingle",
|
|
1377
302
|
description: "Creates and sends a New Order Single",
|
|
1378
|
-
inputSchema:
|
|
1379
|
-
import_zod5.z.object({
|
|
1380
|
-
clOrdID: import_zod5.z.string().describe("Client Order ID"),
|
|
1381
|
-
handlInst: import_zod5.z.enum(["1", "2", "3"]).default(import_fixparser.HandlInst.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),
|
|
1382
|
-
quantity: import_zod5.z.number().describe("Order quantity"),
|
|
1383
|
-
price: import_zod5.z.number().describe("Order price"),
|
|
1384
|
-
ordType: import_zod5.z.enum([
|
|
1385
|
-
"1",
|
|
1386
|
-
"2",
|
|
1387
|
-
"3",
|
|
1388
|
-
"4",
|
|
1389
|
-
"5",
|
|
1390
|
-
"6",
|
|
1391
|
-
"7",
|
|
1392
|
-
"8",
|
|
1393
|
-
"9",
|
|
1394
|
-
"A",
|
|
1395
|
-
"B",
|
|
1396
|
-
"C",
|
|
1397
|
-
"D",
|
|
1398
|
-
"E",
|
|
1399
|
-
"F",
|
|
1400
|
-
"G",
|
|
1401
|
-
"H",
|
|
1402
|
-
"I",
|
|
1403
|
-
"J",
|
|
1404
|
-
"K",
|
|
1405
|
-
"L",
|
|
1406
|
-
"M",
|
|
1407
|
-
"P",
|
|
1408
|
-
"Q",
|
|
1409
|
-
"R",
|
|
1410
|
-
"S"
|
|
1411
|
-
]).default("1").optional().describe("Order type"),
|
|
1412
|
-
side: import_zod5.z.enum([
|
|
1413
|
-
"1",
|
|
1414
|
-
"2",
|
|
1415
|
-
"3",
|
|
1416
|
-
"4",
|
|
1417
|
-
"5",
|
|
1418
|
-
"6",
|
|
1419
|
-
"7",
|
|
1420
|
-
"8",
|
|
1421
|
-
"9",
|
|
1422
|
-
"A",
|
|
1423
|
-
"B",
|
|
1424
|
-
"C",
|
|
1425
|
-
"D",
|
|
1426
|
-
"E",
|
|
1427
|
-
"F",
|
|
1428
|
-
"G",
|
|
1429
|
-
"H"
|
|
1430
|
-
]).describe("Order side (1=Buy, 2=Sell)"),
|
|
1431
|
-
symbol: import_zod5.z.string().describe("Trading symbol"),
|
|
1432
|
-
timeInForce: import_zod5.z.enum(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"]).default(import_fixparser.TimeInForce.Day).optional().describe("Time in force")
|
|
1433
|
-
}),
|
|
1434
|
-
{ name: "NewOrderSingleInput" }
|
|
1435
|
-
)
|
|
303
|
+
inputSchema: newOrderSingleInputSchema
|
|
1436
304
|
},
|
|
1437
305
|
{
|
|
1438
306
|
name: "marketDataRequest",
|
|
1439
307
|
description: "Sends a request for Market Data with the given symbol",
|
|
1440
|
-
inputSchema:
|
|
1441
|
-
import_zod5.z.object({
|
|
1442
|
-
mdUpdateType: import_zod5.z.enum(["0", "1"]).default("0").optional().describe("Market data update type"),
|
|
1443
|
-
symbol: import_zod5.z.string().describe("Trading symbol"),
|
|
1444
|
-
mdReqID: import_zod5.z.string().describe("Market data request ID"),
|
|
1445
|
-
subscriptionRequestType: import_zod5.z.enum(["0", "1", "2"]).default(import_fixparser.SubscriptionRequestType.SnapshotAndUpdates).optional().describe("Subscription request type"),
|
|
1446
|
-
mdEntryType: import_zod5.z.enum([
|
|
1447
|
-
"0",
|
|
1448
|
-
"1",
|
|
1449
|
-
"2",
|
|
1450
|
-
"3",
|
|
1451
|
-
"4",
|
|
1452
|
-
"5",
|
|
1453
|
-
"6",
|
|
1454
|
-
"7",
|
|
1455
|
-
"8",
|
|
1456
|
-
"9",
|
|
1457
|
-
"A",
|
|
1458
|
-
"B",
|
|
1459
|
-
"C",
|
|
1460
|
-
"D",
|
|
1461
|
-
"E",
|
|
1462
|
-
"F",
|
|
1463
|
-
"G",
|
|
1464
|
-
"H",
|
|
1465
|
-
"J",
|
|
1466
|
-
"K",
|
|
1467
|
-
"L",
|
|
1468
|
-
"M",
|
|
1469
|
-
"N",
|
|
1470
|
-
"O",
|
|
1471
|
-
"P",
|
|
1472
|
-
"Q",
|
|
1473
|
-
"S",
|
|
1474
|
-
"R",
|
|
1475
|
-
"T",
|
|
1476
|
-
"U",
|
|
1477
|
-
"V",
|
|
1478
|
-
"W",
|
|
1479
|
-
"X",
|
|
1480
|
-
"Y",
|
|
1481
|
-
"Z",
|
|
1482
|
-
"a",
|
|
1483
|
-
"b",
|
|
1484
|
-
"c",
|
|
1485
|
-
"d",
|
|
1486
|
-
"e",
|
|
1487
|
-
"g",
|
|
1488
|
-
"h",
|
|
1489
|
-
"i",
|
|
1490
|
-
"t"
|
|
1491
|
-
]).default(import_fixparser.MDEntryType.Bid).optional().describe("Market data entry type")
|
|
1492
|
-
}),
|
|
1493
|
-
{ name: "MarketDataRequestInput" }
|
|
1494
|
-
)
|
|
308
|
+
inputSchema: marketDataRequestInputSchema
|
|
1495
309
|
}
|
|
1496
310
|
]
|
|
1497
311
|
};
|
|
@@ -1500,10 +314,8 @@ var MCPLocal = class {
|
|
|
1500
314
|
const { name, arguments: args } = request.params;
|
|
1501
315
|
switch (name) {
|
|
1502
316
|
case "parse": {
|
|
1503
|
-
const { fixString } = import_zod5.z.object({
|
|
1504
|
-
fixString: import_zod5.z.string().describe("FIX message string to parse")
|
|
1505
|
-
}).parse(args || {});
|
|
1506
317
|
try {
|
|
318
|
+
const { fixString } = validateArgs(args, parseInputSchema);
|
|
1507
319
|
const parsedMessage = this.parser?.parse(fixString);
|
|
1508
320
|
if (!parsedMessage || parsedMessage.length === 0) {
|
|
1509
321
|
return {
|
|
@@ -1515,7 +327,8 @@ var MCPLocal = class {
|
|
|
1515
327
|
content: [
|
|
1516
328
|
{
|
|
1517
329
|
type: "text",
|
|
1518
|
-
text:
|
|
330
|
+
text: `${parsedMessage[0].description}
|
|
331
|
+
${parsedMessage[0].messageTypeDescription}`
|
|
1519
332
|
}
|
|
1520
333
|
]
|
|
1521
334
|
};
|
|
@@ -1525,17 +338,15 @@ var MCPLocal = class {
|
|
|
1525
338
|
content: [
|
|
1526
339
|
{
|
|
1527
340
|
type: "text",
|
|
1528
|
-
text:
|
|
341
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
|
|
1529
342
|
}
|
|
1530
343
|
]
|
|
1531
344
|
};
|
|
1532
345
|
}
|
|
1533
346
|
}
|
|
1534
347
|
case "parseToJSON": {
|
|
1535
|
-
const { fixString } = import_zod5.z.object({
|
|
1536
|
-
fixString: import_zod5.z.string().describe("FIX message string to parse")
|
|
1537
|
-
}).parse(args || {});
|
|
1538
348
|
try {
|
|
349
|
+
const { fixString } = validateArgs(args, parseToJSONInputSchema);
|
|
1539
350
|
const parsedMessage = this.parser?.parse(fixString);
|
|
1540
351
|
if (!parsedMessage || parsedMessage.length === 0) {
|
|
1541
352
|
return {
|
|
@@ -1547,7 +358,7 @@ var MCPLocal = class {
|
|
|
1547
358
|
content: [
|
|
1548
359
|
{
|
|
1549
360
|
type: "text",
|
|
1550
|
-
text:
|
|
361
|
+
text: `${parsedMessage[0].toFIXJSON()}`
|
|
1551
362
|
}
|
|
1552
363
|
]
|
|
1553
364
|
};
|
|
@@ -1557,220 +368,340 @@ var MCPLocal = class {
|
|
|
1557
368
|
content: [
|
|
1558
369
|
{
|
|
1559
370
|
type: "text",
|
|
1560
|
-
text:
|
|
371
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
|
|
1561
372
|
}
|
|
1562
373
|
]
|
|
1563
374
|
};
|
|
1564
375
|
}
|
|
1565
376
|
}
|
|
1566
377
|
case "newOrderSingle": {
|
|
1567
|
-
|
|
1568
|
-
clOrdID
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
"4",
|
|
1605
|
-
"5",
|
|
1606
|
-
"6",
|
|
1607
|
-
"7",
|
|
1608
|
-
"8",
|
|
1609
|
-
"9",
|
|
1610
|
-
"A",
|
|
1611
|
-
"B",
|
|
1612
|
-
"C",
|
|
1613
|
-
"D",
|
|
1614
|
-
"E",
|
|
1615
|
-
"F",
|
|
1616
|
-
"G",
|
|
1617
|
-
"H"
|
|
1618
|
-
]).describe("Order side (1=Buy, 2=Sell)"),
|
|
1619
|
-
symbol: import_zod5.z.string().describe("Trading symbol"),
|
|
1620
|
-
timeInForce: import_zod5.z.enum(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"]).default(import_fixparser.TimeInForce.Day).optional().describe("Time in force")
|
|
1621
|
-
}).parse(args || {});
|
|
1622
|
-
const response = new Promise((resolve) => {
|
|
1623
|
-
this.pendingRequests.set(clOrdID, resolve);
|
|
1624
|
-
});
|
|
1625
|
-
const order = this.parser?.createMessage(
|
|
1626
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.NewOrderSingle),
|
|
1627
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
1628
|
-
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
1629
|
-
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
1630
|
-
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
1631
|
-
new import_fixparser.Field(import_fixparser.Fields.ClOrdID, clOrdID),
|
|
1632
|
-
new import_fixparser.Field(import_fixparser.Fields.Side, side),
|
|
1633
|
-
new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
|
|
1634
|
-
new import_fixparser.Field(import_fixparser.Fields.OrderQty, quantity),
|
|
1635
|
-
new import_fixparser.Field(import_fixparser.Fields.Price, price),
|
|
1636
|
-
new import_fixparser.Field(import_fixparser.Fields.OrdType, ordType),
|
|
1637
|
-
new import_fixparser.Field(import_fixparser.Fields.HandlInst, handlInst),
|
|
1638
|
-
new import_fixparser.Field(import_fixparser.Fields.TimeInForce, timeInForce),
|
|
1639
|
-
new import_fixparser.Field(import_fixparser.Fields.TransactTime, this.parser?.getTimestamp())
|
|
1640
|
-
);
|
|
1641
|
-
if (!this.parser?.connected) {
|
|
378
|
+
try {
|
|
379
|
+
const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = validateArgs(args, newOrderSingleInputSchema);
|
|
380
|
+
const response = new Promise((resolve) => {
|
|
381
|
+
this.pendingRequests.set(clOrdID, resolve);
|
|
382
|
+
});
|
|
383
|
+
const order = this.parser?.createMessage(
|
|
384
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.NewOrderSingle),
|
|
385
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
386
|
+
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
387
|
+
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
388
|
+
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
389
|
+
new import_fixparser.Field(import_fixparser.Fields.ClOrdID, clOrdID),
|
|
390
|
+
new import_fixparser.Field(import_fixparser.Fields.Side, side),
|
|
391
|
+
new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
|
|
392
|
+
new import_fixparser.Field(import_fixparser.Fields.OrderQty, quantity),
|
|
393
|
+
new import_fixparser.Field(import_fixparser.Fields.Price, price),
|
|
394
|
+
new import_fixparser.Field(import_fixparser.Fields.OrdType, ordType),
|
|
395
|
+
new import_fixparser.Field(import_fixparser.Fields.HandlInst, handlInst),
|
|
396
|
+
new import_fixparser.Field(import_fixparser.Fields.TimeInForce, timeInForce),
|
|
397
|
+
new import_fixparser.Field(import_fixparser.Fields.TransactTime, this.parser?.getTimestamp())
|
|
398
|
+
);
|
|
399
|
+
if (!this.parser?.connected) {
|
|
400
|
+
this.logger?.log({
|
|
401
|
+
level: "error",
|
|
402
|
+
message: "FIXParser (MCP): -- Not connected. Ignoring message."
|
|
403
|
+
});
|
|
404
|
+
return {
|
|
405
|
+
isError: true,
|
|
406
|
+
content: [
|
|
407
|
+
{
|
|
408
|
+
type: "text",
|
|
409
|
+
text: "Error: Not connected. Ignoring message."
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
this.parser?.send(order);
|
|
1642
415
|
this.logger?.log({
|
|
1643
|
-
level: "
|
|
1644
|
-
message:
|
|
416
|
+
level: "info",
|
|
417
|
+
message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`
|
|
1645
418
|
});
|
|
419
|
+
const fixData = await response;
|
|
420
|
+
return {
|
|
421
|
+
content: [
|
|
422
|
+
{
|
|
423
|
+
type: "text",
|
|
424
|
+
text: `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
};
|
|
428
|
+
} catch (error) {
|
|
1646
429
|
return {
|
|
1647
430
|
isError: true,
|
|
1648
431
|
content: [
|
|
1649
432
|
{
|
|
1650
433
|
type: "text",
|
|
1651
|
-
text:
|
|
434
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to create order"}`
|
|
1652
435
|
}
|
|
1653
436
|
]
|
|
1654
437
|
};
|
|
1655
438
|
}
|
|
1656
|
-
this.parser?.send(order);
|
|
1657
|
-
this.logger?.log({
|
|
1658
|
-
level: "info",
|
|
1659
|
-
message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`
|
|
1660
|
-
});
|
|
1661
|
-
const fixData = await response;
|
|
1662
|
-
return {
|
|
1663
|
-
content: [
|
|
1664
|
-
{
|
|
1665
|
-
type: "text",
|
|
1666
|
-
text: `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
1667
|
-
}
|
|
1668
|
-
]
|
|
1669
|
-
};
|
|
1670
439
|
}
|
|
1671
440
|
case "marketDataRequest": {
|
|
1672
|
-
|
|
1673
|
-
mdUpdateType
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
"Y",
|
|
1712
|
-
"Z",
|
|
1713
|
-
"a",
|
|
1714
|
-
"b",
|
|
1715
|
-
"c",
|
|
1716
|
-
"d",
|
|
1717
|
-
"e",
|
|
1718
|
-
"g",
|
|
1719
|
-
"h",
|
|
1720
|
-
"i",
|
|
1721
|
-
"t"
|
|
1722
|
-
]).default(import_fixparser.MDEntryType.Bid).optional().describe("Market data entry type")
|
|
1723
|
-
}).parse(args || {});
|
|
1724
|
-
const response = new Promise((resolve) => {
|
|
1725
|
-
this.pendingRequests.set(mdReqID, resolve);
|
|
1726
|
-
});
|
|
1727
|
-
const marketDataRequest = this.parser?.createMessage(
|
|
1728
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
1729
|
-
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
1730
|
-
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
1731
|
-
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
1732
|
-
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
1733
|
-
new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
|
|
1734
|
-
new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, mdUpdateType),
|
|
1735
|
-
new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, 1),
|
|
1736
|
-
new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
|
|
1737
|
-
new import_fixparser.Field(import_fixparser.Fields.MDReqID, mdReqID),
|
|
1738
|
-
new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, subscriptionRequestType),
|
|
1739
|
-
new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, 1),
|
|
1740
|
-
new import_fixparser.Field(import_fixparser.Fields.MDEntryType, mdEntryType)
|
|
1741
|
-
);
|
|
1742
|
-
if (!this.parser?.connected) {
|
|
441
|
+
try {
|
|
442
|
+
const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = validateArgs(
|
|
443
|
+
args,
|
|
444
|
+
marketDataRequestInputSchema
|
|
445
|
+
);
|
|
446
|
+
const response = new Promise((resolve) => {
|
|
447
|
+
this.pendingRequests.set(mdReqID, resolve);
|
|
448
|
+
});
|
|
449
|
+
const marketDataRequest = this.parser?.createMessage(
|
|
450
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
451
|
+
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
|
|
452
|
+
new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
453
|
+
new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
|
|
454
|
+
new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
|
|
455
|
+
new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
|
|
456
|
+
new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, mdUpdateType),
|
|
457
|
+
new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, 1),
|
|
458
|
+
new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
|
|
459
|
+
new import_fixparser.Field(import_fixparser.Fields.MDReqID, mdReqID),
|
|
460
|
+
new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, subscriptionRequestType),
|
|
461
|
+
new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, 1),
|
|
462
|
+
new import_fixparser.Field(import_fixparser.Fields.MDEntryType, mdEntryType)
|
|
463
|
+
);
|
|
464
|
+
if (!this.parser?.connected) {
|
|
465
|
+
this.logger?.log({
|
|
466
|
+
level: "error",
|
|
467
|
+
message: "FIXParser (MCP): -- Not connected. Ignoring message."
|
|
468
|
+
});
|
|
469
|
+
return {
|
|
470
|
+
isError: true,
|
|
471
|
+
content: [
|
|
472
|
+
{
|
|
473
|
+
type: "text",
|
|
474
|
+
text: "Error: Not connected. Ignoring message."
|
|
475
|
+
}
|
|
476
|
+
]
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
this.parser?.send(marketDataRequest);
|
|
1743
480
|
this.logger?.log({
|
|
1744
|
-
level: "
|
|
1745
|
-
message:
|
|
481
|
+
level: "info",
|
|
482
|
+
message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`
|
|
1746
483
|
});
|
|
484
|
+
const fixData = await response;
|
|
485
|
+
return {
|
|
486
|
+
content: [
|
|
487
|
+
{
|
|
488
|
+
type: "text",
|
|
489
|
+
text: `Market data for ${symbol}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
};
|
|
493
|
+
} catch (error) {
|
|
1747
494
|
return {
|
|
1748
495
|
isError: true,
|
|
1749
496
|
content: [
|
|
1750
497
|
{
|
|
1751
498
|
type: "text",
|
|
1752
|
-
text:
|
|
499
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to request market data"}`
|
|
1753
500
|
}
|
|
1754
501
|
]
|
|
1755
502
|
};
|
|
1756
503
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
504
|
+
}
|
|
505
|
+
default:
|
|
506
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
this.server.setRequestHandler(import_types.ListPromptsRequestSchema, async () => {
|
|
510
|
+
return {
|
|
511
|
+
prompts: [
|
|
512
|
+
{
|
|
513
|
+
name: "parse",
|
|
514
|
+
description: "Parses a FIX message and describes it in plain language",
|
|
515
|
+
arguments: [
|
|
516
|
+
{
|
|
517
|
+
name: "fixString",
|
|
518
|
+
description: "FIX message string to parse",
|
|
519
|
+
required: true
|
|
520
|
+
}
|
|
521
|
+
]
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
name: "parseToJSON",
|
|
525
|
+
description: "Parses a FIX message into JSON",
|
|
526
|
+
arguments: [
|
|
527
|
+
{
|
|
528
|
+
name: "fixString",
|
|
529
|
+
description: "FIX message string to parse",
|
|
530
|
+
required: true
|
|
531
|
+
}
|
|
532
|
+
]
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
name: "newOrderSingle",
|
|
536
|
+
description: "Creates and sends a New Order Single",
|
|
537
|
+
arguments: [
|
|
538
|
+
{
|
|
539
|
+
name: "clOrdID",
|
|
540
|
+
description: "Client Order ID",
|
|
541
|
+
required: true
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
name: "handlInst",
|
|
545
|
+
description: "Handling instruction",
|
|
546
|
+
required: false
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
name: "quantity",
|
|
550
|
+
description: "Order quantity",
|
|
551
|
+
required: true
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
name: "price",
|
|
555
|
+
description: "Order price",
|
|
556
|
+
required: true
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
name: "ordType",
|
|
560
|
+
description: "Order type",
|
|
561
|
+
required: false
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
name: "side",
|
|
565
|
+
description: "Order side (1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed)",
|
|
566
|
+
required: true
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
name: "symbol",
|
|
570
|
+
description: "Trading symbol",
|
|
571
|
+
required: true
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
name: "timeInForce",
|
|
575
|
+
description: "Time in force",
|
|
576
|
+
required: false
|
|
577
|
+
}
|
|
578
|
+
]
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
name: "marketDataRequest",
|
|
582
|
+
description: "Sends a request for Market Data with the given symbol",
|
|
583
|
+
arguments: [
|
|
584
|
+
{
|
|
585
|
+
name: "mdUpdateType",
|
|
586
|
+
description: "Market data update type",
|
|
587
|
+
required: false
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
name: "symbol",
|
|
591
|
+
description: "Trading symbol",
|
|
592
|
+
required: true
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
name: "mdReqID",
|
|
596
|
+
description: "Market data request ID",
|
|
597
|
+
required: true
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
name: "subscriptionRequestType",
|
|
601
|
+
description: "Subscription request type",
|
|
602
|
+
required: false
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
name: "mdEntryType",
|
|
606
|
+
description: "Market data entry type",
|
|
607
|
+
required: false
|
|
608
|
+
}
|
|
609
|
+
]
|
|
610
|
+
}
|
|
611
|
+
]
|
|
612
|
+
};
|
|
613
|
+
});
|
|
614
|
+
this.server.setRequestHandler(import_types.GetPromptRequestSchema, async (request) => {
|
|
615
|
+
const { name, arguments: args } = request.params;
|
|
616
|
+
switch (name) {
|
|
617
|
+
case "parse": {
|
|
618
|
+
const fixString = args?.fixString || "";
|
|
619
|
+
return {
|
|
620
|
+
messages: [
|
|
621
|
+
{
|
|
622
|
+
role: "user",
|
|
623
|
+
content: {
|
|
624
|
+
type: "text",
|
|
625
|
+
text: `Please parse and explain this FIX message: ${fixString}`
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
]
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
case "parseToJSON": {
|
|
632
|
+
const fixString = args?.fixString || "";
|
|
633
|
+
return {
|
|
634
|
+
messages: [
|
|
635
|
+
{
|
|
636
|
+
role: "user",
|
|
637
|
+
content: {
|
|
638
|
+
type: "text",
|
|
639
|
+
text: `Please parse the FIX message to JSON: ${fixString}`
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
]
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
case "newOrderSingle": {
|
|
646
|
+
const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};
|
|
647
|
+
return {
|
|
648
|
+
messages: [
|
|
649
|
+
{
|
|
650
|
+
role: "user",
|
|
651
|
+
content: {
|
|
652
|
+
type: "text",
|
|
653
|
+
text: [
|
|
654
|
+
"Create a New Order Single FIX message with the following parameters:",
|
|
655
|
+
`- ClOrdID: ${clOrdID}`,
|
|
656
|
+
`- HandlInst: ${handlInst ?? "3"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Manual, '2' for Automated, '3' for AutomatedNoIntervention)`,
|
|
657
|
+
`- Quantity: ${quantity}`,
|
|
658
|
+
`- Price: ${price}`,
|
|
659
|
+
`- OrdType: ${ordType ?? "1"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,
|
|
660
|
+
`- Side: ${side} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,
|
|
661
|
+
`- Symbol: ${symbol}`,
|
|
662
|
+
`- TimeInForce: ${timeInForce ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Day, '1' for Good Till Cancel, '2' for At Opening, '3' for Immediate or Cancel, '4' for Fill or Kill, '5' for Good Till Crossing, '6' for Good Till Date)`,
|
|
663
|
+
"",
|
|
664
|
+
"Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.",
|
|
665
|
+
"",
|
|
666
|
+
'Note: For the Side parameter, always use the numeric/alphabetic value (e.g., "1" for Buy, "2" for Sell) as defined in the FIX protocol, not the descriptive name.',
|
|
667
|
+
'Note: For the HandlInst parameter, always use the numeric/alphabetic value (e.g., "1" for Manual, "2" for Automated, "3" for AutomatedNoIntervention) as defined in the FIX protocol, not the descriptive name.',
|
|
668
|
+
'Note: For the OrdType parameter, always use the numeric/alphabetic value (e.g., "1" for Market, "2" for Limit, "3" for Stop) as defined in the FIX protocol, not the descriptive name.',
|
|
669
|
+
'Note: For the TimeInForce parameter, always use the numeric/alphabetic value (e.g., "0" for Day, "1" for Good Till Cancel, "2" for At Opening) as defined in the FIX protocol, not the descriptive name.'
|
|
670
|
+
].join("\n")
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
]
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
case "marketDataRequest": {
|
|
677
|
+
const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = args || {};
|
|
1763
678
|
return {
|
|
1764
|
-
|
|
679
|
+
messages: [
|
|
1765
680
|
{
|
|
1766
|
-
|
|
1767
|
-
|
|
681
|
+
role: "user",
|
|
682
|
+
content: {
|
|
683
|
+
type: "text",
|
|
684
|
+
text: [
|
|
685
|
+
"Create a Market Data Request FIX message with the following parameters:",
|
|
686
|
+
`- MDUpdateType: ${mdUpdateType ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,
|
|
687
|
+
`- Symbol: ${symbol}`,
|
|
688
|
+
`- MDReqID: ${mdReqID}`,
|
|
689
|
+
`- SubscriptionRequestType: ${subscriptionRequestType ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Snapshot + Updates, '1' for Snapshot, '2' for Unsubscribe)`,
|
|
690
|
+
`- MDEntryType: ${mdEntryType ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Bid, '1' for Offer, '2' for Trade, '3' for Index Value, '4' for Opening Price)`,
|
|
691
|
+
"",
|
|
692
|
+
"Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.",
|
|
693
|
+
"",
|
|
694
|
+
'Note: For the MDUpdateType parameter, always use the numeric/alphabetic value (e.g., "0" for FullRefresh, "1" for IncrementalRefresh) as defined in the FIX protocol, not the descriptive name.',
|
|
695
|
+
'Note: For the SubscriptionRequestType parameter, always use the numeric/alphabetic value (e.g., "0" for Snapshot + Updates, "1" for Snapshot, "2" for Unsubscribe) as defined in the FIX protocol, not the descriptive name.',
|
|
696
|
+
'Note: For the MDEntryType parameter, always use the numeric/alphabetic value (e.g., "0" for Bid, "1" for Offer, "2" for Trade, "3" for Index Value, "4" for Opening Price) as defined in the FIX protocol, not the descriptive name.'
|
|
697
|
+
].join("\n")
|
|
698
|
+
}
|
|
1768
699
|
}
|
|
1769
700
|
]
|
|
1770
701
|
};
|
|
1771
702
|
}
|
|
1772
703
|
default:
|
|
1773
|
-
throw new Error(`Unknown
|
|
704
|
+
throw new Error(`Unknown prompt: ${name}`);
|
|
1774
705
|
}
|
|
1775
706
|
});
|
|
1776
707
|
process.on("SIGINT", async () => {
|