flowlint 0.5.1 → 0.6.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/README.md +45 -355
- package/dist/cli.js +163 -21
- package/dist/cli.js.map +1 -1
- package/package.json +52 -57
- package/dist/cli.d.ts +0 -8
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.js +0 -34
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/scan.d.ts +0 -11
- package/dist/commands/scan.js +0 -104
- package/dist/commands/scan.js.map +0 -1
- package/dist/packages/config/flowlint-config.d.ts +0 -73
- package/dist/packages/config/flowlint-config.js +0 -120
- package/dist/packages/config/flowlint-config.js.map +0 -1
- package/dist/packages/config/index.d.ts +0 -4
- package/dist/packages/config/index.js +0 -21
- package/dist/packages/config/index.js.map +0 -1
- package/dist/packages/github/client.d.ts +0 -2
- package/dist/packages/github/client.js +0 -94
- package/dist/packages/github/client.js.map +0 -1
- package/dist/packages/logger/index.d.ts +0 -11
- package/dist/packages/logger/index.js +0 -40
- package/dist/packages/logger/index.js.map +0 -1
- package/dist/packages/observability/collectors.d.ts +0 -40
- package/dist/packages/observability/collectors.js +0 -75
- package/dist/packages/observability/collectors.js.map +0 -1
- package/dist/packages/observability/index.d.ts +0 -10
- package/dist/packages/observability/index.js +0 -35
- package/dist/packages/observability/index.js.map +0 -1
- package/dist/packages/observability/metrics.d.ts +0 -119
- package/dist/packages/observability/metrics.js +0 -194
- package/dist/packages/observability/metrics.js.map +0 -1
- package/dist/packages/observability/middleware.d.ts +0 -32
- package/dist/packages/observability/middleware.js +0 -58
- package/dist/packages/observability/middleware.js.map +0 -1
- package/dist/packages/review/analysis-engine.d.ts +0 -19
- package/dist/packages/review/analysis-engine.js +0 -111
- package/dist/packages/review/analysis-engine.js.map +0 -1
- package/dist/packages/review/index.d.ts +0 -12
- package/dist/packages/review/index.js +0 -29
- package/dist/packages/review/index.js.map +0 -1
- package/dist/packages/review/parser-n8n.d.ts +0 -2
- package/dist/packages/review/parser-n8n.js +0 -122
- package/dist/packages/review/parser-n8n.js.map +0 -1
- package/dist/packages/review/providers/github.d.ts +0 -62
- package/dist/packages/review/providers/github.js +0 -275
- package/dist/packages/review/providers/github.js.map +0 -1
- package/dist/packages/review/providers.d.ts +0 -106
- package/dist/packages/review/providers.js +0 -12
- package/dist/packages/review/providers.js.map +0 -1
- package/dist/packages/review/reporter.d.ts +0 -17
- package/dist/packages/review/reporter.js +0 -59
- package/dist/packages/review/reporter.js.map +0 -1
- package/dist/packages/review/rules/index.d.ts +0 -9
- package/dist/packages/review/rules/index.js +0 -415
- package/dist/packages/review/rules/index.js.map +0 -1
- package/dist/packages/review/rules/rule-utils.d.ts +0 -36
- package/dist/packages/review/rules/rule-utils.js +0 -75
- package/dist/packages/review/rules/rule-utils.js.map +0 -1
- package/dist/packages/review/schemas/index.d.ts +0 -17
- package/dist/packages/review/schemas/index.js +0 -167
- package/dist/packages/review/schemas/index.js.map +0 -1
- package/dist/packages/review/schemas/n8n-workflow.schema.json +0 -177
- package/dist/packages/review/sniffer.d.ts +0 -15
- package/dist/packages/review/sniffer.js +0 -47
- package/dist/packages/review/sniffer.js.map +0 -1
- package/dist/packages/review/types.d.ts +0 -40
- package/dist/packages/review/types.js +0 -3
- package/dist/packages/review/types.js.map +0 -1
- package/dist/packages/review/utils/findings.d.ts +0 -23
- package/dist/packages/review/utils/findings.js +0 -34
- package/dist/packages/review/utils/findings.js.map +0 -1
- package/dist/packages/review/utils/merge.d.ts +0 -12
- package/dist/packages/review/utils/merge.js +0 -40
- package/dist/packages/review/utils/merge.js.map +0 -1
- package/dist/packages/review/utils.d.ts +0 -60
- package/dist/packages/review/utils.js +0 -214
- package/dist/packages/review/utils.js.map +0 -1
- package/dist/packages/tracing/github-tracer.d.ts +0 -38
- package/dist/packages/tracing/github-tracer.js +0 -79
- package/dist/packages/tracing/github-tracer.js.map +0 -1
- package/dist/packages/tracing/index.d.ts +0 -81
- package/dist/packages/tracing/index.js +0 -240
- package/dist/packages/tracing/index.js.map +0 -1
- package/dist/packages/tracing/tracer.d.ts +0 -30
- package/dist/packages/tracing/tracer.js +0 -141
- package/dist/packages/tracing/tracer.js.map +0 -1
- package/dist/providers/local-config-provider.d.ts +0 -11
- package/dist/providers/local-config-provider.js +0 -39
- package/dist/providers/local-config-provider.js.map +0 -1
- package/dist/providers/local-file-source.d.ts +0 -13
- package/dist/providers/local-file-source.js +0 -47
- package/dist/providers/local-file-source.js.map +0 -1
- package/dist/reporters/console-reporter.d.ts +0 -8
- package/dist/reporters/console-reporter.js +0 -75
- package/dist/reporters/console-reporter.js.map +0 -1
- package/dist/reporters/github-actions-reporter.d.ts +0 -30
- package/dist/reporters/github-actions-reporter.js +0 -104
- package/dist/reporters/github-actions-reporter.js.map +0 -1
- package/dist/reporters/json-reporter.d.ts +0 -14
- package/dist/reporters/json-reporter.js +0 -57
- package/dist/reporters/json-reporter.js.map +0 -1
- package/dist/reporters/junit-reporter.d.ts +0 -25
- package/dist/reporters/junit-reporter.js +0 -142
- package/dist/reporters/junit-reporter.js.map +0 -1
- package/dist/reporters/sarif-reporter.d.ts +0 -21
- package/dist/reporters/sarif-reporter.js +0 -125
- package/dist/reporters/sarif-reporter.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findings.js","sourceRoot":"","sources":["../../../../packages/review/utils/findings.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAcH,0DAOC;AAKD,4CAEC;AAKD,wDAGC;AAzBD;;GAEG;AACH,SAAgB,uBAAuB,CAAC,QAAmB;IACzD,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM;QAC1D,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,MAAM;QAC9D,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,MAAM;QACxD,KAAK,EAAE,QAAQ,CAAC,MAAM;KACvB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,QAAmB;IACxD,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;IACjC,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deep merge utilities
|
|
3
|
-
* Shared logic for merging configuration objects
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Deep merge configuration objects
|
|
7
|
-
*/
|
|
8
|
-
export declare function deepMerge<T>(base: T, override: Record<string, unknown>): T;
|
|
9
|
-
/**
|
|
10
|
-
* Recursively merge source object into target object
|
|
11
|
-
*/
|
|
12
|
-
export declare function mergeInto(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Deep merge utilities
|
|
4
|
-
* Shared logic for merging configuration objects
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.deepMerge = deepMerge;
|
|
8
|
-
exports.mergeInto = mergeInto;
|
|
9
|
-
/**
|
|
10
|
-
* Deep merge configuration objects
|
|
11
|
-
*/
|
|
12
|
-
function deepMerge(base, override) {
|
|
13
|
-
const baseCopy = JSON.parse(JSON.stringify(base));
|
|
14
|
-
if (!override)
|
|
15
|
-
return baseCopy;
|
|
16
|
-
return mergeInto(baseCopy, override);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Recursively merge source object into target object
|
|
20
|
-
*/
|
|
21
|
-
function mergeInto(target, source) {
|
|
22
|
-
for (const [key, value] of Object.entries(source)) {
|
|
23
|
-
if (value === undefined || value === null)
|
|
24
|
-
continue;
|
|
25
|
-
if (Array.isArray(value)) {
|
|
26
|
-
target[key] = value;
|
|
27
|
-
}
|
|
28
|
-
else if (typeof value === 'object') {
|
|
29
|
-
if (typeof target[key] !== 'object' || target[key] === null) {
|
|
30
|
-
target[key] = {};
|
|
31
|
-
}
|
|
32
|
-
mergeInto(target[key], value);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
target[key] = value;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return target;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=merge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../../packages/review/utils/merge.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,8BAIC;AAKD,8BAeC;AA3BD;;GAEG;AACH,SAAgB,SAAS,CAAI,IAAO,EAAE,QAAiC;IACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,IAAI,CAAC,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC/B,OAAO,SAAS,CAAC,QAAe,EAAE,QAAQ,CAAM,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,MAA+B,EAAE,MAA+B;IACxF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QACpD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC5D,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACnB,CAAC;YACD,SAAS,CAAC,MAAM,CAAC,GAAG,CAA4B,EAAE,KAAgC,CAAC,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { Graph, NodeRef } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Shared utility functions for workflow parsing and validation
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Helper to flatten nested connection arrays from n8n workflow connections.
|
|
7
|
-
* Connections can be nested in various ways (arrays of arrays, objects with node properties).
|
|
8
|
-
* This recursively flattens them to a simple array of connection objects.
|
|
9
|
-
*
|
|
10
|
-
* @param value - The connection value to flatten (can be array, object, or primitive)
|
|
11
|
-
* @returns Array of connection objects with 'node' property
|
|
12
|
-
*/
|
|
13
|
-
export declare function flattenConnections(value: any): any[];
|
|
14
|
-
/**
|
|
15
|
-
* Build validation error objects from a collection of items using provided templates.
|
|
16
|
-
* This utility eliminates code duplication in validation error construction.
|
|
17
|
-
*
|
|
18
|
-
* @template T - Type of items to process
|
|
19
|
-
* @param items - Set or array of items to convert to validation errors
|
|
20
|
-
* @param errorConfig - Configuration object containing:
|
|
21
|
-
* - path: The JSON path where the error occurred
|
|
22
|
-
* - messageTemplate: Function to generate error message for each item
|
|
23
|
-
* - suggestionTemplate: Function to generate actionable suggestion for each item
|
|
24
|
-
* @returns Array of validation error objects with path, message, and suggestion fields
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const duplicates = new Set(['node1', 'node2']);
|
|
29
|
-
* const errors = buildValidationErrors(duplicates, {
|
|
30
|
-
* path: 'nodes[].id',
|
|
31
|
-
* messageTemplate: (id) => `Duplicate node ID: "${id}"`,
|
|
32
|
-
* suggestionTemplate: (id) => `Remove or rename the duplicate node with ID "${id}".`
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function buildValidationErrors<T>(items: Set<T> | T[], errorConfig: {
|
|
37
|
-
path: string;
|
|
38
|
-
messageTemplate: (item: T) => string;
|
|
39
|
-
suggestionTemplate: (item: T) => string;
|
|
40
|
-
}): Array<{
|
|
41
|
-
path: string;
|
|
42
|
-
message: string;
|
|
43
|
-
suggestion: string;
|
|
44
|
-
}>;
|
|
45
|
-
export declare function collectStrings(value: unknown, out?: string[]): string[];
|
|
46
|
-
export declare function toRegex(pattern: string): RegExp;
|
|
47
|
-
export declare function isApiNode(type: string): boolean;
|
|
48
|
-
export declare function isMutationNode(type: string): boolean;
|
|
49
|
-
export declare function isErrorProneNode(type: string): boolean;
|
|
50
|
-
export declare function isNotificationNode(type: string): boolean;
|
|
51
|
-
export declare function isErrorHandlerNode(type: string, name?: string): boolean;
|
|
52
|
-
export declare function isRejoinNode(graph: Graph, nodeId: string): boolean;
|
|
53
|
-
export declare function isMeaningfulConsumer(node: NodeRef): boolean;
|
|
54
|
-
export declare function containsCandidate(value: unknown, candidates: string[]): boolean;
|
|
55
|
-
export declare function isTerminalNode(type: string, name?: string): boolean;
|
|
56
|
-
export declare function readNumber(source: any, paths: string[]): number | undefined;
|
|
57
|
-
export declare function findAllDownstreamNodes(graph: Graph, startNodeId: string): Set<string>;
|
|
58
|
-
export declare function findAllUpstreamNodes(graph: Graph, startNodeId: string): Set<string>;
|
|
59
|
-
export declare const EXAMPLES_BASE_URL = "https://github.com/Replikanti/flowlint-examples/tree/main";
|
|
60
|
-
export declare function getExampleLink(ruleId: string): string;
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EXAMPLES_BASE_URL = void 0;
|
|
4
|
-
exports.flattenConnections = flattenConnections;
|
|
5
|
-
exports.buildValidationErrors = buildValidationErrors;
|
|
6
|
-
exports.collectStrings = collectStrings;
|
|
7
|
-
exports.toRegex = toRegex;
|
|
8
|
-
exports.isApiNode = isApiNode;
|
|
9
|
-
exports.isMutationNode = isMutationNode;
|
|
10
|
-
exports.isErrorProneNode = isErrorProneNode;
|
|
11
|
-
exports.isNotificationNode = isNotificationNode;
|
|
12
|
-
exports.isErrorHandlerNode = isErrorHandlerNode;
|
|
13
|
-
exports.isRejoinNode = isRejoinNode;
|
|
14
|
-
exports.isMeaningfulConsumer = isMeaningfulConsumer;
|
|
15
|
-
exports.containsCandidate = containsCandidate;
|
|
16
|
-
exports.isTerminalNode = isTerminalNode;
|
|
17
|
-
exports.readNumber = readNumber;
|
|
18
|
-
exports.findAllDownstreamNodes = findAllDownstreamNodes;
|
|
19
|
-
exports.findAllUpstreamNodes = findAllUpstreamNodes;
|
|
20
|
-
exports.getExampleLink = getExampleLink;
|
|
21
|
-
/**
|
|
22
|
-
* Shared utility functions for workflow parsing and validation
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* Helper to flatten nested connection arrays from n8n workflow connections.
|
|
26
|
-
* Connections can be nested in various ways (arrays of arrays, objects with node properties).
|
|
27
|
-
* This recursively flattens them to a simple array of connection objects.
|
|
28
|
-
*
|
|
29
|
-
* @param value - The connection value to flatten (can be array, object, or primitive)
|
|
30
|
-
* @returns Array of connection objects with 'node' property
|
|
31
|
-
*/
|
|
32
|
-
function flattenConnections(value) {
|
|
33
|
-
if (!value)
|
|
34
|
-
return [];
|
|
35
|
-
if (Array.isArray(value)) {
|
|
36
|
-
return value.flatMap((entry) => flattenConnections(entry));
|
|
37
|
-
}
|
|
38
|
-
if (typeof value === 'object' && 'node' in value) {
|
|
39
|
-
return [value];
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Build validation error objects from a collection of items using provided templates.
|
|
45
|
-
* This utility eliminates code duplication in validation error construction.
|
|
46
|
-
*
|
|
47
|
-
* @template T - Type of items to process
|
|
48
|
-
* @param items - Set or array of items to convert to validation errors
|
|
49
|
-
* @param errorConfig - Configuration object containing:
|
|
50
|
-
* - path: The JSON path where the error occurred
|
|
51
|
-
* - messageTemplate: Function to generate error message for each item
|
|
52
|
-
* - suggestionTemplate: Function to generate actionable suggestion for each item
|
|
53
|
-
* @returns Array of validation error objects with path, message, and suggestion fields
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* const duplicates = new Set(['node1', 'node2']);
|
|
58
|
-
* const errors = buildValidationErrors(duplicates, {
|
|
59
|
-
* path: 'nodes[].id',
|
|
60
|
-
* messageTemplate: (id) => `Duplicate node ID: "${id}"`,
|
|
61
|
-
* suggestionTemplate: (id) => `Remove or rename the duplicate node with ID "${id}".`
|
|
62
|
-
* });
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
function buildValidationErrors(items, errorConfig) {
|
|
66
|
-
const itemArray = Array.isArray(items) ? items : Array.from(items);
|
|
67
|
-
return itemArray.map((item) => ({
|
|
68
|
-
path: errorConfig.path,
|
|
69
|
-
message: errorConfig.messageTemplate(item),
|
|
70
|
-
suggestion: errorConfig.suggestionTemplate(item),
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
function collectStrings(value, out = []) {
|
|
74
|
-
if (typeof value === 'string')
|
|
75
|
-
out.push(value);
|
|
76
|
-
else if (Array.isArray(value))
|
|
77
|
-
value.forEach((entry) => collectStrings(entry, out));
|
|
78
|
-
else if (value && typeof value === 'object')
|
|
79
|
-
Object.values(value).forEach((entry) => collectStrings(entry, out));
|
|
80
|
-
return out;
|
|
81
|
-
}
|
|
82
|
-
function toRegex(pattern) {
|
|
83
|
-
let source = pattern;
|
|
84
|
-
let flags = '';
|
|
85
|
-
if (source.startsWith('(?i)')) {
|
|
86
|
-
source = source.slice(4);
|
|
87
|
-
flags += 'i';
|
|
88
|
-
}
|
|
89
|
-
return new RegExp(source, flags);
|
|
90
|
-
}
|
|
91
|
-
function isApiNode(type) {
|
|
92
|
-
return /http|request|google|facebook|ads/i.test(type);
|
|
93
|
-
}
|
|
94
|
-
function isMutationNode(type) {
|
|
95
|
-
return /write|insert|update|delete|post|put|patch|database|mongo|supabase|sheet/i.test(type);
|
|
96
|
-
}
|
|
97
|
-
function isErrorProneNode(type) {
|
|
98
|
-
return isApiNode(type) || isMutationNode(type) || /execute|workflow|function/i.test(type);
|
|
99
|
-
}
|
|
100
|
-
function isNotificationNode(type) {
|
|
101
|
-
return /slack|discord|email|gotify|mattermost|microsoftTeams|pushbullet|pushover|rocketchat|zulip|telegram/i.test(type);
|
|
102
|
-
}
|
|
103
|
-
function isErrorHandlerNode(type, name) {
|
|
104
|
-
const normalizedType = type.toLowerCase();
|
|
105
|
-
if (normalizedType.includes('stopanderror'))
|
|
106
|
-
return true;
|
|
107
|
-
if (normalizedType.includes('errorhandler'))
|
|
108
|
-
return true;
|
|
109
|
-
if (normalizedType.includes('raiseerror'))
|
|
110
|
-
return true;
|
|
111
|
-
const normalizedName = name?.toLowerCase() ?? '';
|
|
112
|
-
if (normalizedName.includes('stop and error'))
|
|
113
|
-
return true;
|
|
114
|
-
if (normalizedName.includes('error handler'))
|
|
115
|
-
return true;
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
function isRejoinNode(graph, nodeId) {
|
|
119
|
-
const incoming = graph.edges.filter((e) => e.to === nodeId);
|
|
120
|
-
if (incoming.length <= 1)
|
|
121
|
-
return false;
|
|
122
|
-
const hasErrorEdge = incoming.some((e) => e.on === 'error');
|
|
123
|
-
const hasSuccessEdge = incoming.some((e) => e.on !== 'error');
|
|
124
|
-
return hasErrorEdge && hasSuccessEdge;
|
|
125
|
-
}
|
|
126
|
-
function isMeaningfulConsumer(node) {
|
|
127
|
-
// A meaningful consumer is a node that has an external side-effect.
|
|
128
|
-
return (isMutationNode(node.type) || // Writes to a DB, sheet, etc.
|
|
129
|
-
isNotificationNode(node.type) || // Sends a message to Slack, email, etc.
|
|
130
|
-
isApiNode(node.type) || // Calls an external API
|
|
131
|
-
/respondToWebhook/i.test(node.type) // Specifically nodes that send a response back.
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
function containsCandidate(value, candidates) {
|
|
135
|
-
if (!value || !candidates.length)
|
|
136
|
-
return false;
|
|
137
|
-
const queue = [value];
|
|
138
|
-
const candidateRegex = new RegExp(`(${candidates.join('|')})`, 'i');
|
|
139
|
-
while (queue.length > 0) {
|
|
140
|
-
const current = queue.shift();
|
|
141
|
-
if (typeof current === 'string') {
|
|
142
|
-
if (candidateRegex.test(current))
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
else if (Array.isArray(current)) {
|
|
146
|
-
queue.push(...current);
|
|
147
|
-
}
|
|
148
|
-
else if (current && typeof current === 'object') {
|
|
149
|
-
for (const [key, val] of Object.entries(current)) {
|
|
150
|
-
if (candidateRegex.test(key))
|
|
151
|
-
return true;
|
|
152
|
-
queue.push(val);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
const TERMINAL_NODE_PATTERNS = [
|
|
159
|
-
'respond', 'reply', 'end', 'stop', 'terminate', 'return', 'sticky', 'note', 'noop', 'no operation',
|
|
160
|
-
'slack', 'email', 'discord', 'teams', 'webhook', 'telegram', 'pushbullet', 'mattermost', 'notifier', 'notification', 'alert', 'sms', 'call',
|
|
161
|
-
];
|
|
162
|
-
function isTerminalNode(type, name) {
|
|
163
|
-
const label = `${type} ${name ?? ''}`.toLowerCase();
|
|
164
|
-
return TERMINAL_NODE_PATTERNS.some((pattern) => label.includes(pattern));
|
|
165
|
-
}
|
|
166
|
-
function readNumber(source, paths) {
|
|
167
|
-
for (const path of paths) {
|
|
168
|
-
const value = path.split('.').reduce((acc, key) => (acc ? acc[key] : undefined), source);
|
|
169
|
-
if (typeof value === 'number')
|
|
170
|
-
return value;
|
|
171
|
-
if (typeof value === 'string' && !Number.isNaN(Number(value)))
|
|
172
|
-
return Number(value);
|
|
173
|
-
}
|
|
174
|
-
return undefined;
|
|
175
|
-
}
|
|
176
|
-
function findAllDownstreamNodes(graph, startNodeId) {
|
|
177
|
-
const visited = new Set();
|
|
178
|
-
const queue = [startNodeId];
|
|
179
|
-
visited.add(startNodeId);
|
|
180
|
-
let head = 0;
|
|
181
|
-
while (head < queue.length) {
|
|
182
|
-
const currentId = queue[head++];
|
|
183
|
-
const outgoing = graph.edges.filter((e) => e.from === currentId);
|
|
184
|
-
for (const edge of outgoing) {
|
|
185
|
-
if (!visited.has(edge.to)) {
|
|
186
|
-
visited.add(edge.to);
|
|
187
|
-
queue.push(edge.to);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return visited;
|
|
192
|
-
}
|
|
193
|
-
function findAllUpstreamNodes(graph, startNodeId) {
|
|
194
|
-
const visited = new Set();
|
|
195
|
-
const queue = [startNodeId];
|
|
196
|
-
visited.add(startNodeId);
|
|
197
|
-
let head = 0;
|
|
198
|
-
while (head < queue.length) {
|
|
199
|
-
const currentId = queue[head++];
|
|
200
|
-
const incoming = graph.edges.filter((e) => e.to === currentId);
|
|
201
|
-
for (const edge of incoming) {
|
|
202
|
-
if (!visited.has(edge.from)) {
|
|
203
|
-
visited.add(edge.from);
|
|
204
|
-
queue.push(edge.from);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return visited;
|
|
209
|
-
}
|
|
210
|
-
exports.EXAMPLES_BASE_URL = "https://github.com/Replikanti/flowlint-examples/tree/main";
|
|
211
|
-
function getExampleLink(ruleId) {
|
|
212
|
-
return `${exports.EXAMPLES_BASE_URL}/${ruleId}`;
|
|
213
|
-
}
|
|
214
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../packages/review/utils.ts"],"names":[],"mappings":";;;AAeA,gDASC;AAwBD,sDAcC;AAED,wCAMC;AAED,0BAQC;AAED,8BAEC;AAED,wCAEC;AAED,4CAEC;AAED,gDAIC;AAED,gDAWC;AAED,oCAMC;AAED,oDAQC;AAED,8CAsBC;AAOD,wCAGC;AAED,gCAOC;AAED,wDAiBC;AAED,oDAiBC;AAID,wCAEC;AAtND;;GAEG;AAGH;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,KAAU;IAC3C,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;QACjD,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,qBAAqB,CACnC,KAAmB,EACnB,WAIC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,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WAAW,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEzB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAE,CAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;QAC/D,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAEY,QAAA,iBAAiB,GAAG,2DAA2D,CAAC;AAE7F,SAAgB,cAAc,CAAC,MAAc;IAC3C,OAAO,GAAG,yBAAiB,IAAI,MAAM,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GitHub API tracing wrapper
|
|
3
|
-
* Instruments GitHub API calls with OpenTelemetry spans
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Wrap a GitHub API call with tracing
|
|
7
|
-
*/
|
|
8
|
-
export declare function traceGitHubApiCall<T>(method: string, endpoint: string, fn: () => Promise<T>, additionalAttributes?: Record<string, string | number | boolean>): Promise<T>;
|
|
9
|
-
/**
|
|
10
|
-
* GitHub API call attributes for common operations
|
|
11
|
-
*/
|
|
12
|
-
export declare const GitHubApiAttributes: {
|
|
13
|
-
listFiles: (owner: string, repo: string, prNumber: number) => {
|
|
14
|
-
'github.repo.owner': string;
|
|
15
|
-
'github.repo.name': string;
|
|
16
|
-
'github.pr.number': number;
|
|
17
|
-
'github.api.operation': string;
|
|
18
|
-
};
|
|
19
|
-
getContent: (owner: string, repo: string, path: string, ref: string) => {
|
|
20
|
-
'github.repo.owner': string;
|
|
21
|
-
'github.repo.name': string;
|
|
22
|
-
'github.file.path': string;
|
|
23
|
-
'github.ref': string;
|
|
24
|
-
'github.api.operation': string;
|
|
25
|
-
};
|
|
26
|
-
createCheckRun: (owner: string, repo: string, sha: string) => {
|
|
27
|
-
'github.repo.owner': string;
|
|
28
|
-
'github.repo.name': string;
|
|
29
|
-
'github.commit.sha': string;
|
|
30
|
-
'github.api.operation': string;
|
|
31
|
-
};
|
|
32
|
-
updateCheckRun: (owner: string, repo: string, checkRunId: number) => {
|
|
33
|
-
'github.repo.owner': string;
|
|
34
|
-
'github.repo.name': string;
|
|
35
|
-
'github.check_run.id': number;
|
|
36
|
-
'github.api.operation': string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* GitHub API tracing wrapper
|
|
4
|
-
* Instruments GitHub API calls with OpenTelemetry spans
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.GitHubApiAttributes = void 0;
|
|
8
|
-
exports.traceGitHubApiCall = traceGitHubApiCall;
|
|
9
|
-
const index_1 = require("./index");
|
|
10
|
-
/**
|
|
11
|
-
* Wrap a GitHub API call with tracing
|
|
12
|
-
*/
|
|
13
|
-
async function traceGitHubApiCall(method, endpoint, fn, additionalAttributes) {
|
|
14
|
-
return (0, index_1.withClientSpan)(index_1.SpanNames.GITHUB_API_CALL, async (span) => {
|
|
15
|
-
span.setAttributes({
|
|
16
|
-
'github.api.method': method,
|
|
17
|
-
'github.api.endpoint': endpoint,
|
|
18
|
-
'http.method': method,
|
|
19
|
-
'http.url': endpoint,
|
|
20
|
-
...additionalAttributes,
|
|
21
|
-
});
|
|
22
|
-
const startTime = Date.now();
|
|
23
|
-
try {
|
|
24
|
-
const result = await fn();
|
|
25
|
-
const duration = Date.now() - startTime;
|
|
26
|
-
span.setAttributes({
|
|
27
|
-
'github.api.duration_ms': duration,
|
|
28
|
-
'http.status_code': 200, // Assuming success
|
|
29
|
-
});
|
|
30
|
-
span.addEvent('github.api.call.success', {
|
|
31
|
-
duration_ms: duration,
|
|
32
|
-
});
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
const duration = Date.now() - startTime;
|
|
37
|
-
span.setAttributes({
|
|
38
|
-
'github.api.duration_ms': duration,
|
|
39
|
-
'github.api.error': true,
|
|
40
|
-
'error.type': error instanceof Error ? error.constructor.name : 'UnknownError',
|
|
41
|
-
});
|
|
42
|
-
if (error instanceof Error) {
|
|
43
|
-
span.recordException(error);
|
|
44
|
-
}
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* GitHub API call attributes for common operations
|
|
51
|
-
*/
|
|
52
|
-
exports.GitHubApiAttributes = {
|
|
53
|
-
listFiles: (owner, repo, prNumber) => ({
|
|
54
|
-
'github.repo.owner': owner,
|
|
55
|
-
'github.repo.name': repo,
|
|
56
|
-
'github.pr.number': prNumber,
|
|
57
|
-
'github.api.operation': 'list_pr_files',
|
|
58
|
-
}),
|
|
59
|
-
getContent: (owner, repo, path, ref) => ({
|
|
60
|
-
'github.repo.owner': owner,
|
|
61
|
-
'github.repo.name': repo,
|
|
62
|
-
'github.file.path': path,
|
|
63
|
-
'github.ref': ref,
|
|
64
|
-
'github.api.operation': 'get_content',
|
|
65
|
-
}),
|
|
66
|
-
createCheckRun: (owner, repo, sha) => ({
|
|
67
|
-
'github.repo.owner': owner,
|
|
68
|
-
'github.repo.name': repo,
|
|
69
|
-
'github.commit.sha': sha,
|
|
70
|
-
'github.api.operation': 'create_check_run',
|
|
71
|
-
}),
|
|
72
|
-
updateCheckRun: (owner, repo, checkRunId) => ({
|
|
73
|
-
'github.repo.owner': owner,
|
|
74
|
-
'github.repo.name': repo,
|
|
75
|
-
'github.check_run.id': checkRunId,
|
|
76
|
-
'github.api.operation': 'update_check_run',
|
|
77
|
-
}),
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=github-tracer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"github-tracer.js","sourceRoot":"","sources":["../../../packages/tracing/github-tracer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,gDAkDC;AAxDD,mCAAoD;AAGpD;;GAEG;AACI,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,QAAgB,EAChB,EAAoB,EACpB,oBAAgE;IAEhE,OAAO,IAAA,sBAAc,EACnB,iBAAS,CAAC,eAAe,EACzB,KAAK,EAAE,IAAU,EAAE,EAAE;QACnB,IAAI,CAAC,aAAa,CAAC;YACjB,mBAAmB,EAAE,MAAM;YAC3B,qBAAqB,EAAE,QAAQ;YAC/B,aAAa,EAAE,MAAM;YACrB,UAAU,EAAE,QAAQ;YACpB,GAAG,oBAAoB;SACxB,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YAExC,IAAI,CAAC,aAAa,CAAC;gBACjB,wBAAwB,EAAE,QAAQ;gBAClC,kBAAkB,EAAE,GAAG,EAAE,mBAAmB;aAC7C,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,yBAAyB,EAAE;gBACvC,WAAW,EAAE,QAAQ;aACtB,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OA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ACpE,mBAAmB,EAAE,KAAK;QAC1B,kBAAkB,EAAE,IAAI;QACxB,qBAAqB,EAAE,UAAU;QACjC,sBAAsB,EAAE,kBAAkB;KAC3C,CAAC;CACH,CAAC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FlowLint Distributed Tracing Package
|
|
3
|
-
*
|
|
4
|
-
* Provides OpenTelemetry-based distributed tracing for FlowLint.
|
|
5
|
-
* Tracks request flow from webhook reception through job processing to Check Run creation.
|
|
6
|
-
*
|
|
7
|
-
* @module packages/tracing
|
|
8
|
-
*/
|
|
9
|
-
import { Tracer, Span, SpanStatusCode, Context, context, trace, propagation } from '@opentelemetry/api';
|
|
10
|
-
/**
|
|
11
|
-
* Trace span names following OpenTelemetry semantic conventions
|
|
12
|
-
*/
|
|
13
|
-
export declare const SpanNames: {
|
|
14
|
-
readonly WEBHOOK_RECEIVED: "webhook.received";
|
|
15
|
-
readonly WEBHOOK_VERIFY_SIGNATURE: "webhook.verify_signature";
|
|
16
|
-
readonly JOB_ENQUEUED: "job.enqueued";
|
|
17
|
-
readonly JOB_PROCESSED: "job.processed";
|
|
18
|
-
readonly JOB_FETCH_FILES: "job.fetch_files";
|
|
19
|
-
readonly JOB_LOAD_CONFIG: "job.load_config";
|
|
20
|
-
readonly JOB_PARSE_WORKFLOW: "job.parse_workflow";
|
|
21
|
-
readonly JOB_RUN_RULES: "job.run_rules";
|
|
22
|
-
readonly JOB_CREATE_CHECK_RUN: "job.create_check_run";
|
|
23
|
-
readonly GITHUB_API_CALL: "github.api_call";
|
|
24
|
-
readonly LINT_RULE_EXECUTE: "lint.rule.execute";
|
|
25
|
-
readonly REDIS_OPERATION: "redis.operation";
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Get the configured tracer instance
|
|
29
|
-
*/
|
|
30
|
-
export declare function getTracerInstance(): Tracer;
|
|
31
|
-
/**
|
|
32
|
-
* Start a new span with the given name and attributes
|
|
33
|
-
*/
|
|
34
|
-
export declare function startSpan(name: string, attributes?: Record<string, string | number | boolean>, parentContext?: Context): Span;
|
|
35
|
-
/**
|
|
36
|
-
* Start a server span (for incoming requests)
|
|
37
|
-
*/
|
|
38
|
-
export declare function startServerSpan(name: string, attributes?: Record<string, string | number | boolean>, parentContext?: Context): Span;
|
|
39
|
-
/**
|
|
40
|
-
* Start a client span (for outgoing requests)
|
|
41
|
-
*/
|
|
42
|
-
export declare function startClientSpan(name: string, attributes?: Record<string, string | number | boolean>, parentContext?: Context): Span;
|
|
43
|
-
/**
|
|
44
|
-
* Execute a function within a span context
|
|
45
|
-
*/
|
|
46
|
-
export declare function withSpan<T>(name: string, fn: (span: Span) => Promise<T>, attributes?: Record<string, string | number | boolean>, parentContext?: Context): Promise<T>;
|
|
47
|
-
/**
|
|
48
|
-
* Execute a synchronous function within a span context
|
|
49
|
-
*/
|
|
50
|
-
export declare function withSpanSync<T>(name: string, fn: (span: Span) => T, attributes?: Record<string, string | number | boolean>, parentContext?: Context): T;
|
|
51
|
-
/**
|
|
52
|
-
* Execute a function within a server span context (for incoming requests)
|
|
53
|
-
*/
|
|
54
|
-
export declare function withServerSpan<T>(name: string, fn: (span: Span) => Promise<T>, attributes?: Record<string, string | number | boolean>, parentContext?: Context): Promise<T>;
|
|
55
|
-
/**
|
|
56
|
-
* Execute a function within a client span context (for outgoing requests)
|
|
57
|
-
*/
|
|
58
|
-
export declare function withClientSpan<T>(name: string, fn: (span: Span) => Promise<T>, attributes?: Record<string, string | number | boolean>, parentContext?: Context): Promise<T>;
|
|
59
|
-
/**
|
|
60
|
-
* Add an event to the current active span
|
|
61
|
-
*/
|
|
62
|
-
export declare function addSpanEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
63
|
-
/**
|
|
64
|
-
* Set attributes on the current active span
|
|
65
|
-
*/
|
|
66
|
-
export declare function setSpanAttributes(attributes: Record<string, string | number | boolean>): void;
|
|
67
|
-
/**
|
|
68
|
-
* Record an exception on the current active span
|
|
69
|
-
*/
|
|
70
|
-
export declare function recordSpanException(error: Error): void;
|
|
71
|
-
/**
|
|
72
|
-
* Get the current active span
|
|
73
|
-
*/
|
|
74
|
-
export declare function getActiveSpan(): Span | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* Get the current trace context
|
|
77
|
-
*/
|
|
78
|
-
export declare function getActiveContext(): Context;
|
|
79
|
-
export { Span, SpanStatusCode, Context, trace, context, propagation };
|
|
80
|
-
export { initTracing, shutdownTracing } from './tracer';
|
|
81
|
-
export { traceGitHubApiCall, GitHubApiAttributes } from './github-tracer';
|