farseer-cli 1.0.3 → 1.0.5
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/dimensions.js +145 -0
- package/dist/commands/dimensions.js.map +7 -0
- package/dist/commands/variables.js +176 -0
- package/dist/commands/variables.js.map +7 -0
- package/dist/index.js +19 -1
- package/dist/index.js.map +2 -2
- package/dist/mcp/prompts/workflows.js +64 -1
- package/dist/mcp/prompts/workflows.js.map +2 -2
- package/dist/mcp/server.js +4 -1
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +366 -0
- package/dist/mcp/tools/dataTools.js.map +7 -0
- package/dist/services/farseerFactory.js +52 -0
- package/dist/services/farseerFactory.js.map +2 -2
- package/dist/utils/constants.js +3 -0
- package/dist/utils/constants.js.map +2 -2
- package/package.json +1 -1
- package/dist/commands/app.d.ts +0 -2
- package/dist/commands/apps.d.ts +0 -2
- package/dist/commands/checkout.d.ts +0 -2
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/diff.d.ts +0 -2
- package/dist/commands/install.d.ts +0 -2
- package/dist/commands/list.d.ts +0 -2
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/mcp-server.d.ts +0 -8
- package/dist/commands/model.d.ts +0 -2
- package/dist/commands/pull.d.ts +0 -2
- package/dist/commands/push.d.ts +0 -2
- package/dist/commands/run.d.ts +0 -2
- package/dist/commands/setup.d.ts +0 -2
- package/dist/commands/setup.js +0 -137
- package/dist/commands/status.d.ts +0 -2
- package/dist/commands/unsetup.d.ts +0 -2
- package/dist/commands/unsetup.js +0 -122
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/mcp/index.d.ts +0 -7
- package/dist/mcp/prompts/workflows.d.ts +0 -7
- package/dist/mcp/resources/documentation.d.ts +0 -8
- package/dist/mcp/server.d.ts +0 -7
- package/dist/mcp/tools/appTools.d.ts +0 -7
- package/dist/mcp/tools/authTools.d.ts +0 -7
- package/dist/mcp/tools/modelTools.d.ts +0 -7
- package/dist/mcp/tools/runTools.d.ts +0 -7
- package/dist/mcp/tools/syncTools.d.ts +0 -7
- package/dist/mcp/utils/helpers.d.ts +0 -69
- package/dist/services/appSyncService.d.ts +0 -75
- package/dist/services/configService.d.ts +0 -39
- package/dist/services/farseerApi.d.ts +0 -166
- package/dist/services/farseerFactory.d.ts +0 -88
- package/dist/services/farseerService.d.ts +0 -96
- package/dist/services/gitService.d.ts +0 -31
- package/dist/services/syncService.d.ts +0 -44
- package/dist/utils/constants.d.ts +0 -7
- package/dist/utils/helpers.d.ts +0 -69
- package/dist/utils/logger.d.ts +0 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/farseerFactory.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Factory for creating Farseer API client based on available authentication\n *\n * Priority:\n * 1. JWT token (from browser login) - try first\n * 2. API key (from config) - fallback if JWT fails or unavailable\n * 3. Prompt user to login - if nothing works\n */\n\nimport { FarseerService } from './farseerService';\nimport { FarseerApi } from './farseerApi';\nimport { getCredential, getUserAuth, isUserAuthValid, setUserAuth } from './configService';\nimport { refreshAccessToken } from './farseerService';\nimport { logger } from '../utils/logger';\n\n/**\n * Check if an error is an authentication error (401/403)\n */\nexport function isAuthError(error: unknown): boolean {\n if (error instanceof Error) {\n const msg = error.message.toLowerCase();\n return msg.includes('401') || msg.includes('403') || msg.includes('unauthorized') || msg.includes('forbidden');\n }\n return false;\n}\n\n/**\n * Show a consistent \"please login\" message\n */\nexport function showLoginPrompt(tenant?: string): void {\n logger.error('Authentication required.');\n if (tenant) {\n logger.dim(`No valid credentials found for tenant \"${tenant}\".`);\n }\n logger.info('Run \"farseer login\" to authenticate via browser.');\n logger.dim('Or use \"farseer config set <tenant> --api-key <key>\" for API key auth.');\n}\n\nexport interface FileMetadata {\n uploadTime?: string; // ISO timestamp\n uploader?: {\n id: number;\n email: string;\n firstName: string;\n lastName: string;\n };\n size?: number;\n}\n\nexport interface RemoteFile {\n name: string;\n path: string;\n reference: string;\n metadata?: FileMetadata;\n}\n\n// Default file extensions to sync (scripts only)\nexport const DEFAULT_SCRIPT_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];\n\nimport { AppArgument, AppListItem, RemoteApp, ModelExport } from './farseerApi';\n\n// Common interface that both FarseerService and FarseerApi implement\nexport interface IFarseerClient {\n testConnection(): Promise<boolean>;\n getFilesFolder(): Promise<{ id: number; name: string; type: string } | null>;\n listFiles(folderPath?: string[]): Promise<RemoteFile[]>;\n getFileContent(reference: string): Promise<string>;\n getFileContentAsBuffer(reference: string): Promise<Buffer>;\n createFile(content: string | Buffer, fileName: string, folderPath?: string[]): Promise<void>;\n updateFile(reference: string, content: string | Buffer, fileName: string): Promise<void>;\n deleteFile(reference: string): Promise<void>;\n getFileByPath(filePath: string): Promise<RemoteFile | null>;\n getFileMetadata(reference: string): Promise<FileMetadata | null>;\n isTextFile(filename: string): boolean;\n isBinaryFile(filename: string): boolean;\n // Apps API methods\n listApps(): Promise<AppListItem[]>;\n getApp(referenceId: string): Promise<RemoteApp | null>;\n getAppByName(name: string): Promise<RemoteApp | null>;\n createApp(name: string): Promise<RemoteApp>;\n updateApp(referenceId: string, update: {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n scriptFileIds?: string[];\n }): Promise<RemoteApp>;\n deleteApp(referenceId: string): Promise<void>;\n getScriptFiles(): Promise<{ id: string; name: string }[]>;\n // Model export\n exportModel(): Promise<ModelExport>;\n // Token management (optional - only FarseerApi implements this)\n updateAccessToken?(newToken: string): void;\n}\n\nexport interface FarseerClientResult {\n client: IFarseerClient;\n authType: 'apiKey' | 'jwt';\n}\n\n/**\n * Get a Farseer client for the given organisation and tenant.\n * Tries JWT token first (supports apps), then falls back to API key.\n *\n * @param organisation - The organisation hostname (e.g., \"jgl\" for jgl.farseer.io)\n * @param tenant - Tenant name for X-TENANT-ID header (e.g., \"tt-hotels-hr-dev\")\n */\nexport async function getFarseerClient(organisation: string, tenant: string): Promise<FarseerClientResult | null> {\n // 1. Try JWT token from browser login first (supports apps sync)\n const auth = getUserAuth();\n if (auth) {\n // Check if token needs refresh\n let accessToken = auth.accessToken;\n if (!isUserAuthValid()) {\n logger.dim('Token expired, refreshing...');\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n if (!refreshed) {\n logger.warning('Could not refresh token. Please login again with: farseer login');\n // Fall through to API key\n } else {\n // Save refreshed token\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n accessToken = refreshed.accessToken;\n logger.dim('Token refreshed');\n }\n }\n\n if (isUserAuthValid()) {\n return {\n client: new FarseerApi(accessToken, organisation, tenant),\n authType: 'jwt',\n };\n }\n }\n\n // 2. Fall back to API key config\n const credential = getCredential(tenant);\n if (credential) {\n return {\n client: new FarseerService(credential),\n authType: 'apiKey',\n };\n }\n\n return null;\n}\n\n/**\n * Check what authentication methods are available\n */\nexport function getAvailableAuth(tenant: string): {\n hasApiKey: boolean;\n hasJwt: boolean;\n jwtValid: boolean;\n} {\n const credential = getCredential(tenant);\n const auth = getUserAuth();\n\n return {\n hasApiKey: !!credential,\n hasJwt: !!auth,\n jwtValid: isUserAuthValid(),\n };\n}\n\n/**\n * Get a Farseer client with automatic fallback and connection testing.\n * This is the recommended way to get a client for commands.\n *\n * Flow:\n * 1. Try JWT if available and valid\n * 2. If JWT fails or unavailable, try API key\n * 3. If nothing works, return null (caller should show login prompt)\n *\n * @param organisation - The organisation hostname (e.g., \"jgl\" for jgl.farseer.io)\n * @param tenant - Tenant name for X-TENANT-ID header (e.g., \"tt-hotels-hr-dev\")\n */\nexport async function getFarseerClientWithFallback(\n organisation: string,\n tenant: string\n): Promise<FarseerClientResult | null> {\n const auth = getUserAuth();\n const credential = getCredential(tenant);\n\n // 1. Try JWT token first\n if (auth) {\n let accessToken = auth.accessToken;\n\n // Refresh token if needed\n if (!isUserAuthValid()) {\n logger.dim('Token expired, refreshing...');\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n if (refreshed) {\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n accessToken = refreshed.accessToken;\n logger.dim('Token refreshed');\n }\n }\n\n if (isUserAuthValid()) {\n const jwtClient = new FarseerApi(accessToken, organisation, tenant);\n\n // Test JWT connection\n try {\n const connected = await jwtClient.testConnection();\n if (connected) {\n return { client: jwtClient, authType: 'jwt' };\n }\n } catch (error) {\n // JWT failed, will try API key\n logger.dim('JWT auth failed for this tenant, trying API key...');\n }\n }\n }\n\n // 2. Try API key\n if (credential) {\n const apiKeyClient = new FarseerService(credential);\n\n try {\n const connected = await apiKeyClient.testConnection();\n if (connected) {\n return { client: apiKeyClient, authType: 'apiKey' };\n }\n } catch {\n // API key also failed\n logger.dim('API key auth failed.');\n }\n }\n\n // 3. Nothing worked\n return null;\n}\n\n/**\n * Ensure the token is fresh and update the client if needed.\n * Call this before long-running operations to avoid token expiration.\n *\n * @returns true if token was refreshed, false if no refresh needed or API key auth\n */\nexport async function ensureFreshToken(client: IFarseerClient): Promise<boolean> {\n const auth = getUserAuth();\n if (!auth) {\n return false; // No JWT auth, probably using API key\n }\n\n // Check if token needs refresh (give 30 second buffer)\n const expiresAt = new Date(auth.expiresAt);\n const now = new Date();\n const bufferMs = 30 * 1000; // 30 seconds\n\n if (expiresAt.getTime() - now.getTime() > bufferMs) {\n return false; // Token is still fresh enough\n }\n\n // Refresh the token\n logger.dim('Refreshing token before operation...');\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n\n if (!refreshed) {\n logger.warning('Could not refresh token.');\n return false;\n }\n\n // Save the new token\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n\n // Update the client's token if it supports it\n if (client.updateAccessToken) {\n client.updateAccessToken(refreshed.accessToken);\n logger.dim('Token refreshed');\n return true;\n }\n\n return false;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Factory for creating Farseer API client based on available authentication\n *\n * Priority:\n * 1. JWT token (from browser login) - try first\n * 2. API key (from config) - fallback if JWT fails or unavailable\n * 3. Prompt user to login - if nothing works\n */\n\nimport * as farseer from 'farseer-client';\nimport { FarseerService } from './farseerService';\nimport { FarseerApi } from './farseerApi';\nimport { getCredential, getUserAuth, isUserAuthValid, setUserAuth, generateBasePath } from './configService';\nimport { refreshAccessToken } from './farseerService';\nimport { logger } from '../utils/logger';\n\n/**\n * Check if an error is an authentication error (401/403)\n */\nexport function isAuthError(error: unknown): boolean {\n if (error instanceof Error) {\n const msg = error.message.toLowerCase();\n return msg.includes('401') || msg.includes('403') || msg.includes('unauthorized') || msg.includes('forbidden');\n }\n return false;\n}\n\n/**\n * Show a consistent \"please login\" message\n */\nexport function showLoginPrompt(tenant?: string): void {\n logger.error('Authentication required.');\n if (tenant) {\n logger.dim(`No valid credentials found for tenant \"${tenant}\".`);\n }\n logger.info('Run \"farseer login\" to authenticate via browser.');\n logger.dim('Or use \"farseer config set <tenant> --api-key <key>\" for API key auth.');\n}\n\nexport interface FileMetadata {\n uploadTime?: string; // ISO timestamp\n uploader?: {\n id: number;\n email: string;\n firstName: string;\n lastName: string;\n };\n size?: number;\n}\n\nexport interface RemoteFile {\n name: string;\n path: string;\n reference: string;\n metadata?: FileMetadata;\n}\n\n// Default file extensions to sync (scripts only)\nexport const DEFAULT_SCRIPT_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];\n\nimport { AppArgument, AppListItem, RemoteApp, ModelExport } from './farseerApi';\n\n// Common interface that both FarseerService and FarseerApi implement\nexport interface IFarseerClient {\n testConnection(): Promise<boolean>;\n getFilesFolder(): Promise<{ id: number; name: string; type: string } | null>;\n listFiles(folderPath?: string[]): Promise<RemoteFile[]>;\n getFileContent(reference: string): Promise<string>;\n getFileContentAsBuffer(reference: string): Promise<Buffer>;\n createFile(content: string | Buffer, fileName: string, folderPath?: string[]): Promise<void>;\n updateFile(reference: string, content: string | Buffer, fileName: string): Promise<void>;\n deleteFile(reference: string): Promise<void>;\n getFileByPath(filePath: string): Promise<RemoteFile | null>;\n getFileMetadata(reference: string): Promise<FileMetadata | null>;\n isTextFile(filename: string): boolean;\n isBinaryFile(filename: string): boolean;\n // Apps API methods\n listApps(): Promise<AppListItem[]>;\n getApp(referenceId: string): Promise<RemoteApp | null>;\n getAppByName(name: string): Promise<RemoteApp | null>;\n createApp(name: string): Promise<RemoteApp>;\n updateApp(referenceId: string, update: {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n scriptFileIds?: string[];\n }): Promise<RemoteApp>;\n deleteApp(referenceId: string): Promise<void>;\n getScriptFiles(): Promise<{ id: string; name: string }[]>;\n // Model export\n exportModel(): Promise<ModelExport>;\n // Token management (optional - only FarseerApi implements this)\n updateAccessToken?(newToken: string): void;\n}\n\nexport interface FarseerClientResult {\n client: IFarseerClient;\n authType: 'apiKey' | 'jwt';\n}\n\n/**\n * Get a Farseer client for the given organisation and tenant.\n * Tries JWT token first (supports apps), then falls back to API key.\n *\n * @param organisation - The organisation hostname (e.g., \"jgl\" for jgl.farseer.io)\n * @param tenant - Tenant name for X-TENANT-ID header (e.g., \"tt-hotels-hr-dev\")\n */\nexport async function getFarseerClient(organisation: string, tenant: string): Promise<FarseerClientResult | null> {\n // 1. Try JWT token from browser login first (supports apps sync)\n const auth = getUserAuth();\n if (auth) {\n // Check if token needs refresh\n let accessToken = auth.accessToken;\n if (!isUserAuthValid()) {\n logger.dim('Token expired, refreshing...');\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n if (!refreshed) {\n logger.warning('Could not refresh token. Please login again with: farseer login');\n // Fall through to API key\n } else {\n // Save refreshed token\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n accessToken = refreshed.accessToken;\n logger.dim('Token refreshed');\n }\n }\n\n if (isUserAuthValid()) {\n return {\n client: new FarseerApi(accessToken, organisation, tenant),\n authType: 'jwt',\n };\n }\n }\n\n // 2. Fall back to API key config\n const credential = getCredential(tenant);\n if (credential) {\n return {\n client: new FarseerService(credential),\n authType: 'apiKey',\n };\n }\n\n return null;\n}\n\n/**\n * Check what authentication methods are available\n */\nexport function getAvailableAuth(tenant: string): {\n hasApiKey: boolean;\n hasJwt: boolean;\n jwtValid: boolean;\n} {\n const credential = getCredential(tenant);\n const auth = getUserAuth();\n\n return {\n hasApiKey: !!credential,\n hasJwt: !!auth,\n jwtValid: isUserAuthValid(),\n };\n}\n\n/**\n * Get a Farseer client with automatic fallback and connection testing.\n * This is the recommended way to get a client for commands.\n *\n * Flow:\n * 1. Try JWT if available and valid\n * 2. If JWT fails or unavailable, try API key\n * 3. If nothing works, return null (caller should show login prompt)\n *\n * @param organisation - The organisation hostname (e.g., \"jgl\" for jgl.farseer.io)\n * @param tenant - Tenant name for X-TENANT-ID header (e.g., \"tt-hotels-hr-dev\")\n */\nexport async function getFarseerClientWithFallback(\n organisation: string,\n tenant: string\n): Promise<FarseerClientResult | null> {\n const auth = getUserAuth();\n const credential = getCredential(tenant);\n\n // 1. Try JWT token first\n if (auth) {\n let accessToken = auth.accessToken;\n\n // Refresh token if needed\n if (!isUserAuthValid()) {\n logger.dim('Token expired, refreshing...');\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n if (refreshed) {\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n accessToken = refreshed.accessToken;\n logger.dim('Token refreshed');\n }\n }\n\n if (isUserAuthValid()) {\n const jwtClient = new FarseerApi(accessToken, organisation, tenant);\n\n // Test JWT connection\n try {\n const connected = await jwtClient.testConnection();\n if (connected) {\n return { client: jwtClient, authType: 'jwt' };\n }\n } catch (error) {\n // JWT failed, will try API key\n logger.dim('JWT auth failed for this tenant, trying API key...');\n }\n }\n }\n\n // 2. Try API key\n if (credential) {\n const apiKeyClient = new FarseerService(credential);\n\n try {\n const connected = await apiKeyClient.testConnection();\n if (connected) {\n return { client: apiKeyClient, authType: 'apiKey' };\n }\n } catch {\n // API key also failed\n logger.dim('API key auth failed.');\n }\n }\n\n // 3. Nothing worked\n return null;\n}\n\n/**\n * Ensure the token is fresh and update the client if needed.\n * Call this before long-running operations to avoid token expiration.\n *\n * @returns true if token was refreshed, false if no refresh needed or API key auth\n */\nexport async function ensureFreshToken(client: IFarseerClient): Promise<boolean> {\n const auth = getUserAuth();\n if (!auth) {\n return false; // No JWT auth, probably using API key\n }\n\n // Check if token needs refresh (give 30 second buffer)\n const expiresAt = new Date(auth.expiresAt);\n const now = new Date();\n const bufferMs = 30 * 1000; // 30 seconds\n\n if (expiresAt.getTime() - now.getTime() > bufferMs) {\n return false; // Token is still fresh enough\n }\n\n // Refresh the token\n logger.dim('Refreshing token before operation...');\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n\n if (!refreshed) {\n logger.warning('Could not refresh token.');\n return false;\n }\n\n // Save the new token\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n\n // Update the client's token if it supports it\n if (client.updateAccessToken) {\n client.updateAccessToken(refreshed.accessToken);\n logger.dim('Token refreshed');\n return true;\n }\n\n return false;\n}\n\n/**\n * Get a native farseer-client FarseerClient instance.\n * This provides access to the full farseer-client API (export, import jobs, file creation, etc.)\n * that isn't available through the simplified IFarseerClient interface.\n *\n * Tries JWT first, then API key. Handles token refresh automatically.\n *\n * @param organisation - The organisation hostname (e.g., \"jgl\" for jgl.farseer.io)\n * @param tenant - Tenant name for X-TENANT-ID header\n */\nexport async function getNativeFarseerClient(\n organisation: string,\n tenant: string\n): Promise<farseer.FarseerClient | null> {\n const basePath = generateBasePath(organisation);\n\n // 1. Try JWT token first\n const auth = getUserAuth();\n if (auth) {\n let accessToken = auth.accessToken;\n\n if (!isUserAuthValid()) {\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n if (refreshed) {\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n accessToken = refreshed.accessToken;\n }\n }\n\n if (isUserAuthValid()) {\n return new farseer.FarseerClient({\n basePath,\n headers: {\n 'X-TENANT-ID': tenant,\n 'Authorization': `Bearer ${accessToken}`,\n },\n });\n }\n }\n\n // 2. Try API key\n const credential = getCredential(tenant);\n if (credential) {\n return new farseer.FarseerClient({\n basePath: credential.basePath,\n headers: {\n 'X-TENANT-ID': credential.tenantId,\n 'X-API-KEY': credential.apiKey,\n },\n });\n }\n\n return null;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,cAAyB;AACzB,4BAA+B;AAC/B,wBAA2B;AAC3B,2BAA2F;AAC3F,IAAAA,yBAAmC;AACnC,oBAAuB;AAKhB,SAAS,YAAY,OAAyB;AACjD,MAAI,iBAAiB,OAAO;AACxB,UAAM,MAAM,MAAM,QAAQ,YAAY;AACtC,WAAO,IAAI,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,KAAK,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AAO,IAAI,QAAQ,cAAc;AAAA,QAC7B;AAAA,QACA,SAAS;AAAA,UACL,eAAe;AAAA,UACf,iBAAiB,UAAU,WAAW;AAAA,QAC1C;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,EACJ;AAGA,QAAM,iBAAa,oCAAc,MAAM;AACvC,MAAI,YAAY;AACZ,WAAO,IAAI,QAAQ,cAAc;AAAA,MAC7B,UAAU,WAAW;AAAA,MACrB,SAAS;AAAA,QACL,eAAe,WAAW;AAAA,QAC1B,aAAa,WAAW;AAAA,MAC5B;AAAA,IACJ,CAAC;AAAA,EACL;AAEA,SAAO;AACX;",
|
|
6
6
|
"names": ["import_farseerService"]
|
|
7
7
|
}
|
package/dist/utils/constants.js
CHANGED
|
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var constants_exports = {};
|
|
19
19
|
__export(constants_exports, {
|
|
20
20
|
CLI_GIT_AUTHOR: () => CLI_GIT_AUTHOR,
|
|
21
|
+
CLI_VERSION: () => CLI_VERSION,
|
|
21
22
|
FARSEER_CLIENT_AXIOS_URL: () => FARSEER_CLIENT_AXIOS_URL,
|
|
22
23
|
FARSEER_CLIENT_URL: () => FARSEER_CLIENT_URL,
|
|
23
24
|
KEYCLOAK_CLIENT_ID: () => KEYCLOAK_CLIENT_ID,
|
|
@@ -26,6 +27,7 @@ __export(constants_exports, {
|
|
|
26
27
|
SCRIPT_EXTENSIONS: () => SCRIPT_EXTENSIONS
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(constants_exports);
|
|
30
|
+
const CLI_VERSION = "1.0.5";
|
|
29
31
|
const FARSEER_CLIENT_URL = "https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar";
|
|
30
32
|
const FARSEER_CLIENT_AXIOS_URL = "https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar";
|
|
31
33
|
const KEYCLOAK_TOKEN_URL = "https://login.farseer.io/auth/realms/master/protocol/openid-connect/token";
|
|
@@ -36,6 +38,7 @@ const CLI_GIT_AUTHOR = "Farseer CLI <cli@farseer.io>";
|
|
|
36
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
39
|
0 && (module.exports = {
|
|
38
40
|
CLI_GIT_AUTHOR,
|
|
41
|
+
CLI_VERSION,
|
|
39
42
|
FARSEER_CLIENT_AXIOS_URL,
|
|
40
43
|
FARSEER_CLIENT_URL,
|
|
41
44
|
KEYCLOAK_CLIENT_ID,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/constants.ts"],
|
|
4
|
-
"sourcesContent": ["// Farseer client package URLs - update these when new versions are released\nexport const FARSEER_CLIENT_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar';\nexport const FARSEER_CLIENT_AXIOS_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar';\n\n// Keycloak auth configuration\nexport const KEYCLOAK_TOKEN_URL = 'https://login.farseer.io/auth/realms/master/protocol/openid-connect/token';\nexport const KEYCLOAK_CLIENT_ID = 'security-admin-console';\n\n// Default paths\nexport const SCRIPTS_FOLDER_PATH = ['Files', 'Scripts'];\n\n// Supported script file extensions\nexport const SCRIPT_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];\n\n// Git commit author for CLI-generated commits\nexport const CLI_GIT_AUTHOR = 'Farseer CLI <cli@farseer.io>';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;AAGjC,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAG3B,MAAM,sBAAsB,CAAC,SAAS,SAAS;AAG/C,MAAM,oBAAoB,CAAC,OAAO,OAAO,QAAQ,MAAM;AAGvD,MAAM,iBAAiB;",
|
|
4
|
+
"sourcesContent": ["// CLI version - update this when publishing new version\nexport const CLI_VERSION = '1.0.5';\n\n// Farseer client package URLs - update these when new versions are released\nexport const FARSEER_CLIENT_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar';\nexport const FARSEER_CLIENT_AXIOS_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar';\n\n// Keycloak auth configuration\nexport const KEYCLOAK_TOKEN_URL = 'https://login.farseer.io/auth/realms/master/protocol/openid-connect/token';\nexport const KEYCLOAK_CLIENT_ID = 'security-admin-console';\n\n// Default paths\nexport const SCRIPTS_FOLDER_PATH = ['Files', 'Scripts'];\n\n// Supported script file extensions\nexport const SCRIPT_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];\n\n// Git commit author for CLI-generated commits\nexport const CLI_GIT_AUTHOR = 'Farseer CLI <cli@farseer.io>';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,MAAM,cAAc;AAGpB,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;AAGjC,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAG3B,MAAM,sBAAsB,CAAC,SAAS,SAAS;AAG/C,MAAM,oBAAoB,CAAC,OAAO,OAAO,QAAQ,MAAM;AAGvD,MAAM,iBAAiB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
package/dist/commands/app.d.ts
DELETED
package/dist/commands/apps.d.ts
DELETED
package/dist/commands/diff.d.ts
DELETED
package/dist/commands/list.d.ts
DELETED
package/dist/commands/login.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Server Command
|
|
3
|
-
*
|
|
4
|
-
* Starts the Farseer MCP (Model Context Protocol) server for AI assistant integration.
|
|
5
|
-
* This allows Claude, Cursor, and other AI assistants to directly use Farseer functionality.
|
|
6
|
-
*/
|
|
7
|
-
import { Command } from 'commander';
|
|
8
|
-
export declare function registerMcpServerCommand(program: Command): void;
|
package/dist/commands/model.d.ts
DELETED
package/dist/commands/pull.d.ts
DELETED
package/dist/commands/push.d.ts
DELETED
package/dist/commands/run.d.ts
DELETED
package/dist/commands/setup.d.ts
DELETED
package/dist/commands/setup.js
DELETED
|
@@ -1,137 +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.registerSetupCommand = registerSetupCommand;
|
|
37
|
-
const logger_1 = require("../utils/logger");
|
|
38
|
-
const configService_1 = require("../services/configService");
|
|
39
|
-
const helpers_1 = require("../utils/helpers");
|
|
40
|
-
const fs = __importStar(require("fs"));
|
|
41
|
-
const path = __importStar(require("path"));
|
|
42
|
-
function registerSetupCommand(program) {
|
|
43
|
-
program
|
|
44
|
-
.command('setup <tenant> [file]')
|
|
45
|
-
.description('Inject credentials into script(s) for local development')
|
|
46
|
-
.option('--all', 'Inject credentials into all scripts')
|
|
47
|
-
.action(async (tenant, file, options) => {
|
|
48
|
-
const credential = (0, configService_1.getCredential)(tenant);
|
|
49
|
-
if (!credential) {
|
|
50
|
-
logger_1.logger.error(`No credentials found for tenant: ${tenant}`);
|
|
51
|
-
logger_1.logger.dim((0, helpers_1.getCredentialsHint)(tenant));
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
const srcDir = (0, helpers_1.getTenantSrcDir)(tenant);
|
|
55
|
-
if (!fs.existsSync(srcDir)) {
|
|
56
|
-
logger_1.logger.error(`Source folder not found: apps/${tenant}/src/`);
|
|
57
|
-
logger_1.logger.dim('Run "farseer pull <tenant>" first.');
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
// Must specify either a file or --all
|
|
61
|
-
if (!file && !options.all) {
|
|
62
|
-
logger_1.logger.error('Please specify a file or use --all for all files.');
|
|
63
|
-
logger_1.logger.dim('Usage: farseer setup <tenant> <file>');
|
|
64
|
-
logger_1.logger.dim(' or: farseer setup <tenant> --all');
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
const credentialConfig = {
|
|
68
|
-
basePath: credential.basePath,
|
|
69
|
-
tenantId: credential.tenantId,
|
|
70
|
-
apiKey: credential.apiKey,
|
|
71
|
-
};
|
|
72
|
-
if (options.all) {
|
|
73
|
-
// Process all files
|
|
74
|
-
const files = (0, helpers_1.getAllFiles)(srcDir);
|
|
75
|
-
let injectedCount = 0;
|
|
76
|
-
let alreadySetup = 0;
|
|
77
|
-
let noClientFound = 0;
|
|
78
|
-
for (const f of files) {
|
|
79
|
-
const filePath = path.join(srcDir, f);
|
|
80
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
81
|
-
const modified = (0, helpers_1.injectCredentials)(content, credentialConfig);
|
|
82
|
-
if (modified !== content) {
|
|
83
|
-
fs.writeFileSync(filePath, modified);
|
|
84
|
-
injectedCount++;
|
|
85
|
-
logger_1.logger.success(`Setup: ${f}`);
|
|
86
|
-
}
|
|
87
|
-
else if (content.includes('X-API-KEY')) {
|
|
88
|
-
alreadySetup++;
|
|
89
|
-
}
|
|
90
|
-
else if (!content.includes('FarseerClient')) {
|
|
91
|
-
// No FarseerClient in this file - skip silently
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
noClientFound++;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
console.log();
|
|
98
|
-
if (injectedCount > 0) {
|
|
99
|
-
logger_1.logger.success(`Injected credentials into ${injectedCount} file(s).`);
|
|
100
|
-
}
|
|
101
|
-
if (alreadySetup > 0) {
|
|
102
|
-
logger_1.logger.dim(`${alreadySetup} file(s) already have credentials.`);
|
|
103
|
-
}
|
|
104
|
-
if (injectedCount === 0 && alreadySetup === 0) {
|
|
105
|
-
logger_1.logger.warning('No FarseerClient() found to inject credentials into.');
|
|
106
|
-
logger_1.logger.dim('Looking for: const farseerClient = new farseer.FarseerClient();');
|
|
107
|
-
logger_1.logger.dim(' or: const fClient = new farseer.FarseerClient();');
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
// Process single file
|
|
112
|
-
const filePath = path.join(srcDir, file);
|
|
113
|
-
if (!fs.existsSync(filePath)) {
|
|
114
|
-
logger_1.logger.error(`File not found: ${filePath}`);
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
118
|
-
// Check if already has credentials
|
|
119
|
-
if (content.includes('X-API-KEY')) {
|
|
120
|
-
logger_1.logger.warning(`File already has credentials: ${file}`);
|
|
121
|
-
logger_1.logger.dim('Use "farseer unsetup" first if you want to re-inject.');
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const modified = (0, helpers_1.injectCredentials)(content, credentialConfig);
|
|
125
|
-
if (modified === content) {
|
|
126
|
-
logger_1.logger.warning('No FarseerClient() found to inject credentials into.');
|
|
127
|
-
logger_1.logger.dim('Looking for: const farseerClient = new farseer.FarseerClient();');
|
|
128
|
-
logger_1.logger.dim(' or: const fClient = new farseer.FarseerClient();');
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
fs.writeFileSync(filePath, modified);
|
|
132
|
-
logger_1.logger.success(`Credentials injected into: ${file}`);
|
|
133
|
-
logger_1.logger.dim('You can now run and debug this script locally.');
|
|
134
|
-
logger_1.logger.dim(`Run "farseer unsetup ${tenant} ${file}" before pushing.`);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
package/dist/commands/unsetup.js
DELETED
|
@@ -1,122 +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.registerUnsetupCommand = registerUnsetupCommand;
|
|
37
|
-
const logger_1 = require("../utils/logger");
|
|
38
|
-
const configService_1 = require("../services/configService");
|
|
39
|
-
const helpers_1 = require("../utils/helpers");
|
|
40
|
-
const fs = __importStar(require("fs"));
|
|
41
|
-
const path = __importStar(require("path"));
|
|
42
|
-
function registerUnsetupCommand(program) {
|
|
43
|
-
program
|
|
44
|
-
.command('unsetup <tenant> [file]')
|
|
45
|
-
.description('Remove credentials from script(s) before pushing')
|
|
46
|
-
.option('--all', 'Remove credentials from all scripts')
|
|
47
|
-
.action(async (tenant, file, options) => {
|
|
48
|
-
const credential = (0, configService_1.getCredential)(tenant);
|
|
49
|
-
if (!credential) {
|
|
50
|
-
logger_1.logger.error(`No credentials found for tenant: ${tenant}`);
|
|
51
|
-
logger_1.logger.dim((0, helpers_1.getCredentialsHint)(tenant));
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
const srcDir = (0, helpers_1.getTenantSrcDir)(tenant);
|
|
55
|
-
if (!fs.existsSync(srcDir)) {
|
|
56
|
-
logger_1.logger.error(`Source folder not found: apps/${tenant}/src/`);
|
|
57
|
-
logger_1.logger.dim('Run "farseer pull <tenant>" first.');
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
// Must specify either a file or --all
|
|
61
|
-
if (!file && !options.all) {
|
|
62
|
-
logger_1.logger.error('Please specify a file or use --all for all files.');
|
|
63
|
-
logger_1.logger.dim('Usage: farseer unsetup <tenant> <file>');
|
|
64
|
-
logger_1.logger.dim(' or: farseer unsetup <tenant> --all');
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
if (options.all) {
|
|
68
|
-
// Process all files
|
|
69
|
-
const files = (0, helpers_1.getAllFiles)(srcDir);
|
|
70
|
-
let strippedCount = 0;
|
|
71
|
-
let alreadyClean = 0;
|
|
72
|
-
for (const f of files) {
|
|
73
|
-
const filePath = path.join(srcDir, f);
|
|
74
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
75
|
-
const modified = (0, helpers_1.stripCredentials)(content);
|
|
76
|
-
if (modified !== content) {
|
|
77
|
-
fs.writeFileSync(filePath, modified);
|
|
78
|
-
strippedCount++;
|
|
79
|
-
logger_1.logger.success(`Unsetup: ${f}`);
|
|
80
|
-
}
|
|
81
|
-
else if (content.includes('FarseerClient()')) {
|
|
82
|
-
alreadyClean++;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
console.log();
|
|
86
|
-
if (strippedCount > 0) {
|
|
87
|
-
logger_1.logger.success(`Removed credentials from ${strippedCount} file(s).`);
|
|
88
|
-
logger_1.logger.dim('Files are now ready to push.');
|
|
89
|
-
}
|
|
90
|
-
if (alreadyClean > 0) {
|
|
91
|
-
logger_1.logger.dim(`${alreadyClean} file(s) already clean (no credentials).`);
|
|
92
|
-
}
|
|
93
|
-
if (strippedCount === 0 && alreadyClean === 0) {
|
|
94
|
-
logger_1.logger.info('No files with injected credentials found.');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
// Process single file
|
|
99
|
-
const filePath = path.join(srcDir, file);
|
|
100
|
-
if (!fs.existsSync(filePath)) {
|
|
101
|
-
logger_1.logger.error(`File not found: ${filePath}`);
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
105
|
-
// Check if has credentials to remove
|
|
106
|
-
if (!content.includes('X-API-KEY')) {
|
|
107
|
-
logger_1.logger.info(`File has no injected credentials: ${file}`);
|
|
108
|
-
logger_1.logger.dim('Nothing to unsetup.');
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const modified = (0, helpers_1.stripCredentials)(content);
|
|
112
|
-
if (modified === content) {
|
|
113
|
-
logger_1.logger.warning('Could not find credentials pattern to remove.');
|
|
114
|
-
logger_1.logger.dim('The file may have been manually modified.');
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
fs.writeFileSync(filePath, modified);
|
|
118
|
-
logger_1.logger.success(`Credentials removed from: ${file}`);
|
|
119
|
-
logger_1.logger.dim('File is now ready to push.');
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
package/dist/index.d.ts
DELETED
package/dist/mcp/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Documentation Resources
|
|
3
|
-
*
|
|
4
|
-
* Exposes Farseer documentation as MCP resources for AI assistants.
|
|
5
|
-
* Documentation is bundled as embedded strings to work when CLI is installed globally.
|
|
6
|
-
*/
|
|
7
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
-
export declare function registerDocumentationResources(server: McpServer): void;
|
package/dist/mcp/server.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Utility Functions
|
|
3
|
-
*
|
|
4
|
-
* Helper functions for MCP tools including tenant resolution and response formatting.
|
|
5
|
-
*/
|
|
6
|
-
import { IFarseerClient } from '../../services/farseerFactory';
|
|
7
|
-
/**
|
|
8
|
-
* Resolve tenant from argument or checkout state
|
|
9
|
-
*/
|
|
10
|
-
export declare function resolveTenant(tenantArg?: string): string | null;
|
|
11
|
-
/**
|
|
12
|
-
* Resolve organisation from argument or checkout state
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolveOrganisation(orgArg?: string, tenantArg?: string): string | null;
|
|
15
|
-
/**
|
|
16
|
-
* Get authenticated Farseer client
|
|
17
|
-
*/
|
|
18
|
-
export declare function getClient(tenant: string, tenantId?: string): Promise<IFarseerClient | null>;
|
|
19
|
-
/**
|
|
20
|
-
* Create a success response
|
|
21
|
-
*/
|
|
22
|
-
export declare function successResponse(data: Record<string, unknown>): {
|
|
23
|
-
content: Array<{
|
|
24
|
-
type: 'text';
|
|
25
|
-
text: string;
|
|
26
|
-
}>;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Create an error response
|
|
30
|
-
*/
|
|
31
|
-
export declare function errorResponse(message: string, errorCode?: 'AUTH_REQUIRED' | 'NOT_FOUND' | 'NETWORK_ERROR' | 'VALIDATION_ERROR' | 'UNKNOWN'): {
|
|
32
|
-
content: Array<{
|
|
33
|
-
type: 'text';
|
|
34
|
-
text: string;
|
|
35
|
-
}>;
|
|
36
|
-
isError: true;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Create auth required error response
|
|
40
|
-
*/
|
|
41
|
-
export declare function authRequiredResponse(tenant?: string): {
|
|
42
|
-
content: Array<{
|
|
43
|
-
type: 'text';
|
|
44
|
-
text: string;
|
|
45
|
-
}>;
|
|
46
|
-
isError: true;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Create tenant required error response
|
|
50
|
-
*/
|
|
51
|
-
export declare function tenantRequiredResponse(): {
|
|
52
|
-
content: Array<{
|
|
53
|
-
type: 'text';
|
|
54
|
-
text: string;
|
|
55
|
-
}>;
|
|
56
|
-
isError: true;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Get auth status info
|
|
60
|
-
*/
|
|
61
|
-
export declare function getAuthStatus(): {
|
|
62
|
-
jwtValid: boolean;
|
|
63
|
-
jwtExpiresAt?: string;
|
|
64
|
-
currentCheckout?: {
|
|
65
|
-
organisation: string;
|
|
66
|
-
tenant: string;
|
|
67
|
-
};
|
|
68
|
-
configuredTenants: string[];
|
|
69
|
-
};
|