@dereekb/dbx-components-mcp 14.17.0 → 14.18.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/dbx-components-mcp.js
CHANGED
|
@@ -10,7 +10,7 @@ var __export = (target, all) => {
|
|
|
10
10
|
// packages/dbx-components-mcp/package.json
|
|
11
11
|
var package_default = {
|
|
12
12
|
name: "@dereekb/dbx-components-mcp",
|
|
13
|
-
version: "14.
|
|
13
|
+
version: "14.18.0",
|
|
14
14
|
sideEffects: false,
|
|
15
15
|
type: "module",
|
|
16
16
|
bin: {
|
|
@@ -22,8 +22,8 @@ var package_default = {
|
|
|
22
22
|
"ts-morph": "^21.0.0"
|
|
23
23
|
},
|
|
24
24
|
peerDependencies: {
|
|
25
|
-
"@dereekb/dbx-cli": "14.
|
|
26
|
-
"@dereekb/util": "14.
|
|
25
|
+
"@dereekb/dbx-cli": "14.18.0",
|
|
26
|
+
"@dereekb/util": "14.18.0"
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -29882,8 +29882,135 @@ function readJsDocSummary(node) {
|
|
|
29882
29882
|
return result;
|
|
29883
29883
|
}
|
|
29884
29884
|
|
|
29885
|
+
// packages/dbx-cli/manifest-extract/src/lib/extract-handler-map.ts
|
|
29886
|
+
import { Node as Node24, Project as Project9 } from "ts-morph";
|
|
29887
|
+
var CALL_MODEL_HANDLER_MAP_PATH = "src/app/function/model/crud.functions.ts";
|
|
29888
|
+
var VERB_TOKENS = [
|
|
29889
|
+
{ token: "Create", verb: "create" },
|
|
29890
|
+
{ token: "Read", verb: "read" },
|
|
29891
|
+
{ token: "Update", verb: "update" },
|
|
29892
|
+
{ token: "Delete", verb: "delete" },
|
|
29893
|
+
{ token: "Query", verb: "query" },
|
|
29894
|
+
{ token: "Invoke", verb: "invoke" }
|
|
29895
|
+
];
|
|
29896
|
+
var SPECIFIER_HANDLER_CALLEE = "onCallSpecifierHandler";
|
|
29897
|
+
var UNRESOLVED_HANDLER_NAME = "(unresolved)";
|
|
29898
|
+
function extractCallModelHandlerMapFromSourceFile(sourceFile) {
|
|
29899
|
+
const verbsFound = [];
|
|
29900
|
+
const cells = [];
|
|
29901
|
+
const opaque = [];
|
|
29902
|
+
for (const stmt of sourceFile.getVariableStatements()) {
|
|
29903
|
+
for (const decl of stmt.getDeclarations()) {
|
|
29904
|
+
const verb = matchVerbFromConstName(decl.getName());
|
|
29905
|
+
const initializer = verb ? decl.getInitializer() : void 0;
|
|
29906
|
+
if (verb && initializer) {
|
|
29907
|
+
const mapLiteral = unwrapOuterExpressions(initializer);
|
|
29908
|
+
if (Node24.isObjectLiteralExpression(mapLiteral)) {
|
|
29909
|
+
verbsFound.push(verb);
|
|
29910
|
+
collectVerbMap({ verb, mapLiteral, cells, opaque });
|
|
29911
|
+
} else {
|
|
29912
|
+
opaque.push({ verb, reason: "verb_map_not_literal", line: decl.getStartLineNumber() });
|
|
29913
|
+
}
|
|
29914
|
+
}
|
|
29915
|
+
}
|
|
29916
|
+
}
|
|
29917
|
+
return { verbsFound, cells, opaque };
|
|
29918
|
+
}
|
|
29919
|
+
function matchVerbFromConstName(name) {
|
|
29920
|
+
let result;
|
|
29921
|
+
for (const { token, verb } of VERB_TOKENS) {
|
|
29922
|
+
if (name.endsWith(`${token}ModelMap`) || name.endsWith(`_${token.toUpperCase()}_MODEL_MAP`)) {
|
|
29923
|
+
result = verb;
|
|
29924
|
+
break;
|
|
29925
|
+
}
|
|
29926
|
+
}
|
|
29927
|
+
return result;
|
|
29928
|
+
}
|
|
29929
|
+
function collectVerbMap(input) {
|
|
29930
|
+
const { verb, mapLiteral, cells, opaque } = input;
|
|
29931
|
+
for (const prop of mapLiteral.getProperties()) {
|
|
29932
|
+
const line = prop.getStartLineNumber();
|
|
29933
|
+
const model = Node24.isPropertyAssignment(prop) ? readPropertyKey(prop) : void 0;
|
|
29934
|
+
const value = Node24.isPropertyAssignment(prop) ? prop.getInitializer() : void 0;
|
|
29935
|
+
if (Node24.isShorthandPropertyAssignment(prop)) {
|
|
29936
|
+
const name = prop.getName();
|
|
29937
|
+
cells.push({ model: name, verb, handlerName: name, line, reference: prop.getNameNode() });
|
|
29938
|
+
} else if (model !== void 0 && value !== void 0) {
|
|
29939
|
+
collectModelHandler({ verb, model, value, line, cells, opaque });
|
|
29940
|
+
} else {
|
|
29941
|
+
opaque.push({ verb, reason: "verb_map_member", line });
|
|
29942
|
+
}
|
|
29943
|
+
}
|
|
29944
|
+
}
|
|
29945
|
+
function collectModelHandler(input) {
|
|
29946
|
+
const { verb, model, value, line, cells, opaque } = input;
|
|
29947
|
+
const handler = unwrapOuterExpressions(value);
|
|
29948
|
+
if (Node24.isCallExpression(handler) && handler.getExpression().getText().endsWith(SPECIFIER_HANDLER_CALLEE)) {
|
|
29949
|
+
const firstArg = handler.getArguments().at(0);
|
|
29950
|
+
const config = firstArg ? unwrapOuterExpressions(firstArg) : void 0;
|
|
29951
|
+
if (config && Node24.isObjectLiteralExpression(config)) {
|
|
29952
|
+
collectSpecifierMap({ verb, model, config, line, cells, opaque });
|
|
29953
|
+
} else {
|
|
29954
|
+
opaque.push({ verb, model, reason: "specifier_config_not_literal", line });
|
|
29955
|
+
}
|
|
29956
|
+
} else {
|
|
29957
|
+
const handlerName = readBareHandlerName(handler);
|
|
29958
|
+
if (handlerName) {
|
|
29959
|
+
cells.push({ model, verb, handlerName, line, reference: handler });
|
|
29960
|
+
}
|
|
29961
|
+
if (!Node24.isIdentifier(handler)) {
|
|
29962
|
+
opaque.push({ verb, model, reason: "model_handler_expression", line });
|
|
29963
|
+
}
|
|
29964
|
+
}
|
|
29965
|
+
}
|
|
29966
|
+
function collectSpecifierMap(input) {
|
|
29967
|
+
const { verb, model, config, line, cells, opaque } = input;
|
|
29968
|
+
for (const prop of config.getProperties()) {
|
|
29969
|
+
const specifier = Node24.isPropertyAssignment(prop) ? readPropertyKey(prop) : void 0;
|
|
29970
|
+
const value = Node24.isPropertyAssignment(prop) ? prop.getInitializer() : void 0;
|
|
29971
|
+
if (Node24.isShorthandPropertyAssignment(prop)) {
|
|
29972
|
+
const name = prop.getName();
|
|
29973
|
+
cells.push({ model, verb, specifier: name, handlerName: name, line, reference: prop.getNameNode() });
|
|
29974
|
+
} else if (specifier !== void 0 && value !== void 0) {
|
|
29975
|
+
const handler = unwrapOuterExpressions(value);
|
|
29976
|
+
cells.push({ model, verb, specifier, handlerName: readBareHandlerName(handler) ?? UNRESOLVED_HANDLER_NAME, line, reference: handler });
|
|
29977
|
+
} else {
|
|
29978
|
+
opaque.push({ verb, model, reason: "specifier_config_member", line: prop.getStartLineNumber() });
|
|
29979
|
+
}
|
|
29980
|
+
}
|
|
29981
|
+
}
|
|
29982
|
+
function readPropertyKey(prop) {
|
|
29983
|
+
const nameNode = prop.getNameNode();
|
|
29984
|
+
let result;
|
|
29985
|
+
if (Node24.isStringLiteral(nameNode) || Node24.isNoSubstitutionTemplateLiteral(nameNode)) {
|
|
29986
|
+
result = nameNode.getLiteralValue();
|
|
29987
|
+
} else if (!Node24.isComputedPropertyName(nameNode)) {
|
|
29988
|
+
result = nameNode.getText();
|
|
29989
|
+
}
|
|
29990
|
+
return result;
|
|
29991
|
+
}
|
|
29992
|
+
function readBareHandlerName(node) {
|
|
29993
|
+
let result;
|
|
29994
|
+
if (Node24.isIdentifier(node)) {
|
|
29995
|
+
result = node.getText();
|
|
29996
|
+
} else {
|
|
29997
|
+
const text = node.getText().split(/\s|\(/)[0];
|
|
29998
|
+
if (/^[A-Za-z_]\w*$/.test(text)) {
|
|
29999
|
+
result = text;
|
|
30000
|
+
}
|
|
30001
|
+
}
|
|
30002
|
+
return result;
|
|
30003
|
+
}
|
|
30004
|
+
function unwrapOuterExpressions(node) {
|
|
30005
|
+
let current = node;
|
|
30006
|
+
while (Node24.isAsExpression(current) || Node24.isSatisfiesExpression(current) || Node24.isTypeAssertion(current) || Node24.isParenthesizedExpression(current) || Node24.isNonNullExpression(current)) {
|
|
30007
|
+
current = current.getExpression();
|
|
30008
|
+
}
|
|
30009
|
+
return current;
|
|
30010
|
+
}
|
|
30011
|
+
|
|
29885
30012
|
// packages/dbx-cli/manifest-extract/src/lib/extract-models.ts
|
|
29886
|
-
import { Node as
|
|
30013
|
+
import { Node as Node25, SyntaxKind as SyntaxKind10, Project as Project10 } from "ts-morph";
|
|
29887
30014
|
var READ_LEVEL_VALUES2 = /* @__PURE__ */ new Set(["system", "owner", "admin-only", "permissions"]);
|
|
29888
30015
|
var SERVICE_FACTORY_TAG = "dbxModelServiceFactory";
|
|
29889
30016
|
var MCP_TOOL_NAME_SEGMENT_TAG = "dbxModelMcpToolNameSegment";
|
|
@@ -29907,7 +30034,7 @@ var FIELDS_LITERAL_KEY = "fields";
|
|
|
29907
30034
|
var OBJECT_FIELD_KEY = "objectField";
|
|
29908
30035
|
var FIRESTORE_FIELD_KEY = "firestoreField";
|
|
29909
30036
|
function extractModelsFromSource(input) {
|
|
29910
|
-
const project = new
|
|
30037
|
+
const project = new Project10({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
29911
30038
|
const sourceFile = project.createSourceFile(input.name, input.text, { overwrite: true });
|
|
29912
30039
|
const identities = readIdentities(sourceFile);
|
|
29913
30040
|
const interfaces = readInterfaces(sourceFile);
|
|
@@ -29925,7 +30052,7 @@ function readIdentities(sourceFile) {
|
|
|
29925
30052
|
if (!statement.isExported()) continue;
|
|
29926
30053
|
for (const decl of statement.getDeclarations()) {
|
|
29927
30054
|
const initializer = decl.getInitializer();
|
|
29928
|
-
if (initializer &&
|
|
30055
|
+
if (initializer && Node25.isCallExpression(initializer)) {
|
|
29929
30056
|
if (initializer.getExpression().getText() !== IDENTITY_FN) continue;
|
|
29930
30057
|
const parsed = parseFirestoreModelIdentityArgs(initializer.getArguments());
|
|
29931
30058
|
if (parsed) {
|
|
@@ -29971,12 +30098,12 @@ function parseDeclaredIdentityType(typeNode) {
|
|
|
29971
30098
|
function readNamedTypeNode(typeNode) {
|
|
29972
30099
|
let result;
|
|
29973
30100
|
if (typeNode) {
|
|
29974
|
-
if (
|
|
30101
|
+
if (Node25.isImportTypeNode(typeNode)) {
|
|
29975
30102
|
const qualifier = typeNode.getQualifier();
|
|
29976
30103
|
if (qualifier) {
|
|
29977
30104
|
result = { typeName: qualifier.getText().split(".").pop() ?? "", args: typeNode.getTypeArguments() };
|
|
29978
30105
|
}
|
|
29979
|
-
} else if (
|
|
30106
|
+
} else if (Node25.isTypeReference(typeNode)) {
|
|
29980
30107
|
result = { typeName: typeNode.getTypeName().getText().split(".").pop() ?? "", args: typeNode.getTypeArguments() };
|
|
29981
30108
|
}
|
|
29982
30109
|
}
|
|
@@ -29984,9 +30111,9 @@ function readNamedTypeNode(typeNode) {
|
|
|
29984
30111
|
}
|
|
29985
30112
|
function readLiteralTypeText(node) {
|
|
29986
30113
|
let result;
|
|
29987
|
-
if (node &&
|
|
30114
|
+
if (node && Node25.isLiteralTypeNode(node)) {
|
|
29988
30115
|
const literal = node.getLiteral();
|
|
29989
|
-
if (
|
|
30116
|
+
if (Node25.isStringLiteral(literal)) {
|
|
29990
30117
|
result = literal.getLiteralText();
|
|
29991
30118
|
}
|
|
29992
30119
|
}
|
|
@@ -30148,22 +30275,22 @@ function readSingleItemCollections(sourceFile) {
|
|
|
30148
30275
|
}
|
|
30149
30276
|
function readCalleeName(call) {
|
|
30150
30277
|
const expression = call.getExpression();
|
|
30151
|
-
return
|
|
30278
|
+
return Node25.isPropertyAccessExpression(expression) ? expression.getName() : expression.getText();
|
|
30152
30279
|
}
|
|
30153
30280
|
function buildSingleItemCollection(call, root) {
|
|
30154
30281
|
let result;
|
|
30155
30282
|
const args = call.getArguments();
|
|
30156
30283
|
if (args.length > 0) {
|
|
30157
30284
|
const config = args[0];
|
|
30158
|
-
if (
|
|
30285
|
+
if (Node25.isObjectLiteralExpression(config)) {
|
|
30159
30286
|
const identityNode = readPropertyValue(config, MODEL_IDENTITY_KEY);
|
|
30160
|
-
if (identityNode &&
|
|
30287
|
+
if (identityNode && Node25.isIdentifier(identityNode)) {
|
|
30161
30288
|
const identifierNode = readPropertyValue(config, SINGLE_ITEM_IDENTIFIER_KEY);
|
|
30162
30289
|
result = {
|
|
30163
30290
|
identityConst: identityNode.getText(),
|
|
30164
30291
|
root,
|
|
30165
30292
|
documentId: readStringLiteralText(identifierNode),
|
|
30166
|
-
documentIdConstRef: identifierNode &&
|
|
30293
|
+
documentIdConstRef: identifierNode && Node25.isIdentifier(identifierNode) ? identifierNode.getText() : void 0,
|
|
30167
30294
|
explicitIdentifier: config.getProperty(SINGLE_ITEM_IDENTIFIER_KEY) !== void 0,
|
|
30168
30295
|
line: call.getStartLineNumber()
|
|
30169
30296
|
};
|
|
@@ -30187,10 +30314,10 @@ function readStringConstants(sourceFile) {
|
|
|
30187
30314
|
}
|
|
30188
30315
|
function readStringLiteralText(node) {
|
|
30189
30316
|
let current = node;
|
|
30190
|
-
while (current !== void 0 &&
|
|
30317
|
+
while (current !== void 0 && Node25.isAsExpression(current)) {
|
|
30191
30318
|
current = current.getExpression();
|
|
30192
30319
|
}
|
|
30193
|
-
return current !== void 0 && (
|
|
30320
|
+
return current !== void 0 && (Node25.isStringLiteral(current) || Node25.isNoSubstitutionTemplateLiteral(current)) ? current.getLiteralText() : void 0;
|
|
30194
30321
|
}
|
|
30195
30322
|
function readConverters(sourceFile) {
|
|
30196
30323
|
const out = [];
|
|
@@ -30198,7 +30325,7 @@ function readConverters(sourceFile) {
|
|
|
30198
30325
|
if (!statement.isExported()) continue;
|
|
30199
30326
|
for (const decl of statement.getDeclarations()) {
|
|
30200
30327
|
const initializer = decl.getInitializer();
|
|
30201
|
-
if (!initializer || !
|
|
30328
|
+
if (!initializer || !Node25.isCallExpression(initializer)) continue;
|
|
30202
30329
|
const factory = initializer.getExpression().getText();
|
|
30203
30330
|
if (!isConverterFactoryName(factory)) continue;
|
|
30204
30331
|
const interfaceName = readGenericInterfaceName(initializer);
|
|
@@ -30232,13 +30359,13 @@ function readConverterFields2(call) {
|
|
|
30232
30359
|
let result;
|
|
30233
30360
|
if (args.length > 0) {
|
|
30234
30361
|
const config = args[0];
|
|
30235
|
-
if (
|
|
30362
|
+
if (Node25.isObjectLiteralExpression(config)) {
|
|
30236
30363
|
let fieldsLiteral;
|
|
30237
30364
|
if (fnName === SNAPSHOT_FN) {
|
|
30238
30365
|
fieldsLiteral = readObjectProperty(config, FIELDS_LITERAL_KEY);
|
|
30239
30366
|
} else {
|
|
30240
30367
|
const objectField = readPropertyValue(config, OBJECT_FIELD_KEY);
|
|
30241
|
-
if (objectField &&
|
|
30368
|
+
if (objectField && Node25.isObjectLiteralExpression(objectField)) {
|
|
30242
30369
|
fieldsLiteral = readObjectProperty(objectField, FIELDS_LITERAL_KEY);
|
|
30243
30370
|
}
|
|
30244
30371
|
}
|
|
@@ -30252,7 +30379,7 @@ function readConverterFields2(call) {
|
|
|
30252
30379
|
function readFieldEntries2(fields) {
|
|
30253
30380
|
const out = [];
|
|
30254
30381
|
for (const property of fields.getProperties()) {
|
|
30255
|
-
if (
|
|
30382
|
+
if (Node25.isPropertyAssignment(property)) {
|
|
30256
30383
|
const initializer = property.getInitializer();
|
|
30257
30384
|
const converterText = initializer ? initializer.getText().replaceAll(/\s+/g, " ").trim() : "";
|
|
30258
30385
|
const nested = initializer ? readNestedFromExpression(initializer) : void 0;
|
|
@@ -30263,7 +30390,7 @@ function readFieldEntries2(fields) {
|
|
|
30263
30390
|
nestedConverterInline: nested?.inline,
|
|
30264
30391
|
nestedIsArray: nested?.isArray
|
|
30265
30392
|
});
|
|
30266
|
-
} else if (
|
|
30393
|
+
} else if (Node25.isShorthandPropertyAssignment(property)) {
|
|
30267
30394
|
const name = property.getName();
|
|
30268
30395
|
out.push({ key: name, converter: name });
|
|
30269
30396
|
}
|
|
@@ -30272,7 +30399,7 @@ function readFieldEntries2(fields) {
|
|
|
30272
30399
|
}
|
|
30273
30400
|
function readNestedFromExpression(expr) {
|
|
30274
30401
|
let result;
|
|
30275
|
-
if (
|
|
30402
|
+
if (Node25.isCallExpression(expr)) {
|
|
30276
30403
|
const fnName = expr.getExpression().getText();
|
|
30277
30404
|
if (fnName === SUB_OBJECT_FN || fnName === OBJECT_ARRAY_FN) {
|
|
30278
30405
|
result = readNestedConverterCall(expr, fnName);
|
|
@@ -30285,7 +30412,7 @@ function readNestedConverterCall(call, fnName) {
|
|
|
30285
30412
|
const args = call.getArguments();
|
|
30286
30413
|
if (args.length > 0) {
|
|
30287
30414
|
const config = args[0];
|
|
30288
|
-
if (
|
|
30415
|
+
if (Node25.isObjectLiteralExpression(config)) {
|
|
30289
30416
|
const valueNode = readPropertyValue(config, OBJECT_FIELD_KEY) ?? readPropertyValue(config, FIRESTORE_FIELD_KEY);
|
|
30290
30417
|
if (valueNode) {
|
|
30291
30418
|
result = buildNestedConverterMatch({ objectField: valueNode, call, fnName });
|
|
@@ -30298,9 +30425,9 @@ function buildNestedConverterMatch(input) {
|
|
|
30298
30425
|
const { objectField, call, fnName } = input;
|
|
30299
30426
|
const isArray = fnName === OBJECT_ARRAY_FN;
|
|
30300
30427
|
let result;
|
|
30301
|
-
if (
|
|
30428
|
+
if (Node25.isIdentifier(objectField)) {
|
|
30302
30429
|
result = { ref: objectField.getText(), isArray };
|
|
30303
|
-
} else if (
|
|
30430
|
+
} else if (Node25.isObjectLiteralExpression(objectField)) {
|
|
30304
30431
|
const fieldsLiteral = readObjectProperty(objectField, FIELDS_LITERAL_KEY);
|
|
30305
30432
|
if (fieldsLiteral) {
|
|
30306
30433
|
result = {
|
|
@@ -30314,7 +30441,7 @@ function buildNestedConverterMatch(input) {
|
|
|
30314
30441
|
isArray
|
|
30315
30442
|
};
|
|
30316
30443
|
}
|
|
30317
|
-
} else if (
|
|
30444
|
+
} else if (Node25.isCallExpression(objectField)) {
|
|
30318
30445
|
const nested = readNestedFromExpression(objectField);
|
|
30319
30446
|
if (nested) {
|
|
30320
30447
|
result = { ...nested, isArray };
|
|
@@ -30325,16 +30452,16 @@ function buildNestedConverterMatch(input) {
|
|
|
30325
30452
|
function readPropertyValue(literal, key) {
|
|
30326
30453
|
const property = literal.getProperty(key);
|
|
30327
30454
|
let result;
|
|
30328
|
-
if (property &&
|
|
30455
|
+
if (property && Node25.isPropertyAssignment(property)) {
|
|
30329
30456
|
result = property.getInitializer();
|
|
30330
|
-
} else if (property &&
|
|
30457
|
+
} else if (property && Node25.isShorthandPropertyAssignment(property)) {
|
|
30331
30458
|
result = property.getNameNode();
|
|
30332
30459
|
}
|
|
30333
30460
|
return result;
|
|
30334
30461
|
}
|
|
30335
30462
|
function readObjectProperty(literal, key) {
|
|
30336
30463
|
const value = readPropertyValue(literal, key);
|
|
30337
|
-
return value &&
|
|
30464
|
+
return value && Node25.isObjectLiteralExpression(value) ? value : void 0;
|
|
30338
30465
|
}
|
|
30339
30466
|
function readEnums(sourceFile) {
|
|
30340
30467
|
const out = [];
|
|
@@ -30528,13 +30655,12 @@ async function extractDeclaredEntries(roots) {
|
|
|
30528
30655
|
|
|
30529
30656
|
// packages/dbx-cli/validate/src/lib/model-api-validate-app/extract-handlers.ts
|
|
30530
30657
|
import { join as join10 } from "node:path";
|
|
30531
|
-
import { Node as Node27 } from "ts-morph";
|
|
30532
30658
|
|
|
30533
30659
|
// packages/dbx-cli/validate/src/lib/_core/_validate/ast.ts
|
|
30534
30660
|
import { posix as posix2 } from "node:path";
|
|
30535
30661
|
import {
|
|
30536
|
-
Node as
|
|
30537
|
-
Project as
|
|
30662
|
+
Node as Node26,
|
|
30663
|
+
Project as Project11,
|
|
30538
30664
|
SyntaxKind as SyntaxKind11,
|
|
30539
30665
|
VariableDeclarationKind
|
|
30540
30666
|
} from "ts-morph";
|
|
@@ -30543,7 +30669,7 @@ var API_VIRTUAL_PREFIX = "__api__/";
|
|
|
30543
30669
|
var DEREEKB_MODULE_PREFIX = "@dereekb/";
|
|
30544
30670
|
// @__NO_SIDE_EFFECTS__
|
|
30545
30671
|
function buildInMemoryProject(input) {
|
|
30546
|
-
const project = new
|
|
30672
|
+
const project = new Project11({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
30547
30673
|
const componentSources = [];
|
|
30548
30674
|
const apiSources = [];
|
|
30549
30675
|
for (const file of input.component.files) {
|
|
@@ -30563,35 +30689,35 @@ function componentRelPath(sourceFile) {
|
|
|
30563
30689
|
}
|
|
30564
30690
|
function unwrapAsExpressions(node) {
|
|
30565
30691
|
let current = node;
|
|
30566
|
-
while (current &&
|
|
30692
|
+
while (current && Node26.isAsExpression(current)) {
|
|
30567
30693
|
current = current.getExpression();
|
|
30568
30694
|
}
|
|
30569
30695
|
return current;
|
|
30570
30696
|
}
|
|
30571
|
-
function
|
|
30697
|
+
function unwrapOuterExpressions2(node) {
|
|
30572
30698
|
let current = node;
|
|
30573
|
-
while (current && (
|
|
30699
|
+
while (current && (Node26.isAsExpression(current) || Node26.isSatisfiesExpression(current) || Node26.isTypeAssertion(current) || Node26.isParenthesizedExpression(current) || Node26.isNonNullExpression(current))) {
|
|
30574
30700
|
current = current.getExpression();
|
|
30575
30701
|
}
|
|
30576
30702
|
return current;
|
|
30577
30703
|
}
|
|
30578
30704
|
function asObjectLiteral(node) {
|
|
30579
30705
|
const inner = unwrapAsExpressions(node);
|
|
30580
|
-
if (inner &&
|
|
30706
|
+
if (inner && Node26.isObjectLiteralExpression(inner)) {
|
|
30581
30707
|
return inner;
|
|
30582
30708
|
}
|
|
30583
30709
|
return void 0;
|
|
30584
30710
|
}
|
|
30585
30711
|
function asArrayLiteral(node) {
|
|
30586
30712
|
const inner = unwrapAsExpressions(node);
|
|
30587
|
-
if (inner &&
|
|
30713
|
+
if (inner && Node26.isArrayLiteralExpression(inner)) {
|
|
30588
30714
|
return inner;
|
|
30589
30715
|
}
|
|
30590
30716
|
return void 0;
|
|
30591
30717
|
}
|
|
30592
30718
|
function readStringLiteralInitializer(decl) {
|
|
30593
30719
|
const initializer = unwrapAsExpressions(decl.getInitializer());
|
|
30594
|
-
if (initializer &&
|
|
30720
|
+
if (initializer && Node26.isStringLiteral(initializer)) {
|
|
30595
30721
|
return initializer.getLiteralText();
|
|
30596
30722
|
}
|
|
30597
30723
|
return void 0;
|
|
@@ -30603,10 +30729,10 @@ function typeAnnotationText(node) {
|
|
|
30603
30729
|
function getPropertyInitializer(obj, name) {
|
|
30604
30730
|
const prop = obj.getProperty(name);
|
|
30605
30731
|
if (!prop) return void 0;
|
|
30606
|
-
if (
|
|
30732
|
+
if (Node26.isPropertyAssignment(prop)) {
|
|
30607
30733
|
return prop.getInitializer();
|
|
30608
30734
|
}
|
|
30609
|
-
if (
|
|
30735
|
+
if (Node26.isShorthandPropertyAssignment(prop)) {
|
|
30610
30736
|
return prop.getNameNode();
|
|
30611
30737
|
}
|
|
30612
30738
|
return void 0;
|
|
@@ -30624,28 +30750,28 @@ function readStaticProperty(obj, name) {
|
|
|
30624
30750
|
return result;
|
|
30625
30751
|
}
|
|
30626
30752
|
function readStaticPropertyName(property) {
|
|
30627
|
-
const nameNode =
|
|
30753
|
+
const nameNode = Node26.isSpreadAssignment(property) ? void 0 : property.getNameNode();
|
|
30628
30754
|
let result;
|
|
30629
|
-
if (nameNode &&
|
|
30755
|
+
if (nameNode && Node26.isIdentifier(nameNode)) {
|
|
30630
30756
|
result = nameNode.getText();
|
|
30631
|
-
} else if (nameNode && (
|
|
30757
|
+
} else if (nameNode && (Node26.isStringLiteral(nameNode) || Node26.isNoSubstitutionTemplateLiteral(nameNode) || Node26.isNumericLiteral(nameNode))) {
|
|
30632
30758
|
result = nameNode.getLiteralText();
|
|
30633
30759
|
}
|
|
30634
30760
|
return result;
|
|
30635
30761
|
}
|
|
30636
30762
|
function readStaticPropertyValue(property) {
|
|
30637
30763
|
let result = { kind: "unknown" };
|
|
30638
|
-
if (
|
|
30764
|
+
if (Node26.isPropertyAssignment(property)) {
|
|
30639
30765
|
const value = property.getInitializer();
|
|
30640
30766
|
result = value ? { kind: "found", value } : { kind: "unknown" };
|
|
30641
|
-
} else if (
|
|
30767
|
+
} else if (Node26.isShorthandPropertyAssignment(property)) {
|
|
30642
30768
|
result = { kind: "found", value: property.getNameNode() };
|
|
30643
30769
|
}
|
|
30644
30770
|
return result;
|
|
30645
30771
|
}
|
|
30646
30772
|
function readStringProperty2(obj, name) {
|
|
30647
30773
|
const init = unwrapAsExpressions(getPropertyInitializer(obj, name));
|
|
30648
|
-
if (init &&
|
|
30774
|
+
if (init && Node26.isStringLiteral(init)) {
|
|
30649
30775
|
return init.getLiteralText();
|
|
30650
30776
|
}
|
|
30651
30777
|
return void 0;
|
|
@@ -30662,20 +30788,20 @@ function readBooleanProperty2(obj, name) {
|
|
|
30662
30788
|
}
|
|
30663
30789
|
function readIdentifierProperty(obj, name) {
|
|
30664
30790
|
const init = unwrapAsExpressions(getPropertyInitializer(obj, name));
|
|
30665
|
-
if (init &&
|
|
30791
|
+
if (init && Node26.isIdentifier(init)) {
|
|
30666
30792
|
return init.getText();
|
|
30667
30793
|
}
|
|
30668
30794
|
return void 0;
|
|
30669
30795
|
}
|
|
30670
30796
|
function findReturnExpression(fn) {
|
|
30671
|
-
if (!
|
|
30797
|
+
if (!Node26.isArrowFunction(fn) && !Node26.isFunctionDeclaration(fn) && !Node26.isFunctionExpression(fn)) {
|
|
30672
30798
|
return void 0;
|
|
30673
30799
|
}
|
|
30674
30800
|
const body = fn.getBody();
|
|
30675
30801
|
if (!body) return void 0;
|
|
30676
|
-
if (
|
|
30802
|
+
if (Node26.isBlock(body)) {
|
|
30677
30803
|
for (const stmt of body.getStatements()) {
|
|
30678
|
-
if (
|
|
30804
|
+
if (Node26.isReturnStatement(stmt)) {
|
|
30679
30805
|
return stmt.getExpression();
|
|
30680
30806
|
}
|
|
30681
30807
|
}
|
|
@@ -30685,9 +30811,9 @@ function findReturnExpression(fn) {
|
|
|
30685
30811
|
}
|
|
30686
30812
|
function findSoleReturnExpression(fn) {
|
|
30687
30813
|
let result;
|
|
30688
|
-
if (
|
|
30814
|
+
if (Node26.isArrowFunction(fn) || Node26.isFunctionDeclaration(fn) || Node26.isFunctionExpression(fn)) {
|
|
30689
30815
|
const body = fn.getBody();
|
|
30690
|
-
if (
|
|
30816
|
+
if (Node26.isBlock(body)) {
|
|
30691
30817
|
const returns = body.getDescendantsOfKind(SyntaxKind11.ReturnStatement).filter((x) => functionScopeOf(x) === fn);
|
|
30692
30818
|
result = returns.length === 1 && returns[0].getParent() === body ? returns[0].getExpression() : void 0;
|
|
30693
30819
|
} else {
|
|
@@ -30710,9 +30836,9 @@ function findLocalVariable(sf, name) {
|
|
|
30710
30836
|
function resolveObjectLiteralArgument(node, sf) {
|
|
30711
30837
|
const inner = unwrapAsExpressions(node);
|
|
30712
30838
|
let result;
|
|
30713
|
-
if (inner &&
|
|
30839
|
+
if (inner && Node26.isObjectLiteralExpression(inner)) {
|
|
30714
30840
|
result = inner;
|
|
30715
|
-
} else if (inner &&
|
|
30841
|
+
} else if (inner && Node26.isIdentifier(inner)) {
|
|
30716
30842
|
result = asObjectLiteral(findLocalVariable(sf, inner.getText())?.getInitializer());
|
|
30717
30843
|
}
|
|
30718
30844
|
return result;
|
|
@@ -30720,9 +30846,9 @@ function resolveObjectLiteralArgument(node, sf) {
|
|
|
30720
30846
|
function resolveArrayLiteralProperty(obj, name, sf) {
|
|
30721
30847
|
const init = unwrapAsExpressions(getPropertyInitializer(obj, name));
|
|
30722
30848
|
let result;
|
|
30723
|
-
if (init &&
|
|
30849
|
+
if (init && Node26.isArrayLiteralExpression(init)) {
|
|
30724
30850
|
result = init;
|
|
30725
|
-
} else if (init &&
|
|
30851
|
+
} else if (init && Node26.isIdentifier(init)) {
|
|
30726
30852
|
result = asArrayLiteral(findLocalVariable(sf, init.getText())?.getInitializer());
|
|
30727
30853
|
}
|
|
30728
30854
|
return result;
|
|
@@ -30731,7 +30857,7 @@ function sourceSideOf(sf) {
|
|
|
30731
30857
|
return sf.getFilePath().startsWith(`/${COMPONENT_VIRTUAL_PREFIX}`) ? "component" : "api";
|
|
30732
30858
|
}
|
|
30733
30859
|
function collectTypeofReferences(node, out) {
|
|
30734
|
-
if (
|
|
30860
|
+
if (Node26.isTypeQuery(node)) {
|
|
30735
30861
|
out.push(node.getExprName().getText());
|
|
30736
30862
|
return;
|
|
30737
30863
|
}
|
|
@@ -30767,14 +30893,14 @@ function readImportedReference(node, imports) {
|
|
|
30767
30893
|
const inner = unwrapAsExpressions(node);
|
|
30768
30894
|
const target = inner ? followLocalConstReference(inner, imports.bindingsByFilePath.get(inner.getSourceFile().getFilePath()), 0) : void 0;
|
|
30769
30895
|
let result;
|
|
30770
|
-
if (target &&
|
|
30896
|
+
if (target && Node26.isIdentifier(target)) {
|
|
30771
30897
|
const local = target.getText();
|
|
30772
30898
|
const declaration = target.getSourceFile().getImportDeclarations().find((imp) => !imp.isTypeOnly() && findNamedValueImport(imp, local));
|
|
30773
30899
|
const specifier = declaration ? findNamedValueImport(declaration, local) : void 0;
|
|
30774
30900
|
if (declaration && specifier && !isDeclaredValueName(target.getSourceFile(), local)) {
|
|
30775
30901
|
result = { name: specifier.getName(), moduleSpecifier: declaration.getModuleSpecifierValue(), text: local };
|
|
30776
30902
|
}
|
|
30777
|
-
} else if (target &&
|
|
30903
|
+
} else if (target && Node26.isPropertyAccessExpression(target) && Node26.isIdentifier(target.getExpression())) {
|
|
30778
30904
|
const ns = target.getExpression().getText();
|
|
30779
30905
|
const declaration = target.getSourceFile().getImportDeclarations().find((imp) => !imp.isTypeOnly() && imp.getNamespaceImport()?.getText() === ns);
|
|
30780
30906
|
if (declaration && !isDeclaredValueName(target.getSourceFile(), ns)) {
|
|
@@ -30793,27 +30919,27 @@ var MAX_LOCAL_CONST_HOPS = 4;
|
|
|
30793
30919
|
function isValueDeclarationName(identifier) {
|
|
30794
30920
|
const parent = identifier.getParent();
|
|
30795
30921
|
let result;
|
|
30796
|
-
if (
|
|
30922
|
+
if (Node26.isModuleDeclaration(parent)) {
|
|
30797
30923
|
result = true;
|
|
30798
30924
|
} else {
|
|
30799
|
-
const isNamed =
|
|
30925
|
+
const isNamed = Node26.isVariableDeclaration(parent) || Node26.isParameterDeclaration(parent) || Node26.isBindingElement(parent) || Node26.isFunctionDeclaration(parent) || Node26.isFunctionExpression(parent) || Node26.isClassDeclaration(parent) || Node26.isClassExpression(parent) || Node26.isEnumDeclaration(parent);
|
|
30800
30926
|
result = isNamed && parent.getNameNode() === identifier;
|
|
30801
30927
|
}
|
|
30802
30928
|
return result;
|
|
30803
30929
|
}
|
|
30804
30930
|
function isTypeDeclarationName(identifier) {
|
|
30805
30931
|
const parent = identifier.getParent();
|
|
30806
|
-
const isNamed =
|
|
30932
|
+
const isNamed = Node26.isTypeParameterDeclaration(parent) || Node26.isTypeAliasDeclaration(parent) || Node26.isInterfaceDeclaration(parent);
|
|
30807
30933
|
return isNamed && parent.getNameNode() === identifier;
|
|
30808
30934
|
}
|
|
30809
30935
|
function isImportedName(identifier) {
|
|
30810
30936
|
const parent = identifier.getParent();
|
|
30811
30937
|
let result = false;
|
|
30812
|
-
if (
|
|
30938
|
+
if (Node26.isImportSpecifier(parent)) {
|
|
30813
30939
|
result = (parent.getAliasNode() ?? parent.getNameNode()) === identifier;
|
|
30814
|
-
} else if (
|
|
30940
|
+
} else if (Node26.isImportClause(parent)) {
|
|
30815
30941
|
result = parent.getDefaultImport() === identifier;
|
|
30816
|
-
} else if (
|
|
30942
|
+
} else if (Node26.isNamespaceImport(parent) || Node26.isImportEqualsDeclaration(parent)) {
|
|
30817
30943
|
result = parent.getNameNode() === identifier;
|
|
30818
30944
|
}
|
|
30819
30945
|
return result;
|
|
@@ -30821,15 +30947,15 @@ function isImportedName(identifier) {
|
|
|
30821
30947
|
function lexicalScopeOf(statement) {
|
|
30822
30948
|
const holder = statement.getParent();
|
|
30823
30949
|
let result;
|
|
30824
|
-
if (
|
|
30950
|
+
if (Node26.isCaseClause(holder) || Node26.isDefaultClause(holder)) {
|
|
30825
30951
|
result = holder.getParentOrThrow();
|
|
30826
|
-
} else if (
|
|
30952
|
+
} else if (Node26.isBlock(holder) || Node26.isSourceFile(holder) || Node26.isModuleBlock(holder)) {
|
|
30827
30953
|
result = holder;
|
|
30828
30954
|
}
|
|
30829
30955
|
return result;
|
|
30830
30956
|
}
|
|
30831
30957
|
function functionScopeOf(node) {
|
|
30832
|
-
return node.getFirstAncestor((x) =>
|
|
30958
|
+
return node.getFirstAncestor((x) => Node26.isFunctionLikeDeclaration(x) || Node26.isFunctionExpression(x)) ?? node.getSourceFile();
|
|
30833
30959
|
}
|
|
30834
30960
|
function isWithinScope(node, scope) {
|
|
30835
30961
|
return scope.getPos() <= node.getPos() && node.getEnd() <= scope.getEnd();
|
|
@@ -30837,25 +30963,25 @@ function isWithinScope(node, scope) {
|
|
|
30837
30963
|
function isNamespaceExport(statement) {
|
|
30838
30964
|
const block = statement.getParent();
|
|
30839
30965
|
const namespace = block?.getParent();
|
|
30840
|
-
return
|
|
30966
|
+
return Node26.isModuleBlock(block) && Node26.isModuleDeclaration(namespace) && (Node26.isExportable(statement) && statement.hasExportKeyword() || namespace.isAmbient());
|
|
30841
30967
|
}
|
|
30842
30968
|
function blockingScopeOf(identifier) {
|
|
30843
30969
|
const declaration = identifier.getParentOrThrow();
|
|
30844
30970
|
let result;
|
|
30845
|
-
if (
|
|
30971
|
+
if (Node26.isParameterDeclaration(declaration)) {
|
|
30846
30972
|
result = declaration.getParentOrThrow();
|
|
30847
|
-
} else if (
|
|
30973
|
+
} else if (Node26.isFunctionExpression(declaration) || Node26.isClassExpression(declaration)) {
|
|
30848
30974
|
result = declaration;
|
|
30849
30975
|
} else {
|
|
30850
30976
|
const ancestors2 = declaration.getAncestors();
|
|
30851
|
-
result = ancestors2.find((x, i) =>
|
|
30977
|
+
result = ancestors2.find((x, i) => Node26.isFunctionLikeDeclaration(x) || Node26.isFunctionExpression(x) || Node26.isModuleBlock(x) && !isNamespaceExport(i === 0 ? declaration : ancestors2[i - 1])) ?? declaration.getSourceFile();
|
|
30852
30978
|
}
|
|
30853
30979
|
return result;
|
|
30854
30980
|
}
|
|
30855
30981
|
function readHeldReference(decl) {
|
|
30856
30982
|
const initializer = unwrapAsExpressions(decl.getInitializer());
|
|
30857
30983
|
let result;
|
|
30858
|
-
if (
|
|
30984
|
+
if (Node26.isIdentifier(initializer) || Node26.isPropertyAccessExpression(initializer) && Node26.isIdentifier(initializer.getExpression())) {
|
|
30859
30985
|
result = initializer;
|
|
30860
30986
|
}
|
|
30861
30987
|
return result;
|
|
@@ -30865,7 +30991,7 @@ function readConstBinding(decl) {
|
|
|
30865
30991
|
const scope = statement?.getDeclarationKind() === VariableDeclarationKind.Const && !isNamespaceExport(statement) ? lexicalScopeOf(statement) : void 0;
|
|
30866
30992
|
const reference = readHeldReference(decl);
|
|
30867
30993
|
let result;
|
|
30868
|
-
if (scope &&
|
|
30994
|
+
if (scope && Node26.isIdentifier(decl.getNameNode()) && reference) {
|
|
30869
30995
|
result = { scope, reference };
|
|
30870
30996
|
}
|
|
30871
30997
|
return result;
|
|
@@ -30936,13 +31062,13 @@ function readLocalValueBindings(sf) {
|
|
|
30936
31062
|
} else if (statement) {
|
|
30937
31063
|
scope = lexicalScopeOf(statement);
|
|
30938
31064
|
}
|
|
30939
|
-
if (scope &&
|
|
31065
|
+
if (scope && Node26.isIdentifier(decl.getNameNode())) {
|
|
30940
31066
|
add(decl.getName(), decl, scope);
|
|
30941
31067
|
}
|
|
30942
31068
|
}
|
|
30943
31069
|
for (const { name, declaration } of readModuleValueDeclarations(sf)) {
|
|
30944
31070
|
add(name, declaration, sf);
|
|
30945
|
-
for (const overload of
|
|
31071
|
+
for (const overload of Node26.isFunctionDeclaration(declaration) ? declaration.getOverloads() : []) {
|
|
30946
31072
|
declarations.add(overload);
|
|
30947
31073
|
}
|
|
30948
31074
|
}
|
|
@@ -30994,18 +31120,18 @@ function readCalleeName2(call, imports) {
|
|
|
30994
31120
|
const bindings = imports.bindingsByFilePath.get(call.getSourceFile().getFilePath());
|
|
30995
31121
|
const target = followLocalConstReference(call.getExpression(), bindings, 0);
|
|
30996
31122
|
let result;
|
|
30997
|
-
if (
|
|
31123
|
+
if (Node26.isIdentifier(target)) {
|
|
30998
31124
|
result = findVisibleBinding(target, bindings, "value")?.exportedName ?? target.getText();
|
|
30999
|
-
} else if (
|
|
31125
|
+
} else if (Node26.isPropertyAccessExpression(target)) {
|
|
31000
31126
|
const ns = target.getExpression();
|
|
31001
|
-
if (
|
|
31127
|
+
if (Node26.isIdentifier(ns) && findVisibleBinding(ns, bindings, "value")?.namespace) {
|
|
31002
31128
|
result = target.getName();
|
|
31003
31129
|
}
|
|
31004
31130
|
}
|
|
31005
31131
|
return result;
|
|
31006
31132
|
}
|
|
31007
31133
|
function followLocalConstReference(node, bindings, hops) {
|
|
31008
|
-
const reference =
|
|
31134
|
+
const reference = Node26.isIdentifier(node) && hops < MAX_LOCAL_CONST_HOPS ? findVisibleBinding(node, bindings, "value")?.reference : void 0;
|
|
31009
31135
|
return reference ? followLocalConstReference(reference, bindings, hops + 1) : node;
|
|
31010
31136
|
}
|
|
31011
31137
|
function findVisibleBinding(identifier, bindings, space) {
|
|
@@ -31023,11 +31149,11 @@ function resolveLocalValue(reference, imports) {
|
|
|
31023
31149
|
let result;
|
|
31024
31150
|
if (visible.length > 1) {
|
|
31025
31151
|
result = { kind: "ambiguous" };
|
|
31026
|
-
} else if (
|
|
31152
|
+
} else if (Node26.isVariableDeclaration(declaration)) {
|
|
31027
31153
|
result = { kind: "variable", declaration };
|
|
31028
|
-
} else if (
|
|
31154
|
+
} else if (Node26.isFunctionDeclaration(declaration)) {
|
|
31029
31155
|
result = { kind: "function", declaration };
|
|
31030
|
-
} else if (
|
|
31156
|
+
} else if (Node26.isImportSpecifier(declaration) || Node26.isImportClause(declaration)) {
|
|
31031
31157
|
result = { kind: "import", declaration };
|
|
31032
31158
|
} else {
|
|
31033
31159
|
result = { kind: "none" };
|
|
@@ -31035,29 +31161,29 @@ function resolveLocalValue(reference, imports) {
|
|
|
31035
31161
|
return result;
|
|
31036
31162
|
}
|
|
31037
31163
|
function resolveLocalObjectLiteral(node, imports) {
|
|
31038
|
-
const inner =
|
|
31164
|
+
const inner = unwrapOuterExpressions2(node);
|
|
31039
31165
|
let result;
|
|
31040
|
-
if (inner &&
|
|
31166
|
+
if (inner && Node26.isObjectLiteralExpression(inner)) {
|
|
31041
31167
|
result = inner;
|
|
31042
|
-
} else if (inner &&
|
|
31168
|
+
} else if (inner && Node26.isIdentifier(inner)) {
|
|
31043
31169
|
const binding = resolveLocalVariable(inner, imports);
|
|
31044
31170
|
if (binding.kind === "variable" && binding.declaration.getVariableStatement()?.getDeclarationKind() === VariableDeclarationKind.Const) {
|
|
31045
|
-
const initializer =
|
|
31046
|
-
result = initializer &&
|
|
31171
|
+
const initializer = unwrapOuterExpressions2(binding.declaration.getInitializer());
|
|
31172
|
+
result = initializer && Node26.isObjectLiteralExpression(initializer) ? initializer : void 0;
|
|
31047
31173
|
}
|
|
31048
31174
|
}
|
|
31049
31175
|
return result;
|
|
31050
31176
|
}
|
|
31051
31177
|
function readTypeReferenceName(node, imports) {
|
|
31052
31178
|
let result;
|
|
31053
|
-
if (node &&
|
|
31179
|
+
if (node && Node26.isTypeReference(node)) {
|
|
31054
31180
|
const bindings = imports.bindingsByFilePath.get(node.getSourceFile().getFilePath());
|
|
31055
31181
|
const typeName = node.getTypeName();
|
|
31056
|
-
if (
|
|
31182
|
+
if (Node26.isIdentifier(typeName)) {
|
|
31057
31183
|
result = findVisibleBinding(typeName, bindings, "type")?.exportedName ?? typeName.getText();
|
|
31058
31184
|
} else {
|
|
31059
31185
|
const left = typeName.getLeft();
|
|
31060
|
-
if (
|
|
31186
|
+
if (Node26.isIdentifier(left) && findVisibleBinding(left, bindings, "type")?.namespace) {
|
|
31061
31187
|
result = typeName.getRight().getText();
|
|
31062
31188
|
}
|
|
31063
31189
|
}
|
|
@@ -31066,14 +31192,14 @@ function readTypeReferenceName(node, imports) {
|
|
|
31066
31192
|
}
|
|
31067
31193
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
31068
31194
|
function readArrayElementTypeNode(node) {
|
|
31069
|
-
const inner = node &&
|
|
31195
|
+
const inner = node && Node26.isTypeOperatorTypeNode(node) && node.getOperator() === SyntaxKind11.ReadonlyKeyword ? node.getTypeNode() : node;
|
|
31070
31196
|
let result;
|
|
31071
|
-
if (inner &&
|
|
31197
|
+
if (inner && Node26.isArrayTypeNode(inner)) {
|
|
31072
31198
|
result = inner.getElementTypeNode();
|
|
31073
|
-
} else if (inner &&
|
|
31199
|
+
} else if (inner && Node26.isTypeReference(inner)) {
|
|
31074
31200
|
const typeName = inner.getTypeName();
|
|
31075
31201
|
const typeArguments = inner.getTypeArguments();
|
|
31076
|
-
if (
|
|
31202
|
+
if (Node26.isIdentifier(typeName) && ARRAY_TYPE_NAMES.has(typeName.getText()) && typeArguments.length === 1) {
|
|
31077
31203
|
result = typeArguments[0];
|
|
31078
31204
|
}
|
|
31079
31205
|
}
|
|
@@ -31102,7 +31228,7 @@ function readOwnExportedDeclarations(sf) {
|
|
|
31102
31228
|
}
|
|
31103
31229
|
}
|
|
31104
31230
|
for (const stmt of sf.getVariableStatements()) {
|
|
31105
|
-
for (const decl of stmt.getDeclarations().filter((x) =>
|
|
31231
|
+
for (const decl of stmt.getDeclarations().filter((x) => Node26.isIdentifier(x.getNameNode()))) {
|
|
31106
31232
|
locals.set(decl.getName(), decl);
|
|
31107
31233
|
if (stmt.hasExportKeyword()) {
|
|
31108
31234
|
exportedLocals.set(decl.getName(), decl.getName());
|
|
@@ -31212,7 +31338,7 @@ function isCollectableTsFile(entry) {
|
|
|
31212
31338
|
}
|
|
31213
31339
|
|
|
31214
31340
|
// packages/dbx-cli/validate/src/lib/model-api-validate-app/extract-handler-mcp.ts
|
|
31215
|
-
import { Node as
|
|
31341
|
+
import { Node as Node27, SyntaxKind as SyntaxKind12, VariableDeclarationKind as VariableDeclarationKind2 } from "ts-morph";
|
|
31216
31342
|
var API_DETAILS_FACTORY_NAME = "withApiDetails";
|
|
31217
31343
|
var MAX_HANDLER_HOPS = 4;
|
|
31218
31344
|
var MAX_REASON_SNIPPET_LENGTH = 60;
|
|
@@ -31229,7 +31355,7 @@ function buildHandlerMcpReadOnlyContext(input) {
|
|
|
31229
31355
|
return result;
|
|
31230
31356
|
}
|
|
31231
31357
|
function readHandlerMcpReadOnly(reference, context) {
|
|
31232
|
-
const followed = followHandlerReference(
|
|
31358
|
+
const followed = followHandlerReference(unwrapOuterExpressions2(reference), context, 0);
|
|
31233
31359
|
return followed.kind === "declaration" ? readDeclarationMcpReadOnly(followed.declaration, context) : followed.status;
|
|
31234
31360
|
}
|
|
31235
31361
|
function unresolved(reason, declarationSource) {
|
|
@@ -31249,7 +31375,7 @@ function followHandlerReference(reference, context, hops) {
|
|
|
31249
31375
|
let result;
|
|
31250
31376
|
if (hops > MAX_HANDLER_HOPS) {
|
|
31251
31377
|
result = stopAt(unresolved(`the scan stopped after ${MAX_HANDLER_HOPS} alias / import / re-export hops`));
|
|
31252
|
-
} else if (
|
|
31378
|
+
} else if (Node27.isIdentifier(reference)) {
|
|
31253
31379
|
context.ensure(reference.getSourceFile());
|
|
31254
31380
|
const binding = resolveLocalValue(reference, context.imports);
|
|
31255
31381
|
const name = reference.getText();
|
|
@@ -31276,11 +31402,11 @@ function followHandlerReference(reference, context, hops) {
|
|
|
31276
31402
|
return result;
|
|
31277
31403
|
}
|
|
31278
31404
|
function followVariableDeclaration(declaration, context, hops) {
|
|
31279
|
-
const initializer =
|
|
31405
|
+
const initializer = unwrapOuterExpressions2(declaration.getInitializer());
|
|
31280
31406
|
let result;
|
|
31281
31407
|
if (declaration.getVariableStatement()?.getDeclarationKind() !== VariableDeclarationKind2.Const) {
|
|
31282
31408
|
result = stopAt(unresolved(`\`${declaration.getName()}\` is not declared with \`const\``, citeDeclaration(declaration, context)));
|
|
31283
|
-
} else if (initializer &&
|
|
31409
|
+
} else if (initializer && Node27.isIdentifier(initializer)) {
|
|
31284
31410
|
result = followHandlerReference(initializer, context, hops + 1);
|
|
31285
31411
|
} else {
|
|
31286
31412
|
result = { kind: "declaration", declaration };
|
|
@@ -31290,7 +31416,7 @@ function followVariableDeclaration(declaration, context, hops) {
|
|
|
31290
31416
|
function followImport(binding, context, hops) {
|
|
31291
31417
|
const importDeclaration = binding.getFirstAncestorByKindOrThrow(SyntaxKind12.ImportDeclaration);
|
|
31292
31418
|
const moduleSpecifier = importDeclaration.getModuleSpecifierValue();
|
|
31293
|
-
const exportedName =
|
|
31419
|
+
const exportedName = Node27.isImportSpecifier(binding) ? binding.getName() : "default";
|
|
31294
31420
|
let result;
|
|
31295
31421
|
if (isDereekbModuleSpecifier(moduleSpecifier)) {
|
|
31296
31422
|
result = stopAt(unresolved(`imported from \`${moduleSpecifier}\``));
|
|
@@ -31323,7 +31449,7 @@ function followExport(input, context) {
|
|
|
31323
31449
|
result = stopAt(unresolved(`the scan stopped after ${MAX_HANDLER_HOPS} alias / import / re-export hops`));
|
|
31324
31450
|
} else if (own === void 0) {
|
|
31325
31451
|
result = followReExport(input, context);
|
|
31326
|
-
} else if (
|
|
31452
|
+
} else if (Node27.isFunctionDeclaration(own)) {
|
|
31327
31453
|
result = stopAt({ kind: "noApiDetails", declarationSource: citeDeclaration(own, context) });
|
|
31328
31454
|
} else {
|
|
31329
31455
|
result = followVariableDeclaration(own, context, hops);
|
|
@@ -31381,13 +31507,13 @@ function followStarExports(input, starExports, context) {
|
|
|
31381
31507
|
}
|
|
31382
31508
|
function readDeclarationMcpReadOnly(declaration, context) {
|
|
31383
31509
|
const declarationSource = citeDeclaration(declaration, context);
|
|
31384
|
-
const initializer =
|
|
31510
|
+
const initializer = unwrapOuterExpressions2(declaration.getInitializer());
|
|
31385
31511
|
let result;
|
|
31386
31512
|
if (initializer === void 0) {
|
|
31387
31513
|
result = unresolved(`\`${declaration.getName()}\` has no initializer`, declarationSource);
|
|
31388
|
-
} else if (
|
|
31514
|
+
} else if (Node27.isArrowFunction(initializer) || Node27.isFunctionExpression(initializer)) {
|
|
31389
31515
|
result = { kind: "noApiDetails", declarationSource };
|
|
31390
|
-
} else if (
|
|
31516
|
+
} else if (Node27.isCallExpression(initializer)) {
|
|
31391
31517
|
context.ensure(initializer.getSourceFile());
|
|
31392
31518
|
const callee = readCalleeName2(initializer, context.imports);
|
|
31393
31519
|
if (callee === API_DETAILS_FACTORY_NAME) {
|
|
@@ -31427,7 +31553,7 @@ function readMcpBlockReadOnly(mcpBlock, declarationSource) {
|
|
|
31427
31553
|
return result;
|
|
31428
31554
|
}
|
|
31429
31555
|
function readBooleanLiteral(node) {
|
|
31430
|
-
const kind =
|
|
31556
|
+
const kind = unwrapOuterExpressions2(node).getKind();
|
|
31431
31557
|
let result;
|
|
31432
31558
|
if (kind === SyntaxKind12.TrueKeyword) {
|
|
31433
31559
|
result = true;
|
|
@@ -31437,8 +31563,8 @@ function readBooleanLiteral(node) {
|
|
|
31437
31563
|
return result;
|
|
31438
31564
|
}
|
|
31439
31565
|
function isUndefinedValue(node) {
|
|
31440
|
-
const inner =
|
|
31441
|
-
return
|
|
31566
|
+
const inner = unwrapOuterExpressions2(node);
|
|
31567
|
+
return Node27.isIdentifier(inner) && inner.getText() === "undefined" || Node27.isVoidExpression(inner);
|
|
31442
31568
|
}
|
|
31443
31569
|
|
|
31444
31570
|
// packages/dbx-cli/validate/src/lib/model-api-validate-app/mcp-read-only.ts
|
|
@@ -31468,30 +31594,21 @@ function checkHandlerMcpReadOnly(handler) {
|
|
|
31468
31594
|
}
|
|
31469
31595
|
|
|
31470
31596
|
// packages/dbx-cli/validate/src/lib/model-api-validate-app/extract-handlers.ts
|
|
31471
|
-
var HANDLER_MAP_REL = "src/app/function/model/crud.functions.ts";
|
|
31472
31597
|
var FUNCTION_DIR_REL = "src/app/function";
|
|
31473
|
-
var VERB_TOKENS = [
|
|
31474
|
-
{ token: "Create", verb: "create" },
|
|
31475
|
-
{ token: "Read", verb: "read" },
|
|
31476
|
-
{ token: "Update", verb: "update" },
|
|
31477
|
-
{ token: "Delete", verb: "delete" },
|
|
31478
|
-
{ token: "Query", verb: "query" },
|
|
31479
|
-
{ token: "Invoke", verb: "invoke" }
|
|
31480
|
-
];
|
|
31481
31598
|
async function extractHandlerEntries(apiAbs, apiDir) {
|
|
31482
31599
|
const files = await collectTsFiles(join10(apiAbs, FUNCTION_DIR_REL), apiAbs);
|
|
31483
31600
|
return extractHandlerEntriesFromFiles({ files, apiAbs, apiDir });
|
|
31484
31601
|
}
|
|
31485
31602
|
function extractHandlerEntriesFromFiles(input) {
|
|
31486
31603
|
const { files, apiAbs, apiDir } = input;
|
|
31487
|
-
const fullPath = join10(apiAbs,
|
|
31604
|
+
const fullPath = join10(apiAbs, CALL_MODEL_HANDLER_MAP_PATH);
|
|
31488
31605
|
const { apiSources } = buildInMemoryProject({ component: { files: [] }, api: { files } });
|
|
31489
|
-
const sourceFile = apiSources.find((x) => apiRelPath(x) ===
|
|
31606
|
+
const sourceFile = apiSources.find((x) => apiRelPath(x) === CALL_MODEL_HANDLER_MAP_PATH);
|
|
31490
31607
|
let result;
|
|
31491
31608
|
if (sourceFile === void 0) {
|
|
31492
|
-
result = { path: fullPath, status: { kind: "missing", path:
|
|
31609
|
+
result = { path: fullPath, status: { kind: "missing", path: CALL_MODEL_HANDLER_MAP_PATH }, entries: [] };
|
|
31493
31610
|
} else {
|
|
31494
|
-
const { handlers, verbsFound } = collectHandlerMap(sourceFile, `${apiDir}/${
|
|
31611
|
+
const { handlers, verbsFound } = collectHandlerMap(sourceFile, `${apiDir}/${CALL_MODEL_HANDLER_MAP_PATH}`);
|
|
31495
31612
|
const context = buildHandlerMcpReadOnlyContext({ sources: apiSources, apiDir });
|
|
31496
31613
|
const entries = handlers.map(({ entry, reference }) => isMcpReadOnlyInferredVerb(entry.verb) ? entry : { ...entry, mcpReadOnly: readHandlerMcpReadOnly(reference, context) });
|
|
31497
31614
|
result = { path: fullPath, status: { kind: "ok", verbsFound }, entries };
|
|
@@ -31499,75 +31616,10 @@ function extractHandlerEntriesFromFiles(input) {
|
|
|
31499
31616
|
return result;
|
|
31500
31617
|
}
|
|
31501
31618
|
function collectHandlerMap(sourceFile, sourceFileRel) {
|
|
31502
|
-
const
|
|
31503
|
-
const
|
|
31504
|
-
for (const stmt of sourceFile.getVariableStatements()) {
|
|
31505
|
-
for (const decl of stmt.getDeclarations()) {
|
|
31506
|
-
const name = decl.getName();
|
|
31507
|
-
const verb = matchVerbFromConstName(name);
|
|
31508
|
-
if (!verb) continue;
|
|
31509
|
-
const initializer = decl.getInitializer();
|
|
31510
|
-
if (!initializer || !Node27.isObjectLiteralExpression(initializer)) continue;
|
|
31511
|
-
verbsFound.push(verb);
|
|
31512
|
-
collectVerbMap({ verb, mapLiteral: initializer, sourceFileRel, handlers });
|
|
31513
|
-
}
|
|
31514
|
-
}
|
|
31619
|
+
const { cells, verbsFound } = extractCallModelHandlerMapFromSourceFile(sourceFile);
|
|
31620
|
+
const handlers = cells.map(({ reference, ...cell }) => ({ entry: { model: cell.model, verb: cell.verb, specifier: cell.specifier, handlerName: cell.handlerName, sourceFile: sourceFileRel, line: cell.line }, reference }));
|
|
31515
31621
|
return { handlers, verbsFound };
|
|
31516
31622
|
}
|
|
31517
|
-
function matchVerbFromConstName(name) {
|
|
31518
|
-
for (const { token, verb } of VERB_TOKENS) {
|
|
31519
|
-
if (name.endsWith(`${token}ModelMap`) || name.endsWith(`_${token.toUpperCase()}_MODEL_MAP`)) {
|
|
31520
|
-
return verb;
|
|
31521
|
-
}
|
|
31522
|
-
}
|
|
31523
|
-
return void 0;
|
|
31524
|
-
}
|
|
31525
|
-
function collectVerbMap(input) {
|
|
31526
|
-
const { verb, mapLiteral, sourceFileRel, handlers } = input;
|
|
31527
|
-
for (const prop of mapLiteral.getProperties()) {
|
|
31528
|
-
if (!Node27.isPropertyAssignment(prop)) continue;
|
|
31529
|
-
const model = prop.getName();
|
|
31530
|
-
const value = prop.getInitializer();
|
|
31531
|
-
if (!value) continue;
|
|
31532
|
-
const line = prop.getStartLineNumber();
|
|
31533
|
-
const specifierMap = readSpecifierHandler(value);
|
|
31534
|
-
if (specifierMap) {
|
|
31535
|
-
for (const [specifier, { handlerName: handlerName2, reference }] of specifierMap) {
|
|
31536
|
-
handlers.push({ entry: { model, verb, specifier, handlerName: handlerName2, sourceFile: sourceFileRel, line }, reference });
|
|
31537
|
-
}
|
|
31538
|
-
continue;
|
|
31539
|
-
}
|
|
31540
|
-
const handlerName = readBareHandlerName(value);
|
|
31541
|
-
if (handlerName) {
|
|
31542
|
-
handlers.push({ entry: { model, verb, specifier: void 0, handlerName, sourceFile: sourceFileRel, line }, reference: unwrapOuterExpressions(value) });
|
|
31543
|
-
}
|
|
31544
|
-
}
|
|
31545
|
-
}
|
|
31546
|
-
function readSpecifierHandler(node) {
|
|
31547
|
-
if (!Node27.isCallExpression(node)) return void 0;
|
|
31548
|
-
const expr = node.getExpression();
|
|
31549
|
-
if (!expr.getText().endsWith("onCallSpecifierHandler")) return void 0;
|
|
31550
|
-
const args = node.getArguments();
|
|
31551
|
-
if (args.length === 0) return void 0;
|
|
31552
|
-
const firstArg = args[0];
|
|
31553
|
-
if (!Node27.isObjectLiteralExpression(firstArg)) return void 0;
|
|
31554
|
-
const out = /* @__PURE__ */ new Map();
|
|
31555
|
-
for (const prop of firstArg.getProperties()) {
|
|
31556
|
-
if (Node27.isPropertyAssignment(prop)) {
|
|
31557
|
-
const value = prop.getInitializerOrThrow();
|
|
31558
|
-
out.set(prop.getName(), { handlerName: readBareHandlerName(value) ?? "(unresolved)", reference: unwrapOuterExpressions(value) });
|
|
31559
|
-
} else if (Node27.isShorthandPropertyAssignment(prop)) {
|
|
31560
|
-
out.set(prop.getName(), { handlerName: prop.getName(), reference: prop.getNameNode() });
|
|
31561
|
-
}
|
|
31562
|
-
}
|
|
31563
|
-
return out;
|
|
31564
|
-
}
|
|
31565
|
-
function readBareHandlerName(node) {
|
|
31566
|
-
if (Node27.isIdentifier(node)) return node.getText();
|
|
31567
|
-
const text = node.getText().split(/\s|\(/)[0];
|
|
31568
|
-
if (/^[A-Za-z_]\w*$/.test(text)) return text;
|
|
31569
|
-
return void 0;
|
|
31570
|
-
}
|
|
31571
31623
|
|
|
31572
31624
|
// packages/dbx-cli/validate/src/lib/model-api-validate-app/naming.ts
|
|
31573
31625
|
function expectedHandlerNames(model, verb, specifier) {
|
|
@@ -32166,7 +32218,7 @@ __export(dbx_asset_validate_app_exports, {
|
|
|
32166
32218
|
});
|
|
32167
32219
|
|
|
32168
32220
|
// packages/dbx-cli/validate/src/lib/dbx-asset-validate-app/extract.ts
|
|
32169
|
-
import { Node as Node28, Project as
|
|
32221
|
+
import { Node as Node28, Project as Project12 } from "ts-morph";
|
|
32170
32222
|
var ASSETS_RELPATH = "src/lib/assets.ts";
|
|
32171
32223
|
var BARREL_RELPATH = "src/lib/index.ts";
|
|
32172
32224
|
var LOCAL_ASSET_BUILDER = "localAsset";
|
|
@@ -32178,7 +32230,7 @@ var KNOWN_FLUENT_BUILDERS = /* @__PURE__ */ new Set([ASSET_FOLDER_BUILDER, REMOT
|
|
|
32178
32230
|
var ASSET_PATH_REF_ARRAY_TYPE = "AssetPathRef[]";
|
|
32179
32231
|
var BARREL_RE_EXPORT_RE = /export\s*\*\s*from\s*['"]\.\/assets['"]/;
|
|
32180
32232
|
function extractAppAssets(inspection) {
|
|
32181
|
-
const project = new
|
|
32233
|
+
const project = new Project12({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
32182
32234
|
const sources = [];
|
|
32183
32235
|
let assetsFileExists = false;
|
|
32184
32236
|
let barrelText;
|
|
@@ -34381,10 +34433,10 @@ function collectHandlersArrayElements(options) {
|
|
|
34381
34433
|
}
|
|
34382
34434
|
function consumeHandlersArrayElement(el, options) {
|
|
34383
34435
|
if (Node32.isSpreadElement(el)) {
|
|
34384
|
-
consumeHandlersSpreadElement({ ...options, inner:
|
|
34436
|
+
consumeHandlersSpreadElement({ ...options, inner: unwrapOuterExpressions2(el.getExpression()) });
|
|
34385
34437
|
return;
|
|
34386
34438
|
}
|
|
34387
|
-
const inner =
|
|
34439
|
+
const inner = unwrapOuterExpressions2(el);
|
|
34388
34440
|
if (noteUpstreamHandlerCall(inner, options)) return;
|
|
34389
34441
|
const identifier = readHandlerEntryIdentifier(inner);
|
|
34390
34442
|
if (identifier === void 0) {
|
|
@@ -34422,7 +34474,7 @@ function consumeHandlersSpreadElement(options) {
|
|
|
34422
34474
|
collectHandlerBindingsFromIdentifier({ identifier, index, trustedExternal, imports, resolved: resolvedBindings, unresolved: unresolvedBindings, reachedUpstreamHandlerCalls, reachedTaskHandlerEntries, opaqueHandlerValues, outcomes });
|
|
34423
34475
|
}
|
|
34424
34476
|
function collectHandlerBindingsFromValue(options) {
|
|
34425
|
-
const inner =
|
|
34477
|
+
const inner = unwrapOuterExpressions2(options.node);
|
|
34426
34478
|
let result = false;
|
|
34427
34479
|
if (inner) {
|
|
34428
34480
|
if (Node32.isCallExpression(inner)) {
|
|
@@ -34493,7 +34545,7 @@ function tryResolveLocalHandlerBinding(options) {
|
|
|
34493
34545
|
} else if (resolution.kind === "variable") {
|
|
34494
34546
|
const { declaration } = resolution;
|
|
34495
34547
|
const walk4 = () => {
|
|
34496
|
-
const init =
|
|
34548
|
+
const init = unwrapOuterExpressions2(declaration.getInitializer());
|
|
34497
34549
|
let walked;
|
|
34498
34550
|
if (isHandlerConfigLeafDecl(declaration, imports)) {
|
|
34499
34551
|
resolved.push(declaration.getName());
|
|
@@ -34514,7 +34566,7 @@ function tryResolveLocalHandlerBinding(options) {
|
|
|
34514
34566
|
return result;
|
|
34515
34567
|
}
|
|
34516
34568
|
function isHandlerConfigLeafDecl(decl, imports) {
|
|
34517
|
-
const declInit =
|
|
34569
|
+
const declInit = unwrapOuterExpressions2(decl.getInitializer());
|
|
34518
34570
|
return readTypeReferenceName(decl.getTypeNode(), imports) === NOTIF_TASK_SERVICE_HANDLER_CONFIG && declInit !== void 0 && Node32.isObjectLiteralExpression(declInit);
|
|
34519
34571
|
}
|
|
34520
34572
|
function tryResolveFunctionHandlerBinding(options) {
|
|
@@ -36615,14 +36667,14 @@ async function tryReadSystemSource(path) {
|
|
|
36615
36667
|
}
|
|
36616
36668
|
|
|
36617
36669
|
// packages/dbx-cli/validate/src/lib/system-m-validate-folder/extract.ts
|
|
36618
|
-
import { Node as Node34, Project as
|
|
36670
|
+
import { Node as Node34, Project as Project13 } from "ts-morph";
|
|
36619
36671
|
var TYPE_CONSTANT_SUFFIX = "_SYSTEM_STATE_TYPE";
|
|
36620
36672
|
var DATA_INTERFACE_SUFFIX = "SystemData";
|
|
36621
36673
|
var CONVERTER_CONFIG_TYPE = "SystemStateStoredDataFieldConverterConfig";
|
|
36622
36674
|
var CONVERTER_MAP_TYPE = "SystemStateStoredDataConverterMap";
|
|
36623
36675
|
var SYSTEM_STATE_STORED_DATA = "SystemStateStoredData";
|
|
36624
36676
|
function extractSystemFile(name, text) {
|
|
36625
|
-
const project = new
|
|
36677
|
+
const project = new Project13({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
36626
36678
|
const sourceFile = project.createSourceFile(name, text, { overwrite: true });
|
|
36627
36679
|
const typeConstants = findTypeConstants(sourceFile);
|
|
36628
36680
|
const dataInterfaces = findDataInterfaces2(sourceFile);
|
|
@@ -37452,7 +37504,7 @@ function toPosix2(p) {
|
|
|
37452
37504
|
}
|
|
37453
37505
|
|
|
37454
37506
|
// packages/dbx-cli/model-test/src/lib/test/extract.ts
|
|
37455
|
-
import { Node as Node35, Project as
|
|
37507
|
+
import { Node as Node35, Project as Project14, SyntaxKind as SyntaxKind18 } from "ts-morph";
|
|
37456
37508
|
var SPEC_FILE_VIRTUAL_PATH = "__spec__/spec.ts";
|
|
37457
37509
|
var FIXTURE_CONTEXT_SUFFIX = "Context";
|
|
37458
37510
|
var FIXTURE_FACTORY_SUFFIX = "ContextFactory";
|
|
@@ -37465,7 +37517,7 @@ function isItName(name) {
|
|
|
37465
37517
|
}
|
|
37466
37518
|
function extractSpecTreeFromText(input) {
|
|
37467
37519
|
const { text, specPath } = input;
|
|
37468
|
-
const project = new
|
|
37520
|
+
const project = new Project14({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
37469
37521
|
const sourceFile = project.createSourceFile(SPEC_FILE_VIRTUAL_PATH, text, { overwrite: true });
|
|
37470
37522
|
const { prefix, prefixSource, knownFixtureNames } = resolvePrefixAndFixtures(sourceFile, input);
|
|
37471
37523
|
const helpers = collectHelpers(sourceFile);
|
|
@@ -37799,7 +37851,7 @@ import { readFile as readFile14 } from "node:fs/promises";
|
|
|
37799
37851
|
import { join as join15 } from "node:path";
|
|
37800
37852
|
|
|
37801
37853
|
// packages/dbx-cli/model-test/src/lib/fixture/extract.ts
|
|
37802
|
-
import { Node as Node36, Project as
|
|
37854
|
+
import { Node as Node36, Project as Project15, SyntaxKind as SyntaxKind19 } from "ts-morph";
|
|
37803
37855
|
|
|
37804
37856
|
// packages/dbx-cli/model-test/src/lib/fixture/archetype.ts
|
|
37805
37857
|
function classifyFixtureArchetype(input) {
|
|
@@ -37872,7 +37924,7 @@ var BASE_CONTEXT_FIXTURE_BASE = "FirebaseAdminNestTestContextFixture";
|
|
|
37872
37924
|
var MODEL_FACTORY_NAME = "modelTestContextFactory";
|
|
37873
37925
|
function extractAppFixturesFromText(input) {
|
|
37874
37926
|
const { text, fixturePath } = input;
|
|
37875
|
-
const project = new
|
|
37927
|
+
const project = new Project15({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
37876
37928
|
const sourceFile = project.createSourceFile(FIXTURE_FILE_VIRTUAL_PATH, text, { overwrite: true });
|
|
37877
37929
|
const prefix = detectPrefix(sourceFile);
|
|
37878
37930
|
const fixtureClasses = /* @__PURE__ */ new Map();
|
|
@@ -39552,7 +39604,7 @@ function topLevelColonIndex(text) {
|
|
|
39552
39604
|
// packages/dbx-cli/validate/src/lib/model-list-component/extract.ts
|
|
39553
39605
|
import { readdir as readdir9, readFile as readFile17, stat as stat13 } from "node:fs/promises";
|
|
39554
39606
|
import { basename as basename8, join as join17, relative as relative15, sep as sep11 } from "node:path";
|
|
39555
|
-
import { Node as Node37, Project as
|
|
39607
|
+
import { Node as Node37, Project as Project16 } from "ts-morph";
|
|
39556
39608
|
var MODEL_SUBPATH2 = "src/lib/model";
|
|
39557
39609
|
var MODEL_SUBPATH_PREFIX = `${MODEL_SUBPATH2}/`;
|
|
39558
39610
|
var RESERVED_NAMES = RESERVED_MODEL_FOLDERS.map((r) => r.name);
|
|
@@ -39581,7 +39633,7 @@ async function extractComponentModels(componentAbs) {
|
|
|
39581
39633
|
skipReservedFolders: RESERVED_NAMES
|
|
39582
39634
|
});
|
|
39583
39635
|
const richByFolder = groupRichByFolder(richResult.models);
|
|
39584
|
-
const fallbackProject = new
|
|
39636
|
+
const fallbackProject = new Project16({ useInMemoryFileSystem: true });
|
|
39585
39637
|
const models = [];
|
|
39586
39638
|
const unidentified = [];
|
|
39587
39639
|
for (const folder of targetFolders) {
|
|
@@ -39986,7 +40038,7 @@ import { join as join20, relative as relative18, sep as sep14 } from "node:path"
|
|
|
39986
40038
|
// packages/dbx-cli/validate/src/lib/model-api-lookup/extract-actions.ts
|
|
39987
40039
|
import { readFile as readFile19 } from "node:fs/promises";
|
|
39988
40040
|
import { join as join19, relative as relative17, sep as sep13 } from "node:path";
|
|
39989
|
-
import { Project as
|
|
40041
|
+
import { Project as Project17, SyntaxKind as SyntaxKind20 } from "ts-morph";
|
|
39990
40042
|
var ACTION_SERVER_SUFFIX = ".action.server.ts";
|
|
39991
40043
|
var COMMON_MODEL_SUBPATH = "src/app/common/model";
|
|
39992
40044
|
async function buildActionLookup(apiAbs) {
|
|
@@ -39997,7 +40049,7 @@ async function buildActionLookup(apiAbs) {
|
|
|
39997
40049
|
if (files.length === 0) {
|
|
39998
40050
|
return { methodsByParams, factoriesByParams, filesScanned: 0 };
|
|
39999
40051
|
}
|
|
40000
|
-
const project = new
|
|
40052
|
+
const project = new Project17({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
40001
40053
|
for (const filePath of files) {
|
|
40002
40054
|
const text = await readFile19(filePath, "utf8");
|
|
40003
40055
|
const sourceFile = project.createSourceFile(filePath, text, { overwrite: true });
|
|
@@ -40317,7 +40369,7 @@ __export(server_actions_list_app_exports, {
|
|
|
40317
40369
|
// packages/dbx-cli/validate/src/lib/server-actions-list-app/extract.ts
|
|
40318
40370
|
import { readdir as readdir10, readFile as readFile21 } from "node:fs/promises";
|
|
40319
40371
|
import { dirname as dirname18, join as join21, relative as relative19, sep as sep15 } from "node:path";
|
|
40320
|
-
import { Node as Node38, Project as
|
|
40372
|
+
import { Node as Node38, Project as Project18 } from "ts-morph";
|
|
40321
40373
|
var ACTION_SERVER_SUFFIX2 = ".action.server.ts";
|
|
40322
40374
|
var COMMON_MODEL_SUBPATH2 = "src/app/common/model";
|
|
40323
40375
|
var COMMON_BARREL_REL = "src/app/common/index.ts";
|
|
@@ -40327,7 +40379,7 @@ async function extractServerActions(apiAbs, apiRel) {
|
|
|
40327
40379
|
if (actionFiles.length === 0) {
|
|
40328
40380
|
return { modelRoot, entries: [], fixtureStatus: "ok" };
|
|
40329
40381
|
}
|
|
40330
|
-
const project = new
|
|
40382
|
+
const project = new Project18({ useInMemoryFileSystem: true });
|
|
40331
40383
|
const commonBarrelExports = await readCommonBarrelExports(apiAbs);
|
|
40332
40384
|
const fixtureCoverageMap = /* @__PURE__ */ new Map();
|
|
40333
40385
|
let fixtureStatus = "ok";
|
|
@@ -40415,7 +40467,7 @@ async function safeRead(path) {
|
|
|
40415
40467
|
return result;
|
|
40416
40468
|
}
|
|
40417
40469
|
function inspectModuleText(input) {
|
|
40418
|
-
const project = new
|
|
40470
|
+
const project = new Project18({ useInMemoryFileSystem: true });
|
|
40419
40471
|
const sourceFile = project.createSourceFile("module.ts", input.text, { overwrite: true });
|
|
40420
40472
|
let providedByModule = false;
|
|
40421
40473
|
let exportedByModule = false;
|
|
@@ -40458,7 +40510,7 @@ async function readCommonBarrelExports(apiAbs) {
|
|
|
40458
40510
|
const path = join21(apiAbs, COMMON_BARREL_REL);
|
|
40459
40511
|
const text = await safeRead(path);
|
|
40460
40512
|
if (text === void 0) return /* @__PURE__ */ new Set();
|
|
40461
|
-
const project = new
|
|
40513
|
+
const project = new Project18({ useInMemoryFileSystem: true });
|
|
40462
40514
|
const sourceFile = project.createSourceFile(path, text, { overwrite: true });
|
|
40463
40515
|
const exported = /* @__PURE__ */ new Set();
|
|
40464
40516
|
for (const decl of sourceFile.getExportDeclarations()) {
|
|
@@ -41638,7 +41690,7 @@ async function readFileIfExists2(absPath) {
|
|
|
41638
41690
|
}
|
|
41639
41691
|
|
|
41640
41692
|
// packages/dbx-cli/validate/src/lib/dbx-color-template-list-app/extract.ts
|
|
41641
|
-
import { Node as Node39, Project as
|
|
41693
|
+
import { Node as Node39, Project as Project19, SyntaxKind as SyntaxKind21 } from "ts-morph";
|
|
41642
41694
|
var PROVIDE_FN_NAME = "provideDbxStyleService";
|
|
41643
41695
|
var COLOR_SERVICE_CONFIG_PROP = "dbxColorServiceConfig";
|
|
41644
41696
|
var TEMPLATES_PROP = "templates";
|
|
@@ -41646,7 +41698,7 @@ var KEY_PROP = "key";
|
|
|
41646
41698
|
var CONFIG_PROP = "config";
|
|
41647
41699
|
var KNOWN_CONFIG_PROPS = /* @__PURE__ */ new Set(["template", "color", "contrast", "tone", "tonal"]);
|
|
41648
41700
|
function extractColorTemplates(inspection) {
|
|
41649
|
-
const project = new
|
|
41701
|
+
const project = new Project19({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
41650
41702
|
const ctx = { warnings: [], templates: [], provideCallLocation: void 0 };
|
|
41651
41703
|
const sources = [];
|
|
41652
41704
|
for (const file of inspection.files) {
|
|
@@ -41883,12 +41935,12 @@ __export(dbx_color_smell_check_exports, {
|
|
|
41883
41935
|
});
|
|
41884
41936
|
|
|
41885
41937
|
// packages/dbx-cli/validate/src/lib/dbx-color-smell-check/extract.ts
|
|
41886
|
-
import { Node as Node40, Project as
|
|
41938
|
+
import { Node as Node40, Project as Project20, SyntaxKind as SyntaxKind22 } from "ts-morph";
|
|
41887
41939
|
var COLOR_INPUT_NAMES = /* @__PURE__ */ new Set(["color", "dbxColor", "dbxTextColor"]);
|
|
41888
41940
|
var COLOR_TYPE_NAMES = /* @__PURE__ */ new Set(["DbxColorConfig", "DbxColorInput", "Maybe<DbxColorInput>", "Maybe<DbxColorConfig>"]);
|
|
41889
41941
|
var KNOWN_CONFIG_KEYS = /* @__PURE__ */ new Set(["template", "color", "contrast", "tone", "tonal"]);
|
|
41890
41942
|
function extractTsLiterals(filePath, text) {
|
|
41891
|
-
const project = new
|
|
41943
|
+
const project = new Project20({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
41892
41944
|
const sf = project.createSourceFile(filePath, text, { overwrite: true });
|
|
41893
41945
|
const out = [];
|
|
41894
41946
|
for (const obj of sf.getDescendantsOfKind(SyntaxKind22.ObjectLiteralExpression)) {
|
|
@@ -45813,7 +45865,7 @@ var MODEL_FIXTURE_SCAFFOLD_TOOL = { definition: TOOL7, run: run6 };
|
|
|
45813
45865
|
// packages/dbx-components-mcp/src/tools/model-fixture-forward.tool.ts
|
|
45814
45866
|
import { join as join24, resolve as resolve45 } from "node:path";
|
|
45815
45867
|
import { type as type63 } from "arktype";
|
|
45816
|
-
import { Project as
|
|
45868
|
+
import { Project as Project21 } from "ts-morph";
|
|
45817
45869
|
var ForwardArgsType = type63({
|
|
45818
45870
|
apiDir: "string",
|
|
45819
45871
|
model: "string",
|
|
@@ -45899,7 +45951,7 @@ function toErrorMessage(err) {
|
|
|
45899
45951
|
return err instanceof Error ? err.message : String(err);
|
|
45900
45952
|
}
|
|
45901
45953
|
async function applyForwardersToFile(absolutePath, fixtureClassName, rendered) {
|
|
45902
|
-
const project = new
|
|
45954
|
+
const project = new Project21({ skipAddingFilesFromTsConfig: true });
|
|
45903
45955
|
let result;
|
|
45904
45956
|
let sourceFile;
|
|
45905
45957
|
try {
|
|
@@ -52404,7 +52456,7 @@ function createSearchModelSnapshotFieldTool(config) {
|
|
|
52404
52456
|
import { glob, readFile as readFile27 } from "node:fs/promises";
|
|
52405
52457
|
import { resolve as resolve57 } from "node:path";
|
|
52406
52458
|
import { type as type87 } from "arktype";
|
|
52407
|
-
import { Node as Node41, Project as
|
|
52459
|
+
import { Node as Node41, Project as Project22 } from "ts-morph";
|
|
52408
52460
|
var ListAppArgsType4 = type87({
|
|
52409
52461
|
componentDir: "string",
|
|
52410
52462
|
"apiDir?": "string",
|
|
@@ -52501,7 +52553,7 @@ async function collectFiles(rootAbs, globs) {
|
|
|
52501
52553
|
}
|
|
52502
52554
|
async function buildListAppReport(input) {
|
|
52503
52555
|
const { componentDir, componentAbs, apiDir, apiAbs, registry } = input;
|
|
52504
|
-
const project = new
|
|
52556
|
+
const project = new Project22({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
52505
52557
|
const componentFiles = await collectFiles(componentAbs, COMPONENT_MODEL_GLOBS);
|
|
52506
52558
|
for (const rel of componentFiles) {
|
|
52507
52559
|
const abs = resolve57(componentAbs, rel);
|