@edgible-team/cli 1.2.8 → 1.2.9
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/dist/commands/ai/teardown.js +24 -23
- package/dist/commands/application/api-keys/create.d.ts.map +1 -1
- package/dist/commands/application/api-keys/create.js +5 -20
- package/dist/commands/application/api-keys/delete.d.ts.map +1 -1
- package/dist/commands/application/api-keys/delete.js +5 -20
- package/dist/commands/application/api-keys/list.d.ts.map +1 -1
- package/dist/commands/application/api-keys/list.js +5 -21
- package/dist/commands/application/delete.d.ts.map +1 -1
- package/dist/commands/application/delete.js +7 -23
- package/dist/commands/application/get.d.ts.map +1 -1
- package/dist/commands/application/get.js +9 -4
- package/dist/commands/application/short-codes/create.d.ts.map +1 -1
- package/dist/commands/application/short-codes/create.js +5 -20
- package/dist/commands/application/short-codes/delete.d.ts.map +1 -1
- package/dist/commands/application/short-codes/delete.js +5 -20
- package/dist/commands/application/short-codes/list.d.ts.map +1 -1
- package/dist/commands/application/short-codes/list.js +5 -21
- package/dist/commands/application/short-codes/toggle.d.ts.map +1 -1
- package/dist/commands/application/short-codes/toggle.js +5 -20
- package/dist/commands/base/command-wrapper.d.ts +0 -4
- package/dist/commands/base/command-wrapper.d.ts.map +1 -1
- package/dist/commands/base/command-wrapper.js +0 -16
- package/dist/commands/utils/application-prompt.d.ts +23 -0
- package/dist/commands/utils/application-prompt.d.ts.map +1 -0
- package/dist/commands/utils/application-prompt.js +79 -0
- package/dist/commands/utils/output-formatter.d.ts +1 -0
- package/dist/commands/utils/output-formatter.d.ts.map +1 -1
- package/dist/commands/utils/output-formatter.js +1 -1
- package/dist/validation/validator.d.ts +0 -4
- package/dist/validation/validator.d.ts.map +1 -1
- package/dist/validation/validator.js +0 -9
- package/package.json +1 -1
- package/dist/commands/base/BaseCommand.d.ts +0 -53
- package/dist/commands/base/BaseCommand.d.ts.map +0 -1
- package/dist/commands/base/BaseCommand.js +0 -93
- package/dist/commands/base/CommandHandler.d.ts +0 -28
- package/dist/commands/base/CommandHandler.d.ts.map +0 -1
- package/dist/commands/base/CommandHandler.js +0 -7
- package/dist/commands/base/middleware.d.ts +0 -34
- package/dist/commands/base/middleware.d.ts.map +0 -1
- package/dist/commands/base/middleware.js +0 -77
- package/dist/utils/PathMigration.d.ts +0 -45
- package/dist/utils/PathMigration.d.ts.map +0 -1
- package/dist/utils/PathMigration.js +0 -219
- package/dist/utils/progress.d.ts +0 -74
- package/dist/utils/progress.d.ts.map +0 -1
- package/dist/utils/progress.js +0 -167
|
@@ -15,8 +15,4 @@ export declare function validateValue<T>(schema: z.ZodSchema<T>, value: unknown,
|
|
|
15
15
|
* Validate and transform command input
|
|
16
16
|
*/
|
|
17
17
|
export declare function validateAndTransform<TInput, TOutput>(input: TInput, schema: z.ZodSchema<TOutput>): TOutput;
|
|
18
|
-
/**
|
|
19
|
-
* Create a validation middleware for commands
|
|
20
|
-
*/
|
|
21
|
-
export declare function createValidationMiddleware<T>(schema: z.ZodSchema<T>): (options: unknown) => T;
|
|
22
18
|
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/validation/validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAY,MAAM,KAAK,CAAC;AAIlC;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,CAU9E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,CAU7F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAClD,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,GAC3B,OAAO,CAUT
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/validation/validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAY,MAAM,KAAK,CAAC;AAIlC;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,CAU9E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,CAU7F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAClD,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,GAC3B,OAAO,CAUT"}
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.validateOptions = validateOptions;
|
|
8
8
|
exports.validateValue = validateValue;
|
|
9
9
|
exports.validateAndTransform = validateAndTransform;
|
|
10
|
-
exports.createValidationMiddleware = createValidationMiddleware;
|
|
11
10
|
const zod_1 = require("zod");
|
|
12
11
|
const errors_1 = require("../utils/errors");
|
|
13
12
|
const schemas_1 = require("./schemas");
|
|
@@ -56,12 +55,4 @@ function validateAndTransform(input, schema) {
|
|
|
56
55
|
throw error;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Create a validation middleware for commands
|
|
61
|
-
*/
|
|
62
|
-
function createValidationMiddleware(schema) {
|
|
63
|
-
return (options) => {
|
|
64
|
-
return validateOptions(schema, options);
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
58
|
//# sourceMappingURL=validator.js.map
|
package/package.json
CHANGED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base command class
|
|
3
|
-
* Provides consistent command execution with middleware support
|
|
4
|
-
*/
|
|
5
|
-
import { CommandHandler, CommandContext, CommandMiddleware } from './CommandHandler';
|
|
6
|
-
import { Logger } from '../../utils/logger';
|
|
7
|
-
import { ConfigManager } from '../../state/config';
|
|
8
|
-
export interface BaseCommandOptions {
|
|
9
|
-
logger: Logger;
|
|
10
|
-
configManager: ConfigManager;
|
|
11
|
-
requireAuth?: boolean;
|
|
12
|
-
requireOrganization?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Base command implementation with error handling and middleware
|
|
16
|
-
*/
|
|
17
|
-
export declare class BaseCommand implements CommandHandler {
|
|
18
|
-
protected logger: Logger;
|
|
19
|
-
protected configManager: ConfigManager;
|
|
20
|
-
protected requireAuth: boolean;
|
|
21
|
-
protected requireOrganization: boolean;
|
|
22
|
-
private middlewares;
|
|
23
|
-
constructor(options: BaseCommandOptions);
|
|
24
|
-
/**
|
|
25
|
-
* Add middleware to the command
|
|
26
|
-
*/
|
|
27
|
-
use(middleware: CommandMiddleware): void;
|
|
28
|
-
/**
|
|
29
|
-
* Execute the command with middleware chain
|
|
30
|
-
*/
|
|
31
|
-
execute(context: CommandContext): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Run middleware chain
|
|
34
|
-
*/
|
|
35
|
-
private runMiddleware;
|
|
36
|
-
/**
|
|
37
|
-
* Override this method in subclasses to implement command logic
|
|
38
|
-
*/
|
|
39
|
-
protected doExecute(context: CommandContext): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* Check if user is authenticated
|
|
42
|
-
*/
|
|
43
|
-
protected ensureAuthenticated(): void;
|
|
44
|
-
/**
|
|
45
|
-
* Check if organization ID is available
|
|
46
|
-
*/
|
|
47
|
-
protected ensureOrganization(): void;
|
|
48
|
-
/**
|
|
49
|
-
* Validate and ensure authentication and organization
|
|
50
|
-
*/
|
|
51
|
-
protected validateContext(): void;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=BaseCommand.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCommand.d.ts","sourceRoot":"","sources":["../../../src/commands/base/BaseCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,qBAAa,WAAY,YAAW,cAAc;IAChD,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IACvC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACvC,OAAO,CAAC,WAAW,CAA2B;gBAElC,OAAO,EAAE,kBAAkB;IAOvC;;OAEG;IACH,GAAG,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAIxC;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAYrD;;OAEG;YACW,aAAa;IAW3B;;OAEG;cACa,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjE;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAcrC;;OAEG;IACH,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAWpC;;OAEG;IACH,SAAS,CAAC,eAAe,IAAI,IAAI;CAIlC"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Base command class
|
|
4
|
-
* Provides consistent command execution with middleware support
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.BaseCommand = void 0;
|
|
8
|
-
const errors_1 = require("../../utils/errors");
|
|
9
|
-
/**
|
|
10
|
-
* Base command implementation with error handling and middleware
|
|
11
|
-
*/
|
|
12
|
-
class BaseCommand {
|
|
13
|
-
constructor(options) {
|
|
14
|
-
this.middlewares = [];
|
|
15
|
-
this.logger = options.logger;
|
|
16
|
-
this.configManager = options.configManager;
|
|
17
|
-
this.requireAuth = options.requireAuth ?? false;
|
|
18
|
-
this.requireOrganization = options.requireOrganization ?? false;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Add middleware to the command
|
|
22
|
-
*/
|
|
23
|
-
use(middleware) {
|
|
24
|
-
this.middlewares.push(middleware);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Execute the command with middleware chain
|
|
28
|
-
*/
|
|
29
|
-
async execute(context) {
|
|
30
|
-
try {
|
|
31
|
-
// Run middleware chain
|
|
32
|
-
await this.runMiddleware(context, 0);
|
|
33
|
-
// Execute the actual command
|
|
34
|
-
await this.doExecute(context);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
errors_1.ErrorHandler.handleError(error);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Run middleware chain
|
|
42
|
-
*/
|
|
43
|
-
async runMiddleware(context, index) {
|
|
44
|
-
if (index >= this.middlewares.length) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const middleware = this.middlewares[index];
|
|
48
|
-
await middleware.process(context, async () => {
|
|
49
|
-
await this.runMiddleware(context, index + 1);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Override this method in subclasses to implement command logic
|
|
54
|
-
*/
|
|
55
|
-
async doExecute(context) {
|
|
56
|
-
throw new Error('doExecute must be implemented by subclass');
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Check if user is authenticated
|
|
60
|
-
*/
|
|
61
|
-
ensureAuthenticated() {
|
|
62
|
-
if (!this.requireAuth) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const config = this.configManager.getConfig();
|
|
66
|
-
const hasTokens = !!(config.accessToken || config.idToken);
|
|
67
|
-
const hasDeviceCreds = !!(config.deviceId && config.devicePassword);
|
|
68
|
-
if (!hasTokens && !hasDeviceCreds) {
|
|
69
|
-
throw new Error('Not authenticated. Please run "edgible login" first.');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Check if organization ID is available
|
|
74
|
-
*/
|
|
75
|
-
ensureOrganization() {
|
|
76
|
-
if (!this.requireOrganization) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const config = this.configManager.getConfig();
|
|
80
|
-
if (!config.organizationId) {
|
|
81
|
-
throw new Error('No organization found. Please login first.');
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Validate and ensure authentication and organization
|
|
86
|
-
*/
|
|
87
|
-
validateContext() {
|
|
88
|
-
this.ensureAuthenticated();
|
|
89
|
-
this.ensureOrganization();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.BaseCommand = BaseCommand;
|
|
93
|
-
//# sourceMappingURL=BaseCommand.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Command handler interface
|
|
3
|
-
* Defines the contract for command execution
|
|
4
|
-
*/
|
|
5
|
-
import { Command } from 'commander';
|
|
6
|
-
export interface CommandContext {
|
|
7
|
-
command: Command;
|
|
8
|
-
args: Record<string, unknown>;
|
|
9
|
-
options: Record<string, unknown>;
|
|
10
|
-
}
|
|
11
|
-
export interface CommandHandler {
|
|
12
|
-
/**
|
|
13
|
-
* Execute the command
|
|
14
|
-
* @param context - Command context with args and options
|
|
15
|
-
* @returns Promise that resolves when command completes
|
|
16
|
-
*/
|
|
17
|
-
execute(context: CommandContext): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
export interface CommandMiddleware {
|
|
20
|
-
/**
|
|
21
|
-
* Process the command before or after execution
|
|
22
|
-
* @param context - Command context
|
|
23
|
-
* @param next - Next middleware or handler
|
|
24
|
-
* @returns Promise that resolves when processing completes
|
|
25
|
-
*/
|
|
26
|
-
process(context: CommandContext, next: () => Promise<void>): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=CommandHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandHandler.d.ts","sourceRoot":"","sources":["../../../src/commands/base/CommandHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5E"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Built-in command middleware
|
|
3
|
-
*/
|
|
4
|
-
import { CommandContext, CommandMiddleware } from './CommandHandler';
|
|
5
|
-
import { Logger } from '../../utils/logger';
|
|
6
|
-
import { ConfigManager } from '../../state/config';
|
|
7
|
-
/**
|
|
8
|
-
* Logging middleware - logs command execution
|
|
9
|
-
*/
|
|
10
|
-
export declare class LoggingMiddleware implements CommandMiddleware {
|
|
11
|
-
private logger;
|
|
12
|
-
constructor(logger: Logger);
|
|
13
|
-
process(context: CommandContext, next: () => Promise<void>): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Validation middleware - validates command context
|
|
17
|
-
*/
|
|
18
|
-
export declare class ValidationMiddleware implements CommandMiddleware {
|
|
19
|
-
private configManager;
|
|
20
|
-
private requireAuth;
|
|
21
|
-
private requireOrganization;
|
|
22
|
-
constructor(configManager: ConfigManager, requireAuth?: boolean, requireOrganization?: boolean);
|
|
23
|
-
process(context: CommandContext, next: () => Promise<void>): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Performance monitoring middleware
|
|
27
|
-
*/
|
|
28
|
-
export declare class PerformanceMiddleware implements CommandMiddleware {
|
|
29
|
-
private logger;
|
|
30
|
-
private threshold;
|
|
31
|
-
constructor(logger: Logger, thresholdMs?: number);
|
|
32
|
-
process(context: CommandContext, next: () => Promise<void>): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/commands/base/middleware.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,iBAAiB;IAC7C,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE5B,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAejF;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,iBAAiB;IAE1D,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,mBAAmB;gBAFnB,aAAa,EAAE,aAAa,EAC5B,WAAW,GAAE,OAAe,EAC5B,mBAAmB,GAAE,OAAe;IAGxC,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAoBjF;AAED;;GAEG;AACH,qBAAa,qBAAsB,YAAW,iBAAiB;IAGjD,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,SAAS,CAAS;gBAEN,MAAM,EAAE,MAAM,EAAE,WAAW,GAAE,MAAa;IAIxD,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CASjF"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Built-in command middleware
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PerformanceMiddleware = exports.ValidationMiddleware = exports.LoggingMiddleware = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Logging middleware - logs command execution
|
|
9
|
-
*/
|
|
10
|
-
class LoggingMiddleware {
|
|
11
|
-
constructor(logger) {
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
}
|
|
14
|
-
async process(context, next) {
|
|
15
|
-
const commandName = context.command.name();
|
|
16
|
-
this.logger.debug(`Executing command: ${commandName}`, context.options);
|
|
17
|
-
const startTime = Date.now();
|
|
18
|
-
try {
|
|
19
|
-
await next();
|
|
20
|
-
const duration = Date.now() - startTime;
|
|
21
|
-
this.logger.debug(`Command completed: ${commandName} (${duration}ms)`);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
const duration = Date.now() - startTime;
|
|
25
|
-
this.logger.error(`Command failed: ${commandName} (${duration}ms)`, error);
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.LoggingMiddleware = LoggingMiddleware;
|
|
31
|
-
/**
|
|
32
|
-
* Validation middleware - validates command context
|
|
33
|
-
*/
|
|
34
|
-
class ValidationMiddleware {
|
|
35
|
-
constructor(configManager, requireAuth = false, requireOrganization = false) {
|
|
36
|
-
this.configManager = configManager;
|
|
37
|
-
this.requireAuth = requireAuth;
|
|
38
|
-
this.requireOrganization = requireOrganization;
|
|
39
|
-
}
|
|
40
|
-
async process(context, next) {
|
|
41
|
-
if (this.requireAuth) {
|
|
42
|
-
const config = this.configManager.getConfig();
|
|
43
|
-
const hasTokens = !!(config.accessToken || config.idToken);
|
|
44
|
-
const hasDeviceCreds = !!(config.deviceId && config.devicePassword);
|
|
45
|
-
if (!hasTokens && !hasDeviceCreds) {
|
|
46
|
-
throw new Error('Not authenticated. Please run "edgible login" first.');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (this.requireOrganization) {
|
|
50
|
-
const config = this.configManager.getConfig();
|
|
51
|
-
if (!config.organizationId) {
|
|
52
|
-
throw new Error('No organization found. Please login first.');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
await next();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.ValidationMiddleware = ValidationMiddleware;
|
|
59
|
-
/**
|
|
60
|
-
* Performance monitoring middleware
|
|
61
|
-
*/
|
|
62
|
-
class PerformanceMiddleware {
|
|
63
|
-
constructor(logger, thresholdMs = 1000) {
|
|
64
|
-
this.logger = logger;
|
|
65
|
-
this.threshold = thresholdMs;
|
|
66
|
-
}
|
|
67
|
-
async process(context, next) {
|
|
68
|
-
const startTime = Date.now();
|
|
69
|
-
await next();
|
|
70
|
-
const duration = Date.now() - startTime;
|
|
71
|
-
if (duration > this.threshold) {
|
|
72
|
-
this.logger.warn(`Slow command execution: ${context.command.name()} took ${duration}ms`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.PerformanceMiddleware = PerformanceMiddleware;
|
|
77
|
-
//# sourceMappingURL=middleware.js.map
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PathMigration utility handles migration from legacy ~/.edgible paths
|
|
3
|
-
* to the new XDG/platform-specific paths.
|
|
4
|
-
*/
|
|
5
|
-
export declare class PathMigration {
|
|
6
|
-
/**
|
|
7
|
-
* Check if legacy paths exist
|
|
8
|
-
*/
|
|
9
|
-
static hasLegacyPaths(): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Get the legacy config path
|
|
12
|
-
*/
|
|
13
|
-
static getLegacyConfigPath(): string;
|
|
14
|
-
/**
|
|
15
|
-
* Get the legacy agent path
|
|
16
|
-
*/
|
|
17
|
-
static getLegacyAgentPath(): string;
|
|
18
|
-
/**
|
|
19
|
-
* Migrate configuration from legacy paths to new paths
|
|
20
|
-
*
|
|
21
|
-
* @returns true if migration was successful or not needed, false if migration failed
|
|
22
|
-
*/
|
|
23
|
-
static migrateConfig(): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* Migrate agent data from legacy paths to new paths
|
|
26
|
-
*
|
|
27
|
-
* @returns true if migration was successful or not needed, false if migration failed
|
|
28
|
-
*/
|
|
29
|
-
static migrateAgentData(): Promise<boolean>;
|
|
30
|
-
/**
|
|
31
|
-
* Perform full migration from legacy paths to new paths
|
|
32
|
-
*
|
|
33
|
-
* @returns Migration result with details
|
|
34
|
-
*/
|
|
35
|
-
static migrate(): Promise<{
|
|
36
|
-
success: boolean;
|
|
37
|
-
migrated: string[];
|
|
38
|
-
errors: string[];
|
|
39
|
-
}>;
|
|
40
|
-
/**
|
|
41
|
-
* Copy directory recursively
|
|
42
|
-
*/
|
|
43
|
-
private static copyDirectory;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=PathMigration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PathMigration.d.ts","sourceRoot":"","sources":["../../src/utils/PathMigration.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,OAAO;IAKhC;;OAEG;IACH,MAAM,CAAC,mBAAmB,IAAI,MAAM;IAIpC;;OAEG;IACH,MAAM,CAAC,kBAAkB,IAAI,MAAM;IAInC;;;;OAIG;WACU,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAkD9C;;;;OAIG;WACU,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IA+BjD;;;;OAIG;WACU,OAAO,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAwC3F;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;CA2B7B"}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.PathMigration = void 0;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const os = __importStar(require("os"));
|
|
40
|
-
const PathResolver_1 = require("./PathResolver");
|
|
41
|
-
/**
|
|
42
|
-
* PathMigration utility handles migration from legacy ~/.edgible paths
|
|
43
|
-
* to the new XDG/platform-specific paths.
|
|
44
|
-
*/
|
|
45
|
-
class PathMigration {
|
|
46
|
-
/**
|
|
47
|
-
* Check if legacy paths exist
|
|
48
|
-
*/
|
|
49
|
-
static hasLegacyPaths() {
|
|
50
|
-
const legacyPath = path.join(os.homedir(), '.edgible');
|
|
51
|
-
return fs.existsSync(legacyPath);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Get the legacy config path
|
|
55
|
-
*/
|
|
56
|
-
static getLegacyConfigPath() {
|
|
57
|
-
return path.join(os.homedir(), '.edgible', 'config.json');
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get the legacy agent path
|
|
61
|
-
*/
|
|
62
|
-
static getLegacyAgentPath() {
|
|
63
|
-
return path.join(os.homedir(), '.edgible', 'agent');
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Migrate configuration from legacy paths to new paths
|
|
67
|
-
*
|
|
68
|
-
* @returns true if migration was successful or not needed, false if migration failed
|
|
69
|
-
*/
|
|
70
|
-
static async migrateConfig() {
|
|
71
|
-
try {
|
|
72
|
-
const legacyConfigPath = this.getLegacyConfigPath();
|
|
73
|
-
const newConfigPath = PathResolver_1.PathResolver.getCliConfigPath();
|
|
74
|
-
const newConfigDir = path.dirname(newConfigPath);
|
|
75
|
-
// Check if legacy config exists
|
|
76
|
-
if (!fs.existsSync(legacyConfigPath)) {
|
|
77
|
-
return true; // No migration needed
|
|
78
|
-
}
|
|
79
|
-
// Check if new config already exists
|
|
80
|
-
if (fs.existsSync(newConfigPath)) {
|
|
81
|
-
// Both exist - check if they're different
|
|
82
|
-
const legacyContent = fs.readFileSync(legacyConfigPath, 'utf8');
|
|
83
|
-
const newContent = fs.readFileSync(newConfigPath, 'utf8');
|
|
84
|
-
if (legacyContent === newContent) {
|
|
85
|
-
// Same content, migration already done
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
// Different content - backup new and use legacy
|
|
89
|
-
const backupPath = `${newConfigPath}.backup.${Date.now()}`;
|
|
90
|
-
fs.copyFileSync(newConfigPath, backupPath);
|
|
91
|
-
}
|
|
92
|
-
// Ensure new directory exists
|
|
93
|
-
if (!fs.existsSync(newConfigDir)) {
|
|
94
|
-
fs.mkdirSync(newConfigDir, { recursive: true });
|
|
95
|
-
}
|
|
96
|
-
// Copy config file
|
|
97
|
-
fs.copyFileSync(legacyConfigPath, newConfigPath);
|
|
98
|
-
// Preserve permissions
|
|
99
|
-
try {
|
|
100
|
-
const legacyStats = fs.statSync(legacyConfigPath);
|
|
101
|
-
fs.chmodSync(newConfigPath, legacyStats.mode);
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
// Ignore permission errors
|
|
105
|
-
}
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
console.warn('Failed to migrate config:', error);
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Migrate agent data from legacy paths to new paths
|
|
115
|
-
*
|
|
116
|
-
* @returns true if migration was successful or not needed, false if migration failed
|
|
117
|
-
*/
|
|
118
|
-
static async migrateAgentData() {
|
|
119
|
-
try {
|
|
120
|
-
const legacyAgentPath = this.getLegacyAgentPath();
|
|
121
|
-
const newAgentPath = PathResolver_1.PathResolver.getAgentConfigPath(false); // User path for CLI
|
|
122
|
-
// Check if legacy agent path exists
|
|
123
|
-
if (!fs.existsSync(legacyAgentPath)) {
|
|
124
|
-
return true; // No migration needed
|
|
125
|
-
}
|
|
126
|
-
// Check if new agent path already exists
|
|
127
|
-
if (fs.existsSync(newAgentPath)) {
|
|
128
|
-
// Both exist - skip migration to avoid overwriting
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
// Ensure new directory exists
|
|
132
|
-
if (!fs.existsSync(path.dirname(newAgentPath))) {
|
|
133
|
-
fs.mkdirSync(path.dirname(newAgentPath), { recursive: true });
|
|
134
|
-
}
|
|
135
|
-
// Copy entire agent directory
|
|
136
|
-
this.copyDirectory(legacyAgentPath, newAgentPath);
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
console.warn('Failed to migrate agent data:', error);
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Perform full migration from legacy paths to new paths
|
|
146
|
-
*
|
|
147
|
-
* @returns Migration result with details
|
|
148
|
-
*/
|
|
149
|
-
static async migrate() {
|
|
150
|
-
const result = {
|
|
151
|
-
success: true,
|
|
152
|
-
migrated: [],
|
|
153
|
-
errors: []
|
|
154
|
-
};
|
|
155
|
-
if (!this.hasLegacyPaths()) {
|
|
156
|
-
return result; // No legacy paths to migrate
|
|
157
|
-
}
|
|
158
|
-
// Migrate config
|
|
159
|
-
try {
|
|
160
|
-
if (await this.migrateConfig()) {
|
|
161
|
-
result.migrated.push('config');
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
result.errors.push('Failed to migrate config');
|
|
165
|
-
result.success = false;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
result.errors.push(`Config migration error: ${error instanceof Error ? error.message : String(error)}`);
|
|
170
|
-
result.success = false;
|
|
171
|
-
}
|
|
172
|
-
// Migrate agent data
|
|
173
|
-
try {
|
|
174
|
-
if (await this.migrateAgentData()) {
|
|
175
|
-
result.migrated.push('agent-data');
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
result.errors.push('Failed to migrate agent data');
|
|
179
|
-
result.success = false;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
result.errors.push(`Agent data migration error: ${error instanceof Error ? error.message : String(error)}`);
|
|
184
|
-
result.success = false;
|
|
185
|
-
}
|
|
186
|
-
return result;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Copy directory recursively
|
|
190
|
-
*/
|
|
191
|
-
static copyDirectory(src, dest) {
|
|
192
|
-
// Create destination directory
|
|
193
|
-
if (!fs.existsSync(dest)) {
|
|
194
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
195
|
-
}
|
|
196
|
-
// Read source directory
|
|
197
|
-
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
198
|
-
for (const entry of entries) {
|
|
199
|
-
const srcPath = path.join(src, entry.name);
|
|
200
|
-
const destPath = path.join(dest, entry.name);
|
|
201
|
-
if (entry.isDirectory()) {
|
|
202
|
-
this.copyDirectory(srcPath, destPath);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
fs.copyFileSync(srcPath, destPath);
|
|
206
|
-
// Preserve permissions
|
|
207
|
-
try {
|
|
208
|
-
const stats = fs.statSync(srcPath);
|
|
209
|
-
fs.chmodSync(destPath, stats.mode);
|
|
210
|
-
}
|
|
211
|
-
catch {
|
|
212
|
-
// Ignore permission errors
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
exports.PathMigration = PathMigration;
|
|
219
|
-
//# sourceMappingURL=PathMigration.js.map
|