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.
Files changed (81) hide show
  1. package/dist/commands/app.js +344 -316
  2. package/dist/commands/apps.js +83 -103
  3. package/dist/commands/checkout.js +156 -134
  4. package/dist/commands/config.js +126 -124
  5. package/dist/commands/diff.js +194 -169
  6. package/dist/commands/dimensions.js +122 -137
  7. package/dist/commands/files.js +77 -88
  8. package/dist/commands/install.js +77 -74
  9. package/dist/commands/list.js +74 -89
  10. package/dist/commands/login.js +101 -126
  11. package/dist/commands/logout.js +42 -57
  12. package/dist/commands/mcp-server.js +24 -39
  13. package/dist/commands/model.js +176 -184
  14. package/dist/commands/pull.js +276 -248
  15. package/dist/commands/push.js +222 -200
  16. package/dist/commands/run.js +322 -274
  17. package/dist/commands/status.js +170 -147
  18. package/dist/commands/variables.js +192 -168
  19. package/dist/commands/whoami.js +45 -61
  20. package/dist/index.js +115 -117
  21. package/dist/mcp/index.js +17 -33
  22. package/dist/mcp/prompts/workflows.js +146 -191
  23. package/dist/mcp/resources/documentation.js +149 -158
  24. package/dist/mcp/server.js +34 -50
  25. package/dist/mcp/tools/appTools.js +278 -307
  26. package/dist/mcp/tools/authTools.js +123 -130
  27. package/dist/mcp/tools/dataTools.js +271 -275
  28. package/dist/mcp/tools/modelTools.js +233 -265
  29. package/dist/mcp/tools/runTools.js +205 -199
  30. package/dist/mcp/tools/syncTools.js +315 -341
  31. package/dist/mcp/utils/helpers.js +124 -117
  32. package/dist/services/appSyncService.js +438 -379
  33. package/dist/services/configService.js +144 -154
  34. package/dist/services/farseerApi.js +401 -401
  35. package/dist/services/farseerFactory.js +274 -208
  36. package/dist/services/farseerService.js +488 -455
  37. package/dist/services/syncService.js +732 -657
  38. package/dist/utils/constants.js +20 -45
  39. package/dist/utils/helpers.js +366 -333
  40. package/dist/utils/logger.js +43 -74
  41. package/package.json +8 -1
  42. package/dist/commands/app.js.map +0 -7
  43. package/dist/commands/apps.js.map +0 -7
  44. package/dist/commands/checkout.js.map +0 -7
  45. package/dist/commands/config.js.map +0 -7
  46. package/dist/commands/diff.js.map +0 -7
  47. package/dist/commands/dimensions.js.map +0 -7
  48. package/dist/commands/files.js.map +0 -7
  49. package/dist/commands/install.js.map +0 -7
  50. package/dist/commands/list.js.map +0 -7
  51. package/dist/commands/login.js.map +0 -7
  52. package/dist/commands/logout.js.map +0 -7
  53. package/dist/commands/mcp-server.js.map +0 -7
  54. package/dist/commands/model.js.map +0 -7
  55. package/dist/commands/pull.js.map +0 -7
  56. package/dist/commands/push.js.map +0 -7
  57. package/dist/commands/run.js.map +0 -7
  58. package/dist/commands/status.js.map +0 -7
  59. package/dist/commands/variables.js.map +0 -7
  60. package/dist/commands/whoami.js.map +0 -7
  61. package/dist/index.js.map +0 -7
  62. package/dist/mcp/index.js.map +0 -7
  63. package/dist/mcp/prompts/workflows.js.map +0 -7
  64. package/dist/mcp/resources/documentation.js.map +0 -7
  65. package/dist/mcp/server.js.map +0 -7
  66. package/dist/mcp/tools/appTools.js.map +0 -7
  67. package/dist/mcp/tools/authTools.js.map +0 -7
  68. package/dist/mcp/tools/dataTools.js.map +0 -7
  69. package/dist/mcp/tools/modelTools.js.map +0 -7
  70. package/dist/mcp/tools/runTools.js.map +0 -7
  71. package/dist/mcp/tools/syncTools.js.map +0 -7
  72. package/dist/mcp/utils/helpers.js.map +0 -7
  73. package/dist/services/appSyncService.js.map +0 -7
  74. package/dist/services/configService.js.map +0 -7
  75. package/dist/services/farseerApi.js.map +0 -7
  76. package/dist/services/farseerFactory.js.map +0 -7
  77. package/dist/services/farseerService.js.map +0 -7
  78. package/dist/services/syncService.js.map +0 -7
  79. package/dist/utils/constants.js.map +0 -7
  80. package/dist/utils/helpers.js.map +0 -7
  81. package/dist/utils/logger.js.map +0 -7
