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,40 +1,29 @@
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 authTools_exports = {};
19
- __export(authTools_exports, {
20
- registerAuthTools: () => registerAuthTools
21
- });
22
- module.exports = __toCommonJS(authTools_exports);
23
- var import_zod = require("zod");
24
- var import_configService = require("../../services/configService");
25
- var import_farseerFactory = require("../../services/farseerFactory");
26
- var import_syncService = require("../../services/syncService");
27
- var import_appSyncService = require("../../services/appSyncService");
28
- var import_helpers = require("../utils/helpers");
1
+ "use strict";
2
+ /**
3
+ * Authentication and Configuration Tools
4
+ *
5
+ * Tools for checking auth status and managing tenant checkout.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.registerAuthTools = registerAuthTools;
9
+ const zod_1 = require("zod");
10
+ const configService_1 = require("../../services/configService");
11
+ const farseerFactory_1 = require("../../services/farseerFactory");
12
+ const syncService_1 = require("../../services/syncService");
13
+ const appSyncService_1 = require("../../services/appSyncService");
14
+ const helpers_1 = require("../utils/helpers");
15
+ // Define schemas outside of tool registration to avoid deep type instantiation
29
16
  const checkoutSchema = {
30
- organisation: import_zod.z.string().optional().describe("Farseer organisation (subdomain). If omitted with tenant, assumes org=tenant."),
31
- tenant: import_zod.z.string().optional().describe("Tenant ID. If omitted, returns current checkout status."),
32
- skipPull: import_zod.z.boolean().optional().describe("Skip automatic pull after checkout (default: false)")
17
+ organisation: zod_1.z
18
+ .string()
19
+ .optional()
20
+ .describe('Farseer organisation (subdomain). If omitted with tenant, assumes org=tenant.'),
21
+ tenant: zod_1.z.string().optional().describe('Tenant ID. If omitted, returns current checkout status.'),
22
+ skipPull: zod_1.z.boolean().optional().describe('Skip automatic pull after checkout (default: false)'),
33
23
  };
34
24
  function registerAuthTools(server) {
35
- server.tool(
36
- "farseer_whoami",
37
- `Check Farseer authentication status.
25
+ // farseer_whoami - Check authentication status
26
+ server.tool('farseer_whoami', `Check Farseer authentication status.
38
27
 
39
28
  Returns information about:
40
29
  - Whether a JWT token is valid (from browser login)
@@ -43,22 +32,22 @@ Returns information about:
43
32
  - List of tenants with API keys configured
44
33
 
45
34
  Use this before any operation to verify you have valid credentials.
46
- If not authenticated, run "farseer login" in terminal.`,
47
- {},
48
- async () => {
49
- const status = (0, import_helpers.getAuthStatus)();
50
- return (0, import_helpers.successResponse)({
51
- jwtValid: status.jwtValid,
52
- jwtExpiresAt: status.jwtExpiresAt,
53
- currentCheckout: status.currentCheckout,
54
- configuredTenants: status.configuredTenants,
55
- message: status.jwtValid ? "Authenticated via browser login (JWT)" : status.configuredTenants.length > 0 ? "Not authenticated via browser, but API keys are configured" : 'Not authenticated. Run "farseer login" to authenticate.'
56
- });
57
- }
58
- );
59
- server.tool(
60
- "farseer_checkout",
61
- `Set a default tenant for all subsequent Farseer operations, or get the current checkout status.
35
+ If not authenticated, run "farseer login" in terminal.`, {}, async () => {
36
+ const status = (0, helpers_1.getAuthStatus)();
37
+ return (0, helpers_1.successResponse)({
38
+ jwtValid: status.jwtValid,
39
+ jwtExpiresAt: status.jwtExpiresAt,
40
+ currentCheckout: status.currentCheckout,
41
+ configuredTenants: status.configuredTenants,
42
+ message: status.jwtValid
43
+ ? 'Authenticated via browser login (JWT)'
44
+ : status.configuredTenants.length > 0
45
+ ? 'Not authenticated via browser, but API keys are configured'
46
+ : 'Not authenticated. Run "farseer login" to authenticate.',
47
+ });
48
+ });
49
+ // farseer_checkout - Set or get default tenant
50
+ server.tool('farseer_checkout', `Set a default tenant for all subsequent Farseer operations, or get the current checkout status.
62
51
 
63
52
  When setting a tenant:
64
53
  - Verifies authentication works for that tenant
@@ -72,88 +61,92 @@ Organisation and tenant terminology:
72
61
  Often org and tenant are the same (e.g., "tthotels"), but they can differ
73
62
  (e.g., org="fs-personal", tenant="john-doe").
74
63
 
75
- If you only provide tenant without organisation, it assumes org=tenant.`,
76
- checkoutSchema,
64
+ If you only provide tenant without organisation, it assumes org=tenant.`, checkoutSchema,
65
+ // @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
77
66
  async (params) => {
78
- const { organisation, tenant, skipPull } = params;
79
- if (!tenant) {
80
- const current = (0, import_configService.getCurrentCheckout)();
81
- if (current) {
82
- return (0, import_helpers.successResponse)({
83
- currentCheckout: current,
84
- message: `Currently checked out: ${current.tenant} (org: ${current.organisation})`
85
- });
86
- } else {
87
- return (0, import_helpers.successResponse)({
88
- currentCheckout: null,
89
- message: "No tenant currently checked out. Use tenant parameter to checkout."
90
- });
67
+ const { organisation, tenant, skipPull } = params;
68
+ // If no tenant provided, return current checkout status
69
+ if (!tenant) {
70
+ const current = (0, configService_1.getCurrentCheckout)();
71
+ if (current) {
72
+ return (0, helpers_1.successResponse)({
73
+ currentCheckout: current,
74
+ message: `Currently checked out: ${current.tenant} (org: ${current.organisation})`,
75
+ });
76
+ }
77
+ else {
78
+ return (0, helpers_1.successResponse)({
79
+ currentCheckout: null,
80
+ message: 'No tenant currently checked out. Use tenant parameter to checkout.',
81
+ });
82
+ }
91
83
  }
92
- }
93
- const org = organisation || tenant;
94
- const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(org, tenant);
95
- if (!clientResult) {
96
- return (0, import_helpers.authRequiredResponse)(tenant);
97
- }
98
- if (org === tenant) {
99
- (0, import_configService.setCurrentTenant)(tenant);
100
- } else {
101
- (0, import_configService.setCurrentCheckout)(org, tenant);
102
- }
103
- (0, import_configService.saveTenantOrgMapping)(tenant, org);
104
- let pullResult = null;
105
- let appPullResult = null;
106
- if (!skipPull) {
107
- try {
108
- const syncService = new import_syncService.SyncService(tenant, clientResult.client);
109
- pullResult = await syncService.pull();
110
- if (clientResult.authType === "jwt") {
111
- const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
112
- appPullResult = await appSyncService.pull();
113
- }
114
- } catch (error) {
115
- return (0, import_helpers.successResponse)({
116
- currentCheckout: { organisation: org, tenant },
117
- message: `Checked out ${tenant}, but pull failed: ${error instanceof Error ? error.message : "Unknown error"}`,
118
- pullError: true
119
- });
84
+ // Resolve organisation (default to tenant if not specified)
85
+ const org = organisation || tenant;
86
+ // Test connection before setting checkout
87
+ const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(org, tenant);
88
+ if (!clientResult) {
89
+ return (0, helpers_1.authRequiredResponse)(tenant);
90
+ }
91
+ // Set checkout and save org-tenant mapping
92
+ if (org === tenant) {
93
+ (0, configService_1.setCurrentTenant)(tenant);
120
94
  }
121
- }
122
- return (0, import_helpers.successResponse)({
123
- currentCheckout: { organisation: org, tenant },
124
- message: `Successfully checked out ${tenant}${skipPull ? "" : " and pulled latest files"}`,
125
- files: pullResult ? {
126
- downloaded: pullResult.downloaded,
127
- deleted: pullResult.deleted,
128
- unchanged: pullResult.unchanged.length
129
- } : void 0,
130
- apps: appPullResult ? {
131
- created: appPullResult.created,
132
- updated: appPullResult.updated,
133
- deleted: appPullResult.deleted,
134
- unchanged: appPullResult.unchanged.length
135
- } : void 0
136
- });
137
- }
138
- );
139
- server.tool(
140
- "farseer_checkout_clear",
141
- `Clear the current tenant checkout.
95
+ else {
96
+ (0, configService_1.setCurrentCheckout)(org, tenant);
97
+ }
98
+ (0, configService_1.saveTenantOrgMapping)(tenant, org);
99
+ let pullResult = null;
100
+ let appPullResult = null;
101
+ // Pull files and apps unless skipped
102
+ if (!skipPull) {
103
+ try {
104
+ const syncService = new syncService_1.SyncService(tenant, clientResult.client);
105
+ pullResult = await syncService.pull();
106
+ // Pull apps if using JWT auth (API key doesn't support apps)
107
+ if (clientResult.authType === 'jwt') {
108
+ const appSyncService = new appSyncService_1.AppSyncService(tenant, clientResult.client);
109
+ appPullResult = await appSyncService.pull();
110
+ }
111
+ }
112
+ catch (error) {
113
+ // Pull failed but checkout succeeded
114
+ return (0, helpers_1.successResponse)({
115
+ currentCheckout: { organisation: org, tenant },
116
+ message: `Checked out ${tenant}, but pull failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
117
+ pullError: true,
118
+ });
119
+ }
120
+ }
121
+ return (0, helpers_1.successResponse)({
122
+ currentCheckout: { organisation: org, tenant },
123
+ message: `Successfully checked out ${tenant}${skipPull ? '' : ' and pulled latest files'}`,
124
+ files: pullResult
125
+ ? {
126
+ downloaded: pullResult.downloaded,
127
+ deleted: pullResult.deleted,
128
+ unchanged: pullResult.unchanged.length,
129
+ }
130
+ : undefined,
131
+ apps: appPullResult
132
+ ? {
133
+ created: appPullResult.created,
134
+ updated: appPullResult.updated,
135
+ deleted: appPullResult.deleted,
136
+ unchanged: appPullResult.unchanged.length,
137
+ }
138
+ : undefined,
139
+ });
140
+ });
141
+ // farseer_checkout_clear - Clear current checkout
142
+ server.tool('farseer_checkout_clear', `Clear the current tenant checkout.
142
143
 
143
- After clearing, you'll need to specify tenant explicitly for all commands.`,
144
- {},
145
- async () => {
146
- const current = (0, import_configService.getCurrentCheckout)();
147
- (0, import_configService.clearCurrentTenant)();
148
- return (0, import_helpers.successResponse)({
149
- previousCheckout: current,
150
- message: current ? `Cleared checkout for ${current.tenant}` : "No tenant was checked out"
151
- });
152
- }
153
- );
144
+ After clearing, you'll need to specify tenant explicitly for all commands.`, {}, async () => {
145
+ const current = (0, configService_1.getCurrentCheckout)();
146
+ (0, configService_1.clearCurrentTenant)();
147
+ return (0, helpers_1.successResponse)({
148
+ previousCheckout: current,
149
+ message: current ? `Cleared checkout for ${current.tenant}` : 'No tenant was checked out',
150
+ });
151
+ });
154
152
  }
155
- // Annotate the CommonJS export names for ESM import in node:
156
- 0 && (module.exports = {
157
- registerAuthTools
158
- });
159
- //# sourceMappingURL=authTools.js.map