@apiquest/fracture 1.0.2 → 1.0.4
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 +119 -0
- package/bin/cli.js +2 -2
- package/dist/CollectionRunner.js +3 -3
- package/dist/ScriptEngine.js +4 -4
- package/dist/cli/plugin-commands.d.ts.map +1 -1
- package/dist/cli/plugin-commands.js +2 -1
- package/dist/cli/plugin-commands.js.map +1 -1
- package/package.json +55 -50
- package/src/CollectionAnalyzer.ts +102 -102
- package/src/CollectionRunner.ts +1423 -1423
- package/src/CollectionRunner.types.ts +9 -9
- package/src/CollectionValidator.ts +289 -289
- package/src/ConsoleReporter.ts +143 -143
- package/src/CookieJar.ts +258 -258
- package/src/DagScheduler.ts +439 -439
- package/src/Logger.ts +85 -85
- package/src/PluginLoader.ts +126 -126
- package/src/PluginManager.ts +208 -208
- package/src/PluginResolver.ts +154 -154
- package/src/QuestAPI.ts +764 -764
- package/src/QuestAPI.types.ts +33 -33
- package/src/QuestTestAPI.ts +164 -164
- package/src/RequestFilter.ts +224 -224
- package/src/ScriptEngine.ts +219 -219
- package/src/ScriptValidator.ts +428 -428
- package/src/TaskGraph.ts +598 -598
- package/src/TestCounter.ts +109 -109
- package/src/VariableResolver.ts +114 -114
- package/src/cli/index.ts +480 -480
- package/src/cli/plugin-commands.ts +342 -341
- package/src/cli/plugin-discovery.ts +44 -44
- package/src/index.ts +24 -24
- package/src/utils.ts +52 -52
- package/tsconfig.json +20 -20
- package/tsconfig.test.json +5 -5
- package/vitest.config.ts +22 -22
- package/dist/ExecutionTree.d.ts +0 -77
- package/dist/ExecutionTree.d.ts.map +0 -1
- package/dist/ExecutionTree.js +0 -265
- package/dist/ExecutionTree.js.map +0 -1
- package/dist/fracture/src/CollectionAnalyzer.d.ts +0 -17
- package/dist/fracture/src/CollectionAnalyzer.d.ts.map +0 -1
- package/dist/fracture/src/CollectionAnalyzer.js +0 -70
- package/dist/fracture/src/CollectionAnalyzer.js.map +0 -1
- package/dist/fracture/src/CollectionRunner.d.ts +0 -39
- package/dist/fracture/src/CollectionRunner.d.ts.map +0 -1
- package/dist/fracture/src/CollectionRunner.js +0 -802
- package/dist/fracture/src/CollectionRunner.js.map +0 -1
- package/dist/fracture/src/CollectionRunner.types.d.ts +0 -8
- package/dist/fracture/src/CollectionRunner.types.d.ts.map +0 -1
- package/dist/fracture/src/CollectionRunner.types.js +0 -2
- package/dist/fracture/src/CollectionRunner.types.js.map +0 -1
- package/dist/fracture/src/CollectionValidator.d.ts +0 -14
- package/dist/fracture/src/CollectionValidator.d.ts.map +0 -1
- package/dist/fracture/src/CollectionValidator.js +0 -145
- package/dist/fracture/src/CollectionValidator.js.map +0 -1
- package/dist/fracture/src/ConsoleReporter.d.ts +0 -24
- package/dist/fracture/src/ConsoleReporter.d.ts.map +0 -1
- package/dist/fracture/src/ConsoleReporter.js +0 -123
- package/dist/fracture/src/ConsoleReporter.js.map +0 -1
- package/dist/fracture/src/CookieJar.d.ts +0 -70
- package/dist/fracture/src/CookieJar.d.ts.map +0 -1
- package/dist/fracture/src/CookieJar.js +0 -233
- package/dist/fracture/src/CookieJar.js.map +0 -1
- package/dist/fracture/src/ExecutionTree.d.ts +0 -77
- package/dist/fracture/src/ExecutionTree.d.ts.map +0 -1
- package/dist/fracture/src/ExecutionTree.js +0 -258
- package/dist/fracture/src/ExecutionTree.js.map +0 -1
- package/dist/fracture/src/Logger.d.ts +0 -25
- package/dist/fracture/src/Logger.d.ts.map +0 -1
- package/dist/fracture/src/Logger.js +0 -78
- package/dist/fracture/src/Logger.js.map +0 -1
- package/dist/fracture/src/PluginLoader.d.ts +0 -23
- package/dist/fracture/src/PluginLoader.d.ts.map +0 -1
- package/dist/fracture/src/PluginLoader.js +0 -102
- package/dist/fracture/src/PluginLoader.js.map +0 -1
- package/dist/fracture/src/PluginManager.d.ts +0 -64
- package/dist/fracture/src/PluginManager.d.ts.map +0 -1
- package/dist/fracture/src/PluginManager.js +0 -162
- package/dist/fracture/src/PluginManager.js.map +0 -1
- package/dist/fracture/src/PluginResolver.d.ts +0 -35
- package/dist/fracture/src/PluginResolver.d.ts.map +0 -1
- package/dist/fracture/src/PluginResolver.js +0 -128
- package/dist/fracture/src/PluginResolver.js.map +0 -1
- package/dist/fracture/src/QuestAPI.d.ts +0 -9
- package/dist/fracture/src/QuestAPI.d.ts.map +0 -1
- package/dist/fracture/src/QuestAPI.js +0 -679
- package/dist/fracture/src/QuestAPI.js.map +0 -1
- package/dist/fracture/src/QuestAPI.types.d.ts +0 -35
- package/dist/fracture/src/QuestAPI.types.d.ts.map +0 -1
- package/dist/fracture/src/QuestAPI.types.js +0 -3
- package/dist/fracture/src/QuestAPI.types.js.map +0 -1
- package/dist/fracture/src/QuestTestAPI.d.ts +0 -12
- package/dist/fracture/src/QuestTestAPI.d.ts.map +0 -1
- package/dist/fracture/src/QuestTestAPI.js +0 -133
- package/dist/fracture/src/QuestTestAPI.js.map +0 -1
- package/dist/fracture/src/ScriptEngine.d.ts +0 -21
- package/dist/fracture/src/ScriptEngine.d.ts.map +0 -1
- package/dist/fracture/src/ScriptEngine.js +0 -183
- package/dist/fracture/src/ScriptEngine.js.map +0 -1
- package/dist/fracture/src/ScriptValidator.d.ts +0 -68
- package/dist/fracture/src/ScriptValidator.d.ts.map +0 -1
- package/dist/fracture/src/ScriptValidator.js +0 -351
- package/dist/fracture/src/ScriptValidator.js.map +0 -1
- package/dist/fracture/src/TestCounter.d.ts +0 -18
- package/dist/fracture/src/TestCounter.d.ts.map +0 -1
- package/dist/fracture/src/TestCounter.js +0 -82
- package/dist/fracture/src/TestCounter.js.map +0 -1
- package/dist/fracture/src/VariableResolver.d.ts +0 -20
- package/dist/fracture/src/VariableResolver.d.ts.map +0 -1
- package/dist/fracture/src/VariableResolver.js +0 -100
- package/dist/fracture/src/VariableResolver.js.map +0 -1
- package/dist/fracture/src/cli/index.d.ts +0 -3
- package/dist/fracture/src/cli/index.d.ts.map +0 -1
- package/dist/fracture/src/cli/index.js +0 -347
- package/dist/fracture/src/cli/index.js.map +0 -1
- package/dist/fracture/src/cli/plugin-commands.d.ts +0 -6
- package/dist/fracture/src/cli/plugin-commands.d.ts.map +0 -1
- package/dist/fracture/src/cli/plugin-commands.js +0 -263
- package/dist/fracture/src/cli/plugin-commands.js.map +0 -1
- package/dist/fracture/src/cli/plugin-discovery.d.ts +0 -11
- package/dist/fracture/src/cli/plugin-discovery.d.ts.map +0 -1
- package/dist/fracture/src/cli/plugin-discovery.js +0 -64
- package/dist/fracture/src/cli/plugin-discovery.js.map +0 -1
- package/dist/fracture/src/index.d.ts +0 -13
- package/dist/fracture/src/index.d.ts.map +0 -1
- package/dist/fracture/src/index.js +0 -17
- package/dist/fracture/src/index.js.map +0 -1
- package/dist/fracture/src/utils.d.ts +0 -28
- package/dist/fracture/src/utils.d.ts.map +0 -1
- package/dist/fracture/src/utils.js +0 -48
- package/dist/fracture/src/utils.js.map +0 -1
- package/dist/plugin-auth/src/apikey-auth.d.ts +0 -3
- package/dist/plugin-auth/src/apikey-auth.d.ts.map +0 -1
- package/dist/plugin-auth/src/apikey-auth.js +0 -73
- package/dist/plugin-auth/src/apikey-auth.js.map +0 -1
- package/dist/plugin-auth/src/basic-auth.d.ts +0 -3
- package/dist/plugin-auth/src/basic-auth.d.ts.map +0 -1
- package/dist/plugin-auth/src/basic-auth.js +0 -61
- package/dist/plugin-auth/src/basic-auth.js.map +0 -1
- package/dist/plugin-auth/src/bearer-auth.d.ts +0 -3
- package/dist/plugin-auth/src/bearer-auth.d.ts.map +0 -1
- package/dist/plugin-auth/src/bearer-auth.js +0 -49
- package/dist/plugin-auth/src/bearer-auth.js.map +0 -1
- package/dist/plugin-auth/src/helpers.d.ts +0 -3
- package/dist/plugin-auth/src/helpers.d.ts.map +0 -1
- package/dist/plugin-auth/src/helpers.js +0 -8
- package/dist/plugin-auth/src/helpers.js.map +0 -1
- package/dist/plugin-auth/src/index.d.ts +0 -10
- package/dist/plugin-auth/src/index.d.ts.map +0 -1
- package/dist/plugin-auth/src/index.js +0 -25
- package/dist/plugin-auth/src/index.js.map +0 -1
- package/dist/plugin-auth/src/oauth2-auth.d.ts +0 -35
- package/dist/plugin-auth/src/oauth2-auth.d.ts.map +0 -1
- package/dist/plugin-auth/src/oauth2-auth.js +0 -266
- package/dist/plugin-auth/src/oauth2-auth.js.map +0 -1
- package/dist/plugin-http/src/index.d.ts +0 -4
- package/dist/plugin-http/src/index.d.ts.map +0 -1
- package/dist/plugin-http/src/index.js +0 -266
- package/dist/plugin-http/src/index.js.map +0 -1
- package/dist/plugin-vault-file/src/index.d.ts +0 -67
- package/dist/plugin-vault-file/src/index.d.ts.map +0 -1
- package/dist/plugin-vault-file/src/index.js +0 -171
- package/dist/plugin-vault-file/src/index.js.map +0 -1
- package/dist/types.d.ts +0 -374
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -13
- package/dist/types.js.map +0 -1
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import { readFileSync } from 'fs';
|
|
4
|
-
import { CollectionRunner } from '../CollectionRunner.js';
|
|
5
|
-
import { ConsoleReporter } from '../ConsoleReporter.js';
|
|
6
|
-
import { LogLevel } from '@apiquest/types';
|
|
7
|
-
import { getPluginDirectories } from './plugin-discovery.js';
|
|
8
|
-
import { addPluginCommands } from './plugin-commands.js';
|
|
9
|
-
const program = new Command();
|
|
10
|
-
// Get command name from process.argv[1] (the bin script name)
|
|
11
|
-
const commandName = process.argv[1]?.split(/[\\/]/).pop()?.replace('.js', '') ?? 'fracture';
|
|
12
|
-
program
|
|
13
|
-
.name(commandName)
|
|
14
|
-
.description('ApiQuest/Fracture - API testing tool')
|
|
15
|
-
.version('1.0.0');
|
|
16
|
-
// Add plugin management commands
|
|
17
|
-
addPluginCommands(program);
|
|
18
|
-
program
|
|
19
|
-
.command('run')
|
|
20
|
-
.description('Run a collection')
|
|
21
|
-
.argument('<collection>', 'Path to collection JSON file')
|
|
22
|
-
// Variables & Environment
|
|
23
|
-
.option('-g, --global <key=value...>', 'Set global variable (repeatable)', collectKeyValue, {})
|
|
24
|
-
.option('-e, --environment <file>', 'Environment JSON file')
|
|
25
|
-
.option('--env-var <key=value...>', 'Set environment variable (repeatable)', collectKeyValue, {})
|
|
26
|
-
// Data & Iterations
|
|
27
|
-
.option('-d, --data <file>', 'Iteration data file (CSV/JSON)')
|
|
28
|
-
.option('-n, --iterations <count>', 'Limit number of iterations', parseInt)
|
|
29
|
-
// Filtering & Selection
|
|
30
|
-
.option('--folder <name>', 'Run only requests in folder')
|
|
31
|
-
.option('--filter <pattern>', 'Filter requests by regex pattern')
|
|
32
|
-
.option('--exclude-deps', 'Exclude dependencies when filtering')
|
|
33
|
-
// Execution Control
|
|
34
|
-
.option('--parallel', 'Enable parallel execution')
|
|
35
|
-
.option('--concurrency <number>', 'Max concurrent requests', parseInt)
|
|
36
|
-
.option('--bail', 'Stop on first test failure')
|
|
37
|
-
.option('--delay <ms>', 'Delay between requests in milliseconds', parseInt)
|
|
38
|
-
// Timeouts
|
|
39
|
-
.option('--timeout <ms>', 'Request timeout in milliseconds', parseInt)
|
|
40
|
-
// SSL/TLS
|
|
41
|
-
.option('--ssl-cert <path>', 'Client certificate file (PEM format)')
|
|
42
|
-
.option('--ssl-key <path>', 'Client private key file')
|
|
43
|
-
.option('--ssl-key-passphrase <password>', 'Client key passphrase')
|
|
44
|
-
.option('--ssl-ca <path>', 'CA certificate bundle')
|
|
45
|
-
.option('--insecure', 'Disable SSL certificate validation')
|
|
46
|
-
// Proxy
|
|
47
|
-
.option('--proxy <url>', 'HTTP/HTTPS proxy URL (http://host:port)')
|
|
48
|
-
.option('--proxy-auth <user:pass>', 'Proxy authentication credentials')
|
|
49
|
-
.option('--no-proxy <hosts>', 'Bypass proxy for hosts (comma-separated)')
|
|
50
|
-
// Redirects
|
|
51
|
-
.option('--follow-redirects', 'Follow HTTP redirects (default: true)')
|
|
52
|
-
.option('--no-follow-redirects', 'Don\'t follow HTTP redirects')
|
|
53
|
-
.option('--max-redirects <count>', 'Maximum redirects to follow (default: 20)', parseInt)
|
|
54
|
-
// Cookies
|
|
55
|
-
.option('--cookie <name=value>', 'Set cookie for requests (repeatable)')
|
|
56
|
-
.option('--cookie-jar', 'Enable persistent cookie jar')
|
|
57
|
-
.option('--cookie-jar-persist', 'Persist cookies across runs')
|
|
58
|
-
// Output & Reporting
|
|
59
|
-
.option('-r, --reporters <types>', 'Output reporters (comma-separated)', 'cli')
|
|
60
|
-
.option('-o, --out <directory>', 'Output directory for reports')
|
|
61
|
-
.option('--no-color', 'Disable colored output')
|
|
62
|
-
.option('--silent', 'Suppress console output')
|
|
63
|
-
.option('--log-level <level>', 'Log level: error, warn, info, debug, trace (default: info)')
|
|
64
|
-
// Validation & Testing
|
|
65
|
-
.option('--no-strict-mode', 'Disable strict validation mode')
|
|
66
|
-
// Configuration
|
|
67
|
-
.option('--config <file>', 'Load options from config file') // not implemented
|
|
68
|
-
.action(async (collectionPath, options) => {
|
|
69
|
-
// Validate log level if provided
|
|
70
|
-
const validLogLevels = ['error', 'warn', 'info', 'debug', 'trace'];
|
|
71
|
-
if (options.logLevel !== undefined && !validLogLevels.includes(options.logLevel)) {
|
|
72
|
-
console.error(`Error: Invalid log level '${options.logLevel}'. Valid levels: ${validLogLevels.join(', ')}`);
|
|
73
|
-
process.exit(2);
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
// Load collection
|
|
77
|
-
const collectionContent = readFileSync(collectionPath, 'utf-8');
|
|
78
|
-
const collection = JSON.parse(collectionContent);
|
|
79
|
-
// Load environment if specified
|
|
80
|
-
let environment;
|
|
81
|
-
if (options.environment !== undefined) {
|
|
82
|
-
const envContent = readFileSync(options.environment, 'utf-8');
|
|
83
|
-
environment = JSON.parse(envContent);
|
|
84
|
-
}
|
|
85
|
-
// Merge env-var options into environment
|
|
86
|
-
if (options.envVar !== undefined && Object.keys(options.envVar).length > 0) {
|
|
87
|
-
environment ??= { name: 'CLI Environment', variables: {} };
|
|
88
|
-
environment.variables = { ...environment.variables, ...options.envVar };
|
|
89
|
-
}
|
|
90
|
-
// Load iteration data if specified
|
|
91
|
-
let iterationData;
|
|
92
|
-
if (options.data !== undefined) {
|
|
93
|
-
const dataContent = readFileSync(options.data, 'utf-8');
|
|
94
|
-
if (options.data.endsWith('.json')) {
|
|
95
|
-
iterationData = JSON.parse(dataContent);
|
|
96
|
-
}
|
|
97
|
-
else if (options.data.endsWith('.csv')) {
|
|
98
|
-
iterationData = parseCSV(dataContent);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Configure HTTP plugin for SSL validation
|
|
102
|
-
if (options.insecure === true) {
|
|
103
|
-
// This will be passed to axios config in the HTTP plugin
|
|
104
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
105
|
-
}
|
|
106
|
-
// Get plugin directories for auto-discovery
|
|
107
|
-
const pluginDirs = getPluginDirectories();
|
|
108
|
-
// Convert string log level to LogLevel enum
|
|
109
|
-
let logLevel;
|
|
110
|
-
if (options.logLevel !== undefined) {
|
|
111
|
-
const levelMap = {
|
|
112
|
-
'error': LogLevel.ERROR,
|
|
113
|
-
'warn': LogLevel.WARN,
|
|
114
|
-
'info': LogLevel.INFO,
|
|
115
|
-
'debug': LogLevel.DEBUG,
|
|
116
|
-
'trace': LogLevel.TRACE
|
|
117
|
-
};
|
|
118
|
-
logLevel = levelMap[options.logLevel];
|
|
119
|
-
}
|
|
120
|
-
// Create runner with plugin auto-discovery and log level
|
|
121
|
-
const runner = new CollectionRunner({
|
|
122
|
-
pluginsDir: pluginDirs,
|
|
123
|
-
logLevel
|
|
124
|
-
});
|
|
125
|
-
// Set up console reporter
|
|
126
|
-
const silent = options.silent;
|
|
127
|
-
const color = options.color; // --no-color sets this to false
|
|
128
|
-
if (silent !== true) {
|
|
129
|
-
const reporter = new ConsoleReporter({
|
|
130
|
-
logLevel,
|
|
131
|
-
color,
|
|
132
|
-
runner
|
|
133
|
-
});
|
|
134
|
-
// Wire up reporter to runner events
|
|
135
|
-
runner.on('beforeRun', (payload) => {
|
|
136
|
-
reporter.onRunStarted(collection, payload.options);
|
|
137
|
-
// Show expected test count if available
|
|
138
|
-
if (payload.expectedTestCount !== undefined && payload.expectedTestCount >= 0) {
|
|
139
|
-
console.log(`Expected tests: ${payload.expectedTestCount}`);
|
|
140
|
-
console.log('');
|
|
141
|
-
}
|
|
142
|
-
// Show validation errors if any (shouldn't reach here but defensive)
|
|
143
|
-
if (payload.validationResult?.valid === false && payload.validationResult.errors !== undefined) {
|
|
144
|
-
console.error('\nValidation errors detected:');
|
|
145
|
-
for (const error of payload.validationResult.errors) {
|
|
146
|
-
console.error(` ${error.location}: ${error.message}`);
|
|
147
|
-
}
|
|
148
|
-
console.error('');
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
runner.on('beforeRequest', (payload) => {
|
|
152
|
-
reporter.onBeforeRequest?.(payload);
|
|
153
|
-
});
|
|
154
|
-
runner.on('afterRequest', (payload) => {
|
|
155
|
-
reporter.onAfterRequest?.(payload);
|
|
156
|
-
});
|
|
157
|
-
runner.on('assertion', (payload) => {
|
|
158
|
-
reporter.onAssertion?.(payload);
|
|
159
|
-
});
|
|
160
|
-
runner.on('afterRun', (payload) => {
|
|
161
|
-
reporter.onRunCompleted(payload.result);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
// Build RuntimeOptions from CLI options
|
|
165
|
-
const runOptions = {
|
|
166
|
-
// CLI-specific options
|
|
167
|
-
environment,
|
|
168
|
-
globalVariables: options.global,
|
|
169
|
-
data: iterationData,
|
|
170
|
-
iterations: options.iterations,
|
|
171
|
-
folder: options.folder,
|
|
172
|
-
filter: options.filter,
|
|
173
|
-
excludeDeps: options.excludeDeps,
|
|
174
|
-
// RuntimeOptions - Execution
|
|
175
|
-
execution: {
|
|
176
|
-
...(options.concurrency !== undefined ? { maxConcurrency: options.concurrency } : {}),
|
|
177
|
-
...(options.bail !== undefined ? { bail: options.bail } : {}),
|
|
178
|
-
...(options.delay !== undefined ? { delay: options.delay } : {})
|
|
179
|
-
},
|
|
180
|
-
// RuntimeOptions - Timeout
|
|
181
|
-
...(options.timeout !== undefined ? {
|
|
182
|
-
timeout: { request: options.timeout }
|
|
183
|
-
} : {}),
|
|
184
|
-
// RuntimeOptions - SSL
|
|
185
|
-
...(options.sslCert !== undefined || options.sslKey !== undefined || options.sslCa !== undefined || options.insecure !== undefined ? {
|
|
186
|
-
ssl: {
|
|
187
|
-
...(options.insecure !== undefined ? { validateCertificates: options.insecure === false } : {}),
|
|
188
|
-
...(options.sslCert !== undefined || options.sslKey !== undefined ? {
|
|
189
|
-
clientCertificate: {
|
|
190
|
-
...(options.sslCert !== undefined ? { cert: readFileSync(options.sslCert, 'utf-8') } : {}),
|
|
191
|
-
...(options.sslKey !== undefined ? { key: readFileSync(options.sslKey, 'utf-8') } : {}),
|
|
192
|
-
...(options.sslKeyPassphrase !== undefined ? { passphrase: options.sslKeyPassphrase } : {})
|
|
193
|
-
}
|
|
194
|
-
} : {}),
|
|
195
|
-
...(options.sslCa !== undefined ? { ca: readFileSync(options.sslCa, 'utf-8') } : {})
|
|
196
|
-
}
|
|
197
|
-
} : {}),
|
|
198
|
-
// RuntimeOptions - Proxy
|
|
199
|
-
...(options.proxy !== undefined ? {
|
|
200
|
-
proxy: {
|
|
201
|
-
enabled: true,
|
|
202
|
-
...parseProxyUrl(options.proxy),
|
|
203
|
-
...(options.proxyAuth !== undefined ? { auth: parseProxyAuth(options.proxyAuth) } : {}),
|
|
204
|
-
...(options.noProxy !== undefined ? { bypass: parseNoProxy(options.noProxy) } : {})
|
|
205
|
-
}
|
|
206
|
-
} : {}),
|
|
207
|
-
// RuntimeOptions - Cookies
|
|
208
|
-
...(options.cookie !== undefined ? {
|
|
209
|
-
cookies: (Array.isArray(options.cookie) ? options.cookie : [options.cookie]).map(parseCookie).filter((c) => c !== null)
|
|
210
|
-
} : {}),
|
|
211
|
-
// RuntimeOptions - Cookie Jar
|
|
212
|
-
...(options.cookieJar !== undefined || options.cookieJarPersist !== undefined ? {
|
|
213
|
-
jar: {
|
|
214
|
-
enabled: options.cookieJar ?? false,
|
|
215
|
-
...(options.cookieJarPersist !== undefined ? { persist: options.cookieJarPersist } : {})
|
|
216
|
-
}
|
|
217
|
-
} : {}),
|
|
218
|
-
// RuntimeOptions - Redirects
|
|
219
|
-
...(options.followRedirects !== undefined ? { followRedirects: options.followRedirects } : {}),
|
|
220
|
-
...(options.maxRedirects !== undefined ? { maxRedirects: options.maxRedirects } : {}),
|
|
221
|
-
// RuntimeOptions - Logging & Validation
|
|
222
|
-
logLevel,
|
|
223
|
-
strictMode: options.strictMode !== false // --no-strict-mode sets this to false, default is true
|
|
224
|
-
};
|
|
225
|
-
// Run collection
|
|
226
|
-
const result = await runner.run(collection, runOptions);
|
|
227
|
-
// Check for validation errors (pre-run validation failed)
|
|
228
|
-
if (result.validationErrors !== undefined && result.validationErrors.length > 0) {
|
|
229
|
-
if (silent !== true) {
|
|
230
|
-
console.error('\nPre-run validation failed:\n');
|
|
231
|
-
for (const error of result.validationErrors) {
|
|
232
|
-
console.error(` ${error.location}: ${error.message}`);
|
|
233
|
-
if (error.details?.line !== undefined) {
|
|
234
|
-
console.error(` at line ${error.details.line}${error.details.column !== undefined ? `:${error.details.column}` : ''}`);
|
|
235
|
-
}
|
|
236
|
-
if (error.details?.suggestion !== undefined) {
|
|
237
|
-
console.error(` > ${error.details.suggestion}`);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
process.exit(3); // Exit code 3 for validation failures
|
|
242
|
-
}
|
|
243
|
-
// Results are displayed by the reporter
|
|
244
|
-
// Determine exit code based on TEST results because request errors may be expected
|
|
245
|
-
const hasErrors = result.failedTests > 0;
|
|
246
|
-
process.exit(hasErrors ? 1 : 0);
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
249
|
-
console.error('Error:', error instanceof Error ? error.message : String(error));
|
|
250
|
-
process.exit(4);
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
program.parse();
|
|
254
|
-
function collectKeyValue(value, previous) {
|
|
255
|
-
const [key, val] = value.split('=');
|
|
256
|
-
if (key === undefined || key === '' || val === undefined) {
|
|
257
|
-
throw new Error(`Invalid key=value format: ${value}`);
|
|
258
|
-
}
|
|
259
|
-
return { ...previous, [key.trim()]: val.trim() };
|
|
260
|
-
}
|
|
261
|
-
function parseCSV(content) {
|
|
262
|
-
const lines = content.split('\n').filter(line => line.trim() !== '');
|
|
263
|
-
if (lines.length === 0)
|
|
264
|
-
return [];
|
|
265
|
-
const headers = lines[0].split(',').map(h => h.trim());
|
|
266
|
-
const data = [];
|
|
267
|
-
for (let i = 1; i < lines.length; i++) {
|
|
268
|
-
const values = lines[i].split(',').map(v => v.trim());
|
|
269
|
-
const row = {};
|
|
270
|
-
headers.forEach((header, index) => {
|
|
271
|
-
const value = values[index];
|
|
272
|
-
// Try to parse as number
|
|
273
|
-
const numValue = Number(value);
|
|
274
|
-
if (Number.isNaN(numValue) === false && value !== '') {
|
|
275
|
-
row[header] = numValue;
|
|
276
|
-
}
|
|
277
|
-
else if (value === 'true') {
|
|
278
|
-
row[header] = true;
|
|
279
|
-
}
|
|
280
|
-
else if (value === 'false') {
|
|
281
|
-
row[header] = false;
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
row[header] = value;
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
data.push(row);
|
|
288
|
-
}
|
|
289
|
-
return data;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Parse proxy URL string into ProxyOptions
|
|
293
|
-
* Format: http://host:port or https://host:port
|
|
294
|
-
*/
|
|
295
|
-
function parseProxyUrl(proxyUrl) {
|
|
296
|
-
try {
|
|
297
|
-
const url = new URL(proxyUrl);
|
|
298
|
-
return {
|
|
299
|
-
host: url.hostname,
|
|
300
|
-
port: parseInt(url.port) > 0 ? parseInt(url.port) : (url.protocol === 'https:' ? 443 : 80)
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
catch {
|
|
304
|
-
console.error(`Error: Invalid proxy URL format: ${proxyUrl}`);
|
|
305
|
-
console.error('Expected format: http://host:port or https://host:port');
|
|
306
|
-
process.exit(2);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Parse proxy auth string into username/password
|
|
311
|
-
* Format: username:password
|
|
312
|
-
*/
|
|
313
|
-
function parseProxyAuth(authString) {
|
|
314
|
-
const parts = authString.split(':');
|
|
315
|
-
if (parts.length !== 2) {
|
|
316
|
-
console.error(`Error: Invalid proxy auth format: ${authString}`);
|
|
317
|
-
console.error('Expected format: username:password');
|
|
318
|
-
process.exit(2);
|
|
319
|
-
}
|
|
320
|
-
return {
|
|
321
|
-
username: parts[0],
|
|
322
|
-
password: parts[1]
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Parse comma-separated host list for proxy bypass
|
|
327
|
-
*/
|
|
328
|
-
function parseNoProxy(noProxyString) {
|
|
329
|
-
return noProxyString.split(',').map(h => h.trim()).filter(h => h.length > 0);
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Parse cookie string into Cookie object
|
|
333
|
-
* Format: name=value
|
|
334
|
-
*/
|
|
335
|
-
function parseCookie(cookieString) {
|
|
336
|
-
const index = cookieString.indexOf('=');
|
|
337
|
-
if (index === -1) {
|
|
338
|
-
console.error(`Error: Invalid cookie format: ${cookieString}`);
|
|
339
|
-
console.error('Expected format: name=value');
|
|
340
|
-
process.exit(2);
|
|
341
|
-
}
|
|
342
|
-
return {
|
|
343
|
-
name: cookieString.substring(0, index).trim(),
|
|
344
|
-
value: cookieString.substring(index + 1).trim()
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceR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,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE;QAC7C,KAAK,EAAE,YAAY,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-commands.d.ts","sourceRoot":"","sources":["../../../../src/cli/plugin-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0IxD"}
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { exec } from 'child_process';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
import { readdir, readFile, access } from 'fs/promises';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { execSync } from 'child_process';
|
|
6
|
-
import { getUserDataPath } from './plugin-discovery.js';
|
|
7
|
-
const execAsync = promisify(exec);
|
|
8
|
-
/**
|
|
9
|
-
* Add plugin management commands to the CLI program
|
|
10
|
-
*/
|
|
11
|
-
export function addPluginCommands(program) {
|
|
12
|
-
const pluginCommand = program
|
|
13
|
-
.command('plugin')
|
|
14
|
-
.description('Manage ApiQuest plugins');
|
|
15
|
-
// quest plugin install <name>
|
|
16
|
-
pluginCommand
|
|
17
|
-
.command('install')
|
|
18
|
-
.description('Install a plugin')
|
|
19
|
-
.argument('<names...>', 'Plugin name(s) to install')
|
|
20
|
-
.action(async (names) => {
|
|
21
|
-
for (const name of names) {
|
|
22
|
-
const packageName = name.startsWith('@') ? name : `@apiquest/plugin-${name}`;
|
|
23
|
-
console.log(`Installing ${packageName}...`);
|
|
24
|
-
try {
|
|
25
|
-
// Use npm to install globally
|
|
26
|
-
await execAsync(`npm install -g ${packageName}`);
|
|
27
|
-
console.log(`✓ ${packageName} installed`);
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
const err = error;
|
|
31
|
-
console.error(`✗ Failed to install ${packageName}:`, err.message ?? String(error));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
// quest plugin list
|
|
36
|
-
pluginCommand
|
|
37
|
-
.command('list')
|
|
38
|
-
.description('List installed plugins')
|
|
39
|
-
.action(async () => {
|
|
40
|
-
console.log('Installed plugins:\n');
|
|
41
|
-
// Check shared user data plugins directory (same as desktop)
|
|
42
|
-
const userDataPath = getUserDataPath();
|
|
43
|
-
const sharedPluginsDir = path.join(userDataPath, 'plugins');
|
|
44
|
-
await listPluginsFromDir(sharedPluginsDir, 'Shared (Desktop & CLI)');
|
|
45
|
-
// Check global npm packages
|
|
46
|
-
try {
|
|
47
|
-
const globalPath = execSync('npm root -g', { encoding: 'utf-8' }).trim();
|
|
48
|
-
const apiquestPath = path.join(globalPath, '@apiquest');
|
|
49
|
-
await listPluginsFromDir(apiquestPath, 'Global (npm)');
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
console.log(' [Global (npm)] Could not access global npm packages\n');
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
// quest plugin available
|
|
56
|
-
pluginCommand
|
|
57
|
-
.command('available')
|
|
58
|
-
.description('List available plugins from npm registry (fracture runtime)')
|
|
59
|
-
.action(async () => {
|
|
60
|
-
console.log('Available plugins (npm registry):\n');
|
|
61
|
-
try {
|
|
62
|
-
const plugins = await fetchAvailablePlugins();
|
|
63
|
-
if (plugins.length === 0) {
|
|
64
|
-
console.log(' No plugins found for fracture runtime.');
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
for (const plugin of plugins) {
|
|
68
|
-
console.log(` - ${plugin.name}@${plugin.version}`);
|
|
69
|
-
if (plugin.type !== undefined) {
|
|
70
|
-
console.log(` Type: ${plugin.type}`);
|
|
71
|
-
}
|
|
72
|
-
if (plugin.runtime.length > 0) {
|
|
73
|
-
console.log(` Runtime: ${plugin.runtime.join(', ')}`);
|
|
74
|
-
}
|
|
75
|
-
if (plugin.description !== undefined) {
|
|
76
|
-
console.log(` Description: ${plugin.description}`);
|
|
77
|
-
}
|
|
78
|
-
printCapabilities(plugin.provides, ' ');
|
|
79
|
-
}
|
|
80
|
-
console.log('');
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
console.error('Failed to query npm registry:', error instanceof Error ? error.message : String(error));
|
|
84
|
-
process.exit(4);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
// quest plugin remove <name>
|
|
88
|
-
pluginCommand
|
|
89
|
-
.command('remove')
|
|
90
|
-
.description('Remove a plugin')
|
|
91
|
-
.argument('<names...>', 'Plugin name(s) to remove')
|
|
92
|
-
.action(async (names) => {
|
|
93
|
-
for (const name of names) {
|
|
94
|
-
const packageName = name.startsWith('@') ? name : `@apiquest/plugin-${name}`;
|
|
95
|
-
console.log(`Removing ${packageName}...`);
|
|
96
|
-
try {
|
|
97
|
-
await execAsync(`npm uninstall -g ${packageName}`);
|
|
98
|
-
console.log(`✓ ${packageName} removed`);
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
const err = error;
|
|
102
|
-
console.error(`✗ Failed to remove ${packageName}:`, err.message ?? String(error));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
// quest plugin update <name>
|
|
107
|
-
pluginCommand
|
|
108
|
-
.command('update')
|
|
109
|
-
.description('Update plugin(s)')
|
|
110
|
-
.argument('[names...]', 'Plugin name(s) to update (all if not specified)')
|
|
111
|
-
.action(async (names) => {
|
|
112
|
-
if (names.length === 0) {
|
|
113
|
-
// Update all @apiquest plugins
|
|
114
|
-
console.log('Updating all @apiquest plugins...');
|
|
115
|
-
try {
|
|
116
|
-
await execAsync('npm update -g @apiquest/*');
|
|
117
|
-
console.log('✓ All plugins updated');
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
const err = error;
|
|
121
|
-
console.error('✗ Failed to update plugins:', err.message ?? String(error));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
for (const name of names) {
|
|
126
|
-
const packageName = name.startsWith('@') ? name : `@apiquest/plugin-${name}`;
|
|
127
|
-
console.log(`Updating ${packageName}...`);
|
|
128
|
-
try {
|
|
129
|
-
await execAsync(`npm update -g ${packageName}`);
|
|
130
|
-
console.log(`✓ ${packageName} updated`);
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
const err = error;
|
|
134
|
-
console.error(`✗ Failed to update ${packageName}:`, err.message ?? String(error));
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* List plugins from a specific directory
|
|
142
|
-
*/
|
|
143
|
-
async function listPluginsFromDir(dir, label) {
|
|
144
|
-
try {
|
|
145
|
-
await access(dir);
|
|
146
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
147
|
-
const plugins = entries.filter(e => e.isDirectory() && e.name.startsWith('plugin-'));
|
|
148
|
-
let foundAny = false;
|
|
149
|
-
console.log(` [${label}]`);
|
|
150
|
-
for (const plugin of plugins) {
|
|
151
|
-
const pluginPath = path.join(dir, plugin.name);
|
|
152
|
-
const packageJsonPath = path.join(pluginPath, 'package.json');
|
|
153
|
-
try {
|
|
154
|
-
const pkgContent = await readFile(packageJsonPath, 'utf-8');
|
|
155
|
-
const pkg = JSON.parse(pkgContent);
|
|
156
|
-
// Only list fracture runtime plugins
|
|
157
|
-
if (pkg.apiquest?.runtime?.includes('fracture') !== true) {
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
foundAny = true;
|
|
161
|
-
const version = pkg.version ?? 'unknown';
|
|
162
|
-
const type = pkg.apiquest?.type ?? 'unknown';
|
|
163
|
-
const runtime = pkg.apiquest?.runtime?.join(', ') ?? 'unknown';
|
|
164
|
-
console.log(` - ${pkg.name ?? 'unknown'}@${version}`);
|
|
165
|
-
console.log(` Type: ${type}`);
|
|
166
|
-
console.log(` Runtime: ${runtime}`);
|
|
167
|
-
printCapabilities(pkg.apiquest?.capabilities?.provides, ' ');
|
|
168
|
-
}
|
|
169
|
-
catch {
|
|
170
|
-
// Skip invalid package.json
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (!foundAny) {
|
|
174
|
-
console.log(` No fracture plugins found`);
|
|
175
|
-
}
|
|
176
|
-
console.log('');
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
console.log(` [${label}] Directory not found or not accessible\n`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
async function fetchAvailablePlugins() {
|
|
183
|
-
const searchUrl = new URL('https://registry.npmjs.org/-/v1/search');
|
|
184
|
-
searchUrl.searchParams.set('text', 'scope:@apiquest plugin-');
|
|
185
|
-
searchUrl.searchParams.set('size', '250');
|
|
186
|
-
const response = await fetch(searchUrl.toString(), {
|
|
187
|
-
headers: {
|
|
188
|
-
'Accept': 'application/json'
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
if (!response.ok) {
|
|
192
|
-
throw new Error(`Registry search failed: ${response.status} ${response.statusText}`);
|
|
193
|
-
}
|
|
194
|
-
const data = await response.json();
|
|
195
|
-
const names = data.objects
|
|
196
|
-
.map(obj => obj.package?.name)
|
|
197
|
-
.filter((name) => typeof name === 'string' && name.startsWith('@apiquest/plugin-'));
|
|
198
|
-
const pluginResults = await Promise.all(names.map(async (name) => {
|
|
199
|
-
try {
|
|
200
|
-
return await fetchRegistryPluginInfo(name);
|
|
201
|
-
}
|
|
202
|
-
catch {
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
}));
|
|
206
|
-
return pluginResults
|
|
207
|
-
.filter((plugin) => plugin !== null)
|
|
208
|
-
.filter(plugin => plugin.runtime.includes('fracture'))
|
|
209
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
210
|
-
}
|
|
211
|
-
async function fetchRegistryPluginInfo(name) {
|
|
212
|
-
const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(name)}`, {
|
|
213
|
-
headers: {
|
|
214
|
-
'Accept': 'application/json'
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
if (!response.ok) {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
const data = await response.json();
|
|
221
|
-
const latest = data['dist-tags']?.latest;
|
|
222
|
-
const versionData = latest !== undefined && data.versions !== undefined ? data.versions[latest] : undefined;
|
|
223
|
-
const metadata = versionData?.apiquest;
|
|
224
|
-
if (latest === undefined || metadata === undefined) {
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
const runtime = Array.isArray(metadata.runtime) ? metadata.runtime : [];
|
|
228
|
-
return {
|
|
229
|
-
name: data.name,
|
|
230
|
-
version: latest,
|
|
231
|
-
description: versionData?.description,
|
|
232
|
-
type: metadata.type,
|
|
233
|
-
runtime,
|
|
234
|
-
provides: metadata.capabilities?.provides
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
function printCapabilities(provides, indent = ' ') {
|
|
238
|
-
if (provides === undefined) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
if (provides.protocols !== undefined && provides.protocols.length > 0) {
|
|
242
|
-
console.log(`${indent}Protocols: ${provides.protocols.join(', ')}`);
|
|
243
|
-
}
|
|
244
|
-
if (provides.authTypes !== undefined && provides.authTypes.length > 0) {
|
|
245
|
-
console.log(`${indent}Auth Types: ${provides.authTypes.join(', ')}`);
|
|
246
|
-
}
|
|
247
|
-
if (provides.reportTypes !== undefined && provides.reportTypes.length > 0) {
|
|
248
|
-
console.log(`${indent}Report Types: ${provides.reportTypes.join(', ')}`);
|
|
249
|
-
}
|
|
250
|
-
if (provides.importFormats !== undefined && provides.importFormats.length > 0) {
|
|
251
|
-
console.log(`${indent}Import Formats: ${provides.importFormats.join(', ')}`);
|
|
252
|
-
}
|
|
253
|
-
if (provides.exportFormats !== undefined && provides.exportFormats.length > 0) {
|
|
254
|
-
console.log(`${indent}Export Formats: ${provides.exportFormats.join(', ')}`);
|
|
255
|
-
}
|
|
256
|
-
if (provides.visualizations !== undefined && provides.visualizations.length > 0) {
|
|
257
|
-
console.log(`${indent}Visualizations: ${provides.visualizations.join(', ')}`);
|
|
258
|
-
}
|
|
259
|
-
if (provides.provider !== undefined) {
|
|
260
|
-
console.log(`${indent}Provider: ${provides.provider}`);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
//# sourceMappingURL=plugin-commands.js.map
|