@mondaydotcomorg/atp-compiler 0.22.2 → 0.23.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/__tests__/unit/api-call-analyzer.test.ts +387 -0
- package/dist/api-call-analyzer.d.ts +45 -0
- package/dist/api-call-analyzer.d.ts.map +1 -0
- package/dist/api-call-analyzer.js +192 -0
- package/dist/api-call-analyzer.js.map +1 -0
- package/dist/index.cjs +144 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +144 -13
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/api-call-analyzer.ts +232 -0
- package/src/index.ts +4 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.cjs
CHANGED
|
@@ -570,7 +570,7 @@ var require_estraverse = __commonJS({
|
|
|
570
570
|
return false;
|
|
571
571
|
}
|
|
572
572
|
__name(candidateExistsInLeaveList, "candidateExistsInLeaveList");
|
|
573
|
-
Controller.prototype.traverse = /* @__PURE__ */ __name(function
|
|
573
|
+
Controller.prototype.traverse = /* @__PURE__ */ __name(function traverse8(root, visitor) {
|
|
574
574
|
var worklist, leavelist, element, node, nodeType, ret, key, current2, current22, candidates, candidate, sentinel;
|
|
575
575
|
this.__initialize(root, visitor);
|
|
576
576
|
sentinel = {};
|
|
@@ -760,11 +760,11 @@ var require_estraverse = __commonJS({
|
|
|
760
760
|
}
|
|
761
761
|
return outer.root;
|
|
762
762
|
}, "replace");
|
|
763
|
-
function
|
|
763
|
+
function traverse7(root, visitor) {
|
|
764
764
|
var controller = new Controller();
|
|
765
765
|
return controller.traverse(root, visitor);
|
|
766
766
|
}
|
|
767
|
-
__name(
|
|
767
|
+
__name(traverse7, "traverse");
|
|
768
768
|
function replace(root, visitor) {
|
|
769
769
|
var controller = new Controller();
|
|
770
770
|
return controller.replace(root, visitor);
|
|
@@ -812,7 +812,7 @@ var require_estraverse = __commonJS({
|
|
|
812
812
|
comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
|
|
813
813
|
}
|
|
814
814
|
cursor = 0;
|
|
815
|
-
|
|
815
|
+
traverse7(tree, {
|
|
816
816
|
enter: /* @__PURE__ */ __name(function(node) {
|
|
817
817
|
var comment2;
|
|
818
818
|
while (cursor < comments.length) {
|
|
@@ -839,7 +839,7 @@ var require_estraverse = __commonJS({
|
|
|
839
839
|
}, "enter")
|
|
840
840
|
});
|
|
841
841
|
cursor = 0;
|
|
842
|
-
|
|
842
|
+
traverse7(tree, {
|
|
843
843
|
leave: /* @__PURE__ */ __name(function(node) {
|
|
844
844
|
var comment2;
|
|
845
845
|
while (cursor < comments.length) {
|
|
@@ -869,7 +869,7 @@ var require_estraverse = __commonJS({
|
|
|
869
869
|
}
|
|
870
870
|
__name(attachComments, "attachComments");
|
|
871
871
|
exports1.Syntax = Syntax;
|
|
872
|
-
exports1.traverse =
|
|
872
|
+
exports1.traverse = traverse7;
|
|
873
873
|
exports1.replace = replace;
|
|
874
874
|
exports1.attachComments = attachComments;
|
|
875
875
|
exports1.VisitorKeys = VisitorKeys;
|
|
@@ -3075,7 +3075,7 @@ var require_package = __commonJS({
|
|
|
3075
3075
|
var require_escodegen = __commonJS({
|
|
3076
3076
|
"../../node_modules/escodegen/escodegen.js"(exports$1) {
|
|
3077
3077
|
(function() {
|
|
3078
|
-
var Syntax, Precedence, BinaryPrecedence, SourceNode, estraverse, esutils, base2, indent, json, renumber, hexadecimal, quotes, escapeless, newline, space, parentheses, semicolons, safeConcatenation, directive, extra,
|
|
3078
|
+
var Syntax, Precedence, BinaryPrecedence, SourceNode, estraverse, esutils, base2, indent, json, renumber, hexadecimal, quotes, escapeless, newline, space, parentheses, semicolons, safeConcatenation, directive, extra, parse8, sourceMap, sourceCode, preserveBlankLines, FORMAT_MINIFY, FORMAT_DEFAULTS;
|
|
3079
3079
|
estraverse = require_estraverse();
|
|
3080
3080
|
esutils = require_utils();
|
|
3081
3081
|
Syntax = estraverse.Syntax;
|
|
@@ -5071,9 +5071,9 @@ var require_escodegen = __commonJS({
|
|
|
5071
5071
|
}, "ExportSpecifier"),
|
|
5072
5072
|
Literal: /* @__PURE__ */ __name(function(expr, precedence, flags) {
|
|
5073
5073
|
var raw;
|
|
5074
|
-
if (expr.hasOwnProperty("raw") &&
|
|
5074
|
+
if (expr.hasOwnProperty("raw") && parse8 && extra.raw) {
|
|
5075
5075
|
try {
|
|
5076
|
-
raw =
|
|
5076
|
+
raw = parse8(expr.raw).body[0].expression;
|
|
5077
5077
|
if (raw.type === Syntax.Literal) {
|
|
5078
5078
|
if (raw.value === expr.value) {
|
|
5079
5079
|
return expr.raw;
|
|
@@ -5285,7 +5285,7 @@ var require_escodegen = __commonJS({
|
|
|
5285
5285
|
semicolons = options.format.semicolons;
|
|
5286
5286
|
safeConcatenation = options.format.safeConcatenation;
|
|
5287
5287
|
directive = options.directive;
|
|
5288
|
-
|
|
5288
|
+
parse8 = json ? null : options.parse;
|
|
5289
5289
|
sourceMap = options.sourceMap;
|
|
5290
5290
|
sourceCode = options.sourceCode;
|
|
5291
5291
|
preserveBlankLines = options.format.preserveBlankLines && sourceCode !== null;
|
|
@@ -9441,8 +9441,8 @@ var ZodParsedType = util.arrayToEnum([
|
|
|
9441
9441
|
"set"
|
|
9442
9442
|
]);
|
|
9443
9443
|
var getParsedType = /* @__PURE__ */ __name((data2) => {
|
|
9444
|
-
const
|
|
9445
|
-
switch (
|
|
9444
|
+
const t19 = typeof data2;
|
|
9445
|
+
switch (t19) {
|
|
9446
9446
|
case "undefined":
|
|
9447
9447
|
return ZodParsedType.undefined;
|
|
9448
9448
|
case "string":
|
|
@@ -20282,6 +20282,137 @@ async function getCheckpointDataForError() {
|
|
|
20282
20282
|
};
|
|
20283
20283
|
}
|
|
20284
20284
|
__name(getCheckpointDataForError, "getCheckpointDataForError");
|
|
20285
|
+
var traverse6 = _traverse__default.default.default ?? _traverse__default.default;
|
|
20286
|
+
function analyzeApiCalls(code) {
|
|
20287
|
+
const calls = [];
|
|
20288
|
+
const seen = /* @__PURE__ */ new Set();
|
|
20289
|
+
let dynamicCallsDetected = false;
|
|
20290
|
+
let ast;
|
|
20291
|
+
try {
|
|
20292
|
+
ast = parser.parse(code, {
|
|
20293
|
+
sourceType: "module",
|
|
20294
|
+
allowReturnOutsideFunction: true,
|
|
20295
|
+
plugins: [
|
|
20296
|
+
"typescript"
|
|
20297
|
+
]
|
|
20298
|
+
});
|
|
20299
|
+
} catch {
|
|
20300
|
+
return {
|
|
20301
|
+
apiCalls: [],
|
|
20302
|
+
dynamicCallsDetected: true
|
|
20303
|
+
};
|
|
20304
|
+
}
|
|
20305
|
+
const tryRecordCall = /* @__PURE__ */ __name((calleeNode) => {
|
|
20306
|
+
let callee = calleeNode;
|
|
20307
|
+
if ((t13__namespace.isMemberExpression(callee) || t13__namespace.isOptionalMemberExpression(callee)) && !callee.computed && t13__namespace.isIdentifier(callee.property) && (callee.property.name === "call" || callee.property.name === "apply" || callee.property.name === "bind")) {
|
|
20308
|
+
callee = callee.object;
|
|
20309
|
+
}
|
|
20310
|
+
if (!t13__namespace.isMemberExpression(callee) && !t13__namespace.isOptionalMemberExpression(callee)) return;
|
|
20311
|
+
const groupExpr = callee.object;
|
|
20312
|
+
if (!t13__namespace.isMemberExpression(groupExpr) && !t13__namespace.isOptionalMemberExpression(groupExpr)) return;
|
|
20313
|
+
if (!t13__namespace.isIdentifier(groupExpr.object, {
|
|
20314
|
+
name: "api"
|
|
20315
|
+
})) return;
|
|
20316
|
+
if (groupExpr.computed || callee.computed) {
|
|
20317
|
+
dynamicCallsDetected = true;
|
|
20318
|
+
return;
|
|
20319
|
+
}
|
|
20320
|
+
const groupNode = groupExpr.property;
|
|
20321
|
+
const opNode = callee.property;
|
|
20322
|
+
if (!t13__namespace.isIdentifier(groupNode) || !t13__namespace.isIdentifier(opNode)) {
|
|
20323
|
+
dynamicCallsDetected = true;
|
|
20324
|
+
return;
|
|
20325
|
+
}
|
|
20326
|
+
const key = `${groupNode.name}.${opNode.name}`;
|
|
20327
|
+
if (!seen.has(key)) {
|
|
20328
|
+
seen.add(key);
|
|
20329
|
+
calls.push({
|
|
20330
|
+
apiGroup: groupNode.name,
|
|
20331
|
+
operationId: opNode.name
|
|
20332
|
+
});
|
|
20333
|
+
}
|
|
20334
|
+
}, "tryRecordCall");
|
|
20335
|
+
try {
|
|
20336
|
+
traverse6(ast, {
|
|
20337
|
+
// Assignments / destructures that alias `api` or `api.<group>` — any of
|
|
20338
|
+
// these lets the code reach an api group via an opaque identifier later.
|
|
20339
|
+
VariableDeclarator(path) {
|
|
20340
|
+
const init = path.node.init;
|
|
20341
|
+
if (!init) return;
|
|
20342
|
+
if (t13__namespace.isObjectPattern(path.node.id) && t13__namespace.isIdentifier(init, {
|
|
20343
|
+
name: "api"
|
|
20344
|
+
})) {
|
|
20345
|
+
dynamicCallsDetected = true;
|
|
20346
|
+
return;
|
|
20347
|
+
}
|
|
20348
|
+
if (t13__namespace.isIdentifier(path.node.id) && t13__namespace.isIdentifier(init, {
|
|
20349
|
+
name: "api"
|
|
20350
|
+
})) {
|
|
20351
|
+
dynamicCallsDetected = true;
|
|
20352
|
+
return;
|
|
20353
|
+
}
|
|
20354
|
+
if (t13__namespace.isIdentifier(path.node.id) && t13__namespace.isMemberExpression(init) && t13__namespace.isIdentifier(init.object, {
|
|
20355
|
+
name: "api"
|
|
20356
|
+
})) {
|
|
20357
|
+
dynamicCallsDetected = true;
|
|
20358
|
+
}
|
|
20359
|
+
},
|
|
20360
|
+
// Any other mention of `api` that hands it off to an opaque consumer:
|
|
20361
|
+
// fn(api) — alias escape via function argument
|
|
20362
|
+
// Object.values(api) / keys(…) — enumeration
|
|
20363
|
+
// { ...api } / [ ...api ] — spread
|
|
20364
|
+
// return api — caller gets the alias
|
|
20365
|
+
// api = x (reassignment) — later reads hit a different object
|
|
20366
|
+
//
|
|
20367
|
+
// The api.<group>.<op>(...) pattern is recognised by the CallExpression
|
|
20368
|
+
// visitor below; skip it here via parent-shape whitelisting.
|
|
20369
|
+
Identifier(path) {
|
|
20370
|
+
if (path.node.name !== "api") return;
|
|
20371
|
+
if ((t13__namespace.isMemberExpression(path.parent) || t13__namespace.isOptionalMemberExpression(path.parent)) && path.parent.property === path.node && !path.parent.computed) {
|
|
20372
|
+
return;
|
|
20373
|
+
}
|
|
20374
|
+
if ((t13__namespace.isMemberExpression(path.parent) || t13__namespace.isOptionalMemberExpression(path.parent)) && path.parent.object === path.node && !path.parent.computed) {
|
|
20375
|
+
return;
|
|
20376
|
+
}
|
|
20377
|
+
if (t13__namespace.isVariableDeclarator(path.parent) && path.parent.init === path.node) {
|
|
20378
|
+
return;
|
|
20379
|
+
}
|
|
20380
|
+
if ((t13__namespace.isObjectProperty(path.parent) || t13__namespace.isObjectMethod(path.parent)) && path.parent.key === path.node && !path.parent.computed) {
|
|
20381
|
+
return;
|
|
20382
|
+
}
|
|
20383
|
+
if (t13__namespace.isClassMethod(path.parent) && path.parent.key === path.node && !path.parent.computed) {
|
|
20384
|
+
return;
|
|
20385
|
+
}
|
|
20386
|
+
if ((t13__namespace.isFunctionDeclaration(path.parent) || t13__namespace.isFunctionExpression(path.parent) || t13__namespace.isClassDeclaration(path.parent) || t13__namespace.isClassExpression(path.parent)) && path.parent.id === path.node) {
|
|
20387
|
+
return;
|
|
20388
|
+
}
|
|
20389
|
+
if (path.parentPath?.isFunction() && path.listKey === "params") {
|
|
20390
|
+
return;
|
|
20391
|
+
}
|
|
20392
|
+
if (t13__namespace.isImportSpecifier(path.parent) || t13__namespace.isImportDefaultSpecifier(path.parent) || t13__namespace.isImportNamespaceSpecifier(path.parent)) {
|
|
20393
|
+
return;
|
|
20394
|
+
}
|
|
20395
|
+
dynamicCallsDetected = true;
|
|
20396
|
+
},
|
|
20397
|
+
CallExpression(path) {
|
|
20398
|
+
tryRecordCall(path.node.callee);
|
|
20399
|
+
},
|
|
20400
|
+
OptionalCallExpression(path) {
|
|
20401
|
+
tryRecordCall(path.node.callee);
|
|
20402
|
+
}
|
|
20403
|
+
});
|
|
20404
|
+
} catch {
|
|
20405
|
+
return {
|
|
20406
|
+
apiCalls: [],
|
|
20407
|
+
dynamicCallsDetected: true
|
|
20408
|
+
};
|
|
20409
|
+
}
|
|
20410
|
+
return {
|
|
20411
|
+
apiCalls: calls,
|
|
20412
|
+
dynamicCallsDetected
|
|
20413
|
+
};
|
|
20414
|
+
}
|
|
20415
|
+
__name(analyzeApiCalls, "analyzeApiCalls");
|
|
20285
20416
|
|
|
20286
20417
|
exports.ATPCompiler = ATPCompiler;
|
|
20287
20418
|
exports.ArrayTransformer = ArrayTransformer;
|
|
@@ -20317,6 +20448,7 @@ exports.RuntimeFunction = RuntimeFunction;
|
|
|
20317
20448
|
exports.SecurityValidationError = SecurityValidationError;
|
|
20318
20449
|
exports.SecurityValidatorPlugin = SecurityValidatorPlugin;
|
|
20319
20450
|
exports.TransformationError = TransformationError;
|
|
20451
|
+
exports.analyzeApiCalls = analyzeApiCalls;
|
|
20320
20452
|
exports.batchParallel = batchParallel;
|
|
20321
20453
|
exports.cleanupCheckpointRuntime = cleanupCheckpointRuntime;
|
|
20322
20454
|
exports.cleanupRuntime = cleanupRuntime;
|