@dataparade/cli 0.0.13 → 0.0.15

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.
Files changed (81) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/ai-enrichment/candidate-selector.d.ts +4 -4
  3. package/dist/src/ai-enrichment/candidate-selector.js +37 -32
  4. package/dist/src/ai-enrichment/fallbacks.js +130 -3
  5. package/dist/src/ai-enrichment/merge-rules.d.ts +3 -3
  6. package/dist/src/ai-enrichment/merge-rules.js +118 -40
  7. package/dist/src/ai-enrichment/prompts/provider-enrichment-prompts.d.ts +2 -2
  8. package/dist/src/ai-enrichment/prompts/provider-enrichment-prompts.js +3 -3
  9. package/dist/src/ai-enrichment/property-priority.d.ts +5 -0
  10. package/dist/src/ai-enrichment/property-priority.js +23 -0
  11. package/dist/src/ai-enrichment/provider-prompt.d.ts +5 -5
  12. package/dist/src/ai-enrichment/provider-prompt.js +24 -19
  13. package/dist/src/ai-enrichment/red-flags.d.ts +46 -0
  14. package/dist/src/ai-enrichment/red-flags.js +365 -0
  15. package/dist/src/ai-enrichment/third-party-evidence.d.ts +3 -3
  16. package/dist/src/ai-enrichment/third-party-evidence.js +96 -93
  17. package/dist/src/cli.d.ts +1 -1
  18. package/dist/src/cli.js +236 -143
  19. package/dist/src/core/pipeline/orchestrator-result.d.ts +9 -1
  20. package/dist/src/core/pipeline/orchestrator.d.ts +2 -2
  21. package/dist/src/core/pipeline/scan-pipeline.d.ts +2 -2
  22. package/dist/src/core/pipeline/scan-pipeline.js +46 -34
  23. package/dist/src/core/schema/dataflow-wrapper.schema.d.ts +33 -1
  24. package/dist/src/core/schema/dataflow-wrapper.schema.js +19 -3
  25. package/dist/src/output/json.d.ts +18 -3
  26. package/dist/src/output/json.js +14 -5
  27. package/dist/src/platform-api/cli-scan-failure-report.d.ts +9 -0
  28. package/dist/src/platform-api/cli-scan-failure-report.js +23 -0
  29. package/dist/tests/schema/dataflow-wrapper.schema.spec.js +142 -21
  30. package/dist/tests/unit/ai-enrichment/candidate-selector.spec.js +80 -49
  31. package/dist/tests/unit/ai-enrichment/fallbacks.spec.js +78 -0
  32. package/dist/tests/unit/ai-enrichment/merge-rules.spec.js +510 -264
  33. package/dist/tests/unit/ai-enrichment/provider-prompt.spec.js +80 -77
  34. package/dist/tests/unit/ai-enrichment/red-flags.spec.js +227 -0
  35. package/dist/tests/unit/ai-enrichment/third-party-evidence.spec.js +38 -34
  36. package/dist/tests/unit/cli/scan-command-e2e-backend-lambda-orphan.spec.d.ts +1 -0
  37. package/dist/tests/unit/cli/scan-command-e2e-backend-lambda-orphan.spec.js +60 -0
  38. package/dist/tests/unit/cli/scan-command-e2e-occupied-section-hubs.spec.d.ts +1 -0
  39. package/dist/tests/unit/cli/scan-command-e2e-occupied-section-hubs.spec.js +58 -0
  40. package/dist/tests/unit/cli/scan-command-e2e-ruby-basic.spec.d.ts +1 -0
  41. package/dist/tests/unit/cli/scan-command-e2e-ruby-basic.spec.js +46 -0
  42. package/dist/tests/unit/cli/scan-quota-flow.spec.js +57 -45
  43. package/dist/tests/unit/platform-api/cli-scan-failure-report.spec.d.ts +1 -0
  44. package/dist/tests/unit/platform-api/cli-scan-failure-report.spec.js +25 -0
  45. package/package.json +2 -2
  46. package/dist/tests/fixtures/e2e-ts-sample/db-client-import.d.ts +0 -2
  47. package/dist/tests/fixtures/e2e-ts-sample/db-client-import.js +0 -8
  48. package/dist/tests/fixtures/e2e-ts-sample/db.d.ts +0 -3
  49. package/dist/tests/fixtures/e2e-ts-sample/db.js +0 -7
  50. package/dist/tests/fixtures/e2e-ts-sample/external-api.d.ts +0 -1
  51. package/dist/tests/fixtures/e2e-ts-sample/external-api.js +0 -18
  52. package/dist/tests/fixtures/e2e-ts-sample/pg-client.d.ts +0 -3
  53. package/dist/tests/fixtures/e2e-ts-sample/pg-client.js +0 -7
  54. package/dist/tests/fixtures/e2e-ts-sample/server.d.ts +0 -14
  55. package/dist/tests/fixtures/e2e-ts-sample/server.js +0 -4
  56. package/dist/tests/fixtures/e2e-ts-sentry-route-env/server.js +0 -24
  57. package/dist/tests/fixtures/ingest-basic/src/index.d.ts +0 -1
  58. package/dist/tests/fixtures/ingest-basic/src/index.js +0 -6
  59. package/dist/tests/fixtures/mixed-language-basic/api.d.ts +0 -2
  60. package/dist/tests/fixtures/mixed-language-basic/api.js +0 -12
  61. package/dist/tests/fixtures/monorepo-app-plus-terraform/packages/app/app/route.d.ts +0 -1
  62. package/dist/tests/fixtures/monorepo-app-plus-terraform/packages/app/app/route.js +0 -6
  63. package/dist/tests/fixtures/monorepo-front-back-sections/backend/app/route.d.ts +0 -1
  64. package/dist/tests/fixtures/monorepo-front-back-sections/backend/app/route.js +0 -6
  65. package/dist/tests/fixtures/monorepo-front-back-sections/frontend/app/route.d.ts +0 -1
  66. package/dist/tests/fixtures/monorepo-front-back-sections/frontend/app/route.js +0 -7
  67. package/dist/tests/fixtures/typescript-basic/app/route.d.ts +0 -1
  68. package/dist/tests/fixtures/typescript-basic/app/route.js +0 -7
  69. package/dist/tests/fixtures/typescript-basic/db-client-import.d.ts +0 -2
  70. package/dist/tests/fixtures/typescript-basic/db-client-import.js +0 -8
  71. package/dist/tests/fixtures/typescript-basic/db.d.ts +0 -3
  72. package/dist/tests/fixtures/typescript-basic/db.js +0 -7
  73. package/dist/tests/fixtures/typescript-basic/external-api.d.ts +0 -1
  74. package/dist/tests/fixtures/typescript-basic/external-api.js +0 -18
  75. package/dist/tests/fixtures/typescript-basic/pg-client.d.ts +0 -3
  76. package/dist/tests/fixtures/typescript-basic/pg-client.js +0 -7
  77. package/dist/tests/fixtures/typescript-basic/server.d.ts +0 -14
  78. package/dist/tests/fixtures/typescript-basic/server.js +0 -4
  79. package/dist/tests/fixtures/typescript-dependency-manifests-basic/src/index.d.ts +0 -0
  80. package/dist/tests/fixtures/typescript-dependency-manifests-basic/src/index.js +0 -2
  81. /package/dist/tests/{fixtures/e2e-ts-sentry-route-env/server.d.ts → unit/ai-enrichment/red-flags.spec.d.ts} +0 -0
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const cli_1 = require("../../../src/cli");
10
+ const dataflow_wrapper_schema_1 = require("../../../src/core/schema/dataflow-wrapper.schema");
11
+ describe('cli scan command - backend lambda handler absorb', () => {
12
+ it('absorbs the AWS handler into Aws Lambda and wires the section hub', async () => {
13
+ const fixturesRoot = path_1.default.join(__dirname, '..', '..', 'fixtures', 'backend-lambda-orphan');
14
+ const outputPath = path_1.default.join(os_1.default.tmpdir(), `dataparade-scan-e2e-backend-lambda-orphan-${Date.now()}.json`);
15
+ await (0, cli_1.run)([
16
+ 'node',
17
+ 'cli',
18
+ 'scan',
19
+ fixturesRoot,
20
+ '--output',
21
+ outputPath,
22
+ '--no-ai-inference',
23
+ '--skip-auto-upload',
24
+ ]);
25
+ const contents = fs_1.default.readFileSync(outputPath, 'utf8');
26
+ const parsed = JSON.parse(contents);
27
+ const validation = (0, dataflow_wrapper_schema_1.validateDataflowJson)(parsed);
28
+ expect(validation.ok).toBe(true);
29
+ if (!validation.ok)
30
+ return;
31
+ const { graph, metadata } = validation.value;
32
+ const backendNodes = graph.nodes.filter((n) => n?.data?.section_id === 'backend');
33
+ expect(backendNodes.length).toBeGreaterThanOrEqual(1);
34
+ const hubs = backendNodes.filter((n) => n?.data?.isMainApplication === true ||
35
+ n?.data?.isMainApplication === 'true');
36
+ expect(hubs.length).toBeGreaterThanOrEqual(1);
37
+ const hubIds = new Set(hubs.map((h) => h.id));
38
+ const handlerNodes = backendNodes.filter((n) => {
39
+ if (hubIds.has(n.id))
40
+ return false;
41
+ const subType = String(n?.data?.componentSubType ?? n?.data?.subType ?? '');
42
+ return (subType === 'function' || n?.data?.handlerType === 'serverless_handler');
43
+ });
44
+ expect(handlerNodes).toHaveLength(0);
45
+ const lambdaNodes = backendNodes.filter((n) => n?.data?.managed_service_key === 'lambda' ||
46
+ (String(n?.data?.componentSubType ?? '') === 'compute_service' &&
47
+ /lambda/i.test(String(n?.data?.label ?? ''))));
48
+ expect(lambdaNodes.length).toBeGreaterThanOrEqual(1);
49
+ const lambdaIds = new Set(lambdaNodes.map((n) => n.id));
50
+ const hubLinkedToLambda = graph.edges.some((e) => (hubIds.has(e.source) && lambdaIds.has(e.target)) ||
51
+ (hubIds.has(e.target) && lambdaIds.has(e.source)));
52
+ expect(hubLinkedToLambda).toBe(true);
53
+ const redFlags = metadata
54
+ ?.redFlags;
55
+ const blocking = (redFlags ?? []).filter((f) => f.sectionId === 'backend' &&
56
+ (f.code === 'missing_section_hub' || f.code === 'disconnected_handler'));
57
+ expect(blocking).toHaveLength(0);
58
+ fs_1.default.unlinkSync(outputPath);
59
+ }, 30000);
60
+ });
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const cli_1 = require("../../../src/cli");
10
+ const dataflow_wrapper_schema_1 = require("../../../src/core/schema/dataflow-wrapper.schema");
11
+ describe('cli scan command - occupied section hubs', () => {
12
+ it('gives every non-empty service section a main-app hub and hub→third_party edges', async () => {
13
+ const fixturesRoot = path_1.default.join(__dirname, '..', '..', 'fixtures', 'tooling-third-party-only');
14
+ const outputPath = path_1.default.join(os_1.default.tmpdir(), `dataparade-scan-e2e-occupied-section-hubs-${Date.now()}.json`);
15
+ await (0, cli_1.run)([
16
+ 'node',
17
+ 'cli',
18
+ 'scan',
19
+ fixturesRoot,
20
+ '--output',
21
+ outputPath,
22
+ '--no-ai-inference',
23
+ '--skip-auto-upload',
24
+ ]);
25
+ const contents = fs_1.default.readFileSync(outputPath, 'utf8');
26
+ const parsed = JSON.parse(contents);
27
+ const validation = (0, dataflow_wrapper_schema_1.validateDataflowJson)(parsed);
28
+ expect(validation.ok).toBe(true);
29
+ if (!validation.ok)
30
+ return;
31
+ const { graph } = validation.value;
32
+ const sectionIds = new Set(graph.nodes
33
+ .map((n) => n?.data?.section_id)
34
+ .filter((v) => typeof v === 'string' && v.trim().length > 0));
35
+ for (const sectionId of sectionIds) {
36
+ if (sectionId === 'root' ||
37
+ sectionId === 'global' ||
38
+ sectionId === '<unsectioned>') {
39
+ continue;
40
+ }
41
+ const sectionNodes = graph.nodes.filter((n) => n?.data?.section_id === sectionId);
42
+ if (sectionNodes.length === 0)
43
+ continue;
44
+ const hubs = sectionNodes.filter((n) => n?.data?.isMainApplication === true ||
45
+ n?.data?.isMainApplication === 'true');
46
+ expect(hubs.length).toBeGreaterThanOrEqual(1);
47
+ const thirdParties = sectionNodes.filter((n) => n?.type === 'third_party' || n?.type === 'third_party_service');
48
+ if (thirdParties.length === 0)
49
+ continue;
50
+ const hubIds = new Set(hubs.map((h) => h.id));
51
+ for (const tp of thirdParties) {
52
+ const linked = graph.edges.some((e) => hubIds.has(e.source) && e.target === tp.id);
53
+ expect(linked).toBe(true);
54
+ }
55
+ }
56
+ fs_1.default.unlinkSync(outputPath);
57
+ }, 20000);
58
+ });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const cli_1 = require("../../../src/cli");
10
+ const dataflow_wrapper_schema_1 = require("../../../src/core/schema/dataflow-wrapper.schema");
11
+ describe('cli scan command - Ruby basic', () => {
12
+ it('emits runtime boundaries without model components', async () => {
13
+ const fixturesRoot = path_1.default.join(__dirname, '..', '..', 'fixtures', 'ruby-basic');
14
+ const outputPath = path_1.default.join(os_1.default.tmpdir(), `dataparade-scan-e2e-ruby-basic-${Date.now()}.json`);
15
+ await (0, cli_1.run)([
16
+ 'node',
17
+ 'cli',
18
+ 'scan',
19
+ fixturesRoot,
20
+ '--output',
21
+ outputPath,
22
+ '--no-ai-inference',
23
+ '--skip-auto-upload',
24
+ ]);
25
+ const validation = (0, dataflow_wrapper_schema_1.validateDataflowJson)(JSON.parse(fs_1.default.readFileSync(outputPath, 'utf8')));
26
+ expect(validation.ok).toBe(true);
27
+ if (!validation.ok)
28
+ return;
29
+ const nodes = validation.value.graph.nodes;
30
+ expect(nodes.filter((node) => {
31
+ const data = node.data;
32
+ return (data.componentType === 'asset' && data.componentSubType === 'database');
33
+ })).toHaveLength(1);
34
+ expect(nodes.filter((node) => {
35
+ const data = node.data;
36
+ return (data.componentType === 'asset' && data.componentSubType === 'api');
37
+ })).toHaveLength(1);
38
+ expect(nodes.some((node) => {
39
+ const data = node.data;
40
+ return (data.componentType === 'third_party' && data.serviceName === 'stripe');
41
+ })).toBe(true);
42
+ expect(nodes.some((node) => ['User', 'Post'].includes(String(node.data.label)))).toBe(false);
43
+ expect(validation.value.graph.edges.some((edge) => edge.source === edge.target)).toBe(false);
44
+ fs_1.default.unlinkSync(outputPath);
45
+ }, 15000);
46
+ });
@@ -11,15 +11,15 @@ function jsonResponse(body, status = 200) {
11
11
  return {
12
12
  ok: status >= 200 && status < 300,
13
13
  status,
14
- statusText: status === 200 ? "OK" : "Error",
14
+ statusText: status === 200 ? 'OK' : 'Error',
15
15
  json: async () => body,
16
16
  };
17
17
  }
