langgraph-api 0.1.23__py3-none-any.whl → 0.2.1__py3-none-any.whl
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.
Potentially problematic release.
This version of langgraph-api might be problematic. Click here for more details.
- langgraph_api/__init__.py +1 -1
- langgraph_api/api/mcp.py +29 -9
- langgraph_api/js/.prettierrc +1 -1
- langgraph_api/js/src/graph.mts +6 -6
- langgraph_api/js/src/parser/parser.worker.mjs +1 -1
- langgraph_api/js/src/parser/schema/types.mts +60 -60
- langgraph_api/js/src/utils/serde.mts +1 -1
- langgraph_api/js/tests/auth.test.mts +51 -51
- langgraph_api/js/tests/graphs/agent.mts +6 -6
- langgraph_api/js/tests/graphs/auth.mts +1 -1
- langgraph_api/js/tests/graphs/command.mts +1 -1
- langgraph_api/js/tests/graphs/delay.mts +1 -1
- langgraph_api/js/tests/graphs/nested.mts +3 -3
- langgraph_api/js/tests/graphs/weather.mts +1 -1
- langgraph_api/js/tests/utils.mts +2 -2
- langgraph_api/models/run.py +1 -0
- {langgraph_api-0.1.23.dist-info → langgraph_api-0.2.1.dist-info}/METADATA +2 -2
- {langgraph_api-0.1.23.dist-info → langgraph_api-0.2.1.dist-info}/RECORD +22 -22
- openapi.json +12 -0
- {langgraph_api-0.1.23.dist-info → langgraph_api-0.2.1.dist-info}/LICENSE +0 -0
- {langgraph_api-0.1.23.dist-info → langgraph_api-0.2.1.dist-info}/WHEEL +0 -0
- {langgraph_api-0.1.23.dist-info → langgraph_api-0.2.1.dist-info}/entry_points.txt +0 -0
langgraph_api/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1
|
|
1
|
+
__version__ = "0.2.1"
|
langgraph_api/api/mcp.py
CHANGED
|
@@ -91,6 +91,13 @@ ERROR_CODE_INVALID_PARAMS = -32602
|
|
|
91
91
|
ERROR_CODE_METHOD_NOT_FOUND = -32601
|
|
92
92
|
|
|
93
93
|
|
|
94
|
+
def _get_version() -> str:
|
|
95
|
+
"""Get langgraph-api version."""
|
|
96
|
+
from langgraph_api import __version__
|
|
97
|
+
|
|
98
|
+
return __version__
|
|
99
|
+
|
|
100
|
+
|
|
94
101
|
async def handle_mcp_endpoint(request: ApiRequest) -> Response:
|
|
95
102
|
"""MCP endpoint handler the implements the Streamable HTTP protocol.
|
|
96
103
|
|
|
@@ -183,10 +190,11 @@ async def handle_post_request(request: ApiRequest) -> Response:
|
|
|
183
190
|
"Invalid JSON-RPC message. Missing or invalid jsonrpc version.", 400
|
|
184
191
|
)
|
|
185
192
|
|
|
186
|
-
|
|
193
|
+
# Careful ID checks as the integer 0 is a valid ID
|
|
194
|
+
if id_ is not None and method:
|
|
187
195
|
# JSON-RPC request
|
|
188
196
|
return await handle_jsonrpc_request(request, cast(JsonRpcRequest, message))
|
|
189
|
-
elif id_:
|
|
197
|
+
elif id_ is not None:
|
|
190
198
|
# JSON-RPC response
|
|
191
199
|
return handle_jsonrpc_response(cast(JsonRpcResponse, message))
|
|
192
200
|
elif method:
|
|
@@ -292,14 +300,18 @@ def handle_initialize_request(message: JsonRpcRequest) -> dict[str, Any]:
|
|
|
292
300
|
"""
|
|
293
301
|
return {
|
|
294
302
|
"result": {
|
|
295
|
-
#
|
|
303
|
+
# Official type-script SDK client only works with
|
|
304
|
+
# protocol version 2024-11-05 currently.
|
|
305
|
+
# The protocol is versioning the messages schema and not the transport.
|
|
306
|
+
# https://modelcontextprotocol.io/specification/2025-03-26/basic/lifecycle#lifecycle-phases
|
|
307
|
+
"protocolVersion": "2024-11-05",
|
|
296
308
|
"capabilities": {
|
|
297
309
|
"tools": {
|
|
298
|
-
# We do not support subscriptions currently
|
|
299
310
|
"listChanged": False,
|
|
300
|
-
}
|
|
311
|
+
}
|
|
301
312
|
},
|
|
302
|
-
|
|
313
|
+
"serverInfo": {"name": "LangGraph", "version": _get_version()},
|
|
314
|
+
}
|
|
303
315
|
}
|
|
304
316
|
|
|
305
317
|
|
|
@@ -380,7 +392,15 @@ async def handle_tools_list(
|
|
|
380
392
|
"description": "",
|
|
381
393
|
},
|
|
382
394
|
)
|
|
383
|
-
|
|
395
|
+
|
|
396
|
+
result = {"tools": tools}
|
|
397
|
+
|
|
398
|
+
if next_cursor is not None:
|
|
399
|
+
result["nextCursor"] = next_cursor
|
|
400
|
+
|
|
401
|
+
return {
|
|
402
|
+
"result": result,
|
|
403
|
+
}
|
|
384
404
|
|
|
385
405
|
|
|
386
406
|
async def handle_tools_call(
|
|
@@ -454,7 +474,7 @@ async def handle_tools_call(
|
|
|
454
474
|
"result": {
|
|
455
475
|
"isError": True,
|
|
456
476
|
"content": [
|
|
457
|
-
{"type": "text", "
|
|
477
|
+
{"type": "text", "text": value["__error__"]["error"]},
|
|
458
478
|
],
|
|
459
479
|
}
|
|
460
480
|
}
|
|
@@ -463,7 +483,7 @@ async def handle_tools_call(
|
|
|
463
483
|
return {
|
|
464
484
|
"result": {
|
|
465
485
|
"content": [
|
|
466
|
-
{"type": "text", "
|
|
486
|
+
{"type": "text", "text": repr(value)},
|
|
467
487
|
]
|
|
468
488
|
}
|
|
469
489
|
}
|
langgraph_api/js/.prettierrc
CHANGED
langgraph_api/js/src/graph.mts
CHANGED
|
@@ -23,7 +23,7 @@ export type CompiledGraphFactory<T extends string> = (config: {
|
|
|
23
23
|
|
|
24
24
|
export async function resolveGraph(
|
|
25
25
|
spec: string,
|
|
26
|
-
options?: { onlyFilePresence?: false }
|
|
26
|
+
options?: { onlyFilePresence?: false },
|
|
27
27
|
): Promise<{
|
|
28
28
|
sourceFile: string;
|
|
29
29
|
exportSymbol: string;
|
|
@@ -32,12 +32,12 @@ export async function resolveGraph(
|
|
|
32
32
|
|
|
33
33
|
export async function resolveGraph(
|
|
34
34
|
spec: string,
|
|
35
|
-
options: { onlyFilePresence: true }
|
|
35
|
+
options: { onlyFilePresence: true },
|
|
36
36
|
): Promise<{ sourceFile: string; exportSymbol: string; resolved: undefined }>;
|
|
37
37
|
|
|
38
38
|
export async function resolveGraph(
|
|
39
39
|
spec: string,
|
|
40
|
-
options?: { onlyFilePresence?: boolean }
|
|
40
|
+
options?: { onlyFilePresence?: boolean },
|
|
41
41
|
) {
|
|
42
42
|
const [userFile, exportSymbol] = spec.split(":", 2);
|
|
43
43
|
|
|
@@ -64,7 +64,7 @@ export async function resolveGraph(
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
const graph: GraphUnknown = await import(sourceFile).then(
|
|
67
|
-
(module) => module[exportSymbol || "default"]
|
|
67
|
+
(module) => module[exportSymbol || "default"],
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
// obtain the graph, and if not compiled, compile it
|
|
@@ -92,11 +92,11 @@ export async function resolveGraph(
|
|
|
92
92
|
|
|
93
93
|
export async function runGraphSchemaWorker(
|
|
94
94
|
spec: GraphSpec,
|
|
95
|
-
options?: { timeoutMs?: number }
|
|
95
|
+
options?: { timeoutMs?: number },
|
|
96
96
|
) {
|
|
97
97
|
return await new Promise<Record<string, GraphSchema>>((resolve, reject) => {
|
|
98
98
|
const worker = new Worker(
|
|
99
|
-
new URL("./parser/parser.worker.mjs", import.meta.url).pathname
|
|
99
|
+
new URL("./parser/parser.worker.mjs", import.meta.url).pathname,
|
|
100
100
|
);
|
|
101
101
|
|
|
102
102
|
// Set a timeout to reject if the worker takes too long
|
|
@@ -240,7 +240,7 @@ function resolveRequiredFile(
|
|
|
240
240
|
symbol: ts.Symbol,
|
|
241
241
|
key: string,
|
|
242
242
|
fileName: string,
|
|
243
|
-
objectName: string
|
|
243
|
+
objectName: string,
|
|
244
244
|
): any {
|
|
245
245
|
const sourceFile = getSourceFile(symbol);
|
|
246
246
|
const requiredFilePath = /^[.\/]+/.test(fileName)
|
|
@@ -404,7 +404,7 @@ function getCanonicalDeclaration(sym: ts.Symbol): ts.Declaration {
|
|
|
404
404
|
|
|
405
405
|
const declarationCount = sym.declarations?.length ?? 0;
|
|
406
406
|
throw new Error(
|
|
407
|
-
`Symbol "${sym.name}" has no valueDeclaration and ${declarationCount} declarations
|
|
407
|
+
`Symbol "${sym.name}" has no valueDeclaration and ${declarationCount} declarations.`,
|
|
408
408
|
);
|
|
409
409
|
}
|
|
410
410
|
|
|
@@ -418,7 +418,7 @@ function getSourceFile(sym: ts.Symbol): ts.SourceFile {
|
|
|
418
418
|
while (currentDecl.kind !== ts.SyntaxKind.SourceFile) {
|
|
419
419
|
if (currentDecl.parent === undefined) {
|
|
420
420
|
throw new Error(
|
|
421
|
-
`Unable to locate source file for declaration "${sym.name}"
|
|
421
|
+
`Unable to locate source file for declaration "${sym.name}".`,
|
|
422
422
|
);
|
|
423
423
|
}
|
|
424
424
|
currentDecl = currentDecl.parent;
|
|
@@ -561,7 +561,7 @@ class JsonSchemaGenerator {
|
|
|
561
561
|
userSymbols: { [name: string]: ts.Symbol },
|
|
562
562
|
inheritingTypes: { [baseName: string]: string[] },
|
|
563
563
|
tc: ts.TypeChecker,
|
|
564
|
-
private args = getDefaultArgs()
|
|
564
|
+
private args = getDefaultArgs(),
|
|
565
565
|
) {
|
|
566
566
|
this.symbols = symbols;
|
|
567
567
|
this.allSymbols = allSymbols;
|
|
@@ -570,7 +570,7 @@ class JsonSchemaGenerator {
|
|
|
570
570
|
this.tc = tc;
|
|
571
571
|
this.userValidationKeywords = args.validationKeywords.reduce(
|
|
572
572
|
(acc, word) => ({ ...acc, [word]: true }),
|
|
573
|
-
{}
|
|
573
|
+
{},
|
|
574
574
|
);
|
|
575
575
|
this.constAsEnum = args.constAsEnum;
|
|
576
576
|
}
|
|
@@ -606,7 +606,7 @@ class JsonSchemaGenerator {
|
|
|
606
606
|
private parseCommentsIntoDefinition(
|
|
607
607
|
symbol: ts.Symbol,
|
|
608
608
|
definition: Definition,
|
|
609
|
-
otherAnnotations: Record<string, true
|
|
609
|
+
otherAnnotations: Record<string, true>,
|
|
610
610
|
): void {
|
|
611
611
|
if (!symbol) {
|
|
612
612
|
return;
|
|
@@ -621,7 +621,7 @@ class JsonSchemaGenerator {
|
|
|
621
621
|
.map((comment) => {
|
|
622
622
|
const newlineNormalizedComment = comment.text.replace(
|
|
623
623
|
/\r\n/g,
|
|
624
|
-
"\n"
|
|
624
|
+
"\n",
|
|
625
625
|
);
|
|
626
626
|
|
|
627
627
|
// If a comment contains a "{@link XYZ}" inline tag that could not be
|
|
@@ -657,7 +657,7 @@ class JsonSchemaGenerator {
|
|
|
657
657
|
}
|
|
658
658
|
} else if (name === "TJS" && text.startsWith("-")) {
|
|
659
659
|
let match: string[] | RegExpExecArray | null = new RegExp(
|
|
660
|
-
REGEX_TJS_JSDOC
|
|
660
|
+
REGEX_TJS_JSDOC,
|
|
661
661
|
).exec(originalText);
|
|
662
662
|
if (match) {
|
|
663
663
|
name = match[1];
|
|
@@ -673,7 +673,7 @@ class JsonSchemaGenerator {
|
|
|
673
673
|
// to process the "." and beyond from the value
|
|
674
674
|
if (subDefinitions[name]) {
|
|
675
675
|
const match: string[] | RegExpExecArray | null = new RegExp(
|
|
676
|
-
REGEX_GROUP_JSDOC
|
|
676
|
+
REGEX_GROUP_JSDOC,
|
|
677
677
|
).exec(text);
|
|
678
678
|
if (match) {
|
|
679
679
|
const k = match[1];
|
|
@@ -716,7 +716,7 @@ class JsonSchemaGenerator {
|
|
|
716
716
|
reffedType: ts.Symbol,
|
|
717
717
|
definition: Definition,
|
|
718
718
|
defaultNumberType = this.args.defaultNumberType,
|
|
719
|
-
ignoreUndefined = false
|
|
719
|
+
ignoreUndefined = false,
|
|
720
720
|
): Definition {
|
|
721
721
|
const tupleType = resolveTupleType(propertyType);
|
|
722
722
|
|
|
@@ -725,7 +725,7 @@ class JsonSchemaGenerator {
|
|
|
725
725
|
const elemTypes: ts.NodeArray<ts.TypeNode> = (propertyType as any)
|
|
726
726
|
.typeArguments;
|
|
727
727
|
const fixedTypes = elemTypes.map((elType) =>
|
|
728
|
-
this.getTypeDefinition(elType as any)
|
|
728
|
+
this.getTypeDefinition(elType as any),
|
|
729
729
|
);
|
|
730
730
|
definition.type = "array";
|
|
731
731
|
if (fixedTypes.length > 0) {
|
|
@@ -743,12 +743,12 @@ class JsonSchemaGenerator {
|
|
|
743
743
|
const propertyTypeString = this.tc.typeToString(
|
|
744
744
|
propertyType,
|
|
745
745
|
undefined,
|
|
746
|
-
ts.TypeFormatFlags.UseFullyQualifiedType
|
|
746
|
+
ts.TypeFormatFlags.UseFullyQualifiedType,
|
|
747
747
|
);
|
|
748
748
|
const flags = propertyType.flags;
|
|
749
749
|
const arrayType = this.tc.getIndexTypeOfType(
|
|
750
750
|
propertyType,
|
|
751
|
-
ts.IndexKind.Number
|
|
751
|
+
ts.IndexKind.Number,
|
|
752
752
|
);
|
|
753
753
|
|
|
754
754
|
if (flags & ts.TypeFlags.String) {
|
|
@@ -826,7 +826,7 @@ class JsonSchemaGenerator {
|
|
|
826
826
|
};
|
|
827
827
|
if (
|
|
828
828
|
!!Array.from((propertyType as any).members as any[])?.find(
|
|
829
|
-
(member: [string]) => member[0] !== "__index"
|
|
829
|
+
(member: [string]) => member[0] !== "__index",
|
|
830
830
|
)
|
|
831
831
|
) {
|
|
832
832
|
this.getClassDefinition(propertyType, definition);
|
|
@@ -879,7 +879,7 @@ class JsonSchemaGenerator {
|
|
|
879
879
|
} else {
|
|
880
880
|
// Report that type could not be processed
|
|
881
881
|
const error = new TypeError(
|
|
882
|
-
"Unsupported type: " + propertyTypeString
|
|
882
|
+
"Unsupported type: " + propertyTypeString,
|
|
883
883
|
);
|
|
884
884
|
(error as any).type = propertyType;
|
|
885
885
|
throw error;
|
|
@@ -908,7 +908,7 @@ class JsonSchemaGenerator {
|
|
|
908
908
|
|
|
909
909
|
private getDefinitionForProperty(
|
|
910
910
|
prop: ts.Symbol,
|
|
911
|
-
node: ts.Node
|
|
911
|
+
node: ts.Node,
|
|
912
912
|
): Definition | null {
|
|
913
913
|
if (prop.flags & ts.SymbolFlags.Method) {
|
|
914
914
|
return null;
|
|
@@ -923,7 +923,7 @@ class JsonSchemaGenerator {
|
|
|
923
923
|
undefined,
|
|
924
924
|
undefined,
|
|
925
925
|
prop,
|
|
926
|
-
reffedType
|
|
926
|
+
reffedType,
|
|
927
927
|
);
|
|
928
928
|
|
|
929
929
|
if (this.args.titles) {
|
|
@@ -967,12 +967,12 @@ class JsonSchemaGenerator {
|
|
|
967
967
|
definition.default = val;
|
|
968
968
|
} else if (val) {
|
|
969
969
|
console.warn(
|
|
970
|
-
"unknown initializer for property " + propertyName + ": " + val
|
|
970
|
+
"unknown initializer for property " + propertyName + ": " + val,
|
|
971
971
|
);
|
|
972
972
|
}
|
|
973
973
|
} catch (e) {
|
|
974
974
|
console.warn(
|
|
975
|
-
"exception evaluating initializer for property " + propertyName
|
|
975
|
+
"exception evaluating initializer for property " + propertyName,
|
|
976
976
|
);
|
|
977
977
|
}
|
|
978
978
|
}
|
|
@@ -983,13 +983,13 @@ class JsonSchemaGenerator {
|
|
|
983
983
|
|
|
984
984
|
private getEnumDefinition(
|
|
985
985
|
clazzType: ts.Type,
|
|
986
|
-
definition: Definition
|
|
986
|
+
definition: Definition,
|
|
987
987
|
): Definition {
|
|
988
988
|
const node = clazzType.getSymbol()!.getDeclarations()![0];
|
|
989
989
|
const fullName = this.tc.typeToString(
|
|
990
990
|
clazzType,
|
|
991
991
|
undefined,
|
|
992
|
-
ts.TypeFormatFlags.UseFullyQualifiedType
|
|
992
|
+
ts.TypeFormatFlags.UseFullyQualifiedType,
|
|
993
993
|
);
|
|
994
994
|
const members: ts.NodeArray<ts.EnumMember> =
|
|
995
995
|
node.kind === ts.SyntaxKind.EnumDeclaration
|
|
@@ -1034,7 +1034,7 @@ class JsonSchemaGenerator {
|
|
|
1034
1034
|
"initializer is expression for enum: " +
|
|
1035
1035
|
fullName +
|
|
1036
1036
|
"." +
|
|
1037
|
-
caseLabel
|
|
1037
|
+
caseLabel,
|
|
1038
1038
|
);
|
|
1039
1039
|
}
|
|
1040
1040
|
} else if (
|
|
@@ -1068,7 +1068,7 @@ class JsonSchemaGenerator {
|
|
|
1068
1068
|
private getUnionDefinition(
|
|
1069
1069
|
unionType: ts.UnionType,
|
|
1070
1070
|
unionModifier: keyof Definition,
|
|
1071
|
-
definition: Definition
|
|
1071
|
+
definition: Definition,
|
|
1072
1072
|
): Definition {
|
|
1073
1073
|
const enumValues: PrimitiveType[] = [];
|
|
1074
1074
|
const simpleTypes: JSONSchema7TypeName[] = [];
|
|
@@ -1100,7 +1100,7 @@ class JsonSchemaGenerator {
|
|
|
1100
1100
|
symbol,
|
|
1101
1101
|
undefined,
|
|
1102
1102
|
undefined,
|
|
1103
|
-
true
|
|
1103
|
+
true,
|
|
1104
1104
|
);
|
|
1105
1105
|
if (def.type === ("undefined" as any)) {
|
|
1106
1106
|
continue;
|
|
@@ -1184,7 +1184,7 @@ class JsonSchemaGenerator {
|
|
|
1184
1184
|
|
|
1185
1185
|
private getIntersectionDefinition(
|
|
1186
1186
|
intersectionType: ts.IntersectionType,
|
|
1187
|
-
definition: Definition
|
|
1187
|
+
definition: Definition,
|
|
1188
1188
|
): Definition {
|
|
1189
1189
|
const simpleTypes: JSONSchema7TypeName[] = [];
|
|
1190
1190
|
const schemas: Definition[] = [];
|
|
@@ -1230,7 +1230,7 @@ class JsonSchemaGenerator {
|
|
|
1230
1230
|
|
|
1231
1231
|
private getClassDefinition(
|
|
1232
1232
|
clazzType: ts.Type,
|
|
1233
|
-
definition: Definition
|
|
1233
|
+
definition: Definition,
|
|
1234
1234
|
): Definition {
|
|
1235
1235
|
const node = clazzType.getSymbol()!.getDeclarations()![0];
|
|
1236
1236
|
|
|
@@ -1277,7 +1277,7 @@ class JsonSchemaGenerator {
|
|
|
1277
1277
|
const fullName = this.tc.typeToString(
|
|
1278
1278
|
clazzType,
|
|
1279
1279
|
undefined,
|
|
1280
|
-
ts.TypeFormatFlags.UseFullyQualifiedType
|
|
1280
|
+
ts.TypeFormatFlags.UseFullyQualifiedType,
|
|
1281
1281
|
);
|
|
1282
1282
|
|
|
1283
1283
|
const modifierFlags = ts.getCombinedModifierFlags(node);
|
|
@@ -1297,7 +1297,7 @@ class JsonSchemaGenerator {
|
|
|
1297
1297
|
clazz.members == null
|
|
1298
1298
|
? []
|
|
1299
1299
|
: clazz.members.filter(
|
|
1300
|
-
(x) => x.kind === ts.SyntaxKind.IndexSignature
|
|
1300
|
+
(x) => x.kind === ts.SyntaxKind.IndexSignature,
|
|
1301
1301
|
);
|
|
1302
1302
|
if (indexSignatures.length === 1) {
|
|
1303
1303
|
// for case "array-types"
|
|
@@ -1305,21 +1305,21 @@ class JsonSchemaGenerator {
|
|
|
1305
1305
|
indexSignatures[0] as ts.IndexSignatureDeclaration;
|
|
1306
1306
|
if (indexSignature.parameters.length !== 1) {
|
|
1307
1307
|
throw new Error(
|
|
1308
|
-
"Not supported: IndexSignatureDeclaration parameters.length != 1"
|
|
1308
|
+
"Not supported: IndexSignatureDeclaration parameters.length != 1",
|
|
1309
1309
|
);
|
|
1310
1310
|
}
|
|
1311
1311
|
const indexSymbol: ts.Symbol = (indexSignature.parameters[0] as any)
|
|
1312
1312
|
.symbol;
|
|
1313
1313
|
const indexType = this.tc.getTypeOfSymbolAtLocation(
|
|
1314
1314
|
indexSymbol,
|
|
1315
|
-
node
|
|
1315
|
+
node,
|
|
1316
1316
|
);
|
|
1317
1317
|
const isIndexedObject =
|
|
1318
1318
|
indexType.flags === ts.TypeFlags.String ||
|
|
1319
1319
|
indexType.flags === ts.TypeFlags.Number;
|
|
1320
1320
|
if (indexType.flags !== ts.TypeFlags.Number && !isIndexedObject) {
|
|
1321
1321
|
throw new Error(
|
|
1322
|
-
"Not supported: IndexSignatureDeclaration with index symbol other than a number or a string"
|
|
1322
|
+
"Not supported: IndexSignatureDeclaration with index symbol other than a number or a string",
|
|
1323
1323
|
);
|
|
1324
1324
|
}
|
|
1325
1325
|
|
|
@@ -1327,7 +1327,7 @@ class JsonSchemaGenerator {
|
|
|
1327
1327
|
let def: Definition | undefined;
|
|
1328
1328
|
if (typ.flags & ts.TypeFlags.IndexedAccess) {
|
|
1329
1329
|
const targetName = ts.escapeLeadingUnderscores(
|
|
1330
|
-
(clazzType as any).mapper?.target?.value
|
|
1330
|
+
(clazzType as any).mapper?.target?.value,
|
|
1331
1331
|
);
|
|
1332
1332
|
const indexedAccessType = typ as ts.IndexedAccessType;
|
|
1333
1333
|
const symbols: Map<ts.__String, ts.Symbol> = (
|
|
@@ -1339,7 +1339,7 @@ class JsonSchemaGenerator {
|
|
|
1339
1339
|
const targetNode = targetSymbol.getDeclarations()![0];
|
|
1340
1340
|
const targetDef = this.getDefinitionForProperty(
|
|
1341
1341
|
targetSymbol,
|
|
1342
|
-
targetNode
|
|
1342
|
+
targetNode,
|
|
1343
1343
|
);
|
|
1344
1344
|
if (targetDef) {
|
|
1345
1345
|
def = targetDef;
|
|
@@ -1372,7 +1372,7 @@ class JsonSchemaGenerator {
|
|
|
1372
1372
|
}
|
|
1373
1373
|
return all;
|
|
1374
1374
|
},
|
|
1375
|
-
{}
|
|
1375
|
+
{},
|
|
1376
1376
|
);
|
|
1377
1377
|
|
|
1378
1378
|
if (definition.type === undefined) {
|
|
@@ -1403,7 +1403,7 @@ class JsonSchemaGenerator {
|
|
|
1403
1403
|
order.push(prop.getName());
|
|
1404
1404
|
return order;
|
|
1405
1405
|
},
|
|
1406
|
-
[]
|
|
1406
|
+
[],
|
|
1407
1407
|
);
|
|
1408
1408
|
|
|
1409
1409
|
definition.propertyOrder = propertyOrder;
|
|
@@ -1427,7 +1427,7 @@ class JsonSchemaGenerator {
|
|
|
1427
1427
|
}
|
|
1428
1428
|
return required;
|
|
1429
1429
|
},
|
|
1430
|
-
[]
|
|
1430
|
+
[],
|
|
1431
1431
|
);
|
|
1432
1432
|
|
|
1433
1433
|
if (requiredProps.length > 0) {
|
|
@@ -1454,9 +1454,9 @@ class JsonSchemaGenerator {
|
|
|
1454
1454
|
typ,
|
|
1455
1455
|
undefined,
|
|
1456
1456
|
ts.TypeFormatFlags.NoTruncation |
|
|
1457
|
-
ts.TypeFormatFlags.UseFullyQualifiedType
|
|
1457
|
+
ts.TypeFormatFlags.UseFullyQualifiedType,
|
|
1458
1458
|
)
|
|
1459
|
-
.replace(REGEX_FILE_NAME_OR_SPACE, "")
|
|
1459
|
+
.replace(REGEX_FILE_NAME_OR_SPACE, ""),
|
|
1460
1460
|
);
|
|
1461
1461
|
}
|
|
1462
1462
|
|
|
@@ -1489,7 +1489,7 @@ class JsonSchemaGenerator {
|
|
|
1489
1489
|
reffedType?: ts.Symbol,
|
|
1490
1490
|
pairedSymbol?: ts.Symbol,
|
|
1491
1491
|
forceNotRef: boolean = false,
|
|
1492
|
-
ignoreUndefined = false
|
|
1492
|
+
ignoreUndefined = false,
|
|
1493
1493
|
): Definition {
|
|
1494
1494
|
const definition: Definition = {}; // real definition
|
|
1495
1495
|
|
|
@@ -1574,7 +1574,7 @@ class JsonSchemaGenerator {
|
|
|
1574
1574
|
.getFullyQualifiedName(
|
|
1575
1575
|
reffedType!.getFlags() & ts.SymbolFlags.Alias
|
|
1576
1576
|
? this.tc.getAliasedSymbol(reffedType!)
|
|
1577
|
-
: reffedType
|
|
1577
|
+
: reffedType!,
|
|
1578
1578
|
)
|
|
1579
1579
|
.replace(REGEX_FILE_NAME_OR_SPACE, "");
|
|
1580
1580
|
if (this.args.uniqueNames && reffedType) {
|
|
@@ -1582,7 +1582,7 @@ class JsonSchemaGenerator {
|
|
|
1582
1582
|
const relativePath = path.relative(process.cwd(), sourceFile.fileName);
|
|
1583
1583
|
fullTypeName = `${typeName}.${generateHashOfNode(
|
|
1584
1584
|
getCanonicalDeclaration(reffedType!),
|
|
1585
|
-
relativePath
|
|
1585
|
+
relativePath,
|
|
1586
1586
|
)}`;
|
|
1587
1587
|
} else {
|
|
1588
1588
|
fullTypeName = this.makeTypeNameUnique(typ, typeName);
|
|
@@ -1595,7 +1595,7 @@ class JsonSchemaGenerator {
|
|
|
1595
1595
|
const relativePath = path.relative(process.cwd(), sourceFile.fileName);
|
|
1596
1596
|
fullTypeName = `${this.getTypeName(typ)}.${generateHashOfNode(
|
|
1597
1597
|
getCanonicalDeclaration(sym),
|
|
1598
|
-
relativePath
|
|
1598
|
+
relativePath,
|
|
1599
1599
|
)}`;
|
|
1600
1600
|
} else if (
|
|
1601
1601
|
reffedType &&
|
|
@@ -1631,20 +1631,20 @@ class JsonSchemaGenerator {
|
|
|
1631
1631
|
this.parseCommentsIntoDefinition(
|
|
1632
1632
|
typ.aliasSymbol!,
|
|
1633
1633
|
definition,
|
|
1634
|
-
otherAnnotations
|
|
1634
|
+
otherAnnotations,
|
|
1635
1635
|
);
|
|
1636
1636
|
if (prop) {
|
|
1637
1637
|
this.parseCommentsIntoDefinition(
|
|
1638
1638
|
prop,
|
|
1639
1639
|
returnedDefinition,
|
|
1640
|
-
otherAnnotations
|
|
1640
|
+
otherAnnotations,
|
|
1641
1641
|
);
|
|
1642
1642
|
}
|
|
1643
1643
|
if (pairedSymbol && symbol && this.isFromDefaultLib(symbol)) {
|
|
1644
1644
|
this.parseCommentsIntoDefinition(
|
|
1645
1645
|
pairedSymbol,
|
|
1646
1646
|
definition,
|
|
1647
|
-
otherAnnotations
|
|
1647
|
+
otherAnnotations,
|
|
1648
1648
|
);
|
|
1649
1649
|
}
|
|
1650
1650
|
|
|
@@ -1669,7 +1669,7 @@ class JsonSchemaGenerator {
|
|
|
1669
1669
|
true,
|
|
1670
1670
|
undefined,
|
|
1671
1671
|
symbol,
|
|
1672
|
-
symbol
|
|
1672
|
+
symbol,
|
|
1673
1673
|
);
|
|
1674
1674
|
} else {
|
|
1675
1675
|
reffedDefinition = definition;
|
|
@@ -1693,7 +1693,7 @@ class JsonSchemaGenerator {
|
|
|
1693
1693
|
this.getUnionDefinition(
|
|
1694
1694
|
typ as ts.UnionType,
|
|
1695
1695
|
unionModifier,
|
|
1696
|
-
definition
|
|
1696
|
+
definition,
|
|
1697
1697
|
);
|
|
1698
1698
|
} else if (typ.flags & ts.TypeFlags.Intersection) {
|
|
1699
1699
|
if (this.args.noExtraProps) {
|
|
@@ -1711,7 +1711,7 @@ class JsonSchemaGenerator {
|
|
|
1711
1711
|
undefined,
|
|
1712
1712
|
undefined,
|
|
1713
1713
|
undefined,
|
|
1714
|
-
true
|
|
1714
|
+
true,
|
|
1715
1715
|
);
|
|
1716
1716
|
definition.type = other.type; // should always be object
|
|
1717
1717
|
definition.properties = {
|
|
@@ -1722,19 +1722,19 @@ class JsonSchemaGenerator {
|
|
|
1722
1722
|
if (Object.keys(other.default || {}).length > 0) {
|
|
1723
1723
|
definition.default = extend(
|
|
1724
1724
|
definition.default || {},
|
|
1725
|
-
other.default
|
|
1725
|
+
other.default,
|
|
1726
1726
|
);
|
|
1727
1727
|
}
|
|
1728
1728
|
if (other.required) {
|
|
1729
1729
|
definition.required = unique(
|
|
1730
|
-
(definition.required || []).concat(other.required)
|
|
1730
|
+
(definition.required || []).concat(other.required),
|
|
1731
1731
|
).sort();
|
|
1732
1732
|
}
|
|
1733
1733
|
}
|
|
1734
1734
|
} else {
|
|
1735
1735
|
this.getIntersectionDefinition(
|
|
1736
1736
|
typ as ts.IntersectionType,
|
|
1737
|
-
definition
|
|
1737
|
+
definition,
|
|
1738
1738
|
);
|
|
1739
1739
|
}
|
|
1740
1740
|
} else if (isRawType) {
|
|
@@ -1746,7 +1746,7 @@ class JsonSchemaGenerator {
|
|
|
1746
1746
|
reffedType!,
|
|
1747
1747
|
definition,
|
|
1748
1748
|
undefined,
|
|
1749
|
-
ignoreUndefined
|
|
1749
|
+
ignoreUndefined,
|
|
1750
1750
|
);
|
|
1751
1751
|
} else if (
|
|
1752
1752
|
node &&
|
|
@@ -1806,7 +1806,7 @@ class JsonSchemaGenerator {
|
|
|
1806
1806
|
public getSchemaForSymbol(
|
|
1807
1807
|
symbolName: string,
|
|
1808
1808
|
includeReffedDefinitions: boolean = true,
|
|
1809
|
-
includeAllOverrides: boolean = false
|
|
1809
|
+
includeAllOverrides: boolean = false,
|
|
1810
1810
|
): Definition {
|
|
1811
1811
|
const overrideDefinition = this.schemaOverrides.get(symbolName);
|
|
1812
1812
|
if (!this.allSymbols[symbolName] && !overrideDefinition) {
|
|
@@ -1827,7 +1827,7 @@ class JsonSchemaGenerator {
|
|
|
1827
1827
|
undefined,
|
|
1828
1828
|
undefined,
|
|
1829
1829
|
undefined,
|
|
1830
|
-
this.userSymbols[symbolName] || undefined
|
|
1830
|
+
this.userSymbols[symbolName] || undefined,
|
|
1831
1831
|
);
|
|
1832
1832
|
}
|
|
1833
1833
|
|
|
@@ -1849,7 +1849,7 @@ class JsonSchemaGenerator {
|
|
|
1849
1849
|
public getSchemaForSymbols(
|
|
1850
1850
|
symbolNames: string[],
|
|
1851
1851
|
includeReffedDefinitions: boolean = true,
|
|
1852
|
-
includeAllOverrides: boolean = false
|
|
1852
|
+
includeAllOverrides: boolean = false,
|
|
1853
1853
|
): Definition {
|
|
1854
1854
|
const root: {
|
|
1855
1855
|
$id?: string;
|
|
@@ -1875,7 +1875,7 @@ class JsonSchemaGenerator {
|
|
|
1875
1875
|
undefined,
|
|
1876
1876
|
undefined,
|
|
1877
1877
|
undefined,
|
|
1878
|
-
this.userSymbols[symbolName]
|
|
1878
|
+
this.userSymbols[symbolName],
|
|
1879
1879
|
);
|
|
1880
1880
|
}
|
|
1881
1881
|
if (
|
|
@@ -1902,7 +1902,7 @@ class JsonSchemaGenerator {
|
|
|
1902
1902
|
|
|
1903
1903
|
public getMainFileSymbols(
|
|
1904
1904
|
program: ts.Program,
|
|
1905
|
-
onlyIncludeFiles?: string[]
|
|
1905
|
+
onlyIncludeFiles?: string[],
|
|
1906
1906
|
): string[] {
|
|
1907
1907
|
function includeFile(file: ts.SourceFile): boolean {
|
|
1908
1908
|
if (onlyIncludeFiles === undefined) {
|
|
@@ -1940,7 +1940,7 @@ function generateHashOfNode(node: ts.Node, relativePath: string): string {
|
|
|
1940
1940
|
|
|
1941
1941
|
export function buildGenerator(
|
|
1942
1942
|
program: ts.Program,
|
|
1943
|
-
args: PartialArgs = {}
|
|
1943
|
+
args: PartialArgs = {},
|
|
1944
1944
|
): JsonSchemaGenerator | null {
|
|
1945
1945
|
// Use defaults unless otherwise specified
|
|
1946
1946
|
const settings = getDefaultArgs();
|
|
@@ -1990,7 +1990,7 @@ export function buildGenerator(
|
|
|
1990
1990
|
var baseName = tc.typeToString(
|
|
1991
1991
|
baseType,
|
|
1992
1992
|
undefined,
|
|
1993
|
-
ts.TypeFormatFlags.UseFullyQualifiedType
|
|
1993
|
+
ts.TypeFormatFlags.UseFullyQualifiedType,
|
|
1994
1994
|
);
|
|
1995
1995
|
if (!inheritingTypes[baseName]) {
|
|
1996
1996
|
inheritingTypes[baseName] = [];
|
|
@@ -2011,6 +2011,6 @@ export function buildGenerator(
|
|
|
2011
2011
|
userSymbols,
|
|
2012
2012
|
inheritingTypes,
|
|
2013
2013
|
typeChecker,
|
|
2014
|
-
settings
|
|
2014
|
+
settings,
|
|
2015
2015
|
);
|
|
2016
2016
|
}
|