@xlr-lib/xlr-utils 0.2.0--canary.2.120 → 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/cjs/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/index.ts
|
|
@@ -33,223 +23,32 @@ __export(src_exports, {
|
|
|
33
23
|
applyExcludeToNodeType: () => applyExcludeToNodeType,
|
|
34
24
|
applyPartialOrRequiredToNodeType: () => applyPartialOrRequiredToNodeType,
|
|
35
25
|
applyPickOrOmitToNodeType: () => applyPickOrOmitToNodeType,
|
|
36
|
-
buildTemplateRegex: () => buildTemplateRegex,
|
|
37
26
|
computeEffectiveObject: () => computeEffectiveObject,
|
|
38
27
|
computeExtends: () => computeExtends,
|
|
39
|
-
createDocString: () => createDocString,
|
|
40
|
-
createTSDocString: () => createTSDocString,
|
|
41
|
-
decorateNode: () => decorateNode,
|
|
42
28
|
fillInGenerics: () => fillInGenerics,
|
|
43
|
-
getReferencedType: () => getReferencedType,
|
|
44
|
-
getStringLiteralsFromUnion: () => getStringLiteralsFromUnion,
|
|
45
29
|
isAndType: () => isAndType,
|
|
46
30
|
isArrayType: () => isArrayType,
|
|
47
31
|
isBooleanType: () => isBooleanType,
|
|
48
|
-
isExportedDeclaration: () => isExportedDeclaration,
|
|
49
|
-
isGenericInterfaceDeclaration: () => isGenericInterfaceDeclaration,
|
|
50
32
|
isGenericNamedType: () => isGenericNamedType,
|
|
51
33
|
isGenericNodeType: () => isGenericNodeType,
|
|
52
|
-
isGenericTypeDeclaration: () => isGenericTypeDeclaration,
|
|
53
34
|
isNamedType: () => isNamedType,
|
|
54
35
|
isNode: () => isNode,
|
|
55
|
-
isNodeExported: () => isNodeExported,
|
|
56
36
|
isNonNullable: () => isNonNullable,
|
|
57
37
|
isNumberType: () => isNumberType,
|
|
58
38
|
isObjectType: () => isObjectType,
|
|
59
|
-
isOptionalProperty: () => isOptionalProperty,
|
|
60
39
|
isOrType: () => isOrType,
|
|
61
40
|
isPrimitiveTypeNode: () => isPrimitiveTypeNode,
|
|
62
41
|
isRecordType: () => isRecordType,
|
|
63
42
|
isRefType: () => isRefType,
|
|
64
43
|
isStringType: () => isStringType,
|
|
65
|
-
isTopLevelDeclaration: () => isTopLevelDeclaration,
|
|
66
|
-
isTopLevelNode: () => isTopLevelNode,
|
|
67
|
-
isTypeReferenceGeneric: () => isTypeReferenceGeneric,
|
|
68
|
-
isTypeScriptLibType: () => isTypeScriptLibType,
|
|
69
44
|
makePropertyMap: () => makePropertyMap,
|
|
70
45
|
propertyToTuple: () => propertyToTuple,
|
|
71
46
|
resolveConditional: () => resolveConditional,
|
|
72
|
-
resolveReferenceNode: () => resolveReferenceNode
|
|
73
|
-
symbolDisplayToString: () => symbolDisplayToString,
|
|
74
|
-
tsStripOptionalType: () => tsStripOptionalType
|
|
47
|
+
resolveReferenceNode: () => resolveReferenceNode
|
|
75
48
|
});
|
|
76
49
|
module.exports = __toCommonJS(src_exports);
|
|
77
50
|
|
|
78
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/annotations.ts
|
|
79
|
-
var import_typescript = __toESM(require("typescript"));
|
|
80
|
-
function extractDescription(text) {
|
|
81
|
-
if (!text) {
|
|
82
|
-
return {};
|
|
83
|
-
}
|
|
84
|
-
return { description: text };
|
|
85
|
-
}
|
|
86
|
-
function parentIsNonObjectPath(node) {
|
|
87
|
-
return node.parent && (import_typescript.default.isArrayTypeNode(node.parent) || import_typescript.default.isTupleTypeNode(node.parent) || import_typescript.default.isOptionalTypeNode(node.parent) || import_typescript.default.isRestTypeNode(node.parent) || import_typescript.default.isUnionTypeNode(node.parent));
|
|
88
|
-
}
|
|
89
|
-
function recurseTypeChain(node, child) {
|
|
90
|
-
if (!node) {
|
|
91
|
-
return [];
|
|
92
|
-
}
|
|
93
|
-
if (import_typescript.default.isArrayTypeNode(node) && node.parent && import_typescript.default.isRestTypeNode(node.parent)) {
|
|
94
|
-
return recurseTypeChain(node.parent, node);
|
|
95
|
-
}
|
|
96
|
-
if (import_typescript.default.isRestTypeNode(node)) {
|
|
97
|
-
return recurseTypeChain(node.parent, node);
|
|
98
|
-
}
|
|
99
|
-
if (import_typescript.default.isOptionalTypeNode(node)) {
|
|
100
|
-
return recurseTypeChain(node.parent, node);
|
|
101
|
-
}
|
|
102
|
-
if (import_typescript.default.isUnionTypeNode(node)) {
|
|
103
|
-
return recurseTypeChain(node.parent, node);
|
|
104
|
-
}
|
|
105
|
-
if (import_typescript.default.isParenthesizedTypeNode(node)) {
|
|
106
|
-
return recurseTypeChain(node.parent, node);
|
|
107
|
-
}
|
|
108
|
-
if (import_typescript.default.isTypeLiteralNode(node)) {
|
|
109
|
-
return recurseTypeChain(node.parent, node);
|
|
110
|
-
}
|
|
111
|
-
if (import_typescript.default.isArrayTypeNode(node)) {
|
|
112
|
-
return ["[]", ...recurseTypeChain(node.parent, node)];
|
|
113
|
-
}
|
|
114
|
-
if (import_typescript.default.isTupleTypeNode(node)) {
|
|
115
|
-
const pos = node.elements.indexOf(child);
|
|
116
|
-
return [
|
|
117
|
-
...pos === -1 ? [] : [`${pos}`],
|
|
118
|
-
...recurseTypeChain(node.parent, node)
|
|
119
|
-
];
|
|
120
|
-
}
|
|
121
|
-
if (import_typescript.default.isTypeAliasDeclaration(node) || import_typescript.default.isInterfaceDeclaration(node) || import_typescript.default.isPropertySignature(node)) {
|
|
122
|
-
return [node.name.getText(), ...recurseTypeChain(node.parent, node)];
|
|
123
|
-
}
|
|
124
|
-
if (parentIsNonObjectPath(node)) {
|
|
125
|
-
return recurseTypeChain(node.parent, node);
|
|
126
|
-
}
|
|
127
|
-
return [];
|
|
128
|
-
}
|
|
129
|
-
function extractTitle(node) {
|
|
130
|
-
const typeNames = recurseTypeChain(node, void 0).reverse().join(".");
|
|
131
|
-
if (!typeNames.length) {
|
|
132
|
-
return {};
|
|
133
|
-
}
|
|
134
|
-
return { title: typeNames };
|
|
135
|
-
}
|
|
136
|
-
function stringifyDoc(docString) {
|
|
137
|
-
if (typeof docString === "undefined" || typeof docString === "string") {
|
|
138
|
-
return docString;
|
|
139
|
-
}
|
|
140
|
-
return docString.map(({ text }) => text).join(" ");
|
|
141
|
-
}
|
|
142
|
-
function extractTags(tags) {
|
|
143
|
-
const descriptions = [];
|
|
144
|
-
const examples = [];
|
|
145
|
-
const _default = [];
|
|
146
|
-
const see = [];
|
|
147
|
-
const meta = {};
|
|
148
|
-
const extractSee = (tag) => {
|
|
149
|
-
return `${tag.tagName ? `${tag.tagName?.getText()} ` : ""}${stringifyDoc(tag.comment)?.trim() ?? ""}`;
|
|
150
|
-
};
|
|
151
|
-
tags.forEach((tag) => {
|
|
152
|
-
if (!tag.comment) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (tag.tagName.text === "example") {
|
|
156
|
-
examples.push(stringifyDoc(tag.comment)?.trim() ?? "");
|
|
157
|
-
} else if (tag.tagName.text === "default") {
|
|
158
|
-
_default.push(stringifyDoc(tag.comment)?.trim() ?? "");
|
|
159
|
-
} else if (tag.tagName.text === "see") {
|
|
160
|
-
see.push(extractSee(tag));
|
|
161
|
-
} else if (tag.tagName.text === "meta") {
|
|
162
|
-
const [key, value] = tag.comment.toString().split(/:(.*)/);
|
|
163
|
-
meta[key] = value?.trim() ?? "";
|
|
164
|
-
} else {
|
|
165
|
-
const text = stringifyDoc(tag.comment)?.trim() ?? "";
|
|
166
|
-
descriptions.push(`@${tag.tagName.text} ${text}`);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
return {
|
|
170
|
-
...descriptions.length === 0 ? {} : { description: descriptions.join("\n") },
|
|
171
|
-
...examples.length === 0 ? {} : { examples },
|
|
172
|
-
..._default.length === 0 ? {} : { default: _default.join("\n") },
|
|
173
|
-
...see.length === 0 ? {} : { see },
|
|
174
|
-
...meta && Object.keys(meta).length === 0 ? {} : { meta }
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function join(t, separator = "\n") {
|
|
178
|
-
const unique = new Set(t).values();
|
|
179
|
-
return Array.from(unique).filter((s) => s !== void 0).join(separator).trim();
|
|
180
|
-
}
|
|
181
|
-
function mergeAnnotations(nodes) {
|
|
182
|
-
const name = nodes.find((n) => n.name)?.name;
|
|
183
|
-
const title = join(
|
|
184
|
-
nodes.map((n) => n.title),
|
|
185
|
-
", "
|
|
186
|
-
);
|
|
187
|
-
const description = join(nodes.map((n) => n.description));
|
|
188
|
-
const _default = join(nodes.map((n) => n.default));
|
|
189
|
-
const comment = join(nodes.map((n) => n.comment));
|
|
190
|
-
const examples = join(
|
|
191
|
-
nodes.map(
|
|
192
|
-
(n) => Array.isArray(n.examples) ? join(n.examples) : n.examples
|
|
193
|
-
)
|
|
194
|
-
);
|
|
195
|
-
const see = join(
|
|
196
|
-
nodes.map((n) => Array.isArray(n.see) ? join(n.see) : n.see)
|
|
197
|
-
);
|
|
198
|
-
const meta = nodes.find((n) => n.meta)?.meta;
|
|
199
|
-
return {
|
|
200
|
-
...name ? { name } : {},
|
|
201
|
-
...title ? { title } : {},
|
|
202
|
-
...description ? { description } : {},
|
|
203
|
-
...examples ? { examples } : {},
|
|
204
|
-
..._default ? { default: _default } : {},
|
|
205
|
-
...see ? { see } : {},
|
|
206
|
-
...comment ? { comment } : {},
|
|
207
|
-
...meta ? { meta } : {}
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function decorateNode(node) {
|
|
211
|
-
const { jsDoc } = node;
|
|
212
|
-
const titleAnnotation = extractTitle(node);
|
|
213
|
-
if (jsDoc && jsDoc.length) {
|
|
214
|
-
const first = jsDoc[0];
|
|
215
|
-
return mergeAnnotations([
|
|
216
|
-
extractDescription(stringifyDoc(first.comment)),
|
|
217
|
-
titleAnnotation,
|
|
218
|
-
extractTags(first.tags ?? [])
|
|
219
|
-
]);
|
|
220
|
-
}
|
|
221
|
-
return titleAnnotation;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/ts-helpers.ts
|
|
225
|
-
var import_typescript3 = __toESM(require("typescript"));
|
|
226
|
-
|
|
227
51
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/type-checks.ts
|
|
228
|
-
var import_typescript2 = __toESM(require("typescript"));
|
|
229
|
-
function isOptionalProperty(node) {
|
|
230
|
-
return node.questionToken?.kind === import_typescript2.default.SyntaxKind.QuestionToken;
|
|
231
|
-
}
|
|
232
|
-
function isGenericInterfaceDeclaration(node) {
|
|
233
|
-
const length = node.typeParameters?.length;
|
|
234
|
-
return length ? length > 0 : false;
|
|
235
|
-
}
|
|
236
|
-
function isGenericTypeDeclaration(node) {
|
|
237
|
-
const length = node.typeParameters?.length;
|
|
238
|
-
return length ? length > 0 : false;
|
|
239
|
-
}
|
|
240
|
-
function isTypeReferenceGeneric(node, typeChecker) {
|
|
241
|
-
const symbol = typeChecker.getSymbolAtLocation(node.typeName);
|
|
242
|
-
if (symbol && symbol.declarations) {
|
|
243
|
-
return symbol.declarations[0].kind === import_typescript2.default.SyntaxKind.TypeParameter;
|
|
244
|
-
}
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
function isTopLevelDeclaration(node) {
|
|
248
|
-
return node.kind === import_typescript2.default.SyntaxKind.InterfaceDeclaration || node.kind === import_typescript2.default.SyntaxKind.TypeAliasDeclaration;
|
|
249
|
-
}
|
|
250
|
-
function isTopLevelNode(node) {
|
|
251
|
-
return node.kind === import_typescript2.default.SyntaxKind.InterfaceDeclaration || node.kind === import_typescript2.default.SyntaxKind.TypeAliasDeclaration || node.kind === import_typescript2.default.SyntaxKind.VariableStatement;
|
|
252
|
-
}
|
|
253
52
|
function isGenericNodeType(nt) {
|
|
254
53
|
return nt.genericTokens?.length > 0;
|
|
255
54
|
}
|
|
@@ -295,12 +94,8 @@ function isNamedType(node) {
|
|
|
295
94
|
|
|
296
95
|
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/validation-helpers.ts
|
|
297
96
|
function propertyToTuple(node) {
|
|
298
|
-
let key = node.children?.[0].value;
|
|
299
|
-
if (key.includes("-")) {
|
|
300
|
-
key = `'${key}'`;
|
|
301
|
-
}
|
|
302
97
|
return {
|
|
303
|
-
key,
|
|
98
|
+
key: node.children?.[0].value,
|
|
304
99
|
value: node.children?.[1]
|
|
305
100
|
};
|
|
306
101
|
}
|
|
@@ -435,89 +230,20 @@ function computeEffectiveObject(base, operand, errorOnOverlap = true) {
|
|
|
435
230
|
return newObject;
|
|
436
231
|
}
|
|
437
232
|
|
|
438
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/
|
|
439
|
-
function
|
|
440
|
-
return import_typescript3.default.isOptionalTypeNode(node) ? node.type : node;
|
|
441
|
-
}
|
|
442
|
-
function isExportedDeclaration(node) {
|
|
443
|
-
const modifiers = import_typescript3.default.canHaveModifiers(node) ? import_typescript3.default.getModifiers(node) : void 0;
|
|
444
|
-
if (modifiers) {
|
|
445
|
-
return modifiers.some((m) => m.kind === import_typescript3.default.SyntaxKind.ExportKeyword);
|
|
446
|
-
}
|
|
447
|
-
return false;
|
|
448
|
-
}
|
|
449
|
-
function isNodeExported(node) {
|
|
450
|
-
return (import_typescript3.default.getCombinedModifierFlags(node) & import_typescript3.default.ModifierFlags.Export) !== 0 || !!node.parent && node.parent.kind === import_typescript3.default.SyntaxKind.SourceFile;
|
|
451
|
-
}
|
|
452
|
-
function getReferencedType(node, typeChecker) {
|
|
453
|
-
let symbol = typeChecker.getSymbolAtLocation(node.typeName);
|
|
454
|
-
if (symbol && (symbol.flags & import_typescript3.default.SymbolFlags.Alias) === import_typescript3.default.SymbolFlags.Alias) {
|
|
455
|
-
symbol = typeChecker.getAliasedSymbol(symbol);
|
|
456
|
-
}
|
|
457
|
-
const varDecl = symbol?.declarations?.[0];
|
|
458
|
-
if (varDecl && (import_typescript3.default.isInterfaceDeclaration(varDecl) || import_typescript3.default.isTypeAliasDeclaration(varDecl))) {
|
|
459
|
-
return { declaration: varDecl, exported: isNodeExported(varDecl) };
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
function isTypeScriptLibType(node, typeChecker) {
|
|
463
|
-
let symbol = typeChecker.getSymbolAtLocation(node.typeName);
|
|
464
|
-
if (!symbol) return false;
|
|
465
|
-
if ((symbol.flags & import_typescript3.default.SymbolFlags.Alias) === import_typescript3.default.SymbolFlags.Alias) {
|
|
466
|
-
symbol = typeChecker.getAliasedSymbol(symbol);
|
|
467
|
-
}
|
|
468
|
-
const declarations = symbol.getDeclarations();
|
|
469
|
-
if (!declarations || declarations.length === 0) return false;
|
|
470
|
-
return declarations.some((decl) => {
|
|
471
|
-
const sourceFile = decl.getSourceFile();
|
|
472
|
-
if (!sourceFile) return false;
|
|
473
|
-
const filePath = sourceFile.fileName;
|
|
474
|
-
return filePath.includes("/typescript/lib/") || filePath.includes("\\typescript\\lib\\") || filePath.endsWith(".d.ts") && filePath.includes("lib.");
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
function getStringLiteralsFromUnion(node) {
|
|
478
|
-
if (import_typescript3.default.isUnionTypeNode(node)) {
|
|
479
|
-
return new Set(
|
|
480
|
-
node.types.map((type) => {
|
|
481
|
-
if (import_typescript3.default.isLiteralTypeNode(type) && import_typescript3.default.isStringLiteral(type.literal)) {
|
|
482
|
-
return type.literal.text;
|
|
483
|
-
}
|
|
484
|
-
return "";
|
|
485
|
-
})
|
|
486
|
-
);
|
|
487
|
-
}
|
|
488
|
-
if (import_typescript3.default.isLiteralTypeNode(node) && import_typescript3.default.isStringLiteral(node.literal)) {
|
|
489
|
-
return /* @__PURE__ */ new Set([node.literal.text]);
|
|
490
|
-
}
|
|
491
|
-
return /* @__PURE__ */ new Set();
|
|
492
|
-
}
|
|
493
|
-
function buildTemplateRegex(node, typeChecker) {
|
|
494
|
-
let regex = node.head.text;
|
|
495
|
-
node.templateSpans.forEach((span) => {
|
|
496
|
-
let type = span.type.kind;
|
|
497
|
-
if (import_typescript3.default.isTypeReferenceNode(span.type)) {
|
|
498
|
-
let symbol = typeChecker.getSymbolAtLocation(
|
|
499
|
-
span.type.typeName
|
|
500
|
-
);
|
|
501
|
-
if (symbol && (symbol.flags & import_typescript3.default.SymbolFlags.Alias) === import_typescript3.default.SymbolFlags.Alias) {
|
|
502
|
-
symbol = typeChecker.getAliasedSymbol(symbol);
|
|
503
|
-
}
|
|
504
|
-
type = (symbol?.declarations?.[0]).type.kind;
|
|
505
|
-
}
|
|
506
|
-
if (type === import_typescript3.default.SyntaxKind.StringKeyword) {
|
|
507
|
-
regex += ".*";
|
|
508
|
-
} else if (type === import_typescript3.default.SyntaxKind.NumberKeyword) {
|
|
509
|
-
regex += "[0-9]*";
|
|
510
|
-
} else if (type === import_typescript3.default.SyntaxKind.BooleanKeyword) {
|
|
511
|
-
regex += "true|false";
|
|
512
|
-
}
|
|
513
|
-
regex += span.literal.text;
|
|
514
|
-
});
|
|
515
|
-
return regex;
|
|
516
|
-
}
|
|
517
|
-
function fillInGenerics(xlrNode, generics) {
|
|
233
|
+
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/xlr-helpers.ts
|
|
234
|
+
function fillInGenerics(xlrNode, generics, preferLocalGenerics = false) {
|
|
518
235
|
let localGenerics;
|
|
519
236
|
if (generics) {
|
|
520
237
|
localGenerics = new Map(generics);
|
|
238
|
+
if (preferLocalGenerics && isGenericNodeType(xlrNode)) {
|
|
239
|
+
xlrNode.genericTokens?.forEach((token) => {
|
|
240
|
+
const genericValue = token.default ?? token.constraints;
|
|
241
|
+
localGenerics.set(
|
|
242
|
+
token.symbol,
|
|
243
|
+
fillInGenerics(genericValue, localGenerics, preferLocalGenerics)
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
521
247
|
} else {
|
|
522
248
|
localGenerics = /* @__PURE__ */ new Map();
|
|
523
249
|
if (isGenericNodeType(xlrNode)) {
|
|
@@ -525,7 +251,7 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
525
251
|
const genericValue = token.default ?? token.constraints;
|
|
526
252
|
localGenerics.set(
|
|
527
253
|
token.symbol,
|
|
528
|
-
fillInGenerics(genericValue, localGenerics)
|
|
254
|
+
fillInGenerics(genericValue, localGenerics, preferLocalGenerics)
|
|
529
255
|
);
|
|
530
256
|
});
|
|
531
257
|
}
|
|
@@ -536,7 +262,7 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
536
262
|
...localGenerics.get(xlrNode.ref),
|
|
537
263
|
...xlrNode.genericArguments ? {
|
|
538
264
|
genericArguments: xlrNode.genericArguments.map(
|
|
539
|
-
(ga) => fillInGenerics(ga, localGenerics)
|
|
265
|
+
(ga) => fillInGenerics(ga, localGenerics, preferLocalGenerics)
|
|
540
266
|
)
|
|
541
267
|
} : {},
|
|
542
268
|
...xlrNode.title ? { title: xlrNode.title } : {},
|
|
@@ -549,7 +275,7 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
549
275
|
...xlrNode,
|
|
550
276
|
...xlrNode.genericArguments ? {
|
|
551
277
|
genericArguments: xlrNode.genericArguments.map(
|
|
552
|
-
(ga) => fillInGenerics(ga, localGenerics)
|
|
278
|
+
(ga) => fillInGenerics(ga, localGenerics, preferLocalGenerics)
|
|
553
279
|
)
|
|
554
280
|
} : {}
|
|
555
281
|
};
|
|
@@ -560,7 +286,7 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
560
286
|
const prop = xlrNode.properties[propName];
|
|
561
287
|
newProperties[propName] = {
|
|
562
288
|
required: prop.required,
|
|
563
|
-
node: fillInGenerics(prop.node, localGenerics)
|
|
289
|
+
node: fillInGenerics(prop.node, localGenerics, preferLocalGenerics)
|
|
564
290
|
};
|
|
565
291
|
});
|
|
566
292
|
return {
|
|
@@ -570,19 +296,39 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
570
296
|
genericTokens: xlrNode.genericTokens.map((token) => {
|
|
571
297
|
return {
|
|
572
298
|
...token,
|
|
573
|
-
constraints: token.constraints ? fillInGenerics(
|
|
574
|
-
|
|
299
|
+
constraints: token.constraints ? fillInGenerics(
|
|
300
|
+
token.constraints,
|
|
301
|
+
localGenerics,
|
|
302
|
+
preferLocalGenerics
|
|
303
|
+
) : void 0,
|
|
304
|
+
default: token.default ? fillInGenerics(
|
|
305
|
+
token.default,
|
|
306
|
+
localGenerics,
|
|
307
|
+
preferLocalGenerics
|
|
308
|
+
) : void 0
|
|
575
309
|
};
|
|
576
310
|
})
|
|
577
311
|
} : {},
|
|
578
|
-
extends: xlrNode.extends ? fillInGenerics(
|
|
579
|
-
|
|
312
|
+
extends: xlrNode.extends ? fillInGenerics(
|
|
313
|
+
xlrNode.extends,
|
|
314
|
+
localGenerics,
|
|
315
|
+
preferLocalGenerics
|
|
316
|
+
) : void 0,
|
|
317
|
+
additionalProperties: xlrNode.additionalProperties ? fillInGenerics(
|
|
318
|
+
xlrNode.additionalProperties,
|
|
319
|
+
localGenerics,
|
|
320
|
+
preferLocalGenerics
|
|
321
|
+
) : false
|
|
580
322
|
};
|
|
581
323
|
}
|
|
582
324
|
if (xlrNode.type === "array") {
|
|
583
325
|
return {
|
|
584
326
|
...xlrNode,
|
|
585
|
-
elementType: fillInGenerics(
|
|
327
|
+
elementType: fillInGenerics(
|
|
328
|
+
xlrNode.elementType,
|
|
329
|
+
localGenerics,
|
|
330
|
+
preferLocalGenerics
|
|
331
|
+
)
|
|
586
332
|
};
|
|
587
333
|
} else if (xlrNode.type === "or" || xlrNode.type === "and") {
|
|
588
334
|
let pointer;
|
|
@@ -594,25 +340,49 @@ function fillInGenerics(xlrNode, generics) {
|
|
|
594
340
|
return {
|
|
595
341
|
...xlrNode,
|
|
596
342
|
[xlrNode.type]: pointer.map((prop) => {
|
|
597
|
-
return fillInGenerics(prop, localGenerics);
|
|
343
|
+
return fillInGenerics(prop, localGenerics, preferLocalGenerics);
|
|
598
344
|
})
|
|
599
345
|
};
|
|
600
346
|
} else if (xlrNode.type === "record") {
|
|
601
347
|
return {
|
|
602
348
|
...xlrNode,
|
|
603
|
-
keyType: fillInGenerics(
|
|
604
|
-
|
|
349
|
+
keyType: fillInGenerics(
|
|
350
|
+
xlrNode.keyType,
|
|
351
|
+
localGenerics,
|
|
352
|
+
preferLocalGenerics
|
|
353
|
+
),
|
|
354
|
+
valueType: fillInGenerics(
|
|
355
|
+
xlrNode.valueType,
|
|
356
|
+
localGenerics,
|
|
357
|
+
preferLocalGenerics
|
|
358
|
+
)
|
|
605
359
|
};
|
|
606
360
|
} else if (xlrNode.type === "conditional") {
|
|
607
361
|
const filledInConditional = {
|
|
608
362
|
...xlrNode,
|
|
609
363
|
check: {
|
|
610
|
-
left: fillInGenerics(
|
|
611
|
-
|
|
364
|
+
left: fillInGenerics(
|
|
365
|
+
xlrNode.check.left,
|
|
366
|
+
localGenerics,
|
|
367
|
+
preferLocalGenerics
|
|
368
|
+
),
|
|
369
|
+
right: fillInGenerics(
|
|
370
|
+
xlrNode.check.right,
|
|
371
|
+
localGenerics,
|
|
372
|
+
preferLocalGenerics
|
|
373
|
+
)
|
|
612
374
|
},
|
|
613
375
|
value: {
|
|
614
|
-
true: fillInGenerics(
|
|
615
|
-
|
|
376
|
+
true: fillInGenerics(
|
|
377
|
+
xlrNode.value.true,
|
|
378
|
+
localGenerics,
|
|
379
|
+
preferLocalGenerics
|
|
380
|
+
),
|
|
381
|
+
false: fillInGenerics(
|
|
382
|
+
xlrNode.value.false,
|
|
383
|
+
localGenerics,
|
|
384
|
+
preferLocalGenerics
|
|
385
|
+
)
|
|
616
386
|
}
|
|
617
387
|
};
|
|
618
388
|
if (filledInConditional.check.left.type !== "ref" && filledInConditional.check.right.type !== "ref") {
|
|
@@ -706,250 +476,32 @@ function applyExcludeToNodeType(baseObject, filters) {
|
|
|
706
476
|
or: remainingMembers
|
|
707
477
|
};
|
|
708
478
|
}
|
|
709
|
-
|
|
710
|
-
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/documentation.ts
|
|
711
|
-
var import_typescript4 = __toESM(require("typescript"));
|
|
712
|
-
var { SymbolDisplayPartKind, displayPartsToString } = import_typescript4.default;
|
|
713
|
-
function insertBetweenElements(array, separator) {
|
|
714
|
-
return array.reduce((acc, item, index) => {
|
|
715
|
-
if (index === 0) {
|
|
716
|
-
return [item];
|
|
717
|
-
}
|
|
718
|
-
return [...acc, separator, item];
|
|
719
|
-
}, []);
|
|
720
|
-
}
|
|
721
|
-
function createTSDocString(node) {
|
|
722
|
-
if (node.type === "ref") {
|
|
723
|
-
return [
|
|
724
|
-
{
|
|
725
|
-
text: node.ref,
|
|
726
|
-
kind: SymbolDisplayPartKind.keyword
|
|
727
|
-
}
|
|
728
|
-
];
|
|
729
|
-
}
|
|
730
|
-
if (node.type === "or" || node.type === "and") {
|
|
731
|
-
const items = node.type === "and" ? node.and : node.or;
|
|
732
|
-
return insertBetweenElements(
|
|
733
|
-
items.map((subnode) => createTSDocString(subnode)),
|
|
734
|
-
[
|
|
735
|
-
{
|
|
736
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
737
|
-
text: node.type === "and" ? " & " : " | "
|
|
738
|
-
}
|
|
739
|
-
]
|
|
740
|
-
).flat();
|
|
741
|
-
}
|
|
742
|
-
if (node.type === "function") {
|
|
743
|
-
return [
|
|
744
|
-
{
|
|
745
|
-
kind: SymbolDisplayPartKind.keyword,
|
|
746
|
-
text: "function"
|
|
747
|
-
},
|
|
748
|
-
{
|
|
749
|
-
kind: SymbolDisplayPartKind.space,
|
|
750
|
-
text: " "
|
|
751
|
-
},
|
|
752
|
-
...node.name ? [{ text: node.name, kind: SymbolDisplayPartKind.methodName }] : [],
|
|
753
|
-
{
|
|
754
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
755
|
-
text: "("
|
|
756
|
-
},
|
|
757
|
-
...insertBetweenElements(
|
|
758
|
-
node.parameters.map((p) => {
|
|
759
|
-
if (p.name) {
|
|
760
|
-
return [
|
|
761
|
-
{
|
|
762
|
-
kind: SymbolDisplayPartKind.parameterName,
|
|
763
|
-
text: p.name
|
|
764
|
-
},
|
|
765
|
-
{
|
|
766
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
767
|
-
text: p.optional ? "?" : ""
|
|
768
|
-
},
|
|
769
|
-
{
|
|
770
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
771
|
-
text: ": "
|
|
772
|
-
},
|
|
773
|
-
...createTSDocString(p.type)
|
|
774
|
-
];
|
|
775
|
-
}
|
|
776
|
-
return createTSDocString(p.type);
|
|
777
|
-
}),
|
|
778
|
-
[
|
|
779
|
-
{
|
|
780
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
781
|
-
text: ", "
|
|
782
|
-
}
|
|
783
|
-
]
|
|
784
|
-
).flat(),
|
|
785
|
-
{
|
|
786
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
787
|
-
text: ")"
|
|
788
|
-
},
|
|
789
|
-
...node.returnType ? [
|
|
790
|
-
{
|
|
791
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
792
|
-
text: ": "
|
|
793
|
-
},
|
|
794
|
-
...createTSDocString(node.returnType)
|
|
795
|
-
] : []
|
|
796
|
-
];
|
|
797
|
-
}
|
|
798
|
-
if (node.type === "tuple") {
|
|
799
|
-
return [
|
|
800
|
-
{
|
|
801
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
802
|
-
text: "["
|
|
803
|
-
},
|
|
804
|
-
...insertBetweenElements(
|
|
805
|
-
node.elementTypes.map((t) => {
|
|
806
|
-
if (t.name) {
|
|
807
|
-
return [
|
|
808
|
-
{
|
|
809
|
-
kind: SymbolDisplayPartKind.propertyName,
|
|
810
|
-
text: t.name
|
|
811
|
-
},
|
|
812
|
-
{
|
|
813
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
814
|
-
text: ": "
|
|
815
|
-
},
|
|
816
|
-
...createTSDocString(t.type)
|
|
817
|
-
];
|
|
818
|
-
}
|
|
819
|
-
return createTSDocString(t.type);
|
|
820
|
-
}),
|
|
821
|
-
[
|
|
822
|
-
{
|
|
823
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
824
|
-
text: ", "
|
|
825
|
-
}
|
|
826
|
-
]
|
|
827
|
-
).flat(),
|
|
828
|
-
{
|
|
829
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
830
|
-
text: "]"
|
|
831
|
-
}
|
|
832
|
-
];
|
|
833
|
-
}
|
|
834
|
-
if (node.type === "array") {
|
|
835
|
-
return [
|
|
836
|
-
{
|
|
837
|
-
kind: SymbolDisplayPartKind.interfaceName,
|
|
838
|
-
text: "Array"
|
|
839
|
-
},
|
|
840
|
-
{
|
|
841
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
842
|
-
text: "<"
|
|
843
|
-
},
|
|
844
|
-
...createTSDocString(node.elementType),
|
|
845
|
-
{
|
|
846
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
847
|
-
text: ">"
|
|
848
|
-
}
|
|
849
|
-
];
|
|
850
|
-
}
|
|
851
|
-
if (node.type === "record") {
|
|
852
|
-
return [
|
|
853
|
-
{
|
|
854
|
-
kind: SymbolDisplayPartKind.interfaceName,
|
|
855
|
-
text: "Record"
|
|
856
|
-
},
|
|
857
|
-
{
|
|
858
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
859
|
-
text: "<"
|
|
860
|
-
},
|
|
861
|
-
...createTSDocString(node.keyType),
|
|
862
|
-
{
|
|
863
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
864
|
-
text: ", "
|
|
865
|
-
},
|
|
866
|
-
...createTSDocString(node.valueType),
|
|
867
|
-
{
|
|
868
|
-
kind: SymbolDisplayPartKind.punctuation,
|
|
869
|
-
text: ">"
|
|
870
|
-
}
|
|
871
|
-
];
|
|
872
|
-
}
|
|
873
|
-
if ((node.type === "string" || node.type === "boolean" || node.type === "number") && node.const !== void 0) {
|
|
874
|
-
return [
|
|
875
|
-
{
|
|
876
|
-
kind: SymbolDisplayPartKind.keyword,
|
|
877
|
-
text: typeof node.const === "string" ? `"${node.const}"` : String(node.const)
|
|
878
|
-
}
|
|
879
|
-
];
|
|
880
|
-
}
|
|
881
|
-
if (isPrimitiveTypeNode(node) && node.type !== "null") {
|
|
882
|
-
return [
|
|
883
|
-
{
|
|
884
|
-
kind: SymbolDisplayPartKind.keyword,
|
|
885
|
-
text: node.type
|
|
886
|
-
}
|
|
887
|
-
];
|
|
888
|
-
}
|
|
889
|
-
if (node.type === "object" && node.name) {
|
|
890
|
-
return [
|
|
891
|
-
{
|
|
892
|
-
kind: SymbolDisplayPartKind.interfaceName,
|
|
893
|
-
text: node.name
|
|
894
|
-
}
|
|
895
|
-
];
|
|
896
|
-
}
|
|
897
|
-
return [
|
|
898
|
-
{
|
|
899
|
-
kind: SymbolDisplayPartKind.localName,
|
|
900
|
-
text: node.type
|
|
901
|
-
}
|
|
902
|
-
];
|
|
903
|
-
}
|
|
904
|
-
function symbolDisplayToString(displayParts) {
|
|
905
|
-
return displayPartsToString(displayParts);
|
|
906
|
-
}
|
|
907
|
-
function createDocString(node) {
|
|
908
|
-
return symbolDisplayToString(createTSDocString(node));
|
|
909
|
-
}
|
|
910
479
|
// Annotate the CommonJS export names for ESM import in node:
|
|
911
480
|
0 && (module.exports = {
|
|
912
481
|
applyExcludeToNodeType,
|
|
913
482
|
applyPartialOrRequiredToNodeType,
|
|
914
483
|
applyPickOrOmitToNodeType,
|
|
915
|
-
buildTemplateRegex,
|
|
916
484
|
computeEffectiveObject,
|
|
917
485
|
computeExtends,
|
|
918
|
-
createDocString,
|
|
919
|
-
createTSDocString,
|
|
920
|
-
decorateNode,
|
|
921
486
|
fillInGenerics,
|
|
922
|
-
getReferencedType,
|
|
923
|
-
getStringLiteralsFromUnion,
|
|
924
487
|
isAndType,
|
|
925
488
|
isArrayType,
|
|
926
489
|
isBooleanType,
|
|
927
|
-
isExportedDeclaration,
|
|
928
|
-
isGenericInterfaceDeclaration,
|
|
929
490
|
isGenericNamedType,
|
|
930
491
|
isGenericNodeType,
|
|
931
|
-
isGenericTypeDeclaration,
|
|
932
492
|
isNamedType,
|
|
933
493
|
isNode,
|
|
934
|
-
isNodeExported,
|
|
935
494
|
isNonNullable,
|
|
936
495
|
isNumberType,
|
|
937
496
|
isObjectType,
|
|
938
|
-
isOptionalProperty,
|
|
939
497
|
isOrType,
|
|
940
498
|
isPrimitiveTypeNode,
|
|
941
499
|
isRecordType,
|
|
942
500
|
isRefType,
|
|
943
501
|
isStringType,
|
|
944
|
-
isTopLevelDeclaration,
|
|
945
|
-
isTopLevelNode,
|
|
946
|
-
isTypeReferenceGeneric,
|
|
947
|
-
isTypeScriptLibType,
|
|
948
502
|
makePropertyMap,
|
|
949
503
|
propertyToTuple,
|
|
950
504
|
resolveConditional,
|
|
951
|
-
resolveReferenceNode
|
|
952
|
-
symbolDisplayToString,
|
|
953
|
-
tsStripOptionalType
|
|
505
|
+
resolveReferenceNode
|
|
954
506
|
});
|
|
955
507
|
//# sourceMappingURL=index.cjs.map
|