@@ -1,135 +1,142 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var helpers_exports = {};
19
- __export(helpers_exports, {
20
- authRequiredResponse: () => authRequiredResponse,
21
- errorResponse: () => errorResponse,
22
- getAuthStatus: () => getAuthStatus,
23
- getClient: () => getClient,
24
- resolveOrgAndTenant: () => resolveOrgAndTenant,
25
- resolveOrganisation: () => resolveOrganisation,
26
- resolveTenant: () => resolveTenant,
27
- successResponse: () => successResponse,
28
- tenantRequiredResponse: () => tenantRequiredResponse
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
- const checkout = (0, import_configService.getCurrentCheckout)();
35
- const { organisation: orgArg, tenant: tenantArg } = params;
36
- if (orgArg && tenantArg) {
37
- return { organisation: orgArg, tenant: tenantArg };
38
- }
39
- if (tenantArg) {
40
- const savedOrg = (0, import_configService.getTenantOrg)(tenantArg);
41
- return { organisation: savedOrg || orgArg || tenantArg, tenant: tenantArg };
42
- }
43
- if (orgArg) {
44
- return { organisation: orgArg, tenant: orgArg };
45
- }
46
- if (checkout) {
47
- return { organisation: checkout.organisation, tenant: checkout.tenant };
48
- }
49
- return null;
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
- if (tenantArg) {
53
- return tenantArg;
54
- }
55
- return (0, import_configService.getCurrentTenant)() || null;
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
- if (orgArg) {
59
- return orgArg;
60
- }
61
- if (tenantArg) {
62
- const savedOrg = (0, import_configService.getTenantOrg)(tenantArg);
63
- if (savedOrg) return savedOrg;
64
- return tenantArg;
65
- }
66
- const checkout = (0, import_configService.getCurrentCheckout)();
67
- return checkout?.organisation || null;
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
- const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(tenant, tenantId);
71
- return result?.client || null;
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
- return {
75
- content: [
76
- {
77
- type: "text",
78
- text: JSON.stringify({ success: true, ...data }, null, 2)
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
- return {
85
- content: [
86
- {
87
- type: "text",
88
- text: JSON.stringify(
89
- {
90
- success: false,
91
- error: message,
92
- errorCode: errorCode || "UNKNOWN"
93
- },
94
- null,
95
- 2
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
- const message = tenant ? `Authentication required for tenant "${tenant}". Run "farseer login" to authenticate.` : 'Authentication required. Run "farseer login" to authenticate.';
104
- return errorResponse(message, "AUTH_REQUIRED");
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
- return errorResponse(
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
- const auth = (0, import_configService.getUserAuth)();
114
- const checkout = (0, import_configService.getCurrentCheckout)();
115
- const credentials = (0, import_configService.listCredentials)();
116
- return {
117
- jwtValid: (0, import_configService.isUserAuthValid)(),
118
- jwtExpiresAt: auth?.expiresAt,
119
- currentCheckout: checkout,
120
- configuredTenants: Object.keys(credentials)
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