farseer-cli 1.0.9 → 1.0.10
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/app.js +344 -316
- package/dist/commands/apps.js +83 -103
- package/dist/commands/checkout.js +156 -134
- package/dist/commands/config.js +126 -124
- package/dist/commands/diff.js +194 -169
- package/dist/commands/dimensions.js +122 -137
- package/dist/commands/files.js +77 -88
- package/dist/commands/install.js +77 -74
- package/dist/commands/list.js +74 -89
- package/dist/commands/login.js +101 -126
- package/dist/commands/logout.js +42 -57
- package/dist/commands/mcp-server.js +24 -39
- package/dist/commands/model.js +176 -184
- package/dist/commands/pull.js +276 -248
- package/dist/commands/push.js +222 -200
- package/dist/commands/run.js +322 -274
- package/dist/commands/status.js +170 -147
- package/dist/commands/variables.js +192 -168
- package/dist/commands/whoami.js +45 -61
- package/dist/index.js +115 -117
- package/dist/mcp/index.js +17 -33
- package/dist/mcp/prompts/workflows.js +146 -191
- package/dist/mcp/resources/documentation.js +149 -158
- package/dist/mcp/server.js +34 -50
- package/dist/mcp/tools/appTools.js +278 -307
- package/dist/mcp/tools/authTools.js +123 -130
- package/dist/mcp/tools/dataTools.js +271 -275
- package/dist/mcp/tools/modelTools.js +233 -265
- package/dist/mcp/tools/runTools.js +205 -199
- package/dist/mcp/tools/syncTools.js +315 -341
- package/dist/mcp/utils/helpers.js +124 -117
- package/dist/services/appSyncService.js +438 -379
- package/dist/services/configService.js +144 -154
- package/dist/services/farseerApi.js +401 -401
- package/dist/services/farseerFactory.js +274 -208
- package/dist/services/farseerService.js +488 -455
- package/dist/services/syncService.js +732 -657
- package/dist/utils/constants.js +20 -45
- package/dist/utils/helpers.js +366 -333
- package/dist/utils/logger.js +43 -74
- package/package.json +8 -1
- package/dist/commands/app.js.map +0 -7
- package/dist/commands/apps.js.map +0 -7
- package/dist/commands/checkout.js.map +0 -7
- package/dist/commands/config.js.map +0 -7
- package/dist/commands/diff.js.map +0 -7
- package/dist/commands/dimensions.js.map +0 -7
- package/dist/commands/files.js.map +0 -7
- package/dist/commands/install.js.map +0 -7
- package/dist/commands/list.js.map +0 -7
- package/dist/commands/login.js.map +0 -7
- package/dist/commands/logout.js.map +0 -7
- package/dist/commands/mcp-server.js.map +0 -7
- package/dist/commands/model.js.map +0 -7
- package/dist/commands/pull.js.map +0 -7
- package/dist/commands/push.js.map +0 -7
- package/dist/commands/run.js.map +0 -7
- package/dist/commands/status.js.map +0 -7
- package/dist/commands/variables.js.map +0 -7
- package/dist/commands/whoami.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/mcp/index.js.map +0 -7
- package/dist/mcp/prompts/workflows.js.map +0 -7
- package/dist/mcp/resources/documentation.js.map +0 -7
- package/dist/mcp/server.js.map +0 -7
- package/dist/mcp/tools/appTools.js.map +0 -7
- package/dist/mcp/tools/authTools.js.map +0 -7
- package/dist/mcp/tools/dataTools.js.map +0 -7
- package/dist/mcp/tools/modelTools.js.map +0 -7
- package/dist/mcp/tools/runTools.js.map +0 -7
- package/dist/mcp/tools/syncTools.js.map +0 -7
- package/dist/mcp/utils/helpers.js.map +0 -7
- package/dist/services/appSyncService.js.map +0 -7
- package/dist/services/configService.js.map +0 -7
- package/dist/services/farseerApi.js.map +0 -7
- package/dist/services/farseerFactory.js.map +0 -7
- package/dist/services/farseerService.js.map +0 -7
- package/dist/services/syncService.js.map +0 -7
- package/dist/utils/constants.js.map +0 -7
- package/dist/utils/helpers.js.map +0 -7
- package/dist/utils/logger.js.map +0 -7
|
@@ -1,135 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(helpers_exports);
|
|
31
|
-
var import_configService = require("../../services/configService");
|
|
32
|
-
var import_farseerFactory = require("../../services/farseerFactory");
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP Utility Functions
|
|
4
|
+
*
|
|
5
|
+
* Helper functions for MCP tools including tenant resolution and response formatting.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.resolveOrgAndTenant = resolveOrgAndTenant;
|
|
9
|
+
exports.resolveTenant = resolveTenant;
|
|
10
|
+
exports.resolveOrganisation = resolveOrganisation;
|
|
11
|
+
exports.getClient = getClient;
|
|
12
|
+
exports.successResponse = successResponse;
|
|
13
|
+
exports.errorResponse = errorResponse;
|
|
14
|
+
exports.authRequiredResponse = authRequiredResponse;
|
|
15
|
+
exports.tenantRequiredResponse = tenantRequiredResponse;
|
|
16
|
+
exports.getAuthStatus = getAuthStatus;
|
|
17
|
+
const configService_1 = require("../../services/configService");
|
|
18
|
+
const farseerFactory_1 = require("../../services/farseerFactory");
|
|
19
|
+
/**
|
|
20
|
+
* Resolve organisation and tenant from MCP tool parameters.
|
|
21
|
+
*
|
|
22
|
+
* Resolution order:
|
|
23
|
+
* 1. Explicit org/tenant params
|
|
24
|
+
* 2. Tenant param + saved org mapping (from previous checkout)
|
|
25
|
+
* 3. Current checkout
|
|
26
|
+
*
|
|
27
|
+
* Returns null if no tenant can be resolved.
|
|
28
|
+
*/
|
|
33
29
|
function resolveOrgAndTenant(params) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
const checkout = (0, configService_1.getCurrentCheckout)();
|
|
31
|
+
const { organisation: orgArg, tenant: tenantArg } = params;
|
|
32
|
+
// Case 1: Both provided explicitly
|
|
33
|
+
if (orgArg && tenantArg) {
|
|
34
|
+
return { organisation: orgArg, tenant: tenantArg };
|
|
35
|
+
}
|
|
36
|
+
// Case 2: Only tenant provided - look up org from saved mapping or assume org=tenant
|
|
37
|
+
if (tenantArg) {
|
|
38
|
+
const savedOrg = (0, configService_1.getTenantOrg)(tenantArg);
|
|
39
|
+
return { organisation: savedOrg || orgArg || tenantArg, tenant: tenantArg };
|
|
40
|
+
}
|
|
41
|
+
// Case 3: Only org provided (unusual, but treat as org=tenant)
|
|
42
|
+
if (orgArg) {
|
|
43
|
+
return { organisation: orgArg, tenant: orgArg };
|
|
44
|
+
}
|
|
45
|
+
// Case 4: No args - use checkout
|
|
46
|
+
if (checkout) {
|
|
47
|
+
return { organisation: checkout.organisation, tenant: checkout.tenant };
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Resolve tenant from argument or checkout state
|
|
53
|
+
*/
|
|
51
54
|
function resolveTenant(tenantArg) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
if (tenantArg) {
|
|
56
|
+
return tenantArg;
|
|
57
|
+
}
|
|
58
|
+
return (0, configService_1.getCurrentTenant)() || null;
|
|
56
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolve organisation from argument or checkout state
|
|
62
|
+
*/
|
|
57
63
|
function resolveOrganisation(orgArg, tenantArg) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
if (orgArg) {
|
|
65
|
+
return orgArg;
|
|
66
|
+
}
|
|
67
|
+
if (tenantArg) {
|
|
68
|
+
const savedOrg = (0, configService_1.getTenantOrg)(tenantArg);
|
|
69
|
+
if (savedOrg)
|
|
70
|
+
return savedOrg;
|
|
71
|
+
return tenantArg;
|
|
72
|
+
}
|
|
73
|
+
const checkout = (0, configService_1.getCurrentCheckout)();
|
|
74
|
+
return checkout?.organisation || null;
|
|
68
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Get authenticated Farseer client
|
|
78
|
+
*/
|
|
69
79
|
async function getClient(tenant, tenantId) {
|
|
70
|
-
|
|
71
|
-
|
|
80
|
+
const result = await (0, farseerFactory_1.getFarseerClientWithFallback)(tenant, tenantId ?? tenant);
|
|
81
|
+
return result?.client || null;
|
|
72
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Create a success response
|
|
85
|
+
*/
|
|
73
86
|
function successResponse(data) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
return {
|
|
88
|
+
content: [
|
|
89
|
+
{
|
|
90
|
+
type: 'text',
|
|
91
|
+
text: JSON.stringify({ success: true, ...data }, null, 2),
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
82
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Create an error response
|
|
98
|
+
*/
|
|
83
99
|
function errorResponse(message, errorCode) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
],
|
|
99
|
-
isError: true
|
|
100
|
-
};
|
|
100
|
+
return {
|
|
101
|
+
content: [
|
|
102
|
+
{
|
|
103
|
+
type: 'text',
|
|
104
|
+
text: JSON.stringify({
|
|
105
|
+
success: false,
|
|
106
|
+
error: message,
|
|
107
|
+
errorCode: errorCode || 'UNKNOWN',
|
|
108
|
+
}, null, 2),
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
isError: true,
|
|
112
|
+
};
|
|
101
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Create auth required error response
|
|
116
|
+
*/
|
|
102
117
|
function authRequiredResponse(tenant) {
|
|
103
|
-
|
|
104
|
-
|
|
118
|
+
const message = tenant
|
|
119
|
+
? `Authentication required for tenant "${tenant}". Run "farseer login" to authenticate.`
|
|
120
|
+
: 'Authentication required. Run "farseer login" to authenticate.';
|
|
121
|
+
return errorResponse(message, 'AUTH_REQUIRED');
|
|
105
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Create tenant required error response
|
|
125
|
+
*/
|
|
106
126
|
function tenantRequiredResponse() {
|
|
107
|
-
|
|
108
|
-
'No tenant specified. Either provide tenant parameter or run "farseer checkout <tenant>" first.',
|
|
109
|
-
"VALIDATION_ERROR"
|
|
110
|
-
);
|
|
127
|
+
return errorResponse('No tenant specified. Either provide tenant parameter or run "farseer checkout <tenant>" first.', 'VALIDATION_ERROR');
|
|
111
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Get auth status info
|
|
131
|
+
*/
|
|
112
132
|
function getAuthStatus() {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
const auth = (0, configService_1.getUserAuth)();
|
|
134
|
+
const checkout = (0, configService_1.getCurrentCheckout)();
|
|
135
|
+
const credentials = (0, configService_1.listCredentials)();
|
|
136
|
+
return {
|
|
137
|
+
jwtValid: (0, configService_1.isUserAuthValid)(),
|
|
138
|
+
jwtExpiresAt: auth?.expiresAt,
|
|
139
|
+
currentCheckout: checkout,
|
|
140
|
+
configuredTenants: Object.keys(credentials),
|
|
141
|
+
};
|
|
122
142
|
}
|
|
123
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
-
0 && (module.exports = {
|
|
125
|
-
authRequiredResponse,
|
|
126
|
-
errorResponse,
|
|
127
|
-
getAuthStatus,
|
|
128
|
-
getClient,
|
|
129
|
-
resolveOrgAndTenant,
|
|
130
|
-
resolveOrganisation,
|
|
131
|
-
resolveTenant,
|
|
132
|
-
successResponse,
|
|
133
|
-
tenantRequiredResponse
|
|
134
|
-
});
|
|
135
|
-
//# sourceMappingURL=helpers.js.map
|