@xlr-lib/xlr-utils 0.2.0--canary.2.131 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +74 -522
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +73 -494
- package/dist/index.mjs +73 -494
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
- package/src/__tests__/validation-helpers.test.ts +2 -2
- package/src/__tests__/xlr-helpers.test.ts +543 -0
- package/src/index.ts +1 -3
- package/src/type-checks.ts +0 -72
- package/src/validation-helpers.ts +2 -8
- package/src/{ts-helpers.ts → xlr-helpers.ts} +70 -178
- package/types/index.d.ts +1 -3
- package/types/type-checks.d.ts +0 -27
- package/types/xlr-helpers.d.ts +13 -0
- package/src/__tests__/annotations.test.ts +0 -40
- package/src/__tests__/documentation.test.ts +0 -116
- package/src/__tests__/ts-helpers.test.ts +0 -180
- package/src/__tests__/type-check.test.ts +0 -39
- package/src/annotations.ts +0 -237
- package/src/documentation.ts +0 -243
- package/types/annotations.d.ts +0 -7
- package/types/documentation.d.ts +0 -14
- package/types/ts-helpers.d.ts +0 -50
package/dist/index.legacy-esm.js
CHANGED
|
@@ -1,178 +1,4 @@
|
|
|
1
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/annotations.ts
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
function extractDescription(text) {
|
|
4
|
-
if (!text) {
|
|
5
|
-
return {};
|
|
6
|
-
}
|
|
7
|
-
return { description: text };
|
|
8
|
-
}
|
|
9
|
-
function parentIsNonObjectPath(node) {
|
|
10
|
-
return node.parent && (ts.isArrayTypeNode(node.parent) || ts.isTupleTypeNode(node.parent) || ts.isOptionalTypeNode(node.parent) || ts.isRestTypeNode(node.parent) || ts.isUnionTypeNode(node.parent));
|
|
11
|
-
}
|
|
12
|
-
function recurseTypeChain(node, child) {
|
|
13
|
-
if (!node) {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
if (ts.isArrayTypeNode(node) && node.parent && ts.isRestTypeNode(node.parent)) {
|
|
17
|
-
return recurseTypeChain(node.parent, node);
|
|
18
|
-
}
|
|
19
|
-
if (ts.isRestTypeNode(node)) {
|
|
20
|
-
return recurseTypeChain(node.parent, node);
|
|
21
|
-
}
|
|
22
|
-
if (ts.isOptionalTypeNode(node)) {
|
|
23
|
-
return recurseTypeChain(node.parent, node);
|
|
24
|
-
}
|
|
25
|
-
if (ts.isUnionTypeNode(node)) {
|
|
26
|
-
return recurseTypeChain(node.parent, node);
|
|
27
|
-
}
|
|
28
|
-
if (ts.isParenthesizedTypeNode(node)) {
|
|
29
|
-
return recurseTypeChain(node.parent, node);
|
|
30
|
-
}
|
|
31
|
-
if (ts.isTypeLiteralNode(node)) {
|
|
32
|
-
return recurseTypeChain(node.parent, node);
|
|
33
|
-
}
|
|
34
|
-
if (ts.isArrayTypeNode(node)) {
|
|
35
|
-
return ["[]", ...recurseTypeChain(node.parent, node)];
|
|
36
|
-
}
|
|
37
|
-
if (ts.isTupleTypeNode(node)) {
|
|
38
|
-
const pos = node.elements.indexOf(child);
|
|
39
|
-
return [
|
|
40
|
-
...pos === -1 ? [] : [`${pos}`],
|
|
41
|
-
...recurseTypeChain(node.parent, node)
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
if (ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isPropertySignature(node)) {
|
|
45
|
-
return [node.name.getText(), ...recurseTypeChain(node.parent, node)];
|
|
46
|
-
}
|
|
47
|
-
if (parentIsNonObjectPath(node)) {
|
|
48
|
-
return recurseTypeChain(node.parent, node);
|
|
49
|
-
}
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
function extractTitle(node) {
|
|
53
|
-
const typeNames = recurseTypeChain(node, void 0).reverse().join(".");
|
|
54
|
-
if (!typeNames.length) {
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
return { title: typeNames };
|
|
58
|
-
}
|
|
59
|
-
function stringifyDoc(docString) {
|
|
60
|
-
if (typeof docString === "undefined" || typeof docString === "string") {
|
|
61
|
-
return docString;
|
|
62
|
-
}
|
|
63
|
-
return docString.map(({ text }) => text).join(" ");
|
|
64
|
-
}
|
|
65
|
-
function extractTags(tags) {
|
|
66
|
-
const descriptions = [];
|
|
67
|
-
const examples = [];
|
|
68
|
-
const _default = [];
|
|
69
|
-
const see = [];
|
|
70
|
-
const meta = {};
|
|
71
|
-
const extractSee = (tag) => {
|
|
72
|
-
return `${tag.tagName ? `${tag.tagName?.getText()} ` : ""}${stringifyDoc(tag.comment)?.trim() ?? ""}`;
|
|
73
|
-
};
|
|
74
|
-
tags.forEach((tag) => {
|
|
75
|
-
if (!tag.comment) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (tag.tagName.text === "example") {
|
|
79
|
-
examples.push(stringifyDoc(tag.comment)?.trim() ?? "");
|
|
80
|
-
} else if (tag.tagName.text === "default") {
|
|
81
|
-
_default.push(stringifyDoc(tag.comment)?.trim() ?? "");
|
|
82
|
-
} else if (tag.tagName.text === "see") {
|
|
83
|
-
see.push(extractSee(tag));
|
|
84
|
-
} else if (tag.tagName.text === "meta") {
|
|
85
|
-
const [key, value] = tag.comment.toString().split(/:(.*)/);
|
|
86
|
-
meta[key] = value?.trim() ?? "";
|
|
87
|
-
} else {
|
|
88
|
-
const text = stringifyDoc(tag.comment)?.trim() ?? "";
|
|
89
|
-
descriptions.push(`@${tag.tagName.text} ${text}`);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
return {
|
|
93
|
-
...descriptions.length === 0 ? {} : { description: descriptions.join("\n") },
|
|
94
|
-
...examples.length === 0 ? {} : { examples },
|
|
95
|
-
..._default.length === 0 ? {} : { default: _default.join("\n") },
|
|
96
|
-
...see.length === 0 ? {} : { see },
|
|
97
|
-
...meta && Object.keys(meta).length === 0 ? {} : { meta }
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function join(t, separator = "\n") {
|
|
101
|
-
const unique = new Set(t).values();
|
|
102
|
-
return Array.from(unique).filter((s) => s !== void 0).join(separator).trim();
|
|
103
|
-
}
|
|
104
|
-
function mergeAnnotations(nodes) {
|
|
105
|
-
const name = nodes.find((n) => n.name)?.name;
|
|
106
|
-
const title = join(
|
|
107
|
-
nodes.map((n) => n.title),
|
|
108
|
-
", "
|
|
109
|
-
);
|
|
110
|
-
const description = join(nodes.map((n) => n.description));
|
|
111
|
-
const _default = join(nodes.map((n) => n.default));
|
|
112
|
-
const comment = join(nodes.map((n) => n.comment));
|
|
113
|
-
const examples = join(
|
|
114
|
-
nodes.map(
|
|
115
|
-
(n) => Array.isArray(n.examples) ? join(n.examples) : n.examples
|
|
116
|
-
)
|
|
117
|
-
);
|
|
118
|
-
const see = join(
|
|
119
|
-
nodes.map((n) => Array.isArray(n.see) ? join(n.see) : n.see)
|
|
120
|
-
);
|
|
121
|
-
const meta = nodes.find((n) => n.meta)?.meta;
|
|
122
|
-
return {
|
|
123
|
-
...name ? { name } : {},
|
|
124
|
-
...title ? { title } : {},
|
|
125
|
-
...description ? { description } : {},
|
|
126
|
-
...examples ? { examples } : {},
|
|
127
|
-
..._default ? { default: _default } : {},
|
|
128
|
-
...see ? { see } : {},
|
|
129
|
-
...comment ? { comment } : {},
|
|
130
|
-
...meta ? { meta } : {}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function decorateNode(node) {
|
|
134
|
-
const { jsDoc } = node;
|
|
135
|
-
const titleAnnotation = extractTitle(node);
|
|
136
|
-
if (jsDoc && jsDoc.length) {
|
|
137
|
-
const first = jsDoc[0];
|
|
138
|
-
return mergeAnnotations([
|
|
139
|
-
extractDescription(stringifyDoc(first.comment)),
|
|
140
|
-
titleAnnotation,
|
|
141
|
-
extractTags(first.tags ?? [])
|
|
142
|
-
]);
|
|
143
|
-
}
|
|
144
|
-
return titleAnnotation;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/ts-helpers.ts
|
|
148
|
-
import ts3 from "typescript";
|
|
149
|
-
|
|
150
1
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/type-checks.ts
|
|
151
|
-
import ts2 from "typescript";
|
|
152
|
-
function isOptionalProperty(node) {
|
|
153
|
-
return node.questionToken?.kind === ts2.SyntaxKind.QuestionToken;
|
|
154
|
-
}
|
|
155
|
-
function isGenericInterfaceDeclaration(node) {
|
|
156
|
-
const length = node.typeParameters?.length;
|
|
157
|
-
return length ? length > 0 : false;
|
|
158
|
-
}
|
|
159
|
-
function isGenericTypeDeclaration(node) {
|
|
160
|
-
const length = node.typeParameters?.length;
|
|
161
|
-
return length ? length > 0 : false;
|
|
162
|
-
}
|
|
163
|
-
function isTypeReferenceGeneric(node, typeChecker) {
|
|
164
|
-
const symbol = typeChecker.getSymbolAtLocation(node.typeName);
|
|
165
|
-
if (symbol && symbol.declarations) {
|
|
166
|
-
return symbol.declarations[0].kind === ts2.SyntaxKind.TypeParameter;
|
|
167
|
-
}
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
function isTopLevelDeclaration(node) {
|
|
171
|
-
return node.kind === ts2.SyntaxKind.InterfaceDeclaration || node.kind === ts2.SyntaxKind.TypeAliasDeclaration;
|
|
172
|
-
}
|
|
173
|
-
function isTopLevelNode(node) {
|
|
174
|
-
return node.kind === ts2.SyntaxKind.InterfaceDeclaration || node.kind === ts2.SyntaxKind.TypeAliasDeclaration || node.kind === ts2.SyntaxKind.VariableStatement;
|
|
175
|
-
}
|
|
176
2
|
function isGenericNodeType(nt) {
|
|
177
3
|
return nt.genericTokens?.length > 0;
|
|
178
4
|
}
|
|
@@ -218,12 +44,8 @@ function isNamedType(node) {
|
|
|
218
44
|
|
|
219
45
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/validation-helpers.ts
|
|
220
46
|
function propertyToTuple(node) {
|
|
221
|
-
let key = node.children?.[0].value;
|
|
222
|
-
if (key.includes("-")) {
|
|
223
|
-
key = `'${key}'`;
|
|
224
|
-
}
|
|
225
47
|
return {
|
|
226
|
-
key,
|
|
48
|
+
key: node.children?.[0].value,
|
|
227
49
|
value: node.children?.[1]
|
|
228
50
|
};
|
|
229
51
|
}
|
|
@@ -358,89 +180,20 @@ function computeEffectiveObject(base, operand, errorOnOverlap = true) {
|
|
|
358
180
|
return newObject;
|
|
359
181
|
}
|
|
360
182
|
|
|
361
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/
|
|
362
|
-
function
|
|
363
|
-
return ts3.isOptionalTypeNode(node) ? node.type : node;
|
|
364
|
-
}
|
|
365
|
-
function isExportedDeclaration(node) {
|
|
366
|
-
const modifiers = ts3.canHaveModifiers(node) ? ts3.getModifiers(node) : void 0;
|
|
367
|
-
if (modifiers) {
|
|
368
|
-
return modifiers.some((m) => m.kind === ts3.SyntaxKind.ExportKeyword);
|
|
369
|
-
}
|
|
370
|
-
return false;
|
|
371
|
-
}
|
|
372
|
-
function isNodeExported(node) {
|
|
373
|
-
return (ts3.getCombinedModifierFlags(node) & ts3.ModifierFlags.Export) !== 0 || !!node.parent && node.parent.kind === ts3.SyntaxKind.SourceFile;
|
|
374
|
-
}
|
|
375
|
-
function getReferencedType(node, typeChecker) {
|
|
376
|
-
let symbol = typeChecker.getSymbolAtLocation(node.typeName);
|
|
377
|
-
if (symbol && (symbol.flags & ts3.SymbolFlags.Alias) === ts3.SymbolFlags.Alias) {
|
|
378
|
-
symbol = typeChecker.getAliasedSymbol(symbol);
|
|
379
|
-
}
|
|
380
|
-
const varDecl = symbol?.declarations?.[0];
|
|
381
|
-
if (varDecl && (ts3.isInterfaceDeclaration(varDecl) || ts3.isTypeAliasDeclaration(varDecl))) {
|
|
382
|
-
return { declaration: varDecl, exported: isNodeExported(varDecl) };
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
function isTypeScriptLibType(node, typeChecker) {
|
|
386
|
-
let symbol = typeChecker.getSymbolAtLocation(node.typeName);
|
|
387
|
-
if (!symbol) return false;
|
|
388
|
-
if ((symbol.flags & ts3.SymbolFlags.Alias) === ts3.SymbolFlags.Alias) {
|
|
389
|
-
symbol = typeChecker.getAliasedSymbol(symbol);
|
|
390
|
-
}
|
|
391
|
-
const declarations = symbol.getDeclarations();
|
|
392
|
-
if (!declarations || declarations.length === 0) return false;
|
|
393
|
-
return declarations.some((decl) => {
|
|
394
|
-
const sourceFile = decl.getSourceFile();
|
|
395
|
-
if (!sourceFile) return false;
|
|
396
|
-
const filePath = sourceFile.fileName;
|
|
397
|
-
return filePath.includes("/typescript/lib/") || filePath.includes("\\typescript\\lib\\") || filePath.endsWith(".d.ts") && filePath.includes("lib.");
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
function getStringLiteralsFromUnion(node) {
|
|
401
|
-
if (ts3.isUnionTypeNode(node)) {
|
|
402
|
-
return new Set(
|
|
403
|
-
node.types.map((type) => {
|
|
404
|
-
if (ts3.isLiteralTypeNode(type) && ts3.isStringLiteral(type.literal)) {
|
|
405
|
-
return type.literal.text;
|
|
406
|
-
}
|
|
407
|
-
return "";
|
|
408
|
-
})
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
if (ts3.isLiteralTypeNode(node) && ts3.isStringLiteral(node.literal)) {
|
|
412
|
-
return /* @__PURE__ */ new Set([node.literal.text]);
|
|
413
|
-
}
|
|
414
|
-
return /* @__PURE__ */ new Set();
|
|
415
|
-
}
|
|
416
|
-
function buildTemplateRegex(node, typeChecker) {
|
|
417
|
-
let regex = node.head.text;
|
|
418
|
-
node.templateSpans.forEach((span) => {
|
|
419
|
-
let type = span.type.kind;
|
|
420
|
-
if (ts3.isTypeReferenceNode(span.type)) {
|
|
421
|
-
let symbol = typeChecker.getSymbolAtLocation(
|
|
422
|
-
span.type.typeName
|
|
423
|
-
);
|
|
424
|
-
if (symbol && (symbol.flags & ts3.SymbolFlags.Alias) === ts3.SymbolFlags.Alias) {
|
|
425
|
-
symbol = typeChecker.getAliasedSymbol(symbol);
|
|
426
|
-
}
|
|
427
|
-
type = (symbol?.declarations?.[0]).type.kind;
|
|
428
|
-
}
|
|
429
|
-
if (type === ts3.SyntaxKind.StringKeyword) {
|
|
430
|
-
regex += ".*";
|
|
431
|
-
} else if (type === ts3.SyntaxKind.NumberKeyword) {
|
|
432
|
-
regex += "[0-9]*";
|
|
433
|
-
} else if (type === ts3.SyntaxKind.BooleanKeyword) {
|
|
434
|
-
regex += "true|false";
|
|
435
|
-
}
|
|
436
|
-
regex += span.literal.text;
|
|
437
|
-
});
|
|
438
|
-
return regex;
|
|
439
|
-
}
|
|
440
|
-
function fillInGenerics(xlrNode, generics) {
|
|
183
|
+
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/xlr-helpers.ts
|
|
184
|
+
function fillInGenerics(xlrNode, generics, preferLocalGenerics = false) {
|
|
441
185
|
let localGenerics;
|
|
442
186
|
if (generics) {
|
|
443
187
|
localGenerics = new Map(generics);
|
|
188
|
+
if (preferLocalGenerics && isGenericNodeType(xlrNode)) {
|
|
189
|
+
xlrNode.genericTokens?.forEach((token) => {
|
|
190
|
+
const genericValue = token.default ?? token.constraints;
|
|
191
|
+
localGenerics.set(
|
|
192
|
+
token.symbol,
|
|
193
|
+
fillInGenerics(genericValue, localGenerics, preferLocalGenerics)
|
|
194
|
+
);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
444
197
|
} else {
|
|
445
198
|
localGenerics = /* @__PURE__ */ new Map();
|
|
446
199
|
if (isGenericNodeType(xlrNode)) {
|
|
@@ -448,7 +201,7 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
448
201
|
const genericValue = token.default ?? token.constraints;
|
|
449
202
|
localGenerics.set(
|
|
450
203
|
token.symbol,
|
|
451
|
-
fillInGenerics(genericValue, localGenerics)
|
|
204
|
+
fillInGenerics(genericValue, localGenerics, preferLocalGenerics)
|
|
452
205
|
);
|
|
453
206
|
});
|
|
454
207
|
}
|
|
@@ -459,7 +212,7 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
459
212
|
...localGenerics.get(xlrNode.ref),
|
|
460
213
|
...xlrNode.genericArguments ? {
|
|
461
214
|
genericArguments: xlrNode.genericArguments.map(
|
|
462
|
-
(ga) => fillInGenerics(ga, localGenerics)
|
|
215
|
+
(ga) => fillInGenerics(ga, localGenerics, preferLocalGenerics)
|
|
463
216
|
)
|
|
464
217
|
} : {},
|
|
465
218
|
...xlrNode.title ? { title: xlrNode.title } : {},
|
|
@@ -472,7 +225,7 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
472
225
|
...xlrNode,
|
|
473
226
|
...xlrNode.genericArguments ? {
|
|
474
227
|
genericArguments: xlrNode.genericArguments.map(
|
|
475
|
-
(ga) => fillInGenerics(ga, localGenerics)
|
|
228
|
+
(ga) => fillInGenerics(ga, localGenerics, preferLocalGenerics)
|
|
476
229
|
)
|
|
477
230
|
} : {}
|
|
478
231
|
};
|
|
@@ -483,7 +236,7 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
483
236
|
const prop = xlrNode.properties[propName];
|
|
484
237
|
newProperties[propName] = {
|
|
485
238
|
required: prop.required,
|
|
486
|
-
node: fillInGenerics(prop.node, localGenerics)
|
|
239
|
+
node: fillInGenerics(prop.node, localGenerics, preferLocalGenerics)
|
|
487
240
|
};
|
|
488
241
|
});
|
|
489
242
|
return {
|
|
@@ -493,19 +246,39 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
493
246
|
genericTokens: xlrNode.genericTokens.map((token) => {
|
|
494
247
|
return {
|
|
495
248
|
...token,
|
|
496
|
-
constraints: token.constraints ? fillInGenerics(
|
|
497
|
-
|
|
249
|
+
constraints: token.constraints ? fillInGenerics(
|
|
250
|
+
token.constraints,
|
|
251
|
+
localGenerics,
|
|
252
|
+
preferLocalGenerics
|
|
253
|
+
) : void 0,
|
|
254
|
+
default: token.default ? fillInGenerics(
|
|
255
|
+
token.default,
|
|
256
|
+
localGenerics,
|
|
257
|
+
preferLocalGenerics
|
|
258
|
+
) : void 0
|
|
498
259
|
};
|
|
499
260
|
})
|
|
500
261
|
} : {},
|
|
501
|
-
extends: xlrNode.extends ? fillInGenerics(
|
|
502
|
-
|
|
262
|
+
extends: xlrNode.extends ? fillInGenerics(
|
|
263
|
+
xlrNode.extends,
|
|
264
|
+
localGenerics,
|
|
265
|
+
preferLocalGenerics
|
|
266
|
+
) : void 0,
|
|
267
|
+
additionalProperties: xlrNode.additionalProperties ? fillInGenerics(
|
|
268
|
+
xlrNode.additionalProperties,
|
|
269
|
+
localGenerics,
|
|
270
|
+
preferLocalGenerics
|
|
271
|
+
) : false
|
|
503
272
|
};
|
|
504
273
|
}
|
|
505
274
|
if (xlrNode.type === "array") {
|
|
506
275
|
return {
|
|
507
276
|
...xlrNode,
|
|
508
|
-
elementType: fillInGenerics(
|
|
277
|
+
elementType: fillInGenerics(
|
|
278
|
+
xlrNode.elementType,
|
|
279
|
+
localGenerics,
|
|
280
|
+
preferLocalGenerics
|
|
281
|
+
)
|
|
509
282
|
};
|
|
510
283
|
} else if (xlrNode.type === "or" || xlrNode.type === "and") {
|
|
511
284
|
let pointer;
|
|
@@ -517,25 +290,49 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
517
290
|
return {
|
|
518
291
|
...xlrNode,
|
|
519
292
|
[xlrNode.type]: pointer.map((prop) => {
|
|
520
|
-
return fillInGenerics(prop, localGenerics);
|
|
293
|
+
return fillInGenerics(prop, localGenerics, preferLocalGenerics);
|
|
521
294
|
})
|
|
522
295
|
};
|
|
523
296
|
} else if (xlrNode.type === "record") {
|
|
524
297
|
return {
|
|
525
298
|
...xlrNode,
|
|
526
|
-
keyType: fillInGenerics(
|
|
527
|
-
|
|
299
|
+
keyType: fillInGenerics(
|
|
300
|
+
xlrNode.keyType,
|
|
301
|
+
localGenerics,
|
|
302
|
+
preferLocalGenerics
|
|
303
|
+
),
|
|
304
|
+
valueType: fillInGenerics(
|
|
305
|
+
xlrNode.valueType,
|
|
306
|
+
localGenerics,
|
|
307
|
+
preferLocalGenerics
|
|
308
|
+
)
|
|
528
309
|
};
|
|
529
310
|
} else if (xlrNode.type === "conditional") {
|
|
530
311
|
const filledInConditional = {
|
|
531
312
|
...xlrNode,
|
|
532
313
|
check: {
|
|
533
|
-
left: fillInGenerics(
|
|
534
|
-
|
|
314
|
+
left: fillInGenerics(
|
|
315
|
+
xlrNode.check.left,
|
|
316
|
+
localGenerics,
|
|
317
|
+
preferLocalGenerics
|
|
318
|
+
),
|
|
319
|
+
right: fillInGenerics(
|
|
320
|
+
xlrNode.check.right,
|
|
321
|
+
localGenerics,
|
|
322
|
+
preferLocalGenerics
|
|
323
|
+
)
|
|
535
324
|
},
|
|
536
325
|
value: {
|
|
537
|
-
true: fillInGenerics(
|
|
538
|
-
|
|
326
|
+
true: fillInGenerics(
|
|
327
|
+
xlrNode.value.true,
|
|
328
|
+
localGenerics,
|
|
329
|
+
preferLocalGenerics
|
|
330
|
+
),
|
|
331
|
+
false: fillInGenerics(
|
|
332
|
+
xlrNode.value.false,
|
|
333
|
+
localGenerics,
|
|
334
|
+
preferLocalGenerics
|
|
335
|
+
)
|
|
539
336
|
}
|
|
540
337
|
};
|
|
541
338
|
if (filledInConditional.check.left.type !== "ref" && filledInConditional.check.right.type !== "ref") {
|
|
@@ -629,249 +426,31 @@ function applyExcludeToNodeType(baseObject, filters) {
|
|
|
629
426
|
or: remainingMembers
|
|
630
427
|
};
|
|
631
428
|
}
|
|
632
|
-
|
|
633
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/documentation.ts
|
|
634
|
-
import ts4 from "typescript";
|
|
635
|
-
var { SymbolDisplayPartKind, displayPartsToString } = ts4;
|
|
636
|
-
function insertBetweenElements(array, separator) {
|
|
637
|
-
return array.reduce((acc, item, index) => {
|
|
638
|
-
if (index === 0) {
|
|
639
|
-
return [item];
|
|
640
|
-
}
|
|
641
|
-
return [...acc, separator, item];
|
|
642
|
-
}, []);
|
|
643
|
-
}
|
|
644
|
-
function createTSDocString(node) {
|
|
645
|
-
if (node.type === "ref") {
|
|
646
|
-
return [
|
|
647
|
-
{
|
|
648
|
-
text: node.ref,
|
|
649
|
-
kind: SymbolDisplayPartKind.keyword
|
|
650
|
-
}
|
|
651
|
-
];
|
|
652
|
-
}
|
|
653
|
-
if (node.type === "or" || node.type === "and") {
|
|
654
|
-
const items = node.type === "and" ? node.and : node.or;
|
|
655
|
-
return insertBetweenElements(
|
|
656
|
-
items.map((subnode) => createTSDocString(subnode)),
|
|
657
|
-
[
|
|
658
|
-
{
|
|
659
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
660
|
-
text: node.type === "and" ? " & " : " | "
|
|
661
|
-
}
|
|
662
|
-
]
|
|
663
|
-
).flat();
|
|
664
|
-
}
|
|
665
|
-
if (node.type === "function") {
|
|
666
|
-
return [
|
|
667
|
-
{
|
|
668
|
-
kind: SymbolDisplayPartKind.keyword,
|
|
669
|
-
text: "function"
|
|
670
|
-
},
|
|
671
|
-
{
|
|
672
|
-
kind: SymbolDisplayPartKind.space,
|
|
673
|
-
text: " "
|
|
674
|
-
},
|
|
675
|
-
...node.name ? [{ text: node.name, kind: SymbolDisplayPartKind.methodName }] : [],
|
|
676
|
-
{
|
|
677
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
678
|
-
text: "("
|
|
679
|
-
},
|
|
680
|
-
...insertBetweenElements(
|
|
681
|
-
node.parameters.map((p) => {
|
|
682
|
-
if (p.name) {
|
|
683
|
-
return [
|
|
684
|
-
{
|
|
685
|
-
kind: SymbolDisplayPartKind.parameterName,
|
|
686
|
-
text: p.name
|
|
687
|
-
},
|
|
688
|
-
{
|
|
689
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
690
|
-
text: p.optional ? "?" : ""
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
694
|
-
text: ": "
|
|
695
|
-
},
|
|
696
|
-
...createTSDocString(p.type)
|
|
697
|
-
];
|
|
698
|
-
}
|
|
699
|
-
return createTSDocString(p.type);
|
|
700
|
-
}),
|
|
701
|
-
[
|
|
702
|
-
{
|
|
703
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
704
|
-
text: ", "
|
|
705
|
-
}
|
|
706
|
-
]
|
|
707
|
-
).flat(),
|
|
708
|
-
{
|
|
709
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
710
|
-
text: ")"
|
|
711
|
-
},
|
|
712
|
-
...node.returnType ? [
|
|
713
|
-
{
|
|
714
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
715
|
-
text: ": "
|
|
716
|
-
},
|
|
717
|
-
...createTSDocString(node.returnType)
|
|
718
|
-
] : []
|
|
719
|
-
];
|
|
720
|
-
}
|
|
721
|
-
if (node.type === "tuple") {
|
|
722
|
-
return [
|
|
723
|
-
{
|
|
724
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
725
|
-
text: "["
|
|
726
|
-
},
|
|
727
|
-
...insertBetweenElements(
|
|
728
|
-
node.elementTypes.map((t) => {
|
|
729
|
-
if (t.name) {
|
|
730
|
-
return [
|
|
731
|
-
{
|
|
732
|
-
kind: SymbolDisplayPartKind.propertyName,
|
|
733
|
-
text: t.name
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
737
|
-
text: ": "
|
|
738
|
-
},
|
|
739
|
-
...createTSDocString(t.type)
|
|
740
|
-
];
|
|
741
|
-
}
|
|
742
|
-
return createTSDocString(t.type);
|
|
743
|
-
}),
|
|
744
|
-
[
|
|
745
|
-
{
|
|
746
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
747
|
-
text: ", "
|
|
748
|
-
}
|
|
749
|
-
]
|
|
750
|
-
).flat(),
|
|
751
|
-
{
|
|
752
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
753
|
-
text: "]"
|
|
754
|
-
}
|
|
755
|
-
];
|
|
756
|
-
}
|
|
757
|
-
if (node.type === "array") {
|
|
758
|
-
return [
|
|
759
|
-
{
|
|
760
|
-
kind: SymbolDisplayPartKind.interfaceName,
|
|
761
|
-
text: "Array"
|
|
762
|
-
},
|
|
763
|
-
{
|
|
764
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
765
|
-
text: "<"
|
|
766
|
-
},
|
|
767
|
-
...createTSDocString(node.elementType),
|
|
768
|
-
{
|
|
769
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
770
|
-
text: ">"
|
|
771
|
-
}
|
|
772
|
-
];
|
|
773
|
-
}
|
|
774
|
-
if (node.type === "record") {
|
|
775
|
-
return [
|
|
776
|
-
{
|
|
777
|
-
kind: SymbolDisplayPartKind.interfaceName,
|
|
778
|
-
text: "Record"
|
|
779
|
-
},
|
|
780
|
-
{
|
|
781
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
782
|
-
text: "<"
|
|
783
|
-
},
|
|
784
|
-
...createTSDocString(node.keyType),
|
|
785
|
-
{
|
|
786
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
787
|
-
text: ", "
|
|
788
|
-
},
|
|
789
|
-
...createTSDocString(node.valueType),
|
|
790
|
-
{
|
|
791
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
792
|
-
text: ">"
|
|
793
|
-
}
|
|
794
|
-
];
|
|
795
|
-
}
|
|
796
|
-
if ((node.type === "string" || node.type === "boolean" || node.type === "number") && node.const !== void 0) {
|
|
797
|
-
return [
|
|
798
|
-
{
|
|
799
|
-
kind: SymbolDisplayPartKind.keyword,
|
|
800
|
-
text: typeof node.const === "string" ? `"${node.const}"` : String(node.const)
|
|
801
|
-
}
|
|
802
|
-
];
|
|
803
|
-
}
|
|
804
|
-
if (isPrimitiveTypeNode(node) && node.type !== "null") {
|
|
805
|
-
return [
|
|
806
|
-
{
|
|
807
|
-
kind: SymbolDisplayPartKind.keyword,
|
|
808
|
-
text: node.type
|
|
809
|
-
}
|
|
810
|
-
];
|
|
811
|
-
}
|
|
812
|
-
if (node.type === "object" && node.name) {
|
|
813
|
-
return [
|
|
814
|
-
{
|
|
815
|
-
kind: SymbolDisplayPartKind.interfaceName,
|
|
816
|
-
text: node.name
|
|
817
|
-
}
|
|
818
|
-
];
|
|
819
|
-
}
|
|
820
|
-
return [
|
|
821
|
-
{
|
|
822
|
-
kind: SymbolDisplayPartKind.localName,
|
|
823
|
-
text: node.type
|
|
824
|
-
}
|
|
825
|
-
];
|
|
826
|
-
}
|
|
827
|
-
function symbolDisplayToString(displayParts) {
|
|
828
|
-
return displayPartsToString(displayParts);
|
|
829
|
-
}
|
|
830
|
-
function createDocString(node) {
|
|
831
|
-
return symbolDisplayToString(createTSDocString(node));
|
|
832
|
-
}
|
|
833
429
|
export {
|
|
834
430
|
applyExcludeToNodeType,
|
|
835
431
|
applyPartialOrRequiredToNodeType,
|
|
836
432
|
applyPickOrOmitToNodeType,
|
|
837
|
-
buildTemplateRegex,
|
|
838
433
|
computeEffectiveObject,
|
|
839
434
|
computeExtends,
|
|
840
|
-
createDocString,
|
|
841
|
-
createTSDocString,
|
|
842
|
-
decorateNode,
|
|
843
435
|
fillInGenerics,
|
|
844
|
-
getReferencedType,
|
|
845
|
-
getStringLiteralsFromUnion,
|
|
846
436
|
isAndType,
|
|
847
437
|
isArrayType,
|
|
848
438
|
isBooleanType,
|
|
849
|
-
isExportedDeclaration,
|
|
850
|
-
isGenericInterfaceDeclaration,
|
|
851
439
|
isGenericNamedType,
|
|
852
440
|
isGenericNodeType,
|
|
853
|
-
isGenericTypeDeclaration,
|
|
854
441
|
isNamedType,
|
|
855
442
|
isNode,
|
|
856
|
-
isNodeExported,
|
|
857
443
|
isNonNullable,
|
|
858
444
|
isNumberType,
|
|
859
445
|
isObjectType,
|
|
860
|
-
isOptionalProperty,
|
|
861
446
|
isOrType,
|
|
862
447
|
isPrimitiveTypeNode,
|
|
863
448
|
isRecordType,
|
|
864
449
|
isRefType,
|
|
865
450
|
isStringType,
|
|
866
|
-
isTopLevelDeclaration,
|
|
867
|
-
isTopLevelNode,
|
|
868
|
-
isTypeReferenceGeneric,
|
|
869
|
-
isTypeScriptLibType,
|
|
870
451
|
makePropertyMap,
|
|
871
452
|
propertyToTuple,
|
|
872
453
|
resolveConditional,
|
|
873
|
-
resolveReferenceNode
|
|
874
|
-
symbolDisplayToString,
|
|
875
|
-
tsStripOptionalType
|
|
454
|
+
resolveReferenceNode
|
|
876
455
|
};
|
|
877
456
|
//# sourceMappingURL=index.mjs.map
|