18
- describe("scan quota flow", () => {
18
+ describe('scan quota flow', () => {
19
19
  let tempRoot;
20
20
  let fetchMock;
21
21
  beforeEach(() => {
22
- tempRoot = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "dp-scan-quota-"));
22
+ tempRoot = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'dp-scan-quota-'));
23
23
  fetchMock = jest.fn();
24
24
  global.fetch = fetchMock;
25
25
  process.exitCode = 0;
@@ -28,90 +28,102 @@ describe("scan quota flow", () => {
28
28
  fs_1.default.rmSync(tempRoot, { recursive: true, force: true });
29
29
  delete process.env.DATAPARADE_WORKSPACE_API_KEY;
30
30
  delete process.env.DATAPARADE_SKIP_AUTO_UPLOAD;
31
+ delete process.env.SCAN_HOSTED_INFER_PROXY_URL;
31
32
  process.exitCode = 0;
32
33
  });
33
- it("skips quota API when workspace key is present but AI is disabled", async () => {
34
- process.env.DATAPARADE_WORKSPACE_API_KEY = "dp_live_test";
35
- process.env.DATAPARADE_SKIP_AUTO_UPLOAD = "true";
36
- await (0, cli_1.run)(["node", "cli", "scan", tempRoot, "--no-ai-inference"]);
34
+ it('skips anonymous AI session when hosted infer proxy is configured', async () => {
35
+ process.env.SCAN_HOSTED_INFER_PROXY_URL = 'http://127.0.0.1:9/infer';
36
+ process.env.DATAPARADE_SKIP_AUTO_UPLOAD = 'true';
37
+ await (0, cli_1.run)(['node', 'cli', 'scan', tempRoot, '--ai-inference']);
37
38
  expect(fetchMock).not.toHaveBeenCalled();
39
+ expect(process.exitCode ?? 0).toBe(0);
38
40
  });
39
- it("prints workspace quota message when preflight is quota-blocked", async () => {
40
- process.env.DATAPARADE_WORKSPACE_API_KEY = "dp_live_test";
41
- const errorSpy = jest.spyOn(console, "error").mockImplementation(() => { });
41
+ it('skips quota API when workspace key is present but AI is disabled', async () => {
42
+ process.env.DATAPARADE_WORKSPACE_API_KEY = 'dp_live_test';
43
+ process.env.DATAPARADE_SKIP_AUTO_UPLOAD = 'true';
44
+ await (0, cli_1.run)(['node', 'cli', 'scan', tempRoot, '--no-ai-inference']);
45
+ expect(fetchMock).not.toHaveBeenCalled();
46
+ });
47
+ it('prints workspace quota message when preflight is quota-blocked', async () => {
48
+ process.env.DATAPARADE_WORKSPACE_API_KEY = 'dp_live_test';
49
+ const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => { });
42
50
  fetchMock.mockResolvedValueOnce(jsonResponse({
43
- code: "scan_quota_exceeded",
44
- message: "No scan slots remaining in this workspace.",
51
+ code: 'scan_quota_exceeded',
52
+ message: 'No scan slots remaining in this workspace.',
45
53
  scansRemaining: 0,
46
54
  aiTokensRemaining: 1000,
47
55
  }, 403));
48
- await (0, cli_1.run)(["node", "cli", "scan", tempRoot, "--ai-inference"]);
49
- expect(errorSpy).toHaveBeenCalledWith("[scan] workspace quota: No scan slots remaining in this workspace.");
56
+ await (0, cli_1.run)(['node', 'cli', 'scan', tempRoot, '--ai-inference']);
57
+ expect(errorSpy).toHaveBeenCalledWith('[scan] workspace quota: No scan slots remaining in this workspace.');
50
58
  errorSpy.mockRestore();
51
59
  });
52
- it("prints scan in progress message when preflight is blocked by running job", async () => {
53
- process.env.DATAPARADE_WORKSPACE_API_KEY = "dp_live_test";
54
- const errorSpy = jest.spyOn(console, "error").mockImplementation(() => { });
60
+ it('prints scan in progress message when preflight is blocked by running job', async () => {
61
+ process.env.DATAPARADE_WORKSPACE_API_KEY = 'dp_live_test';
62
+ const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => { });
55
63
  fetchMock.mockResolvedValueOnce(jsonResponse({
56
64
  statusCode: 409,
57
65
  message: {
58
- code: "scan_already_running",
59
- message: "Scan in progress — start a new scan after the current one completes.",
66
+ code: 'scan_already_running',
67
+ message: 'Scan in progress — start a new scan after the current one completes.',
60
68
  },
61
69
  }, 409));
62
- await (0, cli_1.run)(["node", "cli", "scan", tempRoot, "--ai-inference"]);
63
- expect(errorSpy).toHaveBeenCalledWith("[scan] scan in progress: Scan in progress — start a new scan after the current one completes.");
70
+ await (0, cli_1.run)(['node', 'cli', 'scan', tempRoot, '--ai-inference']);
71
+ expect(errorSpy).toHaveBeenCalledWith('[scan] scan in progress: Scan in progress — start a new scan after the current one completes.');
64
72
  errorSpy.mockRestore();
65
73
  });
66
- it("reports failed completion when preflight succeeds but config validation fails", async () => {
67
- process.env.DATAPARADE_WORKSPACE_API_KEY = "dp_live_test";
74
+ it('reports failed completion when preflight succeeds but config validation fails', async () => {
75
+ process.env.DATAPARADE_WORKSPACE_API_KEY = 'dp_live_test';
68
76
  fetchMock
69
77
  .mockResolvedValueOnce(jsonResponse({
70
78
  allowed: true,
71
- jobId: "job-123",
79
+ jobId: 'job-123',
72
80
  scansRemaining: 2,
73
81
  aiTokensRemaining: 1000,
74
82
  suggestedAiBudgetTokens: 100,
75
- aiDelivery: "platform_proxy",
83
+ aiDelivery: 'platform_proxy',
76
84
  }))
77
85
  .mockResolvedValueOnce(jsonResponse({ ok: true }));
78
86
  await (0, cli_1.run)([
79
- "node",
80
- "cli",
81
- "scan",
87
+ 'node',
88
+ 'cli',
89
+ 'scan',
82
90
  tempRoot,
83
- "--ai-inference",
84
- "--ai-temperature",
85
- "not-a-number",
91
+ '--ai-inference',
92
+ '--ai-temperature',
93
+ 'not-a-number',
86
94
  ]);
87
95
  expect(fetchMock).toHaveBeenCalledTimes(2);
88
- expect(String(fetchMock.mock.calls[0][0])).toContain("/api/scans/cli/preflight");
89
- expect(String(fetchMock.mock.calls[1][0])).toContain("/api/scans/cli/job-123/complete");
90
- expect(JSON.parse(String(fetchMock.mock.calls[1][1]?.body))).toEqual(expect.objectContaining({ status: "failed", failureCode: "scan_failed" }));
96
+ expect(String(fetchMock.mock.calls[0][0])).toContain('/api/scans/cli/preflight');
97
+ expect(String(fetchMock.mock.calls[1][0])).toContain('/api/scans/cli/job-123/complete');
98
+ expect(JSON.parse(String(fetchMock.mock.calls[1][1]?.body))).toEqual(expect.objectContaining({
99
+ status: 'failed',
100
+ failureCode: 'invalid_configuration',
101
+ failureMessage: expect.stringContaining('aiTemperature'),
102
+ }));
91
103
  });
92
- it("prints ready-for-new-scan message after platform scan completes", async () => {
93
- process.env.DATAPARADE_WORKSPACE_API_KEY = "dp_live_test";
94
- process.env.DATAPARADE_SKIP_AUTO_UPLOAD = "true";
95
- const logSpy = jest.spyOn(console, "log").mockImplementation(() => { });
96
- const isTty = Object.getOwnPropertyDescriptor(process.stdout, "isTTY");
97
- Object.defineProperty(process.stdout, "isTTY", {
104
+ it('prints ready-for-new-scan message after platform scan completes', async () => {
105
+ process.env.DATAPARADE_WORKSPACE_API_KEY = 'dp_live_test';
106
+ process.env.DATAPARADE_SKIP_AUTO_UPLOAD = 'true';
107
+ const logSpy = jest.spyOn(console, 'log').mockImplementation(() => { });
108
+ const isTty = Object.getOwnPropertyDescriptor(process.stdout, 'isTTY');
109
+ Object.defineProperty(process.stdout, 'isTTY', {
98
110
  value: true,
99
111
  configurable: true,
100
112
  });
101
113
  fetchMock
102
114
  .mockResolvedValueOnce(jsonResponse({
103
115
  allowed: true,
104
- jobId: "job-456",
116
+ jobId: 'job-456',
105
117
  scansRemaining: 2,
106
118
  aiTokensRemaining: 1000,
107
119
  suggestedAiBudgetTokens: 100,
108
- aiDelivery: "platform_proxy",
120
+ aiDelivery: 'platform_proxy',
109
121
  }))
110
122
  .mockResolvedValueOnce(jsonResponse({ ok: true }));
111
- await (0, cli_1.run)(["node", "cli", "scan", tempRoot, "--ai-inference"]);
112
- expect(logSpy).toHaveBeenCalledWith("[scan] Scan finished — you can start a new scan now.");
123
+ await (0, cli_1.run)(['node', 'cli', 'scan', tempRoot, '--ai-inference']);
124
+ expect(logSpy).toHaveBeenCalledWith('[scan] Scan finished — you can start a new scan now.');
113
125
  if (isTty) {
114
- Object.defineProperty(process.stdout, "isTTY", isTty);
126
+ Object.defineProperty(process.stdout, 'isTTY', isTty);
115
127
  }
116
128
  else {
117
129
  delete process.stdout.isTTY;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_scan_failure_report_1 = require("../../../src/platform-api/cli-scan-failure-report");
4
+ describe('cli scan failure report', () => {
5
+ it('keeps a single error as-is', () => {
6
+ expect((0, cli_scan_failure_report_1.summarizeScanErrors)(['parser: unexpected token in user.rb'])).toBe('parser: unexpected token in user.rb');
7
+ });
8
+ it('reports the first error and how many others followed', () => {
9
+ expect((0, cli_scan_failure_report_1.summarizeScanErrors)(['first failure', 'second failure', 'third failure'])).toBe('first failure (+2 more errors)');
10
+ });
11
+ it('uses singular wording for one additional error', () => {
12
+ expect((0, cli_scan_failure_report_1.summarizeScanErrors)(['first failure', 'second failure'])).toBe('first failure (+1 more error)');
13
+ });
14
+ it('falls back when the error list is empty or blank', () => {
15
+ expect((0, cli_scan_failure_report_1.summarizeScanErrors)([])).toBe('The scanner reported errors.');
16
+ expect((0, cli_scan_failure_report_1.summarizeScanErrors)([' '])).toBe('The scanner reported errors.');
17
+ });
18
+ it('collapses whitespace and truncates long messages', () => {
19
+ expect((0, cli_scan_failure_report_1.truncateFailureMessage)(' multi\n line\tmessage ')).toBe('multi line message');
20
+ const long = 'x'.repeat(400);
21
+ const truncated = (0, cli_scan_failure_report_1.truncateFailureMessage)(long);
22
+ expect(truncated).toHaveLength(300);
23
+ expect(truncated.endsWith('…')).toBe(true);
24
+ });
25
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataparade/cli",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "dataPARADE CLI — scan codebases for privacy and security data flows",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -54,7 +54,7 @@
54
54
  "eval:models": "pnpm exec node dist/src/evals/run-model-matrix.js"
55
55
  },
56
56
  "dependencies": {
57
- "@dataparade/scanner": "github:DataParade-io/scanner#998fb12b2db667dd7ff305e34c716634b867e806",
57
+ "@dataparade/scanner": "github:DataParade-io/scanner#4363d8ce2925e3457923432e3de1703e0f9ab46f",
58
58
  "@sentry/node": "^10.38.0",
59
59
  "commander": "^12.1.0",
60
60
  "dotenv": "^16.4.7",
@@ -1,2 +0,0 @@
1
- import "./pg-client";
2
- export declare function ensurePgClientLoaded(): void;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensurePgClientLoaded = ensurePgClientLoaded;
4
- require("./pg-client");
5
- function ensurePgClientLoaded() {
6
- // This module exists so the TypeScript analyzer sees a module import containing
7
- // "pg" and can emit a database_connection finding for tests.
8
- }
@@ -1,3 +0,0 @@
1
- type QueryResultRow = Record<string, unknown>;
2
- export declare function getUserById(id: string): Promise<QueryResultRow>;
3
- export {};
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserById = getUserById;
4
- async function getUserById(id) {
5
- const result = await pool.query("SELECT * FROM users WHERE id = $1", [id]);
6
- return result.rows[0];
7
- }
@@ -1 +0,0 @@
1
- export declare function callExternalApi(): Promise<any>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callExternalApi = callExternalApi;
4
- async function callExternalApi() {
5
- const apiKey = process.env.API_KEY;
6
- // Use a host that matches a known third-party (stripe) so the
7
- // external_api_call pattern plus classifier will produce a third_party
8
- // component and a corresponding data flow in tests.
9
- const response = await fetch("https://api.stripe.com/v1/customers", {
10
- headers: {
11
- "x-api-key": apiKey ?? "test-key",
12
- },
13
- });
14
- if (!response.ok) {
15
- throw new Error("API request failed");
16
- }
17
- return response.json();
18
- }
@@ -1,3 +0,0 @@
1
- type QueryResultRow = Record<string, unknown>;
2
- export declare function runHealthCheck(): Promise<QueryResultRow | undefined>;
3
- export {};
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runHealthCheck = runHealthCheck;
4
- async function runHealthCheck() {
5
- const result = await pool.query("SELECT 1", []);
6
- return result.rows[0];
7
- }
@@ -1,14 +0,0 @@
1
- type E2eRequestLike = {
2
- [key: string]: unknown;
3
- };
4
- type E2eResponseLike = {
5
- send: (body: unknown) => void;
6
- };
7
- declare const e2eApp: {
8
- get: (path: string, ...handlers: Array<(req: E2eRequestLike, res: E2eResponseLike, next?: () => void) => void>) => void;
9
- };
10
- declare const e2ePassport: {
11
- authenticate: (strategy: string, options?: {
12
- session?: boolean;
13
- }) => (req: E2eRequestLike, res: E2eResponseLike, next: (() => void) | undefined) => void;
14
- };
@@ -1,4 +0,0 @@
1
- "use strict";
2
- e2eApp.get("/users", e2ePassport.authenticate("jwt", { session: false }), (req, res) => {
3
- res.send("ok");
4
- });
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const express_1 = __importDefault(require("express"));
7
- const app = (0, express_1.default)();
8
- // Express route (used by `express_route` detection).
9
- app.get("/users", (req, res) => {
10
- res.send("ok");
11
- });
12
- // Env var usage (used by `env_variable` detection).
13
- const apiKey = process.env.API_KEY;
14
- const awsRegion = process.env.AWS_REGION;
15
- // Sentry ingestion (used by `external_api_call` detection with serviceName inference).
16
- async function callSentry() {
17
- await fetch("https://o0.ingest.sentry.io/api/123/envelope/", {
18
- method: "POST",
19
- body: "{}",
20
- });
21
- }
22
- void apiKey;
23
- void awsRegion;
24
- void callSentry;
@@ -1 +0,0 @@
1
- export declare function main(): void;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = main;
4
- function main() {
5
- console.log("hello from index.ts");
6
- }
@@ -1,2 +0,0 @@
1
- declare const app: any;
2
- export default app;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const express_1 = __importDefault(require("express"));
7
- const app = (0, express_1.default)();
8
- app.get("/health", async (_req, res) => {
9
- await fetch("https://api.stripe.com/v1/charges");
10
- res.json({ ok: true });
11
- });
12
- exports.default = app;
@@ -1 +0,0 @@
1
- export declare function GET(): Promise<void>;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET = GET;
4
- async function GET() {
5
- // Minimal route handler for express_route detection in the app section.
6
- }
@@ -1 +0,0 @@
1
- export declare function GET(): Promise<void>;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET = GET;
4
- async function GET() {
5
- // Minimal route handler for backend section (express_route detection).
6
- }
@@ -1 +0,0 @@
1
- export declare function GET(): Promise<void>;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET = GET;
4
- async function GET() {
5
- // Minimal Next.js-style route handler used to trigger express_route
6
- // detection via heuristics.
7
- }
@@ -1 +0,0 @@
1
- export declare function GET(): Promise<void>;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET = GET;
4
- async function GET() {
5
- // Minimal Next.js-style route handler used to trigger express_route
6
- // detection via heuristics; body is irrelevant for tests.
7
- }
@@ -1,2 +0,0 @@
1
- import "./pg-client";
2
- export declare function ensurePgClientLoaded(): void;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensurePgClientLoaded = ensurePgClientLoaded;
4
- require("./pg-client");
5
- function ensurePgClientLoaded() {
6
- // This module exists so the TypeScript analyzer sees a module import containing
7
- // \"pg\" and can emit a database_connection finding for tests.
8
- }
@@ -1,3 +0,0 @@
1
- type QueryResultRow = Record<string, unknown>;
2
- export declare function getUserById(id: string): Promise<QueryResultRow>;
3
- export {};
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserById = getUserById;
4
- async function getUserById(id) {
5
- const result = await pool.query("SELECT * FROM users WHERE id = $1", [id]);
6
- return result.rows[0];
7
- }
@@ -1 +0,0 @@
1
- export declare function callExternalApi(): Promise<any>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callExternalApi = callExternalApi;
4
- async function callExternalApi() {
5
- const apiKey = process.env.API_KEY;
6
- // Use a host that matches a known third-party (stripe) so the
7
- // external_api_call pattern plus classifier will produce a third_party
8
- // component and a corresponding data flow in tests.
9
- const response = await fetch("https://api.stripe.com/v1/customers", {
10
- headers: {
11
- "x-api-key": apiKey ?? "test-key",
12
- },
13
- });
14
- if (!response.ok) {
15
- throw new Error("API request failed");
16
- }
17
- return response.json();
18
- }